@coda-console/codex 1.14.1 → 1.14.3

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.
@@ -110,10 +110,30 @@ export function startAccountBridge({ source = new AccountSource(accountSource())
110
110
  });
111
111
  async function close() { if (closing) return; closing = true; reader.close(); source.close(); await server.close(); }
112
112
  reader.on('close', () => void close());
113
- void server.exited.then(() => reader.close());
114
- return { close, server, settled: () => queue };
113
+ // `exit` is how the app-server ended, `{ code, signal, error? }`, when nothing here closed it: its process died. When the
114
+ // bridge was closed first (its client went away, or it was told to stop), the server ending is the close, and it is null.
115
+ let settleExit;
116
+ const exit = new Promise(resolve => { settleExit = resolve; });
117
+ void server.exited.then(result => { settleExit(closing ? null : result ?? { code: 0, signal: null }); void close(); });
118
+ return { close, server, settled: () => queue, exit };
115
119
  }
116
- if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
117
- const bridge = startAccountBridge();
118
- for (const signal of ['SIGTERM', 'SIGINT']) process.on(signal, () => void bridge.close());
120
+
121
+ // The bridge as a process: it ends as the app-server under it ended, by the same signal or with the same exit code, so what
122
+ // runs it (codex-acp, and Coda's exit patch there) sees how the Codex died rather than a clean exit.
123
+ export function runAccountBridge(options) {
124
+ const bridge = startAccountBridge(options);
125
+ const signals = ['SIGTERM', 'SIGINT'], stop = () => void bridge.close();
126
+ for (const signal of signals) process.on(signal, stop);
127
+ void bridge.exit.then(async result => {
128
+ if (!result) return;
129
+ await bridge.close();
130
+ if (result.error) process.stderr.write(`Codex 无法启动:${result.error.code || result.error.message}\n`);
131
+ if (result.signal) {
132
+ for (const signal of signals) process.off(signal, stop);
133
+ process.exitCode = 1;
134
+ process.kill(process.pid, result.signal);
135
+ } else process.exit(result.code ?? 1);
136
+ });
137
+ return bridge;
119
138
  }
139
+ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) runAccountBridge();
@@ -22,6 +22,7 @@
22
22
  "item:agentMessage.id": { "shown": true, "why": "作为 messageId" },
23
23
  "item:agentMessage.text": { "shown": true, "why": "正文" },
24
24
  "item:agentMessage.phase": { "shown": true, "why": "随增量作为 _meta.codex.phase,取值见下" },
25
+ "item:agentMessage.moderation": { "shown": false, "why": "服务端的消息审核元数据;codex-acp 不显示元数据" },
25
26
  "item:agentMessage.memoryCitation": { "shown": false, "why": "记忆的出处,codex-acp 不显示" },
26
27
  "item:agentMessage.delivery": { "shown": true, "why": "送达方式,取值见下;没有就是逐段发增量的普通回复" },
27
28
  "item:agentMessage.questions": { "shown": true, "why": "异步提问,作为这一轮的表单卡片(questions.mjs)" },
@@ -47,6 +48,7 @@
47
48
  "notification:thread/goal/cleared": { "shown": true, "why": "目标" },
48
49
  "notification:thread/queue/changed": { "shown": false, "why": "排队的消息由 Coda 自己管;codex-acp 忽略" },
49
50
  "notification:project/changed": { "shown": false, "why": "Codex 应用的项目;codex-acp 忽略" },
51
+ "notification:thread/section/changed": { "shown": false, "why": "Codex 应用的线程分区;Coda 自己管理会话列表,codex-acp 不处理" },
50
52
  "notification:thread/project/updated": { "shown": false, "why": "Codex 应用的项目;codex-acp 忽略" },
51
53
  "notification:thread/environment/connected": { "shown": false, "why": "远端执行环境;codex-acp 忽略" },
52
54
  "notification:thread/environment/disconnected": { "shown": false, "why": "远端执行环境;codex-acp 忽略" },
package/package.json CHANGED
@@ -3,13 +3,13 @@
3
3
  "id": "codex",
4
4
  "displayName": "Codex",
5
5
  "description": "用 OpenAI Codex 跑会话",
6
- "version": "1.14.1",
6
+ "version": "1.14.3",
7
7
  "categories": [
8
8
  "Agent"
9
9
  ],
10
10
  "dependencies": {
11
11
  "@agentclientprotocol/codex-acp": "1.12.0",
12
- "@openai/codex": "0.165.0"
12
+ "@openai/codex": "0.169.0"
13
13
  },
14
14
  "overrides": {
15
15
  "@agentclientprotocol/codex-acp": {
@@ -24,12 +24,15 @@ export class AppServer {
24
24
  if (message.error) waiter.reject(new Error(oneLine(message.error.message) || 'Codex 拒绝了请求'));
25
25
  else waiter.resolve(message.result);
26
26
  });
27
+ // Resolves how it ended: `{ code, signal }` as the process exited, or, if it could not be started at all (no such
28
+ // command), `{ code: 1, signal: null, error }`.
27
29
  this.exited = new Promise(resolve => {
28
- const done = () => {
30
+ const done = result => {
29
31
  for (const waiter of this.pending.values()) { clearTimeout(waiter.timer); waiter.reject(new Error('Codex 提前退出了')); }
30
- this.pending.clear(); resolve();
32
+ this.pending.clear(); resolve(result);
31
33
  };
32
- this.child.once('error', done); this.child.once('exit', done);
34
+ this.child.once('error', error => done({ code: 1, signal: null, error }));
35
+ this.child.once('exit', (code, signal) => done({ code, signal }));
33
36
  });
34
37
  }
35
38
  send(message) { this.child.stdin.write(`${JSON.stringify(message)}\n`); }