@coda-console/codex 1.8.7 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/agent/entry.mjs CHANGED
@@ -26,10 +26,11 @@ import { CodexReviews } from './reviews.mjs';
26
26
  import { explainCodexError, reportedCodexFailures } from './errors.mjs';
27
27
  import { reportedCodexSleeps } from './sleep.mjs';
28
28
  import { codexDisplayNames } from './display.mjs';
29
+ import { trustedCodaMcpRequests } from './mcp-policy.mjs';
29
30
 
30
31
  const env = process.env;
31
- // A session starts read-only, unless its machine's configuration says otherwise.
32
- env.INITIAL_AGENT_MODE ??= 'read-only';
32
+ // Coda owns the permission boundary. An explicit launch mode or later ACP selection still wins.
33
+ env.INITIAL_AGENT_MODE ??= 'agent-full-access';
33
34
  // The Codex this session runs, as the handshake's `agentInfo` names it (Coda's protocol「Agent 版本」): the connection's own
34
35
  // program when it sets one, else the plugin's locked @openai/codex.
35
36
  const own = env.CODEX_PATH;
@@ -66,6 +67,6 @@ registerHooks({ load(url, context, nextLoad) {
66
67
  const loaded = nextLoad(url, context);
67
68
  if (url !== adapter.href) return loaded;
68
69
  return { ...loaded, source: reportedCodexSleeps(reportedCodexFailures(codexOptionsAsShown(relayedCodexStreams(orderedCodexTitles(followCodexProcessExit(continuedCodexSubagents(
69
- promptRequiredCodexSteering(instructedCodexThreads(servedCodexModels(networkedCodexDevelopment(Buffer.from(loaded.source).toString('utf8')))))))))))) };
70
+ promptRequiredCodexSteering(instructedCodexThreads(servedCodexModels(networkedCodexDevelopment(trustedCodaMcpRequests(Buffer.from(loaded.source).toString('utf8'))))))))))))) };
70
71
  } });
71
72
  await import(adapter.href);
@@ -0,0 +1,24 @@
1
+ import { isAbsolute, sep } from 'node:path';
2
+
3
+ // ACP is the trusted host boundary: Coda reserves the server name `coda` and supplies this stdio shim itself
4
+ // (backend/src/components/session-config/service.mjs). Do not infer trust from a Codex config entry of the same name.
5
+ // The shape check limits the exception to the current Coda transport, not arbitrary HTTP or plugin MCP servers.
6
+ export function codaMcpPolicy(server, config) {
7
+ const args = config.args;
8
+ if (server.name !== 'coda' || 'type' in server || config.command !== process.execPath ||
9
+ !Array.isArray(args) || args.length !== 5 || typeof args[0] !== 'string' || !isAbsolute(args[0]) ||
10
+ !args[0].endsWith(`${sep}src${sep}adapters${sep}mcp-shim.mjs`) ||
11
+ args[1] !== '--thread' || typeof args[2] !== 'string' || !args[2] ||
12
+ args[3] !== '--socket' || typeof args[4] !== 'string' || !isAbsolute(args[4])) return config;
13
+ // All tools of Coda's own server, including workflow_run/approve-command, must reach Coda's permission boundary.
14
+ // This approves the MCP request, not the command or human decision it asks Coda to handle.
15
+ return { ...config, default_tools_approval_mode: 'approve' };
16
+ }
17
+
18
+ const before = ' "mcp_servers": Object.fromEntries(serversToConfigure.map((mcp) => [mcp.name, this.createMcpSeverConfig(mcp.server)]))';
19
+ export function trustedCodaMcpRequests(source) {
20
+ if (source.split(before).length !== 2) throw new Error('codex-acp MCP approval patch no longer matches the locked adapter');
21
+ // Apply after codex-acp's name deduplication: a native configured server it selected keeps its own policy.
22
+ return `import { codaMcpPolicy } from ${JSON.stringify(import.meta.url)};\n${source.replace(/^#![^\n]*\n/, '').replace(before,
23
+ ' "mcp_servers": Object.fromEntries(serversToConfigure.map((mcp) => [mcp.name, codaMcpPolicy(mcp.server, this.createMcpSeverConfig(mcp.server))]))')}`;
24
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "id": "codex",
4
4
  "displayName": "Codex",
5
5
  "description": "Codex Agent:Coda 自带的入口运行 codex-acp,报告子 Agent、后台命令与命令的自动审核。额度与登录由账号来源插件接管;未接入账号来源时使用 Codex 自己的登录面板。",
6
- "version": "1.8.7",
6
+ "version": "1.9.1",
7
7
  "categories": [
8
8
  "Agent"
9
9
  ],
@@ -28,7 +28,8 @@
28
28
  "command": "exec \"$CODA_NODE\" \"$CODA_PLUGIN_PATH/agent/entry.mjs\"",
29
29
  "modes": {
30
30
  "title": "审批模式",
31
- "unset": "人工审批",
31
+ "unset": "Agent 默认",
32
+ "note": "未选择时为完全访问。",
32
33
  "auto": "agent",
33
34
  "full": "agent-full-access"
34
35
  },