pi-web-ui 0.105.1 → 0.107.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 +84 -2
- package/README.md +193 -797
- package/README.zh-CN.md +186 -625
- package/README.zh-TW.md +781 -0
- package/bin/frp-manager.mjs +1488 -0
- package/bin/pi-web-ui.mjs +27 -0
- package/deploy/nginx-subpath.conf +16 -1
- package/dist/server/agent-service-daemon.js +34 -0
- package/dist/server/agent-service.js +259 -60
- package/dist/server/claim-files-tool.js +8 -1
- package/dist/server/client-state.js +136 -30
- package/dist/server/conversation-read-tool.js +12 -4
- package/dist/server/delegate-task.js +9 -1
- package/dist/server/dispatch-domain-handlers.js +15 -0
- package/dist/server/dsh/dsh-agent-service.js +848 -246
- package/dist/server/dsh/dsh-client.js +59 -18
- package/dist/server/dsh/dsh-market-service.js +233 -0
- package/dist/server/dsh/dsh-serialize.js +11 -3
- package/dist/server/dsh/dsh-sessions.js +64 -2
- package/dist/server/dsh/preset-clones.js +12 -1
- package/dist/server/dsh/runtime/goal-rpc.mjs +183 -45
- package/dist/server/durable/durable-agent-service.js +153 -0
- package/dist/server/durable/durable-capabilities.js +11 -0
- package/dist/server/durable/durable-driver.js +481 -0
- package/dist/server/durable/durable-loader.js +38 -0
- package/dist/server/durable/durable-models.js +283 -0
- package/dist/server/durable/durable-storage.js +42 -0
- package/dist/server/durable/durable-tools.js +45 -0
- package/dist/server/durable/index.js +8 -0
- package/dist/server/engine-capabilities.js +91 -0
- package/dist/server/engine-probe.js +391 -0
- package/dist/server/global-loader.js +335 -0
- package/dist/server/goal-service.js +23 -12
- package/dist/server/i18n.js +20 -1
- package/dist/server/index.js +286 -71
- package/dist/server/locales.js +1 -0
- package/dist/server/managed.js +2 -0
- package/dist/server/marker-service.js +5 -19
- package/dist/server/markers/index.js +1 -3
- package/dist/server/mcp-agent-tool.js +10 -7
- package/dist/server/mcp-bridge.js +428 -24
- package/dist/server/model-admin.js +172 -74
- package/dist/server/model-resolver.js +309 -0
- package/dist/server/plugin-installer.js +4 -2
- package/dist/server/plugins.js +89 -12
- package/dist/server/present-files-tool.js +10 -2
- package/dist/server/preset-fields.js +14 -0
- package/dist/server/preset-share.js +2 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/schedule-agent-tool.js +2 -1
- package/dist/server/scm-commitmsg.js +3 -2
- package/dist/server/sdk-origin.js +2 -2
- package/dist/server/serialize.js +1 -1
- package/dist/server/settings-service.js +10 -2
- package/dist/server/skill-discovery.js +161 -0
- package/dist/server/skill-tool.js +2 -1
- package/dist/server/slash-commands.js +154 -73
- package/dist/server/subagent-templates-hant.js +215 -0
- package/dist/server/subagent-templates.js +49 -2
- package/dist/server/subagents.js +22 -12
- package/dist/server/terminals.js +2 -2
- package/dist/server/tool-manager.js +6 -19
- package/dist/server/universal/driver-base.js +60 -0
- package/dist/server/universal/drivers/claude-code.js +463 -0
- package/dist/server/universal/drivers/dsh-driver.js +376 -0
- package/dist/server/universal/drivers/mock-driver.js +103 -0
- package/dist/server/universal/index.js +10 -0
- package/dist/server/universal/session-store.js +100 -0
- package/dist/server/universal/universal-attachments.js +175 -0
- package/dist/server/universal/universal-service.js +166 -0
- package/dist/server/universal/universal-session.js +2664 -0
- package/dist/server/universal/universal-types.js +4 -0
- package/dist/server/update-check.js +24 -9
- package/dist/server/worktree-service.js +1 -1
- package/dist/server/worktree-tool.js +9 -7
- package/package.json +3 -2
- package/plugin-sdk/index.d.ts +12 -2
- package/plugins/catalog.json +50 -5
- package/themes/dark-teal.css +20 -24
- package/themes/flow-light.css +1085 -0
- package/themes/flow.css +1094 -0
- package/themes/md-preview.css +1 -2
- package/themes/wallpaper-flow.css +1158 -0
- package/themes/wallpaper-obsidian.css +743 -0
- package/themes/zhujian-dark.css +0 -7
- package/themes/zhujian.css +0 -7
- package/themes/zhupi-dark.css +0 -7
- package/themes/zhupi.css +0 -7
- package/web/dist/assets/{TerminalPanel-Mk4laCAL.js → TerminalPanel-BnViyTlx.js} +2 -2
- package/web/dist/assets/index-cCRCYMwT.css +1 -0
- package/web/dist/assets/index-fH5vhkAE.js +690 -0
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-BDLVjBeK.js +0 -690
- package/web/dist/assets/index-BQC6lADz.css +0 -1
package/dist/server/index.js
CHANGED
|
@@ -23,9 +23,8 @@ import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
|
23
23
|
import { stat } from "node:fs/promises";
|
|
24
24
|
import { createServer, request as proxyRequest } from "node:http";
|
|
25
25
|
import { createConnection } from "node:net";
|
|
26
|
-
import { basename, delimiter,
|
|
26
|
+
import { basename, delimiter, join, resolve, sep } from "node:path";
|
|
27
27
|
import { homedir } from "node:os";
|
|
28
|
-
import { fileURLToPath } from "node:url";
|
|
29
28
|
import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
|
|
30
29
|
import express from "express";
|
|
31
30
|
import compression from "compression";
|
|
@@ -52,12 +51,12 @@ import { validateClientId } from "./ws-client-id.js";
|
|
|
52
51
|
import { PendingCommandQueue } from "./ws-pending-queue.js";
|
|
53
52
|
import { installPack, isKnownPack, listPacks, loadServerStrings, readPackFile, removePack, unloadServerStrings, } from "./locales.js";
|
|
54
53
|
import { PluginManager, resolvePluginClientFile, } from "./plugins.js";
|
|
55
|
-
import {
|
|
54
|
+
import { confirmPluginInstall, PluginInstaller } from "./plugin-installer.js";
|
|
56
55
|
import { syncPluginCatalog } from "./plugin-catalog-sync.js";
|
|
57
56
|
import { McpBridge } from "./mcp-bridge.js";
|
|
58
57
|
import { createMcpHotReload } from "./mcp-hot-reload.js";
|
|
59
58
|
import { createHostMetricsSampler } from "./host-metrics.js";
|
|
60
|
-
import { SchedulerStore
|
|
59
|
+
import { SchedulerStore } from "./scheduler-tasks.js";
|
|
61
60
|
import { initHttpProxy } from "./http-proxy.js";
|
|
62
61
|
import { globalLspPool } from "./lsp-tool.js";
|
|
63
62
|
import { buildPiWebTokenCookie, decodeCookieToken, isTlsRequest } from "./auth-cookie.js";
|
|
@@ -341,15 +340,18 @@ if (AUTH_TOKEN) {
|
|
|
341
340
|
}
|
|
342
341
|
/** 共享客户端持久化存储:双引擎(pi + dsh)共用同一份内存缓存与落盘通道,避免互相覆盖。 */
|
|
343
342
|
const sharedStateStore = new ClientStateStore(join(DATA_DIR, "client-state.json"));
|
|
344
|
-
/** 启动参数显式指定的引擎(--engine pi|dsh 或 PI_WEB_ENGINE)。未显式传则优先读持久化默认引擎。 */
|
|
343
|
+
/** 启动参数显式指定的引擎(--engine pi|dsh|claude|durable 或 PI_WEB_ENGINE)。未显式传则优先读持久化默认引擎。 */
|
|
345
344
|
const EXPLICIT_ENGINE_ARG = cliFlag("--engine") ?? process.env.PI_WEB_ENGINE;
|
|
346
|
-
let currentDefaultEngine = EXPLICIT_ENGINE_ARG === "
|
|
347
|
-
? "
|
|
348
|
-
: EXPLICIT_ENGINE_ARG === "
|
|
349
|
-
? "
|
|
350
|
-
:
|
|
345
|
+
let currentDefaultEngine = EXPLICIT_ENGINE_ARG === "durable"
|
|
346
|
+
? "durable"
|
|
347
|
+
: EXPLICIT_ENGINE_ARG === "claude"
|
|
348
|
+
? "claude"
|
|
349
|
+
: EXPLICIT_ENGINE_ARG === "dsh"
|
|
350
|
+
? "dsh"
|
|
351
|
+
: EXPLICIT_ENGINE_ARG === "pi"
|
|
352
|
+
? "pi"
|
|
353
|
+
: (sharedStateStore.getDefaultEngine() ?? "pi");
|
|
351
354
|
/** 默认引擎标识(兼容 /api/health 等读取)。 */
|
|
352
|
-
const ENGINE = currentDefaultEngine;
|
|
353
355
|
/** 每个客户端(浏览器标签页 clientId)当前激活的引擎。支持多标签页同时跑不同引擎 + 零重启热切。 */
|
|
354
356
|
const clientEngines = new Map();
|
|
355
357
|
function resolveClientEngine(clientId) {
|
|
@@ -605,7 +607,6 @@ app.get("/api/preview/*splat", async (req, res) => {
|
|
|
605
607
|
// Production: serve the built frontend from web/dist. Resolve relative to this
|
|
606
608
|
// module so it works when installed as a package (global/npx/Docker), not just
|
|
607
609
|
// from the repo root. In dev, Vite serves the UI on :5173 and proxies /ws.
|
|
608
|
-
const here = dirname(fileURLToPath(import.meta.url)); // <pkg>/dist/server or <pkg>/server
|
|
609
610
|
// Resolve the package root robustly: dev runs from <repo>/server (tsx), prod
|
|
610
611
|
// from <pkg>/dist/server — the ancestor that actually has package.json wins.
|
|
611
612
|
function resolvePkgRoot() {
|
|
@@ -1086,10 +1087,17 @@ const heartbeatTimer = setInterval(() => {
|
|
|
1086
1087
|
// Unref'd so it never blocks exit: heartbeat alone must not hold the event loop open.
|
|
1087
1088
|
heartbeatTimer.unref?.();
|
|
1088
1089
|
// 引擎分发:PI_WEB_ENGINE=dsh 时使用 DeepSeek Harness 引擎(server/dsh/),
|
|
1090
|
+
// PI_WEB_ENGINE=claude 时使用通用底座下的 Claude Code 驱动(server/universal/),
|
|
1091
|
+
// PI_WEB_ENGINE=durable 时使用 Pi Durable 引擎(server/durable/),
|
|
1089
1092
|
// 默认 pi 引擎。同一 wire 协议,前端无感知(ready/health 携带 engine 字段)。
|
|
1090
1093
|
import { DshAgentService } from "./dsh/dsh-agent-service.js";
|
|
1094
|
+
import { UniversalAgentService, ClaudeCodeDriver, probeClaudeCode } from "./universal/index.js";
|
|
1095
|
+
import { DurableAgentService } from "./durable/index.js";
|
|
1096
|
+
import { probeAllEngines, probeEngine, getCachedEngineStatuses, updateEngineBackground, isEngineUpdating, ENGINE_PACKAGES, } from "./engine-probe.js";
|
|
1091
1097
|
let piServiceInstance = null;
|
|
1092
1098
|
let dshServiceInstance = null;
|
|
1099
|
+
let claudeServiceInstance = null;
|
|
1100
|
+
let durableServiceInstance = null;
|
|
1093
1101
|
let wireEngineHooks = null;
|
|
1094
1102
|
let sharedSocketCount = 0;
|
|
1095
1103
|
let sharedQuiesced = false;
|
|
@@ -1099,9 +1107,46 @@ function activeEngines() {
|
|
|
1099
1107
|
list.push(piServiceInstance);
|
|
1100
1108
|
if (dshServiceInstance)
|
|
1101
1109
|
list.push(dshServiceInstance);
|
|
1110
|
+
if (claudeServiceInstance)
|
|
1111
|
+
list.push(claudeServiceInstance);
|
|
1112
|
+
if (durableServiceInstance)
|
|
1113
|
+
list.push(durableServiceInstance);
|
|
1102
1114
|
return list;
|
|
1103
1115
|
}
|
|
1104
1116
|
function ensureEngine(engine) {
|
|
1117
|
+
if (engine === "durable") {
|
|
1118
|
+
if (!durableServiceInstance) {
|
|
1119
|
+
durableServiceInstance = new DurableAgentService({
|
|
1120
|
+
cwd: CWD,
|
|
1121
|
+
dataDir: DATA_DIR,
|
|
1122
|
+
agentDir: getAgentDir(),
|
|
1123
|
+
stateStore: sharedStateStore,
|
|
1124
|
+
});
|
|
1125
|
+
for (let i = 0; i < sharedSocketCount; i++)
|
|
1126
|
+
durableServiceInstance.noteSocketOpen();
|
|
1127
|
+
if (sharedQuiesced)
|
|
1128
|
+
durableServiceInstance.quiesce();
|
|
1129
|
+
wireEngineHooks?.(durableServiceInstance);
|
|
1130
|
+
}
|
|
1131
|
+
return durableServiceInstance;
|
|
1132
|
+
}
|
|
1133
|
+
if (engine === "claude") {
|
|
1134
|
+
if (!claudeServiceInstance) {
|
|
1135
|
+
claudeServiceInstance = new UniversalAgentService({
|
|
1136
|
+
cwd: CWD,
|
|
1137
|
+
dataDir: DATA_DIR,
|
|
1138
|
+
agentDir: getAgentDir(),
|
|
1139
|
+
stateStore: sharedStateStore,
|
|
1140
|
+
driverFactory: (cwd) => new ClaudeCodeDriver(cwd, { agentDir: getAgentDir() }),
|
|
1141
|
+
});
|
|
1142
|
+
for (let i = 0; i < sharedSocketCount; i++)
|
|
1143
|
+
claudeServiceInstance.noteSocketOpen();
|
|
1144
|
+
if (sharedQuiesced)
|
|
1145
|
+
claudeServiceInstance.quiesce();
|
|
1146
|
+
wireEngineHooks?.(claudeServiceInstance);
|
|
1147
|
+
}
|
|
1148
|
+
return claudeServiceInstance;
|
|
1149
|
+
}
|
|
1105
1150
|
if (engine === "dsh") {
|
|
1106
1151
|
if (!dshServiceInstance) {
|
|
1107
1152
|
dshServiceInstance = new DshAgentService(CWD, sharedStateStore, DATA_DIR, getAgentDir());
|
|
@@ -1566,11 +1611,12 @@ function pushNoticeToAll(level, text, textEn) {
|
|
|
1566
1611
|
}
|
|
1567
1612
|
}
|
|
1568
1613
|
}
|
|
1569
|
-
// MCP 工具桥:读取配置启动外部 MCP 服务器(stdio),把它们的
|
|
1614
|
+
// MCP 工具桥:读取配置启动外部 MCP 服务器(stdio / HTTP streamable-http),把它们的
|
|
1570
1615
|
// 工具并入与插件工具相同的 customTools 管线;单服务器失败不炸进程。
|
|
1571
1616
|
const mcpBridge = new McpBridge(DATA_DIR, (...a) => console.log("[mcp]", ...a), {
|
|
1572
1617
|
agentDir: getAgentDir(),
|
|
1573
1618
|
cwd: CWD,
|
|
1619
|
+
onToolsChanged: () => service.applyPluginAgentTools(),
|
|
1574
1620
|
});
|
|
1575
1621
|
ClientSession.mcpBridge = mcpBridge;
|
|
1576
1622
|
pluginMgr.mcpBridge = mcpBridge;
|
|
@@ -1905,11 +1951,223 @@ wss.on("connection", (ws) => {
|
|
|
1905
1951
|
})
|
|
1906
1952
|
.catch(() => { });
|
|
1907
1953
|
};
|
|
1954
|
+
const handleSwitchEngine = async (msg) => {
|
|
1955
|
+
const targetEngine = msg.engine === "durable"
|
|
1956
|
+
? "durable"
|
|
1957
|
+
: msg.engine === "claude"
|
|
1958
|
+
? "claude"
|
|
1959
|
+
: msg.engine === "dsh"
|
|
1960
|
+
? "dsh"
|
|
1961
|
+
: msg.engine === "pi"
|
|
1962
|
+
? "pi"
|
|
1963
|
+
: null;
|
|
1964
|
+
if (!targetEngine) {
|
|
1965
|
+
send({
|
|
1966
|
+
type: "notice",
|
|
1967
|
+
level: "error",
|
|
1968
|
+
text: `无效的引擎类型:${String(msg.engine)}(仅支持 pi / dsh / claude / durable)`,
|
|
1969
|
+
textEn: `Invalid engine "${String(msg.engine)}" (supported: pi, dsh, claude, durable)`,
|
|
1970
|
+
});
|
|
1971
|
+
return;
|
|
1972
|
+
}
|
|
1973
|
+
if (!clientId)
|
|
1974
|
+
return;
|
|
1975
|
+
// 闸门:非 pi 引擎需确认宿主环境中已安装对应的全局包/运行时,未安装时拒绝切换
|
|
1976
|
+
if (targetEngine !== "pi") {
|
|
1977
|
+
const probe = await probeEngine(targetEngine);
|
|
1978
|
+
if (!probe.installed) {
|
|
1979
|
+
send({
|
|
1980
|
+
type: "notice",
|
|
1981
|
+
level: "warning",
|
|
1982
|
+
text: `引擎 ${targetEngine.toUpperCase()} 尚未安装全局包(${probe.packageName ?? targetEngine}),请先安装后再切换`,
|
|
1983
|
+
textEn: `Engine ${targetEngine.toUpperCase()} global package (${probe.packageName ?? targetEngine}) is not installed; please install it before switching`,
|
|
1984
|
+
});
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
const prevEngine = resolveClientEngine(clientId);
|
|
1989
|
+
if (prevEngine === targetEngine) {
|
|
1990
|
+
setClientEngine(clientId, targetEngine);
|
|
1991
|
+
return;
|
|
1992
|
+
}
|
|
1993
|
+
// 从旧引擎解绑当前 socket 的推送
|
|
1994
|
+
try {
|
|
1995
|
+
ensureEngine(prevEngine).detach(clientId, send);
|
|
1996
|
+
}
|
|
1997
|
+
catch {
|
|
1998
|
+
/* best effort */
|
|
1999
|
+
}
|
|
2000
|
+
setClientEngine(clientId, targetEngine);
|
|
2001
|
+
attachDone = false;
|
|
2002
|
+
if (!closed) {
|
|
2003
|
+
send(readyMsg(clientId));
|
|
2004
|
+
}
|
|
2005
|
+
const cid = clientId;
|
|
2006
|
+
const nextSvc = ensureEngine(targetEngine);
|
|
2007
|
+
nextSvc
|
|
2008
|
+
.attach(cid, send)
|
|
2009
|
+
.then((newCs) => {
|
|
2010
|
+
if (closed) {
|
|
2011
|
+
nextSvc.detach(cid, send);
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
nextSvc.applyPluginCommandCatalog();
|
|
2015
|
+
newCs.flushSnapshot(true);
|
|
2016
|
+
newCs.pushSettings();
|
|
2017
|
+
void newCs.refreshSessions();
|
|
2018
|
+
void newCs.pushProjects();
|
|
2019
|
+
void newCs.listModels();
|
|
2020
|
+
// 切换引擎后重新广播插件状态与面板项,确保跨引擎切换时自定义布局与插件图标完全一致
|
|
2021
|
+
pluginMgr
|
|
2022
|
+
.ensureLoaded(() => newCs.getLang())
|
|
2023
|
+
.then((plugins) => {
|
|
2024
|
+
if (closed)
|
|
2025
|
+
return;
|
|
2026
|
+
send({ type: "plugins", plugins, epoch: pluginMgr.epoch });
|
|
2027
|
+
send({ type: "plugin_panel_items", groups: pluginMgr.panelGroups() });
|
|
2028
|
+
})
|
|
2029
|
+
.catch(() => { });
|
|
2030
|
+
attachDone = true;
|
|
2031
|
+
for (const m of pending.drain())
|
|
2032
|
+
dispatch(m);
|
|
2033
|
+
if (targetEngine === "claude") {
|
|
2034
|
+
void probeClaudeCode().then((probe) => {
|
|
2035
|
+
if (!probe.installed) {
|
|
2036
|
+
newCs.emitNotice("warning", "已热切换至 Claude Code 引擎。检测到未安装 Claude Code CLI,请在终端执行 npm i -g @anthropic-ai/claude-code 安装并运行 claude 完成登录。", "Switched to Claude Code engine. Claude Code CLI not found; run: npm i -g @anthropic-ai/claude-code and log in with claude.");
|
|
2037
|
+
}
|
|
2038
|
+
else {
|
|
2039
|
+
newCs.emitNotice("info", "已热切换至 Claude Code 引擎(已连接本地 CLI 登录态,无需在页面配置 API Key)", "Switched to Claude Code engine (connected to local CLI login session, no API Key needed)");
|
|
2040
|
+
}
|
|
2041
|
+
});
|
|
2042
|
+
}
|
|
2043
|
+
else if (targetEngine === "dsh") {
|
|
2044
|
+
newCs.emitNotice("info", "已热切换至 DSH 引擎(其他引擎后台会话保持运行,可随时切回)", "Switched to DSH engine in-place (other background conversations keep running)");
|
|
2045
|
+
}
|
|
2046
|
+
else {
|
|
2047
|
+
newCs.emitNotice("info", "已热切换至 pi 引擎(其他引擎后台会话保持运行,可随时切回)", "Switched to pi engine in-place (other background conversations keep running)");
|
|
2048
|
+
}
|
|
2049
|
+
})
|
|
2050
|
+
.catch((err) => {
|
|
2051
|
+
// 切换失败时事务回滚:原样切回 prevEngine,避免状态悬挂
|
|
2052
|
+
setClientEngine(cid, prevEngine);
|
|
2053
|
+
ensureEngine(prevEngine)
|
|
2054
|
+
.attach(cid, send)
|
|
2055
|
+
.then((rollbackCs) => {
|
|
2056
|
+
rollbackCs.flushSnapshot(true);
|
|
2057
|
+
attachDone = true;
|
|
2058
|
+
for (const m of pending.drain())
|
|
2059
|
+
dispatch(m);
|
|
2060
|
+
})
|
|
2061
|
+
.catch(() => {
|
|
2062
|
+
attachDone = true;
|
|
2063
|
+
});
|
|
2064
|
+
send({
|
|
2065
|
+
type: "notice",
|
|
2066
|
+
level: "error",
|
|
2067
|
+
text: `切换引擎失败,已恢复至 ${prevEngine} 引擎:${err.message}`,
|
|
2068
|
+
textEn: `Failed to switch engine, rolled back to ${prevEngine}: ${err.message}`,
|
|
2069
|
+
});
|
|
2070
|
+
});
|
|
2071
|
+
};
|
|
2072
|
+
const handleUpdateEngine = async (msg) => {
|
|
2073
|
+
const targetEngine = String(msg.engineId || "").trim();
|
|
2074
|
+
const meta = ENGINE_PACKAGES[targetEngine];
|
|
2075
|
+
if (!meta || !meta.packageName) {
|
|
2076
|
+
send({
|
|
2077
|
+
type: "notice",
|
|
2078
|
+
level: "error",
|
|
2079
|
+
text: `不支持或未知的引擎「${targetEngine}」`,
|
|
2080
|
+
textEn: `Unsupported or unknown engine "${targetEngine}"`,
|
|
2081
|
+
});
|
|
2082
|
+
return;
|
|
2083
|
+
}
|
|
2084
|
+
const refusal = managedRefusal("update_engine", MANAGED);
|
|
2085
|
+
if (refusal) {
|
|
2086
|
+
send({ type: "notice", level: "error", text: refusal });
|
|
2087
|
+
return;
|
|
2088
|
+
}
|
|
2089
|
+
if (isEngineUpdating(targetEngine)) {
|
|
2090
|
+
send({
|
|
2091
|
+
type: "notice",
|
|
2092
|
+
level: "warning",
|
|
2093
|
+
text: `引擎「${targetEngine.toUpperCase()}」正在后台更新中,请稍候…`,
|
|
2094
|
+
textEn: `Engine "${targetEngine.toUpperCase()}" is already updating, please wait…`,
|
|
2095
|
+
});
|
|
2096
|
+
return;
|
|
2097
|
+
}
|
|
2098
|
+
const engineDisplayNames = {
|
|
2099
|
+
pi: { zh: "Pi", en: "Pi" },
|
|
2100
|
+
dsh: { zh: "DSH", en: "DSH" },
|
|
2101
|
+
claude: { zh: "Claude Code", en: "Claude Code" },
|
|
2102
|
+
durable: { zh: "Pi Durable", en: "Pi Durable" },
|
|
2103
|
+
};
|
|
2104
|
+
const displayName = engineDisplayNames[targetEngine] ?? {
|
|
2105
|
+
zh: targetEngine.toUpperCase(),
|
|
2106
|
+
en: targetEngine.toUpperCase(),
|
|
2107
|
+
};
|
|
2108
|
+
const broadcastStatuses = (list) => {
|
|
2109
|
+
const payload = JSON.stringify({ type: "engines_status", engines: list });
|
|
2110
|
+
for (const c of wss.clients) {
|
|
2111
|
+
if (c.readyState === WebSocket.OPEN) {
|
|
2112
|
+
try {
|
|
2113
|
+
c.send(payload);
|
|
2114
|
+
}
|
|
2115
|
+
catch {
|
|
2116
|
+
/* ignore */
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
send({
|
|
2122
|
+
type: "notice",
|
|
2123
|
+
level: "info",
|
|
2124
|
+
text: `正在后台更新 ${displayName.zh} 引擎(npm i -g ${meta.packageName}@latest)…`,
|
|
2125
|
+
textEn: `Updating ${displayName.en} engine in background (npm i -g ${meta.packageName}@latest)…`,
|
|
2126
|
+
});
|
|
2127
|
+
const updatePromise = updateEngineBackground(targetEngine);
|
|
2128
|
+
broadcastStatuses(getCachedEngineStatuses());
|
|
2129
|
+
const res = await updatePromise;
|
|
2130
|
+
const freshEngines = await probeAllEngines(true);
|
|
2131
|
+
broadcastStatuses(freshEngines);
|
|
2132
|
+
if (res.ok) {
|
|
2133
|
+
send({
|
|
2134
|
+
type: "notice",
|
|
2135
|
+
level: "info",
|
|
2136
|
+
text: `✅ ${displayName.zh} 引擎更新完成`,
|
|
2137
|
+
textEn: `✅ ${displayName.en} engine updated successfully`,
|
|
2138
|
+
});
|
|
2139
|
+
}
|
|
2140
|
+
else {
|
|
2141
|
+
const detail = res.error || (res.output ? res.output.slice(-200) : "");
|
|
2142
|
+
send({
|
|
2143
|
+
type: "notice",
|
|
2144
|
+
level: "error",
|
|
2145
|
+
text: `❌ ${displayName.zh} 引擎更新失败${detail ? `:${detail}` : ""}`,
|
|
2146
|
+
textEn: `❌ Failed to update ${displayName.en} engine${detail ? `: ${detail}` : ""}`,
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
};
|
|
1908
2150
|
const dispatch = (msg) => {
|
|
1909
2151
|
if (!clientId) {
|
|
1910
2152
|
pending.push(msg);
|
|
1911
2153
|
return;
|
|
1912
2154
|
}
|
|
2155
|
+
// switch_engine 为宿主级控制消息:豁免 cs 初始化与 attachDone 门禁,确保任何异常状态下都能自由切回!
|
|
2156
|
+
if (msg.type === "switch_engine") {
|
|
2157
|
+
void handleSwitchEngine(msg);
|
|
2158
|
+
return;
|
|
2159
|
+
}
|
|
2160
|
+
if (msg.type === "update_engine") {
|
|
2161
|
+
void handleUpdateEngine(msg);
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
if (msg.type === "check_engines") {
|
|
2165
|
+
void probeAllEngines(msg.force).then((engines) => {
|
|
2166
|
+
if (!closed)
|
|
2167
|
+
send({ type: "engines_status", engines });
|
|
2168
|
+
});
|
|
2169
|
+
return;
|
|
2170
|
+
}
|
|
1913
2171
|
const cs = service.get(clientId);
|
|
1914
2172
|
if (!cs || !attachDone) {
|
|
1915
2173
|
// Session not ready yet (hello processing / plugin chain) — hold the command.
|
|
@@ -2066,6 +2324,10 @@ wss.on("connection", (ws) => {
|
|
|
2066
2324
|
break;
|
|
2067
2325
|
case "check_updates_all":
|
|
2068
2326
|
void cs.checkUpdatesAll(msg.force === true);
|
|
2327
|
+
void probeAllEngines(true).then((engines) => {
|
|
2328
|
+
if (!closed)
|
|
2329
|
+
send({ type: "engines_status", engines });
|
|
2330
|
+
});
|
|
2069
2331
|
break;
|
|
2070
2332
|
case "check_plugin_updates":
|
|
2071
2333
|
if (typeof cs.checkPluginUpdates === "function") {
|
|
@@ -2105,64 +2367,6 @@ wss.on("connection", (ws) => {
|
|
|
2105
2367
|
setTimeout(() => void scheduleQuit(), 400);
|
|
2106
2368
|
break;
|
|
2107
2369
|
}
|
|
2108
|
-
case "switch_engine": {
|
|
2109
|
-
const targetEngine = msg.engine === "dsh" ? "dsh" : msg.engine === "pi" ? "pi" : null;
|
|
2110
|
-
if (!targetEngine) {
|
|
2111
|
-
send({
|
|
2112
|
-
type: "notice",
|
|
2113
|
-
level: "error",
|
|
2114
|
-
text: `无效的引擎类型:${String(msg.engine)}(仅支持 pi / dsh)`,
|
|
2115
|
-
textEn: `Invalid engine "${String(msg.engine)}" (supported: pi, dsh)`,
|
|
2116
|
-
});
|
|
2117
|
-
break;
|
|
2118
|
-
}
|
|
2119
|
-
const prevEngine = resolveClientEngine(clientId);
|
|
2120
|
-
if (prevEngine === targetEngine) {
|
|
2121
|
-
setClientEngine(clientId, targetEngine);
|
|
2122
|
-
break;
|
|
2123
|
-
}
|
|
2124
|
-
// 从旧引擎解绑当前 socket 的推送(不中止旧引擎后台正在运行的会话)
|
|
2125
|
-
ensureEngine(prevEngine).detach(clientId, send);
|
|
2126
|
-
setClientEngine(clientId, targetEngine);
|
|
2127
|
-
attachDone = false;
|
|
2128
|
-
if (!closed) {
|
|
2129
|
-
send(readyMsg(clientId));
|
|
2130
|
-
}
|
|
2131
|
-
const cid = clientId;
|
|
2132
|
-
const nextSvc = ensureEngine(targetEngine);
|
|
2133
|
-
nextSvc
|
|
2134
|
-
.attach(cid, send)
|
|
2135
|
-
.then((newCs) => {
|
|
2136
|
-
if (closed) {
|
|
2137
|
-
nextSvc.detach(cid, send);
|
|
2138
|
-
return;
|
|
2139
|
-
}
|
|
2140
|
-
nextSvc.applyPluginCommandCatalog();
|
|
2141
|
-
newCs.flushSnapshot(true);
|
|
2142
|
-
newCs.pushSettings();
|
|
2143
|
-
void newCs.refreshSessions();
|
|
2144
|
-
void newCs.pushProjects();
|
|
2145
|
-
attachDone = true;
|
|
2146
|
-
for (const m of pending.drain())
|
|
2147
|
-
dispatch(m);
|
|
2148
|
-
newCs.emitNotice("info", targetEngine === "dsh"
|
|
2149
|
-
? "已热切换至 DSH 引擎(pi 引擎后台会话保持运行,可随时切回)"
|
|
2150
|
-
: "已热切换至 pi 引擎(DSH 引擎后台会话保持运行,可随时切回)", targetEngine === "dsh"
|
|
2151
|
-
? "Switched to DSH engine in-place (pi background conversations keep running)"
|
|
2152
|
-
: "Switched to pi engine in-place (DSH background conversations keep running)");
|
|
2153
|
-
})
|
|
2154
|
-
.catch((err) => {
|
|
2155
|
-
pending.clear();
|
|
2156
|
-
attachDone = true;
|
|
2157
|
-
send({
|
|
2158
|
-
type: "notice",
|
|
2159
|
-
level: "error",
|
|
2160
|
-
text: `切换引擎失败:${err.message}`,
|
|
2161
|
-
textEn: `Failed to switch engine: ${err.message}`,
|
|
2162
|
-
});
|
|
2163
|
-
});
|
|
2164
|
-
break;
|
|
2165
|
-
}
|
|
2166
2370
|
default: {
|
|
2167
2371
|
// 未知 type 只计数 + 节流 warn,不改变已知类型行为。
|
|
2168
2372
|
// default 分支里 msg 已收窄成 never,type 需从宽化后取。
|
|
@@ -2194,6 +2398,7 @@ wss.on("connection", (ws) => {
|
|
|
2194
2398
|
serverVersion: VERSION,
|
|
2195
2399
|
protocolVersion: PROTOCOL_VERSION,
|
|
2196
2400
|
engine: resolveClientEngine(cid),
|
|
2401
|
+
engineCapabilities: ensureEngine(resolveClientEngine(cid)).getCapabilities?.(),
|
|
2197
2402
|
// This package's own version. `serverVersion` is the pi SDK's,
|
|
2198
2403
|
// and the client used to learn ours from the update check —
|
|
2199
2404
|
// which a managed instance never runs.
|
|
@@ -2202,6 +2407,7 @@ wss.on("connection", (ws) => {
|
|
|
2202
2407
|
managed: MANAGED,
|
|
2203
2408
|
tabs: TABS ? [...TABS] : undefined,
|
|
2204
2409
|
service: SERVICE_INFO ?? undefined,
|
|
2410
|
+
engines: getCachedEngineStatuses(),
|
|
2205
2411
|
});
|
|
2206
2412
|
ws.on("message", (data) => {
|
|
2207
2413
|
tracked.isAlive = true;
|
|
@@ -2228,11 +2434,20 @@ wss.on("connection", (ws) => {
|
|
|
2228
2434
|
// saveUpload 的两条路径都从这里来,入口统一拦一次即可)。
|
|
2229
2435
|
const cid = validateClientId(msg.clientId) ?? randomUUID();
|
|
2230
2436
|
clientId = cid;
|
|
2437
|
+
if (msg.locale) {
|
|
2438
|
+
const code = msg.locale.trim().slice(0, 16);
|
|
2439
|
+
if (code)
|
|
2440
|
+
sharedStateStore.saveLocale(cid, code);
|
|
2441
|
+
}
|
|
2231
2442
|
// issue #295:ready 先行 —— 传输握手不等待会话初始化。attach 会进 SDK 的
|
|
2232
2443
|
// resourceLoader.reload 等同步目录扫描,坏挂载/家目录下可能阻塞数十秒;
|
|
2233
2444
|
// ready 在握手里先发,前端立刻离开「正在连接」(快照随后到)。
|
|
2234
2445
|
if (!closed) {
|
|
2235
2446
|
send(readyMsg(cid));
|
|
2447
|
+
void probeAllEngines().then((engines) => {
|
|
2448
|
+
if (!closed)
|
|
2449
|
+
send({ type: "engines_status", engines });
|
|
2450
|
+
});
|
|
2236
2451
|
}
|
|
2237
2452
|
// attach 慢提示:本体继续等,不取消;完成后照常走快照流程。
|
|
2238
2453
|
const slowTimer = setTimeout(() => {
|
package/dist/server/locales.js
CHANGED
|
@@ -27,6 +27,7 @@ export const LOCALE_PACKS = [
|
|
|
27
27
|
{ code: "ko", nativeName: "한국어" },
|
|
28
28
|
{ code: "pt", nativeName: "Português" },
|
|
29
29
|
{ code: "ru", nativeName: "Русский" },
|
|
30
|
+
{ code: "tr", nativeName: "Türkçe" },
|
|
30
31
|
// Traditional Chinese packs. Core "zh" is Simplified; generated from it
|
|
31
32
|
// by OpenCC + glossaries (scripts/zh-tw-locale).
|
|
32
33
|
{ code: "zh-Hant", nativeName: "繁體中文" },
|
package/dist/server/managed.js
CHANGED
|
@@ -31,6 +31,8 @@ export const MANAGED_MESSAGES = [
|
|
|
31
31
|
"check_updates_all",
|
|
32
32
|
/** Installs the pi agent itself. */
|
|
33
33
|
"install_pi_agent",
|
|
34
|
+
/** Updates an agent engine package via background process. */
|
|
35
|
+
"update_engine",
|
|
34
36
|
/** Plugin market: fetches and installs a plugin from the network. */
|
|
35
37
|
"plugin_catalog_add",
|
|
36
38
|
/** Plugin install/update/uninstall run as a background job (issue #152). */
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { pick } from "./i18n.js";
|
|
5
5
|
import { ensureMarkersRegistered, parseMarkers, getMarker, allMarkers, collectGuidance, listMarkerNames, } from "./markers/index.js";
|
|
6
6
|
import { loadStateFromBranch, appendSnapshot } from "./markers/store.js";
|
|
7
|
-
import { TODO_NAMESPACE, initTodoState } from "./markers/builtins/todo.js";
|
|
8
7
|
import { ACTION_NAMESPACE, initActionState } from "./markers/builtins/action.js";
|
|
9
8
|
ensureMarkersRegistered();
|
|
10
9
|
const _DEFAULT_MARKERS = {
|
|
@@ -51,11 +50,11 @@ export class MarkerService {
|
|
|
51
50
|
// place them (a static table value could never inline them).
|
|
52
51
|
const linesText = lines.join("\n");
|
|
53
52
|
return pick(this.lang(), "\n\n────────── 内联标记工具(重要)──────────\n" +
|
|
54
|
-
"
|
|
53
|
+
"状态类操作(操作建议、对话重命名、通知)请直接写在回答正文里,采用内联标记语法,而不要调用对应工具。\n" +
|
|
55
54
|
"插件会替你执行并把标记从展示文本中移除,不会中断你的回答。\n\n" +
|
|
56
55
|
linesText +
|
|
57
56
|
"\n──────────\n", "\n\n────────── Inline marker tools (important) ──────────\n" +
|
|
58
|
-
"Write status operations (
|
|
57
|
+
"Write status operations (action suggestions, conversation renaming, notifications) directly in your reply text using inline marker syntax — do not call a tool for them.\n" +
|
|
59
58
|
"The plugin executes them and strips the markers from the displayed text without interrupting your reply.\n\n" +
|
|
60
59
|
linesText +
|
|
61
60
|
"\n──────────\n", "markers.service.guidance.frame", { lines: linesText });
|
|
@@ -160,9 +159,7 @@ export class MarkerService {
|
|
|
160
159
|
let st = states.get(canonicalNs);
|
|
161
160
|
if (st !== undefined)
|
|
162
161
|
return st;
|
|
163
|
-
if (canonicalNs ===
|
|
164
|
-
st = this.getState(conversationId, canonicalNs, initTodoState);
|
|
165
|
-
else if (canonicalNs === ACTION_NAMESPACE)
|
|
162
|
+
if (canonicalNs === ACTION_NAMESPACE)
|
|
166
163
|
st = this.getState(conversationId, canonicalNs, initActionState);
|
|
167
164
|
else {
|
|
168
165
|
const marker = getMarker(canonicalNs);
|
|
@@ -200,7 +197,7 @@ export class MarkerService {
|
|
|
200
197
|
};
|
|
201
198
|
}
|
|
202
199
|
if (result.applied) {
|
|
203
|
-
//
|
|
200
|
+
// action 落库;notify/conv 即时生效(通知已发 / 对话已重命名),无需快照。
|
|
204
201
|
const canonicalTool = token.tool === "suggest" ? ACTION_NAMESPACE : token.tool;
|
|
205
202
|
if (canonicalTool !== "notify" && canonicalTool !== "conv") {
|
|
206
203
|
dirty.add(canonicalTool);
|
|
@@ -247,9 +244,7 @@ export class MarkerService {
|
|
|
247
244
|
if (!m.overlay)
|
|
248
245
|
continue;
|
|
249
246
|
let state;
|
|
250
|
-
if (m.name ===
|
|
251
|
-
state = this.getState(conversationId, m.name, initTodoState);
|
|
252
|
-
else if (m.name === ACTION_NAMESPACE)
|
|
247
|
+
if (m.name === ACTION_NAMESPACE)
|
|
253
248
|
state = this.getState(conversationId, m.name, initActionState);
|
|
254
249
|
else {
|
|
255
250
|
state = this.getState(conversationId, m.name, () => m.init?.() ?? {});
|
|
@@ -269,16 +264,7 @@ export class MarkerService {
|
|
|
269
264
|
}
|
|
270
265
|
return lines;
|
|
271
266
|
}
|
|
272
|
-
describe(conversationId, tool, includeDeleted = false) {
|
|
273
|
-
const st = this.getState(conversationId, TODO_NAMESPACE, initTodoState);
|
|
274
|
-
const visible = st.tasks.filter((t) => includeDeleted || t.status !== "deleted");
|
|
275
|
-
if (visible.length === 0)
|
|
276
|
-
return pick(this.lang(), "[todo] (空)", "[todo] (empty)", "markers.service.describe.empty");
|
|
277
|
-
return visible.map((t) => `[${t.status}] #${t.id}: ${t.subject}`).join("\n");
|
|
278
|
-
}
|
|
279
267
|
getRawState(conversationId, namespace) {
|
|
280
|
-
if (namespace === TODO_NAMESPACE)
|
|
281
|
-
return this.getState(conversationId, namespace, initTodoState);
|
|
282
268
|
if (namespace === ACTION_NAMESPACE || namespace === "suggest")
|
|
283
269
|
return this.getState(conversationId, ACTION_NAMESPACE, initActionState);
|
|
284
270
|
const m = getMarker(namespace);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* markers/index.ts — 聚合内置标记并提供便捷初始化。
|
|
3
3
|
*/
|
|
4
4
|
import { registerMarker } from "./registry.js";
|
|
5
|
-
import { todoMarker } from "./builtins/todo.js";
|
|
6
5
|
import { notifyMarker } from "./builtins/notify.js";
|
|
7
6
|
import { renameMarker } from "./builtins/rename.js";
|
|
8
7
|
import { actionMarker, suggestMarker } from "./builtins/action.js";
|
|
@@ -10,14 +9,13 @@ let initialized = false;
|
|
|
10
9
|
export function ensureMarkersRegistered() {
|
|
11
10
|
if (initialized)
|
|
12
11
|
return;
|
|
13
|
-
registerMarker(todoMarker);
|
|
14
12
|
registerMarker(notifyMarker);
|
|
15
13
|
registerMarker(renameMarker);
|
|
16
14
|
registerMarker(actionMarker);
|
|
17
15
|
registerMarker(suggestMarker);
|
|
18
16
|
initialized = true;
|
|
19
17
|
}
|
|
20
|
-
export {
|
|
18
|
+
export { notifyMarker, renameMarker, actionMarker, suggestMarker };
|
|
21
19
|
export * from "./marker.js";
|
|
22
20
|
export * from "./registry.js";
|
|
23
21
|
export * from "./store.js";
|
|
@@ -90,10 +90,10 @@ export function makeMcpManageTool(host, lang) {
|
|
|
90
90
|
if (action === "list") {
|
|
91
91
|
const { servers, globalPath, projectPath } = host.listServers();
|
|
92
92
|
if (servers.length === 0) {
|
|
93
|
-
return reply(pick(L, `当前未配置任何 MCP 服务器。\n项目配置:${projectPath}\n全局配置:${globalPath}`, `No MCP servers configured.\nProject config: ${projectPath}\nGlobal config: ${globalPath}`, "mcp_manage.list.empty"), { count: 0 });
|
|
93
|
+
return reply(pick(L, `当前未配置任何 MCP 服务器。\n项目配置:${projectPath}\n全局配置:${globalPath}`, `No MCP servers configured.\nProject config: ${projectPath}\nGlobal config: ${globalPath}`, "mcp_manage.list.empty", { projectPath, globalPath }), { count: 0 });
|
|
94
94
|
}
|
|
95
95
|
const lines = servers.map(formatServerLine).join("\n");
|
|
96
|
-
return reply(pick(L, `已配置的 MCP 服务器(${servers.length}):\n${lines}`, `Configured MCP servers (${servers.length}):\n${lines}`, "mcp_manage.list.ok", { count: servers.length }), { count: servers.length, servers: servers.map((s) => ({ name: s.name, scope: s.scope, status: s.status })) });
|
|
96
|
+
return reply(pick(L, `已配置的 MCP 服务器(${servers.length}):\n${lines}`, `Configured MCP servers (${servers.length}):\n${lines}`, "mcp_manage.list.ok", { count: servers.length, lines }), { count: servers.length, servers: servers.map((s) => ({ name: s.name, scope: s.scope, status: s.status })) });
|
|
97
97
|
}
|
|
98
98
|
if (action === "check") {
|
|
99
99
|
const q = (params.query ?? params.name ?? params.package ?? "").trim();
|
|
@@ -105,7 +105,7 @@ export function makeMcpManageTool(host, lang) {
|
|
|
105
105
|
return reply(pick(L, `未找到匹配「${q}」的 MCP 服务器(installed=false)。可使用 action="install" 安装。`, `No MCP server matching "${q}" is installed (installed=false). Use action="install" to install it.`, "mcp_manage.check.not_installed", { query: q }), { query: q, installed: false, running: false });
|
|
106
106
|
}
|
|
107
107
|
const lines = res.matches.map(formatServerLine).join("\n");
|
|
108
|
-
return reply(pick(L, `已找到匹配「${q}」的 MCP 服务器(installed=true, running=${res.running}):\n${lines}`, `Found MCP server matching "${q}" (installed=true, running=${res.running}):\n${lines}`, "mcp_manage.check.found", { query: q }), {
|
|
108
|
+
return reply(pick(L, `已找到匹配「${q}」的 MCP 服务器(installed=true, running=${res.running}):\n${lines}`, `Found MCP server matching "${q}" (installed=true, running=${res.running}):\n${lines}`, "mcp_manage.check.found", { query: q, running: res.running, lines }), {
|
|
109
109
|
query: q,
|
|
110
110
|
installed: true,
|
|
111
111
|
running: res.running,
|
|
@@ -131,15 +131,17 @@ export function makeMcpManageTool(host, lang) {
|
|
|
131
131
|
description: params.description,
|
|
132
132
|
});
|
|
133
133
|
if (!res.ok) {
|
|
134
|
-
|
|
134
|
+
const errorText = res.error ?? (L === "zh" ? "未知错误" : "unknown error");
|
|
135
|
+
return reply(pick(L, `MCP 服务器安装失败:${res.error ?? "未知错误"}`, `Failed to install MCP server: ${res.error ?? "unknown error"}`, "mcp_manage.install.fail", { error: errorText }), { ok: false, error: res.error });
|
|
135
136
|
}
|
|
136
137
|
const toolNames = (res.tools ?? []).map((t) => `${res.name}_${t.name}`);
|
|
138
|
+
const toolsJoined = toolNames.join(", ");
|
|
137
139
|
const toolHint = toolNames.length > 0
|
|
138
|
-
? pick(L, `\n已暴露工具(${toolNames.length}):${
|
|
140
|
+
? pick(L, `\n已暴露工具(${toolNames.length}):${toolsJoined}`, `\nExposed tools (${toolNames.length}): ${toolsJoined}`, "mcp_manage.install.tools", { count: toolNames.length, tools: toolsJoined })
|
|
139
141
|
: res.error
|
|
140
142
|
? `\n⚠️ ${res.error}`
|
|
141
143
|
: "";
|
|
142
|
-
return reply(pick(L, `已安装 MCP 服务器「${res.name}」(作用域:${res.scope},状态:${res.status})。${toolHint}`, `Installed MCP server "${res.name}" (scope: ${res.scope}, status: ${res.status}).${toolHint}`, "mcp_manage.install.ok", { name: res.name ?? "", scope: res.scope ?? "project", status: res.status ?? "stopped" }), {
|
|
144
|
+
return reply(pick(L, `已安装 MCP 服务器「${res.name}」(作用域:${res.scope},状态:${res.status})。${toolHint}`, `Installed MCP server "${res.name}" (scope: ${res.scope}, status: ${res.status}).${toolHint}`, "mcp_manage.install.ok", { name: res.name ?? "", scope: res.scope ?? "project", status: res.status ?? "stopped", toolHint }), {
|
|
143
145
|
ok: true,
|
|
144
146
|
name: res.name,
|
|
145
147
|
scope: res.scope,
|
|
@@ -155,7 +157,8 @@ export function makeMcpManageTool(host, lang) {
|
|
|
155
157
|
}
|
|
156
158
|
const res = await host.removeServer(name, params.scope);
|
|
157
159
|
if (!res.ok) {
|
|
158
|
-
|
|
160
|
+
const errorText = res.error ?? (L === "zh" ? "不存在" : "not found");
|
|
161
|
+
return reply(pick(L, `移除 MCP 服务器「${name}」失败:${res.error ?? "不存在"}`, `Failed to remove MCP server "${name}": ${res.error ?? "not found"}`, "mcp_manage.remove.fail", { name, error: errorText }), { ok: false, name, error: res.error });
|
|
159
162
|
}
|
|
160
163
|
return reply(pick(L, `已移除 MCP 服务器「${name}」并同步工具列表。`, `Removed MCP server "${name}" and synced tools.`, "mcp_manage.remove.ok", { name }), { ok: true, name });
|
|
161
164
|
}
|