pi-web-ui 0.114.3 → 0.116.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -1
- package/bin/pi-web-ui.mjs +90 -8
- package/dist/gh-comment-781.md +5 -0
- package/dist/server/agent-service-daemon.js +522 -32
- package/dist/server/agent-service.js +954 -402
- package/dist/server/canvas/canvas-dispatch.js +13 -1
- package/dist/server/client-state.js +42 -2
- package/dist/server/communicate-tool.js +2 -0
- package/dist/server/conversation-communication.js +14 -0
- package/dist/server/conversation-identity.js +27 -0
- package/dist/server/device-center/approval-summary.js +31 -0
- package/dist/server/device-center/bot-catalog.js +21 -7
- package/dist/server/device-center/bot-execution.js +100 -9
- package/dist/server/device-center/bot-presets.js +46 -0
- package/dist/server/device-center/collab-service.js +362 -13
- package/dist/server/device-center/collab-tool.js +824 -13
- package/dist/server/device-center/connector.js +359 -23
- package/dist/server/device-center/desktop-page.js +22 -16
- package/dist/server/device-center/device-integration.js +595 -0
- package/dist/server/device-center/execution-guides.js +32 -0
- package/dist/server/device-center/execution-instructions.js +20 -0
- package/dist/server/device-center/execution-settings.js +213 -0
- package/dist/server/device-center/execution-system-prompt.js +38 -0
- package/dist/server/device-center/execution-workspace.js +20 -0
- package/dist/server/device-center/executor.js +392 -40
- package/dist/server/device-center/file-sync-paths.js +171 -0
- package/dist/server/device-center/file-sync.js +186 -96
- package/dist/server/device-center/group-context-delta.js +37 -0
- package/dist/server/device-center/group-context-message.js +210 -0
- package/dist/server/device-center/group-context.js +179 -0
- package/dist/server/device-center/group-events.js +136 -0
- package/dist/server/device-center/group-plan-guard.js +138 -0
- package/dist/server/device-center/hub-conversations.js +233 -0
- package/dist/server/device-center/hub-deliveries.js +277 -0
- package/dist/server/device-center/hub-integration.js +451 -0
- package/dist/server/device-center/hub-locks.js +320 -0
- package/dist/server/device-center/hub-page.js +13 -33
- package/dist/server/device-center/hub-webhooks.js +165 -0
- package/dist/server/device-center/hub.js +2379 -107
- package/dist/server/device-center/human-interaction.js +232 -0
- package/dist/server/device-center/integration-errors.js +25 -0
- package/dist/server/device-center/local-hub.js +20 -1
- package/dist/server/device-center/local-page.js +17 -0
- package/dist/server/device-center/local.js +430 -41
- package/dist/server/device-center/main.js +11 -1
- package/dist/server/device-center/partition-log.js +293 -0
- package/dist/server/device-center/path-portal.js +11 -3
- package/dist/server/device-center/relay.js +364 -35
- package/dist/server/device-center/report-metadata.js +66 -0
- package/dist/server/device-center/report-upload.js +63 -0
- package/dist/server/device-center/runtime.js +598 -41
- package/dist/server/device-center/smoke-preview.js +3 -0
- package/dist/server/device-center/store.js +203 -41
- package/dist/server/device-center/task-context-budget.js +161 -0
- package/dist/server/device-center/task-journal.js +385 -0
- package/dist/server/device-center/task-plan.js +33 -0
- package/dist/server/device-center/task-progress.js +141 -0
- package/dist/server/device-center/task-recovery.js +452 -0
- package/dist/server/device-center/task-report-outbox.js +216 -0
- package/dist/server/device-center/task-report.js +384 -0
- package/dist/server/device-center/task-scheduler.js +445 -0
- package/dist/server/device-center/task-state.js +333 -0
- package/dist/server/device-center/transfer-stream.js +1006 -0
- package/dist/server/device-center/transfers.js +841 -8
- package/dist/server/dispatch-domain-handlers.js +35 -6
- package/dist/server/dsh/dsh-agent-service.js +6 -0
- package/dist/server/durable/durable-capabilities.js +11 -0
- package/dist/server/engine-probe.js +112 -1
- package/dist/server/global-loader.js +119 -19
- package/dist/server/goal-service.js +10 -5
- package/dist/server/index.js +222 -29
- package/dist/server/managed.js +2 -0
- package/dist/server/markers/builtins/services.js +123 -0
- package/dist/server/markers/builtins/todo.js +189 -0
- package/dist/server/markers-list-tool.js +34 -0
- package/dist/server/message-deletion.js +40 -0
- package/dist/server/message-window.js +9 -0
- package/dist/server/model-admin.js +48 -6
- package/dist/server/model-enrich.js +10 -1
- package/dist/server/orchestrator.js +109 -0
- package/dist/server/patch-executable-lookup.js +396 -0
- package/dist/server/payload-limits.js +2 -0
- package/dist/server/plugin-llm.js +100 -9
- package/dist/server/plugins.js +65 -7
- package/dist/server/preset-fields.js +24 -0
- package/dist/server/preset-share.js +2 -0
- package/dist/server/prompt-base-store.js +85 -0
- package/dist/server/prompt-composer.js +44 -2
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/protocol.js +2 -2
- package/dist/server/reasoning-registry.js +207 -0
- package/dist/server/remote-ssh-service.js +22 -9
- package/dist/server/resolve-global-sdk.js +2 -0
- package/dist/server/session-search.js +1 -1
- package/dist/server/settings-service.js +90 -39
- package/dist/server/skill-content-filler.js +29 -8
- package/dist/server/skill-tool.js +12 -3
- package/dist/server/startup-banner.js +35 -0
- package/dist/server/subagent-helpers.js +4 -1
- package/dist/server/subagents.js +52 -37
- package/dist/server/system-prompt-soul.js +41 -0
- package/dist/server/tool-host-factories.js +1 -0
- package/dist/server/tool-manager.js +17 -9
- package/dist/server/unauthorized-page.js +319 -0
- package/dist/server/univer-service.js +448 -0
- package/dist/server/universal/drivers/dsh-driver.js +379 -0
- package/dist/server/universal/universal-session.js +5 -0
- package/dist/server/webui-context.js +25 -5
- package/dist/test-artifact.md +9 -0
- package/dist/test-preview-modal.md +11 -0
- package/dist/test-report.html +20 -0
- package/docs/README.md +94 -0
- package/docs/architecture-plugins.md +946 -0
- package/docs/device-center.md +106 -12
- package/docs/dsh-engine.md +10 -10
- package/extensions/webui.ts +43 -1
- package/package.json +2 -1
- package/themes/aetheris.css +5 -0
- package/themes/ayu-light.css +6 -0
- package/themes/bases/flow-base.css +68 -68
- package/themes/catppuccin-latte.css +6 -0
- package/themes/catppuccin.css +6 -0
- package/themes/claude-code-dark.css +5 -0
- package/themes/codex.css +6 -0
- package/themes/cyberpunk.css +6 -0
- package/themes/dark-teal.css +6 -1
- package/themes/dazzle.css +6 -0
- package/themes/everforest-light.css +6 -0
- package/themes/flow-light.css +8 -1
- package/themes/flow.css +6 -1
- package/themes/geist.css +6 -0
- package/themes/gruvbox-light.css +6 -0
- package/themes/kanagawa-lotus.css +6 -0
- package/themes/md-preview.css +6 -0
- package/themes/mist.css +6 -0
- package/themes/nord.css +6 -0
- package/themes/one-dark.css +6 -0
- package/themes/paper.css +6 -0
- package/themes/rose-pine-dawn.css +6 -0
- package/themes/sakura.css +6 -0
- package/themes/solarized-light.css +6 -0
- package/themes/tokyo-night.css +6 -0
- package/themes/translucent.css +6 -0
- package/themes/transparent.css +6 -0
- package/themes/vs-code-dark.css +5 -0
- package/themes/wallpaper-flow.css +5 -1
- package/themes/wallpaper-obsidian.css +6 -0
- package/themes/white.css +6 -0
- package/themes/zhujian-dark.css +6 -1
- package/themes/zhujian.css +6 -1
- package/themes/zhupi-dark.css +6 -1
- package/themes/zhupi.css +6 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/BgTasksModal-BDoOpj-F.js +1 -0
- package/web/dist/assets/BgTasksModal-C0i3O1FT.js +1 -0
- package/web/dist/assets/{CanvasStudio-BSg9ghPV.js → CanvasStudio-B8thymBN.js} +3 -3
- package/web/dist/assets/{CanvasStudio-DxW7C3Sz.js → CanvasStudio-zSxyIx1R.js} +3 -3
- package/web/dist/assets/DeviceCenter-DfAHKcid.js +3 -0
- package/web/dist/assets/DeviceCenter-ydvOTlzE.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-q5Ik8oXg.js +1 -0
- package/web/dist/assets/DeviceGroups-CI14_SRb.js +1 -0
- package/web/dist/assets/DeviceGroups-DvsB5IEU.js +1 -0
- package/web/dist/assets/Dropdown-C4LIhshN.js +1 -0
- package/web/dist/assets/FilePreview-BgGongmv.js +2 -0
- package/web/dist/assets/FilePreview-D4NrhF-U.js +2 -0
- package/web/dist/assets/GlobalSearchModal-BWgU8yPd.js +1 -0
- package/web/dist/assets/GlobalSearchModal-F7fNimKk.js +1 -0
- package/web/dist/assets/GroupConversation-Dh71Pdb-.js +17 -0
- package/web/dist/assets/GroupConversation-ZK3nRmNm.js +17 -0
- package/web/dist/assets/HintTip-c6d0TJoh.js +1 -0
- package/web/dist/assets/ModelConfigModal-YVEgyy34.js +2 -0
- package/web/dist/assets/ModelConfigModal-vWtg3srp.js +2 -0
- package/web/dist/assets/PiSetupModal-BmMrrgB9.js +1 -0
- package/web/dist/assets/ProviderOAuthControls-BGSBIKD7.js +1 -0
- package/web/dist/assets/SCMPanel-B8_EDxNr.js +2 -0
- package/web/dist/assets/SCMPanel-BU58qk3T.js +2 -0
- package/web/dist/assets/SettingsModal-CMUybq3J.js +32 -0
- package/web/dist/assets/SettingsModal-OBmGTh-5.js +32 -0
- package/web/dist/assets/TerminalPanel-0CYvD72B.js +3 -0
- package/web/dist/assets/TerminalPanel-DDavKvFr.js +3 -0
- package/web/dist/assets/TuiOverlayModal-BsA-QTvN.js +1 -0
- package/web/dist/assets/TuiOverlayModal-DzoVQBuG.js +1 -0
- package/web/dist/assets/app-globals-CZxzGvIo.js +123 -0
- package/web/dist/assets/canvas-client-CUnXlQYX.js +1 -0
- package/web/dist/assets/{desktop-7EvUHhKQ.js → desktop-aAKpvKJV.js} +1 -1
- package/web/dist/assets/group-view-state-CGCzYF8k.js +1 -0
- package/web/dist/assets/index-C6DwztqE.css +1 -0
- package/web/dist/assets/index-CuN802Sj.js +93 -0
- package/web/dist/assets/index-EH5Fw9fa.js +93 -0
- package/web/dist/assets/plugin-host-BRWib9DF.js +1 -0
- package/web/dist/assets/remote-ssh-client-CfYSMEZg.js +1 -0
- package/web/dist/assets/theme-D2l_mLNo.js +1 -0
- package/web/dist/index.html +10 -9
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/BgTasksModal-BvnUHjFe.js +0 -1
- package/web/dist/assets/BgTasksModal-DSC8ncW3.js +0 -1
- package/web/dist/assets/DeviceCenter-Bmgr-Bwm.js +0 -3
- package/web/dist/assets/DeviceCenter-Cl9MBXaH.js +0 -3
- package/web/dist/assets/DeviceGroups-aeLD2msl.js +0 -1
- package/web/dist/assets/Dropdown-D1Jl35dw.js +0 -1
- package/web/dist/assets/FilePreview-6CqoDF_P.js +0 -2
- package/web/dist/assets/FilePreview-CJa27G_Q.js +0 -2
- package/web/dist/assets/GlobalSearchModal-CJX35rZL.js +0 -1
- package/web/dist/assets/GlobalSearchModal-CMW0xz0P.js +0 -1
- package/web/dist/assets/GroupConversation-Cq4daBFb.js +0 -1
- package/web/dist/assets/GroupConversation-DoELa83U.js +0 -1
- package/web/dist/assets/ModelConfigModal-Bp7tfKYh.js +0 -2
- package/web/dist/assets/PiSetupModal-DD8srwBJ.js +0 -1
- package/web/dist/assets/ProviderOAuthControls-C6tfXb88.js +0 -1
- package/web/dist/assets/SCMPanel-CghgsyBN.js +0 -2
- package/web/dist/assets/SCMPanel-D8-8aqwC.js +0 -2
- package/web/dist/assets/SettingsModal-BbBe2rYo.js +0 -20
- package/web/dist/assets/SettingsModal-qETiVPKj.js +0 -20
- package/web/dist/assets/TerminalPanel-Da-Xs4Wk.js +0 -3
- package/web/dist/assets/TerminalPanel-DnS4tFQO.js +0 -3
- package/web/dist/assets/TuiOverlayModal-CGyGkKYl.js +0 -1
- package/web/dist/assets/TuiOverlayModal-CpBKjG6x.js +0 -1
- package/web/dist/assets/app-globals-DcyO0UPi.js +0 -1
- package/web/dist/assets/fi-NyN-ZrgD.js +0 -325
- package/web/dist/assets/index-DK3F5ZJo.js +0 -85
- package/web/dist/assets/index-DQMii2he.js +0 -85
- package/web/dist/assets/index-vwBnwzkr.css +0 -1
- package/web/dist/assets/plugin-host-BCnX3P8U.js +0 -1
- package/web/dist/assets/theme-D2DMH6tH.js +0 -1
|
@@ -140,7 +140,7 @@ export function piSessionsRoot() {
|
|
|
140
140
|
export function isInsideSessionsDir(agentDir, targetPath) {
|
|
141
141
|
const fold = (p) => (process.platform === "win32" ? p.toLowerCase() : p);
|
|
142
142
|
const abs = fold(resolve(targetPath));
|
|
143
|
-
const roots = [fold(resolve(agentDir, "sessions"))];
|
|
143
|
+
const roots = [fold(resolve(agentDir, "sessions")), fold(resolve(agentDir, "bot-sessions"))];
|
|
144
144
|
const extra = piSessionsRoot();
|
|
145
145
|
if (extra)
|
|
146
146
|
roots.push(fold(resolve(extra)));
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { existsSync, readFileSync } from "node:fs";
|
|
10
10
|
import { basename, dirname, join } from "node:path";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
|
-
import { extensionKey, isInternalExtension, normalizeBgCleanupMinutes, normalizeDisabledPluginTools, normalizeRetryMaxAttempts, normalizeKeepRecentMessages, normalizeSkillList, normalizeSkillsCatalogBudget, normalizeSkillsCatalogMaxDesc, normalizeToolWatchdogTimeoutMs, normalizeUiLayout, defaultSubagentAutoWakeMaxTurns, normalizeSubagentAutoWakeMaxTurns, settingsPresetToUi, } from "./client-state.js";
|
|
12
|
+
import { extensionKey, isInternalExtension, normalizeBgCleanupMinutes, normalizeDisabledPluginTools, normalizeRetryMaxAttempts, normalizeKeepRecentMessages, normalizeSkillList, normalizeSkillsCatalogBudget, normalizeSkillsCatalogMaxDesc, normalizeSkillsFullTextMaxBytes, normalizeSkillsMaxFileBytes, normalizeToolWatchdogTimeoutMs, normalizeUiLayout, defaultSubagentAutoWakeMaxTurns, normalizeSubagentAutoWakeMaxTurns, settingsPresetToUi, } from "./client-state.js";
|
|
13
13
|
import { normalizeSoftCapByModel, normalizeSoftCapTokens } from "./soft-cap.js";
|
|
14
14
|
import { findVisionModels, SYSTEM_PROMPT } from "./vision-bridge.js";
|
|
15
15
|
import { COMMITMSG_SYSTEM_PROMPT } from "./scm-commitmsg.js";
|
|
@@ -30,6 +30,7 @@ export class SettingsService {
|
|
|
30
30
|
knownExtensions = new Map();
|
|
31
31
|
/** 流式中改了需要 reload 的设置 → agent_end 后延迟应用(防拆毁运行中 run)。 */
|
|
32
32
|
pendingReload = false;
|
|
33
|
+
pendingRuntimeReloads = new Set();
|
|
33
34
|
unsubscribeSettings;
|
|
34
35
|
sharedVersion = 0;
|
|
35
36
|
sharedQueue = Promise.resolve();
|
|
@@ -69,6 +70,7 @@ export class SettingsService {
|
|
|
69
70
|
this.unsubscribeSettings?.();
|
|
70
71
|
this.unsubscribeSettings = undefined;
|
|
71
72
|
this.pendingReload = false;
|
|
73
|
+
this.pendingRuntimeReloads.clear();
|
|
72
74
|
}
|
|
73
75
|
/** Apply a durable commit without saving it again. Serialize reloads; ignore stale deliveries. */
|
|
74
76
|
receiveSharedSettings(change) {
|
|
@@ -110,7 +112,7 @@ export class SettingsService {
|
|
|
110
112
|
this.host.onGoalModeDisabled?.();
|
|
111
113
|
if (changed("showForkedParentSessions"))
|
|
112
114
|
this.host.onSessionsFilterChanged?.();
|
|
113
|
-
this.push(
|
|
115
|
+
this.push();
|
|
114
116
|
this.host.flushSnapshot();
|
|
115
117
|
if (changed("promptMode", "customSystemPrompt", "promptTemplate", "promptOverrides", "promptDisabled", "disabledSkills", "disabledExtensions"))
|
|
116
118
|
await this.applyRuntime();
|
|
@@ -150,15 +152,22 @@ export class SettingsService {
|
|
|
150
152
|
}
|
|
151
153
|
return false;
|
|
152
154
|
}
|
|
153
|
-
hasPendingReload() {
|
|
154
|
-
return this.pendingReload;
|
|
155
|
+
hasPendingReload(runtimeTarget) {
|
|
156
|
+
return runtimeTarget ? this.pendingRuntimeReloads.has(runtimeTarget) : this.pendingReload;
|
|
155
157
|
}
|
|
156
|
-
setPendingReload(v) {
|
|
157
|
-
|
|
158
|
+
setPendingReload(v, runtimeTarget) {
|
|
159
|
+
if (runtimeTarget) {
|
|
160
|
+
if (v)
|
|
161
|
+
this.pendingRuntimeReloads.add(runtimeTarget);
|
|
162
|
+
else
|
|
163
|
+
this.pendingRuntimeReloads.delete(runtimeTarget);
|
|
164
|
+
}
|
|
165
|
+
else
|
|
166
|
+
this.pendingReload = v;
|
|
158
167
|
}
|
|
159
|
-
consumePendingReload() {
|
|
160
|
-
const v = this.
|
|
161
|
-
this.
|
|
168
|
+
consumePendingReload(runtimeTarget) {
|
|
169
|
+
const v = this.hasPendingReload(runtimeTarget);
|
|
170
|
+
this.setPendingReload(false, runtimeTarget);
|
|
162
171
|
return v;
|
|
163
172
|
}
|
|
164
173
|
/** 判断某个 skill 名是否仍存在于磁盘任何来源(各类 Agent 项目区 / 全局 / 祖先 / npm 包等)。
|
|
@@ -219,14 +228,14 @@ export class SettingsService {
|
|
|
219
228
|
}
|
|
220
229
|
return false;
|
|
221
230
|
}
|
|
222
|
-
|
|
231
|
+
/** Discover disk resources and prune stale preferences only on explicit refresh. Never reloads. */
|
|
232
|
+
refreshResources() {
|
|
223
233
|
if (this.disposed || this.host.isDisposed())
|
|
224
234
|
return;
|
|
235
|
+
this.resetResourceCatalog();
|
|
225
236
|
this.settings = this.host.stateStore.getSettings(this.host.clientId);
|
|
226
237
|
this.presets = this.host.stateStore.getPresets(this.host.clientId);
|
|
227
238
|
const disabledSkills = new Set(this.settings.disabledSkills);
|
|
228
|
-
const reviewDisabledSkills = new Set(this.settings.reviewDisabledSkills);
|
|
229
|
-
const disabledExts = new Set(this.settings.disabledExtensions);
|
|
230
239
|
let loadedSkillNames = null;
|
|
231
240
|
let loadedExtNames = null;
|
|
232
241
|
try {
|
|
@@ -241,17 +250,12 @@ export class SettingsService {
|
|
|
241
250
|
agentDir: this.host.agentDir(),
|
|
242
251
|
});
|
|
243
252
|
const diskSkills = this.host.filterDiskSkills?.(discoveredSkills) ?? discoveredSkills;
|
|
244
|
-
//
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
const keepSkills = new Set([
|
|
248
|
-
...loadedSkills.map((s) => s.name),
|
|
249
|
-
...diskSkills.map((s) => s.name),
|
|
250
|
-
...this.settings.disabledSkills,
|
|
251
|
-
]);
|
|
253
|
+
// Rebuild membership from loaded and discovered resources so deleted
|
|
254
|
+
// disabled entries cannot keep themselves alive through the cache.
|
|
255
|
+
const keepSkills = new Set([...loadedSkills.map((s) => s.name), ...diskSkills.map((s) => s.name)]);
|
|
252
256
|
const keepExts = new Set([
|
|
253
257
|
...loadedExts.map((e) => extensionKey(e)),
|
|
254
|
-
...this.settings.disabledExtensions.filter((id) => !isInternalExtension({ path: id })),
|
|
258
|
+
...this.settings.disabledExtensions.filter((id) => !isInternalExtension({ path: id }) && this.extensionStillOnDisk(id)),
|
|
255
259
|
]);
|
|
256
260
|
// eslint-disable-next-line unicorn/no-useless-spread -- snapshot: handlers may unsubscribe mid-emit
|
|
257
261
|
for (const name of [...this.knownSkills.keys()]) {
|
|
@@ -292,11 +296,6 @@ export class SettingsService {
|
|
|
292
296
|
enabled: true,
|
|
293
297
|
});
|
|
294
298
|
}
|
|
295
|
-
// 若发现磁盘新增了 loader 尚未加载的技能,触发会话后台异步 reload 以刷新提示词和技能工具
|
|
296
|
-
const hasUnloadedDiskSkills = diskSkills.some((ds) => !loadedSkillNames.has(ds.name));
|
|
297
|
-
if (maintain && hasUnloadedDiskSkills && !this.host.isStreaming()) {
|
|
298
|
-
void this.applyRuntime();
|
|
299
|
-
}
|
|
300
299
|
}
|
|
301
300
|
catch {
|
|
302
301
|
// Session not ready yet — keep whatever we already know.
|
|
@@ -305,7 +304,7 @@ export class SettingsService {
|
|
|
305
304
|
// disabledSkills / reviewDisabledSkills 持久化记录中移除——否则每次
|
|
306
305
|
// 推送都会把已删除的 skill 以灰条形式永恒地补回面板(“关闭过的
|
|
307
306
|
// skill 被一直记录”)。session 未就绪时保守跳过。
|
|
308
|
-
if (
|
|
307
|
+
if (loadedSkillNames !== null) {
|
|
309
308
|
const stale = [
|
|
310
309
|
...new Set([
|
|
311
310
|
...this.settings.disabledSkills,
|
|
@@ -330,7 +329,7 @@ export class SettingsService {
|
|
|
330
329
|
// disabledExtensions 同理:已卸载(loader 里没有、磁盘/配置里也没有)的扩展
|
|
331
330
|
// 从禁用记录里剔除并持久化 —— 否则卸载过的扩展以“已禁用”灰条永生(issue #192)。
|
|
332
331
|
// loadedExtNames 非 null 即 session 就绪;取不到(catch 分支)时保守跳过。
|
|
333
|
-
if (
|
|
332
|
+
if (loadedExtNames !== null) {
|
|
334
333
|
const staleExts = this.settings.disabledExtensions.filter((id) => isInternalExtension({ path: id }) || (!loadedExtNames.has(id) && !this.extensionStillOnDisk(id)));
|
|
335
334
|
if (staleExts.length > 0) {
|
|
336
335
|
this.settings.disabledExtensions = this.settings.disabledExtensions.filter((n) => !staleExts.includes(n));
|
|
@@ -362,6 +361,50 @@ export class SettingsService {
|
|
|
362
361
|
});
|
|
363
362
|
}
|
|
364
363
|
}
|
|
364
|
+
this.push();
|
|
365
|
+
}
|
|
366
|
+
catalogCwd;
|
|
367
|
+
resetResourceCatalog() {
|
|
368
|
+
const cwd = this.host.cwd();
|
|
369
|
+
if (cwd === this.catalogCwd)
|
|
370
|
+
return;
|
|
371
|
+
this.catalogCwd = cwd;
|
|
372
|
+
this.knownSkills.clear();
|
|
373
|
+
this.knownExtensions.clear();
|
|
374
|
+
}
|
|
375
|
+
/** Publish persisted preferences and the current in-memory resource catalog. No discovery, writes or reloads. */
|
|
376
|
+
push() {
|
|
377
|
+
if (this.disposed || this.host.isDisposed())
|
|
378
|
+
return;
|
|
379
|
+
this.resetResourceCatalog();
|
|
380
|
+
this.settings = this.host.stateStore.getSettings(this.host.clientId);
|
|
381
|
+
this.presets = this.host.stateStore.getPresets(this.host.clientId);
|
|
382
|
+
const disabledSkills = new Set(this.settings.disabledSkills);
|
|
383
|
+
const reviewDisabledSkills = new Set(this.settings.reviewDisabledSkills);
|
|
384
|
+
const disabledExts = new Set(this.settings.disabledExtensions);
|
|
385
|
+
try {
|
|
386
|
+
const loader = this.host.getSession().resourceLoader;
|
|
387
|
+
for (const skill of loader.getSkills().skills) {
|
|
388
|
+
this.knownSkills.set(skill.name, { name: skill.name, description: skill.description, enabled: true });
|
|
389
|
+
}
|
|
390
|
+
for (const extension of loader.getExtensions().extensions) {
|
|
391
|
+
if (isInternalExtension(extension))
|
|
392
|
+
continue;
|
|
393
|
+
const id = extensionKey(extension);
|
|
394
|
+
const path = extension.sourceInfo?.path ?? extension.path;
|
|
395
|
+
this.knownExtensions.set(id, {
|
|
396
|
+
id,
|
|
397
|
+
name: extension.sourceInfo?.origin === "package" && extension.sourceInfo.source
|
|
398
|
+
? extension.sourceInfo.source
|
|
399
|
+
: basename(path),
|
|
400
|
+
path,
|
|
401
|
+
enabled: true,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
catch {
|
|
406
|
+
// Session initialization may still be in progress.
|
|
407
|
+
}
|
|
365
408
|
const skills = [...this.knownSkills.values()]
|
|
366
409
|
.map((s) => ({ ...s, enabled: !disabledSkills.has(s.name) }))
|
|
367
410
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -438,6 +481,8 @@ export class SettingsService {
|
|
|
438
481
|
skillsCatalogMaxDesc: this.settings.skillsCatalogMaxDesc,
|
|
439
482
|
skillsCatalogShowLocation: this.settings.skillsCatalogShowLocation,
|
|
440
483
|
skillsCatalogBudget: this.settings.skillsCatalogBudget,
|
|
484
|
+
skillsMaxFileBytes: this.settings.skillsMaxFileBytes,
|
|
485
|
+
skillsFullTextMaxBytes: this.settings.skillsFullTextMaxBytes,
|
|
441
486
|
// The composed system prompt actually in effect (read-only view).
|
|
442
487
|
effectiveSystemPrompt: promptSnap.full,
|
|
443
488
|
// 每个来源未覆盖时的默认(自动)内容(「各来源」行预览用)。
|
|
@@ -713,6 +758,12 @@ export class SettingsService {
|
|
|
713
758
|
if (partial.skillsCatalogBudget !== undefined) {
|
|
714
759
|
next.skillsCatalogBudget = normalizeSkillsCatalogBudget(partial.skillsCatalogBudget);
|
|
715
760
|
}
|
|
761
|
+
if (partial.skillsMaxFileBytes !== undefined) {
|
|
762
|
+
next.skillsMaxFileBytes = normalizeSkillsMaxFileBytes(partial.skillsMaxFileBytes);
|
|
763
|
+
}
|
|
764
|
+
if (partial.skillsFullTextMaxBytes !== undefined) {
|
|
765
|
+
next.skillsFullTextMaxBytes = normalizeSkillsFullTextMaxBytes(partial.skillsFullTextMaxBytes);
|
|
766
|
+
}
|
|
716
767
|
for (const key of ["chatUploadMaxMb", "workspaceUploadMaxMb", "folderUploadMaxMb"]) {
|
|
717
768
|
if (partial[key] !== undefined)
|
|
718
769
|
next[key] = partial[key];
|
|
@@ -880,7 +931,7 @@ export class SettingsService {
|
|
|
880
931
|
return { ...s, name };
|
|
881
932
|
}
|
|
882
933
|
/** Replace the current settings with the named preset and apply it. */
|
|
883
|
-
async applyPreset(name) {
|
|
934
|
+
async applyPreset(name, runtimeTarget) {
|
|
884
935
|
this.settings = this.current;
|
|
885
936
|
this.presets = this.host.stateStore.getPresets(this.host.clientId);
|
|
886
937
|
const p = this.presets.find((x) => x.name === name);
|
|
@@ -936,7 +987,7 @@ export class SettingsService {
|
|
|
936
987
|
if ((this.settings.showForkedParentSessions ?? false) !== prevShowForked) {
|
|
937
988
|
this.host.onSessionsFilterChanged?.();
|
|
938
989
|
}
|
|
939
|
-
await this.applyRuntime(true);
|
|
990
|
+
await this.applyRuntime(true, runtimeTarget);
|
|
940
991
|
}
|
|
941
992
|
/** Remove a named preset. */
|
|
942
993
|
async deletePreset(name) {
|
|
@@ -1122,11 +1173,11 @@ export class SettingsService {
|
|
|
1122
1173
|
* overrides read this.settings at call time, so a reload re-applies them.
|
|
1123
1174
|
* Reloading mid-stream would tear down the in-flight run — defer instead.
|
|
1124
1175
|
*/
|
|
1125
|
-
async applyRuntime(throwOnError = false) {
|
|
1176
|
+
async applyRuntime(throwOnError = false, runtimeTarget) {
|
|
1126
1177
|
if (this.disposed || this.host.isDisposed())
|
|
1127
1178
|
return;
|
|
1128
|
-
if (this.host.isStreaming()) {
|
|
1129
|
-
this.
|
|
1179
|
+
if ((runtimeTarget ?? this.host).isStreaming()) {
|
|
1180
|
+
this.setPendingReload(true, runtimeTarget);
|
|
1130
1181
|
this.host.emit({
|
|
1131
1182
|
type: "notice",
|
|
1132
1183
|
level: "info",
|
|
@@ -1135,14 +1186,14 @@ export class SettingsService {
|
|
|
1135
1186
|
});
|
|
1136
1187
|
return;
|
|
1137
1188
|
}
|
|
1138
|
-
await this.applyReload(throwOnError);
|
|
1189
|
+
await this.applyReload(throwOnError, runtimeTarget);
|
|
1139
1190
|
}
|
|
1140
1191
|
/** session.reload() + refresh the slash-command catalog + push state. */
|
|
1141
|
-
async applyReload(throwOnError = false) {
|
|
1192
|
+
async applyReload(throwOnError = false, runtimeTarget) {
|
|
1142
1193
|
if (this.disposed || this.host.isDisposed())
|
|
1143
1194
|
return;
|
|
1144
|
-
if (this.host.isStreaming()) {
|
|
1145
|
-
this.
|
|
1195
|
+
if ((runtimeTarget ?? this.host).isStreaming()) {
|
|
1196
|
+
this.setPendingReload(true, runtimeTarget);
|
|
1146
1197
|
this.host.emit({
|
|
1147
1198
|
type: "notice",
|
|
1148
1199
|
level: "info",
|
|
@@ -1152,10 +1203,10 @@ export class SettingsService {
|
|
|
1152
1203
|
return;
|
|
1153
1204
|
}
|
|
1154
1205
|
try {
|
|
1155
|
-
await this.host.reloadSession();
|
|
1206
|
+
await (runtimeTarget ?? this.host).reloadSession();
|
|
1156
1207
|
if (this.disposed || this.host.isDisposed())
|
|
1157
1208
|
return;
|
|
1158
|
-
this.
|
|
1209
|
+
this.refreshResources();
|
|
1159
1210
|
this.host.flushSnapshot();
|
|
1160
1211
|
this.host.emit({ type: "notice", level: "info", text: "设置已应用", textEn: "Settings applied" });
|
|
1161
1212
|
}
|
|
@@ -2,29 +2,50 @@
|
|
|
2
2
|
* skill-content-filler — 技能全文注入({{skills}} 全文模式)内容填充器。
|
|
3
3
|
*
|
|
4
4
|
* 负责读取名单里技能的文件正文。
|
|
5
|
-
*
|
|
5
|
+
* 单文件上限(默认 8KB)与总量预算(默认 32KB)都由调用方传入,缺省即历史硬编码值
|
|
6
|
+
* (设置项 skillsMaxFileBytes / skillsFullTextMaxBytes,见 issue #819);
|
|
7
|
+
* 失败/超限/不在名单回落名录(无 content)。
|
|
6
8
|
* 名单为空时零开销:原样返回,不碰磁盘。
|
|
7
9
|
*
|
|
10
|
+
* 预算口径是 **UTF-8 字节**:注入的是文本,模型按 token 付费,而字节数才是文件大小
|
|
11
|
+
* 与上下文占用的共同尺度。以前按 `raw.length`(JavaScript 字符数)扣预算,同样的
|
|
12
|
+
* 中文技能会被低估约 3 倍,总量可以冲出上限。
|
|
13
|
+
*
|
|
8
14
|
* 从 agent-service.ts 抽出为独立模块。
|
|
9
15
|
*/
|
|
10
16
|
import { readFileSync, statSync } from "node:fs";
|
|
11
17
|
import { decodeText } from "./text-sniff.js";
|
|
12
|
-
import { normalizeSkillList } from "./client-state.js";
|
|
13
|
-
export function fillSkillContents(skills, skillsFullTextConfig) {
|
|
18
|
+
import { DEFAULT_SKILLS_FULL_TEXT_MAX_BYTES, DEFAULT_SKILLS_MAX_FILE_BYTES, normalizeSkillList, normalizeSkillsFullTextMaxBytes, normalizeSkillsMaxFileBytes, } from "./client-state.js";
|
|
19
|
+
export function fillSkillContents(skills, skillsFullTextConfig, limits = {}) {
|
|
14
20
|
const wanted = new Set(normalizeSkillList(skillsFullTextConfig));
|
|
15
21
|
if (wanted.size === 0)
|
|
16
22
|
return skills;
|
|
17
|
-
|
|
23
|
+
const maxFile = limits.maxFileBytes === undefined
|
|
24
|
+
? DEFAULT_SKILLS_MAX_FILE_BYTES
|
|
25
|
+
: normalizeSkillsMaxFileBytes(limits.maxFileBytes);
|
|
26
|
+
const maxTotal = limits.maxTotalBytes === undefined
|
|
27
|
+
? DEFAULT_SKILLS_FULL_TEXT_MAX_BYTES
|
|
28
|
+
: normalizeSkillsFullTextMaxBytes(limits.maxTotalBytes);
|
|
29
|
+
// 0 = 显式不设限:用 Infinity 让下面的预算判断保持单一路径。
|
|
30
|
+
let budget = maxTotal > 0 ? maxTotal : Number.POSITIVE_INFINITY;
|
|
18
31
|
return skills.map((s) => {
|
|
19
32
|
if (!wanted.has(s.name) || !s.filePath || budget <= 0)
|
|
20
33
|
return s;
|
|
21
34
|
try {
|
|
22
35
|
const st = statSync(s.filePath);
|
|
23
|
-
if (!st.isFile() || st.size <= 0
|
|
36
|
+
if (!st.isFile() || st.size <= 0)
|
|
37
|
+
return s;
|
|
38
|
+
if (maxFile > 0 && st.size > maxFile)
|
|
39
|
+
return s;
|
|
40
|
+
const room = Math.min(st.size, budget);
|
|
41
|
+
const slice = readFileSync(s.filePath).subarray(0, room);
|
|
42
|
+
// 按预算截断时末尾可能是半个多字节字符,解码成 U+FFFD —— 丢掉它,别把乱码塞进提示词。
|
|
43
|
+
const text = decodeText(slice);
|
|
44
|
+
const raw = (room < st.size ? text.replace(/\uFFFD+$/u, "") : text).trim();
|
|
45
|
+
if (!raw)
|
|
24
46
|
return s;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return raw ? { ...s, content: raw } : s;
|
|
47
|
+
budget -= Buffer.byteLength(raw, "utf8");
|
|
48
|
+
return { ...s, content: raw };
|
|
28
49
|
}
|
|
29
50
|
catch {
|
|
30
51
|
return s;
|
|
@@ -23,8 +23,15 @@ import { Type } from "typebox";
|
|
|
23
23
|
import { pick } from "./i18n.js";
|
|
24
24
|
import { SKILL_TOOL_NAME } from "./tool-manager.js";
|
|
25
25
|
import { decodeText } from "./text-sniff.js";
|
|
26
|
-
/**
|
|
26
|
+
/** 单文件正文上限的出厂默认(= 设置项 skillsMaxFileBytes 的默认值,8KB)。 */
|
|
27
27
|
export const SKILL_TOOL_FILE_CAP = 8192;
|
|
28
|
+
/** 实际生效的单文件上限:非负整数,非法/未设置回退出厂默认。0 = 不设单文件上限。 */
|
|
29
|
+
function effectiveFileCap(host) {
|
|
30
|
+
const raw = host.maxFileBytes?.();
|
|
31
|
+
if (typeof raw === "number" && Number.isFinite(raw) && raw >= 0)
|
|
32
|
+
return Math.floor(raw);
|
|
33
|
+
return SKILL_TOOL_FILE_CAP;
|
|
34
|
+
}
|
|
28
35
|
/** 精确名匹配(大小写敏感,与 skillsFullText 名单语义一致)。 */
|
|
29
36
|
export function findSkill(skills, name) {
|
|
30
37
|
const n = name.trim();
|
|
@@ -127,8 +134,10 @@ export function makeSkillTool(host, lang) {
|
|
|
127
134
|
}
|
|
128
135
|
try {
|
|
129
136
|
const st = statSync(found.filePath);
|
|
130
|
-
const
|
|
131
|
-
|
|
137
|
+
const cap = effectiveFileCap(host);
|
|
138
|
+
// 0 = 不设单文件上限(设置项显式打开);否则超限回落可读错误,不截断正文。
|
|
139
|
+
const kb = Math.max(1, Math.round(cap / 1024));
|
|
140
|
+
if (!st.isFile() || st.size <= 0 || (cap > 0 && st.size > cap)) {
|
|
132
141
|
return text(pick(L, `技能 ${name} 的文件不可读(不存在/超 ${kb}KB 上限)。`, `Skill ${name} file unreadable (missing or over the ${kb}KB cap).`, "skill.file.unreadable", { name, kb }));
|
|
133
142
|
}
|
|
134
143
|
const body = decodeText(readFileSync(found.filePath).subarray(0, st.size)).trim();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isLoopbackHost } from "./host-guard.js";
|
|
2
|
+
/**
|
|
3
|
+
* 计算服务对外展示的主入口 URL。
|
|
4
|
+
* - 当配置了 token 时,自动追加 `/?token=...`,确保用户从控制台或脚本直达 Web 界面并完成认证;
|
|
5
|
+
* - 回环地址与 0.0.0.0 归一化为 localhost,保证浏览器直接点击可达。
|
|
6
|
+
*/
|
|
7
|
+
export function buildMainUrl(port, host, token) {
|
|
8
|
+
const trimmedToken = token?.trim() ?? "";
|
|
9
|
+
const urlHost = isLoopbackHost(host) || host === "0.0.0.0" ? "localhost" : host;
|
|
10
|
+
const tokenQuery = trimmedToken ? `/?token=${encodeURIComponent(trimmedToken)}` : "";
|
|
11
|
+
return `http://${urlHost}:${port}${tokenQuery}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 格式化启动横幅日志文本行列表。
|
|
15
|
+
*/
|
|
16
|
+
export function formatStartupBannerLines(params) {
|
|
17
|
+
const mainUrl = buildMainUrl(params.port, params.host, params.token);
|
|
18
|
+
const lines = [
|
|
19
|
+
"",
|
|
20
|
+
" ⚡ pi-web-ui — web chat for the pi coding agent",
|
|
21
|
+
` ${mainUrl}`,
|
|
22
|
+
` workspace : ${params.cwd}`,
|
|
23
|
+
` session dir : ${params.sessionDir}`,
|
|
24
|
+
` pi SDK : v${params.version}`,
|
|
25
|
+
];
|
|
26
|
+
if (params.sdkNote) {
|
|
27
|
+
lines.push(` pi SDK note : ${params.sdkNote}`);
|
|
28
|
+
}
|
|
29
|
+
lines.push(` bind : ${params.host}:${params.port}`);
|
|
30
|
+
if (params.token?.trim()) {
|
|
31
|
+
lines.push(` token : ${params.token.trim()}`);
|
|
32
|
+
}
|
|
33
|
+
lines.push(` setup : http://127.0.0.1:${params.port}/setup (仅本机:配 token/监听/白名单)`);
|
|
34
|
+
return lines;
|
|
35
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SUBAGENT_PROMPT_SNAPSHOT_CAP } from "./agent-formatters.js";
|
|
2
|
+
import { conversationIdentity, parentConversationIdentity, conversationParent } from "./conversation-identity.js";
|
|
2
3
|
/** 子代理是否处于活跃(流式运行中或首轮投递启动中)状态。
|
|
3
4
|
* #589:名额与可见性解耦——仅活跃(非终态)子代理占用 MAX_SUBAGENTS 并发名额;
|
|
4
5
|
* 已结束(done / canceled / error)的子代理保留在左栏供用户审阅追溯,不再占名额。 */
|
|
@@ -96,6 +97,8 @@ export function toSubagentSnapshot(conv) {
|
|
|
96
97
|
const modelKey = m ? `${m.provider}/${m.id}` : (conv.subagentTemplate?.model ?? undefined);
|
|
97
98
|
return {
|
|
98
99
|
convId: conv.id,
|
|
100
|
+
executionId: conversationIdentity(conv),
|
|
101
|
+
parentExecutionId: parentConversationIdentity(conv),
|
|
99
102
|
type: conv.subagentType ?? "general",
|
|
100
103
|
title: conv.title,
|
|
101
104
|
prompt: fullPrompt.length > SUBAGENT_PROMPT_SNAPSHOT_CAP
|
|
@@ -110,7 +113,7 @@ export function toSubagentSnapshot(conv) {
|
|
|
110
113
|
model: modelKey,
|
|
111
114
|
thinkingLevel,
|
|
112
115
|
output: conv.session.getLastAssistantText() ?? "",
|
|
113
|
-
parentId: conv
|
|
116
|
+
parentId: conversationParent(conv)?.id,
|
|
114
117
|
persisted: isPersisted,
|
|
115
118
|
handoffTo: conv.peerHandoffTo ? [...conv.peerHandoffTo] : undefined,
|
|
116
119
|
handoffFrom: conv.peerHandoffFrom ? [...conv.peerHandoffFrom] : undefined,
|