pi-web-ui 0.118.0 → 0.120.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 +143 -1
- package/bin/hub-upgrade.mjs +33 -15
- package/bin/lib/atomic-file.mjs +90 -0
- package/dist/server/agent-service-daemon.js +44 -10
- package/dist/server/agent-service.js +930 -166
- package/dist/server/approval-default-rules.js +4 -4
- package/dist/server/ask-user-question-tool.js +3 -40
- package/dist/server/atomic-file.js +130 -5
- package/dist/server/background-executors.js +235 -0
- package/dist/server/bash-timeout.js +47 -0
- package/dist/server/bash-tool.js +72 -5
- package/dist/server/bg-servers.js +19 -13
- package/dist/server/browser-page-tool.js +38 -29
- package/dist/server/browser-script-tool.js +119 -0
- package/dist/server/canvas/canvas-agent-tool.js +46 -35
- package/dist/server/canvas/canvas-dispatch.js +12 -1
- package/dist/server/claim-files-tool.js +6 -7
- package/dist/server/client-state.js +457 -41
- package/dist/server/communicate-tool.js +59 -77
- package/dist/server/compact-context-tool.js +4 -13
- package/dist/server/conversation-communication.js +23 -1
- package/dist/server/conversation-read-tool.js +14 -23
- package/dist/server/conversation-rows.js +17 -0
- package/dist/server/conversation-tool-names.js +2 -2
- package/dist/server/conversation-tool.js +23 -15
- package/dist/server/conversation-touches.js +1 -1
- package/dist/server/delegate-mode.js +0 -1
- package/dist/server/delegate-task.js +18 -39
- package/dist/server/device-center/approval-summary.js +0 -1
- package/dist/server/device-center/bot-execution.js +0 -1
- package/dist/server/device-center/group-router-runtime.js +2 -0
- package/dist/server/device-center/hub-upgrade.js +5 -10
- package/dist/server/device-center/task-progress.js +2 -2
- package/dist/server/dispatch-domain-handlers.js +97 -24
- package/dist/server/dispatch-plugin-handlers.js +10 -0
- package/dist/server/dsh/dsh-agent-service.js +21 -19
- package/dist/server/durable/durable-agent-service.js +1 -1
- package/dist/server/edit-tool.js +293 -0
- package/dist/server/engine-catalog.js +8 -2
- package/dist/server/engine-cli.js +29 -7
- package/dist/server/engine-probe.js +11 -6
- package/dist/server/eval-tool.js +5 -19
- package/dist/server/files-service.js +41 -19
- package/dist/server/fs-copy.js +93 -0
- package/dist/server/goal-review-gate.js +2 -3
- package/dist/server/index.js +92 -3
- package/dist/server/job-runner.js +345 -0
- package/dist/server/lsp-tool.js +10 -28
- package/dist/server/marker-service.js +42 -30
- package/dist/server/mcp-agent-tool.js +22 -47
- package/dist/server/model-session.js +16 -0
- package/dist/server/native-cli-session-hooks.js +3 -2
- package/dist/server/native-cli-session.js +27 -2
- package/dist/server/patch-tool.js +2 -8
- package/dist/server/phone-tool.js +167 -0
- package/dist/server/plan-mode.js +7 -4
- package/dist/server/plan-update-tool.js +5 -8
- package/dist/server/plugin-api-catalog.js +13 -1
- package/dist/server/plugin-bundled.js +35 -28
- package/dist/server/plugin-catalog.js +6 -0
- package/dist/server/plugin-delivery.js +358 -0
- package/dist/server/plugin-inbox.js +152 -0
- package/dist/server/plugin-installer.js +15 -0
- package/dist/server/plugin-ledger.js +183 -0
- package/dist/server/plugin-manifest-validate.js +19 -0
- package/dist/server/plugin-materialize.js +161 -0
- package/dist/server/plugin-paths.js +60 -0
- package/dist/server/plugin-removal.js +16 -3
- package/dist/server/plugin-schedule.js +8 -7
- package/dist/server/plugin-secrets.js +7 -3
- package/dist/server/plugin-updater.js +2 -4
- package/dist/server/plugins.js +205 -48
- package/dist/server/present-files-tool.js +7 -13
- package/dist/server/preset-fields.js +23 -12
- package/dist/server/preset-share.js +1 -1
- package/dist/server/process-utils.js +11 -0
- package/dist/server/project-scripts.js +38 -0
- package/dist/server/prompt-composer.js +40 -21
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/question-params.js +98 -0
- package/dist/server/quick-ask-settings.js +0 -1
- package/dist/server/quick-ask.js +3 -0
- package/dist/server/read-tool.js +10 -17
- package/dist/server/remote-ssh-service.js +40 -1
- package/dist/server/sandbox-runtime-gate.js +1 -1
- package/dist/server/sandbox-service.js +0 -1
- package/dist/server/sandbox-tool.js +25 -34
- package/dist/server/schedule-agent-tool.js +9 -19
- package/dist/server/scm-commitmsg.js +2 -1
- package/dist/server/serialize.js +8 -0
- package/dist/server/session-list-index.js +246 -0
- package/dist/server/session-list-scan.js +5 -0
- package/dist/server/session-parser.js +16 -0
- package/dist/server/settings-service.js +49 -19
- package/dist/server/skill-tool.js +4 -6
- package/dist/server/subagent-budget.js +68 -0
- package/dist/server/subagent-evidence.js +297 -0
- package/dist/server/subagent-helpers.js +12 -0
- package/dist/server/subagent-ledger.js +401 -0
- package/dist/server/subagent-notify.js +6 -2
- package/dist/server/subagent-security-gate.js +2 -3
- package/dist/server/subagent-settle.js +71 -0
- package/dist/server/subagents.js +566 -211
- package/dist/server/tabs.js +8 -1
- package/dist/server/terminals.js +34 -28
- package/dist/server/tool-approval.js +15 -1
- package/dist/server/tool-guards.js +0 -91
- package/dist/server/tool-manager.js +127 -47
- package/dist/server/tool-overrides.js +8 -1
- package/dist/server/tool-prompt-overrides.js +3 -6
- package/dist/server/tool-prompts.js +60 -17
- package/dist/server/universal/driver-base.js +2 -0
- package/dist/server/universal/drivers/claude-code.js +210 -211
- package/dist/server/universal/drivers/codex.js +29 -24
- package/dist/server/universal/engine-mcp.js +107 -0
- package/dist/server/universal/universal-attachments.js +77 -1
- package/dist/server/universal/universal-service.js +1 -1
- package/dist/server/universal/universal-session.js +106 -69
- package/dist/server/vision-bridge.js +2 -0
- package/dist/server/workspace-handle.js +119 -17
- package/dist/server/workspace-queue.js +37 -0
- package/dist/server/worktree-tool.js +13 -20
- package/docs/README.md +40 -36
- package/docs/architecture-plugins.md +64 -35
- package/docs/device-center.md +1 -1
- package/package.json +16 -4
- package/plugin-sdk/index.d.ts +102 -0
- package/plugins/catalog.json +23 -51
- package/themes/bases/flow-base.css +8 -17
- package/themes/dark-teal.css +0 -3
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/BgTasksModal-BdOJ19Hj.js +1 -0
- package/web/dist/assets/BgTasksModal-SAH2XCkY.js +1 -0
- package/web/dist/assets/{CanvasStudio-CAWcs9tm.js → CanvasStudio-BB_Iq7pl.js} +3 -3
- package/web/dist/assets/CanvasStudio-DU6O3N4u.js +1579 -0
- package/web/dist/assets/DeviceCenter-By1zVTSY.js +3 -0
- package/web/dist/assets/DeviceCenter-Cnm0Tjrx.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-qJzbI0Cf.js +1 -0
- package/web/dist/assets/{DeviceGroups-C_fZMNeK.js → DeviceGroups-DPrQxW6B.js} +1 -1
- package/web/dist/assets/DeviceGroups-DoucyUjI.js +1 -0
- package/web/dist/assets/{Dropdown-CTgVLUbp.js → Dropdown-kj_NIj6e.js} +1 -1
- package/web/dist/assets/FilePreview-Bub8Y9uq.js +2 -0
- package/web/dist/assets/FilePreview-CC76Z6an.js +2 -0
- package/web/dist/assets/GlobalSearchModal-01nkgw4X.js +1 -0
- package/web/dist/assets/GlobalSearchModal-CiT6wBmR.js +1 -0
- package/web/dist/assets/GroupConversation-1-lsPO1f.js +61 -0
- package/web/dist/assets/GroupConversation-HeiyW_O_.js +61 -0
- package/web/dist/assets/{GroupWorkItems-BIvZtr10.js → GroupWorkItems-BYJv2XFj.js} +1 -1
- package/web/dist/assets/{HintTip-Da6qc566.js → HintTip-DFhoclDw.js} +1 -1
- package/web/dist/assets/ModelConfigModal-D2Ro-jUZ.js +2 -0
- package/web/dist/assets/ModelConfigModal-DPc9R1pq.js +2 -0
- package/web/dist/assets/{NativeCliPanel-CU1rZmyu.js → NativeCliPanel-B108d697.js} +3 -3
- package/web/dist/assets/NativeCliPanel-DupvGwQM.js +5 -0
- package/web/dist/assets/{PiSetupModal-DZKY5Wiw.js → PiSetupModal-D0HitBfd.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-BLKUEDde.js +1 -0
- package/web/dist/assets/SCMPanel-DDbWrUHR.js +2 -0
- package/web/dist/assets/SCMPanel-DluNcd2-.js +2 -0
- package/web/dist/assets/SettingsModal-Cy5lRC97.css +1 -0
- package/web/dist/assets/SettingsModal-DQu18366.js +33 -0
- package/web/dist/assets/SettingsModal-Dm_haPme.js +33 -0
- package/web/dist/assets/{TermXterm-Bt5WKAxP.js → TermXterm-SYc-MUk2.js} +2 -2
- package/web/dist/assets/TerminalPanel-CgA_lhVT.js +1 -0
- package/web/dist/assets/TerminalPanel-vdSIOPjD.js +1 -0
- package/web/dist/assets/TuiOverlayModal-Cy1jYYIw.js +1 -0
- package/web/dist/assets/TuiOverlayModal-kXY_4hV8.js +1 -0
- package/web/dist/assets/app-globals-CBEscsYP.js +129 -0
- package/web/dist/assets/{canvas-client-WkhM55mR.js → canvas-client-Clsypfs6.js} +1 -1
- package/web/dist/assets/{desktop-B8NZ3KW-.js → desktop-C6D9a8HZ.js} +1 -1
- package/web/dist/assets/index-BD29OL9L.js +404 -0
- package/web/dist/assets/index-BlCxbqqr.js +404 -0
- package/web/dist/assets/index-DB55rbKC.css +1 -0
- package/web/dist/assets/plugin-host-VWBcq-LQ.js +1 -0
- package/web/dist/assets/remote-ssh-client-C2eab5Kw.js +1 -0
- package/web/dist/assets/theme-CpQk_Agp.js +1 -0
- package/web/dist/index.html +10 -10
- package/web/dist/sw.js +1 -1
- package/dist/server/edit-soft-tool.js +0 -297
- package/web/dist/assets/BgTasksModal-D-x7kA63.js +0 -1
- package/web/dist/assets/DeviceCenter-Dc0whRcu.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +0 -1
- package/web/dist/assets/FilePreview-C6W0PvaK.js +0 -2
- package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +0 -1
- package/web/dist/assets/GroupConversation-C81YjF2C.js +0 -61
- package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +0 -1
- package/web/dist/assets/SCMPanel-CuEgzAlO.js +0 -2
- package/web/dist/assets/SettingsModal-Cdu5h29p.js +0 -33
- package/web/dist/assets/TerminalPanel-BCIBV8se.js +0 -1
- package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +0 -1
- package/web/dist/assets/app-globals-CZjFtI4F.js +0 -129
- package/web/dist/assets/index-CQc3VrWa.css +0 -1
- package/web/dist/assets/index-D_AGu4Zv.js +0 -404
- package/web/dist/assets/plugin-host-uqZGpvCs.js +0 -1
- package/web/dist/assets/remote-ssh-client-Cdf-cTUe.js +0 -1
- package/web/dist/assets/theme-DGL7hLUs.js +0 -1
package/dist/server/plugins.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ensurePluginAsset, getPluginAssetStatus, } from "./plugin-assets.js";
|
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { ttsService } from "./tts-service.js";
|
|
5
5
|
import { mkdir, readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
6
|
-
import { cpSync, existsSync, lstatSync, readFileSync, readdirSync, watch as fsWatch
|
|
6
|
+
import { cpSync, existsSync, lstatSync, readFileSync, readdirSync, watch as fsWatch } from "node:fs";
|
|
7
7
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
8
8
|
import { pathToFileURL } from "node:url";
|
|
9
9
|
import { writeJsonAtomicSync } from "./atomic-file.js";
|
|
@@ -21,6 +21,11 @@ import { PluginGrantsStore, normalizeGrantPath } from "./plugin-grants.js";
|
|
|
21
21
|
import { normalizeIconSvg } from "./icon-svg.js";
|
|
22
22
|
import { cleanupRemovedPlugins } from "./plugin-removal.js";
|
|
23
23
|
import { prepareBundledPlugins } from "./plugin-bundled.js";
|
|
24
|
+
import { materializePlugin } from "./plugin-materialize.js";
|
|
25
|
+
import { migratePluginState, pluginCodeDir, pluginStateDir } from "./plugin-paths.js";
|
|
26
|
+
import { PluginInbox } from "./plugin-inbox.js";
|
|
27
|
+
import { PluginLedgerStore } from "./plugin-ledger.js";
|
|
28
|
+
import { DeliveryQueue } from "./plugin-delivery.js";
|
|
24
29
|
import { PluginDomConsent, declarationWantsDom } from "./plugin-dom.js";
|
|
25
30
|
import { validatePluginManifest, formatManifestIssue, isKnownPermission } from "./plugin-manifest-validate.js";
|
|
26
31
|
import { buildPluginApiCatalog } from "./plugin-api-catalog.js";
|
|
@@ -780,9 +785,18 @@ function resolveSettingsValues(schema, stored, overlay, secrets) {
|
|
|
780
785
|
}
|
|
781
786
|
return { values, sources };
|
|
782
787
|
}
|
|
783
|
-
function
|
|
788
|
+
function readManifestVersion(manifestPath) {
|
|
784
789
|
try {
|
|
785
|
-
const
|
|
790
|
+
const raw = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
791
|
+
return typeof raw.version === "string" ? raw.version.trim() : "";
|
|
792
|
+
}
|
|
793
|
+
catch {
|
|
794
|
+
return "";
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
function readStoredSettings(stateDir) {
|
|
798
|
+
try {
|
|
799
|
+
const parsed = JSON.parse(readFileSync(join(stateDir, "storage.json"), "utf8"));
|
|
786
800
|
if (parsed && typeof parsed === "object" && parsed.settings && typeof parsed.settings === "object") {
|
|
787
801
|
return parsed.settings;
|
|
788
802
|
}
|
|
@@ -790,8 +804,8 @@ function readStoredSettings(dir) {
|
|
|
790
804
|
catch { }
|
|
791
805
|
return {};
|
|
792
806
|
}
|
|
793
|
-
function runtimeSettingsValues(
|
|
794
|
-
return resolveSettingsValues(schema, readStoredSettings(
|
|
807
|
+
function runtimeSettingsValues(stateDir, schema, secrets, overlay = {}) {
|
|
808
|
+
return resolveSettingsValues(schema, readStoredSettings(stateDir), overlay, { get: (k) => secrets.get(k) }).values;
|
|
795
809
|
}
|
|
796
810
|
function cleanNonSecretSettingsField(f, v, lang) {
|
|
797
811
|
if (f.type === "number") {
|
|
@@ -832,7 +846,7 @@ function cleanNonSecretSettingsField(f, v, lang) {
|
|
|
832
846
|
}
|
|
833
847
|
return { value: v === undefined ? (f.default ?? "") : String(v) };
|
|
834
848
|
}
|
|
835
|
-
function saveSettingsValues(
|
|
849
|
+
function saveSettingsValues(stateDir, schema, values, lang, secrets) {
|
|
836
850
|
const l = lang?.() ?? "en";
|
|
837
851
|
const clean = {};
|
|
838
852
|
const secretUpdates = {};
|
|
@@ -872,7 +886,7 @@ function saveSettingsValues(dir, schema, values, lang, secrets) {
|
|
|
872
886
|
for (const [k, v] of Object.entries(clean))
|
|
873
887
|
if (!secretKeys.has(k))
|
|
874
888
|
persist[k] = v;
|
|
875
|
-
const file = join(
|
|
889
|
+
const file = join(stateDir, "storage.json");
|
|
876
890
|
withFileRmwLockSync(file, () => {
|
|
877
891
|
if (secrets)
|
|
878
892
|
secrets.commitSettings(persist, secretUpdates);
|
|
@@ -893,7 +907,7 @@ function saveSettingsValues(dir, schema, values, lang, secrets) {
|
|
|
893
907
|
});
|
|
894
908
|
}
|
|
895
909
|
catch (err) {
|
|
896
|
-
console.error(`[plugins] settings persist failed (${
|
|
910
|
+
console.error(`[plugins] settings persist failed (${stateDir}):`, err);
|
|
897
911
|
return { error: err.message, clean };
|
|
898
912
|
}
|
|
899
913
|
return { clean };
|
|
@@ -918,7 +932,7 @@ export class PluginManager {
|
|
|
918
932
|
panelSweepTimer = null;
|
|
919
933
|
epochCounter = 0;
|
|
920
934
|
lifecycleGeneration = 0;
|
|
921
|
-
|
|
935
|
+
loadingByScope = new Map();
|
|
922
936
|
reloading;
|
|
923
937
|
activatingEffects = new Set();
|
|
924
938
|
catalogEpoch = 0;
|
|
@@ -1039,7 +1053,7 @@ export class PluginManager {
|
|
|
1039
1053
|
const l = lang?.() ?? "en";
|
|
1040
1054
|
if (!ID_RE.test(pluginId))
|
|
1041
1055
|
return { error: pick(l, "非法的插件 id", "Invalid plugin id", "plugins.id.invalid") };
|
|
1042
|
-
const
|
|
1056
|
+
const stateDir = pluginStateDir(this.dataDir, pluginId);
|
|
1043
1057
|
const info = this.loaded.get(pluginId)?.info;
|
|
1044
1058
|
const schema = info?.settingsSchema ?? [];
|
|
1045
1059
|
if (!schema.length)
|
|
@@ -1048,7 +1062,7 @@ export class PluginManager {
|
|
|
1048
1062
|
};
|
|
1049
1063
|
let result;
|
|
1050
1064
|
try {
|
|
1051
|
-
result = saveSettingsValues(
|
|
1065
|
+
result = saveSettingsValues(stateDir, schema, values, lang, new PluginSecrets(this.dataDir, stateDir));
|
|
1052
1066
|
}
|
|
1053
1067
|
catch (err) {
|
|
1054
1068
|
return { error: err.message };
|
|
@@ -1169,9 +1183,9 @@ export class PluginManager {
|
|
|
1169
1183
|
}
|
|
1170
1184
|
}
|
|
1171
1185
|
}
|
|
1172
|
-
async maybeConsentNotice(info,
|
|
1186
|
+
async maybeConsentNotice(info, stateDir, perms) {
|
|
1173
1187
|
try {
|
|
1174
|
-
const markerFile = join(
|
|
1188
|
+
const markerFile = join(stateDir, ".pi-approved");
|
|
1175
1189
|
const key = createHash("sha256").update(JSON.stringify(perms)).digest("hex").slice(0, 32);
|
|
1176
1190
|
let prev = "";
|
|
1177
1191
|
try {
|
|
@@ -1182,7 +1196,8 @@ export class PluginManager {
|
|
|
1182
1196
|
return;
|
|
1183
1197
|
const list = perms.length ? perms.join(", ") : "无";
|
|
1184
1198
|
this.notifyAll(perms.length ? "warning" : "info", `插件「${info.name}」已激活(${prev ? "能力清单变更" : "首次安装"};声明能力:${list})——请确认来源可信`, `Plugin "${info.name}" activated (${prev ? "capability list changed" : "first install"}; declared: ${list}) — verify the source is trusted`);
|
|
1185
|
-
|
|
1199
|
+
// 状态目录可能还没建(新装/刚迁移),原子写自带 mkdir;直接 writeFileSync 会 ENOENT 且每次都重报
|
|
1200
|
+
writeJsonAtomicSync(markerFile, { v: 1, key, perms });
|
|
1186
1201
|
}
|
|
1187
1202
|
catch (err) {
|
|
1188
1203
|
console.error(`[plugin:${info.id}] consent notice failed:`, err);
|
|
@@ -1525,6 +1540,10 @@ export class PluginManager {
|
|
|
1525
1540
|
modelLister = undefined;
|
|
1526
1541
|
mcpProjects = undefined;
|
|
1527
1542
|
permGrants;
|
|
1543
|
+
/** 插件投递账本:按插件 id 缓存,跨 reload/反激活保留(这正是账本的意义)。 */
|
|
1544
|
+
inboxes = new Map();
|
|
1545
|
+
/** 一个插件一个账本(入站/出站共用同一个 PluginLedgerStore 与同一份文件)。 */
|
|
1546
|
+
ledgers = new Map();
|
|
1528
1547
|
permissionRequester = undefined;
|
|
1529
1548
|
onPermGrantsChanged = undefined;
|
|
1530
1549
|
statsHandlers = new Set();
|
|
@@ -2003,17 +2022,93 @@ export class PluginManager {
|
|
|
2003
2022
|
},
|
|
2004
2023
|
});
|
|
2005
2024
|
}
|
|
2006
|
-
ensureLoaded(lang) {
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2025
|
+
ensureLoaded(lang, opts) {
|
|
2026
|
+
const scope = opts?.scope ?? "all";
|
|
2027
|
+
const running = this.loadingByScope.get(scope);
|
|
2028
|
+
if (running)
|
|
2029
|
+
return running;
|
|
2030
|
+
const pending = this.loadGeneration(this.lifecycleGeneration, lang, scope).finally(() => {
|
|
2031
|
+
if (this.loadingByScope.get(scope) === pending)
|
|
2032
|
+
this.loadingByScope.delete(scope);
|
|
2012
2033
|
});
|
|
2013
|
-
this.
|
|
2034
|
+
this.loadingByScope.set(scope, pending);
|
|
2014
2035
|
return pending;
|
|
2015
2036
|
}
|
|
2016
|
-
|
|
2037
|
+
/** 取得(或创建)某个插件的投递账本。 */
|
|
2038
|
+
/** 取得(或创建)某个插件的投递账本:入站与出站共享同一个存储。 */
|
|
2039
|
+
ledgerFor(pluginId) {
|
|
2040
|
+
const id = String(pluginId ?? "plugin").replace(/[^A-Za-z0-9_-]/g, "") || "plugin";
|
|
2041
|
+
const existing = this.ledgers.get(id);
|
|
2042
|
+
if (existing)
|
|
2043
|
+
return existing;
|
|
2044
|
+
const ledger = new PluginLedgerStore({ dataDir: this.dataDir, pluginId: id });
|
|
2045
|
+
const inbox = new PluginInbox({ dataDir: this.dataDir, pluginId: id, ledger });
|
|
2046
|
+
const delivery = new DeliveryQueue({ ledger });
|
|
2047
|
+
// 出站重试必须有后台 pump,否则入队的消息永远不会再发。
|
|
2048
|
+
delivery.start();
|
|
2049
|
+
const entry = { ledger, inbox, delivery };
|
|
2050
|
+
this.ledgers.set(id, entry);
|
|
2051
|
+
this.inboxes.set(id, inbox);
|
|
2052
|
+
return entry;
|
|
2053
|
+
}
|
|
2054
|
+
inboxFor(pluginId) {
|
|
2055
|
+
return this.ledgerFor(pluginId).inbox;
|
|
2056
|
+
}
|
|
2057
|
+
deliveryFor(pluginId) {
|
|
2058
|
+
return this.ledgerFor(pluginId).delivery;
|
|
2059
|
+
}
|
|
2060
|
+
/** 所有渠道的出站人数聚合(供 /api/health)。 */
|
|
2061
|
+
deliveryStats() {
|
|
2062
|
+
const plugins = {};
|
|
2063
|
+
let totalQueued = 0;
|
|
2064
|
+
let totalDead = 0;
|
|
2065
|
+
for (const [id, entry] of this.ledgers) {
|
|
2066
|
+
const out = entry.delivery.stats();
|
|
2067
|
+
const inboxDead = entry.inbox.dead().length;
|
|
2068
|
+
plugins[id] = { ...out, inboxDead };
|
|
2069
|
+
totalQueued += out.queued;
|
|
2070
|
+
totalDead += out.dead + inboxDead;
|
|
2071
|
+
}
|
|
2072
|
+
return { plugins, totalQueued, totalDead };
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* 启动时(无任何 WS 连接)激活声明了 manifest.alwaysOn 的插件。
|
|
2076
|
+
* 未声明的插件保持懒激活,等首个客户端 attach —— 避免开机拉起上百个 UI 插件的副作用。
|
|
2077
|
+
*/
|
|
2078
|
+
ensureAlwaysOnLoaded(lang) {
|
|
2079
|
+
return this.ensureLoaded(lang, { scope: "alwaysOn" });
|
|
2080
|
+
}
|
|
2081
|
+
/**
|
|
2082
|
+
* 重新激活激活失败的常驻插件(供后台执行者的 on-failure 自愈)。
|
|
2083
|
+
* 成功激活的常驻插件保持不动,其余插件的懒激活状态不受影响。
|
|
2084
|
+
*/
|
|
2085
|
+
async rescanAlwaysOn(lang) {
|
|
2086
|
+
// eslint-disable-next-line unicorn/no-useless-spread -- snapshot: deactivateEntry mutates this.loaded mid-loop
|
|
2087
|
+
for (const [id, p] of [...this.loaded]) {
|
|
2088
|
+
if (p.info.alwaysOn !== true || !p.info.error)
|
|
2089
|
+
continue;
|
|
2090
|
+
this.deactivateEntry(id, p);
|
|
2091
|
+
this.attempted.delete(id);
|
|
2092
|
+
}
|
|
2093
|
+
return this.ensureAlwaysOnLoaded(lang);
|
|
2094
|
+
}
|
|
2095
|
+
/** 常驻插件体检快照(供 /api/health 与后台执行者探针使用)。 */
|
|
2096
|
+
alwaysOnSnapshot() {
|
|
2097
|
+
const out = [];
|
|
2098
|
+
for (const [id, p] of this.loaded) {
|
|
2099
|
+
if (p.info.alwaysOn !== true)
|
|
2100
|
+
continue;
|
|
2101
|
+
out.push({
|
|
2102
|
+
id,
|
|
2103
|
+
...(p.info.version ? { version: p.info.version } : {}),
|
|
2104
|
+
active: !p.info.error,
|
|
2105
|
+
...(p.info.error ? { error: p.info.error } : {}),
|
|
2106
|
+
diagnostics: (p.info.diagnostics ?? []).slice(0, 10),
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
return out;
|
|
2110
|
+
}
|
|
2111
|
+
async loadGeneration(generation, lang, scope = "all") {
|
|
2017
2112
|
const l = lang?.() ?? "en";
|
|
2018
2113
|
const found = await this.scan(lang);
|
|
2019
2114
|
if (generation !== this.lifecycleGeneration)
|
|
@@ -2034,6 +2129,8 @@ export class PluginManager {
|
|
|
2034
2129
|
continue;
|
|
2035
2130
|
if (!existsSync(join(this.pluginsDir, info.id, "index.mjs")))
|
|
2036
2131
|
continue;
|
|
2132
|
+
if (scope === "alwaysOn" && info.alwaysOn !== true)
|
|
2133
|
+
continue;
|
|
2037
2134
|
await this.activate(info, lang);
|
|
2038
2135
|
if (generation !== this.lifecycleGeneration)
|
|
2039
2136
|
return [];
|
|
@@ -2104,8 +2201,12 @@ export class PluginManager {
|
|
|
2104
2201
|
}
|
|
2105
2202
|
dispose() {
|
|
2106
2203
|
this.lifecycleGeneration += 1;
|
|
2107
|
-
this.
|
|
2204
|
+
this.loadingByScope.clear();
|
|
2108
2205
|
this.reloading = undefined;
|
|
2206
|
+
for (const entry of this.ledgers.values())
|
|
2207
|
+
entry.delivery.dispose();
|
|
2208
|
+
this.ledgers.clear();
|
|
2209
|
+
this.inboxes.clear();
|
|
2109
2210
|
this.attempted.clear();
|
|
2110
2211
|
this.activatingGates.clear();
|
|
2111
2212
|
for (const effects of this.activatingEffects)
|
|
@@ -2170,9 +2271,17 @@ export class PluginManager {
|
|
|
2170
2271
|
catch { }
|
|
2171
2272
|
}
|
|
2172
2273
|
try {
|
|
2173
|
-
prepareBundledPlugins(this.dataDir, this.builtinCatalogPath, new Set(this.catalog()
|
|
2274
|
+
const outcomes = prepareBundledPlugins(this.dataDir, this.builtinCatalogPath, new Set(this.catalog()
|
|
2174
2275
|
.filter((entry) => entry.origin === "custom")
|
|
2175
2276
|
.map((entry) => entry.id)));
|
|
2277
|
+
for (const outcome of outcomes) {
|
|
2278
|
+
if (outcome.status === "repaired") {
|
|
2279
|
+
console.log(`[plugins] 随包插件 ${outcome.id} 就地修复(缺回执或文件不全)→ ${outcome.files} 个文件`);
|
|
2280
|
+
}
|
|
2281
|
+
else if (outcome.status === "failed" || outcome.status === "source-invalid") {
|
|
2282
|
+
console.warn(`[plugins] 随包插件 ${outcome.id} 物化失败:${outcome.error ?? outcome.status}`);
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2176
2285
|
}
|
|
2177
2286
|
catch (err) {
|
|
2178
2287
|
console.warn("[plugins] Preparing bundled modules failed:", err);
|
|
@@ -2205,22 +2314,31 @@ export class PluginManager {
|
|
|
2205
2314
|
catch { }
|
|
2206
2315
|
const targetManifest = join(targetDir, "manifest.json");
|
|
2207
2316
|
const sourceManifest = join(sourceDir, "manifest.json");
|
|
2208
|
-
if (!existsSync(sourceDir) || !existsSync(sourceManifest)
|
|
2317
|
+
if (!existsSync(sourceDir) || !existsSync(sourceManifest))
|
|
2209
2318
|
continue;
|
|
2210
|
-
}
|
|
2211
2319
|
try {
|
|
2212
2320
|
const srcRaw = JSON.parse(readFileSync(sourceManifest, "utf8"));
|
|
2213
|
-
const tgtRaw = JSON.parse(readFileSync(targetManifest, "utf8"));
|
|
2214
2321
|
const srcVer = typeof srcRaw.version === "string" ? srcRaw.version.trim() : "";
|
|
2215
|
-
const tgtVer =
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2322
|
+
const tgtVer = readManifestVersion(targetManifest);
|
|
2323
|
+
const upgrade = Boolean(srcVer && tgtVer && compareVersions(srcVer, tgtVer) > 0);
|
|
2324
|
+
const outcome = materializePlugin({
|
|
2325
|
+
id: name,
|
|
2326
|
+
sourceDir,
|
|
2327
|
+
targetDir,
|
|
2328
|
+
upgrade,
|
|
2329
|
+
beforeOverwrite: () => {
|
|
2330
|
+
ensureBackup(this.dataDir, name, { source: `builtin:${srcVer}` });
|
|
2331
|
+
},
|
|
2332
|
+
});
|
|
2333
|
+
if (outcome.status === "failed" || outcome.status === "source-invalid") {
|
|
2334
|
+
console.warn(`[plugins] 自动同步内置插件 ${name} 失败:${outcome.error ?? outcome.status}`);
|
|
2335
|
+
}
|
|
2336
|
+
else if (outcome.status === "upgraded") {
|
|
2222
2337
|
console.log(`[plugins] 内置插件 ${name} 随宿主自动同步升级:${tgtVer} → ${srcVer}`);
|
|
2223
2338
|
}
|
|
2339
|
+
else if (outcome.status === "repaired") {
|
|
2340
|
+
console.log(`[plugins] 内置插件 ${name} 重新物化(缺回执或文件不全)→ ${outcome.files} 个文件`);
|
|
2341
|
+
}
|
|
2224
2342
|
}
|
|
2225
2343
|
catch (err) {
|
|
2226
2344
|
console.warn(`[plugins] 自动同步内置插件 ${name} 失败:`, err);
|
|
@@ -2244,7 +2362,7 @@ export class PluginManager {
|
|
|
2244
2362
|
for (const name of names.sort()) {
|
|
2245
2363
|
if (!ID_RE.test(name))
|
|
2246
2364
|
continue;
|
|
2247
|
-
const dir =
|
|
2365
|
+
const dir = pluginCodeDir(this.dataDir, name);
|
|
2248
2366
|
try {
|
|
2249
2367
|
const st = await stat(dir);
|
|
2250
2368
|
if (generation !== this.lifecycleGeneration)
|
|
@@ -2255,6 +2373,11 @@ export class PluginManager {
|
|
|
2255
2373
|
catch {
|
|
2256
2374
|
continue;
|
|
2257
2375
|
}
|
|
2376
|
+
const stateDir = pluginStateDir(this.dataDir, name);
|
|
2377
|
+
// 老布局(状态住在代码目录)→ 状态目录,幂等;从此代码目录可自由重放
|
|
2378
|
+
for (const movedFile of migratePluginState(this.dataDir, name)) {
|
|
2379
|
+
console.log(`[plugins] 插件 ${name} 的状态文件 ${movedFile} 已迁到 plugin-data/${name}/`);
|
|
2380
|
+
}
|
|
2258
2381
|
try {
|
|
2259
2382
|
const raw = await readFile(join(dir, "manifest.json"), "utf8");
|
|
2260
2383
|
if (generation !== this.lifecycleGeneration)
|
|
@@ -2296,7 +2419,7 @@ export class PluginManager {
|
|
|
2296
2419
|
const overlayForScan = cleanOverlaySettings(settingsSchemaForScan, overlayFileForScan.raw, "en");
|
|
2297
2420
|
for (const w of [...overlayFileForScan.warnings, ...overlayForScan.warnings])
|
|
2298
2421
|
uiDiags.push(`override: ${w}`);
|
|
2299
|
-
const resolvedSettingsForScan = resolveSettingsValues(settingsSchemaForScan, readStoredSettings(
|
|
2422
|
+
const resolvedSettingsForScan = resolveSettingsValues(settingsSchemaForScan, readStoredSettings(stateDir), overlayForScan.values, { has: (k) => new PluginSecrets(this.dataDir, stateDir).has(k) });
|
|
2300
2423
|
const hasClient = existsSync(join(dir, "client", "entry.mjs"));
|
|
2301
2424
|
out.push({
|
|
2302
2425
|
id: name,
|
|
@@ -2340,6 +2463,7 @@ export class PluginManager {
|
|
|
2340
2463
|
settingsSchema: settingsSchemaForScan,
|
|
2341
2464
|
settingsValues: resolvedSettingsForScan.values,
|
|
2342
2465
|
settingsSources: resolvedSettingsForScan.sources,
|
|
2466
|
+
alwaysOn: m.alwaysOn === true ? true : undefined,
|
|
2343
2467
|
isolated: m.isolated === true || m.shadow === true ? true : undefined,
|
|
2344
2468
|
renderers: Array.isArray(m.renderers)
|
|
2345
2469
|
? m.renderers.filter((r) => typeof r === "string" && r.length > 0).slice(0, 32)
|
|
@@ -2525,7 +2649,9 @@ export class PluginManager {
|
|
|
2525
2649
|
async activate(info, lang) {
|
|
2526
2650
|
const l = lang?.() ?? "en";
|
|
2527
2651
|
this.attempted.add(info.id);
|
|
2528
|
-
const dir =
|
|
2652
|
+
const dir = pluginCodeDir(this.dataDir, info.id);
|
|
2653
|
+
const stateDir = pluginStateDir(this.dataDir, info.id);
|
|
2654
|
+
migratePluginState(this.dataDir, info.id);
|
|
2529
2655
|
try {
|
|
2530
2656
|
const rawManifest = readFileSync(join(dir, "manifest.json"), "utf8");
|
|
2531
2657
|
const parsedManifest = JSON.parse(rawManifest);
|
|
@@ -2694,8 +2820,8 @@ export class PluginManager {
|
|
|
2694
2820
|
}
|
|
2695
2821
|
}
|
|
2696
2822
|
const netAllow = info.netAllowlist ?? [];
|
|
2697
|
-
const storage = new PluginStorage(join(
|
|
2698
|
-
const secrets = new PluginSecrets(this.dataDir,
|
|
2823
|
+
const storage = new PluginStorage(join(stateDir, "storage.json"));
|
|
2824
|
+
const secrets = new PluginSecrets(this.dataDir, stateDir);
|
|
2699
2825
|
const workspaceFs = new WorkspaceFS(() => self.cwdValue);
|
|
2700
2826
|
const allowAbs = (p) => {
|
|
2701
2827
|
const abs = normalizeGrantPath(p);
|
|
@@ -2926,6 +3052,37 @@ export class PluginManager {
|
|
|
2926
3052
|
completeDelivery: (id, result) => workItemsCall("completeDelivery", { id, ...result }),
|
|
2927
3053
|
failDelivery: (id, result) => workItemsCall("failDelivery", { id, ...result }),
|
|
2928
3054
|
},
|
|
3055
|
+
inbox: (() => {
|
|
3056
|
+
const inbox = self.inboxFor(info.id);
|
|
3057
|
+
return {
|
|
3058
|
+
claim: (key, meta) => inbox.claim(key, meta),
|
|
3059
|
+
complete: (key, result) => inbox.complete(key, result ?? {}),
|
|
3060
|
+
fail: (key, error) => inbox.fail(key, error),
|
|
3061
|
+
pending: () => inbox.pending(),
|
|
3062
|
+
dead: () => inbox.dead(),
|
|
3063
|
+
};
|
|
3064
|
+
})(),
|
|
3065
|
+
delivery: (() => {
|
|
3066
|
+
const queue = self.deliveryFor(info.id);
|
|
3067
|
+
const requireChat = () => {
|
|
3068
|
+
if (!can("chat"))
|
|
3069
|
+
throw new Error(`插件未声明能力 "chat"(manifest.permissions)——出站发送被拒`);
|
|
3070
|
+
};
|
|
3071
|
+
return {
|
|
3072
|
+
register: (input) => {
|
|
3073
|
+
requireChat();
|
|
3074
|
+
queue.registerSender(String(input?.channel ?? ""), input.send);
|
|
3075
|
+
return () => queue.unregisterSender(String(input?.channel ?? ""));
|
|
3076
|
+
},
|
|
3077
|
+
send: (req) => {
|
|
3078
|
+
requireChat();
|
|
3079
|
+
return queue.sendNow(req);
|
|
3080
|
+
},
|
|
3081
|
+
stats: () => queue.stats(),
|
|
3082
|
+
pending: () => queue.pending(),
|
|
3083
|
+
dead: () => queue.dead(),
|
|
3084
|
+
};
|
|
3085
|
+
})(),
|
|
2929
3086
|
chatWait: async (req, opts) => {
|
|
2930
3087
|
try {
|
|
2931
3088
|
const sent = await sendChat(req);
|
|
@@ -3567,7 +3724,7 @@ export class PluginManager {
|
|
|
3567
3724
|
const schema = info.settingsSchema ?? [];
|
|
3568
3725
|
const overlayFile = readSettingsOverlayFile(self.dataDir, info.id);
|
|
3569
3726
|
const overlay = cleanOverlaySettings(schema, overlayFile.raw, "en");
|
|
3570
|
-
return runtimeSettingsValues(
|
|
3727
|
+
return runtimeSettingsValues(stateDir, schema, secrets, overlay.values);
|
|
3571
3728
|
},
|
|
3572
3729
|
onSettingsChanged: (h) => {
|
|
3573
3730
|
settingsHandlers.add(h);
|
|
@@ -3678,7 +3835,7 @@ export class PluginManager {
|
|
|
3678
3835
|
: "";
|
|
3679
3836
|
if (!sid || !ID_RE.test(sid))
|
|
3680
3837
|
throw new Error("schedule: persistent 任务必须给合法 id(字母/数字/下划线/连字符),重启后靠它重建");
|
|
3681
|
-
const records = loadScheduleRecords(
|
|
3838
|
+
const records = loadScheduleRecords(stateDir);
|
|
3682
3839
|
const prev = records[sid];
|
|
3683
3840
|
records[sid] = {
|
|
3684
3841
|
spec: specText,
|
|
@@ -3687,7 +3844,7 @@ export class PluginManager {
|
|
|
3687
3844
|
...(prev?.lastRun !== undefined ? { lastRun: prev.lastRun } : {}),
|
|
3688
3845
|
createdAt: prev?.createdAt ?? Date.now(),
|
|
3689
3846
|
};
|
|
3690
|
-
saveScheduleRecords(
|
|
3847
|
+
saveScheduleRecords(stateDir, records);
|
|
3691
3848
|
}
|
|
3692
3849
|
let timer;
|
|
3693
3850
|
let grace;
|
|
@@ -3747,11 +3904,11 @@ export class PluginManager {
|
|
|
3747
3904
|
if (cancelled)
|
|
3748
3905
|
return;
|
|
3749
3906
|
if (persistent) {
|
|
3750
|
-
const records = loadScheduleRecords(
|
|
3907
|
+
const records = loadScheduleRecords(stateDir);
|
|
3751
3908
|
const rec = records[sid];
|
|
3752
3909
|
if (rec) {
|
|
3753
3910
|
rec.lastRun = Date.now();
|
|
3754
|
-
saveScheduleRecords(
|
|
3911
|
+
saveScheduleRecords(stateDir, records);
|
|
3755
3912
|
}
|
|
3756
3913
|
}
|
|
3757
3914
|
try {
|
|
@@ -3787,7 +3944,7 @@ export class PluginManager {
|
|
|
3787
3944
|
timer.unref?.();
|
|
3788
3945
|
}
|
|
3789
3946
|
if (persistent && catchUp === "once") {
|
|
3790
|
-
const refTime = loadScheduleRecords(
|
|
3947
|
+
const refTime = loadScheduleRecords(stateDir)[sid]?.lastRun ?? loadScheduleRecords(stateDir)[sid]?.createdAt ?? Date.now();
|
|
3791
3948
|
const missed = parts
|
|
3792
3949
|
? (() => {
|
|
3793
3950
|
const at = nextCronFire(parts, refTime);
|
|
@@ -3814,10 +3971,10 @@ export class PluginManager {
|
|
|
3814
3971
|
cancelTimer();
|
|
3815
3972
|
bgUnreg?.();
|
|
3816
3973
|
if (persistent) {
|
|
3817
|
-
const records = loadScheduleRecords(
|
|
3974
|
+
const records = loadScheduleRecords(stateDir);
|
|
3818
3975
|
if (sid in records) {
|
|
3819
3976
|
delete records[sid];
|
|
3820
|
-
saveScheduleRecords(
|
|
3977
|
+
saveScheduleRecords(stateDir, records);
|
|
3821
3978
|
}
|
|
3822
3979
|
}
|
|
3823
3980
|
};
|
|
@@ -4159,7 +4316,7 @@ export class PluginManager {
|
|
|
4159
4316
|
settingsHandlers,
|
|
4160
4317
|
});
|
|
4161
4318
|
console.log(`[plugin:${info.id}] activated (v${info.version ?? "?"})`);
|
|
4162
|
-
void this.maybeConsentNotice(info,
|
|
4319
|
+
void this.maybeConsentNotice(info, stateDir, permsDeclared);
|
|
4163
4320
|
}
|
|
4164
4321
|
catch (err) {
|
|
4165
4322
|
const failed = effects.release();
|
|
@@ -236,28 +236,22 @@ export function makePresentFilesTool(fallbackCwd, options = {}) {
|
|
|
236
236
|
return defineTool({
|
|
237
237
|
name: PRESENT_FILES_TOOL_NAME,
|
|
238
238
|
label: "Show files to the user",
|
|
239
|
-
description: "Show files
|
|
240
|
-
"each card can open locally, reveal in file manager, download, or copy path. " +
|
|
241
|
-
"Give workspace-relative paths (max 12); `title`/`note` show above the cards, `caption` next to the name, `focus: true` opens that item immediately.",
|
|
239
|
+
description: "Show workspace files (1-12) as preview cards in chat.",
|
|
242
240
|
promptSnippet: "show a produced artifact (image/chart/report) to the user",
|
|
243
241
|
promptGuidelines: [
|
|
244
242
|
"After producing something visual or user-facing (screenshot, chart, video, report, log, build output), show it with present_files instead of only printing the path",
|
|
245
243
|
"Skip it for ordinary source edits the user did not ask to see; never call it twice for the same file in one turn",
|
|
246
244
|
],
|
|
247
245
|
parameters: Type.Object({
|
|
248
|
-
title: Type.Optional(Type.String(
|
|
249
|
-
|
|
250
|
-
})),
|
|
251
|
-
note: Type.Optional(Type.String({
|
|
252
|
-
description: "Optional one-line note above the cards (markdown).",
|
|
253
|
-
})),
|
|
246
|
+
title: Type.Optional(Type.String()),
|
|
247
|
+
note: Type.Optional(Type.String()),
|
|
254
248
|
items: Type.Array(Type.Object({
|
|
255
|
-
path: Type.String(
|
|
256
|
-
caption: Type.Optional(Type.String(
|
|
249
|
+
path: Type.String(),
|
|
250
|
+
caption: Type.Optional(Type.String()),
|
|
257
251
|
focus: Type.Optional(Type.Boolean({
|
|
258
|
-
description: "
|
|
252
|
+
description: "Open preview dialog immediately",
|
|
259
253
|
})),
|
|
260
|
-
})
|
|
254
|
+
})),
|
|
261
255
|
}),
|
|
262
256
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
263
257
|
const lang = getLang();
|
|
@@ -11,7 +11,6 @@ export const PRESET_EXCLUDED_KEYS = [
|
|
|
11
11
|
"quickAskTranslateTarget",
|
|
12
12
|
"quickAskTranslateStyle",
|
|
13
13
|
"quickAskTranslatePrompt",
|
|
14
|
-
"quickAskShowOriginal",
|
|
15
14
|
"quickAskReferenceMenus",
|
|
16
15
|
"quickAskConversationScope",
|
|
17
16
|
"quickAskFolderScope",
|
|
@@ -29,6 +28,7 @@ export const PRESET_FIELD_GROUPS = {
|
|
|
29
28
|
],
|
|
30
29
|
tools: [
|
|
31
30
|
"disabledAgentTools",
|
|
31
|
+
"toolOnDemandTools",
|
|
32
32
|
"disabledPluginTools",
|
|
33
33
|
"toolPromptOverrides",
|
|
34
34
|
"toolLazyLoading",
|
|
@@ -41,7 +41,6 @@ export const PRESET_FIELD_GROUPS = {
|
|
|
41
41
|
"questionPresentation",
|
|
42
42
|
"toolApprovalPresentation",
|
|
43
43
|
"questionTimeoutSeconds",
|
|
44
|
-
"editSoftEnabled",
|
|
45
44
|
"terminalToolsEnabled",
|
|
46
45
|
],
|
|
47
46
|
terminal: ["terminalBash", "terminalBashIdleMs", "terminalBashMaxForegroundMs"],
|
|
@@ -180,6 +179,12 @@ export const PRESET_FIELD_META = {
|
|
|
180
179
|
hintZh: "不在 AI 可用工具列表中暴露的内置工具",
|
|
181
180
|
hintEn: "Built-in tools removed from agent visibility",
|
|
182
181
|
},
|
|
182
|
+
toolOnDemandTools: {
|
|
183
|
+
labelZh: "按需工具列表",
|
|
184
|
+
labelEn: "On-Demand Tools",
|
|
185
|
+
hintZh: "延迟名单:仅按需加载开启时生效,列内工具需 load_tools 拉取",
|
|
186
|
+
hintEn: "Lazy list: only applies when lazy loading is on; listed tools need load_tools to activate",
|
|
187
|
+
},
|
|
183
188
|
disabledPluginTools: {
|
|
184
189
|
labelZh: "禁用的插件工具",
|
|
185
190
|
labelEn: "Disabled Plugin Tools",
|
|
@@ -195,8 +200,8 @@ export const PRESET_FIELD_META = {
|
|
|
195
200
|
toolLazyLoading: {
|
|
196
201
|
labelZh: "工具按需延迟加载",
|
|
197
202
|
labelEn: "Tool Lazy Loading",
|
|
198
|
-
hintZh: "
|
|
199
|
-
hintEn: "
|
|
203
|
+
hintZh: "总开关:开启才有 load_tools;仅名单里的工具延迟加载",
|
|
204
|
+
hintEn: "Master switch for load_tools; only listed tools load on demand",
|
|
200
205
|
},
|
|
201
206
|
codemodeMode: {
|
|
202
207
|
labelZh: "codemode 运行模式",
|
|
@@ -276,12 +281,6 @@ export const PRESET_FIELD_META = {
|
|
|
276
281
|
hintZh: "秒;0 为持续等待,超时不自动选择答案",
|
|
277
282
|
hintEn: "Seconds; 0 waits indefinitely, timeout never selects an answer",
|
|
278
283
|
},
|
|
279
|
-
editSoftEnabled: {
|
|
280
|
-
labelZh: "宽松缩进编辑 (edit_soft)",
|
|
281
|
-
labelEn: "Soft Indentation Edit",
|
|
282
|
-
hintZh: "提供忽略前导空白缩进差异的鲁棒编辑工具",
|
|
283
|
-
hintEn: "Provide indentation-tolerant text replacement tool",
|
|
284
|
-
},
|
|
285
284
|
terminalToolsEnabled: {
|
|
286
285
|
labelZh: "终端工具集",
|
|
287
286
|
labelEn: "Terminal Toolset",
|
|
@@ -623,6 +622,18 @@ export function formatPresetFieldValue(field, value, lang = "zh") {
|
|
|
623
622
|
].join("\n"),
|
|
624
623
|
};
|
|
625
624
|
}
|
|
625
|
+
if (field === "toolOnDemandTools") {
|
|
626
|
+
const list = Array.isArray(value) ? value.filter((x) => typeof x === "string" && Boolean(x)) : [];
|
|
627
|
+
if (list.length === 0) {
|
|
628
|
+
return { summary: isZh ? "空(无延迟加载工具)" : "Empty (nothing lazy)" };
|
|
629
|
+
}
|
|
630
|
+
return {
|
|
631
|
+
summary: isZh
|
|
632
|
+
? `延迟加载 ${list.length} 个工具(${list.join(", ")})`
|
|
633
|
+
: `${list.length} tool(s) lazy: ${list.join(", ")}`,
|
|
634
|
+
detail: list.map((item) => `- ${item}`).join("\n"),
|
|
635
|
+
};
|
|
636
|
+
}
|
|
626
637
|
if (field === "disabledPluginTools") {
|
|
627
638
|
const list = Array.isArray(value) ? value.filter((x) => typeof x === "string" && Boolean(x)) : [];
|
|
628
639
|
if (list.length === 0) {
|
|
@@ -789,8 +800,8 @@ export function formatPresetFieldValue(field, value, lang = "zh") {
|
|
|
789
800
|
return {
|
|
790
801
|
summary: value
|
|
791
802
|
? isZh
|
|
792
|
-
? "
|
|
793
|
-
: "Enabled (
|
|
803
|
+
? "开启(仅名单里的工具延迟,其余常驻)"
|
|
804
|
+
: "Enabled (only listed tools lazy, others resident)"
|
|
794
805
|
: isZh
|
|
795
806
|
? "关闭(所有工具全部直接挂载)"
|
|
796
807
|
: "Disabled (all tools loaded)",
|
|
@@ -165,6 +165,7 @@ const PRESET_FIELD_KINDS = {
|
|
|
165
165
|
reviewPrompt: "text",
|
|
166
166
|
reviewDisabledSkills: "list",
|
|
167
167
|
disabledAgentTools: "list",
|
|
168
|
+
toolOnDemandTools: "list",
|
|
168
169
|
disabledPluginTools: "list",
|
|
169
170
|
toolPromptOverrides: "toolPromptOverrides",
|
|
170
171
|
toolLazyLoading: "bool",
|
|
@@ -181,7 +182,6 @@ const PRESET_FIELD_KINDS = {
|
|
|
181
182
|
questionPresentation: "questionPresentation",
|
|
182
183
|
toolApprovalPresentation: "questionPresentation",
|
|
183
184
|
questionTimeoutSeconds: "questionTimeout",
|
|
184
|
-
editSoftEnabled: "bool",
|
|
185
185
|
terminalToolsEnabled: "bool",
|
|
186
186
|
terminalBash: "bool",
|
|
187
187
|
terminalBashIdleMs: "number",
|
|
@@ -179,6 +179,17 @@ export async function lookupProcessDetailsBatch(pids) {
|
|
|
179
179
|
catch { }
|
|
180
180
|
return out;
|
|
181
181
|
}
|
|
182
|
+
export function pidAlive(pid) {
|
|
183
|
+
if (!(pid > 1 && pid !== process.pid))
|
|
184
|
+
return false;
|
|
185
|
+
try {
|
|
186
|
+
process.kill(pid, 0);
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
182
193
|
export async function killPidTree(pid) {
|
|
183
194
|
if (!(pid > 1 && pid !== process.pid))
|
|
184
195
|
return;
|