@coda-console/claude 1.7.6 → 1.7.8
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/models.mjs +16 -8
- package/agent/session.mjs +2 -1
- package/package.json +7 -3
package/agent/models.mjs
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// SDK lists is its resolved wire ID with the context variant it selects (`[1m]`), or its own value when it resolves to
|
|
3
3
|
// none, and rows that come to the same ID are one model. What the row is called is kept, the ID beside it when the name
|
|
4
4
|
// does not say it.
|
|
5
|
-
export const MODES = [['default', '人工审批'], ['acceptEdits', '自动接受编辑'
|
|
6
|
-
['
|
|
5
|
+
export const MODES = [['default', '人工审批', '审批'], ['acceptEdits', '自动接受编辑', '接受编辑'], ['plan', '规划', '规划'],
|
|
6
|
+
['dontAsk', '未预先允许则拒绝', '拒绝未授权'], ['auto', '自动审批', '自动审批'], ['bypassPermissions', '跳过所有审批', '跳过审批']]
|
|
7
|
+
.map(([id, name, shortName]) => ({ id, name, shortName }));
|
|
7
8
|
|
|
8
9
|
export function claudeModels(rows = []) {
|
|
9
10
|
const models = new Map();
|
|
@@ -12,12 +13,18 @@ export function claudeModels(rows = []) {
|
|
|
12
13
|
const variant = row.value.match(/\[[^\]]+\]$/)?.[0] ?? '', resolved = row.resolvedModel?.trim();
|
|
13
14
|
const id = resolved ? resolved + (resolved.endsWith(variant) ? '' : variant) : row.value;
|
|
14
15
|
const label = row.displayName || row.value, name = label.includes(id) ? label : `${label} (${id})`;
|
|
16
|
+
const short = label.replace(/^Claude\s+/i, '').replace(/\s*\(1m context\)/i, ' [1m]');
|
|
17
|
+
const shortName = variant && !short.toLowerCase().includes(variant.toLowerCase()) ? `${short} ${variant}` : short;
|
|
15
18
|
const known = models.get(id);
|
|
16
19
|
// The SDK's `default` row is the model it would pick: the row naming that model says what it is.
|
|
17
|
-
if (!known) models.set(id, { id, name, efforts: row.supportedEffortLevels ?? [], from: row.value });
|
|
18
|
-
else if (known.from === 'default') Object.assign(known, { name, from: row.value });
|
|
20
|
+
if (!known) models.set(id, { id, name, shortName, efforts: row.supportedEffortLevels ?? [], from: row.value });
|
|
21
|
+
else if (known.from === 'default') Object.assign(known, { name, shortName, from: row.value });
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
const result = [...models.values()];
|
|
24
|
+
const counts = new Map();
|
|
25
|
+
for (const model of result) counts.set(model.shortName, (counts.get(model.shortName) ?? 0) + 1);
|
|
26
|
+
for (const model of result) if (counts.get(model.shortName) > 1) model.shortName = model.name;
|
|
27
|
+
return result;
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
// The model a native init reports: one of the list, keeping the context variant chosen when its base is the one reported.
|
|
@@ -27,8 +34,9 @@ export function reportedModel(models, current, model) {
|
|
|
27
34
|
return models.find(m => m.id === model)?.id ?? model;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
|
-
const
|
|
31
|
-
|
|
37
|
+
const choice = c => ({ value: c.id, name: c.name,
|
|
38
|
+
...(c._meta || c.shortName ? { _meta: { ...c._meta, coda: { ...c._meta?.coda, ...(c.shortName ? { shortName: c.shortName } : {}) } } } : {}) });
|
|
39
|
+
const select = (id, name, category, currentValue, choices) => ({ id, name, category, type: 'select', currentValue, options: choices.map(choice) });
|
|
32
40
|
// The models, grouped by where they come from once a model service's are among them (ACP's select groups, Coda's
|
|
33
41
|
// docs/agent-protocol.md「模型的分组」): Claude's own, then each service's, under its title. Claude's alone are one plain list.
|
|
34
42
|
function modelSelect(currentValue, models) {
|
|
@@ -38,7 +46,7 @@ function modelSelect(currentValue, models) {
|
|
|
38
46
|
const id = model.service ?? 'claude';
|
|
39
47
|
let group = groups.find(g => g.group === id);
|
|
40
48
|
if (!group) groups.push(group = { group: id, name: model.group || id, options: [] });
|
|
41
|
-
group.options.push(
|
|
49
|
+
group.options.push(choice(model));
|
|
42
50
|
}
|
|
43
51
|
return { id: 'model', name: '模型', category: 'model', type: 'select', currentValue, options: groups.filter(g => g.options.length) };
|
|
44
52
|
}
|
package/agent/session.mjs
CHANGED
|
@@ -165,8 +165,9 @@ export class ClaudeSession {
|
|
|
165
165
|
settings: { crossSessionInbound: 'refuse' },
|
|
166
166
|
includePartialMessages: true, forwardSubagentText: true, cwd: dir,
|
|
167
167
|
...(Object.keys(servers).length ? { mcpServers: servers } : {}), ...(additionalDirectories.length ? { additionalDirectories } : {}),
|
|
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
|
-
env: { ...environment, CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: '1' },
|
|
170
|
+
env: { ...environment, CLAUDE_CODE_ENTRYPOINT: 'coda', CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: '1' },
|
|
170
171
|
// Stop supplies the complete list of scheduled wakeups. A CronCreate result alone cannot tell whether one was later
|
|
171
172
|
// deleted or fired.
|
|
172
173
|
hooks: { Stop: [{ hooks: [async input => {
|
package/package.json
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
"id": "claude",
|
|
4
4
|
"displayName": "Claude",
|
|
5
5
|
"description": "Claude SDK Agent:Coda 基于 Claude Agent SDK 写的 ACP 入口,一个进程一个 SDK 会话;资源页的「Claude」面板显示会话报告的额度,可从 Coda 登录。",
|
|
6
|
-
"version": "1.7.
|
|
7
|
-
"categories": [
|
|
6
|
+
"version": "1.7.8",
|
|
7
|
+
"categories": [
|
|
8
|
+
"Agent"
|
|
9
|
+
],
|
|
8
10
|
"dependencies": {
|
|
9
11
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
10
12
|
"@anthropic-ai/claude-agent-sdk": "0.3.296"
|
|
@@ -41,7 +43,9 @@
|
|
|
41
43
|
"items": {
|
|
42
44
|
"type": "string",
|
|
43
45
|
"format": "coda-model-provider",
|
|
44
|
-
"modelApis": [
|
|
46
|
+
"modelApis": [
|
|
47
|
+
"anthropic-messages"
|
|
48
|
+
]
|
|
45
49
|
},
|
|
46
50
|
"title": "模型服务",
|
|
47
51
|
"order": 1,
|