@1agents/acp-service 0.5.0 → 0.5.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/dist/src/acp-connection.js +11 -6
- package/dist/src/bridge.js +10 -1
- package/package.json +2 -1
- package/vendor/dsh/README.md +3 -3
- package/vendor/dsh/adapter.d.ts +2 -0
- package/vendor/dsh/adapter.js +33 -9
- package/vendor/dsh/client.js +151 -4
- package/vendor/dsh/imports.d.ts +4 -2
- package/vendor/dsh/imports.js +16 -7
- package/vendor/dsh/state.d.ts +4 -1
- package/vendor/dsh/state.js +9 -1
- package/vendor/dsh/tool-events.d.ts +26 -0
- package/vendor/dsh/tool-events.js +13 -0
|
@@ -104,12 +104,19 @@ function envelope(value) {
|
|
|
104
104
|
const { event: _event, ...fields } = value;
|
|
105
105
|
return { [NS]: fields };
|
|
106
106
|
}
|
|
107
|
-
function updateFor(event) {
|
|
107
|
+
function updateFor(event, toolUpdate = false) {
|
|
108
108
|
const common = { _meta: envelope(event) };
|
|
109
109
|
switch (event.event) {
|
|
110
110
|
case 'text_delta': return { ...common, sessionUpdate: event.type === 'thought' ? 'agent_thought_chunk' : 'agent_message_chunk', content: { type: 'text', text: event.text || '' } };
|
|
111
|
-
case 'tool_call':
|
|
112
|
-
|
|
111
|
+
case 'tool_call': {
|
|
112
|
+
const fields = { ...common, toolCallId: event.toolCallId, title: event.title ?? event.toolName, status: event.status,
|
|
113
|
+
kind: event.kind, rawInput: event.arguments, rawOutput: event.rawOutput, content: event.content, locations: event.locations };
|
|
114
|
+
return toolUpdate ? { ...fields, sessionUpdate: 'tool_call_update' }
|
|
115
|
+
: { ...fields, sessionUpdate: 'tool_call', title: fields.title ?? 'Tool', status: fields.status ?? 'pending' };
|
|
116
|
+
}
|
|
117
|
+
case 'tool_result': return { ...common, sessionUpdate: 'tool_call_update', toolCallId: event.toolCallId, status: event.isError ? 'failed' : 'completed',
|
|
118
|
+
...(event.rawOutput !== undefined ? { rawOutput: event.rawOutput } : event.text ? { rawOutput: event.text } : {}),
|
|
119
|
+
...(event.content !== undefined ? { content: event.content } : event.text ? { content: [{ type: 'content', content: { type: 'text', text: event.text } }] } : {}) };
|
|
113
120
|
case 'mode_changed': return { ...common, sessionUpdate: 'current_mode_update', currentModeId: event.payload.currentModeId };
|
|
114
121
|
case 'available_commands_update': return { ...common, sessionUpdate: 'available_commands_update', availableCommands: event.payload.availableCommands.map((c) => ({ name: c.name, description: c.description || '', ...(c.hasInput ? { input: { hint: c.inputHint || 'Arguments' } } : {}) })) };
|
|
115
122
|
case 'plan': return { ...common, sessionUpdate: 'plan', entries: event.entries || event.payload?.entries || [] };
|
|
@@ -241,11 +248,9 @@ export function attachAcpConnection(ws, req, backend = production, state = new A
|
|
|
241
248
|
const summary = backend.sessions.get(sessionId)?.acpResponsePolicy === 'summary';
|
|
242
249
|
if (event.event === 'text_delta' && event.type !== 'thought')
|
|
243
250
|
answers.set(sessionId, (answers.get(sessionId) || '') + (event.text || ''));
|
|
244
|
-
let update = updateFor(event);
|
|
251
|
+
let update = updateFor(event, event.event === 'tool_call' && toolsSeen.has(`${sessionId}:${event.toolCallId}`));
|
|
245
252
|
if (update?.sessionUpdate === 'tool_call') {
|
|
246
253
|
const key = `${sessionId}:${update.toolCallId}`;
|
|
247
|
-
if (toolsSeen.has(key))
|
|
248
|
-
update = { ...update, sessionUpdate: 'tool_call_update' };
|
|
249
254
|
toolsSeen.add(key);
|
|
250
255
|
}
|
|
251
256
|
if (update) {
|
package/dist/src/bridge.js
CHANGED
|
@@ -2487,10 +2487,17 @@ async function runPromptTurn(session, sessionId, promptItem) {
|
|
|
2487
2487
|
// so the frontend can treat status as authoritative over heuristics.
|
|
2488
2488
|
const rawStatus = typeof event.status === "string" ? event.status : undefined;
|
|
2489
2489
|
const toolStatus = rawStatus === "success" ? "completed" : rawStatus || undefined;
|
|
2490
|
+
// The runtime synthesizes "tool call" for sparse ACP updates.
|
|
2491
|
+
// Do not replace a previously supplied title with that display fallback.
|
|
2492
|
+
const toolTitle = event.tag === "tool_call_update" && event.title === "tool call"
|
|
2493
|
+
? undefined : event.title;
|
|
2490
2494
|
sendRuntimeTurnEvent(targetWs, sessionId, turn, {
|
|
2491
2495
|
event: "tool_call",
|
|
2492
2496
|
content: event.content,
|
|
2493
|
-
toolName
|
|
2497
|
+
...(event.toolName || event.kind || toolTitle
|
|
2498
|
+
? { toolName: resolveToolDisplayName(event) } : {}),
|
|
2499
|
+
...(toolTitle !== undefined ? { title: toolTitle } : {}),
|
|
2500
|
+
...(event.rawOutput !== undefined ? { rawOutput: event.rawOutput } : {}),
|
|
2494
2501
|
toolCallId: event.toolCallId,
|
|
2495
2502
|
...(event.agentTurnId ? { agentTurnId: event.agentTurnId } : {}),
|
|
2496
2503
|
...(event.rawInput !== undefined ? { arguments: event.rawInput } : {}),
|
|
@@ -2519,6 +2526,8 @@ async function runPromptTurn(session, sessionId, promptItem) {
|
|
|
2519
2526
|
toolCallId: event.toolCallId,
|
|
2520
2527
|
toolName: resolveToolDisplayName(event),
|
|
2521
2528
|
text: textContent,
|
|
2529
|
+
...(event.rawOutput !== undefined ? { rawOutput: event.rawOutput } : {}),
|
|
2530
|
+
...(event.content !== undefined ? { content: event.content } : {}),
|
|
2522
2531
|
isError: toolStatus === "failed",
|
|
2523
2532
|
...(event.agentTurnId ? { agentTurnId: event.agentTurnId } : {}),
|
|
2524
2533
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1agents/acp-service",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "ACP runtime, CLI, HTTP/WebSocket service and DeepSeek Harness plugin in one package.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dreammate",
|
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
"inject": [
|
|
100
100
|
"@deepseek-ai/dsh-client-ui-commands",
|
|
101
101
|
"@deepseek-ai/dsh-client-ui-conversation",
|
|
102
|
+
"@deepseek-ai/dsh-client-ui-chat",
|
|
102
103
|
"@deepseek-ai/dsh-client-locale",
|
|
103
104
|
"@deepseek-ai/dsh-api-remotes"
|
|
104
105
|
]
|
package/vendor/dsh/README.md
CHANGED
|
@@ -26,7 +26,7 @@ The service requires each native Agent’s CLI and credentials. Installing the p
|
|
|
26
26
|
|
|
27
27
|
Choose a discovered **ACP · Agent** in the new-session Agent preset picker, choose a workspace, then send a message. ACP routes are not listed as ordinary DSH models, and the adapter rejects requests from ordinary presets, including previously saved ACP routes. Before the first turn, switching the Agent preset replaces the discovery connection and its native commands. Once a turn starts, the session keeps its remote Agent and workspace; start a new session to change Agent. Native Agent binaries and authentication belong to acp-service.
|
|
28
28
|
|
|
29
|
-
The bundle registers an ACP adapter through DSH's public streaming extension and routes the ACP presets to it. It sends newly admitted messages whose source is `user` to `session/prompt`, not to `subagent-acp`; there is no coordinating DeepSeek model call. DSH-generated workspace instructions and runtime-context messages are excluded. The external Agent owns its model, prompt, tools and native history, including any project instructions it discovers itself. DSH owns its UI and local user/assistant transcript. External tool progress
|
|
29
|
+
The bundle registers an ACP adapter through DSH's public streaming extension and routes the ACP presets to it. It sends newly admitted messages whose source is `user` to `session/prompt`, not to `subagent-acp`; there is no coordinating DeepSeek model call. DSH-generated workspace instructions and runtime-context messages are excluded. The external Agent owns its model, prompt, tools and native history, including any project instructions it discovers itself. DSH owns its UI and local user/assistant transcript. External tool progress is preserved as display metadata on empty text blocks in DSH's existing assistant stream records and projected onto expandable ACP tool cards. ACP updates retain previously supplied fields, and replay is deduplicated by the managed turn sequence. These snapshots contain no visible text and never dispatch local tools; they use the existing persisted session format so conversations can reopen normally. Only Agent thought chunks enter the thinking stream.
|
|
30
30
|
|
|
31
31
|
## Continue imported native sessions
|
|
32
32
|
|
|
@@ -34,14 +34,14 @@ With `@1agents/session-reader` installed, choose **在 DSH 中继续原会话**
|
|
|
34
34
|
|
|
35
35
|
Imported bindings use `session/resume` because the service does not own a complete ACP replay of earlier native history. Existing ordinary ACP bindings continue using `session/load`. Endpoint, source provider and native ID identify an import; repeated admission reuses its DSH session without refreshing or replacing history. Old history-only DSH copies are not adopted. Original Agent history can continue changing outside DSH; the imported DSH history is a snapshot.
|
|
36
36
|
|
|
37
|
-
The service ID is saved before DSH creation. A failed local creation or workspace attachment can be retried after restart without importing again.
|
|
37
|
+
The service ID is saved before DSH creation. A failed local creation or workspace attachment can be retried after restart without importing again. When the original session reports `already has an active writer`, DSH still creates and opens its historical session. The composer is disabled with an explanation; capability refresh retries the original identity and restores input after its writer releases it. A pending import survives plugin restart. Other native restoration and authentication failures are reported, never replaced by a new empty session. If the transport is lost before the import response reaches the plugin, the plugin cannot know the service ID and does not automatically retry that RPC.
|
|
38
38
|
|
|
39
39
|
### Plugin service API
|
|
40
40
|
|
|
41
41
|
`ctx.oneagentsAcpSessions` is a Cordis service owned by this plugin; consumers may declare it optional so history browsing works without ACP. Its TypeScript declarations are exported from `@1agents/acp-service/dsh/imports`. Consumers call the service from the Host and must not instantiate it or write its binding files.
|
|
42
42
|
|
|
43
43
|
- `availability(provider)` returns `{ available, agent?, reason? }` without restoring a session. It checks configuration and the service inventory; successful native restoration remains the final capability/authentication check.
|
|
44
|
-
- `importSession({ provider, nativeSessionId, cwd, events })` accepts current DSH events starting at sequence zero. It returns `{ success: true, dshSessionId, workspace, workspaceId, agent, continuation: 'native' }`
|
|
44
|
+
- `importSession({ provider, nativeSessionId, cwd, events })` accepts current DSH events starting at sequence zero. It returns `{ success: true, dshSessionId, workspace, workspaceId, agent, continuation: 'native', writable, blocked? }` after DSH creation and workspace attachment. An active native writer returns `writable: false, blocked: 'active-writer'` while leaving history available.
|
|
45
45
|
|
|
46
46
|
Provider mapping is `claude → claude`, `codex → codex`, `grok → grok-build`. The service validates history through DSH before restoring a new native binding. No DSH Session format changes are required.
|
|
47
47
|
|
package/vendor/dsh/adapter.d.ts
CHANGED
package/vendor/dsh/adapter.js
CHANGED
|
@@ -3,7 +3,8 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
5
|
import { connect, object } from './transport.js';
|
|
6
|
-
import { State } from './state.js';
|
|
6
|
+
import { State, hasActiveWriter } from './state.js';
|
|
7
|
+
import { mergeTool } from './tool-events.js';
|
|
7
8
|
/** Producer/consumer queue; errors are delivered after already received chunks. */
|
|
8
9
|
class Queue {
|
|
9
10
|
values = [];
|
|
@@ -81,10 +82,18 @@ export class AcpAdapter {
|
|
|
81
82
|
return this.config.agents.includes(name) ? name : undefined;
|
|
82
83
|
}
|
|
83
84
|
async describe(agent) {
|
|
84
|
-
|
|
85
|
+
const name = this.agentName(agent);
|
|
86
|
+
if (!name)
|
|
85
87
|
return null;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
try {
|
|
89
|
+
await this.connection(agent);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (!this.state.get(agent.id)?.imported || !hasActiveWriter(error))
|
|
93
|
+
throw error;
|
|
94
|
+
return { agent: name, commands: [], configOptions: [], writable: false, blocked: 'active-writer' };
|
|
95
|
+
}
|
|
96
|
+
return { ...this.capabilities.get(agent.id), writable: true };
|
|
88
97
|
}
|
|
89
98
|
async configure(agent, configId, value) {
|
|
90
99
|
if (this.controllers.has(agent.id))
|
|
@@ -213,6 +222,11 @@ export class AcpAdapter {
|
|
|
213
222
|
const existing = this.links.get(agent.id);
|
|
214
223
|
if (existing)
|
|
215
224
|
return existing;
|
|
225
|
+
if (binding?.imported && !binding.sessionId) {
|
|
226
|
+
// Retry the original native identity after its writer releases it; never open an empty replacement.
|
|
227
|
+
binding = { ...await this.importNative(name, cwd, binding.imported.nativeSessionId), imported: binding.imported };
|
|
228
|
+
this.state.save(agent.id, binding);
|
|
229
|
+
}
|
|
216
230
|
const operation = (async () => {
|
|
217
231
|
if (!this.commandContexts.has(agent.id)) {
|
|
218
232
|
const fiber = await agent.ctx.inject(['commands'], scope => {
|
|
@@ -364,6 +378,11 @@ export class AcpAdapter {
|
|
|
364
378
|
if (binding && (binding.agent !== options.model || binding.cwd !== cwd || binding.endpoint !== endpoint.href))
|
|
365
379
|
throw new Error('This session is bound to another ACP Agent or endpoint; start a new session');
|
|
366
380
|
const seen = new Set();
|
|
381
|
+
const tools = new Map();
|
|
382
|
+
const boundary = this.ctx.sessionProjections.stateOf(agent.session, 'turnBoundary');
|
|
383
|
+
const stepStart = boundary?.lastStepStartSeq == null ? undefined : agent.session.eventAt(boundary.lastStepStartSeq);
|
|
384
|
+
const turn = boundary?.lastTurn ?? 0;
|
|
385
|
+
const step = stepStart?.type === 'step/start' ? stepStart.data.step : 0;
|
|
367
386
|
let index = 0, current, content = '', answer = '';
|
|
368
387
|
const endBlock = () => { if (current) {
|
|
369
388
|
queue.push({ type: 'block-end', index, block: { type: current, text: content } });
|
|
@@ -396,14 +415,19 @@ export class AcpAdapter {
|
|
|
396
415
|
if ((u.sessionUpdate === 'agent_message_chunk' || u.sessionUpdate === 'agent_thought_chunk') && u.content.type === 'text')
|
|
397
416
|
emit(u.sessionUpdate === 'agent_message_chunk' ? 'text' : 'reasoning', u.content.text);
|
|
398
417
|
else if (u.sessionUpdate === 'tool_call' || u.sessionUpdate === 'tool_call_update') {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
418
|
+
const tool = mergeTool(tools.get(u.toolCallId), u);
|
|
419
|
+
tools.set(u.toolCallId, tool);
|
|
420
|
+
// Known stream records preserve plugin metadata across save/reload.
|
|
421
|
+
// Empty text is inert; only the plugin projects it into remote Tool cards.
|
|
422
|
+
endBlock();
|
|
423
|
+
const block = { type: 'text', text: '', acpTool: { turn, step, requestId, sequence: meta.sequence, tool } };
|
|
424
|
+
queue.push({ type: 'block-start', index, blockType: 'text' });
|
|
425
|
+
queue.push({ type: 'block-end', index, block });
|
|
426
|
+
index++;
|
|
403
427
|
}
|
|
404
428
|
};
|
|
405
429
|
let active;
|
|
406
|
-
const cancel = () => { if (binding)
|
|
430
|
+
const cancel = () => { if (binding?.sessionId)
|
|
407
431
|
void active?.rpc.notify('session/cancel', { sessionId: binding.sessionId }).catch(() => { }); };
|
|
408
432
|
signal.addEventListener('abort', cancel, { once: true });
|
|
409
433
|
try {
|
package/vendor/dsh/client.js
CHANGED
|
@@ -21,16 +21,100 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/client.js
|
|
22
22
|
var client_exports = {};
|
|
23
23
|
__export(client_exports, {
|
|
24
|
+
AcpTools: () => AcpTools,
|
|
24
25
|
apply: () => apply,
|
|
25
26
|
choices: () => choices,
|
|
26
27
|
inject: () => inject
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(client_exports);
|
|
29
30
|
var import_react = require("react");
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
// src/tool-conversation.js
|
|
33
|
+
var names = { execute: "Bash", read: "Read", edit: "Edit", delete: "Delete", move: "Move", search: "Search", fetch: "Fetch", think: "Think" };
|
|
34
|
+
function contentOf(tool) {
|
|
35
|
+
if (tool.content?.length) return tool.content.flatMap((item) => {
|
|
36
|
+
if (item.type === "content" && item.content.type === "text") return [item.content];
|
|
37
|
+
if (item.type === "diff") return [{ type: "text", text: `${item.path}
|
|
38
|
+
---
|
|
39
|
+
${item.oldText ?? ""}
|
|
40
|
+
+++
|
|
41
|
+
${item.newText}` }];
|
|
42
|
+
return [];
|
|
43
|
+
});
|
|
44
|
+
if (tool.rawOutput === void 0 || tool.rawOutput === null) return [];
|
|
45
|
+
return [{ type: "text", text: typeof tool.rawOutput === "string" ? tool.rawOutput : JSON.stringify(tool.rawOutput, null, 2) }];
|
|
46
|
+
}
|
|
47
|
+
function rootOf(state, location) {
|
|
48
|
+
const { tool, requestId, turn, step } = state.data;
|
|
49
|
+
const name = tool.name && tool.name !== "Tool" ? tool.name : names[tool.kind] ?? tool.title ?? tool.name ?? "Tool";
|
|
50
|
+
const argsRaw = JSON.stringify(tool.rawInput ?? {});
|
|
51
|
+
const head = { callId: `${requestId}:${tool.toolCallId}`, name, argsRaw, turn, step, time: state.time, subCalls: [] };
|
|
52
|
+
const settled = tool.status === "completed" || tool.status === "failed";
|
|
53
|
+
const closed = location?.kind === "step" && location.step.status === "closed" ? location.step.end : (location?.kind === "step" || location?.kind === "turn") && location.turn.status === "closed" ? location.turn.end : void 0;
|
|
54
|
+
if (!settled && !closed) return { ...head, phase: "start" };
|
|
55
|
+
return {
|
|
56
|
+
kind: "tool-result",
|
|
57
|
+
seq: state.seq,
|
|
58
|
+
time: settled ? state.updatedAt : closed.time,
|
|
59
|
+
callId: head.callId,
|
|
60
|
+
call: { name, argsRaw },
|
|
61
|
+
callTime: state.time,
|
|
62
|
+
content: contentOf(tool),
|
|
63
|
+
isError: tool.status === "failed" || !settled,
|
|
64
|
+
...!settled ? { error: { name: "Interrupted", code: "interrupted" } } : {},
|
|
65
|
+
meta: { acp: tool },
|
|
66
|
+
subCalls: []
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function snapshots(event) {
|
|
70
|
+
const fromChunk = (chunk, time) => chunk?.type === "block-end" && chunk.block?.acpTool ? [{ data: chunk.block.acpTool, time }] : [];
|
|
71
|
+
if (event.type === "assistant/live-chunk") return fromChunk(event.data.chunk, event.time);
|
|
72
|
+
if (event.type === "assistant/message" || event.type === "assistant/attempt") {
|
|
73
|
+
return (event.data.stream ?? []).flatMap((record) => record.type === "chunk" ? fromChunk(record.chunk, record.time) : []);
|
|
74
|
+
}
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
function fold(previous, match) {
|
|
78
|
+
const tools = new Map(previous?.tools);
|
|
79
|
+
for (const { data, time } of snapshots(match.event)) {
|
|
80
|
+
const current = tools.get(data.tool.toolCallId);
|
|
81
|
+
if (current && current.data.sequence >= data.sequence) continue;
|
|
82
|
+
tools.set(data.tool.toolCallId, { data, seq: current?.seq ?? match.event.seq, time: current?.time ?? time, updatedAt: time });
|
|
83
|
+
}
|
|
84
|
+
return { tools, seq: previous?.seq ?? match.event.seq };
|
|
85
|
+
}
|
|
86
|
+
var toolConversationDefinition = {
|
|
87
|
+
kind: "oneagents-acp-tools",
|
|
88
|
+
target: "chat",
|
|
89
|
+
match: (event) => {
|
|
90
|
+
const first = snapshots(event)[0];
|
|
91
|
+
return first ? { id: first.data.requestId, role: "start" } : null;
|
|
92
|
+
},
|
|
93
|
+
start: (_context, match) => fold(void 0, match),
|
|
94
|
+
update: (context, match) => fold(context.state, match),
|
|
95
|
+
publication: () => "immediate",
|
|
96
|
+
buildViewNode: (context) => {
|
|
97
|
+
const state = context.state;
|
|
98
|
+
if (!state) return null;
|
|
99
|
+
const location = context.start?.location ?? context.matches[0]?.location ?? { kind: "unresolved" };
|
|
100
|
+
return {
|
|
101
|
+
key: context.key,
|
|
102
|
+
id: context.id,
|
|
103
|
+
kind: "oneagents-acp-tools",
|
|
104
|
+
target: "chat",
|
|
105
|
+
anchorSeq: state.seq,
|
|
106
|
+
location,
|
|
107
|
+
visibility: "visible",
|
|
108
|
+
data: { roots: [...state.tools.values()].map((tool) => rootOf(tool, location)) }
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/client.js
|
|
114
|
+
var inject = ["slots", "sessions", "commandUi", "remote", "remote.session", "locale", "uiConversation", "conversation"];
|
|
31
115
|
var dictionaries = {
|
|
32
|
-
zh: { model: "\u6A21\u578B", choose: "\u9009\u62E9\u6A21\u578B", loading: "\u6B63\u5728\u8FDE\u63A5 Agent\u2026", retry: "\u91CD\u8BD5", mode: "\u6A21\u5F0F", command: "Agent \u6307\u4EE4", effort: "\u601D\u8003\u5F3A\u5EA6", unsupported: "Agent \u672A\u63D0\u4F9B\u53EF\u5207\u6362\u7684\u6A21\u578B", description: "\u9009\u62E9\u5F53\u524D Agent \u7684\u6A21\u578B", error: "\u8FDE\u63A5\u5931\u8D25", noCommands: "Agent \u5C1A\u672A\u63D0\u4F9B\u6307\u4EE4", native: "ACP \u8BBE\u7F6E" },
|
|
33
|
-
en: { model: "Model", choose: "Select model", loading: "Connecting to Agent\u2026", retry: "Retry", mode: "Mode", command: "Agent commands", effort: "Reasoning effort", unsupported: "This Agent does not advertise model selection", description: "Select this Agent\u2019s model", error: "Connection failed", noCommands: "No commands advertised", native: "ACP settings" }
|
|
116
|
+
zh: { toolRunning: "\u6267\u884C\u4E2D", toolFailed: "\u5931\u8D25", toolCompleted: "\u5DF2\u5B8C\u6210", toolNoOutput: "\u65E0\u8F93\u51FA", model: "\u6A21\u578B", choose: "\u9009\u62E9\u6A21\u578B", loading: "\u6B63\u5728\u8FDE\u63A5 Agent\u2026", retry: "\u91CD\u8BD5", mode: "\u6A21\u5F0F", command: "Agent \u6307\u4EE4", effort: "\u601D\u8003\u5F3A\u5EA6", unsupported: "Agent \u672A\u63D0\u4F9B\u53EF\u5207\u6362\u7684\u6A21\u578B", description: "\u9009\u62E9\u5F53\u524D Agent \u7684\u6A21\u578B", error: "\u8FDE\u63A5\u5931\u8D25", noCommands: "Agent \u5C1A\u672A\u63D0\u4F9B\u6307\u4EE4", native: "ACP \u8BBE\u7F6E", activeWriter: "\u539F\u4F1A\u8BDD\u6B63\u5728\u5176\u4ED6\u5BA2\u6237\u7AEF\u8FD0\u884C\uFF0C\u53EF\u67E5\u770B\u5386\u53F2\uFF1B\u5360\u7528\u89E3\u9664\u540E\u81EA\u52A8\u6062\u590D\u8F93\u5165\u3002" },
|
|
117
|
+
en: { toolRunning: "Running", toolFailed: "Failed", toolCompleted: "Completed", toolNoOutput: "No output", model: "Model", choose: "Select model", loading: "Connecting to Agent\u2026", retry: "Retry", mode: "Mode", command: "Agent commands", effort: "Reasoning effort", unsupported: "This Agent does not advertise model selection", description: "Select this Agent\u2019s model", error: "Connection failed", noCommands: "No commands advertised", native: "ACP settings", activeWriter: "The original session is running in another client. History is available; input resumes when it is released." }
|
|
34
118
|
};
|
|
35
119
|
function choices(option) {
|
|
36
120
|
return (option.options ?? []).flatMap((item) => "group" in item ? item.options.map((value) => ({ ...value, group: item.name ?? item.group })) : [item]);
|
|
@@ -58,23 +142,85 @@ function Select({ title, value, rows, disabled, onSelect, placeholder }) {
|
|
|
58
142
|
)
|
|
59
143
|
);
|
|
60
144
|
}
|
|
145
|
+
function AcpTools({ node, t }) {
|
|
146
|
+
return (0, import_react.createElement)("div", { "data-oneagents-acp-tools": "", style: { display: "grid", gap: 6 } }, node.data.roots.map((root) => {
|
|
147
|
+
const running = root.phase === "start";
|
|
148
|
+
const tool = running ? root : root.call;
|
|
149
|
+
const output = running ? [] : root.content;
|
|
150
|
+
const acp = root.meta?.acp;
|
|
151
|
+
let args;
|
|
152
|
+
try {
|
|
153
|
+
args = JSON.parse(tool.argsRaw);
|
|
154
|
+
} catch {
|
|
155
|
+
args = tool.argsRaw;
|
|
156
|
+
}
|
|
157
|
+
const input = args?.command ?? args?.path ?? args?.file_path ?? acp?.title ?? tool.argsRaw;
|
|
158
|
+
const state = running ? "running" : root.isError ? "failed" : "completed";
|
|
159
|
+
const labels = { running: t("toolRunning"), failed: t("toolFailed"), completed: t("toolCompleted"), noOutput: t("toolNoOutput") };
|
|
160
|
+
return (0, import_react.createElement)(
|
|
161
|
+
"details",
|
|
162
|
+
{
|
|
163
|
+
key: root.callId,
|
|
164
|
+
"data-acp-call": root.callId,
|
|
165
|
+
"data-acp-status": state,
|
|
166
|
+
style: { border: "1px solid var(--dsw-alias-border-l1, #8883)", borderRadius: 8, padding: "7px 10px" }
|
|
167
|
+
},
|
|
168
|
+
(0, import_react.createElement)(
|
|
169
|
+
"summary",
|
|
170
|
+
{ style: { cursor: "pointer", fontSize: 13 } },
|
|
171
|
+
(0, import_react.createElement)("strong", null, tool.name),
|
|
172
|
+
" ",
|
|
173
|
+
(0, import_react.createElement)("span", { style: { opacity: 0.65 } }, labels[state]),
|
|
174
|
+
(0, import_react.createElement)("code", { style: { display: "block", whiteSpace: "pre-wrap", overflowWrap: "anywhere", marginTop: 4 } }, typeof input === "string" ? input : JSON.stringify(input))
|
|
175
|
+
),
|
|
176
|
+
(0, import_react.createElement)(
|
|
177
|
+
"pre",
|
|
178
|
+
{ style: { whiteSpace: "pre-wrap", overflowWrap: "anywhere", maxHeight: 360, overflow: "auto", fontSize: 12 } },
|
|
179
|
+
output.length ? output.map((block) => block.text ?? "").join("\n") : running ? labels.running : labels.noOutput
|
|
180
|
+
)
|
|
181
|
+
);
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
61
184
|
function apply(ctx) {
|
|
185
|
+
ctx.uiConversation.events.register(toolConversationDefinition);
|
|
186
|
+
ctx.slots.inject("conversation.chat.node", () => ctx.slots.register({
|
|
187
|
+
name: "conversation.chat.node",
|
|
188
|
+
key: "oneagents-acp-tools",
|
|
189
|
+
locale: "oneagentsAcp"
|
|
190
|
+
}, AcpTools));
|
|
62
191
|
ctx.effect(() => ctx.locale.register("oneagentsAcp", dictionaries));
|
|
63
192
|
const t = ctx.locale.bind("oneagentsAcp");
|
|
64
193
|
const native = /* @__PURE__ */ new Map();
|
|
65
194
|
const pending = /* @__PURE__ */ new Map();
|
|
66
195
|
const listeners = /* @__PURE__ */ new Map();
|
|
196
|
+
const blockedSessions = /* @__PURE__ */ new Set();
|
|
197
|
+
let disposed = false;
|
|
67
198
|
const presetOf = (id) => ctx.sessions.binding(id)?.session.projections.faceOf("agentPreset").getSnapshot();
|
|
68
199
|
const isAcp = (id) => String(presetOf(id) ?? "").startsWith("oneagents-acp-");
|
|
200
|
+
const block = (id, reason) => {
|
|
201
|
+
if (disposed) return;
|
|
202
|
+
if (reason) blockedSessions.add(id);
|
|
203
|
+
else blockedSessions.delete(id);
|
|
204
|
+
ctx.conversation.blocks.set(id, reason ? { reason } : void 0);
|
|
205
|
+
};
|
|
206
|
+
ctx.effect(() => () => {
|
|
207
|
+
disposed = true;
|
|
208
|
+
for (const id of blockedSessions) ctx.conversation.blocks.set(id, void 0);
|
|
209
|
+
});
|
|
69
210
|
const publish = (id, value) => {
|
|
70
211
|
native.set(id, value);
|
|
212
|
+
block(id, value?.writable === false ? t(value.blocked === "active-writer" ? "activeWriter" : "error") : void 0);
|
|
71
213
|
for (const fn of listeners.get(id) ?? []) fn();
|
|
72
214
|
};
|
|
73
215
|
const load = (id) => {
|
|
74
216
|
if (!pending.has(id)) {
|
|
217
|
+
if (!native.has(id)) block(id, t("loading"));
|
|
75
218
|
const operation = acpRequest(id).then((value) => {
|
|
76
219
|
publish(id, value);
|
|
77
220
|
return value;
|
|
221
|
+
}).catch((error) => {
|
|
222
|
+
block(id, `${t("error")}: ${error.message}`);
|
|
223
|
+
throw error;
|
|
78
224
|
}).finally(() => pending.delete(id));
|
|
79
225
|
pending.set(id, operation);
|
|
80
226
|
}
|
|
@@ -85,6 +231,7 @@ function apply(ctx) {
|
|
|
85
231
|
publish(id, updated);
|
|
86
232
|
};
|
|
87
233
|
const reset = () => {
|
|
234
|
+
for (const id of native.keys()) block(id, isAcp(id) ? t("loading") : void 0);
|
|
88
235
|
native.clear();
|
|
89
236
|
for (const set of listeners.values()) for (const fn of set) fn();
|
|
90
237
|
};
|
|
@@ -144,7 +291,7 @@ function apply(ctx) {
|
|
|
144
291
|
setBusy(false);
|
|
145
292
|
}
|
|
146
293
|
};
|
|
147
|
-
const disabled = locked || busy;
|
|
294
|
+
const disabled = locked || busy || external && capabilities?.writable === false;
|
|
148
295
|
const controls = [];
|
|
149
296
|
if (external && capabilities) {
|
|
150
297
|
const configs = capabilities.configOptions.filter((option) => option.type === "select");
|
package/vendor/dsh/imports.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface NativeSessionInput {
|
|
|
15
15
|
/** Current DSH events, contiguous from sequence zero. */
|
|
16
16
|
events: readonly SessionEvent[];
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/** Attached historical session, safe for navigation even while native writing is blocked. */
|
|
19
19
|
export interface ImportResult {
|
|
20
20
|
success: true;
|
|
21
21
|
dshSessionId: SessionId;
|
|
@@ -23,6 +23,8 @@ export interface ImportResult {
|
|
|
23
23
|
workspaceId: string;
|
|
24
24
|
agent: string;
|
|
25
25
|
continuation: 'native';
|
|
26
|
+
writable: boolean;
|
|
27
|
+
blocked?: 'active-writer';
|
|
26
28
|
}
|
|
27
29
|
declare module '@deepseek-ai/cordis' {
|
|
28
30
|
interface Context {
|
|
@@ -45,7 +47,7 @@ export declare class NativeSessions {
|
|
|
45
47
|
availability(provider: string): Promise<ImportAvailability>;
|
|
46
48
|
/** Restore one native session; repeated calls return its existing DSH identity and never replace its history.
|
|
47
49
|
* @param input Native identity, original workspace and historical events.
|
|
48
|
-
* @returns The attached DSH session
|
|
50
|
+
* @returns The attached DSH session and its native writing availability.
|
|
49
51
|
*/
|
|
50
52
|
importSession(input: NativeSessionInput): Promise<ImportResult>;
|
|
51
53
|
/** Stop new admissions and await callers already creating or attaching a session. */
|
package/vendor/dsh/imports.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { realpath, stat } from 'node:fs/promises';
|
|
4
4
|
import { isAbsolute } from 'node:path';
|
|
5
5
|
import { discoverPresets } from './discovery.js';
|
|
6
|
-
import { State } from './state.js';
|
|
6
|
+
import { State, hasActiveWriter } from './state.js';
|
|
7
7
|
const providers = { claude: 'claude', codex: 'codex', grok: 'grok-build' };
|
|
8
8
|
/** Owns import identities and serializes retries through remote import, local creation and workspace attachment. */
|
|
9
9
|
export class NativeSessions {
|
|
@@ -41,7 +41,7 @@ export class NativeSessions {
|
|
|
41
41
|
}
|
|
42
42
|
/** Restore one native session; repeated calls return its existing DSH identity and never replace its history.
|
|
43
43
|
* @param input Native identity, original workspace and historical events.
|
|
44
|
-
* @returns The attached DSH session
|
|
44
|
+
* @returns The attached DSH session and its native writing availability.
|
|
45
45
|
*/
|
|
46
46
|
async importSession(input) {
|
|
47
47
|
if (this.disposed)
|
|
@@ -105,10 +105,18 @@ export class NativeSessions {
|
|
|
105
105
|
this.ctx.sessions.prepare(id, { seed: input.events, meta: { cwd, agentPreset: preset } });
|
|
106
106
|
await this.ctx.agentPresets.resolve(preset);
|
|
107
107
|
}
|
|
108
|
+
let blocked = false;
|
|
108
109
|
if (!binding) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
const imported = { provider: input.provider, nativeSessionId: input.nativeSessionId, messageIds: [] };
|
|
111
|
+
try {
|
|
112
|
+
binding = { ...await this.adapter.importNative(agent, cwd, input.nativeSessionId), imported };
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!hasActiveWriter(error))
|
|
116
|
+
throw error;
|
|
117
|
+
blocked = true;
|
|
118
|
+
binding = { agent, cwd, endpoint: endpoint.href, restoreMethod: 'session/resume', imported };
|
|
119
|
+
}
|
|
112
120
|
// The service ID survives local creation/attachment failure and plugin restart.
|
|
113
121
|
this.state.save(id, binding);
|
|
114
122
|
}
|
|
@@ -125,9 +133,10 @@ export class NativeSessions {
|
|
|
125
133
|
const resolved = await this.ctx.sessionController.resolveAgent(id);
|
|
126
134
|
if ('error' in resolved)
|
|
127
135
|
throw resolved.error;
|
|
128
|
-
await this.adapter.describe(resolved.agent);
|
|
136
|
+
const capabilities = blocked ? { writable: false, blocked: 'active-writer' } : await this.adapter.describe(resolved.agent);
|
|
129
137
|
const workspace = await this.ctx.workspaceRegistry.create(cwd);
|
|
130
138
|
await workspace.attachSession(id);
|
|
131
|
-
return { success: true, dshSessionId: id, workspace: cwd, workspaceId: workspace.id, agent, continuation: 'native'
|
|
139
|
+
return { success: true, dshSessionId: id, workspace: cwd, workspaceId: workspace.id, agent, continuation: 'native',
|
|
140
|
+
writable: capabilities?.writable !== false, ...(capabilities?.blocked ? { blocked: capabilities.blocked } : {}) };
|
|
132
141
|
}
|
|
133
142
|
}
|
package/vendor/dsh/state.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export interface Binding {
|
|
|
8
8
|
agent: string;
|
|
9
9
|
cwd: string;
|
|
10
10
|
endpoint: string;
|
|
11
|
-
|
|
11
|
+
/** Absent while the original native session has an active writer. Never use session/new for this binding. */
|
|
12
|
+
sessionId?: string;
|
|
12
13
|
/** Absent on bindings created before native imports were supported. */
|
|
13
14
|
restoreMethod?: 'session/load' | 'session/resume';
|
|
14
15
|
imported?: NativeImport;
|
|
@@ -20,3 +21,5 @@ export declare class State {
|
|
|
20
21
|
get(id: string): Binding | undefined;
|
|
21
22
|
save(id: string, binding: Binding): void;
|
|
22
23
|
}
|
|
24
|
+
/** Native writer ownership prevents execution, but must not prevent reading imported history. */
|
|
25
|
+
export declare function hasActiveWriter(error: unknown): boolean;
|
package/vendor/dsh/state.js
CHANGED
|
@@ -30,7 +30,11 @@ function decodeBinding(value) {
|
|
|
30
30
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
31
31
|
throw new Error('Invalid ACP binding');
|
|
32
32
|
const binding = value;
|
|
33
|
-
if (['agent', 'cwd', 'endpoint'
|
|
33
|
+
if (['agent', 'cwd', 'endpoint'].some(key => typeof binding[key] !== 'string' || !binding[key]))
|
|
34
|
+
throw new Error('Invalid ACP binding identity');
|
|
35
|
+
if (binding.sessionId !== undefined && (typeof binding.sessionId !== 'string' || !binding.sessionId))
|
|
36
|
+
throw new Error('Invalid ACP binding identity');
|
|
37
|
+
if (binding.sessionId === undefined && binding.imported === undefined)
|
|
34
38
|
throw new Error('Invalid ACP binding identity');
|
|
35
39
|
if (binding.restoreMethod !== undefined && binding.restoreMethod !== 'session/load' && binding.restoreMethod !== 'session/resume')
|
|
36
40
|
throw new Error('Invalid ACP restore method');
|
|
@@ -45,3 +49,7 @@ function decodeBinding(value) {
|
|
|
45
49
|
}
|
|
46
50
|
return value;
|
|
47
51
|
}
|
|
52
|
+
/** Native writer ownership prevents execution, but must not prevent reading imported history. */
|
|
53
|
+
export function hasActiveWriter(error) {
|
|
54
|
+
return error instanceof Error && /already has an active writer/.test(error.message);
|
|
55
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Display metadata on empty stream blocks never becomes a local tool request. */
|
|
2
|
+
import type { SessionUpdate } from '@agentclientprotocol/sdk';
|
|
3
|
+
type ToolUpdate = Extract<SessionUpdate, {
|
|
4
|
+
sessionUpdate: 'tool_call' | 'tool_call_update';
|
|
5
|
+
}>;
|
|
6
|
+
export interface RemoteTool {
|
|
7
|
+
toolCallId: string;
|
|
8
|
+
title?: string | null;
|
|
9
|
+
name?: string;
|
|
10
|
+
status?: ToolUpdate['status'];
|
|
11
|
+
kind?: ToolUpdate['kind'];
|
|
12
|
+
rawInput?: unknown;
|
|
13
|
+
rawOutput?: unknown;
|
|
14
|
+
content?: ToolUpdate['content'];
|
|
15
|
+
locations?: ToolUpdate['locations'];
|
|
16
|
+
}
|
|
17
|
+
export interface ToolEvent {
|
|
18
|
+
turn: number;
|
|
19
|
+
step: number;
|
|
20
|
+
requestId: string;
|
|
21
|
+
sequence: number;
|
|
22
|
+
tool: RemoteTool;
|
|
23
|
+
}
|
|
24
|
+
/** ACP updates replace supplied fields and leave omitted fields intact. */
|
|
25
|
+
export declare function mergeTool(previous: RemoteTool | undefined, update: ToolUpdate): RemoteTool;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** ACP updates replace supplied fields and leave omitted fields intact. */
|
|
2
|
+
export function mergeTool(previous, update) {
|
|
3
|
+
const tool = { ...previous, toolCallId: update.toolCallId };
|
|
4
|
+
for (const key of ['title', 'status', 'kind', 'rawInput', 'rawOutput', 'content', 'locations']) {
|
|
5
|
+
if (update[key] !== undefined && (update[key] !== null || key === 'rawInput' || key === 'rawOutput'))
|
|
6
|
+
Object.assign(tool, { [key]: update[key] });
|
|
7
|
+
}
|
|
8
|
+
// The service's friendly name is display metadata, separate from ACP's title.
|
|
9
|
+
const name = update._meta?.['1agents']?.toolName;
|
|
10
|
+
if (name && (name !== 'Tool' || !tool.name))
|
|
11
|
+
tool.name = name;
|
|
12
|
+
return tool;
|
|
13
|
+
}
|