AI協調開発研究ドキュメントの完成と Phase 10.9-β 進捗
【AI協調開発研究】 - AI二重化モデルの学術論文draft完成(workshop_paper_draft.md) - 「隠れた危機」分析とbirthの原則哲学化 - TyEnv「唯一の真実」協調会話を保存・研究資料に統合 - papers管理構造の整備(wip/under-review/published分離) 【Phase 10.9-β HostCall進捗】 - JitConfigBox: relax_numeric フラグ追加(i64→f64コアーション制御) - HostcallRegistryBox: 署名検証・白黒リスト・コアーション対応 - JitHostcallRegistryBox: Nyash側レジストリ操作API - Lower統合: env直読 → jit::config::current() 参照に統一 - 数値緩和設定: NYASH_JIT_HOSTCALL_RELAX_NUMERIC/Config.set_flag 【検証サンプル拡充】 - math.sin/cos/abs/min/max 関数スタイル(examples/jit_math_function_style_*.nyash) - 境界ケース: 署名不一致・コアーション許可・mutating拒否サンプル - E2E実証: String.length→allow, Array.push→fallback, math関数の署名一致観測 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
146
tools/codex-tmux-driver/codex-claude-auto-bridge.js
Normal file
146
tools/codex-tmux-driver/codex-claude-auto-bridge.js
Normal file
@ -0,0 +1,146 @@
|
||||
// codex-claude-auto-bridge.js
|
||||
// CodexとClaudeを自動で橋渡しするシステム
|
||||
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
const TmuxCodexController = require('./tmux-codex-controller');
|
||||
const CodexOutputWatcher = require('./codex-output-watcher');
|
||||
|
||||
class CodexClaudeAutoBridge {
|
||||
constructor(config = {}) {
|
||||
this.config = {
|
||||
sessionName: config.sessionName || 'codex-safe',
|
||||
outputFile: config.outputFile || './codex-response.txt',
|
||||
logFile: config.logFile || './bridge.log',
|
||||
watchInterval: config.watchInterval || 500,
|
||||
...config
|
||||
};
|
||||
|
||||
this.controller = new TmuxCodexController(this.config.sessionName);
|
||||
this.watcher = new CodexOutputWatcher(this.config.sessionName);
|
||||
this.isRunning = false;
|
||||
}
|
||||
|
||||
// ブリッジを開始
|
||||
async start() {
|
||||
console.log('🌉 Starting Codex-Claude Auto Bridge...');
|
||||
this.isRunning = true;
|
||||
|
||||
// 出力ウォッチャーのイベント設定
|
||||
this.watcher.on('response', async (response) => {
|
||||
await this.handleCodexResponse(response);
|
||||
});
|
||||
|
||||
this.watcher.on('ready', () => {
|
||||
console.log('💚 Codex is ready for next input');
|
||||
});
|
||||
|
||||
// 監視開始
|
||||
this.watcher.start(this.config.watchInterval);
|
||||
|
||||
await this.log('Bridge started');
|
||||
}
|
||||
|
||||
// Codexの応答を処理
|
||||
async handleCodexResponse(response) {
|
||||
console.log('\n📝 Got Codex response!');
|
||||
|
||||
// 応答をファイルに保存(Claudeが読めるように)
|
||||
await this.saveResponse(response);
|
||||
|
||||
// ログに記録
|
||||
await this.log(`Codex response: ${response.substring(0, 100)}...`);
|
||||
|
||||
// 通知
|
||||
console.log('✅ Response saved to:', this.config.outputFile);
|
||||
console.log('📢 Please read the response file and send next message to Codex!');
|
||||
|
||||
// 自動応答モードの場合(オプション)
|
||||
if (this.config.autoReply) {
|
||||
await this.sendAutoReply();
|
||||
}
|
||||
}
|
||||
|
||||
// 応答をファイルに保存
|
||||
async saveResponse(response) {
|
||||
const timestamp = new Date().toISOString();
|
||||
const content = `=== Codex Response at ${timestamp} ===\n\n${response}\n\n`;
|
||||
|
||||
await fs.writeFile(this.config.outputFile, content);
|
||||
}
|
||||
|
||||
// Codexにメッセージを送信
|
||||
async sendToCodex(message) {
|
||||
console.log(`📤 Sending to Codex: "${message}"`);
|
||||
await this.controller.sendKeys(message, true); // Enterも送る
|
||||
await this.log(`Sent to Codex: ${message}`);
|
||||
}
|
||||
|
||||
// 自動応答(実験的)
|
||||
async sendAutoReply() {
|
||||
// 簡単な自動応答ロジック
|
||||
const replies = [
|
||||
"なるほど!それについてもう少し詳しく教えて",
|
||||
"いい感じだにゃ!次はどうする?",
|
||||
"了解!他に何か提案はある?"
|
||||
];
|
||||
|
||||
const reply = replies[Math.floor(Math.random() * replies.length)];
|
||||
|
||||
console.log(`🤖 Auto-replying in 3 seconds: "${reply}"`);
|
||||
setTimeout(async () => {
|
||||
await this.sendToCodex(reply);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// ログ記録
|
||||
async log(message) {
|
||||
const timestamp = new Date().toISOString();
|
||||
const logEntry = `[${timestamp}] ${message}\n`;
|
||||
|
||||
await fs.appendFile(this.config.logFile, logEntry);
|
||||
}
|
||||
|
||||
// 停止
|
||||
stop() {
|
||||
this.watcher.stop();
|
||||
this.isRunning = false;
|
||||
console.log('🛑 Bridge stopped');
|
||||
}
|
||||
}
|
||||
|
||||
// CLIとして使う場合
|
||||
if (require.main === module) {
|
||||
const bridge = new CodexClaudeAutoBridge({
|
||||
outputFile: './codex-response.txt',
|
||||
autoReply: false // 自動応答は無効
|
||||
});
|
||||
|
||||
// 引数からメッセージを取得
|
||||
const initialMessage = process.argv.slice(2).join(' ');
|
||||
|
||||
async function run() {
|
||||
// ブリッジ開始
|
||||
await bridge.start();
|
||||
|
||||
// 初期メッセージがあれば送信
|
||||
if (initialMessage) {
|
||||
console.log('📨 Sending initial message...');
|
||||
await bridge.sendToCodex(initialMessage);
|
||||
} else {
|
||||
console.log('💡 Send a message to Codex using:');
|
||||
console.log(' tmux send-keys -t codex-safe "your message" Enter');
|
||||
}
|
||||
|
||||
// Ctrl+Cで終了
|
||||
process.on('SIGINT', () => {
|
||||
console.log('\n👋 Shutting down...');
|
||||
bridge.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
run().catch(console.error);
|
||||
}
|
||||
|
||||
module.exports = CodexClaudeAutoBridge;
|
||||
Reference in New Issue
Block a user