@1agents/acp-service 0.5.2 → 0.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1agents/acp-service",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "ACP runtime, CLI, HTTP/WebSocket service and DeepSeek Harness plugin in one package.",
5
5
  "keywords": [
6
6
  "dreammate",
@@ -100,6 +100,7 @@
100
100
  "@deepseek-ai/dsh-client-ui-commands",
101
101
  "@deepseek-ai/dsh-client-ui-conversation",
102
102
  "@deepseek-ai/dsh-client-ui-chat",
103
+ "@deepseek-ai/dsh-client-ui-tool",
103
104
  "@deepseek-ai/dsh-client-locale",
104
105
  "@deepseek-ai/dsh-api-remotes"
105
106
  ]
@@ -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 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.
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 collapsed groups of peer tool cards, separated by native prose and reasoning. 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
 
@@ -384,6 +384,7 @@ export class AcpAdapter {
384
384
  const turn = boundary?.lastTurn ?? 0;
385
385
  const step = stepStart?.type === 'step/start' ? stepStart.data.step : 0;
386
386
  let index = 0, current, content = '', answer = '';
387
+ const acpStream = { turn, step, requestId };
387
388
  const endBlock = () => { if (current) {
388
389
  queue.push({ type: 'block-end', index, block: { type: current, text: content } });
389
390
  index++;
@@ -396,12 +397,13 @@ export class AcpAdapter {
396
397
  if (current !== kind) {
397
398
  endBlock();
398
399
  current = kind;
399
- queue.push({ type: 'block-start', index, blockType: kind });
400
+ queue.push({ type: 'block-start', index, blockType: kind, acpStream });
400
401
  }
401
402
  content += text;
402
403
  if (kind === 'text')
403
404
  answer += text;
404
- queue.push(kind === 'text' ? { type: 'text-delta', index, text } : { type: 'reasoning-delta', index, text });
405
+ const chunk = kind === 'text' ? { type: 'text-delta', index, text, acpStream } : { type: 'reasoning-delta', index, text, acpStream };
406
+ queue.push(chunk);
405
407
  };
406
408
  const update = (u) => {
407
409
  const meta = u._meta?.['1agents'];
@@ -1,8 +1,10 @@
1
1
  window.__ModuleLoader__.load({id:"@1agents/acp-service",dependencies:["react"],factory:(require)=>{var module={exports:{}};var exports=module.exports;
2
2
  "use strict";
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,23 +18,30 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
 
21
31
  // src/client.js
22
32
  var client_exports = {};
23
33
  __export(client_exports, {
24
- AcpTools: () => AcpTools,
25
34
  apply: () => apply,
26
35
  choices: () => choices,
27
36
  inject: () => inject
28
37
  });
29
38
  module.exports = __toCommonJS(client_exports);
30
- var import_react = require("react");
39
+ var import_react2 = require("react");
31
40
 
32
41
  // src/tool-conversation.js
33
42
  var names = { execute: "Bash", read: "Read", edit: "Edit", delete: "Delete", move: "Move", search: "Search", fetch: "Fetch", think: "Think" };
34
43
  function contentOf(tool) {
35
- if (tool.content?.length) return tool.content.flatMap((item) => {
44
+ const content = (tool.content ?? []).flatMap((item) => {
36
45
  if (item.type === "content" && item.content.type === "text") return [item.content];
37
46
  if (item.type === "diff") return [{ type: "text", text: `${item.path}
38
47
  ---
@@ -41,13 +50,14 @@ ${item.oldText ?? ""}
41
50
  ${item.newText}` }];
42
51
  return [];
43
52
  });
44
- if (tool.rawOutput === void 0 || tool.rawOutput === null) return [];
53
+ if (content.length || tool.rawOutput == null) return content;
45
54
  return [{ type: "text", text: typeof tool.rawOutput === "string" ? tool.rawOutput : JSON.stringify(tool.rawOutput, null, 2) }];
46
55
  }
47
56
  function rootOf(state, location) {
48
57
  const { tool, requestId, turn, step } = state.data;
49
58
  const name = tool.name && tool.name !== "Tool" ? tool.name : names[tool.kind] ?? tool.title ?? tool.name ?? "Tool";
50
- const argsRaw = JSON.stringify(tool.rawInput ?? {});
59
+ const input = tool.rawInput ?? (tool.locations?.[0]?.path ? { path: tool.locations[0].path } : tool.title ? { description: tool.title } : {});
60
+ const argsRaw = JSON.stringify(input);
51
61
  const head = { callId: `${requestId}:${tool.toolCallId}`, name, argsRaw, turn, step, time: state.time, subCalls: [] };
52
62
  const settled = tool.status === "completed" || tool.status === "failed";
53
63
  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;
@@ -66,55 +76,190 @@ function rootOf(state, location) {
66
76
  subCalls: []
67
77
  };
68
78
  }
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
- }
79
+ function records(event) {
80
+ if (event.type === "assistant/live-chunk") return [{ chunk: event.data.chunk, time: event.time }];
81
+ if (event.type === "assistant/message" || event.type === "assistant/attempt") return (event.data.stream ?? []).filter((record) => record.type === "chunk");
75
82
  return [];
76
83
  }
77
84
  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 });
85
+ const event = match.event;
86
+ const replay = event.type !== "assistant/live-chunk";
87
+ const state = {
88
+ blocks: new Map(replay ? void 0 : previous?.blocks),
89
+ tools: new Map(replay ? void 0 : previous?.tools),
90
+ acp: previous?.acp ?? false,
91
+ seq: previous?.seq ?? event.seq,
92
+ final: event.type === "assistant/message" || previous?.final === true
93
+ };
94
+ for (const { chunk, time } of records(event)) {
95
+ if (chunk.acpStream || chunk.block?.acpTool) state.acp = true;
96
+ const index = chunk.index;
97
+ if (chunk.type === "block-start" && (chunk.blockType === "text" || chunk.blockType === "reasoning")) {
98
+ state.blocks.set(index, { kind: chunk.blockType, text: "" });
99
+ } else if (chunk.type === "text-delta" || chunk.type === "reasoning-delta") {
100
+ const kind = chunk.type === "text-delta" ? "text" : "reasoning";
101
+ const current = state.blocks.get(index);
102
+ state.blocks.set(index, { kind, text: (current?.kind === kind ? current.text : "") + chunk.text });
103
+ } else if (chunk.type === "block-end") {
104
+ const data = chunk.block.acpTool;
105
+ if (data) {
106
+ const current = state.tools.get(data.tool.toolCallId);
107
+ state.blocks.delete(index);
108
+ if (current && current.data.sequence >= data.sequence) continue;
109
+ const position = current?.index ?? index;
110
+ state.blocks.set(position, { kind: "tool", id: data.tool.toolCallId });
111
+ state.tools.set(data.tool.toolCallId, { data, index: position, seq: current?.seq ?? event.seq, time: current?.time ?? time, updatedAt: time });
112
+ } else if (chunk.block.type === "text" || chunk.block.type === "reasoning") {
113
+ state.blocks.set(index, { kind: chunk.block.type, text: chunk.block.text });
114
+ }
115
+ }
83
116
  }
84
- return { tools, seq: previous?.seq ?? match.event.seq };
117
+ return state;
118
+ }
119
+ function groupParts(parts) {
120
+ const groups = [];
121
+ for (const part of parts) {
122
+ const last = groups.at(-1);
123
+ if (part.kind === "tool") {
124
+ if (last?.kind === "tools") last.roots.push(part.root);
125
+ else groups.push({ kind: "tools", key: part.root.callId, roots: [part.root] });
126
+ } else groups.push(part);
127
+ }
128
+ return groups;
85
129
  }
86
130
  var toolConversationDefinition = {
87
131
  kind: "oneagents-acp-tools",
88
132
  target: "chat",
89
- match: (event) => {
90
- const first = snapshots(event)[0];
91
- return first ? { id: first.data.requestId, role: "start" } : null;
92
- },
133
+ match: (event) => ["assistant/live-chunk", "assistant/message", "assistant/attempt"].includes(event.type) ? { id: `${event.data.turn}:${event.data.step}`, role: "start" } : null,
93
134
  start: (_context, match) => fold(void 0, match),
94
135
  update: (context, match) => fold(context.state, match),
95
136
  publication: () => "immediate",
96
137
  buildViewNode: (context) => {
97
138
  const state = context.state;
98
- if (!state) return null;
139
+ if (!state?.acp) return null;
99
140
  const location = context.start?.location ?? context.matches[0]?.location ?? { kind: "unresolved" };
141
+ const parts = [];
142
+ for (const [index, block] of [...state.blocks].sort(([a], [b]) => a - b)) {
143
+ if (block.kind === "tool") parts.push({ kind: "tool", root: rootOf(state.tools.get(block.id), location) });
144
+ else if (block.text.trim()) {
145
+ const last = parts.at(-1);
146
+ if (last?.kind === block.kind) last.text += block.text;
147
+ else parts.push({ ...block, key: String(index) });
148
+ }
149
+ }
150
+ if (!parts.length) return null;
151
+ const status = state.final ? "settled" : location.kind === "step" && location.step.status === "closed" ? "interrupted" : "running";
152
+ const turn = context.matches[0].event.data.turn, step = context.matches[0].event.data.step;
153
+ const text = parts.filter((part) => part.kind === "text").map((part) => part.text).join("\n");
154
+ const blocks = [{ kind: "text", text: text || parts.filter((part) => part.kind === "tool").map((part) => part.root.name ?? part.root.call.name).join(", ") || "ACP" }];
100
155
  return {
101
156
  key: context.key,
102
157
  id: context.id,
103
- kind: "oneagents-acp-tools",
158
+ kind: "assistant-step",
104
159
  target: "chat",
105
160
  anchorSeq: state.seq,
106
161
  location,
107
162
  visibility: "visible",
108
- data: { roots: [...state.tools.values()].map((tool) => rootOf(tool, location)) }
163
+ data: {
164
+ status,
165
+ turn,
166
+ step,
167
+ blocks,
168
+ time: context.matches[0].event.time,
169
+ acpTranscript: { groups: groupParts(parts), status }
170
+ }
109
171
  };
110
172
  }
111
173
  };
112
174
 
175
+ // src/transcript-view.js
176
+ var import_react = __toESM(require("react"), 1);
177
+ var h = import_react.default.createElement;
178
+ var toolKeys = { Bash: "bash", Read: "read", Edit: "edit", Write: "write", Search: "search", Fetch: "web_fetch" };
179
+ function ToolGroup({ roots, owner, renderTool, label }) {
180
+ const { expanded, toggle } = owner.useDisclosure();
181
+ return h(
182
+ "div",
183
+ { "data-oneagents-acp-tool-group": "", style: { margin: "8px 0" } },
184
+ h(
185
+ "button",
186
+ {
187
+ type: "button",
188
+ "aria-expanded": expanded,
189
+ onClick: toggle,
190
+ style: { border: 0, background: "transparent", color: "inherit", opacity: 0.7, cursor: "pointer", font: "inherit", fontSize: 14, padding: "4px 0" }
191
+ },
192
+ `${expanded ? "\u2303" : "\u2304"} ${label(roots.length)}`
193
+ ),
194
+ expanded ? h("div", { style: { paddingTop: 6 } }, roots.map((root) => renderTool(root, owner))) : null
195
+ );
196
+ }
197
+ function installTranscriptView(ctx) {
198
+ ctx.slots.inject("conversation.chat.node", () => {
199
+ const native = [...ctx.slots.entries("conversation.chat.node")].reverse().find((entry) => entry.options.key === "assistant-step");
200
+ if (!native || native.children) throw new Error("DSH native assistant renderer is unavailable");
201
+ const tTool = ctx.locale.bind("conversation");
202
+ const t = ctx.locale.bind("oneagentsAcp");
203
+ const renderTool = (root, owner) => {
204
+ const name = root.name ?? root.call?.name ?? "Tool";
205
+ const entries = ctx.slots.entries("tool.call.toolview");
206
+ const key = toolKeys[name] ?? name;
207
+ const entry = [...entries].reverse().find((entry2) => entry2.options.key === key && !entry2.children) ?? entries.find((entry2) => entry2.options.key === "sleep" && !entry2.children);
208
+ if (!entry) throw new Error(`DSH atomic Tool renderer is unavailable for ${name}`);
209
+ return h(entry.component, {
210
+ ...owner,
211
+ key: root.callId,
212
+ callId: root.callId,
213
+ toolName: key,
214
+ phase: root.phase === "start" ? "start" : "result",
215
+ block: root,
216
+ home: ctx.remote.$host?.home,
217
+ inspect: void 0,
218
+ t: tTool
219
+ });
220
+ };
221
+ function Assistant(props) {
222
+ const projected = props.useChat?.((snapshot) => snapshot?.nodes.values().some((node) => node.data.acpTranscript && node.data.turn === props.node.data.turn && node.data.step === props.node.data.step));
223
+ const transcript = props.node.data.acpTranscript;
224
+ if (transcript) return h("div", { "data-oneagents-acp-transcript": "" }, transcript.groups.map((group) => {
225
+ if (group.kind === "tools") return h(ToolGroup, {
226
+ key: group.key,
227
+ roots: group.roots,
228
+ owner: props,
229
+ renderTool,
230
+ label: (count) => t("toolGroup").replace("{count}", String(count))
231
+ });
232
+ const node = { ...props.node, data: {
233
+ ...props.node.data,
234
+ acpTranscript: void 0,
235
+ blocks: [{ kind: group.kind, text: group.text }]
236
+ } };
237
+ return h(native.component, { ...props, key: group.key, node, groupPart: void 0, turnProcess: void 0 });
238
+ }));
239
+ const preset = ctx.sessions.binding(props.sessionId)?.session.projections.faceOf("agentPreset").getSnapshot();
240
+ return projected && typeof preset === "string" && preset.startsWith("oneagents-acp-") ? h("span", { hidden: true, "data-oneagents-acp-original": "" }) : h(native.component, props);
241
+ }
242
+ return ctx.slots.register({
243
+ name: "conversation.chat.node",
244
+ key: "assistant-step",
245
+ priority: (native.options.priority ?? 0) - 1,
246
+ locale: native.locale,
247
+ inject: native.inject
248
+ }, Assistant);
249
+ });
250
+ ctx.effect(() => {
251
+ const style = document.createElement("style");
252
+ style.textContent = "[data-step-process]:has([data-oneagents-acp-original]):not(:has([data-oneagents-acp-transcript])){display:none}";
253
+ document.head.append(style);
254
+ return () => style.remove();
255
+ });
256
+ }
257
+
113
258
  // src/client.js
114
259
  var inject = ["slots", "sessions", "commandUi", "remote", "remote.session", "locale", "uiConversation", "conversation"];
115
260
  var dictionaries = {
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." }
261
+ zh: { toolGroup: "\u5DF2\u8C03\u7528 {count} \u4E2A\u5DE5\u5177", 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" },
262
+ en: { toolGroup: "{count} tool calls", 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." }
118
263
  };
119
264
  function choices(option) {
120
265
  return (option.options ?? []).flatMap((item) => "group" in item ? item.options.map((value) => ({ ...value, group: item.name ?? item.group })) : [item]);
@@ -130,64 +275,21 @@ async function acpRequest(sessionId, change) {
130
275
  }
131
276
  var selectStyle = { maxWidth: 210, minHeight: 30, borderRadius: 7, border: "1px solid var(--dsw-alias-border-l1, #8885)", color: "inherit", background: "var(--dsw-alias-bg-base, transparent)", padding: "3px 7px", fontSize: 12 };
132
277
  function Select({ title, value, rows, disabled, onSelect, placeholder }) {
133
- return (0, import_react.createElement)(
278
+ return (0, import_react2.createElement)(
134
279
  "label",
135
280
  { style: { display: "inline-flex", gap: 5, alignItems: "center", fontSize: 12 } },
136
- (0, import_react.createElement)("span", null, title),
137
- (0, import_react.createElement)(
281
+ (0, import_react2.createElement)("span", null, title),
282
+ (0, import_react2.createElement)(
138
283
  "select",
139
284
  { "aria-label": title, style: selectStyle, value: value ?? "", disabled, onChange: (e) => onSelect(e.target.value) },
140
- (0, import_react.createElement)("option", { value: "", disabled: true }, placeholder || title),
141
- rows.map((row) => (0, import_react.createElement)("option", { key: row.value, value: row.value, title: row.description }, `${row.group ? `${row.group} \xB7 ` : ""}${row.name}`))
285
+ (0, import_react2.createElement)("option", { value: "", disabled: true }, placeholder || title),
286
+ rows.map((row) => (0, import_react2.createElement)("option", { key: row.value, value: row.value, title: row.description }, `${row.group ? `${row.group} \xB7 ` : ""}${row.name}`))
142
287
  )
143
288
  );
144
289
  }
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
- }
184
290
  function apply(ctx) {
185
291
  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));
292
+ installTranscriptView(ctx);
191
293
  ctx.effect(() => ctx.locale.register("oneagentsAcp", dictionaries));
192
294
  const t = ctx.locale.bind("oneagentsAcp");
193
295
  const native = /* @__PURE__ */ new Map();
@@ -241,9 +343,9 @@ function apply(ctx) {
241
343
  const binding = ctx.sessions.binding(sessionId);
242
344
  const preset = binding.session.projections.faceOf("agentPreset");
243
345
  const selection = binding.session.projections.faceOf("modelSelection");
244
- const presetId = (0, import_react.useSyncExternalStore)((fn) => preset.subscribe(fn), () => preset.getSnapshot());
245
- const projected = (0, import_react.useSyncExternalStore)((fn) => selection.subscribe(fn), () => selection.getSnapshot());
246
- const capabilities = (0, import_react.useSyncExternalStore)((fn) => {
346
+ const presetId = (0, import_react2.useSyncExternalStore)((fn) => preset.subscribe(fn), () => preset.getSnapshot());
347
+ const projected = (0, import_react2.useSyncExternalStore)((fn) => selection.subscribe(fn), () => selection.getSnapshot());
348
+ const capabilities = (0, import_react2.useSyncExternalStore)((fn) => {
247
349
  let set = listeners.get(sessionId);
248
350
  if (!set) listeners.set(sessionId, set = /* @__PURE__ */ new Set());
249
351
  set.add(fn);
@@ -252,11 +354,11 @@ function apply(ctx) {
252
354
  };
253
355
  }, () => native.get(sessionId));
254
356
  const external = String(presetId ?? "").startsWith("oneagents-acp-");
255
- const [catalog, setCatalog] = (0, import_react.useState)(null);
256
- const [error, setError] = (0, import_react.useState)("");
257
- const [loadError, setLoadError] = (0, import_react.useState)("");
258
- const [busy, setBusy] = (0, import_react.useState)(false);
259
- const [expanded, setExpanded] = (0, import_react.useState)(false);
357
+ const [catalog, setCatalog] = (0, import_react2.useState)(null);
358
+ const [error, setError] = (0, import_react2.useState)("");
359
+ const [loadError, setLoadError] = (0, import_react2.useState)("");
360
+ const [busy, setBusy] = (0, import_react2.useState)(false);
361
+ const [expanded, setExpanded] = (0, import_react2.useState)(false);
260
362
  const refresh = async () => {
261
363
  try {
262
364
  if (external) await load(sessionId);
@@ -270,10 +372,10 @@ function apply(ctx) {
270
372
  setLoadError(String(error2.message ?? error2));
271
373
  }
272
374
  };
273
- (0, import_react.useEffect)(() => {
375
+ (0, import_react2.useEffect)(() => {
274
376
  void refresh();
275
377
  }, [sessionId, presetId]);
276
- (0, import_react.useEffect)(() => {
378
+ (0, import_react2.useEffect)(() => {
277
379
  if (!external) return;
278
380
  const timer = setInterval(() => {
279
381
  if (document.visibilityState === "visible") void refresh();
@@ -296,13 +398,13 @@ function apply(ctx) {
296
398
  if (external && capabilities) {
297
399
  const configs = capabilities.configOptions.filter((option) => option.type === "select");
298
400
  const model = configs.find((option) => option.category === "model" || option.id === "model");
299
- if (model) controls.push((0, import_react.createElement)(Select, { key: model.id, title: model.name || t("model"), value: model.currentValue, rows: choices(model), disabled, onSelect: (value) => change(() => configure(sessionId, model.id, value)) }));
300
- else controls.push((0, import_react.createElement)("span", { key: "unsupported", title: t("unsupported"), style: { fontSize: 12 } }, `ACP \xB7 ${capabilities.agent}`));
401
+ if (model) controls.push((0, import_react2.createElement)(Select, { key: model.id, title: model.name || t("model"), value: model.currentValue, rows: choices(model), disabled, onSelect: (value) => change(() => configure(sessionId, model.id, value)) }));
402
+ else controls.push((0, import_react2.createElement)("span", { key: "unsupported", title: t("unsupported"), style: { fontSize: 12 } }, `ACP \xB7 ${capabilities.agent}`));
301
403
  const additional = configs.filter((option) => option !== model && !(capabilities.modes && (option.category === "mode" || option.id === "mode")));
302
- if (additional.length || capabilities.modes) controls.push((0, import_react.createElement)("button", { key: "settings", type: "button", style: selectStyle, onClick: () => setExpanded(!expanded), "aria-expanded": expanded }, t("native")));
404
+ if (additional.length || capabilities.modes) controls.push((0, import_react2.createElement)("button", { key: "settings", type: "button", style: selectStyle, onClick: () => setExpanded(!expanded), "aria-expanded": expanded }, t("native")));
303
405
  if (expanded) {
304
- for (const option of additional) controls.push((0, import_react.createElement)(Select, { key: option.id, title: option.name, value: option.currentValue, rows: choices(option), disabled, onSelect: (value) => change(() => configure(sessionId, option.id, value)) }));
305
- if (capabilities.modes) controls.push((0, import_react.createElement)(Select, { key: "mode", title: t("mode"), value: capabilities.modes.currentModeId, rows: capabilities.modes.availableModes.map((m) => ({ value: m.id, name: m.name, description: m.description })), disabled, onSelect: (value) => change(() => configure(sessionId, "$mode", value)) }));
406
+ for (const option of additional) controls.push((0, import_react2.createElement)(Select, { key: option.id, title: option.name, value: option.currentValue, rows: choices(option), disabled, onSelect: (value) => change(() => configure(sessionId, option.id, value)) }));
407
+ if (capabilities.modes) controls.push((0, import_react2.createElement)(Select, { key: "mode", title: t("mode"), value: capabilities.modes.currentModeId, rows: capabilities.modes.availableModes.map((m) => ({ value: m.id, name: m.name, description: m.description })), disabled, onSelect: (value) => change(() => configure(sessionId, "$mode", value)) }));
306
408
  }
307
409
  } else if (!external && catalog) {
308
410
  const current = projected?.next ?? catalog.default;
@@ -311,15 +413,15 @@ function apply(ctx) {
311
413
  const result = await ctx.remote.session.selectModel({ sessionId, provider, model: model2, ...reasoningEffort ? { reasoningEffort } : {} });
312
414
  if (!result.ok) throw new Error(result.error.message);
313
415
  };
314
- controls.push((0, import_react.createElement)(Select, { key: "dsh-model", title: t("model"), value: current?.provider === "1agents-acp" ? "" : JSON.stringify([current?.provider, current?.model]), rows, disabled, placeholder: t("choose"), onSelect: (value) => change(() => select(...JSON.parse(value))) }));
416
+ controls.push((0, import_react2.createElement)(Select, { key: "dsh-model", title: t("model"), value: current?.provider === "1agents-acp" ? "" : JSON.stringify([current?.provider, current?.model]), rows, disabled, placeholder: t("choose"), onSelect: (value) => change(() => select(...JSON.parse(value))) }));
315
417
  const model = catalog.groups.find((g) => g.id === current?.provider)?.models.find((m) => m.id === current?.model);
316
- if (model?.reasoning) controls.push((0, import_react.createElement)(Select, { key: "effort", title: t("effort"), value: current.reasoningEffort ?? model.reasoning.defaultEffort, rows: model.reasoning.efforts.map((e) => ({ value: e.id, name: e.name })), disabled, onSelect: (value) => change(() => select(current.provider, current.model, value)) }));
317
- } else if (!error && !loadError) controls.push((0, import_react.createElement)("span", { key: "loading", style: { fontSize: 12 } }, t("loading")));
318
- if (error || loadError) controls.push((0, import_react.createElement)("span", { key: "error", role: "alert", style: { color: "#c64b45", fontSize: 12, maxWidth: 360 } }, error || loadError, " ", (0, import_react.createElement)("button", { type: "button", onClick: () => {
418
+ if (model?.reasoning) controls.push((0, import_react2.createElement)(Select, { key: "effort", title: t("effort"), value: current.reasoningEffort ?? model.reasoning.defaultEffort, rows: model.reasoning.efforts.map((e) => ({ value: e.id, name: e.name })), disabled, onSelect: (value) => change(() => select(current.provider, current.model, value)) }));
419
+ } else if (!error && !loadError) controls.push((0, import_react2.createElement)("span", { key: "loading", style: { fontSize: 12 } }, t("loading")));
420
+ if (error || loadError) controls.push((0, import_react2.createElement)("span", { key: "error", role: "alert", style: { color: "#c64b45", fontSize: 12, maxWidth: 360 } }, error || loadError, " ", (0, import_react2.createElement)("button", { type: "button", onClick: () => {
319
421
  setError("");
320
422
  void refresh();
321
423
  } }, t("retry"))));
322
- return (0, import_react.createElement)("div", { "data-oneagents-acp-controls": external ? "acp" : "dsh", style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 8 } }, controls);
424
+ return (0, import_react2.createElement)("div", { "data-oneagents-acp-controls": external ? "acp" : "dsh", style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 8 } }, controls);
323
425
  }
324
426
  ctx.slots.inject("conversation.input.model", () => ctx.slots.register({ name: "conversation.input.model", inject: (sessionId) => ({ sessionId }) }, ModelControls));
325
427
  ctx.effect(() => ctx.commandUi.register({