pi-web-ui 0.115.0 → 0.116.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/CHANGELOG.md +29 -0
- package/bin/pi-web-ui.mjs +21 -1
- package/dist/gh-comment-781.md +5 -0
- package/dist/server/agent-service-daemon.js +84 -2
- package/dist/server/agent-service.js +107 -26
- package/dist/server/client-state.js +17 -2
- package/dist/server/device-center/bot-execution.js +29 -1
- package/dist/server/device-center/collab-service.js +36 -5
- package/dist/server/device-center/collab-tool.js +90 -5
- package/dist/server/device-center/execution-guides.js +2 -2
- package/dist/server/device-center/execution-instructions.js +2 -1
- package/dist/server/device-center/execution-settings.js +138 -25
- package/dist/server/device-center/executor.js +4 -1
- package/dist/server/device-center/file-sync.js +14 -13
- package/dist/server/device-center/group-context-message.js +3 -1
- package/dist/server/device-center/group-context.js +73 -3
- package/dist/server/device-center/hub-conversations.js +58 -3
- package/dist/server/device-center/hub-locks.js +320 -0
- package/dist/server/device-center/hub-page.js +13 -33
- package/dist/server/device-center/hub-webhooks.js +165 -0
- package/dist/server/device-center/hub.js +872 -64
- package/dist/server/device-center/local-hub.js +2 -1
- package/dist/server/device-center/local-page.js +17 -0
- package/dist/server/device-center/local.js +74 -1
- package/dist/server/device-center/partition-log.js +293 -0
- package/dist/server/device-center/runtime.js +49 -0
- package/dist/server/device-center/smoke-preview.js +3 -0
- package/dist/server/device-center/store.js +163 -64
- package/dist/server/device-center/task-scheduler.js +48 -3
- package/dist/server/device-center/transfers.js +41 -15
- package/dist/server/dispatch-domain-handlers.js +14 -3
- package/dist/server/durable/durable-capabilities.js +11 -0
- package/dist/server/engine-probe.js +112 -1
- package/dist/server/global-loader.js +119 -19
- package/dist/server/index.js +133 -16
- package/dist/server/managed.js +2 -0
- package/dist/server/markers/builtins/services.js +123 -0
- package/dist/server/markers/builtins/todo.js +189 -0
- package/dist/server/markers-list-tool.js +34 -0
- package/dist/server/model-admin.js +48 -6
- package/dist/server/model-enrich.js +10 -1
- package/dist/server/orchestrator.js +109 -0
- package/dist/server/plugins.js +64 -7
- package/dist/server/prompt-composer.js +39 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/reasoning-registry.js +207 -0
- package/dist/server/startup-banner.js +35 -0
- package/dist/server/subagents.js +2 -1
- package/dist/server/system-prompt-soul.js +41 -0
- package/dist/server/tool-manager.js +17 -9
- package/dist/server/unauthorized-page.js +319 -0
- package/dist/server/univer-service.js +448 -0
- package/dist/server/universal/drivers/dsh-driver.js +379 -0
- package/dist/test-artifact.md +9 -0
- package/dist/test-preview-modal.md +11 -0
- package/dist/test-report.html +20 -0
- package/docs/architecture-plugins.md +946 -0
- package/docs/device-center.md +6 -0
- package/package.json +2 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BYzPgmoq.js → BgTasksModal-BDoOpj-F.js} +1 -1
- package/web/dist/assets/{BgTasksModal-ni0VTmAQ.js → BgTasksModal-C0i3O1FT.js} +1 -1
- package/web/dist/assets/{CanvasStudio-BCUeEf25.js → CanvasStudio-B8thymBN.js} +3 -3
- package/web/dist/assets/{CanvasStudio-DNmDNBod.js → CanvasStudio-zSxyIx1R.js} +3 -3
- package/web/dist/assets/DeviceCenter-DfAHKcid.js +3 -0
- package/web/dist/assets/DeviceCenter-ydvOTlzE.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-q5Ik8oXg.js +1 -0
- package/web/dist/assets/DeviceGroups-CI14_SRb.js +1 -0
- package/web/dist/assets/DeviceGroups-DvsB5IEU.js +1 -0
- package/web/dist/assets/{Dropdown-CGXD0DfT.js → Dropdown-C4LIhshN.js} +1 -1
- package/web/dist/assets/FilePreview-BgGongmv.js +2 -0
- package/web/dist/assets/FilePreview-D4NrhF-U.js +2 -0
- package/web/dist/assets/{GlobalSearchModal-mevF-ySi.js → GlobalSearchModal-BWgU8yPd.js} +1 -1
- package/web/dist/assets/{GlobalSearchModal-qL99FN_F.js → GlobalSearchModal-F7fNimKk.js} +1 -1
- package/web/dist/assets/GroupConversation-Dh71Pdb-.js +17 -0
- package/web/dist/assets/GroupConversation-ZK3nRmNm.js +17 -0
- package/web/dist/assets/{HintTip-LHwkS2jV.js → HintTip-c6d0TJoh.js} +1 -1
- package/web/dist/assets/ModelConfigModal-YVEgyy34.js +2 -0
- package/web/dist/assets/ModelConfigModal-vWtg3srp.js +2 -0
- package/web/dist/assets/{PiSetupModal-DE5-gEtI.js → PiSetupModal-BmMrrgB9.js} +1 -1
- package/web/dist/assets/{ProviderOAuthControls-6UMARucA.js → ProviderOAuthControls-BGSBIKD7.js} +1 -1
- package/web/dist/assets/SCMPanel-B8_EDxNr.js +2 -0
- package/web/dist/assets/SCMPanel-BU58qk3T.js +2 -0
- package/web/dist/assets/SettingsModal-CMUybq3J.js +32 -0
- package/web/dist/assets/SettingsModal-OBmGTh-5.js +32 -0
- package/web/dist/assets/{TerminalPanel-CTp_BZ4S.js → TerminalPanel-0CYvD72B.js} +2 -2
- package/web/dist/assets/{TerminalPanel-CkYxC-Gh.js → TerminalPanel-DDavKvFr.js} +2 -2
- package/web/dist/assets/{TuiOverlayModal-1cRLP8IF.js → TuiOverlayModal-BsA-QTvN.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-2xlptqWX.js → TuiOverlayModal-DzoVQBuG.js} +1 -1
- package/web/dist/assets/app-globals-CZxzGvIo.js +123 -0
- package/web/dist/assets/{canvas-client-Bye9nSFO.js → canvas-client-CUnXlQYX.js} +1 -1
- package/web/dist/assets/{desktop-kjBoE3Nu.js → desktop-aAKpvKJV.js} +1 -1
- package/web/dist/assets/index-C6DwztqE.css +1 -0
- package/web/dist/assets/index-CuN802Sj.js +93 -0
- package/web/dist/assets/index-EH5Fw9fa.js +93 -0
- package/web/dist/assets/{plugin-host-C8mNgghx.js → plugin-host-BRWib9DF.js} +1 -1
- package/web/dist/assets/{remote-ssh-client-CeP3CLUW.js → remote-ssh-client-CfYSMEZg.js} +1 -1
- package/web/dist/assets/{theme-BXGpyTMh.js → theme-D2l_mLNo.js} +1 -1
- package/web/dist/index.html +10 -10
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/DeviceCenter-BcBhRgL6.js +0 -3
- package/web/dist/assets/DeviceCenter-CmL5FZmt.js +0 -3
- package/web/dist/assets/DeviceGroups-CLdpdnI7.js +0 -1
- package/web/dist/assets/DeviceGroups-CgBaDPrD.js +0 -1
- package/web/dist/assets/FilePreview-B8iqnBjy.js +0 -2
- package/web/dist/assets/FilePreview-BqviZKCN.js +0 -2
- package/web/dist/assets/GroupConversation-B88Yy-lt.js +0 -3
- package/web/dist/assets/GroupConversation-BwP5NVOE.js +0 -3
- package/web/dist/assets/ModelConfigModal-Do3Fe3jH.js +0 -2
- package/web/dist/assets/SCMPanel-Hi6QqC1Q.js +0 -2
- package/web/dist/assets/SCMPanel-ezY_ZtCu.js +0 -2
- package/web/dist/assets/SettingsModal-6HgeEsJ8.js +0 -20
- package/web/dist/assets/SettingsModal-CF-7MwqS.js +0 -20
- package/web/dist/assets/app-globals-DZNa9v8u.js +0 -325
- package/web/dist/assets/index-CsFs_HMb.css +0 -1
- package/web/dist/assets/index-DHeeHS_l.js +0 -85
- package/web/dist/assets/index-DTZch8uz.js +0 -85
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-driver.ts — DeepSeek Harness (DSH) 引擎驱动实现(基于 Universal Agent 底座)。
|
|
3
|
+
*
|
|
4
|
+
* 通过 stdio JSON-RPC 与 DSH 运行时子进程通信,将 DSH 的事件流、思考过程、工具调用与
|
|
5
|
+
* 统计信息完整映射到 Universal 底座的 AgentEventSink。
|
|
6
|
+
*
|
|
7
|
+
* 特性:
|
|
8
|
+
* 1. 原生流式 Thinking 与正文增量(reasoning-delta / text-delta);
|
|
9
|
+
* 2. 工具调用生命周期(tool/call → onToolStart, tool/result → onToolEnd);
|
|
10
|
+
* 3. 自动计算 Token 用量与缓存命中率(normalizeDshUsage);
|
|
11
|
+
* 4. 人在回路问卷提问桥(question.pending ↔ onAskUser);
|
|
12
|
+
* 5. 全量接入公共模型底座(models.json 自定义端点与多密钥动态注入);
|
|
13
|
+
* 6. 强杀中断与自愈恢复(abort → runtime.kill)。
|
|
14
|
+
*/
|
|
15
|
+
import { randomUUID } from "node:crypto";
|
|
16
|
+
import { homedir } from "node:os";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
import { BaseAgentDriver } from "../driver-base.js";
|
|
19
|
+
import { DshRuntime } from "../../dsh/dsh-client.js";
|
|
20
|
+
import { normalizeDshUsage } from "../../dsh/dsh-usage.js";
|
|
21
|
+
import { listCustomModelsFromConfig } from "../../model-resolver.js";
|
|
22
|
+
import { discoverDiskSkills } from "../../skill-discovery.js";
|
|
23
|
+
const DEFAULT_MODEL = "deepseek-v4-flash";
|
|
24
|
+
const DSH_OFFICIAL_MODELS = [
|
|
25
|
+
{ id: "deepseek-v4-flash", name: "DeepSeek V4 Flash", provider: "deepseek", vision: false },
|
|
26
|
+
{ id: "deepseek-v4-pro", name: "DeepSeek V4 Pro", provider: "deepseek", vision: false },
|
|
27
|
+
{
|
|
28
|
+
id: "deepseek-v4-flash-vision-exp",
|
|
29
|
+
name: "DeepSeek V4 Flash Vision (exp)",
|
|
30
|
+
provider: "deepseek",
|
|
31
|
+
vision: true,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
export class DshAgentDriver extends BaseAgentDriver {
|
|
35
|
+
id = "dsh";
|
|
36
|
+
name = "DeepSeek Harness";
|
|
37
|
+
capabilities = {
|
|
38
|
+
supportsTreeFork: false,
|
|
39
|
+
supportsHistoryEdit: false,
|
|
40
|
+
supportsToolPromptOverride: false,
|
|
41
|
+
supportsModelSwitch: true,
|
|
42
|
+
supportsThinkingLevels: true,
|
|
43
|
+
supportsAskUser: true,
|
|
44
|
+
};
|
|
45
|
+
agentDir;
|
|
46
|
+
dataDir;
|
|
47
|
+
sessionRoot;
|
|
48
|
+
currentModel;
|
|
49
|
+
currentProvider;
|
|
50
|
+
activeSessionId = null;
|
|
51
|
+
runtime;
|
|
52
|
+
activeSink = null;
|
|
53
|
+
turnCompleteEmitted = false;
|
|
54
|
+
constructor(cwd, opts) {
|
|
55
|
+
super(cwd);
|
|
56
|
+
this.agentDir = opts?.agentDir || process.env.PI_CODING_AGENT_DIR || join(homedir(), ".pi", "agent");
|
|
57
|
+
this.dataDir = opts?.dataDir || process.env.PI_WEB_DATA_DIR || join(homedir(), ".pi-web");
|
|
58
|
+
this.sessionRoot = opts?.sessionRoot;
|
|
59
|
+
this.currentModel = opts?.defaultModel ?? DEFAULT_MODEL;
|
|
60
|
+
this.currentProvider = opts?.defaultProvider ?? "deepseek";
|
|
61
|
+
if (opts?.runtime) {
|
|
62
|
+
this.runtime = opts.runtime;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.runtime = new DshRuntime({
|
|
66
|
+
cwd: this.cwd,
|
|
67
|
+
provider: "deepseek-official",
|
|
68
|
+
model: this.currentModel,
|
|
69
|
+
modelProvider: this.currentProvider,
|
|
70
|
+
sessionRoot: this.sessionRoot,
|
|
71
|
+
dataDir: this.dataDir,
|
|
72
|
+
agentDir: this.agentDir,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
this.setupNotificationHandler();
|
|
76
|
+
}
|
|
77
|
+
async createSession() {
|
|
78
|
+
const sessionId = `web-${randomUUID().slice(0, 12)}`;
|
|
79
|
+
this.activeSessionId = sessionId;
|
|
80
|
+
return sessionId;
|
|
81
|
+
}
|
|
82
|
+
async resumeSession(sessionId) {
|
|
83
|
+
this.activeSessionId = sessionId;
|
|
84
|
+
}
|
|
85
|
+
getActiveSessionId() {
|
|
86
|
+
return this.activeSessionId;
|
|
87
|
+
}
|
|
88
|
+
getSupportedThinkingLevels() {
|
|
89
|
+
return ["high"];
|
|
90
|
+
}
|
|
91
|
+
/** 绑定运行时通知事件分发到 Universal 底座的 sink */
|
|
92
|
+
setupNotificationHandler() {
|
|
93
|
+
this.runtime.onNotification((method, params) => {
|
|
94
|
+
const sink = this.activeSink;
|
|
95
|
+
if (!sink || typeof params !== "object" || params === null)
|
|
96
|
+
return;
|
|
97
|
+
const p = params;
|
|
98
|
+
if (method === "session.event") {
|
|
99
|
+
const event = p.event;
|
|
100
|
+
if (!event)
|
|
101
|
+
return;
|
|
102
|
+
const type = String(event.type ?? "");
|
|
103
|
+
const data = (event.data ?? {});
|
|
104
|
+
switch (type) {
|
|
105
|
+
case "assistant/chunk": {
|
|
106
|
+
const chunk = (data.chunk ?? {});
|
|
107
|
+
const chunkType = String(chunk.type ?? "");
|
|
108
|
+
if (chunkType === "reasoning-delta" && chunk.text) {
|
|
109
|
+
sink.onThinkingDelta(String(chunk.text));
|
|
110
|
+
}
|
|
111
|
+
else if (chunkType === "text-delta" && chunk.text) {
|
|
112
|
+
sink.onTextDelta(String(chunk.text));
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case "tool/call": {
|
|
117
|
+
const callId = String(data.id ?? `call_${Date.now()}`);
|
|
118
|
+
const toolName = String(data.name ?? "unknown");
|
|
119
|
+
const args = (data.args ?? {});
|
|
120
|
+
sink.onToolStart(callId, toolName, args);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case "tool/result": {
|
|
124
|
+
const message = (data.message ?? {});
|
|
125
|
+
const contentList = Array.isArray(message.content) ? message.content : [];
|
|
126
|
+
const tr = contentList.find((b) => b?.type === "tool-result");
|
|
127
|
+
const callId = String(tr?.toolCallId ?? data.id ?? "");
|
|
128
|
+
const isError = Boolean(tr?.isError ?? data.isError);
|
|
129
|
+
const rawText = Array.isArray(tr?.content)
|
|
130
|
+
? tr.content.map((c) => c?.text ?? "").join("\n")
|
|
131
|
+
: String(data.result ?? "");
|
|
132
|
+
sink.onToolEnd(callId, {
|
|
133
|
+
output: isError ? undefined : rawText,
|
|
134
|
+
error: isError ? rawText : undefined,
|
|
135
|
+
});
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case "assistant/message": {
|
|
139
|
+
const message = (data.message ?? {});
|
|
140
|
+
const usage = message.usage ? normalizeDshUsage(message.usage) : null;
|
|
141
|
+
const meta = {
|
|
142
|
+
model: this.currentModel,
|
|
143
|
+
usage: usage
|
|
144
|
+
? {
|
|
145
|
+
inputTokens: usage.input,
|
|
146
|
+
outputTokens: usage.output,
|
|
147
|
+
cacheReadTokens: usage.cacheRead,
|
|
148
|
+
cacheWriteTokens: usage.cacheWrite,
|
|
149
|
+
}
|
|
150
|
+
: undefined,
|
|
151
|
+
};
|
|
152
|
+
if (!this.turnCompleteEmitted) {
|
|
153
|
+
this.turnCompleteEmitted = true;
|
|
154
|
+
sink.onTurnComplete(meta);
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else if (method === "question.pending") {
|
|
161
|
+
if (sink.onAskUser && p.id && typeof p.question === "string") {
|
|
162
|
+
const qId = String(p.id);
|
|
163
|
+
const qText = String(p.question);
|
|
164
|
+
const options = Array.isArray(p.options)
|
|
165
|
+
? p.options
|
|
166
|
+
: undefined;
|
|
167
|
+
sink
|
|
168
|
+
.onAskUser(qId, qText, options)
|
|
169
|
+
.then((answers) => {
|
|
170
|
+
return this.runtime.answerQuestion(qId, [
|
|
171
|
+
{ id: qId, selected: answers.selected, custom: answers.custom },
|
|
172
|
+
]);
|
|
173
|
+
})
|
|
174
|
+
.catch(() => {
|
|
175
|
+
return this.runtime.answerQuestion(qId, [], true);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else if (method === "session.status") {
|
|
180
|
+
if (p.status === "idle" && !this.turnCompleteEmitted) {
|
|
181
|
+
this.turnCompleteEmitted = true;
|
|
182
|
+
sink.onTurnComplete({ model: this.currentModel });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
async sendPrompt(prompt, attachments, sink) {
|
|
188
|
+
this.activeSink = sink;
|
|
189
|
+
this.turnCompleteEmitted = false;
|
|
190
|
+
if (!this.activeSessionId) {
|
|
191
|
+
await this.createSession();
|
|
192
|
+
}
|
|
193
|
+
const sessionId = this.activeSessionId;
|
|
194
|
+
await this.runtime.start();
|
|
195
|
+
// 构建 contentBlocks
|
|
196
|
+
const contentBlocks = [];
|
|
197
|
+
// 处理图片和文件附件
|
|
198
|
+
if (attachments && attachments.length > 0) {
|
|
199
|
+
for (const att of attachments) {
|
|
200
|
+
if (att.imageData) {
|
|
201
|
+
try {
|
|
202
|
+
const name = att.name || "image.png";
|
|
203
|
+
const mime = name.endsWith(".png")
|
|
204
|
+
? "image/png"
|
|
205
|
+
: name.endsWith(".gif")
|
|
206
|
+
? "image/gif"
|
|
207
|
+
: name.endsWith(".webp")
|
|
208
|
+
? "image/webp"
|
|
209
|
+
: "image/jpeg";
|
|
210
|
+
const res = await this.runtime.attachmentSave(mime, att.imageData, name);
|
|
211
|
+
if (res.ref) {
|
|
212
|
+
contentBlocks.push({ type: "image", attachmentRef: res.ref });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
/* 回落内联 */
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else if (att.path) {
|
|
220
|
+
contentBlocks.push({
|
|
221
|
+
type: "text",
|
|
222
|
+
text: `[Attachment: ${att.name || att.path}]\n${att.path}`,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
contentBlocks.push({ type: "text", text: prompt });
|
|
228
|
+
let turnDoneResolve;
|
|
229
|
+
const turnPromise = new Promise((resolve) => {
|
|
230
|
+
turnDoneResolve = resolve;
|
|
231
|
+
});
|
|
232
|
+
// 代理 sink 以获知完成时点
|
|
233
|
+
const wrappedSink = {
|
|
234
|
+
onTextDelta: (d) => sink.onTextDelta(d),
|
|
235
|
+
onThinkingDelta: (d) => sink.onThinkingDelta(d),
|
|
236
|
+
onToolStart: (id, name, args) => sink.onToolStart(id, name, args),
|
|
237
|
+
onToolUpdate: (id, out) => sink.onToolUpdate?.(id, out),
|
|
238
|
+
onToolEnd: (id, res) => sink.onToolEnd(id, res),
|
|
239
|
+
onAskUser: sink.onAskUser ? (id, q, opts) => sink.onAskUser(id, q, opts) : undefined,
|
|
240
|
+
onTurnComplete: (meta) => {
|
|
241
|
+
sink.onTurnComplete(meta);
|
|
242
|
+
turnDoneResolve();
|
|
243
|
+
},
|
|
244
|
+
onError: (err) => {
|
|
245
|
+
sink.onError(err);
|
|
246
|
+
turnDoneResolve();
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
this.activeSink = wrappedSink;
|
|
250
|
+
try {
|
|
251
|
+
await this.runtime.prompt(sessionId, contentBlocks);
|
|
252
|
+
await turnPromise;
|
|
253
|
+
}
|
|
254
|
+
catch (err) {
|
|
255
|
+
wrappedSink.onError(err instanceof Error ? err : new Error(String(err)));
|
|
256
|
+
}
|
|
257
|
+
finally {
|
|
258
|
+
this.activeSink = null;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
async abort() {
|
|
262
|
+
await this.runtime.kill();
|
|
263
|
+
}
|
|
264
|
+
async listModels() {
|
|
265
|
+
const official = DSH_OFFICIAL_MODELS.map((m) => ({
|
|
266
|
+
id: `deepseek/${m.id}`,
|
|
267
|
+
name: m.name,
|
|
268
|
+
}));
|
|
269
|
+
let dynamic = [];
|
|
270
|
+
try {
|
|
271
|
+
if (this.runtime.alive) {
|
|
272
|
+
const res = await this.runtime.listModels();
|
|
273
|
+
dynamic = (res.models ?? []).map((m) => ({
|
|
274
|
+
id: m.id.includes("/") ? m.id : `deepseek/${m.id}`,
|
|
275
|
+
name: m.name || m.id,
|
|
276
|
+
}));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
/* ignore */
|
|
281
|
+
}
|
|
282
|
+
let custom = [];
|
|
283
|
+
try {
|
|
284
|
+
const customList = listCustomModelsFromConfig(this.agentDir);
|
|
285
|
+
custom = customList.map((c) => ({
|
|
286
|
+
id: `${c.providerId}/${c.modelId}`,
|
|
287
|
+
name: c.name,
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
/* ignore */
|
|
292
|
+
}
|
|
293
|
+
const seen = new Set();
|
|
294
|
+
const result = [];
|
|
295
|
+
for (const m of [...official, ...dynamic, ...custom]) {
|
|
296
|
+
if (!seen.has(m.id)) {
|
|
297
|
+
seen.add(m.id);
|
|
298
|
+
result.push(m);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
async setModel(modelId) {
|
|
304
|
+
const normId = modelId.trim();
|
|
305
|
+
const hasSlash = normId.includes("/");
|
|
306
|
+
const targetProvider = hasSlash ? normId.slice(0, normId.indexOf("/")) : "deepseek";
|
|
307
|
+
const bareModelId = hasSlash ? normId.slice(normId.indexOf("/") + 1) : normId;
|
|
308
|
+
this.currentModel = bareModelId;
|
|
309
|
+
this.currentProvider = targetProvider;
|
|
310
|
+
await this.runtime.restart(bareModelId, targetProvider);
|
|
311
|
+
}
|
|
312
|
+
async getSlashCommands() {
|
|
313
|
+
return [
|
|
314
|
+
{
|
|
315
|
+
name: "skills",
|
|
316
|
+
description: "查看 DeepSeek Harness 运行时与磁盘技能列表",
|
|
317
|
+
descriptionEn: "List DeepSeek Harness runtime and disk skills",
|
|
318
|
+
source: "extension",
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: "clear",
|
|
322
|
+
description: "重置 DSH 会话上下文",
|
|
323
|
+
descriptionEn: "Reset DSH session context",
|
|
324
|
+
source: "extension",
|
|
325
|
+
},
|
|
326
|
+
];
|
|
327
|
+
}
|
|
328
|
+
async execSlashCommand(name, _args, context) {
|
|
329
|
+
switch (name) {
|
|
330
|
+
case "skills": {
|
|
331
|
+
const skills = await this.getSkills();
|
|
332
|
+
const summary = skills.length > 0
|
|
333
|
+
? `DSH 可用技能 (${skills.length}):${skills.map((s) => s.name).join(", ")}`
|
|
334
|
+
: "DSH 当前无可用技能";
|
|
335
|
+
const summaryEn = skills.length > 0
|
|
336
|
+
? `DSH skills (${skills.length}): ${skills.map((s) => s.name).join(", ")}`
|
|
337
|
+
: "No DSH skills available";
|
|
338
|
+
context?.emitNotice?.("info", summary, summaryEn);
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
case "clear": {
|
|
342
|
+
await this.createSession();
|
|
343
|
+
context?.emitNotice?.("info", "DSH 会话上下文已重置", "DSH session context reset");
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
default:
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
async getSkills() {
|
|
351
|
+
const diskSkills = discoverDiskSkills({ cwd: this.cwd, agentDir: this.agentDir });
|
|
352
|
+
const out = diskSkills.map((s) => ({
|
|
353
|
+
name: s.name,
|
|
354
|
+
description: s.description,
|
|
355
|
+
filePath: s.filePath,
|
|
356
|
+
}));
|
|
357
|
+
try {
|
|
358
|
+
if (this.runtime.alive) {
|
|
359
|
+
const rpcSkills = await this.runtime.listSkills();
|
|
360
|
+
for (const s of rpcSkills.skills ?? []) {
|
|
361
|
+
if (!out.some((x) => x.name === s.name)) {
|
|
362
|
+
out.push({
|
|
363
|
+
name: s.name,
|
|
364
|
+
description: s.description,
|
|
365
|
+
filePath: "",
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
catch {
|
|
372
|
+
/* ignore runtime error */
|
|
373
|
+
}
|
|
374
|
+
return out;
|
|
375
|
+
}
|
|
376
|
+
dispose() {
|
|
377
|
+
void this.runtime.close();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>远程 HTML 报告测试</title>
|
|
6
|
+
<style>
|
|
7
|
+
body { font-family: sans-serif; padding: 2rem; background: #0f172a; color: #f8fafc; }
|
|
8
|
+
.card { background: #1e293b; padding: 1.5rem; border-radius: 8px; border: 1px solid #334155; }
|
|
9
|
+
h1 { color: #38bdf8; }
|
|
10
|
+
button { background: #38bdf8; color: #0f172a; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: bold; }
|
|
11
|
+
</style>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<div class="card">
|
|
15
|
+
<h1>🎉 远程 HTML 报告沙箱正常运行!</h1>
|
|
16
|
+
<p>这是一个能够完全在沙箱中交互并独立打开的 HTML 页面。</p>
|
|
17
|
+
<button onclick="alert('JS 在沙箱中正常触发!')">点击测试 JavaScript 交互</button>
|
|
18
|
+
</div>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|