@1agents/acp-service 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -0
- package/dist/bin/a2a.d.ts +1 -0
- package/dist/bin/a2a.js +50 -0
- package/dist/bin/acp-service.js +20 -2
- package/dist/src/a2a/executor.d.ts +29 -0
- package/dist/src/a2a/executor.js +144 -0
- package/dist/src/a2a/gateway.d.ts +136 -0
- package/dist/src/a2a/gateway.js +426 -0
- package/dist/src/a2a/index.d.ts +7 -0
- package/dist/src/a2a/index.js +4 -0
- package/dist/src/a2a/server.d.ts +22 -0
- package/dist/src/a2a/server.js +339 -0
- package/dist/src/a2a/store.d.ts +34 -0
- package/dist/src/a2a/store.js +468 -0
- package/dist/src/a2a/types.d.ts +26 -0
- package/dist/src/a2a/types.js +1 -0
- package/package.json +15 -8
- package/skills/acp-service/SKILL.md +90 -0
- package/skills/acp-service/agents/openai.yaml +3 -0
- package/skills/acp-service/references/a2a.md +183 -0
- package/skills/acp-service/references/acp.md +104 -0
- package/skills/acp-service/references/dsh.md +61 -0
- package/vendor/dsh/README.md +5 -3
- package/vendor/dsh/a2a-executor.d.ts +26 -0
- package/vendor/dsh/a2a-executor.js +169 -0
- package/vendor/dsh/a2a.d.ts +15 -0
- package/vendor/dsh/a2a.js +32 -0
- package/vendor/dsh/adapter.js +4 -2
- package/vendor/dsh/client.js +198 -56
- package/vendor/dsh/index.d.ts +5 -1
- package/vendor/dsh/index.js +3 -0
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({
|
package/vendor/dsh/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import { type Config } from './adapter.js';
|
|
3
3
|
import { type ServiceOptions } from './service-process.js';
|
|
4
|
+
import { type DshA2AOptions } from './a2a.js';
|
|
5
|
+
export type { DshA2AOptions } from './a2a.js';
|
|
4
6
|
export { name, inject } from '@1agents/acp-service';
|
|
5
|
-
export declare function apply(ctx: Context, input?: Partial<Config & ServiceOptions>
|
|
7
|
+
export declare function apply(ctx: Context, input?: Partial<Config & ServiceOptions> & {
|
|
8
|
+
a2a?: DshA2AOptions;
|
|
9
|
+
}): Promise<void>;
|
package/vendor/dsh/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { AcpAdapter } from './adapter.js';
|
|
|
5
5
|
import { discoverPresets } from './discovery.js';
|
|
6
6
|
import { NativeSessions } from './imports.js';
|
|
7
7
|
import { acquireService, resolveServiceOptions } from './service-process.js';
|
|
8
|
+
import { mountDshA2A } from './a2a.js';
|
|
8
9
|
export { name, inject } from '@1agents/acp-service';
|
|
9
10
|
export async function apply(ctx, input = {}) {
|
|
10
11
|
const homePath = ctx.get('dshHomePath');
|
|
@@ -81,4 +82,6 @@ export async function apply(ctx, input = {}) {
|
|
|
81
82
|
});
|
|
82
83
|
ctx.effect(() => dispose);
|
|
83
84
|
}
|
|
85
|
+
if (input.a2a)
|
|
86
|
+
await mountDshA2A(ctx, input.a2a, join(home, 'plugins', '1agents-acp', 'a2a'));
|
|
84
87
|
}
|