toc-ocra 0.3.0 → 0.3.2
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 +11 -5
- package/dist/cli/cli.mjs +3916 -1884
- package/dist/service/agent.mjs +3856 -1824
- package/dist/src/acp/agent-process.d.ts +34 -0
- package/dist/src/acp/agent-process.js +90 -0
- package/dist/src/acp/agent-process.js.map +1 -0
- package/dist/src/acp/chat-agents.d.ts +53 -0
- package/dist/src/acp/chat-agents.js +120 -0
- package/dist/src/acp/chat-agents.js.map +1 -0
- package/dist/src/acp/chat-forwarder.d.ts +30 -0
- package/dist/src/acp/chat-forwarder.js +101 -0
- package/dist/src/acp/chat-forwarder.js.map +1 -0
- package/dist/src/acp/chat-host.d.ts +28 -0
- package/dist/src/acp/chat-host.js +102 -0
- package/dist/src/acp/chat-host.js.map +1 -0
- package/dist/src/acp/chat-session.d.ts +112 -0
- package/dist/src/acp/chat-session.js +465 -0
- package/dist/src/acp/chat-session.js.map +1 -0
- package/dist/src/acp/connection.d.ts +77 -0
- package/dist/src/acp/connection.js +204 -0
- package/dist/src/acp/connection.js.map +1 -0
- package/dist/src/acp/rpc.d.ts +40 -0
- package/dist/src/acp/rpc.js +137 -0
- package/dist/src/acp/rpc.js.map +1 -0
- package/dist/src/acp/transcript.d.ts +39 -0
- package/dist/src/acp/transcript.js +273 -0
- package/dist/src/acp/transcript.js.map +1 -0
- package/dist/src/acp/vendor.d.ts +21 -0
- package/dist/src/acp/vendor.js +137 -0
- package/dist/src/acp/vendor.js.map +1 -0
- package/dist/src/config.d.ts +1 -1
- package/dist/src/providers/acp/acp-agents.d.ts +9 -0
- package/dist/src/providers/acp/acp-agents.js +8 -8
- package/dist/src/providers/acp/acp-agents.js.map +1 -1
- package/dist/src/providers/acp/acp-driver.d.ts +2 -2
- package/dist/src/providers/acp/acp-driver.js +9 -3
- package/dist/src/providers/acp/acp-driver.js.map +1 -1
- package/dist/src/providers/chat/codex-app-server.d.ts +1 -1
- package/dist/src/providers/chat/codex-app-server.js +6 -4
- package/dist/src/providers/chat/codex-app-server.js.map +1 -1
- package/dist/src/providers/chat/codex-goal.d.ts +17 -0
- package/dist/src/providers/chat/codex-goal.js +187 -0
- package/dist/src/providers/chat/codex-goal.js.map +1 -0
- package/dist/src/providers/cli/claude.d.ts +6 -0
- package/dist/src/providers/cli/claude.js +120 -8
- package/dist/src/providers/cli/claude.js.map +1 -1
- package/dist/src/providers/cli/codex-fork.d.ts +11 -0
- package/dist/src/providers/cli/codex-fork.js +84 -0
- package/dist/src/providers/cli/codex-fork.js.map +1 -0
- package/dist/src/providers/cli/codex.d.ts +12 -1
- package/dist/src/providers/cli/codex.js +33 -2
- package/dist/src/providers/cli/codex.js.map +1 -1
- package/dist/src/providers/cli/kiro.js +4 -3
- package/dist/src/providers/cli/kiro.js.map +1 -1
- package/dist/src/providers/cli-failure.js +1 -1
- package/dist/src/providers/provider.d.ts +46 -1
- package/dist/src/providers/provider.js +19 -0
- package/dist/src/providers/provider.js.map +1 -1
- package/dist/src/providers/registry.d.ts +7 -2
- package/dist/src/providers/registry.js +24 -8
- package/dist/src/providers/registry.js.map +1 -1
- package/dist/src/runs/run-supervisor.d.ts +53 -7
- package/dist/src/runs/run-supervisor.js +307 -61
- package/dist/src/runs/run-supervisor.js.map +1 -1
- package/dist/src/runtime/agent-runtime.js +26 -11
- package/dist/src/runtime/agent-runtime.js.map +1 -1
- package/dist/src/session/terminal-line-sanitizer.d.ts +5 -0
- package/dist/src/session/terminal-line-sanitizer.js +18 -0
- package/dist/src/session/terminal-line-sanitizer.js.map +1 -1
- package/dist/src/smoke/cli-smoke.js +1 -1
- package/dist/src/smoke/cli-smoke.js.map +1 -1
- package/dist/src/transport/gateway-client.d.ts +3 -1
- package/dist/src/transport/gateway-client.js +6 -0
- package/dist/src/transport/gateway-client.js.map +1 -1
- package/dist/src/types/protocol.d.ts +41 -4
- package/dist/src/types/protocol.js +30 -3
- package/dist/src/types/protocol.js.map +1 -1
- package/locales/en.json +1 -1
- package/locales/zh-CN.json +1 -1
- package/package.json +4 -2
- package/vendor/acp/claude/LICENSE +191 -0
- package/vendor/acp/claude/index.mjs +167 -0
- package/vendor/acp/claude/runtime.json +7 -0
- package/vendor/acp/codex/LICENSE +190 -0
- package/vendor/acp/codex/index.mjs +158 -0
- package/vendor/acp/codex/runtime.json +3 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { runLog } from '../providers/provider.js';
|
|
2
|
+
import { record } from './connection.js';
|
|
3
|
+
/**
|
|
4
|
+
* Folds one turn's ACP `session/update` stream into Echo chat events whose
|
|
5
|
+
* items have the shapes of Lody's history `MessageContent` (text, thought,
|
|
6
|
+
* tool_call, plan, available_commands), so the web renders them with Lody's
|
|
7
|
+
* own conversation components. The fold follows Lody's history writer:
|
|
8
|
+
*
|
|
9
|
+
* - message / thought chunks append to the last item of the same kind; any
|
|
10
|
+
* other item in between starts a new one (`appendOrMergeAdjacentText`);
|
|
11
|
+
* - a tool call is one item per `toolCallId`; `tool_call_update` replaces
|
|
12
|
+
* the fields it carries (ACP: `content` and `locations` are replacement
|
|
13
|
+
* lists) and its status never moves backwards;
|
|
14
|
+
* - plan, available commands, session config and usage are one item each.
|
|
15
|
+
*
|
|
16
|
+
* Every item event carries the whole item: the server replaces items by id.
|
|
17
|
+
*/
|
|
18
|
+
/** A string longer than this is cut; keeps one item well under the server's 256 KiB. */
|
|
19
|
+
const MAX_STRING = 16_000;
|
|
20
|
+
/** Old/new text of a diff block. */
|
|
21
|
+
const MAX_DIFF_TEXT = 48_000;
|
|
22
|
+
/** rawInput of a tool call (a Write tool carries the whole file). */
|
|
23
|
+
const MAX_RAW_INPUT_STRING = 4_000;
|
|
24
|
+
const STATUS_RANK = { pending: 0, in_progress: 1, completed: 2, failed: 2 };
|
|
25
|
+
const READ_KINDS = new Set(['read', 'search']);
|
|
26
|
+
export class TurnTranscript {
|
|
27
|
+
emit;
|
|
28
|
+
rows;
|
|
29
|
+
sequence = 0;
|
|
30
|
+
/** Kind and id of the item the next chunk may append to. */
|
|
31
|
+
open;
|
|
32
|
+
tools = new Map();
|
|
33
|
+
texts = [];
|
|
34
|
+
reply = '';
|
|
35
|
+
thought = '';
|
|
36
|
+
config = {};
|
|
37
|
+
shellOpen = '';
|
|
38
|
+
constructor(emit, rows) {
|
|
39
|
+
this.emit = emit;
|
|
40
|
+
this.rows = rows;
|
|
41
|
+
}
|
|
42
|
+
/** The turn's answer text, for the finish report. */
|
|
43
|
+
get finalMessage() {
|
|
44
|
+
this.flushRows();
|
|
45
|
+
return this.texts.join('\n\n').trim();
|
|
46
|
+
}
|
|
47
|
+
update(update) {
|
|
48
|
+
switch (update.sessionUpdate) {
|
|
49
|
+
case 'agent_message_chunk': return this.chunk('text', update.content);
|
|
50
|
+
case 'agent_thought_chunk': return this.chunk('thought', update.content);
|
|
51
|
+
case 'tool_call':
|
|
52
|
+
case 'tool_call_update': return this.toolCall(update);
|
|
53
|
+
case 'plan': return this.item({ itemId: 'plan', type: 'plan', entries: planEntries(update.entries) });
|
|
54
|
+
case 'plan_update': {
|
|
55
|
+
const plan = record(update.plan);
|
|
56
|
+
if (plan.type === 'items')
|
|
57
|
+
return this.item({ itemId: 'plan', type: 'plan', entries: planEntries(plan.entries) });
|
|
58
|
+
if (plan.type === 'markdown' && typeof plan.planId === 'string') {
|
|
59
|
+
return this.item({ itemId: `proposed_plan:${plan.planId}`, type: 'proposed_plan', turnId: plan.planId, markdown: clipText(String(plan.content ?? ''), 64_000), status: 'delta', isLatest: true });
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
case 'plan_removed':
|
|
64
|
+
if (typeof update.planId === 'string')
|
|
65
|
+
this.item({ itemId: `proposed_plan:${update.planId}`, type: 'proposed_plan', turnId: update.planId, markdown: '', status: 'cleared', isLatest: false });
|
|
66
|
+
return;
|
|
67
|
+
case 'available_commands_update': return this.availableCommands(update.availableCommands);
|
|
68
|
+
case 'current_mode_update':
|
|
69
|
+
if (typeof update.currentModeId === 'string')
|
|
70
|
+
this.sessionConfig({ currentModeId: update.currentModeId });
|
|
71
|
+
return;
|
|
72
|
+
case 'config_option_update':
|
|
73
|
+
if (Array.isArray(update.configOptions))
|
|
74
|
+
this.sessionConfig({ configOptions: clip(update.configOptions, 2_000) });
|
|
75
|
+
return;
|
|
76
|
+
case 'usage_update': return this.usage({ used: update.used, size: update.size, ...(update.cost !== undefined ? { cost: update.cost } : {}) });
|
|
77
|
+
default: return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** The agent's slash commands, also known before the first prompt. */
|
|
81
|
+
availableCommands(list) {
|
|
82
|
+
if (!Array.isArray(list))
|
|
83
|
+
return;
|
|
84
|
+
const commands = list.map(record).filter((command) => typeof command.name === 'string').map((command) => ({
|
|
85
|
+
name: command.name,
|
|
86
|
+
description: clipText(typeof command.description === 'string' ? command.description : '', 600),
|
|
87
|
+
...(command.input && typeof command.input === 'object' ? { input: clip(command.input, 600) } : {})
|
|
88
|
+
}));
|
|
89
|
+
this.item({ itemId: 'available_commands', type: 'available_commands', commands });
|
|
90
|
+
}
|
|
91
|
+
/** Session-level mode / config state (for the composer; never rendered as a step). */
|
|
92
|
+
sessionConfig(patch) {
|
|
93
|
+
this.config = { ...this.config, ...patch };
|
|
94
|
+
this.item({ itemId: 'session_config', type: 'session_config', ...this.config });
|
|
95
|
+
}
|
|
96
|
+
/** Lody Core `_lody/session/usage_update` or ACP `usage_update`. */
|
|
97
|
+
usage(value) {
|
|
98
|
+
this.item({ itemId: 'usage', type: 'usage', ...clip(value, 400) });
|
|
99
|
+
}
|
|
100
|
+
/** A user message taken into the running turn; later output follows it. */
|
|
101
|
+
steer(steerId, text, status) {
|
|
102
|
+
this.flushRows();
|
|
103
|
+
this.open = undefined;
|
|
104
|
+
this.item({ itemId: `steer:${steerId}`, type: 'user_steer', steerId, text: clipText(text, 64_000), status, at: Date.now() });
|
|
105
|
+
this.rows([runLog.event(`插入消息:${clipText(text.replace(/\s+/g, ' '), 120)}`)]);
|
|
106
|
+
}
|
|
107
|
+
/** A run-log notice. */
|
|
108
|
+
note(text) {
|
|
109
|
+
this.flushRows();
|
|
110
|
+
this.rows([runLog.event(text)]);
|
|
111
|
+
}
|
|
112
|
+
/** Writes buffered reply / thinking text to the run log. */
|
|
113
|
+
flushRows() {
|
|
114
|
+
const rows = [];
|
|
115
|
+
if (this.thought.trim())
|
|
116
|
+
rows.push(...runLog.thinking(this.thought.trim()));
|
|
117
|
+
this.thought = '';
|
|
118
|
+
if (this.reply.trim())
|
|
119
|
+
rows.push(...runLog.reply(this.reply.trim()));
|
|
120
|
+
this.reply = '';
|
|
121
|
+
if (rows.length)
|
|
122
|
+
this.rows(rows);
|
|
123
|
+
}
|
|
124
|
+
chunk(kind, content) {
|
|
125
|
+
const part = record(content);
|
|
126
|
+
if (part.type !== 'text' || typeof part.text !== 'string' || !part.text)
|
|
127
|
+
return;
|
|
128
|
+
let open = this.open;
|
|
129
|
+
if (open?.kind !== kind) {
|
|
130
|
+
if (kind === 'text' ? this.thought : this.reply)
|
|
131
|
+
this.flushRows();
|
|
132
|
+
open = { kind, itemId: `${kind === 'text' ? 'm' : 't'}${++this.sequence}` };
|
|
133
|
+
this.open = open;
|
|
134
|
+
if (kind === 'text')
|
|
135
|
+
this.texts.push('');
|
|
136
|
+
}
|
|
137
|
+
if (kind === 'text') {
|
|
138
|
+
const last = this.texts.length - 1;
|
|
139
|
+
this.texts[last] = (this.texts[last] ?? '') + part.text;
|
|
140
|
+
this.reply += part.text;
|
|
141
|
+
}
|
|
142
|
+
else
|
|
143
|
+
this.thought += part.text;
|
|
144
|
+
this.emit([{ event: kind === 'text' ? 'text_delta' : 'thought_delta', item_id: open.itemId, text: part.text }]);
|
|
145
|
+
}
|
|
146
|
+
toolCall(update) {
|
|
147
|
+
const id = typeof update.toolCallId === 'string' ? update.toolCallId : '';
|
|
148
|
+
if (!id)
|
|
149
|
+
return;
|
|
150
|
+
const known = this.tools.get(id);
|
|
151
|
+
const tool = known ?? { toolCallId: id, status: 'pending' };
|
|
152
|
+
if (typeof update.title === 'string' && update.title)
|
|
153
|
+
tool.title = update.title;
|
|
154
|
+
if (typeof update.kind === 'string' && update.kind)
|
|
155
|
+
tool.kind = update.kind;
|
|
156
|
+
if (typeof update.status === 'string' && (STATUS_RANK[update.status] ?? -1) >= (STATUS_RANK[tool.status] ?? 0))
|
|
157
|
+
tool.status = update.status;
|
|
158
|
+
if (Array.isArray(update.content))
|
|
159
|
+
tool.content = toolContent(update.content);
|
|
160
|
+
if (Array.isArray(update.locations))
|
|
161
|
+
tool.locations = clip(update.locations, 1_000);
|
|
162
|
+
if (update.rawInput !== undefined)
|
|
163
|
+
tool.rawInput = clip(update.rawInput, MAX_RAW_INPUT_STRING);
|
|
164
|
+
// A read's raw output is the file itself; Lody never keeps it either.
|
|
165
|
+
if (update.rawOutput !== undefined && !READ_KINDS.has(tool.kind ?? ''))
|
|
166
|
+
tool.rawOutput = clip(update.rawOutput, MAX_STRING);
|
|
167
|
+
const meta = toolMeta(update._meta);
|
|
168
|
+
if (meta)
|
|
169
|
+
tool._meta = { ...tool._meta, ...meta };
|
|
170
|
+
this.tools.set(id, tool);
|
|
171
|
+
if (!known) {
|
|
172
|
+
this.flushRows();
|
|
173
|
+
this.open = undefined;
|
|
174
|
+
this.toolRows(tool, true);
|
|
175
|
+
}
|
|
176
|
+
else if (tool.status === 'completed' || tool.status === 'failed')
|
|
177
|
+
this.toolRows(tool, false);
|
|
178
|
+
this.item({ itemId: `tool:${id}`, type: 'tool_call', ...tool });
|
|
179
|
+
}
|
|
180
|
+
/** Run-log rows for the output tail (the 运行日志 view). */
|
|
181
|
+
toolRows(tool, first) {
|
|
182
|
+
const input = record(tool.rawInput);
|
|
183
|
+
const command = typeof input.command === 'string' ? input.command : Array.isArray(input.command) ? input.command.join(' ') : undefined;
|
|
184
|
+
if (tool.kind === 'execute') {
|
|
185
|
+
if (first) {
|
|
186
|
+
this.shellOpen = tool.toolCallId;
|
|
187
|
+
this.rows([runLog.command(command ?? tool.title ?? 'shell')]);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
const output = record(tool.rawOutput);
|
|
191
|
+
const text = typeof output.aggregated_output === 'string' ? output.aggregated_output : typeof output.stdout === 'string' ? output.stdout : '';
|
|
192
|
+
const header = this.shellOpen === tool.toolCallId ? [] : [runLog.command(command ?? tool.title ?? 'shell')];
|
|
193
|
+
this.shellOpen = '';
|
|
194
|
+
const code = typeof output.exit_code === 'number' ? output.exit_code : tool.status === 'failed' ? 1 : 0;
|
|
195
|
+
this.rows([...header, ...runLog.commandOutput(text), runLog.commandExit(code)]);
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (!first) {
|
|
200
|
+
if (tool.status === 'failed')
|
|
201
|
+
this.rows([runLog.error(`${tool.title ?? '工具调用'} 失败`)]);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.shellOpen = '';
|
|
205
|
+
const location = record(tool.locations?.[0]);
|
|
206
|
+
const path = typeof location.path === 'string' ? location.path : undefined;
|
|
207
|
+
if (tool.kind === 'edit' || tool.kind === 'delete' || tool.kind === 'move')
|
|
208
|
+
this.rows([runLog.fileChange(path)]);
|
|
209
|
+
else if (tool.kind === 'fetch')
|
|
210
|
+
this.rows([runLog.tool('web_search')]);
|
|
211
|
+
else if (!READ_KINDS.has(tool.kind ?? '') && tool.kind !== 'think')
|
|
212
|
+
this.rows([runLog.tool('tool_call')]);
|
|
213
|
+
}
|
|
214
|
+
item(item) {
|
|
215
|
+
this.emit([{ event: 'item', item }]);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function planEntries(value) {
|
|
219
|
+
if (!Array.isArray(value))
|
|
220
|
+
return [];
|
|
221
|
+
return value.map(record).map((entry) => ({
|
|
222
|
+
content: clipText(String(entry.content ?? ''), 2_000),
|
|
223
|
+
priority: typeof entry.priority === 'string' ? entry.priority : 'medium',
|
|
224
|
+
status: typeof entry.status === 'string' ? entry.status : 'pending'
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
/** ACP tool content with diff texts and terminal snapshots bounded. */
|
|
228
|
+
function toolContent(content) {
|
|
229
|
+
return content.map((block) => {
|
|
230
|
+
const part = record(block);
|
|
231
|
+
if (part.type === 'diff') {
|
|
232
|
+
return {
|
|
233
|
+
type: 'diff',
|
|
234
|
+
path: typeof part.path === 'string' ? part.path : '',
|
|
235
|
+
...(typeof part.oldText === 'string' ? { oldText: clipText(part.oldText, MAX_DIFF_TEXT) } : part.oldText === null ? { oldText: null } : {}),
|
|
236
|
+
newText: clipText(typeof part.newText === 'string' ? part.newText : '', MAX_DIFF_TEXT)
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return clip(part, MAX_STRING);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/** The parts of a tool call's `_meta` Lody's renderer reads: Lody Core and Claude Code's tool facts. */
|
|
243
|
+
function toolMeta(value) {
|
|
244
|
+
const meta = record(value);
|
|
245
|
+
const out = {};
|
|
246
|
+
if (meta.lody !== undefined)
|
|
247
|
+
out.lody = clip(meta.lody, 2_000);
|
|
248
|
+
const claudeCode = record(meta.claudeCode);
|
|
249
|
+
if (Object.keys(claudeCode).length) {
|
|
250
|
+
out.claudeCode = {
|
|
251
|
+
...(typeof claudeCode.toolName === 'string' ? { toolName: claudeCode.toolName } : {}),
|
|
252
|
+
...(claudeCode.toolResponse !== undefined ? { toolResponse: clip(claudeCode.toolResponse, MAX_STRING) } : {})
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
return Object.keys(out).length ? out : undefined;
|
|
256
|
+
}
|
|
257
|
+
export function clipText(text, max) {
|
|
258
|
+
return text.length > max ? `${text.slice(0, max)}…` : text;
|
|
259
|
+
}
|
|
260
|
+
/** A JSON value with every string cut to `max` characters and depth bounded. */
|
|
261
|
+
export function clip(value, max, depth = 0) {
|
|
262
|
+
if (typeof value === 'string')
|
|
263
|
+
return clipText(value, max);
|
|
264
|
+
if (depth > 8)
|
|
265
|
+
return Array.isArray(value) ? [] : value && typeof value === 'object' ? {} : value;
|
|
266
|
+
if (Array.isArray(value))
|
|
267
|
+
return value.slice(0, 500).map((item) => clip(item, max, depth + 1));
|
|
268
|
+
if (value && typeof value === 'object') {
|
|
269
|
+
return Object.fromEntries(Object.entries(value).slice(0, 200).map(([key, item]) => [key, clip(item, max, depth + 1)]));
|
|
270
|
+
}
|
|
271
|
+
return value;
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=transcript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../../src/acp/transcript.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC;;;;;;;;;;;;;;GAcG;AAEH,wFAAwF;AACxF,MAAM,UAAU,GAAG,MAAM,CAAA;AACzB,oCAAoC;AACpC,MAAM,aAAa,GAAG,MAAM,CAAA;AAC5B,qEAAqE;AACrE,MAAM,oBAAoB,GAAG,KAAK,CAAA;AAclC,MAAM,WAAW,GAA2B,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAA;AACnG,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;AAI9C,MAAM,OAAO,cAAc;IAYN;IACA;IAZX,QAAQ,GAAG,CAAC,CAAA;IACpB,4DAA4D;IACpD,IAAI,CAA0D;IACrD,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAA;IACnC,KAAK,GAAa,EAAE,CAAA;IAC7B,KAAK,GAAG,EAAE,CAAA;IACV,OAAO,GAAG,EAAE,CAAA;IACZ,MAAM,GAA4B,EAAE,CAAA;I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C,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAA;IAC9F,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnJ,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ACP adapters toc-ocra ships in `vendor/acp/` (Lody's
|
|
3
|
+
* acp-extension-claude / acp-extension-codex, bundled by
|
|
4
|
+
* scripts/build-acp-adapters.mjs). Codex's bundle is self-contained.
|
|
5
|
+
* Claude's needs `@anthropic-ai/claude-agent-sdk`, which is not
|
|
6
|
+
* redistributed: it is installed from npm into the data directory on first
|
|
7
|
+
* use, without its optional platform binaries (the adapter is pointed at
|
|
8
|
+
* the Claude Code the user installed).
|
|
9
|
+
*/
|
|
10
|
+
export declare class AcpRuntimeUnavailable extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
/** toc-ocra's version, sent as ACP `clientInfo.version`. */
|
|
14
|
+
export declare function agentPackageVersion(): string;
|
|
15
|
+
/** Path of a vendored adapter entry, or undefined when this build has none. */
|
|
16
|
+
export declare function vendoredAdapter(name: 'claude' | 'codex'): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The directory holding the Claude adapter next to its SDK, installed once
|
|
19
|
+
* per adapter build. Concurrent turns share one install.
|
|
20
|
+
*/
|
|
21
|
+
export declare function ensureClaudeRuntime(dataDir: string): Promise<string>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { copyFile, mkdir, rename, rm, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { providerEnvironment, resolveExecutable } from '../providers/provider.js';
|
|
8
|
+
/**
|
|
9
|
+
* The ACP adapters toc-ocra ships in `vendor/acp/` (Lody's
|
|
10
|
+
* acp-extension-claude / acp-extension-codex, bundled by
|
|
11
|
+
* scripts/build-acp-adapters.mjs). Codex's bundle is self-contained.
|
|
12
|
+
* Claude's needs `@anthropic-ai/claude-agent-sdk`, which is not
|
|
13
|
+
* redistributed: it is installed from npm into the data directory on first
|
|
14
|
+
* use, without its optional platform binaries (the adapter is pointed at
|
|
15
|
+
* the Claude Code the user installed).
|
|
16
|
+
*/
|
|
17
|
+
export class AcpRuntimeUnavailable extends Error {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'AcpRuntimeUnavailable';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const NPM_INSTALL_TIMEOUT_MS = 10 * 60_000;
|
|
24
|
+
/** The nearest toc-ocra package root above this file (tsc build or bundle). */
|
|
25
|
+
function packageRoot() {
|
|
26
|
+
let directory = dirname(fileURLToPath(import.meta.url));
|
|
27
|
+
while (true) {
|
|
28
|
+
const path = resolve(directory, 'package.json');
|
|
29
|
+
if (existsSync(path)) {
|
|
30
|
+
try {
|
|
31
|
+
if (JSON.parse(readFileSync(path, 'utf8')).name === 'toc-ocra')
|
|
32
|
+
return directory;
|
|
33
|
+
}
|
|
34
|
+
catch { /* keep walking */ }
|
|
35
|
+
}
|
|
36
|
+
const parent = dirname(directory);
|
|
37
|
+
if (parent === directory)
|
|
38
|
+
return undefined;
|
|
39
|
+
directory = parent;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
let root;
|
|
43
|
+
function agentRoot() {
|
|
44
|
+
if (root === undefined)
|
|
45
|
+
root = packageRoot() ?? null;
|
|
46
|
+
return root ?? undefined;
|
|
47
|
+
}
|
|
48
|
+
/** toc-ocra's version, sent as ACP `clientInfo.version`. */
|
|
49
|
+
export function agentPackageVersion() {
|
|
50
|
+
const directory = agentRoot();
|
|
51
|
+
if (!directory)
|
|
52
|
+
return '0';
|
|
53
|
+
try {
|
|
54
|
+
return JSON.parse(readFileSync(join(directory, 'package.json'), 'utf8')).version ?? '0';
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return '0';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Path of a vendored adapter entry, or undefined when this build has none. */
|
|
61
|
+
export function vendoredAdapter(name) {
|
|
62
|
+
const directory = agentRoot();
|
|
63
|
+
const entry = directory ? join(directory, 'vendor', 'acp', name, 'index.mjs') : undefined;
|
|
64
|
+
return entry && existsSync(entry) ? entry : undefined;
|
|
65
|
+
}
|
|
66
|
+
const installs = new Map();
|
|
67
|
+
/**
|
|
68
|
+
* The directory holding the Claude adapter next to its SDK, installed once
|
|
69
|
+
* per adapter build. Concurrent turns share one install.
|
|
70
|
+
*/
|
|
71
|
+
export function ensureClaudeRuntime(dataDir) {
|
|
72
|
+
const entry = vendoredAdapter('claude');
|
|
73
|
+
if (!entry)
|
|
74
|
+
return Promise.reject(new AcpRuntimeUnavailable('这个版本的设备代理没有附带 Claude ACP 适配器'));
|
|
75
|
+
const manifestPath = join(dirname(entry), 'runtime.json');
|
|
76
|
+
let manifest;
|
|
77
|
+
try {
|
|
78
|
+
manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return Promise.reject(new AcpRuntimeUnavailable('Claude ACP 适配器缺少 runtime.json'));
|
|
82
|
+
}
|
|
83
|
+
const hash = createHash('sha256').update(readFileSync(entry)).digest('hex').slice(0, 12);
|
|
84
|
+
const directory = join(dataDir, 'acp-runtimes', `claude-${manifest.adapterVersion}-sdk-${manifest.sdk.version}-${hash}`);
|
|
85
|
+
const existing = installs.get(directory);
|
|
86
|
+
if (existing)
|
|
87
|
+
return existing;
|
|
88
|
+
const install = installClaudeRuntime(directory, entry, manifest).catch((error) => {
|
|
89
|
+
installs.delete(directory);
|
|
90
|
+
throw error instanceof AcpRuntimeUnavailable ? error : new AcpRuntimeUnavailable(`安装 Claude ACP 运行时失败:${error instanceof Error ? error.message : String(error)}`);
|
|
91
|
+
});
|
|
92
|
+
installs.set(directory, install);
|
|
93
|
+
return install;
|
|
94
|
+
}
|
|
95
|
+
async function installClaudeRuntime(directory, entry, manifest) {
|
|
96
|
+
const sdkPackage = join(directory, 'node_modules', ...manifest.sdk.name.split('/'), 'package.json');
|
|
97
|
+
if (existsSync(sdkPackage) && existsSync(join(directory, 'index.mjs')))
|
|
98
|
+
return directory;
|
|
99
|
+
const temporary = `${directory}.tmp-${process.pid}-${Date.now()}`;
|
|
100
|
+
await mkdir(temporary, { recursive: true, mode: 0o700 });
|
|
101
|
+
try {
|
|
102
|
+
await writeFile(join(temporary, 'package.json'), JSON.stringify({
|
|
103
|
+
name: 'toc-ocra-claude-acp-runtime', private: true, type: 'module',
|
|
104
|
+
dependencies: { [manifest.sdk.name]: manifest.sdk.version }
|
|
105
|
+
}, null, 2));
|
|
106
|
+
await runNpm(['install', '--omit=optional', '--no-audit', '--no-fund', '--no-package-lock', '--loglevel=error'], temporary);
|
|
107
|
+
await copyFile(entry, join(temporary, 'index.mjs'));
|
|
108
|
+
await rm(directory, { recursive: true, force: true });
|
|
109
|
+
await rename(temporary, directory);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
await rm(temporary, { recursive: true, force: true }).catch(() => undefined);
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
return directory;
|
|
116
|
+
}
|
|
117
|
+
function runNpm(args, cwd) {
|
|
118
|
+
const env = providerEnvironment();
|
|
119
|
+
const launch = resolveExecutable('npm', args, env, process.env.TOC_OCRA_NPM_PATH);
|
|
120
|
+
return new Promise((resolvePromise, reject) => {
|
|
121
|
+
const child = spawn(launch.executable, launch.args, { cwd, env: launch.env, shell: false, windowsHide: true, stdio: ['ignore', 'ignore', 'pipe'] });
|
|
122
|
+
const stderr = [];
|
|
123
|
+
child.stderr.setEncoding('utf8').on('data', (chunk) => { stderr.push(chunk); if (stderr.length > 50)
|
|
124
|
+
stderr.shift(); });
|
|
125
|
+
const timer = setTimeout(() => { child.kill('SIGKILL'); reject(new Error('npm install 超时')); }, NPM_INSTALL_TIMEOUT_MS);
|
|
126
|
+
timer.unref();
|
|
127
|
+
child.once('error', (error) => { clearTimeout(timer); reject(new Error(`无法运行 npm:${error.message}`)); });
|
|
128
|
+
child.once('close', (code) => {
|
|
129
|
+
clearTimeout(timer);
|
|
130
|
+
if (code === 0)
|
|
131
|
+
resolvePromise();
|
|
132
|
+
else
|
|
133
|
+
reject(new Error(`npm install 失败(exit ${code ?? '?'}):${stderr.join('').trim().slice(-600)}`));
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=vendor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vendor.js","sourceRoot":"","sources":["../../../src/acp/vendor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,E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AAE,CAAA;QACb,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;QACvG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YAC3B,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,IAAI,IAAI,KAAK,CAAC;gBAAE,cAAc,EAAE,CAAA;;gBAC3B,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAuB,IAAI,IAAI,GAAG,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;QACrG,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type AgentConfig = {
|
|
|
23
23
|
hostname: string;
|
|
24
24
|
platform: NodeJS.Platform;
|
|
25
25
|
allowedRoots: string[];
|
|
26
|
-
/** 0 = unlimited (default). Each
|
|
26
|
+
/** 0 = unlimited (default). Each session still runs one turn at a time. */
|
|
27
27
|
maxConcurrentRuns: number;
|
|
28
28
|
/** 0 = no limit (default): long tasks run to the end; silent ones are caught by the stall policy. */
|
|
29
29
|
maxRunSeconds: number;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import type { CliFailureRule } from '../cli-failure.js';
|
|
1
2
|
import { type AcpAgentSpec } from './acp-driver.js';
|
|
3
|
+
/**
|
|
4
|
+
* The ACP CLIs, as launch specs only (the counterpart of Orca's
|
|
5
|
+
* `ACP_LAUNCH_SPECS`). Adding an ACP CLI is one spec here plus its
|
|
6
|
+
* cli-specs.ts row; the lifecycle, permissions and errors are shared.
|
|
7
|
+
*/
|
|
8
|
+
/** The Echo progress callback: the one MCP tool a restricted turn may call. */
|
|
9
|
+
export declare const ECHO_CALLBACK: RegExp;
|
|
2
10
|
export declare const KIRO_ACP: AcpAgentSpec;
|
|
11
|
+
export declare const GEMINI_FAILURE_RULES: readonly CliFailureRule[];
|
|
3
12
|
export declare const GEMINI_ACP: AcpAgentSpec;
|
|
4
13
|
export declare const kiroAcpProvider: import("../provider.js").HeadlessProvider;
|
|
5
14
|
export declare const geminiAcpProvider: import("../provider.js").HeadlessProvider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { requireCliSpec } from '../cli-specs.js';
|
|
2
2
|
import { isKiroNoise, KIRO_FAILURE_RULES } from '../cli/kiro.js';
|
|
3
|
-
import { runLog } from '../provider.js';
|
|
3
|
+
import { accessLevel, runLog } from '../provider.js';
|
|
4
4
|
import { acpProvider } from './acp-driver.js';
|
|
5
5
|
/**
|
|
6
6
|
* The ACP CLIs, as launch specs only (the counterpart of Orca's
|
|
@@ -8,14 +8,14 @@ import { acpProvider } from './acp-driver.js';
|
|
|
8
8
|
* cli-specs.ts row; the lifecycle, permissions and errors are shared.
|
|
9
9
|
*/
|
|
10
10
|
/** The Echo progress callback: the one MCP tool a restricted turn may call. */
|
|
11
|
-
const ECHO_CALLBACK = /echo_report_task_progress/;
|
|
11
|
+
export const ECHO_CALLBACK = /echo_report_task_progress/;
|
|
12
12
|
export const KIRO_ACP = {
|
|
13
13
|
cli: requireCliSpec('kiro'),
|
|
14
14
|
args: (request) => [
|
|
15
15
|
'acp',
|
|
16
|
-
//
|
|
17
|
-
// request is answered by the driver
|
|
18
|
-
request
|
|
16
|
+
// Below full access only Echo's callback is trusted; every other permission
|
|
17
|
+
// request is answered by the driver by tool kind and the turn's level.
|
|
18
|
+
accessLevel(request) === 'bypassPermissions' ? '--trust-all-tools' : '--trust-tools=@doer/echo_report_task_progress',
|
|
19
19
|
...(request.model ? ['--model', request.model] : []),
|
|
20
20
|
...(request.reasoningEffort ? ['--effort', request.reasoningEffort] : [])
|
|
21
21
|
],
|
|
@@ -35,7 +35,7 @@ export const KIRO_ACP = {
|
|
|
35
35
|
return [];
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
const GEMINI_FAILURE_RULES = [
|
|
38
|
+
export const GEMINI_FAILURE_RULES = [
|
|
39
39
|
{ kind: 'sessionMissing', pattern: /session[^\n]{0,60}(?:not found|does not exist)|no session found|invalid session/i },
|
|
40
40
|
{ kind: 'notSignedIn', pattern: /api key is missing|not configured|login required|please (?:log|sign) ?in/i }
|
|
41
41
|
];
|
|
@@ -43,8 +43,8 @@ export const GEMINI_ACP = {
|
|
|
43
43
|
cli: requireCliSpec('gemini'),
|
|
44
44
|
args: (request) => [
|
|
45
45
|
'--acp',
|
|
46
|
-
//
|
|
47
|
-
...(request
|
|
46
|
+
// Below full access Gemini asks before editing or running anything; the driver answers by level.
|
|
47
|
+
...(accessLevel(request) === 'bypassPermissions' ? ['--yolo'] : ['--approval-mode', 'default']),
|
|
48
48
|
...(request.model ? ['--model', request.model] : [])
|
|
49
49
|
],
|
|
50
50
|
restrictedTools: ECHO_CALLBACK,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-agents.js","sourceRoot":"","sources":["../../../../src/providers/acp/acp-agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"acp-agents.js","sourceRoot":"","sources":["../../../../src/providers/acp/acp-agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAA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MAAM,CAAC,OAAO,KAAK,QAAQ;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;QACxI,OAAO,EAAE,CAAA;IACX,CAAC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAA8B;IAC7D,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,kFAAkF,EAAE;IACvH,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,2EAA2E,EAAE;CAC9G,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAiB;IACtC,GAAG,EAAE,cAAc,CAAC,QAAQ,CAAC;IAC7B,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACjB,OAAO;QACP,iGAAiG;QACjG,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,mBAAmB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;QAC/F,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACrD;IACD,eAAe,EAAE,aAAa;IAC9B,YAAY,EAAE,oBAAoB;CACnC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAA;AACpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -23,7 +23,7 @@ export type AcpAgentSpec = {
|
|
|
23
23
|
args(request: HeadlessRunRequest): string[];
|
|
24
24
|
/** Tool titles trusted under restricted permission besides read-only tools. */
|
|
25
25
|
restrictedTools?: RegExp;
|
|
26
|
-
/** Apply the
|
|
26
|
+
/** Apply the session's model with `session/set_model` after a resume (launch flags only reach new sessions). */
|
|
27
27
|
setModelOnLoad?: true;
|
|
28
28
|
failureRules?: readonly CliFailureRule[];
|
|
29
29
|
stderrDisplay?(line: string): string[];
|
|
@@ -48,7 +48,7 @@ export declare function acpErrorText(error: Rpc['error']): string;
|
|
|
48
48
|
/** Exit code a tool reported (`exit status: 2`, `"exitCode": 2`), when it did. */
|
|
49
49
|
export declare function reportedExitCode(rawOutput: unknown): number | undefined;
|
|
50
50
|
/** The permission answer for a tool call under this turn's policy. */
|
|
51
|
-
export declare function permissionOutcome(params: Record<string, unknown>, request: Pick<HeadlessRunRequest, 'permissionMode'>, spec: Pick<AcpAgentSpec, 'restrictedTools'>): unknown;
|
|
51
|
+
export declare function permissionOutcome(params: Record<string, unknown>, request: Pick<HeadlessRunRequest, 'permissionMode' | 'access'>, spec: Pick<AcpAgentSpec, 'restrictedTools'>): unknown;
|
|
52
52
|
/**
|
|
53
53
|
* The catalog's provider for an ACP CLI. The supervisor calls `forTurn` for
|
|
54
54
|
* every turn, so request ids, session and buffers never leak between
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { classifyCliOutput, failureMessage } from '../cli-failure.js';
|
|
2
|
-
import { clip, launchCli, runLog, str, toolCallRows, tryJson } from '../provider.js';
|
|
2
|
+
import { accessLevel, clip, launchCli, runLog, str, toolCallRows, tryJson } from '../provider.js';
|
|
3
3
|
const PROTOCOL_VERSION = 1;
|
|
4
4
|
/** ACP's `auth_required` error code. */
|
|
5
5
|
const AUTH_REQUIRED = -32000;
|
|
6
6
|
/** Tool kinds a restricted turn may run: they only read. */
|
|
7
7
|
const READ_ONLY_KINDS = new Set(['read', 'search', 'think']);
|
|
8
|
+
/** Tool kinds the 自动编辑 level also allows: file changes, never commands. */
|
|
9
|
+
const EDIT_KINDS = new Set(['edit', 'delete', 'move']);
|
|
8
10
|
const record = (value) => value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
9
11
|
/** One line of an ACP error: message plus the agent's detail. */
|
|
10
12
|
export function acpErrorText(error) {
|
|
@@ -54,8 +56,12 @@ export function permissionOutcome(params, request, spec) {
|
|
|
54
56
|
const options = Array.isArray(params.options) ? params.options.map(record) : [];
|
|
55
57
|
const call = record(params.toolCall);
|
|
56
58
|
const title = str(call.title) ?? '';
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
+
const kind = str(call.kind) ?? '';
|
|
60
|
+
const level = accessLevel(request);
|
|
61
|
+
const allowed = level === 'bypassPermissions'
|
|
62
|
+
|| READ_ONLY_KINDS.has(kind)
|
|
63
|
+
|| (level !== 'restricted' && kind === 'fetch')
|
|
64
|
+
|| (level === 'acceptEdits' && EDIT_KINDS.has(kind))
|
|
59
65
|
|| Boolean(spec.restrictedTools?.test(title));
|
|
60
66
|
const pick = (prefix) => options.find((option) => str(option.kind) === `${prefix}_once`) ?? options.find((option) => str(option.kind)?.startsWith(prefix));
|
|
61
67
|
const option = allowed ? pick('allow') : pick('reject');
|