@coda-console/claude 1.12.1 → 1.12.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.
- package/README.md +26 -0
- package/agent/known-tools.json +5 -0
- package/agent/registry.mjs +1 -0
- package/agent/session.mjs +18 -3
- package/agent/waits.mjs +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Claude SDK Agent:Coda 基于 Claude Agent SDK 写的 ACP 入口,一个进程一个 SDK 会话;资源页的「Claude」显示会话报告的额度,可从 Coda 登录。
|
|
4
4
|
|
|
5
|
+
## MCP 配置不进命令行
|
|
6
|
+
|
|
7
|
+
Coda 交来的 MCP 服务(含 `coda` 服务 `env` 里的令牌 `CODA_TOKEN`)若交给 SDK 的 `mcpServers`,会被写成 `--mcp-config '<JSON>'` 放进 Claude 进程的命令行参数,同一台机器上别的用户看得见。
|
|
8
|
+
入口改为:会话打开时在系统临时目录下 `mkdtemp` 建目录(0700),把 `{ mcpServers }` 写进里面的 `mcp.json`(0600),用 `extraArgs` 交 `--mcp-config <路径>`。
|
|
9
|
+
入口这一侧,令牌不再进命令行,只写进这个文件;会话结束(进程被关、查询自己结束)时连目录一起删。进程崩溃留下的目录不另外清理:令牌随托管记录作废,系统临时目录也会自己回收。没有 MCP 服务的会话不建目录。
|
|
10
|
+
|
|
5
11
|
## 认不出的东西
|
|
6
12
|
|
|
7
13
|
Claude Code 会自己长出新东西:SDK 升级带来新的消息类型,服务端让模型返回新的内容块,模型多了新的原生工具。
|
|
@@ -32,3 +38,23 @@ Claude Code 会自己长出新东西:SDK 升级带来新的消息类型,服
|
|
|
32
38
|
检查读不出声明时,按报错补读法或改登记,不要跳过。
|
|
33
39
|
3. 用新 SDK 跑一轮真实会话,把新出现的原生工具加进 `agent/known-tools.json`(会话里没登记的工具会报成 `tool:<名字>`,遥测按 Agent 版本计数);
|
|
34
40
|
要按读写、命令等显示的,同时在 `agent/tools.mjs` 里归类。
|
|
41
|
+
|
|
42
|
+
### SDK 0.3.312 → 0.3.322(2026-11-13)
|
|
43
|
+
|
|
44
|
+
依据 npm 发布包的 `sdk.d.ts` 对比和 [SDK CHANGELOG](https://github.com/anthropics/claude-agent-sdk-typescript/blob/main/CHANGELOG.md);消息联合只新增 `system/session_writes_lost`,内容块类型无新增。保持升级前功能,不打开新的开关。
|
|
45
|
+
|
|
46
|
+
| 新消息、事件或字段 | 去向 |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `system/session_writes_lost`;`error_code: ENOSPC/EDQUOT`、`lost: transcript/global_config`、`transcript_session_ids` | `registry.mjs` 登记为有意忽略。SDK 明确允许忽略;已收到的结果不变,Coda 自己的记录照旧,不将其报为没适配。 |
|
|
49
|
+
| `task_type: mcp_task` | `waits.mjs` 的普通 `task`(与 `local_bash` 一样),沿用开始、转后台、快照、结束、停止;不打开 `CLAUDE_AUTO_BACKGROUND_TASKS`。 |
|
|
50
|
+
| result 的 `credential_expires_at`(成功与失败均可带) | 有意不消费;登录仍由现有认证及资源路径管理,不增加到期时间展示或跨层参数。 |
|
|
51
|
+
| `startup_failure_reason: sandbox_required_unavailable / initialize_not_first / config_file_invalid` | 仍按 `result/error_during_execution` 处理,`errors` 原文经 `errorText`、`claudeFailure` 报执行失败;不额外按原因改变重试策略。 |
|
|
52
|
+
| hook 回调失败的 warning | 既有 `system/notification` 登记为运行机通知、有意不显示;不启用新增 `HookCallbackMatcher.onFailure: block`。默认 `continue` 不变。 |
|
|
53
|
+
| `agentProgressSummaries` 延后或省略摘要 | 既有 `system/task_progress` 有意忽略;等待项靠生命周期,不靠心跳或摘要。 |
|
|
54
|
+
| control initialize 的 `hook_on_failure_supported`;响应的 `pending_elicitation_requests` | SDK 控制层使用;插件只取模型、命令、账号,不自行接管控制响应或重放表单。现有表单继续经 `onElicitation`。 |
|
|
55
|
+
| `set_has_subscribers` 控制请求、MCP call 的 `check_permissions`、readFile 的 `lossy` | 控制层接口,插件不调用;不增加订阅、直接 MCP 调用或文件读取功能。 |
|
|
56
|
+
| 真实会话 init 的 `ArtifactComments / ArtifactData / DesignSync / SendToProject / SendToProjectContext` | 补进 `known-tools.json`;沿用通用工具调用及结果,不误报未适配。发布包 `BUILTIN_TOOL_NAMES` 两版相比没有新增名。 |
|
|
57
|
+
| `TaskCreate` 结果的 `task.description`;Read 不再返回 `file_unchanged` | 沿用 `tool_result` 的既有工具结果处理,不按这些字段分支。 |
|
|
58
|
+
| `prewarm` 进入 `/core`;`Settings.permissions.blockWritesOutsideWorkingDirectories / blockReadsExemptPaths / workingDirectoriesAsGiven / denyInsteadOfPrompting`、`disableReplyCheck / disableWindowsBashCommandSplit`;`PushNotificationInput.status` 可省略 | 有意不启用;继续使用现有 `query`、Stop hook 和设置。 |
|
|
59
|
+
|
|
60
|
+
ACP 2.6.0 只使用默认 stable v1。逐项经过真实连接的解析测试:`initialize` 保留 `clientCapabilities._meta.coda.unrecognized`;`new/load` 保留目录、MCP 配置及其环境变量、`systemPrompt`、`_meta`;`prompt` 保留文本及内容块的 `_meta`;配置值与模式照常到达处理器;`_session/steering`、`_coda/wait/stop`、`_coda/session/compact` 沿用原自有解析器。未发现 Coda 用到的字段被新版裁掉,因而没有新增解析器。`new/load` 原注释中“schema 不认识 systemPrompt”在 2.6.0 已不成立。
|
package/agent/known-tools.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
[
|
|
2
2
|
"Agent",
|
|
3
3
|
"Artifact",
|
|
4
|
+
"ArtifactComments",
|
|
5
|
+
"ArtifactData",
|
|
4
6
|
"AskUserQuestion",
|
|
5
7
|
"Bash",
|
|
6
8
|
"BashOutput",
|
|
7
9
|
"CronCreate",
|
|
8
10
|
"CronDelete",
|
|
9
11
|
"CronList",
|
|
12
|
+
"DesignSync",
|
|
10
13
|
"Edit",
|
|
11
14
|
"EnterPlanMode",
|
|
12
15
|
"EnterWorktree",
|
|
@@ -31,6 +34,8 @@
|
|
|
31
34
|
"ReportFindings",
|
|
32
35
|
"ScheduleWakeup",
|
|
33
36
|
"SendMessage",
|
|
37
|
+
"SendToProject",
|
|
38
|
+
"SendToProjectContext",
|
|
34
39
|
"Skill",
|
|
35
40
|
"Task",
|
|
36
41
|
"TaskCreate",
|
package/agent/registry.mjs
CHANGED
|
@@ -49,6 +49,7 @@ export const MESSAGES = {
|
|
|
49
49
|
'system/memory_recall': hidden('召回的记忆,已作为上下文交给模型'),
|
|
50
50
|
'system/elicitation_complete': hidden('链接表单完成的确认;表单本身经 onElicitation 转给 Coda'),
|
|
51
51
|
'system/permission_denied': hidden('被拒的工具调用;拒绝的原因在工具结果里,随工具调用显示'),
|
|
52
|
+
'system/session_writes_lost': hidden('本机记录未存盘(ENOSPC/EDQUOT;transcript/global_config),SDK 明确允许忽略;已收到的结果和 Coda 记录仍有效'),
|
|
52
53
|
'system/mirror_error': hidden('会话记录镜像(SessionStore)写入失败,入口不用镜像'),
|
|
53
54
|
'system/informational': hidden('终端里的提示行(状态、钩子的反馈),不是 Claude 说的话'),
|
|
54
55
|
tool_progress: hidden('工具运行中的心跳;工具调用本身照常显示'),
|
package/agent/session.mjs
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
// that is to go on later is compacted before its cache expires, as the plugin's lifecycle process asks (compaction.mjs).
|
|
8
8
|
// What the SDK sends that is not registered, and native tools not known, are told to Coda (registry.mjs).
|
|
9
9
|
import { randomUUID } from 'node:crypto';
|
|
10
|
-
import { readFileSync } from 'node:fs';
|
|
10
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
11
11
|
import { realpath, stat } from 'node:fs/promises';
|
|
12
|
+
import { tmpdir } from 'node:os';
|
|
12
13
|
import { join } from 'node:path';
|
|
13
14
|
import { agent, PROTOCOL_VERSION, RequestError } from '@agentclientprotocol/sdk';
|
|
14
15
|
import { ClaudeSessionLimits, accountHash } from './limits.mjs';
|
|
@@ -103,7 +104,7 @@ export class ClaudeSession {
|
|
|
103
104
|
agentCapabilities: { loadSession: true, sessionCapabilities: { additionalDirectories: {}, systemPrompt: {} }, _meta: { coda: { waits: {}, compact: {} } } },
|
|
104
105
|
_meta: { steering: { supported: true } } };
|
|
105
106
|
})
|
|
106
|
-
//
|
|
107
|
+
// Read these requests as sent: the SDK's own parsers drop fields its schema does not name.
|
|
107
108
|
.onRequest('session/new', params => params ?? {}, ({ params }) => this.open(params))
|
|
108
109
|
.onRequest('session/load', params => params ?? {}, ({ params }) => this.open(params, params.sessionId))
|
|
109
110
|
.onRequest('session/set_config_option', ({ params }) => this.configure(params.configId, params.value))
|
|
@@ -163,7 +164,7 @@ export class ClaudeSession {
|
|
|
163
164
|
// message would start a turn Coda cannot attribute. Continuing a native subagent is in-process and unaffected.
|
|
164
165
|
settings: { crossSessionInbound: 'refuse' },
|
|
165
166
|
includePartialMessages: true, forwardSubagentText: true, cwd: dir,
|
|
166
|
-
...(Object.keys(servers).length ? { mcpServers: servers } : {}), ...(additionalDirectories.length ? { additionalDirectories } : {}),
|
|
167
|
+
...(Object.keys(servers).length ? { extraArgs: { 'mcp-config': this.mcpConfig({ mcpServers: servers }) } } : {}), ...(additionalDirectories.length ? { additionalDirectories } : {}),
|
|
167
168
|
// Identify Coda even when a parent supplied an SDK label (anthropics/claude-code#97074).
|
|
168
169
|
// Claude Code reports running and idle only when asked: idle is what ends a task's wait.
|
|
169
170
|
env: { ...environment, CLAUDE_CODE_ENTRYPOINT: 'coda', CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: '1' },
|
|
@@ -196,6 +197,18 @@ export class ClaudeSession {
|
|
|
196
197
|
throw error instanceof RequestError ? error : failure(error?.message || 'Claude 会话启动失败');
|
|
197
198
|
}
|
|
198
199
|
}
|
|
200
|
+
// The SDK would put `mcpServers` in Claude's command line, where the servers' environment (Coda's token) shows to every user of
|
|
201
|
+
// the machine. They go in a file only this user reads, by path, which stays until the session ends (`dropMcpConfig`).
|
|
202
|
+
mcpConfig(config) {
|
|
203
|
+
this.mcpDir = mkdtempSync(join(tmpdir(), 'coda-claude-mcp-'));
|
|
204
|
+
const file = join(this.mcpDir, 'mcp.json');
|
|
205
|
+
writeFileSync(file, JSON.stringify(config), { mode: 0o600 });
|
|
206
|
+
return file;
|
|
207
|
+
}
|
|
208
|
+
dropMcpConfig() {
|
|
209
|
+
if (this.mcpDir) rmSync(this.mcpDir, { recursive: true, force: true });
|
|
210
|
+
this.mcpDir = null;
|
|
211
|
+
}
|
|
199
212
|
// A query of the session, reading a prompt stream of its own: on Claude's own models, or on `model` of a chosen
|
|
200
213
|
// service, which it runs with that service as its API and that model for every role. One started after the session
|
|
201
214
|
// opened goes on with the model, mode and effort chosen.
|
|
@@ -436,6 +449,7 @@ export class ClaudeSession {
|
|
|
436
449
|
for (const { reject } of this.prompts.values()) reject(failure(error?.message ?? 'Claude 会话已结束'));
|
|
437
450
|
this.prompts.clear();
|
|
438
451
|
try { query?.close(); } catch {}
|
|
452
|
+
this.dropMcpConfig();
|
|
439
453
|
if (!intended) this.onEnded(error);
|
|
440
454
|
}
|
|
441
455
|
receive(m) {
|
|
@@ -683,5 +697,6 @@ export class ClaudeSession {
|
|
|
683
697
|
for (const withdrawn of this.withdrawals) withdrawn.abort();
|
|
684
698
|
try { this.query?.close(); } catch {}
|
|
685
699
|
if (this.pump) await this.pump; else this.phase = 'ended';
|
|
700
|
+
this.dropMcpConfig();
|
|
686
701
|
}
|
|
687
702
|
}
|
package/agent/waits.mjs
CHANGED
|
@@ -65,6 +65,7 @@ export class ClaudeWaits {
|
|
|
65
65
|
stoppable: true, model: this.models.get(known.childSessionId) });
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
+
// local_bash and mcp_task share the ordinary task lifecycle; only local_agent owns a child session.
|
|
68
69
|
const subagent = native.task_type === 'local_agent', toolUseId = cut(native.tool_use_id, 200);
|
|
69
70
|
const task = { taskId: native.task_id, waitId: native.task_id.slice(0, 200), run: 1, kind: subagent ? 'subagent' : 'task', toolUseId, runId: native.run_id,
|
|
70
71
|
listed: listed || native.is_backgrounded === true, parentTaskId: native.parent_task_id, ...(subagent ? { childSessionId: toolUseId ?? native.task_id.slice(0, 200) } : {}) };
|
package/package.json
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
"id": "claude",
|
|
4
4
|
"displayName": "Claude",
|
|
5
5
|
"description": "用 Claude Agent SDK 跑会话",
|
|
6
|
-
"version": "1.12.
|
|
6
|
+
"version": "1.12.3",
|
|
7
7
|
"categories": [
|
|
8
8
|
"Agent"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@agentclientprotocol/sdk": "
|
|
12
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
11
|
+
"@agentclientprotocol/sdk": "2.6.0",
|
|
12
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.322"
|
|
13
13
|
},
|
|
14
14
|
"contributes": {
|
|
15
15
|
"agents": [
|