@coda-console/codex 1.7.0 → 1.7.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.
@@ -51,11 +51,19 @@ export class ServiceModels {
51
51
  served(model) { return this.models.find(m => m.id === model) ?? null; }
52
52
  // What a turn names to Codex: the service's own name for one of its models.
53
53
  wire(model) { return this.served(model)?.model ?? model; }
54
+ // A stop that comes while a turn waits on the move has no turn of codex-acp's to interrupt yet: it is the waiting turn's,
55
+ // which ends cancelled with its input not given (`route` says so).
56
+ cancel(sessionId) { if (this.moving === sessionId) this.stopped = true; }
57
+ async route(server, params) {
58
+ this.moving = params.sessionId; this.stopped = false;
59
+ try { await this.move(server, params); } finally { this.moving = null; }
60
+ return this.stopped;
61
+ }
54
62
  // Before a turn of codex-acp's `server`: the session on the provider of its model, its thread resumed with Coda's
55
63
  // instructions as it was opened. A thread nothing was said in yet is not written down, and would not be resumed after the
56
64
  // restart: naming it, by what it is first told, writes it. A move that failed is made again from the restart, on which
57
65
  // codex-acp has a client again; the thread was written down before it.
58
- async route(server, { sessionId, prompt }) {
66
+ async move(server, { sessionId, prompt }) {
59
67
  const state = server.sessions.get(sessionId);
60
68
  if (!state) return;
61
69
  const served = this.served(state.currentModelId.replace(/\[[^\]]*\]$/, '')), wanted = served ? this.service.url : null;
@@ -85,7 +93,10 @@ const patches = [
85
93
  [' } while (cursor);\n return models;\n }', ' } while (cursor);\n return [...models, ...await codaServices.list()];\n }', 1],
86
94
  // A turn first moves the session to the provider of its model, and names the model as that provider does.
87
95
  [' async prompt(params, signal, onTurnStarted) {\n if (this.providerUpdate !== null) {',
88
- ' async prompt(params, signal, onTurnStarted) {\n await codaServices.route(this, params);\n if (this.providerUpdate !== null) {', 1],
96
+ ' async prompt(params, signal, onTurnStarted) {\n if (await codaServices.route(this, params)) return { stopReason: "cancelled" };\n if (this.providerUpdate !== null) {', 1],
97
+ // A stop while the session moves is the moving turn's.
98
+ [' async cancel(params) {\n const sessionState = this.sessions.get(params.sessionId);',
99
+ ' async cancel(params) {\n codaServices.cancel(params.sessionId);\n const sessionState = this.sessions.get(params.sessionId);', 1],
89
100
  [' model: modelId.model,\n serviceTier\n }, onTurnStarted);', ' model: codaServices.wire(modelId.model),\n serviceTier\n }, onTurnStarted);', 1],
90
101
  [' case "warning":\n return this.createWarningEvent(notification.params);',
91
102
  ' case "warning":\n if (codaServices.quiet(notification.params)) return null;\n return this.createWarningEvent(notification.params);', 1],
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.7.0",
6
+ "version": "1.7.1",
7
7
  "dependencies": {
8
8
  "@agentclientprotocol/codex-acp": "1.12.0",
9
9
  "@openai/codex": "0.162.1"