




















@@ -36,6 +36,7 @@ const describeLive = LIVE && ACP_BIND_LIVE ? describe : describe.skip;
36363737const CONNECT_TIMEOUT_MS = 90_000;
3838const LIVE_TIMEOUT_MS = 240_000;
39+const DEFAULT_LIVE_CODEX_MODEL = "gpt-5.4";
3940type LiveAcpAgent = "claude" | "codex" | "gemini";
40414142function createSlackCurrentConversationBindingRegistry() {
@@ -129,6 +130,32 @@ function logLiveStep(message: string): void {
129130console.info(`[live-acp-bind] ${message}`);
130131}
131132133+async function prepareCodexHomeForLiveBindTest(): Promise<void> {
134+const home = process.env.HOME?.trim();
135+if (!home) {
136+return;
137+}
138+const model = process.env.OPENCLAW_LIVE_ACP_BIND_CODEX_MODEL?.trim() || DEFAULT_LIVE_CODEX_MODEL;
139+const codexHome = path.join(home, ".codex");
140+await fs.mkdir(codexHome, { recursive: true });
141+const configPath = path.join(codexHome, "config.toml");
142+let rawConfig = "";
143+try {
144+rawConfig = await fs.readFile(configPath, "utf8");
145+} catch (error) {
146+if ((error as NodeJS.ErrnoException)?.code !== "ENOENT") {
147+throw error;
148+}
149+}
150+const modelLine = `model = ${JSON.stringify(model)}`;
151+const nextConfig = /^model\s*=.*$/m.test(rawConfig)
152+ ? rawConfig.replace(/^model\s*=.*$/m, modelLine)
153+ : `${modelLine}\n${rawConfig}`;
154+await fs.writeFile(configPath, nextConfig, "utf8");
155+process.env.CODEX_HOME = codexHome;
156+logLiveStep(`using Codex ACP model ${model}`);
157+}
158+132159async function waitForGatewayPort(params: {
133160host: string;
134161port: number;
@@ -414,6 +441,7 @@ describeLive("gateway live (ACP bind)", () => {
414441skipGmail: process.env.OPENCLAW_SKIP_GMAIL_WATCHER,
415442skipCron: process.env.OPENCLAW_SKIP_CRON,
416443skipCanvas: process.env.OPENCLAW_SKIP_CANVAS_HOST,
444+codexHome: process.env.CODEX_HOME,
417445};
418446const liveAgent = normalizeAcpAgent(process.env.OPENCLAW_LIVE_ACP_BIND_AGENT);
419447const agentCommandOverride =
@@ -438,6 +466,9 @@ describeLive("gateway live (ACP bind)", () => {
438466process.env.OPENCLAW_SKIP_CANVAS_HOST = "1";
439467process.env.OPENCLAW_GATEWAY_TOKEN = token;
440468process.env.OPENCLAW_GATEWAY_PORT = String(port);
469+if (liveAgent === "codex" && !agentCommandOverride) {
470+await prepareCodexHomeForLiveBindTest();
471+}
441472442473const cfg = loadConfig();
443474const acpxEntry = cfg.plugins?.entries?.acpx;
@@ -866,6 +897,11 @@ describeLive("gateway live (ACP bind)", () => {
866897} else {
867898process.env.OPENCLAW_SKIP_CANVAS_HOST = previous.skipCanvas;
868899}
900+if (previous.codexHome === undefined) {
901+delete process.env.CODEX_HOME;
902+} else {
903+process.env.CODEX_HOME = previous.codexHome;
904+}
869905}
870906},
871907LIVE_TIMEOUT_MS + 360_000,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。