pi-web-ui 0.119.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 +79 -0
- 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 +803 -106
- package/dist/server/atomic-file.js +130 -5
- package/dist/server/bash-timeout.js +15 -0
- package/dist/server/bash-tool.js +68 -4
- package/dist/server/bg-servers.js +19 -13
- package/dist/server/canvas/canvas-dispatch.js +12 -1
- package/dist/server/client-state.js +56 -14
- package/dist/server/conversation-tool.js +3 -2
- package/dist/server/delegate-task.js +8 -8
- package/dist/server/device-center/group-router-runtime.js +2 -0
- package/dist/server/device-center/hub-upgrade.js +5 -10
- package/dist/server/dispatch-domain-handlers.js +96 -22
- package/dist/server/dispatch-plugin-handlers.js +10 -0
- package/dist/server/dsh/dsh-agent-service.js +9 -9
- package/dist/server/durable/durable-agent-service.js +1 -1
- package/dist/server/files-service.js +41 -19
- package/dist/server/fs-copy.js +93 -0
- package/dist/server/goal-review-gate.js +2 -2
- package/dist/server/index.js +15 -0
- package/dist/server/job-runner.js +345 -0
- package/dist/server/marker-service.js +42 -26
- package/dist/server/model-session.js +16 -0
- package/dist/server/phone-tool.js +167 -0
- package/dist/server/plan-mode.js +2 -2
- package/dist/server/plugin-api-catalog.js +1 -1
- package/dist/server/plugin-bundled.js +35 -28
- package/dist/server/plugin-installer.js +15 -0
- package/dist/server/plugin-manifest-validate.js +10 -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 +74 -38
- package/dist/server/preset-fields.js +9 -9
- 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/quick-ask.js +3 -0
- package/dist/server/remote-ssh-service.js +39 -0
- 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 +39 -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 -2
- package/dist/server/subagent-settle.js +71 -0
- package/dist/server/subagents.js +497 -79
- package/dist/server/tabs.js +8 -1
- package/dist/server/terminals.js +0 -1
- package/dist/server/tool-manager.js +90 -16
- package/dist/server/tool-prompts.js +5 -1
- package/dist/server/universal/universal-service.js +1 -1
- package/dist/server/universal/universal-session.js +45 -7
- 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/docs/README.md +25 -23
- package/docs/architecture-plugins.md +23 -3
- package/docs/device-center.md +1 -1
- package/package.json +15 -3
- package/plugins/catalog.json +13 -2
- package/themes/bases/flow-base.css +7 -16
- 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-2ydYbnpW.js → CanvasStudio-BB_Iq7pl.js} +3 -3
- package/web/dist/assets/{CanvasStudio-DizWvRjn.js → CanvasStudio-DU6O3N4u.js} +3 -3
- package/web/dist/assets/DeviceCenter-By1zVTSY.js +3 -0
- package/web/dist/assets/DeviceCenter-Cnm0Tjrx.js +3 -0
- package/web/dist/assets/{DeviceExecutionSettings-B7R9ONaq.js → DeviceExecutionSettings-qJzbI0Cf.js} +1 -1
- package/web/dist/assets/{DeviceGroups-DFU4cv5b.js → DeviceGroups-DPrQxW6B.js} +1 -1
- package/web/dist/assets/{DeviceGroups-DoaQcxKj.js → DeviceGroups-DoucyUjI.js} +1 -1
- package/web/dist/assets/{Dropdown-Btjt6Dzh.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-DwZZrMuE.js → GroupConversation-1-lsPO1f.js} +3 -3
- package/web/dist/assets/{GroupConversation-KOi8sa5b.js → GroupConversation-HeiyW_O_.js} +3 -3
- package/web/dist/assets/{GroupWorkItems-FqAL74bC.js → GroupWorkItems-BYJv2XFj.js} +1 -1
- package/web/dist/assets/{HintTip-BOwPzBGR.js → HintTip-DFhoclDw.js} +1 -1
- package/web/dist/assets/{ModelConfigModal-DLIfWKdB.js → ModelConfigModal-D2Ro-jUZ.js} +2 -2
- package/web/dist/assets/{ModelConfigModal-B140kWrs.js → ModelConfigModal-DPc9R1pq.js} +2 -2
- package/web/dist/assets/{NativeCliPanel-BwiLazSq.js → NativeCliPanel-B108d697.js} +3 -3
- package/web/dist/assets/{NativeCliPanel-U0F_EfAU.js → NativeCliPanel-DupvGwQM.js} +3 -3
- package/web/dist/assets/{PiSetupModal-Dc7EQ4L3.js → PiSetupModal-D0HitBfd.js} +1 -1
- package/web/dist/assets/{ProviderOAuthControls-C3opmPhu.js → ProviderOAuthControls-BLKUEDde.js} +1 -1
- package/web/dist/assets/{SCMPanel-BBxQfmq9.js → SCMPanel-DDbWrUHR.js} +1 -1
- package/web/dist/assets/{SCMPanel-D2t97Vvr.js → SCMPanel-DluNcd2-.js} +1 -1
- 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-B6nCtO2b.js → TermXterm-SYc-MUk2.js} +1 -1
- package/web/dist/assets/{TerminalPanel-BWB3iSeN.js → TerminalPanel-CgA_lhVT.js} +1 -1
- package/web/dist/assets/{TerminalPanel-CAV2SosY.js → TerminalPanel-vdSIOPjD.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-B0jBPOMc.js → TuiOverlayModal-Cy1jYYIw.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-DGd6fzU6.js → TuiOverlayModal-kXY_4hV8.js} +1 -1
- package/web/dist/assets/{app-globals-CR8Ls9nE.js → app-globals-CBEscsYP.js} +9 -9
- package/web/dist/assets/{canvas-client-B0lkqTtF.js → canvas-client-Clsypfs6.js} +1 -1
- package/web/dist/assets/{desktop-BME3DkyE.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-CVgcdBOk.js → plugin-host-VWBcq-LQ.js} +1 -1
- 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/web/dist/assets/BgTasksModal-CVHW1lRA.js +0 -1
- package/web/dist/assets/BgTasksModal-t5hxW1H6.js +0 -1
- package/web/dist/assets/DeviceCenter-CPaZNBJE.js +0 -3
- package/web/dist/assets/DeviceCenter-DsVakAYR.js +0 -3
- package/web/dist/assets/FilePreview-QGQfD2lV.js +0 -2
- package/web/dist/assets/FilePreview-qez9walH.js +0 -2
- package/web/dist/assets/GlobalSearchModal-B-cnTDJ5.js +0 -1
- package/web/dist/assets/GlobalSearchModal-BvbafjdU.js +0 -1
- package/web/dist/assets/SettingsModal-BqPQNUwF.js +0 -34
- package/web/dist/assets/SettingsModal-l7eeV-Rq.js +0 -34
- package/web/dist/assets/index-BBAQNi6v.js +0 -404
- package/web/dist/assets/index-BYW9d61A.js +0 -404
- package/web/dist/assets/index-BYWs88H2.css +0 -1
- package/web/dist/assets/remote-ssh-client-DEpvwgqG.js +0 -1
- package/web/dist/assets/theme-DVa7Z5Zu.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,8 @@ 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";
|
|
24
26
|
import { PluginInbox } from "./plugin-inbox.js";
|
|
25
27
|
import { PluginLedgerStore } from "./plugin-ledger.js";
|
|
26
28
|
import { DeliveryQueue } from "./plugin-delivery.js";
|
|
@@ -783,9 +785,18 @@ function resolveSettingsValues(schema, stored, overlay, secrets) {
|
|
|
783
785
|
}
|
|
784
786
|
return { values, sources };
|
|
785
787
|
}
|
|
786
|
-
function
|
|
788
|
+
function readManifestVersion(manifestPath) {
|
|
787
789
|
try {
|
|
788
|
-
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"));
|
|
789
800
|
if (parsed && typeof parsed === "object" && parsed.settings && typeof parsed.settings === "object") {
|
|
790
801
|
return parsed.settings;
|
|
791
802
|
}
|
|
@@ -793,8 +804,8 @@ function readStoredSettings(dir) {
|
|
|
793
804
|
catch { }
|
|
794
805
|
return {};
|
|
795
806
|
}
|
|
796
|
-
function runtimeSettingsValues(
|
|
797
|
-
return resolveSettingsValues(schema, readStoredSettings(
|
|
807
|
+
function runtimeSettingsValues(stateDir, schema, secrets, overlay = {}) {
|
|
808
|
+
return resolveSettingsValues(schema, readStoredSettings(stateDir), overlay, { get: (k) => secrets.get(k) }).values;
|
|
798
809
|
}
|
|
799
810
|
function cleanNonSecretSettingsField(f, v, lang) {
|
|
800
811
|
if (f.type === "number") {
|
|
@@ -835,7 +846,7 @@ function cleanNonSecretSettingsField(f, v, lang) {
|
|
|
835
846
|
}
|
|
836
847
|
return { value: v === undefined ? (f.default ?? "") : String(v) };
|
|
837
848
|
}
|
|
838
|
-
function saveSettingsValues(
|
|
849
|
+
function saveSettingsValues(stateDir, schema, values, lang, secrets) {
|
|
839
850
|
const l = lang?.() ?? "en";
|
|
840
851
|
const clean = {};
|
|
841
852
|
const secretUpdates = {};
|
|
@@ -875,7 +886,7 @@ function saveSettingsValues(dir, schema, values, lang, secrets) {
|
|
|
875
886
|
for (const [k, v] of Object.entries(clean))
|
|
876
887
|
if (!secretKeys.has(k))
|
|
877
888
|
persist[k] = v;
|
|
878
|
-
const file = join(
|
|
889
|
+
const file = join(stateDir, "storage.json");
|
|
879
890
|
withFileRmwLockSync(file, () => {
|
|
880
891
|
if (secrets)
|
|
881
892
|
secrets.commitSettings(persist, secretUpdates);
|
|
@@ -896,7 +907,7 @@ function saveSettingsValues(dir, schema, values, lang, secrets) {
|
|
|
896
907
|
});
|
|
897
908
|
}
|
|
898
909
|
catch (err) {
|
|
899
|
-
console.error(`[plugins] settings persist failed (${
|
|
910
|
+
console.error(`[plugins] settings persist failed (${stateDir}):`, err);
|
|
900
911
|
return { error: err.message, clean };
|
|
901
912
|
}
|
|
902
913
|
return { clean };
|
|
@@ -1042,7 +1053,7 @@ export class PluginManager {
|
|
|
1042
1053
|
const l = lang?.() ?? "en";
|
|
1043
1054
|
if (!ID_RE.test(pluginId))
|
|
1044
1055
|
return { error: pick(l, "非法的插件 id", "Invalid plugin id", "plugins.id.invalid") };
|
|
1045
|
-
const
|
|
1056
|
+
const stateDir = pluginStateDir(this.dataDir, pluginId);
|
|
1046
1057
|
const info = this.loaded.get(pluginId)?.info;
|
|
1047
1058
|
const schema = info?.settingsSchema ?? [];
|
|
1048
1059
|
if (!schema.length)
|
|
@@ -1051,7 +1062,7 @@ export class PluginManager {
|
|
|
1051
1062
|
};
|
|
1052
1063
|
let result;
|
|
1053
1064
|
try {
|
|
1054
|
-
result = saveSettingsValues(
|
|
1065
|
+
result = saveSettingsValues(stateDir, schema, values, lang, new PluginSecrets(this.dataDir, stateDir));
|
|
1055
1066
|
}
|
|
1056
1067
|
catch (err) {
|
|
1057
1068
|
return { error: err.message };
|
|
@@ -1172,9 +1183,9 @@ export class PluginManager {
|
|
|
1172
1183
|
}
|
|
1173
1184
|
}
|
|
1174
1185
|
}
|
|
1175
|
-
async maybeConsentNotice(info,
|
|
1186
|
+
async maybeConsentNotice(info, stateDir, perms) {
|
|
1176
1187
|
try {
|
|
1177
|
-
const markerFile = join(
|
|
1188
|
+
const markerFile = join(stateDir, ".pi-approved");
|
|
1178
1189
|
const key = createHash("sha256").update(JSON.stringify(perms)).digest("hex").slice(0, 32);
|
|
1179
1190
|
let prev = "";
|
|
1180
1191
|
try {
|
|
@@ -1185,7 +1196,8 @@ export class PluginManager {
|
|
|
1185
1196
|
return;
|
|
1186
1197
|
const list = perms.length ? perms.join(", ") : "无";
|
|
1187
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`);
|
|
1188
|
-
|
|
1199
|
+
// 状态目录可能还没建(新装/刚迁移),原子写自带 mkdir;直接 writeFileSync 会 ENOENT 且每次都重报
|
|
1200
|
+
writeJsonAtomicSync(markerFile, { v: 1, key, perms });
|
|
1189
1201
|
}
|
|
1190
1202
|
catch (err) {
|
|
1191
1203
|
console.error(`[plugin:${info.id}] consent notice failed:`, err);
|
|
@@ -2259,9 +2271,17 @@ export class PluginManager {
|
|
|
2259
2271
|
catch { }
|
|
2260
2272
|
}
|
|
2261
2273
|
try {
|
|
2262
|
-
prepareBundledPlugins(this.dataDir, this.builtinCatalogPath, new Set(this.catalog()
|
|
2274
|
+
const outcomes = prepareBundledPlugins(this.dataDir, this.builtinCatalogPath, new Set(this.catalog()
|
|
2263
2275
|
.filter((entry) => entry.origin === "custom")
|
|
2264
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
|
+
}
|
|
2265
2285
|
}
|
|
2266
2286
|
catch (err) {
|
|
2267
2287
|
console.warn("[plugins] Preparing bundled modules failed:", err);
|
|
@@ -2294,22 +2314,31 @@ export class PluginManager {
|
|
|
2294
2314
|
catch { }
|
|
2295
2315
|
const targetManifest = join(targetDir, "manifest.json");
|
|
2296
2316
|
const sourceManifest = join(sourceDir, "manifest.json");
|
|
2297
|
-
if (!existsSync(sourceDir) || !existsSync(sourceManifest)
|
|
2317
|
+
if (!existsSync(sourceDir) || !existsSync(sourceManifest))
|
|
2298
2318
|
continue;
|
|
2299
|
-
}
|
|
2300
2319
|
try {
|
|
2301
2320
|
const srcRaw = JSON.parse(readFileSync(sourceManifest, "utf8"));
|
|
2302
|
-
const tgtRaw = JSON.parse(readFileSync(targetManifest, "utf8"));
|
|
2303
2321
|
const srcVer = typeof srcRaw.version === "string" ? srcRaw.version.trim() : "";
|
|
2304
|
-
const tgtVer =
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
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") {
|
|
2311
2337
|
console.log(`[plugins] 内置插件 ${name} 随宿主自动同步升级:${tgtVer} → ${srcVer}`);
|
|
2312
2338
|
}
|
|
2339
|
+
else if (outcome.status === "repaired") {
|
|
2340
|
+
console.log(`[plugins] 内置插件 ${name} 重新物化(缺回执或文件不全)→ ${outcome.files} 个文件`);
|
|
2341
|
+
}
|
|
2313
2342
|
}
|
|
2314
2343
|
catch (err) {
|
|
2315
2344
|
console.warn(`[plugins] 自动同步内置插件 ${name} 失败:`, err);
|
|
@@ -2333,7 +2362,7 @@ export class PluginManager {
|
|
|
2333
2362
|
for (const name of names.sort()) {
|
|
2334
2363
|
if (!ID_RE.test(name))
|
|
2335
2364
|
continue;
|
|
2336
|
-
const dir =
|
|
2365
|
+
const dir = pluginCodeDir(this.dataDir, name);
|
|
2337
2366
|
try {
|
|
2338
2367
|
const st = await stat(dir);
|
|
2339
2368
|
if (generation !== this.lifecycleGeneration)
|
|
@@ -2344,6 +2373,11 @@ export class PluginManager {
|
|
|
2344
2373
|
catch {
|
|
2345
2374
|
continue;
|
|
2346
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
|
+
}
|
|
2347
2381
|
try {
|
|
2348
2382
|
const raw = await readFile(join(dir, "manifest.json"), "utf8");
|
|
2349
2383
|
if (generation !== this.lifecycleGeneration)
|
|
@@ -2385,7 +2419,7 @@ export class PluginManager {
|
|
|
2385
2419
|
const overlayForScan = cleanOverlaySettings(settingsSchemaForScan, overlayFileForScan.raw, "en");
|
|
2386
2420
|
for (const w of [...overlayFileForScan.warnings, ...overlayForScan.warnings])
|
|
2387
2421
|
uiDiags.push(`override: ${w}`);
|
|
2388
|
-
const resolvedSettingsForScan = resolveSettingsValues(settingsSchemaForScan, readStoredSettings(
|
|
2422
|
+
const resolvedSettingsForScan = resolveSettingsValues(settingsSchemaForScan, readStoredSettings(stateDir), overlayForScan.values, { has: (k) => new PluginSecrets(this.dataDir, stateDir).has(k) });
|
|
2389
2423
|
const hasClient = existsSync(join(dir, "client", "entry.mjs"));
|
|
2390
2424
|
out.push({
|
|
2391
2425
|
id: name,
|
|
@@ -2615,7 +2649,9 @@ export class PluginManager {
|
|
|
2615
2649
|
async activate(info, lang) {
|
|
2616
2650
|
const l = lang?.() ?? "en";
|
|
2617
2651
|
this.attempted.add(info.id);
|
|
2618
|
-
const dir =
|
|
2652
|
+
const dir = pluginCodeDir(this.dataDir, info.id);
|
|
2653
|
+
const stateDir = pluginStateDir(this.dataDir, info.id);
|
|
2654
|
+
migratePluginState(this.dataDir, info.id);
|
|
2619
2655
|
try {
|
|
2620
2656
|
const rawManifest = readFileSync(join(dir, "manifest.json"), "utf8");
|
|
2621
2657
|
const parsedManifest = JSON.parse(rawManifest);
|
|
@@ -2784,8 +2820,8 @@ export class PluginManager {
|
|
|
2784
2820
|
}
|
|
2785
2821
|
}
|
|
2786
2822
|
const netAllow = info.netAllowlist ?? [];
|
|
2787
|
-
const storage = new PluginStorage(join(
|
|
2788
|
-
const secrets = new PluginSecrets(this.dataDir,
|
|
2823
|
+
const storage = new PluginStorage(join(stateDir, "storage.json"));
|
|
2824
|
+
const secrets = new PluginSecrets(this.dataDir, stateDir);
|
|
2789
2825
|
const workspaceFs = new WorkspaceFS(() => self.cwdValue);
|
|
2790
2826
|
const allowAbs = (p) => {
|
|
2791
2827
|
const abs = normalizeGrantPath(p);
|
|
@@ -3688,7 +3724,7 @@ export class PluginManager {
|
|
|
3688
3724
|
const schema = info.settingsSchema ?? [];
|
|
3689
3725
|
const overlayFile = readSettingsOverlayFile(self.dataDir, info.id);
|
|
3690
3726
|
const overlay = cleanOverlaySettings(schema, overlayFile.raw, "en");
|
|
3691
|
-
return runtimeSettingsValues(
|
|
3727
|
+
return runtimeSettingsValues(stateDir, schema, secrets, overlay.values);
|
|
3692
3728
|
},
|
|
3693
3729
|
onSettingsChanged: (h) => {
|
|
3694
3730
|
settingsHandlers.add(h);
|
|
@@ -3799,7 +3835,7 @@ export class PluginManager {
|
|
|
3799
3835
|
: "";
|
|
3800
3836
|
if (!sid || !ID_RE.test(sid))
|
|
3801
3837
|
throw new Error("schedule: persistent 任务必须给合法 id(字母/数字/下划线/连字符),重启后靠它重建");
|
|
3802
|
-
const records = loadScheduleRecords(
|
|
3838
|
+
const records = loadScheduleRecords(stateDir);
|
|
3803
3839
|
const prev = records[sid];
|
|
3804
3840
|
records[sid] = {
|
|
3805
3841
|
spec: specText,
|
|
@@ -3808,7 +3844,7 @@ export class PluginManager {
|
|
|
3808
3844
|
...(prev?.lastRun !== undefined ? { lastRun: prev.lastRun } : {}),
|
|
3809
3845
|
createdAt: prev?.createdAt ?? Date.now(),
|
|
3810
3846
|
};
|
|
3811
|
-
saveScheduleRecords(
|
|
3847
|
+
saveScheduleRecords(stateDir, records);
|
|
3812
3848
|
}
|
|
3813
3849
|
let timer;
|
|
3814
3850
|
let grace;
|
|
@@ -3868,11 +3904,11 @@ export class PluginManager {
|
|
|
3868
3904
|
if (cancelled)
|
|
3869
3905
|
return;
|
|
3870
3906
|
if (persistent) {
|
|
3871
|
-
const records = loadScheduleRecords(
|
|
3907
|
+
const records = loadScheduleRecords(stateDir);
|
|
3872
3908
|
const rec = records[sid];
|
|
3873
3909
|
if (rec) {
|
|
3874
3910
|
rec.lastRun = Date.now();
|
|
3875
|
-
saveScheduleRecords(
|
|
3911
|
+
saveScheduleRecords(stateDir, records);
|
|
3876
3912
|
}
|
|
3877
3913
|
}
|
|
3878
3914
|
try {
|
|
@@ -3908,7 +3944,7 @@ export class PluginManager {
|
|
|
3908
3944
|
timer.unref?.();
|
|
3909
3945
|
}
|
|
3910
3946
|
if (persistent && catchUp === "once") {
|
|
3911
|
-
const refTime = loadScheduleRecords(
|
|
3947
|
+
const refTime = loadScheduleRecords(stateDir)[sid]?.lastRun ?? loadScheduleRecords(stateDir)[sid]?.createdAt ?? Date.now();
|
|
3912
3948
|
const missed = parts
|
|
3913
3949
|
? (() => {
|
|
3914
3950
|
const at = nextCronFire(parts, refTime);
|
|
@@ -3935,10 +3971,10 @@ export class PluginManager {
|
|
|
3935
3971
|
cancelTimer();
|
|
3936
3972
|
bgUnreg?.();
|
|
3937
3973
|
if (persistent) {
|
|
3938
|
-
const records = loadScheduleRecords(
|
|
3974
|
+
const records = loadScheduleRecords(stateDir);
|
|
3939
3975
|
if (sid in records) {
|
|
3940
3976
|
delete records[sid];
|
|
3941
|
-
saveScheduleRecords(
|
|
3977
|
+
saveScheduleRecords(stateDir, records);
|
|
3942
3978
|
}
|
|
3943
3979
|
}
|
|
3944
3980
|
};
|
|
@@ -4280,7 +4316,7 @@ export class PluginManager {
|
|
|
4280
4316
|
settingsHandlers,
|
|
4281
4317
|
});
|
|
4282
4318
|
console.log(`[plugin:${info.id}] activated (v${info.version ?? "?"})`);
|
|
4283
|
-
void this.maybeConsentNotice(info,
|
|
4319
|
+
void this.maybeConsentNotice(info, stateDir, permsDeclared);
|
|
4284
4320
|
}
|
|
4285
4321
|
catch (err) {
|
|
4286
4322
|
const failed = effects.release();
|
|
@@ -182,8 +182,8 @@ export const PRESET_FIELD_META = {
|
|
|
182
182
|
toolOnDemandTools: {
|
|
183
183
|
labelZh: "按需工具列表",
|
|
184
184
|
labelEn: "On-Demand Tools",
|
|
185
|
-
hintZh: "
|
|
186
|
-
hintEn: "
|
|
185
|
+
hintZh: "延迟名单:仅按需加载开启时生效,列内工具需 load_tools 拉取",
|
|
186
|
+
hintEn: "Lazy list: only applies when lazy loading is on; listed tools need load_tools to activate",
|
|
187
187
|
},
|
|
188
188
|
disabledPluginTools: {
|
|
189
189
|
labelZh: "禁用的插件工具",
|
|
@@ -200,8 +200,8 @@ export const PRESET_FIELD_META = {
|
|
|
200
200
|
toolLazyLoading: {
|
|
201
201
|
labelZh: "工具按需延迟加载",
|
|
202
202
|
labelEn: "Tool Lazy Loading",
|
|
203
|
-
hintZh: "
|
|
204
|
-
hintEn: "
|
|
203
|
+
hintZh: "总开关:开启才有 load_tools;仅名单里的工具延迟加载",
|
|
204
|
+
hintEn: "Master switch for load_tools; only listed tools load on demand",
|
|
205
205
|
},
|
|
206
206
|
codemodeMode: {
|
|
207
207
|
labelZh: "codemode 运行模式",
|
|
@@ -625,12 +625,12 @@ export function formatPresetFieldValue(field, value, lang = "zh") {
|
|
|
625
625
|
if (field === "toolOnDemandTools") {
|
|
626
626
|
const list = Array.isArray(value) ? value.filter((x) => typeof x === "string" && Boolean(x)) : [];
|
|
627
627
|
if (list.length === 0) {
|
|
628
|
-
return { summary: isZh ? "
|
|
628
|
+
return { summary: isZh ? "空(无延迟加载工具)" : "Empty (nothing lazy)" };
|
|
629
629
|
}
|
|
630
630
|
return {
|
|
631
631
|
summary: isZh
|
|
632
|
-
?
|
|
633
|
-
: `${list.length} tool(s)
|
|
632
|
+
? `延迟加载 ${list.length} 个工具(${list.join(", ")})`
|
|
633
|
+
: `${list.length} tool(s) lazy: ${list.join(", ")}`,
|
|
634
634
|
detail: list.map((item) => `- ${item}`).join("\n"),
|
|
635
635
|
};
|
|
636
636
|
}
|
|
@@ -800,8 +800,8 @@ export function formatPresetFieldValue(field, value, lang = "zh") {
|
|
|
800
800
|
return {
|
|
801
801
|
summary: value
|
|
802
802
|
? isZh
|
|
803
|
-
? "
|
|
804
|
-
: "Enabled (
|
|
803
|
+
? "开启(仅名单里的工具延迟,其余常驻)"
|
|
804
|
+
: "Enabled (only listed tools lazy, others resident)"
|
|
805
805
|
: isZh
|
|
806
806
|
? "关闭(所有工具全部直接挂载)"
|
|
807
807
|
: "Disabled (all tools loaded)",
|
|
@@ -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;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
const MAX_PKG_BYTES = 512 * 1024;
|
|
4
|
+
function readScripts(pkgPath) {
|
|
5
|
+
try {
|
|
6
|
+
if (!existsSync(pkgPath) || statSync(pkgPath).size > MAX_PKG_BYTES)
|
|
7
|
+
return undefined;
|
|
8
|
+
const raw = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
9
|
+
if (!raw || typeof raw !== "object" || !raw.scripts || typeof raw.scripts !== "object")
|
|
10
|
+
return undefined;
|
|
11
|
+
const out = {};
|
|
12
|
+
for (const [k, v] of Object.entries(raw.scripts)) {
|
|
13
|
+
if (typeof v === "string" && v.trim())
|
|
14
|
+
out[k] = v.trim().slice(0, 500);
|
|
15
|
+
if (Object.keys(out).length >= 60)
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** 从 cwd 就近向上找 package.json(含 scripts 的那一层),找不到返回 cwd 本身 + 空表。 */
|
|
25
|
+
export function resolveProjectScripts(cwd) {
|
|
26
|
+
const start = resolve(cwd || process.cwd());
|
|
27
|
+
let cur = start;
|
|
28
|
+
while (cur) {
|
|
29
|
+
const scripts = readScripts(join(cur, "package.json"));
|
|
30
|
+
if (scripts)
|
|
31
|
+
return { cwd: cur, scripts };
|
|
32
|
+
const parent = dirname(cur);
|
|
33
|
+
if (parent === cur)
|
|
34
|
+
break;
|
|
35
|
+
cur = parent;
|
|
36
|
+
}
|
|
37
|
+
return { cwd: start, scripts: {} };
|
|
38
|
+
}
|
|
@@ -5,8 +5,6 @@ export const PROMPT_TOKENS = [
|
|
|
5
5
|
"guidelines",
|
|
6
6
|
"pi_docs",
|
|
7
7
|
"append",
|
|
8
|
-
"persona",
|
|
9
|
-
"terminal",
|
|
10
8
|
"markers",
|
|
11
9
|
"plugin_dev",
|
|
12
10
|
"context",
|
|
@@ -17,8 +15,6 @@ export const READONLY_PROMPT_SOURCES = [
|
|
|
17
15
|
"tools",
|
|
18
16
|
"pi_docs",
|
|
19
17
|
"plugin_dev",
|
|
20
|
-
"persona",
|
|
21
|
-
"terminal",
|
|
22
18
|
"markers",
|
|
23
19
|
"context",
|
|
24
20
|
"skills",
|
|
@@ -28,6 +24,17 @@ export const DEFAULT_PROMPT_DISABLED = ["plugin_dev"];
|
|
|
28
24
|
export function isReadonlyPromptSource(token) {
|
|
29
25
|
return READONLY_PROMPT_SOURCES.includes(token);
|
|
30
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* 已下线的历史来源:`{{terminal}}`(终端工具引导)、`{{persona}}`(Windows 约束)。
|
|
29
|
+
* 老模板/老预设里残留该 token 时渲染为空——不留 `{{terminal}}` / `{{persona}}` 字面量,也不复活该段文本。
|
|
30
|
+
*
|
|
31
|
+
* `{{persona}}` 下线理由:Windows / 远程工作区约束由宿主在 append 段无条件注入(`WINDOWS_PERSONA`),
|
|
32
|
+
* 再挂一个可开关 token 只会让同一段文字注入两遍;设置面板也不该让用户去「启用」平台安全约束。
|
|
33
|
+
*/
|
|
34
|
+
export const LEGACY_PROMPT_TOKENS = ["terminal", "persona"];
|
|
35
|
+
export function isLegacyPromptToken(token) {
|
|
36
|
+
return LEGACY_PROMPT_TOKENS.includes(token);
|
|
37
|
+
}
|
|
31
38
|
export const DEFAULT_PROMPT_TEMPLATE = PROMPT_TOKENS.map((t) => `{{${t}}}`).join("\n\n");
|
|
32
39
|
const TOKEN_RE = /\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;
|
|
33
40
|
export function collectTemplateTokens(template) {
|
|
@@ -197,25 +204,37 @@ function buildContextText(files, lang = "en") {
|
|
|
197
204
|
"</project_context>",
|
|
198
205
|
].join("\n");
|
|
199
206
|
}
|
|
200
|
-
|
|
207
|
+
const TOOLS_TAIL = "In addition to the tools above, you may have access to other custom tools depending on the project.";
|
|
208
|
+
function buildToolsText(inputs) {
|
|
201
209
|
const listed = inputs.catalogTools ?? inputs.selectedTools;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
210
|
+
if (inputs.lazy) {
|
|
211
|
+
// 按需目录:只列名单工具(常驻工具 schema 已全量下发,不重复列)。
|
|
212
|
+
// 名单为空 = 没有任何工具可加载,整段(目录 + load_tools 说明 + 尾巴)都不输出。
|
|
213
|
+
if (listed.length === 0)
|
|
214
|
+
return "";
|
|
215
|
+
const onDemandList = listed
|
|
207
216
|
.map((n) => {
|
|
208
217
|
const sig = inputs.toolSignatures?.[n] ? ` ${inputs.toolSignatures[n]}` : "";
|
|
209
|
-
|
|
218
|
+
const snippet = inputs.toolSnippets[n];
|
|
219
|
+
return `- ${n}:${sig}${snippet ? ` ${snippet}` : ""}`;
|
|
210
220
|
})
|
|
211
|
-
.join("\n")
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
221
|
+
.join("\n");
|
|
222
|
+
// 纯英文精简:工具段不进双语(与工具提示词口径一致)。
|
|
223
|
+
return [
|
|
224
|
+
`On-demand tools (schema not attached — call \`load_tools\` with the names first):\n${onDemandList}`,
|
|
225
|
+
TOOLS_TAIL,
|
|
226
|
+
].join("\n\n");
|
|
216
227
|
}
|
|
217
|
-
|
|
218
|
-
|
|
228
|
+
const visible = listed.filter((n) => !!inputs.toolSnippets[n]);
|
|
229
|
+
if (visible.length === 0)
|
|
230
|
+
return "";
|
|
231
|
+
const toolsList = visible
|
|
232
|
+
.map((n) => {
|
|
233
|
+
const sig = inputs.toolSignatures?.[n] ? ` ${inputs.toolSignatures[n]}` : "";
|
|
234
|
+
return `- ${n}:${sig} ${inputs.toolSnippets[n]}`;
|
|
235
|
+
})
|
|
236
|
+
.join("\n");
|
|
237
|
+
return [`Available tools:\n${toolsList}`, TOOLS_TAIL].join("\n\n");
|
|
219
238
|
}
|
|
220
239
|
export function buildToolsSchemaText(tools) {
|
|
221
240
|
if (tools.length === 0)
|
|
@@ -242,12 +261,10 @@ export function resolveSectionTexts(inputs) {
|
|
|
242
261
|
soul = `${soul}\nBe concise in your responses\nShow file paths clearly when working with files`;
|
|
243
262
|
return {
|
|
244
263
|
soul,
|
|
245
|
-
tools: buildToolsText(inputs
|
|
264
|
+
tools: buildToolsText(inputs),
|
|
246
265
|
guidelines: buildGuidelinesText(inputs),
|
|
247
266
|
pi_docs: buildPiDocsText(inputs.piReadme, inputs.piDocs, inputs.piExamples, lang),
|
|
248
267
|
append: inputs.appendFiles.join("\n\n"),
|
|
249
|
-
persona: inputs.windowsPersona,
|
|
250
|
-
terminal: inputs.terminalGuidance,
|
|
251
268
|
markers: inputs.markersGuidance,
|
|
252
269
|
plugin_dev: buildPluginDevText(inputs, lang),
|
|
253
270
|
context: buildContextText(inputs.contextFiles, lang),
|
|
@@ -264,6 +281,8 @@ export function renderPromptTemplate(template, texts, overrides, disabled) {
|
|
|
264
281
|
return effectiveTemplate(template).replace(TOKEN_RE, (full, name) => {
|
|
265
282
|
if (dis.has(name))
|
|
266
283
|
return "";
|
|
284
|
+
if (isLegacyPromptToken(name))
|
|
285
|
+
return "";
|
|
267
286
|
const ov = overrideOf(overrides, name);
|
|
268
287
|
if (ov)
|
|
269
288
|
return ov;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PROTOCOL_VERSION =
|
|
1
|
+
export const PROTOCOL_VERSION = 55;
|
package/dist/server/quick-ask.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { isQuickAskModel, normalizeQuickAskSettings } from "./quick-ask-settings.js";
|
|
4
|
+
import { modelSessionId } from "./model-session.js";
|
|
4
5
|
import { MAX_QUICK_ASK_ATTACHMENTS, MAX_QUICK_ASK_TOTAL_IMAGE_BYTES, QuickAskError, parseQuickAskAttachment, quickAskAttachmentText, parseQuickAskContextRequest, resolveQuickAskContext, QUICK_ASK_CONTEXT_TIMEOUT_MS, } from "./quick-ask-context.js";
|
|
5
6
|
export const MAX_QUICK_ASK_TEXT_LENGTH = 65_536;
|
|
6
7
|
export const MAX_QUICK_ASK_MESSAGES = 100;
|
|
@@ -106,6 +107,8 @@ async function complete(request, settings, runtime, signal, emit) {
|
|
|
106
107
|
...(settings.quickAskThinking !== "off" ? { reasoning: settings.quickAskThinking } : {}),
|
|
107
108
|
signal,
|
|
108
109
|
maxTokens: 4096,
|
|
110
|
+
// Keep one provider session per popup topic: relay gateways reject requests without it.
|
|
111
|
+
sessionId: modelSessionId(request.messages[0]?.content),
|
|
109
112
|
};
|
|
110
113
|
let result;
|
|
111
114
|
if (emit) {
|
|
@@ -285,6 +285,7 @@ export class RemoteSshService {
|
|
|
285
285
|
hostConnections = new Map();
|
|
286
286
|
inflightConnects = new Map();
|
|
287
287
|
credentialCache = new Map();
|
|
288
|
+
pendingHostKeys = new Map();
|
|
288
289
|
secretKey = null;
|
|
289
290
|
constructor(dataDir) {
|
|
290
291
|
this.dataDir = dataDir;
|
|
@@ -730,9 +731,20 @@ export class RemoteSshService {
|
|
|
730
731
|
conn = this.registerConnection(client, hydrated);
|
|
731
732
|
}
|
|
732
733
|
catch (err) {
|
|
734
|
+
const anyErr = err;
|
|
735
|
+
const hostKey = err.hostKey;
|
|
736
|
+
if (anyErr.hostTrust && Buffer.isBuffer(hostKey)) {
|
|
737
|
+
if (!this.pendingHostKeys)
|
|
738
|
+
this.pendingHostKeys = new Map();
|
|
739
|
+
this.pendingHostKeys.set(`${anyErr.hostTrust.host.toLowerCase()}:${anyErr.hostTrust.port}`, {
|
|
740
|
+
key: Buffer.from(hostKey),
|
|
741
|
+
fingerprint: anyErr.hostTrust.fingerprint,
|
|
742
|
+
});
|
|
743
|
+
}
|
|
733
744
|
return {
|
|
734
745
|
ok: false,
|
|
735
746
|
error: err.message || String(err),
|
|
747
|
+
hostTrust: anyErr.hostTrust,
|
|
736
748
|
};
|
|
737
749
|
}
|
|
738
750
|
}
|
|
@@ -783,6 +795,33 @@ done
|
|
|
783
795
|
};
|
|
784
796
|
}
|
|
785
797
|
}
|
|
798
|
+
async trustHostKey(params) {
|
|
799
|
+
try {
|
|
800
|
+
const pending = this.pendingHostKeys?.get(`${params.host.toLowerCase()}:${params.port}`);
|
|
801
|
+
if (!pending || pending.fingerprint !== params.fingerprint) {
|
|
802
|
+
return {
|
|
803
|
+
ok: false,
|
|
804
|
+
error: "主机密钥已过期,请重新连接获取最新指纹后再确认 / Host key expired; reconnect first",
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
const packageRoot = resolveDefaultPkgRoot();
|
|
808
|
+
if (!packageRoot)
|
|
809
|
+
throw new Error("Cannot locate SSH host verification module");
|
|
810
|
+
const { saveTrustedHostKey } = await import(pathToFileURL(path.join(packageRoot, "plugin-sdk", "ssh-host-trust.mjs")).href);
|
|
811
|
+
await saveTrustedHostKey({
|
|
812
|
+
host: params.host,
|
|
813
|
+
port: params.port,
|
|
814
|
+
key: pending.key,
|
|
815
|
+
fingerprint: pending.fingerprint,
|
|
816
|
+
replace: params.replace,
|
|
817
|
+
});
|
|
818
|
+
this.pendingHostKeys?.delete(`${params.host.toLowerCase()}:${params.port}`);
|
|
819
|
+
return { ok: true };
|
|
820
|
+
}
|
|
821
|
+
catch (err) {
|
|
822
|
+
return { ok: false, error: err.message || String(err) };
|
|
823
|
+
}
|
|
824
|
+
}
|
|
786
825
|
parseProbeOutput(raw) {
|
|
787
826
|
const lines = raw.split(/\r?\n/).map((l) => l.trim());
|
|
788
827
|
const sections = {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isNotRepoError, scmCommitContext } from "./scm.js";
|
|
2
2
|
import { pick } from "./i18n.js";
|
|
3
|
+
import { modelSessionId } from "./model-session.js";
|
|
3
4
|
export const SCM_COMMITMSG_TIMEOUT_MS = 60_000;
|
|
4
5
|
export const MAX_COMMITMSG_LEN = 200;
|
|
5
6
|
const MAX_FILE_LINES = 200;
|
|
@@ -118,7 +119,7 @@ export async function generateScmCommitMessage(opts) {
|
|
|
118
119
|
content: [{ type: "text", text: input }],
|
|
119
120
|
},
|
|
120
121
|
],
|
|
121
|
-
}, { signal: ac.signal, maxTokens: 400 });
|
|
122
|
+
}, { signal: ac.signal, maxTokens: 400, sessionId: modelSessionId() });
|
|
122
123
|
}
|
|
123
124
|
finally {
|
|
124
125
|
clearTimeout(timer);
|
package/dist/server/serialize.js
CHANGED
|
@@ -227,6 +227,9 @@ function serializeAssistantMessage(m, id, streaming = false) {
|
|
|
227
227
|
role: "assistant",
|
|
228
228
|
content: serializeAssistantContent(m.content, streaming),
|
|
229
229
|
timestamp: m.timestamp,
|
|
230
|
+
...(typeof m.durationMs === "number" && Number.isFinite(m.durationMs) && m.durationMs >= 0
|
|
231
|
+
? { durationMs: Math.round(m.durationMs) }
|
|
232
|
+
: {}),
|
|
230
233
|
model: m.model,
|
|
231
234
|
provider: m.provider,
|
|
232
235
|
usageCost: typeof m.usage?.cost?.total === "number" ? m.usage.cost.total : undefined,
|
|
@@ -320,6 +323,11 @@ export function serializeMessage(m, seq) {
|
|
|
320
323
|
toolName: m.toolName,
|
|
321
324
|
isError: m.isError,
|
|
322
325
|
timestamp: m.timestamp,
|
|
326
|
+
...(typeof m.durationMs === "number" &&
|
|
327
|
+
Number.isFinite(m.durationMs) &&
|
|
328
|
+
m.durationMs >= 0
|
|
329
|
+
? { durationMs: Math.round(m.durationMs) }
|
|
330
|
+
: {}),
|
|
323
331
|
};
|
|
324
332
|
if (m.details !== undefined) {
|
|
325
333
|
try {
|