pi-web-ui 0.100.0 → 0.101.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 +39 -1
- package/README.md +46 -44
- package/README.zh-CN.md +41 -39
- package/bin/pi-web-ui.mjs +4 -10
- package/dist/server/agent-formatters.js +191 -0
- package/dist/server/agent-service-daemon.js +1266 -0
- package/dist/server/agent-service.js +9883 -12935
- package/dist/server/approval-default-rules.js +158 -0
- package/dist/server/approval-rules.js +41 -167
- package/dist/server/ask-user-question-tool.js +94 -0
- package/dist/server/attachment-store.js +38 -1
- package/dist/server/bash-tool.js +83 -0
- package/dist/server/browser-page-tool.js +207 -0
- package/dist/server/client-id-utils.js +51 -0
- package/dist/server/client-state.js +23 -2
- package/dist/server/compaction-markers.js +34 -1
- package/dist/server/context-budget-runner.js +43 -0
- package/dist/server/dangling-tools.js +18 -5
- package/dist/server/delegate-mode.js +1 -0
- package/dist/server/dispatch-domain-handlers.js +631 -0
- package/dist/server/dispatch-plugin-handlers.js +300 -0
- package/dist/server/dsh/dsh-agent-service.js +9 -1
- package/dist/server/goal-evidence.js +9 -2
- package/dist/server/goal-service.js +1 -1
- package/dist/server/hashline-engine.js +1 -1
- package/dist/server/index.js +191 -969
- package/dist/server/left-panel-running.js +115 -0
- package/dist/server/lsp-tool.js +40 -12
- package/dist/server/markers-list-tool.js +34 -0
- package/dist/server/market-service.js +277 -0
- package/dist/server/mcp-bridge.js +137 -30
- package/dist/server/mcp-hot-reload.js +84 -27
- package/dist/server/mcp-manager.js +215 -0
- package/dist/server/message-entry-resolver.js +32 -0
- package/dist/server/orphan-manager.js +44 -0
- package/dist/server/persona-chain.js +63 -0
- package/dist/server/plan-mode.js +2 -0
- package/dist/server/plan-update-tool.js +96 -0
- package/dist/server/plugin-api-catalog.js +20 -0
- package/dist/server/plugin-facilities.js +13 -3
- package/dist/server/plugin-ui-slots.js +39 -0
- package/dist/server/plugins.js +71 -38
- package/dist/server/preset-fields.js +7 -0
- package/dist/server/preset-share.js +1 -0
- package/dist/server/process-utils.js +30 -0
- package/dist/server/prompt-assembler.js +80 -0
- package/dist/server/scm-commitmsg.js +74 -0
- package/dist/server/serialize.js +97 -7
- package/dist/server/session-branch.js +367 -0
- package/dist/server/session-parser.js +235 -0
- package/dist/server/session-search.js +158 -0
- package/dist/server/settings-service.js +13 -1
- package/dist/server/skill-content-filler.js +33 -0
- package/dist/server/subagent-handoff.js +18 -0
- package/dist/server/subagent-helpers.js +88 -0
- package/dist/server/terminals.js +155 -58
- package/dist/server/tool-guards.js +527 -0
- package/dist/server/tool-host-factories.js +217 -0
- package/dist/server/tool-manager.js +30 -5
- package/dist/server/wait-subscription-scan.js +46 -1
- package/dist/server/workspace-snapshot.js +18 -0
- package/extensions/webui.ts +90 -24
- package/package.json +1 -1
- package/plugin-sdk/README.md +17 -0
- package/plugin-sdk/index.d.ts +17 -0
- package/plugin-sdk/index.mjs +5 -0
- package/plugins/catalog.json +20 -0
- package/themes/aetheris.css +3 -1
- package/themes/translucent.css +8 -1
- package/themes/transparent.css +9 -1
- package/web/dist/assets/{TerminalPanel-C3I1Mc-C.js → TerminalPanel-DD7I5_aC.js} +1 -1
- package/web/dist/assets/index-CpjA1YdT.css +1 -0
- package/web/dist/assets/index-nKn87VuM.js +678 -0
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-B-E2EM_0.css +0 -1
- package/web/dist/assets/index-BYumAaGi.js +0 -379
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dispatch-plugin-handlers — WebSocket 插件管理与生命周期事件分发路由处理器。
|
|
3
|
+
*
|
|
4
|
+
* 负责:
|
|
5
|
+
* - 插件双向通信(plugin_message)与配置持久化(plugin_settings)
|
|
6
|
+
* - 插件市场目录同步、添加与移除(plugin_catalog_*)
|
|
7
|
+
* - 插件后台作业(安装/更新/卸载/取消及安装前检查,plugin_job_*)
|
|
8
|
+
* - 插件 API 注册面只读目录(plugin_api_catalog)
|
|
9
|
+
* - 插件特权目录授权、网络/LLM能力授权及撤销(plugin_path_* / plugin_permission_*)
|
|
10
|
+
* - 特权 DOM 两步握手授权与应答(plugin_dom_consent_*)
|
|
11
|
+
*
|
|
12
|
+
* 从 server/index.ts 抽出为独立模块。
|
|
13
|
+
*/
|
|
14
|
+
import { randomUUID } from "node:crypto";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { WebSocket } from "ws";
|
|
17
|
+
import { buildPluginJobArgs, inspectInstallSpec } from "./plugin-installer.js";
|
|
18
|
+
import { syncPluginCatalog } from "./plugin-catalog-sync.js";
|
|
19
|
+
export function handlePluginMessage(msg, ctx) {
|
|
20
|
+
const { pluginMgr, pluginInstaller, cs, clientId, send, dataDir, cwd, clients, pendingPathRequests, pendingPermissionRequests, pendingDomConsents, findDomConsentById, applyDomConsent, pushPluginGrants, pushPluginPermissions, reloadPluginsAndPush, confirmPluginInstallHelper, } = ctx;
|
|
21
|
+
switch (msg.type) {
|
|
22
|
+
case "plugin_message":
|
|
23
|
+
pluginMgr.handleMessage(msg.pluginId, msg.payload, clientId ?? undefined);
|
|
24
|
+
return true;
|
|
25
|
+
case "plugin_settings": {
|
|
26
|
+
const r = pluginMgr.savePluginSettings(msg.pluginId, msg.values ?? {}, () => cs?.getLang() ?? "en");
|
|
27
|
+
if (r.error) {
|
|
28
|
+
cs?.emitNotice?.("error", `插件设置保存失败:${r.error}`, `Failed to save plugin settings: ${r.error}`);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
cs?.emitNotice?.("info", "插件设置已保存", "Plugin settings saved");
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
case "plugins_reload":
|
|
36
|
+
void pluginMgr.reload(() => cs?.getLang() ?? "en").then(() => pluginMgr.pushToAll());
|
|
37
|
+
return true;
|
|
38
|
+
case "plugin_catalog_add": {
|
|
39
|
+
const r = pluginMgr.addCatalogEntry(msg.entry ?? {}, () => cs?.getLang() ?? "en");
|
|
40
|
+
if (r.error) {
|
|
41
|
+
cs?.emitNotice?.("error", `添加到插件列表失败:${r.error}`, `Failed to add to plugin list: ${r.error}`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
cs?.emitNotice?.("info", "已添加到插件列表", "Added to the plugin list");
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
case "plugin_catalog_remove": {
|
|
49
|
+
const r = pluginMgr.removeCatalogEntry(msg.id, () => cs?.getLang() ?? "en");
|
|
50
|
+
if (r.error) {
|
|
51
|
+
cs?.emitNotice?.("error", `从插件列表移除失败:${r.error}`, `Failed to remove from plugin list: ${r.error}`);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
cs?.emitNotice?.("info", "已从插件列表移除", "Removed from the plugin list");
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
case "plugin_job": {
|
|
59
|
+
const jobLang = () => cs?.getLang() ?? "en";
|
|
60
|
+
const jobId = String(msg.jobId ?? "");
|
|
61
|
+
const pluginId = String(msg.id ?? "");
|
|
62
|
+
const jobAction = msg.action;
|
|
63
|
+
const jobSpec = {
|
|
64
|
+
jobId,
|
|
65
|
+
action: jobAction,
|
|
66
|
+
id: pluginId,
|
|
67
|
+
source: msg.source,
|
|
68
|
+
build: msg.build === true,
|
|
69
|
+
noBuild: msg.noBuild === true,
|
|
70
|
+
};
|
|
71
|
+
const jobDone = (ok, error) => {
|
|
72
|
+
send({
|
|
73
|
+
type: "plugin_job",
|
|
74
|
+
jobId,
|
|
75
|
+
action: jobAction,
|
|
76
|
+
pluginId,
|
|
77
|
+
phase: "done",
|
|
78
|
+
ok,
|
|
79
|
+
...(error ? { error } : {}),
|
|
80
|
+
output: "",
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
const argCheck = buildPluginJobArgs(jobSpec, dataDir, jobLang);
|
|
84
|
+
if ("error" in argCheck) {
|
|
85
|
+
jobDone(false, argCheck.error);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
if (jobAction === "install" || jobAction === "update") {
|
|
89
|
+
const alreadyGranted = pluginMgr.permGrants.has("plugin-installer", "net", { host: "github.com" });
|
|
90
|
+
if (!alreadyGranted) {
|
|
91
|
+
send({
|
|
92
|
+
type: "plugin_job",
|
|
93
|
+
jobId,
|
|
94
|
+
action: jobAction,
|
|
95
|
+
pluginId,
|
|
96
|
+
phase: "start",
|
|
97
|
+
});
|
|
98
|
+
send({
|
|
99
|
+
type: "plugin_job",
|
|
100
|
+
jobId,
|
|
101
|
+
action: jobAction,
|
|
102
|
+
pluginId,
|
|
103
|
+
phase: "log",
|
|
104
|
+
line: jobLang() === "zh" ? "等待确认安装授权…" : "Waiting for install confirmation…",
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
void confirmPluginInstallHelper([{ id: pluginId, source: String(msg.source ?? "") }])
|
|
108
|
+
.then((confirmed) => {
|
|
109
|
+
if (!confirmed) {
|
|
110
|
+
jobDone(false, jobLang() === "zh"
|
|
111
|
+
? "用户未确认安装(拒绝或 120 秒超时)"
|
|
112
|
+
: "Installation not confirmed (rejected or timed out after 120s)");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
startPluginJob();
|
|
116
|
+
})
|
|
117
|
+
.catch(() => jobDone(false, jobLang() === "zh" ? "安装确认流程异常" : "Installation confirmation error"));
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
startPluginJob();
|
|
121
|
+
function startPluginJob() {
|
|
122
|
+
const started = pluginInstaller.start(jobSpec, {
|
|
123
|
+
lang: jobLang,
|
|
124
|
+
emit: (m) => send(m),
|
|
125
|
+
done: async (ok, info) => {
|
|
126
|
+
if (ok) {
|
|
127
|
+
await reloadPluginsAndPush(jobLang);
|
|
128
|
+
if (typeof cs?.checkPluginUpdates === "function") {
|
|
129
|
+
void cs.checkPluginUpdates(false);
|
|
130
|
+
}
|
|
131
|
+
const isZh = jobLang() === "zh";
|
|
132
|
+
const actionLabel = jobAction === "uninstall"
|
|
133
|
+
? isZh
|
|
134
|
+
? "卸载"
|
|
135
|
+
: "uninstalled"
|
|
136
|
+
: jobAction === "update"
|
|
137
|
+
? isZh
|
|
138
|
+
? "更新"
|
|
139
|
+
: "updated"
|
|
140
|
+
: isZh
|
|
141
|
+
? "安装"
|
|
142
|
+
: "installed";
|
|
143
|
+
cs?.emitNotice?.("info", `插件「${pluginId}」${actionLabel}完成`, `Plugin "${pluginId}" ${actionLabel} successfully`);
|
|
144
|
+
}
|
|
145
|
+
else if (info.error) {
|
|
146
|
+
cs?.emitNotice?.("error", `插件操作失败:${info.error}`, `Plugin operation failed: ${info.error}`);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
if (!started.ok)
|
|
151
|
+
jobDone(false, started.error);
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
case "plugin_job_cancel":
|
|
156
|
+
pluginInstaller.cancel(String(msg.jobId ?? ""));
|
|
157
|
+
return true;
|
|
158
|
+
case "plugin_api_catalog": {
|
|
159
|
+
const requestId = String(msg.requestId ?? "");
|
|
160
|
+
send({ type: "plugin_api_catalog_result", requestId, catalog: pluginMgr.getApiCatalog() });
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
case "plugin_install_inspect": {
|
|
164
|
+
const requestId = String(msg.requestId ?? "");
|
|
165
|
+
const source = String(msg.source ?? "");
|
|
166
|
+
void inspectInstallSpec(source, {
|
|
167
|
+
pluginsDir: pluginMgr.pluginsDir,
|
|
168
|
+
...(typeof msg.explicitId === "string" && msg.explicitId.trim() ? { explicitId: msg.explicitId.trim() } : {}),
|
|
169
|
+
force: msg.force === true,
|
|
170
|
+
}).then((r) => {
|
|
171
|
+
send({
|
|
172
|
+
type: "plugin_install_inspect_result",
|
|
173
|
+
requestId,
|
|
174
|
+
source,
|
|
175
|
+
kind: r.spec.kind,
|
|
176
|
+
suggestedId: r.suggestedId,
|
|
177
|
+
installed: r.installed,
|
|
178
|
+
...(r.problem ? { problem: r.problem } : {}),
|
|
179
|
+
...(r.detail ? { detail: r.detail } : {}),
|
|
180
|
+
...(r.manifest ? { manifest: r.manifest } : {}),
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
case "plugin_path_response": {
|
|
186
|
+
const id = String(msg.id ?? "");
|
|
187
|
+
const pending = pendingPathRequests.get(id);
|
|
188
|
+
if (pending && clientId && pending.recipients.has(clientId)) {
|
|
189
|
+
clearTimeout(pending.timer);
|
|
190
|
+
pendingPathRequests.delete(id);
|
|
191
|
+
pending.resolve(msg.ok === true);
|
|
192
|
+
}
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
case "plugin_permission_response": {
|
|
196
|
+
const id = String(msg.id ?? "");
|
|
197
|
+
const pending = pendingPermissionRequests.get(id);
|
|
198
|
+
if (pending && clientId && pending.recipients.has(clientId)) {
|
|
199
|
+
clearTimeout(pending.timer);
|
|
200
|
+
pendingPermissionRequests.delete(id);
|
|
201
|
+
const resolved = JSON.stringify({ type: "plugin_permission_resolved", id });
|
|
202
|
+
for (const client of clients) {
|
|
203
|
+
if (client.readyState === WebSocket.OPEN) {
|
|
204
|
+
try {
|
|
205
|
+
client.send(resolved);
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
/* dead connection */
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
pending.resolve({ ok: msg.ok === true, remember: msg.remember === true });
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
case "plugin_dom_consent": {
|
|
217
|
+
if (msg.granted === true) {
|
|
218
|
+
const pid = typeof msg.pluginId === "string" ? msg.pluginId.trim() : "";
|
|
219
|
+
if (!pid || !pluginMgr.isDomPlugin(pid) || pendingDomConsents.has(pid))
|
|
220
|
+
return true;
|
|
221
|
+
const id = randomUUID();
|
|
222
|
+
const timer = setTimeout(() => {
|
|
223
|
+
pendingDomConsents.delete(pid);
|
|
224
|
+
}, 120_000);
|
|
225
|
+
pendingDomConsents.set(pid, { id, pluginId: pid, recipients: new Set(pluginMgr.onlineClientIds()), timer });
|
|
226
|
+
const payload = JSON.stringify({ type: "plugin_dom_consent_request", id, pluginId: pid, from: clientId });
|
|
227
|
+
for (const client of clients) {
|
|
228
|
+
if (client.readyState === WebSocket.OPEN) {
|
|
229
|
+
try {
|
|
230
|
+
client.send(payload);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
/* dead connection */
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
applyDomConsent(msg.pluginId, false);
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
case "plugin_dom_consent_response": {
|
|
243
|
+
const id = typeof msg.id === "string" ? msg.id : "";
|
|
244
|
+
const pendingConsent = findDomConsentById(id);
|
|
245
|
+
if (pendingConsent && clientId && pendingConsent.recipients.has(clientId)) {
|
|
246
|
+
clearTimeout(pendingConsent.timer);
|
|
247
|
+
pendingDomConsents.delete(pendingConsent.pluginId);
|
|
248
|
+
if (msg.ok === true)
|
|
249
|
+
applyDomConsent(pendingConsent.pluginId, true);
|
|
250
|
+
}
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
case "plugin_path_revoke": {
|
|
254
|
+
const removed = pluginMgr.grants.revoke(typeof msg.pluginId === "string" ? msg.pluginId : undefined, typeof msg.path === "string" ? msg.path : undefined);
|
|
255
|
+
cs?.emitNotice?.("info", `已撤销 ${removed} 条插件目录授权`, `Revoked ${removed} plugin path grant(s)`);
|
|
256
|
+
pushPluginGrants();
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
case "plugin_permission_revoke": {
|
|
260
|
+
const family = msg.family === "net" || msg.family === "llm" ? msg.family : undefined;
|
|
261
|
+
const removed = pluginMgr.permGrants.revoke(typeof msg.pluginId === "string" ? msg.pluginId : undefined, family, typeof msg.host === "string" || typeof msg.model === "string"
|
|
262
|
+
? {
|
|
263
|
+
...(typeof msg.host === "string" ? { host: msg.host } : {}),
|
|
264
|
+
...(typeof msg.model === "string" ? { model: msg.model } : {}),
|
|
265
|
+
}
|
|
266
|
+
: undefined);
|
|
267
|
+
cs?.emitNotice?.("info", `已撤销 ${removed} 条能力授权`, `Revoked ${removed} permission grant(s)`);
|
|
268
|
+
pushPluginPermissions();
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
case "plugin_catalog_sync": {
|
|
272
|
+
const syncLang = () => cs?.getLang() ?? "en";
|
|
273
|
+
const requestId = String(msg.requestId ?? "");
|
|
274
|
+
void syncPluginCatalog(String(msg.source ?? ""), { install: msg.install === true, replace: msg.replace === true }, {
|
|
275
|
+
customCatalogPath: pluginMgr.customCatalogPath,
|
|
276
|
+
pluginsDir: join(dataDir, "plugins"),
|
|
277
|
+
installer: pluginInstaller,
|
|
278
|
+
afterWrite: () => (msg.install === true ? reloadPluginsAndPush(syncLang) : pluginMgr.pushCatalog()),
|
|
279
|
+
lang: syncLang,
|
|
280
|
+
workspaceRoot: cs?.cwd ?? cwd,
|
|
281
|
+
confirmInstall: (items) => confirmPluginInstallHelper(items),
|
|
282
|
+
}).then((r) => {
|
|
283
|
+
if (r.installRefused) {
|
|
284
|
+
cs?.emitNotice?.("warning", "目录已同步,但安装未获用户确认(拒绝或超时),未安装任何插件", "Catalog synced, but installation was not confirmed (denied or timed out) — nothing was installed");
|
|
285
|
+
}
|
|
286
|
+
send({
|
|
287
|
+
type: "plugin_catalog_sync_result",
|
|
288
|
+
requestId,
|
|
289
|
+
ok: r.ok,
|
|
290
|
+
...(r.error ? { error: r.error } : {}),
|
|
291
|
+
entries: pluginMgr.catalog(),
|
|
292
|
+
...(r.installed ? { installed: r.installed } : {}),
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
default:
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
@@ -31,7 +31,7 @@ import { randomUUID } from "node:crypto";
|
|
|
31
31
|
import { homedir } from "node:os";
|
|
32
32
|
import { BG_CLEANUP_FALLBACK_MIN, BgServerTracker } from "../bg-servers.js";
|
|
33
33
|
import { ClientStateStore, DEFAULT_RETRY_MAX_ATTEMPTS, normalizeBgCleanupMinutes, normalizePathKey, normalizeToolWatchdogTimeoutMs, settingsPresetToUi, } from "../client-state.js";
|
|
34
|
-
import { normalizeUiLayout } from "../client-state.js";
|
|
34
|
+
import { normalizeUiLayout, normalizeKeepRecentMessages, DEFAULT_KEEP_RECENT_MESSAGES } from "../client-state.js";
|
|
35
35
|
import { PLAN_MODE_SYSTEM_PROMPT } from "../plan-mode.js";
|
|
36
36
|
import { FilesService, workspacePath, desktopDirWire } from "../files-service.js";
|
|
37
37
|
import { QuiesceRejectedError } from "../agent-service.js";
|
|
@@ -139,6 +139,7 @@ const DEFAULT_SETTINGS = {
|
|
|
139
139
|
thinkingWrap: false,
|
|
140
140
|
toolsWrap: true,
|
|
141
141
|
toolImagesEnabled: true,
|
|
142
|
+
keepRecentMessages: DEFAULT_KEEP_RECENT_MESSAGES,
|
|
142
143
|
disabledPlugins: [],
|
|
143
144
|
uiLayout: {},
|
|
144
145
|
reviewPrompt: "",
|
|
@@ -292,6 +293,7 @@ export class DshClientSession {
|
|
|
292
293
|
thinkingWrap: savedSettings.thinkingWrap,
|
|
293
294
|
toolsWrap: savedSettings.toolsWrap,
|
|
294
295
|
toolImagesEnabled: savedSettings.toolImagesEnabled ?? true,
|
|
296
|
+
keepRecentMessages: normalizeKeepRecentMessages(savedSettings.keepRecentMessages),
|
|
295
297
|
disabledPlugins: savedSettings.disabledPlugins ?? [],
|
|
296
298
|
uiLayout: normalizeUiLayout(savedSettings.uiLayout),
|
|
297
299
|
reviewPrompt: savedSettings.reviewPrompt,
|
|
@@ -2670,6 +2672,7 @@ export class DshClientSession {
|
|
|
2670
2672
|
thinkingWrap: this.settings.thinkingWrap,
|
|
2671
2673
|
toolsWrap: this.settings.toolsWrap,
|
|
2672
2674
|
toolImagesEnabled: this.settings.toolImagesEnabled,
|
|
2675
|
+
keepRecentMessages: normalizeKeepRecentMessages(this.settings.keepRecentMessages),
|
|
2673
2676
|
// DSH 无 skill 全文注入概念,给空保协议完整。
|
|
2674
2677
|
skillsFullText: [],
|
|
2675
2678
|
visionBridgeEnabled: false,
|
|
@@ -2758,6 +2761,8 @@ export class DshClientSession {
|
|
|
2758
2761
|
this.settings.toolsWrap = partial.toolsWrap;
|
|
2759
2762
|
if (partial.toolImagesEnabled !== undefined)
|
|
2760
2763
|
this.settings.toolImagesEnabled = partial.toolImagesEnabled;
|
|
2764
|
+
if (partial.keepRecentMessages !== undefined)
|
|
2765
|
+
this.settings.keepRecentMessages = normalizeKeepRecentMessages(partial.keepRecentMessages);
|
|
2761
2766
|
if (partial.disabledPlugins !== undefined)
|
|
2762
2767
|
this.settings.disabledPlugins = partial.disabledPlugins;
|
|
2763
2768
|
if (partial.uiLayout !== undefined)
|
|
@@ -2796,6 +2801,7 @@ export class DshClientSession {
|
|
|
2796
2801
|
thinkingWrap: this.settings.thinkingWrap,
|
|
2797
2802
|
toolsWrap: this.settings.toolsWrap,
|
|
2798
2803
|
toolImagesEnabled: this.settings.toolImagesEnabled,
|
|
2804
|
+
keepRecentMessages: normalizeKeepRecentMessages(this.settings.keepRecentMessages),
|
|
2799
2805
|
disabledPlugins: this.settings.disabledPlugins,
|
|
2800
2806
|
uiLayout: normalizeUiLayout(this.settings.uiLayout),
|
|
2801
2807
|
reviewPrompt: this.settings.reviewPrompt,
|
|
@@ -3185,6 +3191,7 @@ export class DshClientSession {
|
|
|
3185
3191
|
thinkingWrap: this.settings.thinkingWrap,
|
|
3186
3192
|
toolsWrap: this.settings.toolsWrap,
|
|
3187
3193
|
toolImagesEnabled: this.settings.toolImagesEnabled,
|
|
3194
|
+
keepRecentMessages: normalizeKeepRecentMessages(this.settings.keepRecentMessages),
|
|
3188
3195
|
disabledPlugins: this.settings.disabledPlugins,
|
|
3189
3196
|
uiLayout: normalizeUiLayout(this.settings.uiLayout),
|
|
3190
3197
|
reviewPrompt: this.settings.reviewPrompt,
|
|
@@ -4342,6 +4349,7 @@ export class DshAgentService {
|
|
|
4342
4349
|
if (conv)
|
|
4343
4350
|
return {
|
|
4344
4351
|
clientId,
|
|
4352
|
+
convId: conv.id,
|
|
4345
4353
|
title: conv.title,
|
|
4346
4354
|
cwd: conv.cwd,
|
|
4347
4355
|
isStreaming: conv.isStreaming,
|
|
@@ -25,6 +25,13 @@ function isRecord(v) {
|
|
|
25
25
|
return typeof v === "object" && v !== null;
|
|
26
26
|
}
|
|
27
27
|
/** 压成一行并封顶(提示是给人/模型扫的,不做换行)。 */
|
|
28
|
+
/** 高危命中前缀:同一命令里的多处命中逐条列出(去重标签,#578)。 */
|
|
29
|
+
function dangerPrefix(hits) {
|
|
30
|
+
if (hits.length === 0)
|
|
31
|
+
return "";
|
|
32
|
+
const labels = [...new Set(hits.map((h) => h.label))];
|
|
33
|
+
return `⚠️ [${labels.join(" / ")}] `;
|
|
34
|
+
}
|
|
28
35
|
function oneLine(v, max = 120) {
|
|
29
36
|
if (typeof v !== "string")
|
|
30
37
|
return "";
|
|
@@ -95,7 +102,7 @@ export function collectToolEvidence(messages, opts = {}) {
|
|
|
95
102
|
if (m.role === "bashExecution") {
|
|
96
103
|
const cmd = typeof m.command === "string" ? m.command : "";
|
|
97
104
|
const dangerHits = checkBashCommandDanger(cmd);
|
|
98
|
-
const prefix = dangerHits
|
|
105
|
+
const prefix = dangerPrefix(dangerHits);
|
|
99
106
|
out.push({
|
|
100
107
|
tool: "bash",
|
|
101
108
|
hint: `${prefix}${oneLine(m.command)}`,
|
|
@@ -114,7 +121,7 @@ export function collectToolEvidence(messages, opts = {}) {
|
|
|
114
121
|
if (effectiveTool === "bash" && hint) {
|
|
115
122
|
const dangerHits = checkBashCommandDanger(hint);
|
|
116
123
|
if (dangerHits.length > 0) {
|
|
117
|
-
hint =
|
|
124
|
+
hint = `${dangerPrefix(dangerHits)}${hint}`;
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
127
|
out.push({
|
|
@@ -1163,7 +1163,7 @@ export class GoalService {
|
|
|
1163
1163
|
async stopAllGoals() {
|
|
1164
1164
|
let stopped = 0;
|
|
1165
1165
|
// 快照迭代:await stopDelegated 期间,循环退出的回调可能增删这张表。
|
|
1166
|
-
for (const convId of
|
|
1166
|
+
for (const convId of Array.from(this.delegatedLoops.keys())) {
|
|
1167
1167
|
const conv = this.host.getConv(convId);
|
|
1168
1168
|
if (!conv)
|
|
1169
1169
|
continue;
|
|
@@ -333,7 +333,7 @@ export const globalSnapshotStore = new HashlineSnapshotStore();
|
|
|
333
333
|
*
|
|
334
334
|
* 核心逻辑:若磁盘文件的改动未侵入 targetHunks 所在的锚点行,则将锚点行映射到最新文件的对应行,安全完成合并。
|
|
335
335
|
*/
|
|
336
|
-
export function tryRecoverEdits(baseText, currentText, hunks,
|
|
336
|
+
export function tryRecoverEdits(baseText, currentText, hunks, _filePath) {
|
|
337
337
|
const baseLines = normalizeLineEndings(baseText).split("\n");
|
|
338
338
|
const curLines = normalizeLineEndings(currentText).split("\n");
|
|
339
339
|
// 若内容完全相同,无需恢复
|