pi-web-ui 0.116.0 → 0.118.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 +83 -3
- package/README.md +69 -138
- package/README.zh-CN.md +70 -179
- package/README.zh-TW.md +3 -1
- package/bin/device-hub-cli.mjs +163 -36
- package/bin/frp-manager.mjs +4 -80
- package/bin/hub-upgrade.mjs +561 -0
- package/bin/pi-device-hub.mjs +0 -1
- package/bin/pi-web-ui.mjs +184 -504
- package/deploy/nginx-subpath.conf +0 -33
- package/deploy/pi-web-ui.service +0 -20
- package/dist/server/agent-formatters.js +4 -38
- package/dist/server/agent-service-daemon.js +203 -371
- package/dist/server/agent-service.js +1281 -3030
- package/dist/server/approval-audit.js +2 -23
- package/dist/server/approval-default-rules.js +0 -6
- package/dist/server/approval-rules.js +7 -105
- package/dist/server/ask-user-question-tool.js +1 -12
- package/dist/server/atomic-file.js +33 -5
- package/dist/server/attachment-store.js +0 -36
- package/dist/server/attachments.js +3 -112
- package/dist/server/auth-cookie.js +0 -21
- package/dist/server/bash-tool.js +1 -32
- package/dist/server/bg-servers.js +0 -96
- package/dist/server/browser-page-tool.js +11 -62
- package/dist/server/builtin-modules.js +7 -0
- package/dist/server/canvas/canvas-agent-tool.js +58 -47
- package/dist/server/canvas/canvas-cards.js +0 -14
- package/dist/server/canvas/canvas-dispatch.js +7 -4
- package/dist/server/canvas/canvas-orchestrator.js +167 -181
- package/dist/server/canvas/canvas-runtime-messages.js +30 -0
- package/dist/server/canvas/canvas-scheduled-task.js +0 -3
- package/dist/server/canvas/canvas-scheduler.js +5 -7
- package/dist/server/canvas/canvas-store.js +24 -35
- package/dist/server/canvas/canvas-validation.js +17 -14
- package/dist/server/canvas/canvas-workspace.js +42 -114
- package/dist/server/canvas/pstack-skills-data.js +0 -5
- package/dist/server/claim-files-tool.js +1 -15
- package/dist/server/claim-store.js +5 -49
- package/dist/server/client-id-utils.js +0 -16
- package/dist/server/client-state.js +36 -214
- package/dist/server/communicate-tool.js +0 -3
- package/dist/server/compact-context-tool.js +0 -30
- package/dist/server/compacted-history.js +0 -35
- package/dist/server/compaction-instructions.js +0 -13
- package/dist/server/compaction-markers.js +38 -92
- package/dist/server/compaction-state.js +0 -21
- package/dist/server/composer-drafts.js +0 -34
- package/dist/server/context-budget-runner.js +0 -11
- package/dist/server/context-budget.js +1 -70
- package/dist/server/context-evidence.js +0 -14
- package/dist/server/context-usage.js +0 -12
- package/dist/server/control-socket.js +4 -48
- package/dist/server/conversation-communication.js +0 -10
- package/dist/server/conversation-identity.js +0 -1
- package/dist/server/conversation-read-tool.js +0 -58
- package/dist/server/conversation-tool-names.js +0 -1
- package/dist/server/conversation-tool.js +0 -1
- package/dist/server/conversation-touches.js +4 -75
- package/dist/server/dangling-tools.js +142 -68
- package/dist/server/delegate-mode.js +0 -36
- package/dist/server/delegate-task.js +2 -28
- package/dist/server/device-center/approval-summary.js +0 -1
- package/dist/server/device-center/bot-catalog.js +0 -3
- package/dist/server/device-center/bot-execution.js +48 -9
- package/dist/server/device-center/bot-presets.js +0 -1
- package/dist/server/device-center/bots.js +0 -1
- package/dist/server/device-center/collab-service.js +27 -11
- package/dist/server/device-center/collab-tool.js +393 -27
- package/dist/server/device-center/connector.js +128 -48
- package/dist/server/device-center/delivery-authority.js +95 -0
- package/dist/server/device-center/delivery-subject.js +29 -0
- package/dist/server/device-center/desktop-linux.js +3 -15
- package/dist/server/device-center/desktop-native.js +1 -10
- package/dist/server/device-center/desktop-page.js +2 -3
- package/dist/server/device-center/desktop-setup.js +1 -3
- package/dist/server/device-center/desktop.js +1 -7
- package/dist/server/device-center/device-integration.js +452 -208
- package/dist/server/device-center/device-lan-access.js +403 -0
- package/dist/server/device-center/device-lan.js +484 -0
- package/dist/server/device-center/device-portals.js +0 -3
- package/dist/server/device-center/execution-failure.js +0 -2
- package/dist/server/device-center/execution-guides.js +15 -6
- package/dist/server/device-center/execution-instructions.js +0 -1
- package/dist/server/device-center/execution-settings.js +0 -1
- package/dist/server/device-center/execution-system-prompt.js +0 -3
- package/dist/server/device-center/execution-workspace.js +1 -4
- package/dist/server/device-center/executor.js +46 -31
- package/dist/server/device-center/file-sync-paths.js +0 -5
- package/dist/server/device-center/file-sync.js +0 -10
- package/dist/server/device-center/group-context-delta.js +0 -8
- package/dist/server/device-center/group-context-message.js +0 -14
- package/dist/server/device-center/group-context.js +0 -19
- package/dist/server/device-center/group-events.js +0 -2
- package/dist/server/device-center/group-plan-guard.js +1 -35
- package/dist/server/device-center/group-router-runtime.js +182 -0
- package/dist/server/device-center/group-router-worker.js +178 -0
- package/dist/server/device-center/group-router.js +359 -0
- package/dist/server/device-center/hub-auth.js +24 -2
- package/dist/server/device-center/hub-conversations.js +13 -15
- package/dist/server/device-center/hub-deliveries.js +119 -15
- package/dist/server/device-center/hub-integration.js +647 -334
- package/dist/server/device-center/hub-locks.js +1 -5
- package/dist/server/device-center/hub-mobile.js +147 -0
- package/dist/server/device-center/hub-orchestration.js +400 -0
- package/dist/server/device-center/hub-page.js +28 -9
- package/dist/server/device-center/hub-setup.js +23 -7
- package/dist/server/device-center/hub-transaction-log.js +175 -0
- package/dist/server/device-center/hub-upgrade.js +162 -0
- package/dist/server/device-center/hub-webhooks.js +1 -3
- package/dist/server/device-center/hub.js +946 -404
- package/dist/server/device-center/human-interaction.js +1 -4
- package/dist/server/device-center/integration-errors.js +0 -2
- package/dist/server/device-center/integration-verification.js +111 -0
- package/dist/server/device-center/local-hub.js +6 -4
- package/dist/server/device-center/local-publication.js +416 -0
- package/dist/server/device-center/local-verification-job.js +95 -0
- package/dist/server/device-center/local-verification.js +273 -0
- package/dist/server/device-center/local.js +341 -18
- package/dist/server/device-center/main.js +18 -2
- package/dist/server/device-center/mobile-notification-forwarder.js +292 -0
- package/dist/server/device-center/native-desktop/macos.js +0 -1
- package/dist/server/device-center/native-desktop/windows.js +0 -1
- package/dist/server/device-center/partition-log.js +52 -46
- package/dist/server/device-center/path-portal.js +42 -12
- package/dist/server/device-center/publication-journal.js +305 -0
- package/dist/server/device-center/publish-intent.js +374 -0
- package/dist/server/device-center/relay.js +217 -52
- package/dist/server/device-center/report-upload.js +0 -1
- package/dist/server/device-center/runtime.js +419 -52
- package/dist/server/device-center/store.js +223 -65
- package/dist/server/device-center/task-context-budget.js +0 -3
- package/dist/server/device-center/task-error.js +0 -1
- package/dist/server/device-center/task-journal.js +6 -23
- package/dist/server/device-center/task-outcome.js +68 -0
- package/dist/server/device-center/task-plan.js +0 -1
- package/dist/server/device-center/task-progress.js +0 -16
- package/dist/server/device-center/task-recovery.js +569 -227
- package/dist/server/device-center/task-report-outbox.js +0 -4
- package/dist/server/device-center/task-report.js +2 -10
- package/dist/server/device-center/task-scheduler.js +1 -35
- package/dist/server/device-center/task-settlement.js +335 -0
- package/dist/server/device-center/task-state.js +0 -12
- package/dist/server/device-center/task-workspace.js +393 -0
- package/dist/server/device-center/transfer-stream.js +5 -45
- package/dist/server/device-center/transfers.js +2 -10
- package/dist/server/device-center/verification-limits.js +9 -0
- package/dist/server/device-center/work-contract.js +923 -0
- package/dist/server/device-center/work-items.js +317 -0
- package/dist/server/device-center/workspaces.js +0 -1
- package/dist/server/dispatch-domain-handlers.js +202 -29
- package/dist/server/dispatch-plugin-handlers.js +2 -19
- package/dist/server/dsh/dsh-agent-service.js +78 -601
- package/dist/server/dsh/dsh-client.js +7 -111
- package/dist/server/dsh/dsh-market-service.js +4 -25
- package/dist/server/dsh/dsh-serialize.js +0 -49
- package/dist/server/dsh/dsh-sessions.js +0 -37
- package/dist/server/dsh/dsh-usage.js +0 -37
- package/dist/server/dsh/preset-clones.js +1 -65
- package/dist/server/dsh/runtime/custom-prompt.mjs +0 -14
- package/dist/server/dsh/runtime/goal-rpc.mjs +7 -176
- package/dist/server/dsh/runtime/launcher.mjs +2 -53
- package/dist/server/dsh/runtime/override.patch.yml +0 -29
- package/dist/server/dsh/runtime/runtime-root.mjs +0 -54
- package/dist/server/durable/durable-agent-service.js +5 -23
- package/dist/server/durable/durable-driver.js +12 -73
- package/dist/server/durable/durable-event-projector.js +1 -50
- package/dist/server/durable/durable-loader.js +0 -12
- package/dist/server/durable/durable-models.js +11 -80
- package/dist/server/durable/durable-storage.js +1 -17
- package/dist/server/durable/durable-tools.js +2 -20
- package/dist/server/durable/index.js +0 -3
- package/dist/server/edit-soft-tool.js +2 -81
- package/dist/server/engine-capabilities.js +0 -13
- package/dist/server/engine-catalog.js +74 -0
- package/dist/server/engine-cli.js +89 -0
- package/dist/server/engine-probe.js +35 -217
- package/dist/server/ensure-bash.js +2 -28
- package/dist/server/eval-tool.js +1 -50
- package/dist/server/evidence-tool-hooks.js +0 -2
- package/dist/server/file-archives.js +0 -10
- package/dist/server/file-save.js +1 -12
- package/dist/server/file-transfer-routes.js +0 -11
- package/dist/server/files-service.js +18 -271
- package/dist/server/global-loader.js +9 -89
- package/dist/server/goal-evidence.js +1 -35
- package/dist/server/goal-review-gate.js +0 -58
- package/dist/server/goal-service.js +19 -422
- package/dist/server/hashline-engine.js +8 -112
- package/dist/server/host-guard.js +0 -24
- package/dist/server/host-metrics.js +0 -6
- package/dist/server/http-proxy.js +1 -7
- package/dist/server/i18n.js +5 -72
- package/dist/server/icon-svg.js +0 -15
- package/dist/server/index.js +199 -677
- package/dist/server/json-utils.js +0 -12
- package/dist/server/launch-origin.js +0 -44
- package/dist/server/left-panel-running.js +0 -9
- package/dist/server/load-timing.js +1 -4
- package/dist/server/load-tools-tool.js +0 -20
- package/dist/server/locales.js +1 -46
- package/dist/server/lsp-tool.js +13 -126
- package/dist/server/managed.js +0 -48
- package/dist/server/marker-service.js +1 -22
- package/dist/server/markers/builtins/action.js +0 -19
- package/dist/server/markers/builtins/notify.js +1 -9
- package/dist/server/markers/builtins/rename.js +0 -13
- package/dist/server/markers/index.js +0 -3
- package/dist/server/markers/marker.js +0 -13
- package/dist/server/markers/registry.js +0 -3
- package/dist/server/markers/store.js +1 -12
- package/dist/server/market-service.js +7 -43
- package/dist/server/mcp-agent-tool.js +0 -10
- package/dist/server/mcp-bridge.js +6 -138
- package/dist/server/mcp-hot-reload.js +0 -25
- package/dist/server/mcp-manager.js +2 -44
- package/dist/server/mcp-oauth-login.js +0 -2
- package/dist/server/mcp-oauth-ui.js +1 -4
- package/dist/server/mcp-oauth.js +5 -79
- package/dist/server/mcp-project-runtime.js +0 -4
- package/dist/server/message-deletion.js +0 -2
- package/dist/server/message-entry-resolver.js +0 -8
- package/dist/server/message-window.js +0 -71
- package/dist/server/mobile-notification-events.js +16 -0
- package/dist/server/mobile-origin.js +79 -0
- package/dist/server/mobile-push.js +523 -0
- package/dist/server/model-admin.js +19 -358
- package/dist/server/model-enrich.js +0 -19
- package/dist/server/model-resolver.js +2 -61
- package/dist/server/native-cli-discovery.js +115 -0
- package/dist/server/native-cli-model.js +71 -0
- package/dist/server/native-cli-references.js +214 -0
- package/dist/server/native-cli-remote-cleanup.js +58 -0
- package/dist/server/native-cli-remote-files.js +282 -0
- package/dist/server/native-cli-routes.js +68 -0
- package/dist/server/native-cli-runtime.js +1 -0
- package/dist/server/native-cli-session-hooks.js +170 -0
- package/dist/server/native-cli-session.js +585 -0
- package/dist/server/native-cli-state.js +82 -0
- package/dist/server/native-cli.js +210 -0
- package/dist/server/net-guard.js +9 -71
- package/dist/server/office-parse.js +0 -50
- package/dist/server/orphan-manager.js +0 -18
- package/dist/server/patch-bash-process.js +0 -4
- package/dist/server/patch-executable-lookup.js +0 -77
- package/dist/server/patch-node-pty.js +6 -45
- package/dist/server/patch-remote-catalog.js +4 -34
- package/dist/server/patch-tool.js +0 -15
- package/dist/server/payload-limits.js +0 -5
- package/dist/server/pending-question.js +0 -5
- package/dist/server/permission-preset.js +4 -33
- package/dist/server/persona-chain.js +0 -26
- package/dist/server/pkg-info.js +1 -17
- package/dist/server/plan-manager.js +2 -49
- package/dist/server/plan-mode.js +0 -97
- package/dist/server/plan-update-tool.js +1 -15
- package/dist/server/plugin-api-catalog.js +6 -4
- package/dist/server/plugin-assets.js +1 -35
- package/dist/server/plugin-bundled.js +68 -0
- package/dist/server/plugin-catalog-sync.js +0 -37
- package/dist/server/plugin-catalog.js +13 -67
- package/dist/server/plugin-chat-attachments.js +0 -1
- package/dist/server/plugin-conversation-view.js +0 -20
- package/dist/server/plugin-dom.js +1 -23
- package/dist/server/plugin-facilities.js +4 -115
- package/dist/server/plugin-grants.js +2 -90
- package/dist/server/plugin-install-spec.js +0 -43
- package/dist/server/plugin-installer.js +34 -75
- package/dist/server/plugin-llm.js +4 -38
- package/dist/server/plugin-manifest-validate.js +0 -31
- package/dist/server/plugin-permissions.js +1 -24
- package/dist/server/plugin-project.js +7 -129
- package/dist/server/plugin-removal.js +1 -8
- package/dist/server/plugin-schedule.js +1 -38
- package/dist/server/plugin-secrets.js +3 -16
- package/dist/server/plugin-tool-guard.js +1 -28
- package/dist/server/plugin-ui-slots.js +0 -4
- package/dist/server/plugin-updater.js +15 -90
- package/dist/server/plugins.js +71 -619
- package/dist/server/present-files-tool.js +0 -57
- package/dist/server/preset-fields.js +24 -61
- package/dist/server/preset-plugin-dependencies.js +0 -2
- package/dist/server/preset-share.js +4 -172
- package/dist/server/process-utils.js +4 -80
- package/dist/server/prompt-assembler.js +2 -30
- package/dist/server/prompt-base-store.js +0 -47
- package/dist/server/prompt-composer.js +21 -98
- package/dist/server/prompt-templates.js +0 -2
- package/dist/server/protocol-version.js +1 -11
- package/dist/server/protocol.js +0 -5
- package/dist/server/queue-modes.js +0 -3
- package/dist/server/queue-utils.js +0 -40
- package/dist/server/quick-ask-context.js +384 -0
- package/dist/server/quick-ask-settings.js +61 -0
- package/dist/server/quick-ask.js +260 -0
- package/dist/server/read-tool.js +0 -65
- package/dist/server/reasoning-registry.js +1 -29
- package/dist/server/remote-cli-persistence.js +373 -0
- package/dist/server/remote-native-cli.js +78 -0
- package/dist/server/remote-ssh-service.js +481 -190
- package/dist/server/request-context.js +0 -9
- package/dist/server/resolve-global-sdk.js +55 -31
- package/dist/server/sandbox-data.js +0 -1
- package/dist/server/sandbox-engines.js +0 -1
- package/dist/server/sandbox-runtime-gate.js +0 -3
- package/dist/server/sandbox-service.js +0 -41
- package/dist/server/sandbox-tool.js +0 -20
- package/dist/server/schedule-agent-tool.js +2 -31
- package/dist/server/scheduler-tasks.js +32 -56
- package/dist/server/scm-commitmsg.js +0 -53
- package/dist/server/scm.js +3 -48
- package/dist/server/sdk-builtin-extensions.js +2 -29
- package/dist/server/sdk-origin.js +0 -45
- package/dist/server/serialize.js +2 -92
- package/dist/server/server-config.js +0 -11
- package/dist/server/session-branch.js +1 -87
- package/dist/server/session-list-scan.js +215 -0
- package/dist/server/session-open.js +69 -0
- package/dist/server/session-parser.js +4 -54
- package/dist/server/session-scan.js +81 -45
- package/dist/server/session-search.js +0 -56
- package/dist/server/settings-service.js +19 -126
- package/dist/server/setup-config.js +0 -2
- package/dist/server/setup-page.js +0 -9
- package/dist/server/skill-content-filler.js +0 -17
- package/dist/server/skill-discovery.js +5 -92
- package/dist/server/skill-maintenance.js +1 -28
- package/dist/server/skill-tool.js +0 -30
- package/dist/server/slash-commands.js +5 -50
- package/dist/server/soft-cap.js +3 -40
- package/dist/server/startup-banner.js +0 -8
- package/dist/server/subagent-handoff.js +0 -11
- package/dist/server/subagent-helpers.js +2 -17
- package/dist/server/subagent-notify.js +0 -19
- package/dist/server/subagent-security-gate.js +0 -50
- package/dist/server/subagent-task.js +0 -9
- package/dist/server/subagent-templates-hant.js +0 -10
- package/dist/server/subagent-templates.js +3 -103
- package/dist/server/subagents.js +1 -87
- package/dist/server/system-screenshot-windows.js +259 -0
- package/dist/server/system-screenshot.js +77 -0
- package/dist/server/tabs.js +3 -48
- package/dist/server/terminals.js +559 -586
- package/dist/server/text-quote.js +0 -12
- package/dist/server/text-sniff.js +2 -52
- package/dist/server/themes.js +2 -41
- package/dist/server/tool-approval.js +0 -47
- package/dist/server/tool-guards.js +0 -90
- package/dist/server/tool-host-factories.js +1 -16
- package/dist/server/tool-info.js +0 -13
- package/dist/server/tool-manager.js +1 -229
- package/dist/server/tool-overrides.js +1 -46
- package/dist/server/tool-prompt-overrides.js +1 -30
- package/dist/server/tool-prompts.js +0 -14
- package/dist/server/tool-signature.js +0 -25
- package/dist/server/transcript-prepare.js +55 -0
- package/dist/server/tts-routes.js +58 -0
- package/dist/server/tts-service.js +106 -0
- package/dist/server/tts-system.js +160 -0
- package/dist/server/turn-timing.js +0 -1
- package/dist/server/unauthorized-page.js +0 -8
- package/dist/server/universal/driver-base.js +2 -31
- package/dist/server/universal/drivers/claude-code.js +98 -194
- package/dist/server/universal/drivers/codex.js +12 -35
- package/dist/server/universal/drivers/mock-driver.js +1 -11
- package/dist/server/universal/index.js +0 -3
- package/dist/server/universal/session-store.js +4 -21
- package/dist/server/universal/universal-attachments.js +2 -36
- package/dist/server/universal/universal-service.js +5 -24
- package/dist/server/universal/universal-session.js +30 -148
- package/dist/server/universal/universal-types.js +0 -3
- package/dist/server/update-check.js +6 -182
- package/dist/server/uploads.js +4 -43
- package/dist/server/virtual-tui.js +2 -27
- package/dist/server/vision-bridge.js +0 -27
- package/dist/server/wait-subscription-scan.js +13 -115
- package/dist/server/webui-context.js +2 -87
- package/dist/server/workspace-handle.js +373 -0
- package/dist/server/workspace-snapshot.js +7 -113
- package/dist/server/worktree-service.js +2 -53
- package/dist/server/worktree-tool.js +0 -11
- package/dist/server/ws-client-id.js +0 -18
- package/dist/server/ws-pending-queue.js +0 -7
- package/dist/server/ws-unknown-types.js +0 -17
- package/docs/README.md +24 -17
- package/docs/architecture-plugins.md +55 -6
- package/docs/device-center.md +57 -23
- package/docs/device-desktop.md +3 -3
- package/docs/group-orchestration.md +142 -0
- package/docs/hub-upgrade-release-testing.md +46 -0
- package/extensions/webui.ts +3 -74
- package/package.json +9 -6
- package/plugin-sdk/README.md +22 -8
- package/plugin-sdk/client-utils.mjs +0 -7
- package/plugin-sdk/client.d.ts +26 -0
- package/plugin-sdk/client.mjs +52 -0
- package/plugin-sdk/import-check.mjs +4 -51
- package/plugin-sdk/index.d.ts +128 -117
- package/plugin-sdk/index.mjs +2 -687
- package/plugin-sdk/package.json +15 -4
- package/plugin-sdk/ssh-host-trust.mjs +0 -12
- package/plugin-sdk/testing.d.ts +9 -0
- package/plugin-sdk/testing.mjs +511 -0
- package/plugins/catalog.json +52 -4
- package/plugins/superagent/README.md +110 -0
- package/plugins/superagent/client/entry.mjs +21 -0
- package/plugins/superagent/index.mjs +8 -0
- package/plugins/superagent/main.mjs +218 -0
- package/plugins/superagent/manifest.json +15 -0
- package/plugins/superagent/server.mjs +572 -0
- package/plugins/superagent/style.css +167 -0
- package/themes/aetheris.css +1 -31
- package/themes/ayu-light.css +0 -1
- package/themes/bases/flow-base.css +2 -83
- package/themes/bases/obsidian-base.css +2 -37
- package/themes/bases/statusbar-flat-base.css +0 -1
- package/themes/bases/zhujian-base.css +0 -63
- package/themes/bases/zhupi-base.css +0 -64
- package/themes/catppuccin-latte.css +0 -1
- package/themes/catppuccin.css +0 -1
- package/themes/claude-code-dark.css +0 -1
- package/themes/codex.css +0 -1
- package/themes/dark-teal.css +22 -54
- package/themes/everforest-light.css +0 -1
- package/themes/flow-cristallo.css +160 -0
- package/themes/flow-ink.css +160 -0
- package/themes/flow-light.css +1 -10
- package/themes/flow-obsidian.css +160 -0
- package/themes/flow-zurich.css +160 -0
- package/themes/flow.css +1 -9
- package/themes/geist.css +0 -1
- package/themes/gruvbox-light.css +0 -1
- package/themes/kanagawa-lotus.css +0 -1
- package/themes/md-preview.css +1 -2
- package/themes/mist.css +0 -1
- package/themes/nord.css +0 -1
- package/themes/one-dark.css +0 -1
- package/themes/paper.css +0 -1
- package/themes/rose-pine-dawn.css +0 -1
- package/themes/sakura.css +0 -1
- package/themes/solarized-light.css +0 -1
- package/themes/tokyo-night.css +0 -1
- package/themes/translucent.css +4 -35
- package/themes/transparent.css +4 -41
- package/themes/vs-code-dark.css +0 -1
- package/themes/wallpaper-flow.css +3 -17
- package/themes/wallpaper-obsidian.css +1 -4
- package/themes/white.css +0 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BDoOpj-F.js → BgTasksModal-D-x7kA63.js} +1 -1
- package/web/dist/assets/CanvasStudio-CAWcs9tm.js +1579 -0
- package/web/dist/assets/DeviceCenter-Dc0whRcu.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +1 -0
- package/web/dist/assets/DeviceGroups-C_fZMNeK.js +1 -0
- package/web/dist/assets/{Dropdown-C4LIhshN.js → Dropdown-CTgVLUbp.js} +1 -1
- package/web/dist/assets/FilePreview-C6W0PvaK.js +2 -0
- package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +1 -0
- package/web/dist/assets/GroupConversation-C81YjF2C.js +61 -0
- package/web/dist/assets/GroupWorkItems-BIvZtr10.js +1 -0
- package/web/dist/assets/{HintTip-c6d0TJoh.js → HintTip-Da6qc566.js} +1 -1
- package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +2 -0
- package/web/dist/assets/NativeCliPanel-CU1rZmyu.js +5 -0
- package/web/dist/assets/{PiSetupModal-BmMrrgB9.js → PiSetupModal-DZKY5Wiw.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
- package/web/dist/assets/SCMPanel-CuEgzAlO.js +2 -0
- package/web/dist/assets/SettingsModal-Cdu5h29p.js +33 -0
- package/web/dist/assets/TermXterm-Bt5WKAxP.js +3 -0
- package/web/dist/assets/TerminalPanel-BCIBV8se.js +1 -0
- package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +1 -0
- package/web/dist/assets/app-globals-CZjFtI4F.js +129 -0
- package/web/dist/assets/canvas-client-WkhM55mR.js +1 -0
- package/web/dist/assets/composer-bridge-CImnjDHq.js +1 -0
- package/web/dist/assets/desktop-B8NZ3KW-.js +1 -0
- package/web/dist/assets/index-CQc3VrWa.css +1 -0
- package/web/dist/assets/index-D_AGu4Zv.js +404 -0
- package/web/dist/assets/plugin-host-uqZGpvCs.js +1 -0
- package/web/dist/assets/{remote-ssh-client-CfYSMEZg.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
- package/web/dist/assets/theme-DGL7hLUs.js +1 -0
- package/web/dist/index.html +12 -11
- package/web/dist/sw.js +15 -61
- package/web/public/sw.js +14 -60
- package/dist/gh-comment-781.md +0 -5
- package/dist/server/device-center/local-page.js +0 -17
- package/dist/server/device-center/smoke-preview.js +0 -3
- package/dist/server/durable/durable-capabilities.js +0 -11
- package/dist/server/markers/builtins/services.js +0 -123
- package/dist/server/markers/builtins/todo.js +0 -189
- package/dist/server/markers-list-tool.js +0 -34
- package/dist/server/orchestrator.js +0 -109
- package/dist/server/patch-turn-end-boundary.js +0 -77
- package/dist/server/system-prompt-soul.js +0 -41
- package/dist/server/univer-service.js +0 -448
- package/dist/server/universal/drivers/dsh-driver.js +0 -379
- package/dist/test-artifact.md +0 -9
- package/dist/test-preview-modal.md +0 -11
- package/dist/test-report.html +0 -20
- package/web/dist/assets/BgTasksModal-C0i3O1FT.js +0 -1
- package/web/dist/assets/CanvasStudio-B8thymBN.js +0 -1579
- package/web/dist/assets/CanvasStudio-zSxyIx1R.js +0 -1579
- package/web/dist/assets/DeviceCenter-DfAHKcid.js +0 -3
- package/web/dist/assets/DeviceCenter-ydvOTlzE.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-q5Ik8oXg.js +0 -1
- package/web/dist/assets/DeviceGroups-CI14_SRb.js +0 -1
- package/web/dist/assets/DeviceGroups-DvsB5IEU.js +0 -1
- package/web/dist/assets/FilePreview-BgGongmv.js +0 -2
- package/web/dist/assets/FilePreview-D4NrhF-U.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BWgU8yPd.js +0 -1
- package/web/dist/assets/GlobalSearchModal-F7fNimKk.js +0 -1
- package/web/dist/assets/GroupConversation-Dh71Pdb-.js +0 -17
- package/web/dist/assets/GroupConversation-ZK3nRmNm.js +0 -17
- package/web/dist/assets/ModelConfigModal-YVEgyy34.js +0 -2
- package/web/dist/assets/ModelConfigModal-vWtg3srp.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-BGSBIKD7.js +0 -1
- package/web/dist/assets/SCMPanel-B8_EDxNr.js +0 -2
- package/web/dist/assets/SCMPanel-BU58qk3T.js +0 -2
- package/web/dist/assets/SettingsModal-CMUybq3J.js +0 -32
- package/web/dist/assets/SettingsModal-OBmGTh-5.js +0 -32
- package/web/dist/assets/TerminalPanel-0CYvD72B.js +0 -3
- package/web/dist/assets/TerminalPanel-DDavKvFr.js +0 -3
- package/web/dist/assets/TuiOverlayModal-BsA-QTvN.js +0 -1
- package/web/dist/assets/TuiOverlayModal-DzoVQBuG.js +0 -1
- package/web/dist/assets/app-globals-CZxzGvIo.js +0 -123
- package/web/dist/assets/canvas-client-CUnXlQYX.js +0 -1
- package/web/dist/assets/desktop-aAKpvKJV.js +0 -1
- package/web/dist/assets/index-C6DwztqE.css +0 -1
- package/web/dist/assets/index-CuN802Sj.js +0 -93
- package/web/dist/assets/index-EH5Fw9fa.js +0 -93
- package/web/dist/assets/plugin-host-BRWib9DF.js +0 -1
- package/web/dist/assets/theme-D2l_mLNo.js +0 -1
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* client-state — 每浏览器客户端的持久化 UI 状态(<dataDir>/client-state.json):
|
|
3
|
-
* 最近项目/工作目录、目标审查偏好、设置面板状态(提示词模式 + 技能/插件开关 +
|
|
4
|
-
* 视觉桥偏好)、命名预设。文件 I/O 一律 best-effort:持久化故障绝不能
|
|
5
|
-
* 弄崩 server 或阻塞会话。
|
|
6
|
-
*
|
|
7
|
-
* 从 agent-service.ts 抽出,行为保持不变。
|
|
8
|
-
*/
|
|
9
1
|
import { readFileSync } from "node:fs";
|
|
2
|
+
import { normalizeNativeCliInheritModel } from "./engine-catalog.js";
|
|
10
3
|
import { normalizeUploadMaxMb } from "./payload-limits.js";
|
|
11
4
|
import * as fsPromises from "node:fs/promises";
|
|
12
5
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
13
6
|
import { writeJsonAtomicSync } from "./atomic-file.js";
|
|
14
|
-
import { normalizeSoftCapByModel, normalizeSoftCapTokens } from "./soft-cap.js";
|
|
7
|
+
import { normalizeAutoCompactionInstructions, normalizeSoftCapByModel, normalizeSoftCapTokens } from "./soft-cap.js";
|
|
15
8
|
import { deriveLegacy, legacyToDisabled, normalizeDisabledAgentTools } from "./tool-manager.js";
|
|
16
9
|
import { normalizeToolPromptOverrides } from "./tool-prompt-overrides.js";
|
|
17
10
|
import { UI_SLOTS } from "./plugin-ui-slots.js";
|
|
18
11
|
import { DEFAULT_PROMPT_DISABLED } from "./prompt-composer.js";
|
|
19
|
-
|
|
12
|
+
import { mergeQuickAskSettings, normalizeQuickAskSettings } from "./quick-ask-settings.js";
|
|
20
13
|
export function normalizeQueueMode(value) {
|
|
21
14
|
return value === "one-at-a-time" ? value : "all";
|
|
22
15
|
}
|
|
@@ -30,20 +23,14 @@ export function normalizePromptDisabled(stored) {
|
|
|
30
23
|
}
|
|
31
24
|
return list;
|
|
32
25
|
}
|
|
33
|
-
/** 大模型 API 出错自动重试次数的默认值(SDK 默认 3)。 */
|
|
34
26
|
export const DEFAULT_RETRY_MAX_ATTEMPTS = 6;
|
|
35
|
-
/** 工具执行看门狗超时的默认值(默认 20 分钟;环境变量 PI_WEB_TOOL_TIMEOUT_MS 覆盖)。 */
|
|
36
27
|
export const DEFAULT_TOOL_WATCHDOG_TIMEOUT_MS = (() => {
|
|
37
28
|
const v = Number(process.env.PI_WEB_TOOL_TIMEOUT_MS);
|
|
38
29
|
return Number.isFinite(v) && v >= 0 ? v : 20 * 60_000;
|
|
39
30
|
})();
|
|
40
|
-
/** 消息列表尾部「常驻渲染」消息条数的默认值:更早的消息折叠为摘要行
|
|
41
|
-
* (见 web/src/components/MessageList.tsx 的 recentStart)。默认与原硬编码
|
|
42
|
-
* KEEP_RECENT 一致(15),想要更大窗口在设置面板「常驻渲染消息数」里开。纯 UI 偏好。 */
|
|
43
31
|
export const DEFAULT_KEEP_RECENT_MESSAGES = 15;
|
|
44
32
|
export const KEEP_RECENT_MESSAGES_MIN = 5;
|
|
45
33
|
export const KEEP_RECENT_MESSAGES_MAX = 100;
|
|
46
|
-
/** 归一化常驻渲染消息数:缺省/非数值回落默认值;有效整数钳到 [5, 100]。 */
|
|
47
34
|
export function normalizeKeepRecentMessages(v) {
|
|
48
35
|
if (v === null || v === undefined || v === "")
|
|
49
36
|
return DEFAULT_KEEP_RECENT_MESSAGES;
|
|
@@ -56,7 +43,6 @@ export function normalizeKeepRecentMessages(v) {
|
|
|
56
43
|
return KEEP_RECENT_MESSAGES_MAX;
|
|
57
44
|
return n;
|
|
58
45
|
}
|
|
59
|
-
/** 归一化工具看门狗超时(毫秒):0 = 禁用;非数值、负数或空值回落默认值,非负整数保留。 */
|
|
60
46
|
export function normalizeToolWatchdogTimeoutMs(v) {
|
|
61
47
|
if (v === null || v === undefined || v === "")
|
|
62
48
|
return DEFAULT_TOOL_WATCHDOG_TIMEOUT_MS;
|
|
@@ -65,10 +51,7 @@ export function normalizeToolWatchdogTimeoutMs(v) {
|
|
|
65
51
|
return DEFAULT_TOOL_WATCHDOG_TIMEOUT_MS;
|
|
66
52
|
return n;
|
|
67
53
|
}
|
|
68
|
-
/** 「后台任务」自动清理阈值的合法档位(分钟)。0 = 关。 */
|
|
69
54
|
export const BG_CLEANUP_MINUTES = [0, 15, 30, 60, 120];
|
|
70
|
-
/** 归一化自动清理阈值(分钟):只认档位表里的值(脏值按最近档位下取,负数/非数回落 0 = 关)。
|
|
71
|
-
* 默认关 —— 杀进程是破坏性动作,不替用户做主。 */
|
|
72
55
|
export function normalizeBgCleanupMinutes(v) {
|
|
73
56
|
const n = Math.floor(Number(v));
|
|
74
57
|
if (!Number.isFinite(n) || n <= 0)
|
|
@@ -79,14 +62,7 @@ export function normalizeBgCleanupMinutes(v) {
|
|
|
79
62
|
best = step;
|
|
80
63
|
return best;
|
|
81
64
|
}
|
|
82
|
-
/** 工具自己声明超时时留给它的余量(毫秒):让工具先自己超时并返回错误,
|
|
83
|
-
* 而不是看门狗先下手把整轮对话 abort 掉。 */
|
|
84
65
|
export const TOOL_WATCHDOG_EXPLICIT_GRACE_MS = 5_000;
|
|
85
|
-
/** 计算单次工具调用的有效看门狗超时(毫秒;≤0 = 不布看门狗)。
|
|
86
|
-
* 基础值来自设置/环境变量(见 DEFAULT_TOOL_WATCHDOG_TIMEOUT_MS);**若工具调用
|
|
87
|
-
* 自己声明了更长的超时**(目前只有 bash 的 `args.timeout`,单位秒),自动顺延到
|
|
88
|
-
* 「工具超时 + 余量」—— 否则 AI 明确要求跑 90 分钟的命令,会被 20 分钟的看门狗
|
|
89
|
-
* 连同整轮对话一起剁掉。纯函数,可单测。 */
|
|
90
66
|
export function effectiveToolWatchdogMs(baseMs, toolName, args) {
|
|
91
67
|
if (!Number.isFinite(baseMs) || baseMs <= 0)
|
|
92
68
|
return 0;
|
|
@@ -99,10 +75,6 @@ export function effectiveToolWatchdogMs(baseMs, toolName, args) {
|
|
|
99
75
|
}
|
|
100
76
|
return ms;
|
|
101
77
|
}
|
|
102
|
-
/** 归一化插件 AI 工具禁用名单:只收非空字符串(去重,上限 256 个)。
|
|
103
|
-
* 与 disabledAgentTools 不同——插件工具名是动态的(注册才知道),不能按
|
|
104
|
-
* 固定目录校验;未知/已卸载插件的条目刻意保留(重装后仍保持关闭)。
|
|
105
|
-
* 纯函数,可单测。 */
|
|
106
78
|
export function normalizeDisabledPluginTools(v) {
|
|
107
79
|
if (!Array.isArray(v))
|
|
108
80
|
return [];
|
|
@@ -119,14 +91,12 @@ export function normalizeDisabledPluginTools(v) {
|
|
|
119
91
|
}
|
|
120
92
|
return out;
|
|
121
93
|
}
|
|
122
|
-
/** 归一化重试次数:非数值回落默认,钳制到 [0, 100] 整数。 */
|
|
123
94
|
export function normalizeRetryMaxAttempts(v) {
|
|
124
95
|
const n = Math.floor(Number(v));
|
|
125
96
|
if (!Number.isFinite(n))
|
|
126
97
|
return DEFAULT_RETRY_MAX_ATTEMPTS;
|
|
127
98
|
return Math.min(100, Math.max(0, n));
|
|
128
99
|
}
|
|
129
|
-
/** 子代理无人类干预连续自动唤醒上限轮数的默认值(默认 5;0 = 不限制;环境变量 PI_WEB_SUBAGENT_AUTO_WAKE_MAX_TURNS 覆盖)。 */
|
|
130
100
|
export function defaultSubagentAutoWakeMaxTurns() {
|
|
131
101
|
const raw = process.env.PI_WEB_SUBAGENT_AUTO_WAKE_MAX_TURNS;
|
|
132
102
|
if (raw !== undefined && raw.trim() !== "") {
|
|
@@ -137,7 +107,6 @@ export function defaultSubagentAutoWakeMaxTurns() {
|
|
|
137
107
|
}
|
|
138
108
|
return 5;
|
|
139
109
|
}
|
|
140
|
-
/** 归一化子代理自动唤醒轮数上限:缺省/非数回落默认值;有效整数(0 = 不限制)。 */
|
|
141
110
|
export function normalizeSubagentAutoWakeMaxTurns(v) {
|
|
142
111
|
if (v === null || v === undefined || v === "")
|
|
143
112
|
return defaultSubagentAutoWakeMaxTurns();
|
|
@@ -146,11 +115,6 @@ export function normalizeSubagentAutoWakeMaxTurns(v) {
|
|
|
146
115
|
return defaultSubagentAutoWakeMaxTurns();
|
|
147
116
|
return n;
|
|
148
117
|
}
|
|
149
|
-
/**
|
|
150
|
-
* 归一化 UI 布局偏好(UiLayoutPrefs):只收字符串数组 / 字符串字典,去重 + 长度上限。
|
|
151
|
-
* 脏数据(数字、对象、超长 key、嵌套)一律丢弃而不是整份回落 —— 用户手动调过的那部分
|
|
152
|
-
* 不该因为插件写坏了一个字段就全丢。
|
|
153
|
-
*/
|
|
154
118
|
export function normalizeUiLayout(v) {
|
|
155
119
|
if (!v || typeof v !== "object" || Array.isArray(v))
|
|
156
120
|
return {};
|
|
@@ -174,7 +138,6 @@ export function normalizeUiLayout(v) {
|
|
|
174
138
|
}
|
|
175
139
|
return Object.keys(out).length ? out : undefined;
|
|
176
140
|
};
|
|
177
|
-
// 品牌二合一迁移:旧 host:brand-logo/host:brand-name → host:brand(去重;显式新值赢)。
|
|
178
141
|
const BRAND_NEW = "host:brand";
|
|
179
142
|
const isBrandOld = (id) => id === "host:brand-logo" || id === "host:brand-name";
|
|
180
143
|
const mapBrandList = (list) => {
|
|
@@ -188,7 +151,6 @@ export function normalizeUiLayout(v) {
|
|
|
188
151
|
}
|
|
189
152
|
return out.length ? out : undefined;
|
|
190
153
|
};
|
|
191
|
-
/** 旧品牌 key 折进 host:brand:logo 优先还是名称优先由调用方定(对齐/分组跟 logo,走名称)。 */
|
|
192
154
|
const foldBrandDict = (src, logoFirst) => {
|
|
193
155
|
if (!src)
|
|
194
156
|
return undefined;
|
|
@@ -212,7 +174,6 @@ export function normalizeUiLayout(v) {
|
|
|
212
174
|
const order = mapBrandList(arr(o.order, 200));
|
|
213
175
|
const groups = foldBrandDict(dict(o.groups, 200), true);
|
|
214
176
|
const labels = foldBrandDict(dict(o.labels, 200), false);
|
|
215
|
-
// 用户对齐:只收 start/center/end(手改脏值回落丢弃,不污染合并结果)。
|
|
216
177
|
let align;
|
|
217
178
|
if (o.align && typeof o.align === "object" && !Array.isArray(o.align)) {
|
|
218
179
|
align = {};
|
|
@@ -224,7 +185,6 @@ export function normalizeUiLayout(v) {
|
|
|
224
185
|
if (Object.keys(align).length === 0)
|
|
225
186
|
align = undefined;
|
|
226
187
|
}
|
|
227
|
-
// 品牌对齐同样折进 host:brand(跟 logo 的值,显式新值赢)。
|
|
228
188
|
if (align && ("host:brand-logo" in align || "host:brand-name" in align)) {
|
|
229
189
|
const out = {};
|
|
230
190
|
for (const [k, val] of Object.entries(align)) {
|
|
@@ -239,11 +199,8 @@ export function normalizeUiLayout(v) {
|
|
|
239
199
|
}
|
|
240
200
|
align = Object.keys(out).length ? out : undefined;
|
|
241
201
|
}
|
|
242
|
-
// 顶栏按钮文字总开关:只收布尔值(缺席 = 显示,兼容老存档)。
|
|
243
202
|
const topbarText = typeof o.topbarText === "boolean" ? o.topbarText : undefined;
|
|
244
|
-
// 侧边图标停靠栏形态:只收布尔值(缺席 = 贴边槽位)。
|
|
245
203
|
const sideDockFloat = typeof o.sideDockFloat === "boolean" ? o.sideDockFloat : undefined;
|
|
246
|
-
// 用户自定义槽位/位置:只收合法 slot 字符串
|
|
247
204
|
let slots;
|
|
248
205
|
if (o.slots && typeof o.slots === "object" && !Array.isArray(o.slots)) {
|
|
249
206
|
slots = {};
|
|
@@ -255,7 +212,6 @@ export function normalizeUiLayout(v) {
|
|
|
255
212
|
if (Object.keys(slots).length === 0)
|
|
256
213
|
slots = undefined;
|
|
257
214
|
}
|
|
258
|
-
// 品牌槽位同样折进 host:brand
|
|
259
215
|
if (slots && ("host:brand-logo" in slots || "host:brand-name" in slots)) {
|
|
260
216
|
const out = {};
|
|
261
217
|
for (const [k, val] of Object.entries(slots)) {
|
|
@@ -282,50 +238,39 @@ export function normalizeUiLayout(v) {
|
|
|
282
238
|
...(slots ? { slots } : {}),
|
|
283
239
|
};
|
|
284
240
|
}
|
|
285
|
-
/** 归一化技能名单:字符串数组原样过滤;其他(含旧 bool 开关)回落空数组。 */
|
|
286
241
|
export function normalizeSkillList(v) {
|
|
287
242
|
return Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
|
|
288
243
|
}
|
|
289
244
|
export const DEFAULT_SKILLS_CATALOG_MAX_DESC = 250;
|
|
290
245
|
export const DEFAULT_SKILLS_CATALOG_BUDGET = 20000;
|
|
291
|
-
/** 技能正文上限(与 #819 的设置项同口径):单文件 8KB、全文注入总量 32KB。
|
|
292
|
-
* 默认值 = 历史硬编码值,老用户升级后行为不变。 */
|
|
293
246
|
export const DEFAULT_SKILLS_MAX_FILE_BYTES = 8192;
|
|
294
247
|
export const DEFAULT_SKILLS_FULL_TEXT_MAX_BYTES = 32768;
|
|
295
|
-
/** 上限的硬边界:设置可调但不能把上下文预算彻底关掉(1MB / 4MB)。 */
|
|
296
248
|
export const MAX_SKILLS_MAX_FILE_BYTES = 1024 * 1024;
|
|
297
249
|
export const MAX_SKILLS_FULL_TEXT_MAX_BYTES = 4 * 1024 * 1024;
|
|
298
|
-
/** 归一化单文件技能正文上限:0..1MB 的整数,非法/未设置回退 8192。0 = 不设单文件上限。 */
|
|
299
250
|
export function normalizeSkillsMaxFileBytes(v) {
|
|
300
251
|
if (typeof v === "number" && Number.isFinite(v) && v >= 0) {
|
|
301
252
|
return Math.min(Math.floor(v), MAX_SKILLS_MAX_FILE_BYTES);
|
|
302
253
|
}
|
|
303
254
|
return DEFAULT_SKILLS_MAX_FILE_BYTES;
|
|
304
255
|
}
|
|
305
|
-
/** 归一化全文注入总量上限:0..4MB 的整数,非法/未设置回退 32768。0 = 不设总量上限。 */
|
|
306
256
|
export function normalizeSkillsFullTextMaxBytes(v) {
|
|
307
257
|
if (typeof v === "number" && Number.isFinite(v) && v >= 0) {
|
|
308
258
|
return Math.min(Math.floor(v), MAX_SKILLS_FULL_TEXT_MAX_BYTES);
|
|
309
259
|
}
|
|
310
260
|
return DEFAULT_SKILLS_FULL_TEXT_MAX_BYTES;
|
|
311
261
|
}
|
|
312
|
-
/** 归一化技能名录单描述字符数截断:>=0 整数,非法/未设置回退 250。0 为不截断。 */
|
|
313
262
|
export function normalizeSkillsCatalogMaxDesc(v) {
|
|
314
263
|
if (typeof v === "number" && Number.isFinite(v) && v >= 0) {
|
|
315
264
|
return Math.floor(v);
|
|
316
265
|
}
|
|
317
266
|
return DEFAULT_SKILLS_CATALOG_MAX_DESC;
|
|
318
267
|
}
|
|
319
|
-
/** 归一化技能名录总字符预算:>=0 整数,非法/未设置回退 20000。0 为不设限。 */
|
|
320
268
|
export function normalizeSkillsCatalogBudget(v) {
|
|
321
269
|
if (typeof v === "number" && Number.isFinite(v) && v >= 0) {
|
|
322
270
|
return Math.floor(v);
|
|
323
271
|
}
|
|
324
272
|
return DEFAULT_SKILLS_CATALOG_BUDGET;
|
|
325
273
|
}
|
|
326
|
-
/** 工具延迟加载的**出厂默认**(默认关:模型忘记加载会先吃一次 `Tool <name> not found`,
|
|
327
|
-
* 开箱即用优先——见 #652;`PI_WEB_TOOL_LAZY_LOADING=1/true/on/yes` 部署级打开,给
|
|
328
|
-
* 「想省上下文、愿意让模型多一步 load_tools」的实例一个开关;用户在设置面板的选择优先于此)。 */
|
|
329
274
|
export const DEFAULT_TOOL_LAZY_LOADING = (() => {
|
|
330
275
|
const v = (process.env.PI_WEB_TOOL_LAZY_LOADING ?? "").trim().toLowerCase();
|
|
331
276
|
return v === "1" || v === "true" || v === "on" || v === "yes";
|
|
@@ -341,7 +286,6 @@ export function normalizeCodemodeInlineBudget(v) {
|
|
|
341
286
|
}
|
|
342
287
|
return DEFAULT_CODEMODE_INLINE_BUDGET;
|
|
343
288
|
}
|
|
344
|
-
/** 预设 → 设置面板列表用的 UI 形状(协议要求字段完整:旧/部分预设用默认值补齐)。 */
|
|
345
289
|
export function settingsPresetToUi(p) {
|
|
346
290
|
return {
|
|
347
291
|
name: p.name,
|
|
@@ -357,23 +301,12 @@ export function settingsPresetToUi(p) {
|
|
|
357
301
|
reviewDisabledSkills: [...(p.reviewDisabledSkills ?? [])],
|
|
358
302
|
};
|
|
359
303
|
}
|
|
360
|
-
/** Stable identity of an extension for the enable/disable toggle: the npm
|
|
361
|
-
* spec for packages (survives version bumps), the resolved entry path
|
|
362
|
-
* otherwise. */
|
|
363
304
|
export function extensionKey(e) {
|
|
364
305
|
const src = e.sourceInfo;
|
|
365
306
|
if (src?.origin === "package" && src.source)
|
|
366
307
|
return src.source;
|
|
367
308
|
return src?.path ?? e.path;
|
|
368
309
|
}
|
|
369
|
-
/** All identities an extension may be disabled by. The SDK applies
|
|
370
|
-
* `sourceInfo` only AFTER extensionsOverride runs (resource-loader reload():
|
|
371
|
-
* override first, applyExtensionSourceInfo second), so inside the override a
|
|
372
|
-
* package extension still has no sourceInfo and extensionKey() falls back to
|
|
373
|
-
* the raw entry path — which never matches the "npm:<pkg>" id the settings
|
|
374
|
-
* panel stores. Derive the package name from the entry path
|
|
375
|
-
* (.../node_modules/<pkg>/... or .../node_modules/@scope/<pkg>/...) so both
|
|
376
|
-
* sides agree. */
|
|
377
310
|
export function extensionKeyCandidates(e) {
|
|
378
311
|
const keys = new Set([extensionKey(e)]);
|
|
379
312
|
const norm = e.path.replace(/\\/g, "/");
|
|
@@ -381,20 +314,15 @@ export function extensionKeyCandidates(e) {
|
|
|
381
314
|
const idx = norm.lastIndexOf(marker);
|
|
382
315
|
if (idx !== -1) {
|
|
383
316
|
const segs = norm.slice(idx + marker.length).split("/");
|
|
384
|
-
// Scoped package @scope/name spans two segments.
|
|
385
317
|
const name = segs[0]?.startsWith("@") && segs[1] ? `${segs[0]}/${segs[1]}` : segs[0];
|
|
386
318
|
if (name)
|
|
387
319
|
keys.add(`npm:${name}`);
|
|
388
320
|
}
|
|
389
321
|
return [...keys];
|
|
390
322
|
}
|
|
391
|
-
/** 判断一个扩展是否为宿主或 SDK 内部注入的基础设施扩展(如 codemode、tool_search、persona 等),
|
|
392
|
-
* 这些扩展不属于用户安装的业务扩展,不应在设置面板显示,也不受用户启停配置控制。 */
|
|
393
323
|
export function isInternalExtension(e) {
|
|
394
324
|
return Boolean(e.hidden) || e.path.startsWith("<inline:") || e.path.startsWith("<builtin:");
|
|
395
325
|
}
|
|
396
|
-
/** Whether an extension is covered by the disabled list (any identity match).
|
|
397
|
-
* Internal / hidden infrastructure extensions are always exempt. */
|
|
398
326
|
export function isExtensionDisabled(e, disabled) {
|
|
399
327
|
if (isInternalExtension(e))
|
|
400
328
|
return false;
|
|
@@ -403,10 +331,6 @@ export function isExtensionDisabled(e, disabled) {
|
|
|
403
331
|
const keys = extensionKeyCandidates(e);
|
|
404
332
|
return disabled.some((d) => keys.includes(d));
|
|
405
333
|
}
|
|
406
|
-
/** Whether an extension is covered by an ENABLED whitelist (any identity
|
|
407
|
-
* match). Empty whitelist = not whitelisting = everything allowed. Used by
|
|
408
|
-
* subagent templates(白名单语义:模板勾选 = 子代理只加载这些扩展)。
|
|
409
|
-
* Internal / hidden infrastructure extensions are always kept. */
|
|
410
334
|
export function isExtensionEnabled(e, enabled) {
|
|
411
335
|
if (isInternalExtension(e))
|
|
412
336
|
return true;
|
|
@@ -415,14 +339,7 @@ export function isExtensionEnabled(e, enabled) {
|
|
|
415
339
|
const keys = extensionKeyCandidates(e);
|
|
416
340
|
return enabled.some((d) => keys.includes(d));
|
|
417
341
|
}
|
|
418
|
-
/** 额外工作区根(宿主侧多根,issue #146)上限:右栏文件树可切换的根数量。 */
|
|
419
342
|
export const MAX_WORKSPACE_ROOTS = 8;
|
|
420
|
-
/**
|
|
421
|
-
* 归一化「额外工作区根」列表:只收**绝对路径**(相对路径在服务端没有任何可靠基准)、
|
|
422
|
-
* 去重(win32 折大小写)、上限 MAX_WORKSPACE_ROOTS,并 resolve 成规范形式以便与工作区
|
|
423
|
-
* 做前缀比较。脏数据(数字/空串/对象)逐个丢弃而不是整份回落 —— 用户加过的根不该因为
|
|
424
|
-
* 前端传坏了一个元素就全丢。
|
|
425
|
-
*/
|
|
426
343
|
export function normalizeWorkspaceRoots(v) {
|
|
427
344
|
if (!Array.isArray(v))
|
|
428
345
|
return [];
|
|
@@ -445,8 +362,6 @@ export function normalizeWorkspaceRoots(v) {
|
|
|
445
362
|
}
|
|
446
363
|
return out;
|
|
447
364
|
}
|
|
448
|
-
/** 跨平台(尤其是 Windows)路径归一化键:统一转绝对路径,并在 Windows 下转小写以消除大小写与正反斜杠差异。
|
|
449
|
-
* 对于 ssh:// 格式的远程工作区 URI 保持原样不走路径解析。 */
|
|
450
365
|
export function normalizePathKey(p) {
|
|
451
366
|
if (p.startsWith("ssh://")) {
|
|
452
367
|
return p;
|
|
@@ -455,7 +370,6 @@ export function normalizePathKey(p) {
|
|
|
455
370
|
if (process.platform === "win32") {
|
|
456
371
|
return resolve(p).toLowerCase();
|
|
457
372
|
}
|
|
458
|
-
// 在非 Windows 平台(如 Linux CI 或容器)处理 Windows 盘符路径时做跨平台归一化
|
|
459
373
|
if (/^[a-zA-Z]:[\\/]/.test(p)) {
|
|
460
374
|
const drive = p.slice(0, 2).toLowerCase();
|
|
461
375
|
const rest = p.slice(2).replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
@@ -467,16 +381,9 @@ export function normalizePathKey(p) {
|
|
|
467
381
|
return process.platform === "win32" ? p.toLowerCase() : p;
|
|
468
382
|
}
|
|
469
383
|
}
|
|
470
|
-
/** 死 clientId 状态的保留期(issue #441):距最近活跃超过该时长的 per-client 键在
|
|
471
|
-
* 加载/定期扫描时淘汰。取 30 天——clientId 存 sessionStorage,每个标签页每次会话
|
|
472
|
-
* 都生成新 id,远超 30 天才回来的标签页实际等同全新会话,误伤概率可忽略。 */
|
|
473
384
|
export const CLIENT_STATE_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
|
|
474
|
-
/** per-client 键数上限(issue #441):活跃客户端数超过该值时按最近活跃保留前 50、
|
|
475
|
-
* 淘汰最旧的。兜底上限:完全无时间戳可推断的存量键不按年龄淘汰,靠它保证
|
|
476
|
-
* client-state.json 不随时间无界膨胀。 */
|
|
477
385
|
export const MAX_TRACKED_CLIENTS = 50;
|
|
478
|
-
|
|
479
|
-
* 首次加载必扫。 */
|
|
386
|
+
export const RECENT_PROJECTS_MAX = 100;
|
|
480
387
|
export const CLIENT_STATE_SWEEP_INTERVAL_MS = 60 * 60 * 1000;
|
|
481
388
|
function freezeSettings(value) {
|
|
482
389
|
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
@@ -492,34 +399,23 @@ export class ClientStateStore {
|
|
|
492
399
|
settingsVersion = 0;
|
|
493
400
|
settingsSnapshot;
|
|
494
401
|
settingsListeners = new Set();
|
|
495
|
-
/** Subscribe to durable settings commits. Observer failures never turn a successful write into a failure. */
|
|
496
402
|
subscribeSettings(listener) {
|
|
497
403
|
this.settingsListeners.add(listener);
|
|
498
404
|
return () => {
|
|
499
405
|
this.settingsListeners.delete(listener);
|
|
500
406
|
};
|
|
501
407
|
}
|
|
502
|
-
/** O(1) between commits. This frozen snapshot is detached from the writable store. */
|
|
503
408
|
getSettingsSnapshot(clientId) {
|
|
504
409
|
return (this.settingsSnapshot ??= freezeSettings(this.readSettings(clientId)));
|
|
505
410
|
}
|
|
506
411
|
getSettingsVersion() {
|
|
507
412
|
return this.settingsVersion;
|
|
508
413
|
}
|
|
509
|
-
/** 上次死键清理扫描的时间戳(epoch ms;0 = 尚未扫过,首次 load 必扫)。 */
|
|
510
414
|
lastSweepAt = 0;
|
|
511
415
|
constructor(filePath) {
|
|
512
416
|
this.filePath = filePath;
|
|
513
417
|
}
|
|
514
|
-
/** 长期设置(设置面板 config + 预设 + 标记开关)的固定存储键。
|
|
515
|
-
*
|
|
516
|
-
* 为什么用固定全局键而非 per-clientId:clientId 存 sessionStorage(每标签页独立、
|
|
517
|
-
* 关浏览器即失),按 clientId 存设置会在每次新会话/重启后生成新 id → 设置全部重置、
|
|
518
|
-
* 且各标签页/浏览器各有一套互不同步。改为全局共享后:所有客户端(标签页/浏览器)
|
|
519
|
-
* 使用同一套配置,且持久化在服务端,重启不丢(「同一套配置」)。会话级状态
|
|
520
|
-
* (最近项目 / lastCwd / 项目模型与密钥等)仍按 clientId 各自保留。 */
|
|
521
418
|
static GLOBAL_SETTINGS_KEY = "__settings__";
|
|
522
|
-
/** <dataDir>(client-state.json 的上一级)——共享配置(子代理模板库等)落在这里。 */
|
|
523
419
|
get dataDir() {
|
|
524
420
|
return dirname(this.filePath);
|
|
525
421
|
}
|
|
@@ -535,8 +431,6 @@ export class ClientStateStore {
|
|
|
535
431
|
catch {
|
|
536
432
|
this.cache = {};
|
|
537
433
|
}
|
|
538
|
-
// 历史数据迁移:老版本将 removedProjects 仅记在各自临时 clientId 下,升级后新标签页无法继承。
|
|
539
|
-
// 启动/加载时自动将所有老 client 的墓碑合并到全局 __settings__,避免重启或新标签页后已删项目复活。
|
|
540
434
|
let migrated = false;
|
|
541
435
|
const globalState = (this.cache[ClientStateStore.GLOBAL_SETTINGS_KEY] ??= { projects: [] });
|
|
542
436
|
const globalSet = new Set((globalState.removedProjects ?? []).map(normalizePathKey));
|
|
@@ -552,8 +446,24 @@ export class ClientStateStore {
|
|
|
552
446
|
}
|
|
553
447
|
}
|
|
554
448
|
}
|
|
555
|
-
|
|
556
|
-
|
|
449
|
+
const projectsByKey = new Map();
|
|
450
|
+
for (const state of Object.values(this.cache)) {
|
|
451
|
+
for (const project of state.projects ?? []) {
|
|
452
|
+
const key = normalizePathKey(project.path);
|
|
453
|
+
if (globalSet.has(key))
|
|
454
|
+
continue;
|
|
455
|
+
const existing = projectsByKey.get(key);
|
|
456
|
+
if (!existing || project.lastUsed > existing.lastUsed)
|
|
457
|
+
projectsByKey.set(key, project);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
const projects = [...projectsByKey.values()].sort((a, b) => b.lastUsed - a.lastUsed).slice(0, RECENT_PROJECTS_MAX);
|
|
461
|
+
const previousProjects = globalState.projects ?? [];
|
|
462
|
+
if (projects.length !== previousProjects.length ||
|
|
463
|
+
projects.some((p, i) => p.path !== previousProjects[i].path || p.lastUsed !== previousProjects[i].lastUsed)) {
|
|
464
|
+
globalState.projects = projects;
|
|
465
|
+
migrated = true;
|
|
466
|
+
}
|
|
557
467
|
this.lastSweepAt = Date.now();
|
|
558
468
|
const evicted = this.sweepDeadClients();
|
|
559
469
|
if (migrated || evicted > 0) {
|
|
@@ -561,7 +471,6 @@ export class ClientStateStore {
|
|
|
561
471
|
}
|
|
562
472
|
return this.cache;
|
|
563
473
|
}
|
|
564
|
-
/** 死键清理的节流入口:首次 load 必扫,之后按 CLIENT_STATE_SWEEP_INTERVAL_MS 节流。 */
|
|
565
474
|
sweepStaleClientsIfNeeded() {
|
|
566
475
|
if (Date.now() - this.lastSweepAt < CLIENT_STATE_SWEEP_INTERVAL_MS)
|
|
567
476
|
return;
|
|
@@ -569,24 +478,6 @@ export class ClientStateStore {
|
|
|
569
478
|
if (this.sweepDeadClients() > 0)
|
|
570
479
|
this.save();
|
|
571
480
|
}
|
|
572
|
-
/** 淘汰长期不活跃的 per-client 状态(issue #441)。
|
|
573
|
-
*
|
|
574
|
-
* 背景:clientId 存 sessionStorage——每个浏览器标签页每次会话都生成新 id,服务端
|
|
575
|
-
* 却为每个见过的 id 永久建键(projects / workspaceRoots / projectProviderKeys /
|
|
576
|
-
* projectModels…),client-state.json 随死键线性膨胀,save() 的同步
|
|
577
|
-
* JSON.stringify + writeFileSync 成本也随之线性增长。
|
|
578
|
-
*
|
|
579
|
-
* 策略(保守,只动内存态,下次任意 save 自然落盘;绝不直接删文件):
|
|
580
|
-
* - 距最近活跃超过 CLIENT_STATE_RETENTION_MS(30 天)的 clientId 淘汰。活跃时间
|
|
581
|
-
* 优先取显式 lastActive(写路径 touchClient 维护),旧存档回退按
|
|
582
|
-
* max(projects[].lastUsed, interrupted[].at) 推断;推断值写回内存态,随下次
|
|
583
|
-
* save 落盘。完全无时间戳可推断的(无法判定活跃度)不按年龄淘汰,仅受数量上限约束。
|
|
584
|
-
* - 淘汰后仍超过 MAX_TRACKED_CLIENTS(50)时按最近活跃保留前 50,其余淘汰
|
|
585
|
-
* (无时间戳的排最旧优先淘汰)。
|
|
586
|
-
* - 全局键 __settings__ 永不淘汰:设置面板 config / 预设 / 墓碑都在它下面,
|
|
587
|
-
* 与任何 clientId 无关。
|
|
588
|
-
*
|
|
589
|
-
* 返回淘汰的键数(0 = 无变化,调用方无需为此 save)。 */
|
|
590
481
|
sweepDeadClients() {
|
|
591
482
|
const all = this.cache;
|
|
592
483
|
if (!all)
|
|
@@ -621,8 +512,6 @@ export class ClientStateStore {
|
|
|
621
512
|
delete all[id];
|
|
622
513
|
return dead.size;
|
|
623
514
|
}
|
|
624
|
-
/** 打点客户端活跃时间(内存态,随任意后续 save 落盘;不主动触发 save)。
|
|
625
|
-
* 仅在 per-client 写路径上调用,键尚不存在时是 no-op(创建方随后 ??= 补上)。 */
|
|
626
515
|
touchClient(all, clientId) {
|
|
627
516
|
const state = all[clientId];
|
|
628
517
|
if (state)
|
|
@@ -633,7 +522,6 @@ export class ClientStateStore {
|
|
|
633
522
|
writeJsonAtomicSync(this.filePath, this.cache);
|
|
634
523
|
}
|
|
635
524
|
catch (error) {
|
|
636
|
-
// Discard uncommitted mutations; callers must surface persistence failures.
|
|
637
525
|
this.cache = null;
|
|
638
526
|
throw error;
|
|
639
527
|
}
|
|
@@ -641,7 +529,6 @@ export class ClientStateStore {
|
|
|
641
529
|
get(clientId) {
|
|
642
530
|
return this.load()[clientId] ?? { projects: [] };
|
|
643
531
|
}
|
|
644
|
-
/** Remember which workspace a client last used; bumps its project entry. */
|
|
645
532
|
remember(clientId, cwd) {
|
|
646
533
|
const all = this.load();
|
|
647
534
|
const state = (all[clientId] ??= { projects: [] });
|
|
@@ -652,13 +539,13 @@ export class ClientStateStore {
|
|
|
652
539
|
state.projects = [
|
|
653
540
|
{ path: cwd, lastUsed: now },
|
|
654
541
|
...state.projects.filter((p) => normalizePathKey(p.path) !== targetKey),
|
|
655
|
-
].slice(0,
|
|
542
|
+
].slice(0, RECENT_PROJECTS_MAX);
|
|
656
543
|
// Also persist in global settings so new tabs and sessions inherit it immediately
|
|
657
544
|
const globalState = (all[ClientStateStore.GLOBAL_SETTINGS_KEY] ??= { projects: [] });
|
|
658
545
|
globalState.projects = [
|
|
659
546
|
{ path: cwd, lastUsed: now },
|
|
660
547
|
...(globalState.projects ?? []).filter((p) => normalizePathKey(p.path) !== targetKey),
|
|
661
|
-
].slice(0,
|
|
548
|
+
].slice(0, RECENT_PROJECTS_MAX);
|
|
662
549
|
// Opening the workspace again clears its removal tombstone across all clients and global settings.
|
|
663
550
|
for (const cState of Object.values(all)) {
|
|
664
551
|
if (cState.removedProjects?.length) {
|
|
@@ -667,12 +554,6 @@ export class ClientStateStore {
|
|
|
667
554
|
}
|
|
668
555
|
this.save();
|
|
669
556
|
}
|
|
670
|
-
/** Drop one workspace from the recent-project list (user-requested removal).
|
|
671
|
-
* Records a tombstone too: pushProjects() re-discovers cwds from session
|
|
672
|
-
* files on every listing, so without it the entry would instantly reappear.
|
|
673
|
-
* Recorded in both the requesting client and GLOBAL_SETTINGS_KEY so the
|
|
674
|
-
* removal stays across all browser tabs and server restarts until the user
|
|
675
|
-
* explicitly opens that project again. */
|
|
676
557
|
removeProject(clientId, cwd) {
|
|
677
558
|
const all = this.load();
|
|
678
559
|
const targetKey = normalizePathKey(cwd);
|
|
@@ -695,8 +576,6 @@ export class ClientStateStore {
|
|
|
695
576
|
}
|
|
696
577
|
this.save();
|
|
697
578
|
}
|
|
698
|
-
/** Tombstoned projects (explicitly removed by the user) for filtering the
|
|
699
|
-
* merged recent-project list across clients. */
|
|
700
579
|
getRemovedProjects(clientId) {
|
|
701
580
|
const all = this.load();
|
|
702
581
|
const clientRemoved = all[clientId]?.removedProjects ?? [];
|
|
@@ -754,17 +633,13 @@ export class ClientStateStore {
|
|
|
754
633
|
merge(cState.projects);
|
|
755
634
|
}
|
|
756
635
|
}
|
|
757
|
-
|
|
758
|
-
const candidates = [...map.values()].sort((a, b) => b.lastUsed - a.lastUsed).slice(0, 30);
|
|
636
|
+
const candidates = [...map.values()].sort((a, b) => b.lastUsed - a.lastUsed).slice(0, RECENT_PROJECTS_MAX);
|
|
759
637
|
const probes = await Promise.allSettled(candidates.map((p) => this.pathExists(p.path)));
|
|
760
638
|
return candidates.filter((_, i) => {
|
|
761
639
|
const probe = probes[i];
|
|
762
640
|
return probe?.status === "fulfilled" && probe.value;
|
|
763
641
|
});
|
|
764
642
|
}
|
|
765
|
-
/** 单条路径的存活性探测(issue #441):异步 access,绝不阻塞事件循环。
|
|
766
|
-
* 远程工作区 URI (ssh://) 始终判定存活,避免被本地 fs.access 过滤掉。
|
|
767
|
-
* 独立成 protected 方法便于单测用子类覆写做计数探针。 */
|
|
768
643
|
async pathExists(path) {
|
|
769
644
|
if (path.startsWith("ssh://")) {
|
|
770
645
|
return true;
|
|
@@ -804,7 +679,6 @@ export class ClientStateStore {
|
|
|
804
679
|
this.save();
|
|
805
680
|
}
|
|
806
681
|
}
|
|
807
|
-
/** Last-used goal/review prefs for a client, or undefined if never set. */
|
|
808
682
|
getGoalPrefs(clientId) {
|
|
809
683
|
const s = this.load()[clientId];
|
|
810
684
|
if (!s?.goalPrefs)
|
|
@@ -816,11 +690,9 @@ export class ClientStateStore {
|
|
|
816
690
|
execModel: s.goalPrefs.execModel ?? null,
|
|
817
691
|
};
|
|
818
692
|
}
|
|
819
|
-
/** 某项目当前的额外工作区根(空数组 = 单根)。 */
|
|
820
693
|
getWorkspaceRoots(clientId, cwd) {
|
|
821
694
|
return this.load()[clientId]?.workspaceRoots?.[cwd] ?? [];
|
|
822
695
|
}
|
|
823
|
-
/** 记下某项目的额外工作区根(空数组 = 清掉该项目的键,不留空壳)。 */
|
|
824
696
|
saveWorkspaceRoots(clientId, cwd, roots) {
|
|
825
697
|
const all = this.load();
|
|
826
698
|
const state = (all[clientId] ??= { projects: [] });
|
|
@@ -838,7 +710,6 @@ export class ClientStateStore {
|
|
|
838
710
|
(state.workspaceRoots ??= {})[cwd] = next;
|
|
839
711
|
this.save();
|
|
840
712
|
}
|
|
841
|
-
/** Persist the client's UI locale code (hello/set_locale; best-effort). */
|
|
842
713
|
saveLocale(clientId, locale) {
|
|
843
714
|
const code = locale.trim().slice(0, 16);
|
|
844
715
|
if (!code)
|
|
@@ -851,7 +722,6 @@ export class ClientStateStore {
|
|
|
851
722
|
state.locale = code;
|
|
852
723
|
this.save();
|
|
853
724
|
}
|
|
854
|
-
/** Persist the client's goal/review preferences (model choice, rounds, lock). */
|
|
855
725
|
saveGoalPrefs(clientId, prefs) {
|
|
856
726
|
const all = this.load();
|
|
857
727
|
const state = (all[clientId] ??= { projects: [] });
|
|
@@ -864,8 +734,6 @@ export class ClientStateStore {
|
|
|
864
734
|
};
|
|
865
735
|
this.save();
|
|
866
736
|
}
|
|
867
|
-
/** Remember conversations that were still streaming at shutdown (best-
|
|
868
|
-
* effort; called during the graceful-shutdown path). */
|
|
869
737
|
saveInterrupted(clientId, list) {
|
|
870
738
|
if (list.length === 0)
|
|
871
739
|
return;
|
|
@@ -875,8 +743,6 @@ export class ClientStateStore {
|
|
|
875
743
|
state.interrupted = list.slice(0, 8);
|
|
876
744
|
this.save();
|
|
877
745
|
}
|
|
878
|
-
/** Consume the interrupted-conversation record (returns and clears it) —
|
|
879
|
-
* called once on the client's first attach after a restart. */
|
|
880
746
|
takeInterrupted(clientId) {
|
|
881
747
|
const all = this.load();
|
|
882
748
|
const state = all[clientId];
|
|
@@ -888,16 +754,12 @@ export class ClientStateStore {
|
|
|
888
754
|
}
|
|
889
755
|
return list;
|
|
890
756
|
}
|
|
891
|
-
/** 设置面板状态(系统提示词模式/文字 + 禁用技能/扩展)——全局共享同一套配置。 */
|
|
892
757
|
getSettings(clientId) {
|
|
893
758
|
return structuredClone(this.getSettingsSnapshot(clientId));
|
|
894
759
|
}
|
|
895
760
|
readSettings(_clientId) {
|
|
896
761
|
const s = this.load()[ClientStateStore.GLOBAL_SETTINGS_KEY];
|
|
897
|
-
// Never lend mutable nested objects from the authoritative cache to a client.
|
|
898
762
|
const stored = structuredClone(s?.settings);
|
|
899
|
-
// 旧存档(promptMode/customSystemPrompt)迁移到 compose:追加文字成为独立
|
|
900
|
-
// {{append}} 覆盖、替换文字成为 {{soul}} 覆盖;无自定义则用默认模板。
|
|
901
763
|
let promptTemplate = "";
|
|
902
764
|
let promptOverrides = {};
|
|
903
765
|
if (stored?.promptTemplate !== undefined) {
|
|
@@ -921,7 +783,7 @@ export class ClientStateStore {
|
|
|
921
783
|
disabledExtensions: stored?.disabledExtensions ?? [],
|
|
922
784
|
disabledAgentTools: legacyToDisabled(stored ?? {}),
|
|
923
785
|
disabledPluginTools: normalizeDisabledPluginTools(stored?.disabledPluginTools),
|
|
924
|
-
|
|
786
|
+
nativeCliInheritModel: normalizeNativeCliInheritModel(stored?.nativeCliInheritModel),
|
|
925
787
|
terminalToolsEnabled: stored?.disabledAgentTools !== undefined
|
|
926
788
|
? deriveLegacy(legacyToDisabled(stored)).terminalToolsEnabled
|
|
927
789
|
: (stored?.terminalToolsEnabled ?? false),
|
|
@@ -977,6 +839,7 @@ export class ClientStateStore {
|
|
|
977
839
|
visionBridgePrompt: stored?.visionBridgePrompt ?? "",
|
|
978
840
|
scmCommitMsgPromptMode: stored?.scmCommitMsgPromptMode === "replace" ? "replace" : "append",
|
|
979
841
|
scmCommitMsgPrompt: stored?.scmCommitMsgPrompt ?? "",
|
|
842
|
+
...normalizeQuickAskSettings(stored ?? {}),
|
|
980
843
|
planModePromptMode: stored?.planModePromptMode === "replace" ? "replace" : "append",
|
|
981
844
|
planModePrompt: stored?.planModePrompt ?? "",
|
|
982
845
|
subagentDefaultModel: stored?.subagentDefaultModel ?? null,
|
|
@@ -987,6 +850,7 @@ export class ClientStateStore {
|
|
|
987
850
|
retryMaxAttempts: normalizeRetryMaxAttempts(stored?.retryMaxAttempts),
|
|
988
851
|
softCapTokens: normalizeSoftCapTokens(stored?.softCapTokens),
|
|
989
852
|
softCapByModel: normalizeSoftCapByModel(stored?.softCapByModel),
|
|
853
|
+
autoCompactionInstructions: normalizeAutoCompactionInstructions(stored?.autoCompactionInstructions),
|
|
990
854
|
quickPhrases: stored?.quickPhrases ?? [],
|
|
991
855
|
quickPhrasesEnabled: stored?.quickPhrasesEnabled ?? true,
|
|
992
856
|
minimalNewChat: stored?.minimalNewChat ?? false,
|
|
@@ -1023,6 +887,10 @@ export class ClientStateStore {
|
|
|
1023
887
|
disabledExtensions: settings.disabledExtensions ?? cur.disabledExtensions ?? [],
|
|
1024
888
|
disabledAgentTools: normalizeDisabledAgentTools(settings.disabledAgentTools ?? cur.disabledAgentTools),
|
|
1025
889
|
disabledPluginTools: normalizeDisabledPluginTools(settings.disabledPluginTools ?? cur.disabledPluginTools),
|
|
890
|
+
nativeCliInheritModel: {
|
|
891
|
+
...normalizeNativeCliInheritModel(cur.nativeCliInheritModel),
|
|
892
|
+
...normalizeNativeCliInheritModel(settings.nativeCliInheritModel),
|
|
893
|
+
},
|
|
1026
894
|
terminalToolsEnabled: settings.terminalToolsEnabled ?? cur.terminalToolsEnabled ?? false,
|
|
1027
895
|
terminalBash: settings.terminalBash ?? cur.terminalBash ?? false,
|
|
1028
896
|
terminalBashIdleMs: settings.terminalBashIdleMs ?? cur.terminalBashIdleMs ?? 15_000,
|
|
@@ -1063,9 +931,6 @@ export class ClientStateStore {
|
|
|
1063
931
|
workspaceUploadMaxMb: normalizeUploadMaxMb(settings.workspaceUploadMaxMb ?? cur.workspaceUploadMaxMb, 100),
|
|
1064
932
|
folderUploadMaxMb: normalizeUploadMaxMb(settings.folderUploadMaxMb ?? cur.folderUploadMaxMb, 32),
|
|
1065
933
|
visionBridgeEnabled: settings.visionBridgeEnabled ?? cur.visionBridgeEnabled ?? true,
|
|
1066
|
-
// 按键存在性合并:null 是合法值(清除语义),`null ?? cur` 会把旧值
|
|
1067
|
-
// 复活到磁盘(设置面板清空后重启又回来)。settings-service 持久化
|
|
1068
|
-
// 时传全量对象,键总在;其他调用方传 partial,键缺 = 保持旧值。
|
|
1069
934
|
visionBridgeModel: "visionBridgeModel" in settings ? (settings.visionBridgeModel ?? null) : (cur.visionBridgeModel ?? null),
|
|
1070
935
|
subagentDefaultModel: "subagentDefaultModel" in settings
|
|
1071
936
|
? (settings.subagentDefaultModel ?? null)
|
|
@@ -1077,10 +942,12 @@ export class ClientStateStore {
|
|
|
1077
942
|
retryMaxAttempts: normalizeRetryMaxAttempts(settings.retryMaxAttempts ?? cur.retryMaxAttempts ?? DEFAULT_RETRY_MAX_ATTEMPTS),
|
|
1078
943
|
softCapTokens: normalizeSoftCapTokens(settings.softCapTokens ?? cur.softCapTokens ?? 0),
|
|
1079
944
|
softCapByModel: normalizeSoftCapByModel(settings.softCapByModel ?? cur.softCapByModel ?? {}),
|
|
945
|
+
autoCompactionInstructions: normalizeAutoCompactionInstructions(settings.autoCompactionInstructions ?? cur.autoCompactionInstructions ?? ""),
|
|
1080
946
|
visionBridgePromptMode: settings.visionBridgePromptMode ?? cur.visionBridgePromptMode ?? "append",
|
|
1081
947
|
visionBridgePrompt: settings.visionBridgePrompt ?? cur.visionBridgePrompt ?? "",
|
|
1082
948
|
scmCommitMsgPromptMode: settings.scmCommitMsgPromptMode ?? cur.scmCommitMsgPromptMode ?? "append",
|
|
1083
949
|
scmCommitMsgPrompt: settings.scmCommitMsgPrompt ?? cur.scmCommitMsgPrompt ?? "",
|
|
950
|
+
...mergeQuickAskSettings(cur, settings),
|
|
1084
951
|
planModePromptMode: settings.planModePromptMode ?? cur.planModePromptMode ?? "append",
|
|
1085
952
|
planModePrompt: settings.planModePrompt ?? cur.planModePrompt ?? "",
|
|
1086
953
|
reviewPrompt: settings.reviewPrompt ?? cur.reviewPrompt ?? "",
|
|
@@ -1104,7 +971,6 @@ export class ClientStateStore {
|
|
|
1104
971
|
before,
|
|
1105
972
|
settings: committed,
|
|
1106
973
|
});
|
|
1107
|
-
// Snapshot: a subscriber may release its subscription while handling the event.
|
|
1108
974
|
// eslint-disable-next-line unicorn/no-useless-spread
|
|
1109
975
|
for (const listener of [...this.settingsListeners]) {
|
|
1110
976
|
try {
|
|
@@ -1122,7 +988,6 @@ export class ClientStateStore {
|
|
|
1122
988
|
getPresets(_clientId) {
|
|
1123
989
|
return (this.load()[ClientStateStore.GLOBAL_SETTINGS_KEY]?.presets ?? []).map((p) => {
|
|
1124
990
|
const preset = { ...p };
|
|
1125
|
-
// Missing fields in partial/older presets must keep the current settings on apply.
|
|
1126
991
|
if (Object.hasOwn(p, "reviewPrompt"))
|
|
1127
992
|
preset.reviewPrompt = p.reviewPrompt ?? "";
|
|
1128
993
|
if (Object.hasOwn(p, "reviewDisabledSkills"))
|
|
@@ -1140,6 +1005,8 @@ export class ClientStateStore {
|
|
|
1140
1005
|
}
|
|
1141
1006
|
if (Object.hasOwn(p, "softCapByModel"))
|
|
1142
1007
|
preset.softCapByModel = normalizeSoftCapByModel(p.softCapByModel);
|
|
1008
|
+
if (Object.hasOwn(p, "autoCompactionInstructions"))
|
|
1009
|
+
preset.autoCompactionInstructions = normalizeAutoCompactionInstructions(p.autoCompactionInstructions);
|
|
1143
1010
|
return preset;
|
|
1144
1011
|
});
|
|
1145
1012
|
}
|
|
@@ -1150,11 +1017,9 @@ export class ClientStateStore {
|
|
|
1150
1017
|
state.presets = presets;
|
|
1151
1018
|
this.save();
|
|
1152
1019
|
}
|
|
1153
|
-
/** Get per-project provider keys for a cwd, or undefined. */
|
|
1154
1020
|
getProjectProviderKeys(clientId, cwd) {
|
|
1155
1021
|
return this.load()[clientId]?.projectProviderKeys?.[cwd];
|
|
1156
1022
|
}
|
|
1157
|
-
/** Get a single provider's saved key for a project. */
|
|
1158
1023
|
getProjectProviderKey(clientId, cwd, provider) {
|
|
1159
1024
|
const all = this.load();
|
|
1160
1025
|
const globalHit = all[ClientStateStore.GLOBAL_SETTINGS_KEY]?.projectProviderKeys?.[cwd]?.[provider];
|
|
@@ -1172,7 +1037,6 @@ export class ClientStateStore {
|
|
|
1172
1037
|
}
|
|
1173
1038
|
return undefined;
|
|
1174
1039
|
}
|
|
1175
|
-
/** Remember which key was last used for a provider in a project. */
|
|
1176
1040
|
saveProjectProviderKey(clientId, cwd, provider, keyName) {
|
|
1177
1041
|
const all = this.load();
|
|
1178
1042
|
const globalState = (all[ClientStateStore.GLOBAL_SETTINGS_KEY] ??= { projects: [] });
|
|
@@ -1185,7 +1049,6 @@ export class ClientStateStore {
|
|
|
1185
1049
|
inner[provider] = keyName;
|
|
1186
1050
|
this.save();
|
|
1187
1051
|
}
|
|
1188
|
-
/** Delete a per-project provider key (e.g. when the key is removed). */
|
|
1189
1052
|
deleteProjectProviderKey(clientId, cwd, provider) {
|
|
1190
1053
|
const all = this.load();
|
|
1191
1054
|
const gInner = all[ClientStateStore.GLOBAL_SETTINGS_KEY]?.projectProviderKeys?.[cwd];
|
|
@@ -1204,9 +1067,6 @@ export class ClientStateStore {
|
|
|
1204
1067
|
}
|
|
1205
1068
|
this.save();
|
|
1206
1069
|
}
|
|
1207
|
-
/** Remove one provider from EVERY project's saved keys (all clients, all
|
|
1208
|
-
* cwds) — e.g. the provider was cleared and returned to unconfigured.
|
|
1209
|
-
* Returns the number of entries removed. */
|
|
1210
1070
|
deleteProviderEverywhere(provider) {
|
|
1211
1071
|
const all = this.load();
|
|
1212
1072
|
let removed = 0;
|
|
@@ -1229,11 +1089,6 @@ export class ClientStateStore {
|
|
|
1229
1089
|
this.save();
|
|
1230
1090
|
return removed;
|
|
1231
1091
|
}
|
|
1232
|
-
/** Fix every project that still references a deleted key: point it at the
|
|
1233
|
-
* key that took over (`newActive`), or drop the reference when the
|
|
1234
|
-
* provider has no keys left (`newActive` null). A key deletion made in
|
|
1235
|
-
* one project must not keep haunting every other project that once used
|
|
1236
|
-
* the same key on every project switch. Returns entries touched. */
|
|
1237
1092
|
repointDeletedKeyEverywhere(provider, deletedKeyName, newActive) {
|
|
1238
1093
|
const all = this.load();
|
|
1239
1094
|
let touched = 0;
|
|
@@ -1260,11 +1115,9 @@ export class ClientStateStore {
|
|
|
1260
1115
|
this.save();
|
|
1261
1116
|
return touched;
|
|
1262
1117
|
}
|
|
1263
|
-
/** Get the model the user last selected in a project, or undefined. */
|
|
1264
1118
|
getProjectModel(clientId, cwd, engine) {
|
|
1265
1119
|
const all = this.load();
|
|
1266
1120
|
const eng = engine?.trim();
|
|
1267
|
-
// 1. 如果指定了引擎,优先查找按引擎隔离的项目模型记录
|
|
1268
1121
|
if (eng) {
|
|
1269
1122
|
const globalEngHit = all[ClientStateStore.GLOBAL_SETTINGS_KEY]?.engineProjectModels?.[eng]?.[cwd];
|
|
1270
1123
|
if (globalEngHit)
|
|
@@ -1286,12 +1139,10 @@ export class ClientStateStore {
|
|
|
1286
1139
|
engCandidates.sort((a, b) => b.lastUsed - a.lastUsed);
|
|
1287
1140
|
return engCandidates[0].model;
|
|
1288
1141
|
}
|
|
1289
|
-
// 非 pi 引擎不向旧有的全局 projectModels 回退,保持严格隔离
|
|
1290
1142
|
if (eng !== "pi") {
|
|
1291
1143
|
return undefined;
|
|
1292
1144
|
}
|
|
1293
1145
|
}
|
|
1294
|
-
// 2. 回退到旧有的通用项目模型记录(向后兼容)
|
|
1295
1146
|
const globalHit = all[ClientStateStore.GLOBAL_SETTINGS_KEY]?.projectModels?.[cwd];
|
|
1296
1147
|
if (globalHit)
|
|
1297
1148
|
return globalHit;
|
|
@@ -1314,7 +1165,6 @@ export class ClientStateStore {
|
|
|
1314
1165
|
}
|
|
1315
1166
|
return undefined;
|
|
1316
1167
|
}
|
|
1317
|
-
/** Remember the model last selected in a project (immediate, not after a turn). */
|
|
1318
1168
|
saveProjectModel(clientId, cwd, modelId, engine) {
|
|
1319
1169
|
const all = this.load();
|
|
1320
1170
|
const eng = engine?.trim();
|
|
@@ -1325,7 +1175,6 @@ export class ClientStateStore {
|
|
|
1325
1175
|
this.touchClient(all, clientId);
|
|
1326
1176
|
((state.engineProjectModels ??= {})[eng] ??= {})[cwd] = modelId;
|
|
1327
1177
|
}
|
|
1328
|
-
// 若为 pi 引擎或未传 engine,同步维护旧字段 projectModels 保持向后兼容
|
|
1329
1178
|
if (!eng || eng === "pi") {
|
|
1330
1179
|
const globalState = (all[ClientStateStore.GLOBAL_SETTINGS_KEY] ??= { projects: [] });
|
|
1331
1180
|
(globalState.projectModels ??= {})[cwd] = modelId;
|
|
@@ -1335,8 +1184,6 @@ export class ClientStateStore {
|
|
|
1335
1184
|
}
|
|
1336
1185
|
this.save();
|
|
1337
1186
|
}
|
|
1338
|
-
/** Drop the per-project model memory for a project (e.g. when the model is
|
|
1339
|
-
* removed from the catalog). */
|
|
1340
1187
|
deleteProjectModel(clientId, cwd, engine) {
|
|
1341
1188
|
const all = this.load();
|
|
1342
1189
|
const eng = engine?.trim();
|
|
@@ -1366,7 +1213,6 @@ export class ClientStateStore {
|
|
|
1366
1213
|
}
|
|
1367
1214
|
this.save();
|
|
1368
1215
|
}
|
|
1369
|
-
/** 全局默认模型(跨客户端共享,存 __settings__ 键)。缺省 = 未设置。 */
|
|
1370
1216
|
getDefaultModel(engine) {
|
|
1371
1217
|
const eng = engine?.trim();
|
|
1372
1218
|
const globalSettings = this.load()[ClientStateStore.GLOBAL_SETTINGS_KEY];
|
|
@@ -1379,7 +1225,6 @@ export class ClientStateStore {
|
|
|
1379
1225
|
}
|
|
1380
1226
|
return globalSettings?.defaultModel;
|
|
1381
1227
|
}
|
|
1382
|
-
/** 设置全局默认模型("provider/id")。 */
|
|
1383
1228
|
saveDefaultModel(modelId, engine) {
|
|
1384
1229
|
const all = this.load();
|
|
1385
1230
|
const state = (all[ClientStateStore.GLOBAL_SETTINGS_KEY] ??= { projects: [] });
|
|
@@ -1392,7 +1237,6 @@ export class ClientStateStore {
|
|
|
1392
1237
|
}
|
|
1393
1238
|
this.save();
|
|
1394
1239
|
}
|
|
1395
|
-
/** 清除全局默认模型(连带其 key 记忆)。 */
|
|
1396
1240
|
clearDefaultModel() {
|
|
1397
1241
|
const all = this.load();
|
|
1398
1242
|
const state = all[ClientStateStore.GLOBAL_SETTINGS_KEY];
|
|
@@ -1402,24 +1246,20 @@ export class ClientStateStore {
|
|
|
1402
1246
|
delete state.defaultProviderKeys;
|
|
1403
1247
|
this.save();
|
|
1404
1248
|
}
|
|
1405
|
-
/** 取全局默认的某 provider key。 */
|
|
1406
1249
|
getDefaultProviderKey(provider) {
|
|
1407
1250
|
return this.load()[ClientStateStore.GLOBAL_SETTINGS_KEY]?.defaultProviderKeys?.[provider];
|
|
1408
1251
|
}
|
|
1409
|
-
/** 记全局默认的某 provider key(设全局默认模型时连带记)。 */
|
|
1410
1252
|
saveDefaultProviderKey(provider, keyName) {
|
|
1411
1253
|
const all = this.load();
|
|
1412
1254
|
const state = (all[ClientStateStore.GLOBAL_SETTINGS_KEY] ??= { projects: [] });
|
|
1413
1255
|
(state.defaultProviderKeys ??= {})[provider] = keyName;
|
|
1414
1256
|
this.save();
|
|
1415
1257
|
}
|
|
1416
|
-
/** 获取某项目已钉住的会话文件路径列表。 */
|
|
1417
1258
|
getPinnedSessions(cwd) {
|
|
1418
1259
|
const normCwd = normalizePathKey(cwd);
|
|
1419
1260
|
const map = this.load()[ClientStateStore.GLOBAL_SETTINGS_KEY]?.pinnedSessions;
|
|
1420
1261
|
return map?.[normCwd] ?? [];
|
|
1421
1262
|
}
|
|
1422
|
-
/** 钉住 / 取消钉住某个会话文件。 */
|
|
1423
1263
|
setSessionPinned(cwd, sessionPath, pinned) {
|
|
1424
1264
|
const normCwd = normalizePathKey(cwd);
|
|
1425
1265
|
const normPath = normalizePathKey(sessionPath);
|
|
@@ -1446,13 +1286,11 @@ export class ClientStateStore {
|
|
|
1446
1286
|
}
|
|
1447
1287
|
this.save();
|
|
1448
1288
|
}
|
|
1449
|
-
/** 检查某个会话文件是否已被钉住。 */
|
|
1450
1289
|
isSessionPinned(cwd, sessionPath) {
|
|
1451
1290
|
const list = this.getPinnedSessions(cwd);
|
|
1452
1291
|
const norm = normalizePathKey(sessionPath);
|
|
1453
1292
|
return list.some((p) => normalizePathKey(p) === norm);
|
|
1454
1293
|
}
|
|
1455
|
-
/** 会话文件被删除时清理钉住记录。 */
|
|
1456
1294
|
cleanPinnedSession(sessionPath) {
|
|
1457
1295
|
const norm = normalizePathKey(sessionPath);
|
|
1458
1296
|
const all = this.load();
|
|
@@ -1479,7 +1317,6 @@ export class ClientStateStore {
|
|
|
1479
1317
|
this.save();
|
|
1480
1318
|
}
|
|
1481
1319
|
}
|
|
1482
|
-
/** 全局默认 key 跟随删除:被删的 key 若是全局默认记的,指到接替者(无接替则删引用)。 */
|
|
1483
1320
|
repointDeletedKeyInDefault(provider, deletedKeyName, newActive) {
|
|
1484
1321
|
const all = this.load();
|
|
1485
1322
|
const map = all[ClientStateStore.GLOBAL_SETTINGS_KEY]?.defaultProviderKeys;
|
|
@@ -1494,13 +1331,6 @@ export class ClientStateStore {
|
|
|
1494
1331
|
}
|
|
1495
1332
|
this.save();
|
|
1496
1333
|
}
|
|
1497
|
-
/** 全局「快捷短语已 seed」标记(非 per-clientId)。
|
|
1498
|
-
*
|
|
1499
|
-
* 为什么全局:clientId 存 sessionStorage(每标签页独立、关浏览器即失),按
|
|
1500
|
-
* clientId 记 seed 会在每次新会话生成新 clientId 时误判为「从未 seed」,导致
|
|
1501
|
-
* 用户删掉的默认短语又被填回默认。seed 只需一次(首次见空列表),之后即为用户
|
|
1502
|
-
* 数据,增删改/恢复默认/关闭都走设置面板。存服务端而非浏览器 localStorage,
|
|
1503
|
-
* 任何浏览器/标签页/清缓存都不受影响。 */
|
|
1504
1334
|
getQuickPhrasesSeeded() {
|
|
1505
1335
|
const meta = this.load()[ClientStateStore.GLOBAL_SETTINGS_KEY];
|
|
1506
1336
|
return !!meta?.quickPhrasesSeeded;
|
|
@@ -1513,7 +1343,6 @@ export class ClientStateStore {
|
|
|
1513
1343
|
meta.quickPhrasesSeeded = true;
|
|
1514
1344
|
this.save();
|
|
1515
1345
|
}
|
|
1516
|
-
/** 内置标记工具开关(全局共享同一套 + 按 marker 禁用)。 */
|
|
1517
1346
|
getMarkerSettings(_clientId) {
|
|
1518
1347
|
const s = this.load()[ClientStateStore.GLOBAL_SETTINGS_KEY]?.markers;
|
|
1519
1348
|
return {
|
|
@@ -1531,12 +1360,10 @@ export class ClientStateStore {
|
|
|
1531
1360
|
};
|
|
1532
1361
|
this.save();
|
|
1533
1362
|
}
|
|
1534
|
-
/** 读取某客户端(标签页)上次使用的引擎(未设置返回 undefined)。 */
|
|
1535
1363
|
getClientEngine(clientId) {
|
|
1536
1364
|
const eng = this.load()[clientId]?.engine;
|
|
1537
1365
|
return eng === "dsh" || eng === "pi" || eng === "codex" || eng === "claude" || eng === "durable" ? eng : undefined;
|
|
1538
1366
|
}
|
|
1539
|
-
/** 保存某客户端(标签页)当前使用的引擎。 */
|
|
1540
1367
|
saveClientEngine(clientId, engine) {
|
|
1541
1368
|
const all = this.load();
|
|
1542
1369
|
const state = (all[clientId] ??= { projects: [] });
|
|
@@ -1544,19 +1371,16 @@ export class ClientStateStore {
|
|
|
1544
1371
|
this.touchClient(all, clientId);
|
|
1545
1372
|
this.save();
|
|
1546
1373
|
}
|
|
1547
|
-
/** 读取全局默认引擎(存在 __settings__ 下,新标签页及服务重启后默认跟随)。 */
|
|
1548
1374
|
getDefaultEngine() {
|
|
1549
1375
|
const eng = this.load()[ClientStateStore.GLOBAL_SETTINGS_KEY]?.defaultEngine;
|
|
1550
1376
|
return eng === "dsh" || eng === "pi" || eng === "codex" || eng === "claude" || eng === "durable" ? eng : undefined;
|
|
1551
1377
|
}
|
|
1552
|
-
/** 保存全局默认引擎。 */
|
|
1553
1378
|
saveDefaultEngine(engine) {
|
|
1554
1379
|
const all = this.load();
|
|
1555
1380
|
const state = (all[ClientStateStore.GLOBAL_SETTINGS_KEY] ??= { projects: [] });
|
|
1556
1381
|
state.defaultEngine = engine;
|
|
1557
1382
|
this.save();
|
|
1558
1383
|
}
|
|
1559
|
-
/** 保存指定会话的自定义标题(按 cwd + sessionKey 索引,跨重启存活) */
|
|
1560
1384
|
saveSessionTitle(cwd, sessionKey, title) {
|
|
1561
1385
|
const all = this.load();
|
|
1562
1386
|
const state = (all[ClientStateStore.GLOBAL_SETTINGS_KEY] ??= { projects: [] });
|
|
@@ -1567,7 +1391,6 @@ export class ClientStateStore {
|
|
|
1567
1391
|
cwdMap[normKey] = title.trim();
|
|
1568
1392
|
this.save();
|
|
1569
1393
|
}
|
|
1570
|
-
/** 读取指定会话的自定义标题(若未自定义过返回 undefined) */
|
|
1571
1394
|
getSessionTitle(cwd, sessionKey) {
|
|
1572
1395
|
const all = this.load();
|
|
1573
1396
|
const map = all[ClientStateStore.GLOBAL_SETTINGS_KEY]?.sessionTitles;
|
|
@@ -1577,7 +1400,6 @@ export class ClientStateStore {
|
|
|
1577
1400
|
const normKey = normalizePathKey(sessionKey);
|
|
1578
1401
|
return map[normCwd]?.[normKey] || map[normCwd]?.[sessionKey];
|
|
1579
1402
|
}
|
|
1580
|
-
/** 删除指定会话的自定义标题记忆 */
|
|
1581
1403
|
deleteSessionTitle(cwd, sessionKey) {
|
|
1582
1404
|
const all = this.load();
|
|
1583
1405
|
const map = all[ClientStateStore.GLOBAL_SETTINGS_KEY]?.sessionTitles;
|