@1agents/acp-service 0.5.3 → 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 +1 -1
- package/vendor/dsh/README.md +1 -1
- package/vendor/dsh/adapter.js +4 -2
- package/vendor/dsh/client.js +198 -56
package/package.json
CHANGED
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 is preserved as display metadata on empty text blocks in DSH's existing assistant stream records and projected onto
|
|
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
|
|
package/vendor/dsh/adapter.js
CHANGED
|
@@ -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
|
-
|
|
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'];
|
package/vendor/dsh/client.js
CHANGED
|
@@ -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,6 +18,14 @@ 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
|
|
@@ -26,12 +36,12 @@ __export(client_exports, {
|
|
|
26
36
|
inject: () => inject
|
|
27
37
|
});
|
|
28
38
|
module.exports = __toCommonJS(client_exports);
|
|
29
|
-
var
|
|
39
|
+
var import_react2 = require("react");
|
|
30
40
|
|
|
31
41
|
// src/tool-conversation.js
|
|
32
42
|
var names = { execute: "Bash", read: "Read", edit: "Edit", delete: "Delete", move: "Move", search: "Search", fetch: "Fetch", think: "Think" };
|
|
33
43
|
function contentOf(tool) {
|
|
34
|
-
|
|
44
|
+
const content = (tool.content ?? []).flatMap((item) => {
|
|
35
45
|
if (item.type === "content" && item.content.type === "text") return [item.content];
|
|
36
46
|
if (item.type === "diff") return [{ type: "text", text: `${item.path}
|
|
37
47
|
---
|
|
@@ -40,13 +50,14 @@ ${item.oldText ?? ""}
|
|
|
40
50
|
${item.newText}` }];
|
|
41
51
|
return [];
|
|
42
52
|
});
|
|
43
|
-
if (
|
|
53
|
+
if (content.length || tool.rawOutput == null) return content;
|
|
44
54
|
return [{ type: "text", text: typeof tool.rawOutput === "string" ? tool.rawOutput : JSON.stringify(tool.rawOutput, null, 2) }];
|
|
45
55
|
}
|
|
46
56
|
function rootOf(state, location) {
|
|
47
57
|
const { tool, requestId, turn, step } = state.data;
|
|
48
58
|
const name = tool.name && tool.name !== "Tool" ? tool.name : names[tool.kind] ?? tool.title ?? tool.name ?? "Tool";
|
|
49
|
-
const
|
|
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);
|
|
50
61
|
const head = { callId: `${requestId}:${tool.toolCallId}`, name, argsRaw, turn, step, time: state.time, subCalls: [] };
|
|
51
62
|
const settled = tool.status === "completed" || tool.status === "failed";
|
|
52
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;
|
|
@@ -65,60 +76,190 @@ function rootOf(state, location) {
|
|
|
65
76
|
subCalls: []
|
|
66
77
|
};
|
|
67
78
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
if (event.type === "assistant/
|
|
71
|
-
if (event.type === "assistant/message" || event.type === "assistant/attempt") {
|
|
72
|
-
return (event.data.stream ?? []).flatMap((record) => record.type === "chunk" ? fromChunk(record.chunk, record.time) : []);
|
|
73
|
-
}
|
|
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");
|
|
74
82
|
return [];
|
|
75
83
|
}
|
|
76
84
|
function fold(previous, match) {
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
tools
|
|
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
|
+
}
|
|
82
116
|
}
|
|
83
|
-
return
|
|
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;
|
|
84
129
|
}
|
|
85
130
|
var toolConversationDefinition = {
|
|
86
131
|
kind: "oneagents-acp-tools",
|
|
87
132
|
target: "chat",
|
|
88
|
-
match: (event) => {
|
|
89
|
-
const first = snapshots(event)[0];
|
|
90
|
-
return first ? { id: first.data.requestId, role: "start" } : null;
|
|
91
|
-
},
|
|
133
|
+
match: (event) => ["assistant/live-chunk", "assistant/message", "assistant/attempt"].includes(event.type) ? { id: `${event.data.turn}:${event.data.step}`, role: "start" } : null,
|
|
92
134
|
start: (_context, match) => fold(void 0, match),
|
|
93
135
|
update: (context, match) => fold(context.state, match),
|
|
94
136
|
publication: () => "immediate",
|
|
95
137
|
buildViewNode: (context) => {
|
|
96
138
|
const state = context.state;
|
|
97
|
-
if (!state) return null;
|
|
139
|
+
if (!state?.acp) return null;
|
|
98
140
|
const location = context.start?.location ?? context.matches[0]?.location ?? { kind: "unresolved" };
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
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" }];
|
|
102
155
|
return {
|
|
103
156
|
key: context.key,
|
|
104
157
|
id: context.id,
|
|
105
|
-
kind: "
|
|
158
|
+
kind: "assistant-step",
|
|
106
159
|
target: "chat",
|
|
107
|
-
|
|
108
|
-
// answer so DSH retains the completed Turn's process disclosure.
|
|
109
|
-
anchorSeq: location.kind === "step" ? location.step.start?.seq ?? state.seq : state.seq,
|
|
160
|
+
anchorSeq: state.seq,
|
|
110
161
|
location,
|
|
111
162
|
visibility: "visible",
|
|
112
|
-
data: {
|
|
163
|
+
data: {
|
|
164
|
+
status,
|
|
165
|
+
turn,
|
|
166
|
+
step,
|
|
167
|
+
blocks,
|
|
168
|
+
time: context.matches[0].event.time,
|
|
169
|
+
acpTranscript: { groups: groupParts(parts), status }
|
|
170
|
+
}
|
|
113
171
|
};
|
|
114
172
|
}
|
|
115
173
|
};
|
|
116
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
|
+
|
|
117
258
|
// src/client.js
|
|
118
259
|
var inject = ["slots", "sessions", "commandUi", "remote", "remote.session", "locale", "uiConversation", "conversation"];
|
|
119
260
|
var dictionaries = {
|
|
120
|
-
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", 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" },
|
|
121
|
-
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", 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." }
|
|
122
263
|
};
|
|
123
264
|
function choices(option) {
|
|
124
265
|
return (option.options ?? []).flatMap((item) => "group" in item ? item.options.map((value) => ({ ...value, group: item.name ?? item.group })) : [item]);
|
|
@@ -134,20 +275,21 @@ async function acpRequest(sessionId, change) {
|
|
|
134
275
|
}
|
|
135
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 };
|
|
136
277
|
function Select({ title, value, rows, disabled, onSelect, placeholder }) {
|
|
137
|
-
return (0,
|
|
278
|
+
return (0, import_react2.createElement)(
|
|
138
279
|
"label",
|
|
139
280
|
{ style: { display: "inline-flex", gap: 5, alignItems: "center", fontSize: 12 } },
|
|
140
|
-
(0,
|
|
141
|
-
(0,
|
|
281
|
+
(0, import_react2.createElement)("span", null, title),
|
|
282
|
+
(0, import_react2.createElement)(
|
|
142
283
|
"select",
|
|
143
284
|
{ "aria-label": title, style: selectStyle, value: value ?? "", disabled, onChange: (e) => onSelect(e.target.value) },
|
|
144
|
-
(0,
|
|
145
|
-
rows.map((row) => (0,
|
|
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}`))
|
|
146
287
|
)
|
|
147
288
|
);
|
|
148
289
|
}
|
|
149
290
|
function apply(ctx) {
|
|
150
291
|
ctx.uiConversation.events.register(toolConversationDefinition);
|
|
292
|
+
installTranscriptView(ctx);
|
|
151
293
|
ctx.effect(() => ctx.locale.register("oneagentsAcp", dictionaries));
|
|
152
294
|
const t = ctx.locale.bind("oneagentsAcp");
|
|
153
295
|
const native = /* @__PURE__ */ new Map();
|
|
@@ -201,9 +343,9 @@ function apply(ctx) {
|
|
|
201
343
|
const binding = ctx.sessions.binding(sessionId);
|
|
202
344
|
const preset = binding.session.projections.faceOf("agentPreset");
|
|
203
345
|
const selection = binding.session.projections.faceOf("modelSelection");
|
|
204
|
-
const presetId = (0,
|
|
205
|
-
const projected = (0,
|
|
206
|
-
const capabilities = (0,
|
|
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) => {
|
|
207
349
|
let set = listeners.get(sessionId);
|
|
208
350
|
if (!set) listeners.set(sessionId, set = /* @__PURE__ */ new Set());
|
|
209
351
|
set.add(fn);
|
|
@@ -212,11 +354,11 @@ function apply(ctx) {
|
|
|
212
354
|
};
|
|
213
355
|
}, () => native.get(sessionId));
|
|
214
356
|
const external = String(presetId ?? "").startsWith("oneagents-acp-");
|
|
215
|
-
const [catalog, setCatalog] = (0,
|
|
216
|
-
const [error, setError] = (0,
|
|
217
|
-
const [loadError, setLoadError] = (0,
|
|
218
|
-
const [busy, setBusy] = (0,
|
|
219
|
-
const [expanded, setExpanded] = (0,
|
|
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);
|
|
220
362
|
const refresh = async () => {
|
|
221
363
|
try {
|
|
222
364
|
if (external) await load(sessionId);
|
|
@@ -230,10 +372,10 @@ function apply(ctx) {
|
|
|
230
372
|
setLoadError(String(error2.message ?? error2));
|
|
231
373
|
}
|
|
232
374
|
};
|
|
233
|
-
(0,
|
|
375
|
+
(0, import_react2.useEffect)(() => {
|
|
234
376
|
void refresh();
|
|
235
377
|
}, [sessionId, presetId]);
|
|
236
|
-
(0,
|
|
378
|
+
(0, import_react2.useEffect)(() => {
|
|
237
379
|
if (!external) return;
|
|
238
380
|
const timer = setInterval(() => {
|
|
239
381
|
if (document.visibilityState === "visible") void refresh();
|
|
@@ -256,13 +398,13 @@ function apply(ctx) {
|
|
|
256
398
|
if (external && capabilities) {
|
|
257
399
|
const configs = capabilities.configOptions.filter((option) => option.type === "select");
|
|
258
400
|
const model = configs.find((option) => option.category === "model" || option.id === "model");
|
|
259
|
-
if (model) controls.push((0,
|
|
260
|
-
else controls.push((0,
|
|
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}`));
|
|
261
403
|
const additional = configs.filter((option) => option !== model && !(capabilities.modes && (option.category === "mode" || option.id === "mode")));
|
|
262
|
-
if (additional.length || capabilities.modes) controls.push((0,
|
|
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")));
|
|
263
405
|
if (expanded) {
|
|
264
|
-
for (const option of additional) controls.push((0,
|
|
265
|
-
if (capabilities.modes) controls.push((0,
|
|
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)) }));
|
|
266
408
|
}
|
|
267
409
|
} else if (!external && catalog) {
|
|
268
410
|
const current = projected?.next ?? catalog.default;
|
|
@@ -271,15 +413,15 @@ function apply(ctx) {
|
|
|
271
413
|
const result = await ctx.remote.session.selectModel({ sessionId, provider, model: model2, ...reasoningEffort ? { reasoningEffort } : {} });
|
|
272
414
|
if (!result.ok) throw new Error(result.error.message);
|
|
273
415
|
};
|
|
274
|
-
controls.push((0,
|
|
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))) }));
|
|
275
417
|
const model = catalog.groups.find((g) => g.id === current?.provider)?.models.find((m) => m.id === current?.model);
|
|
276
|
-
if (model?.reasoning) controls.push((0,
|
|
277
|
-
} else if (!error && !loadError) controls.push((0,
|
|
278
|
-
if (error || loadError) controls.push((0,
|
|
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: () => {
|
|
279
421
|
setError("");
|
|
280
422
|
void refresh();
|
|
281
423
|
} }, t("retry"))));
|
|
282
|
-
return (0,
|
|
424
|
+
return (0, import_react2.createElement)("div", { "data-oneagents-acp-controls": external ? "acp" : "dsh", style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 8 } }, controls);
|
|
283
425
|
}
|
|
284
426
|
ctx.slots.inject("conversation.input.model", () => ctx.slots.register({ name: "conversation.input.model", inject: (sessionId) => ({ sessionId }) }, ModelControls));
|
|
285
427
|
ctx.effect(() => ctx.commandUi.register({
|