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,16 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Settings service — 从 agent-service.ts 抽出(系统提示词 / 技能插件开关 /
|
|
3
|
-
* 目标审查提示词 / 预设 / 视觉桥偏好)。设置持久化在 client-state.json 全局共享。
|
|
4
|
-
*
|
|
5
|
-
* 经 SettingsHost 回调与 ClientSession 解耦:本模块只管「设置状态 + 面板推送 +
|
|
6
|
-
* 预设存取 + 何时需要 reload」,真正动 runtime 的 session.reload() 走宿主回调
|
|
7
|
-
* (reloadSession 里还会刷新斜杠命令目录)。
|
|
8
|
-
*/
|
|
9
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { normalizeNativeCliInheritModel } from "./engine-catalog.js";
|
|
10
3
|
import { basename, dirname, join } from "node:path";
|
|
11
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { mergeQuickAskSettings, normalizeQuickAskSettings } from "./quick-ask-settings.js";
|
|
12
6
|
import { extensionKey, isInternalExtension, normalizeBgCleanupMinutes, normalizeDisabledPluginTools, normalizeRetryMaxAttempts, normalizeKeepRecentMessages, normalizeSkillList, normalizeSkillsCatalogBudget, normalizeSkillsCatalogMaxDesc, normalizeSkillsFullTextMaxBytes, normalizeSkillsMaxFileBytes, normalizeToolWatchdogTimeoutMs, normalizeUiLayout, defaultSubagentAutoWakeMaxTurns, normalizeSubagentAutoWakeMaxTurns, settingsPresetToUi, } from "./client-state.js";
|
|
13
|
-
import { normalizeSoftCapByModel, normalizeSoftCapTokens } from "./soft-cap.js";
|
|
7
|
+
import { normalizeAutoCompactionInstructions, normalizeSoftCapByModel, normalizeSoftCapTokens } from "./soft-cap.js";
|
|
14
8
|
import { findVisionModels, SYSTEM_PROMPT } from "./vision-bridge.js";
|
|
15
9
|
import { COMMITMSG_SYSTEM_PROMPT } from "./scm-commitmsg.js";
|
|
16
10
|
import { PLAN_MODE_SYSTEM_PROMPT } from "./plan-mode.js";
|
|
@@ -28,7 +22,6 @@ export class SettingsService {
|
|
|
28
22
|
presets;
|
|
29
23
|
knownSkills = new Map();
|
|
30
24
|
knownExtensions = new Map();
|
|
31
|
-
/** 流式中改了需要 reload 的设置 → agent_end 后延迟应用(防拆毁运行中 run)。 */
|
|
32
25
|
pendingReload = false;
|
|
33
26
|
pendingRuntimeReloads = new Set();
|
|
34
27
|
unsubscribeSettings;
|
|
@@ -36,23 +29,17 @@ export class SettingsService {
|
|
|
36
29
|
sharedQueue = Promise.resolve();
|
|
37
30
|
committingSettings = false;
|
|
38
31
|
disposed = false;
|
|
39
|
-
constructor(host,
|
|
40
|
-
/** 全局子代理模板库(所有客户端共享;模板改动无需 reload runtime)。 */
|
|
41
|
-
templates,
|
|
42
|
-
/** 全局审批规则库(所有客户端共享;修改实时生效无需 reload runtime)。 */
|
|
43
|
-
approvalRules) {
|
|
32
|
+
constructor(host, templates, approvalRules) {
|
|
44
33
|
this.host = host;
|
|
45
34
|
this.templates = templates;
|
|
46
35
|
this.approvalRules = approvalRules;
|
|
47
36
|
this.settings = host.stateStore.getSettings(host.clientId);
|
|
48
37
|
this.presets = host.stateStore.getPresets(host.clientId);
|
|
49
38
|
}
|
|
50
|
-
/** Immutable snapshot: repeated hot-path reads share the same detached object. */
|
|
51
39
|
get current() {
|
|
52
40
|
return (this.host.stateStore.getSettingsSnapshot?.(this.host.clientId) ??
|
|
53
41
|
this.host.stateStore.getSettings(this.host.clientId));
|
|
54
42
|
}
|
|
55
|
-
/** Call once after the host has assigned settingsSvc and finished initialization. */
|
|
56
43
|
subscribeSharedSettings() {
|
|
57
44
|
if (this.unsubscribeSettings || this.disposed)
|
|
58
45
|
return;
|
|
@@ -72,7 +59,6 @@ export class SettingsService {
|
|
|
72
59
|
this.pendingReload = false;
|
|
73
60
|
this.pendingRuntimeReloads.clear();
|
|
74
61
|
}
|
|
75
|
-
/** Apply a durable commit without saving it again. Serialize reloads; ignore stale deliveries. */
|
|
76
62
|
receiveSharedSettings(change) {
|
|
77
63
|
if (this.disposed || this.host.isDisposed() || change.version <= this.sharedVersion)
|
|
78
64
|
return this.sharedQueue;
|
|
@@ -137,9 +123,6 @@ export class SettingsService {
|
|
|
137
123
|
this.committingSettings = false;
|
|
138
124
|
}
|
|
139
125
|
}
|
|
140
|
-
/** Effective dev-no-cache: explicit setting wins, else source-tree default
|
|
141
|
-
* (ON from source, OFF for installs) — same rule as the index.html route.
|
|
142
|
-
* PI_WEB_DEV_CACHE=0/1 overrides either way. */
|
|
143
126
|
defaultDevNoCache() {
|
|
144
127
|
const env = process.env.PI_WEB_DEV_CACHE;
|
|
145
128
|
if (env !== undefined)
|
|
@@ -170,18 +153,12 @@ export class SettingsService {
|
|
|
170
153
|
this.setPendingReload(false, runtimeTarget);
|
|
171
154
|
return v;
|
|
172
155
|
}
|
|
173
|
-
/** 判断某个 skill 名是否仍存在于磁盘任何来源(各类 Agent 项目区 / 全局 / 祖先 / npm 包等)。
|
|
174
|
-
* 被禁用且文件已删除的名字不应再出现在设置面板,也不应留在持久化记录里。 */
|
|
175
156
|
skillStillOnDisk(name) {
|
|
176
157
|
return isSkillStillOnDisk(name, {
|
|
177
158
|
cwd: this.host.cwd(),
|
|
178
159
|
agentDir: this.host.agentDir(),
|
|
179
160
|
});
|
|
180
161
|
}
|
|
181
|
-
/** 判断某个扩展 id 是否仍存在(loader 之外的兜底,供禁用残留清理用):
|
|
182
|
-
* npm: 包 → 任一 npm 根还有目录,或还列在任一 settings.json packages 里
|
|
183
|
-
* (只删了 node_modules 但配置还在 = 保守保留,等下次 loader 同步);
|
|
184
|
-
* 路径型 → 文件/目录任一存在。空串一律不存在。 */
|
|
185
162
|
extensionStillOnDisk(id) {
|
|
186
163
|
if (!id)
|
|
187
164
|
return false;
|
|
@@ -209,7 +186,6 @@ export class SettingsService {
|
|
|
209
186
|
return false;
|
|
210
187
|
}
|
|
211
188
|
}
|
|
212
|
-
/** 包名是否还列在全局/项目 settings.json 的 packages 里(文件缺失/坏 JSON 当没列)。 */
|
|
213
189
|
packageStillListed(pkg) {
|
|
214
190
|
const wanted = `npm:${pkg}`;
|
|
215
191
|
for (const file of [join(this.host.agentDir(), "settings.json"), join(this.host.cwd(), ".pi", "settings.json")]) {
|
|
@@ -228,7 +204,6 @@ export class SettingsService {
|
|
|
228
204
|
}
|
|
229
205
|
return false;
|
|
230
206
|
}
|
|
231
|
-
/** Discover disk resources and prune stale preferences only on explicit refresh. Never reloads. */
|
|
232
207
|
refreshResources() {
|
|
233
208
|
if (this.disposed || this.host.isDisposed())
|
|
234
209
|
return;
|
|
@@ -244,14 +219,11 @@ export class SettingsService {
|
|
|
244
219
|
const loadedExts = allLoadedExts.filter((e) => !isInternalExtension(e));
|
|
245
220
|
loadedSkillNames = new Set(loadedSkills.map((s) => s.name));
|
|
246
221
|
loadedExtNames = new Set(loadedExts.map((e) => extensionKey(e)));
|
|
247
|
-
// 实时全源磁盘扫描:动态发现外部新安装/更新的各类 Agent 全局与本地技能
|
|
248
222
|
const discoveredSkills = discoverDiskSkills({
|
|
249
223
|
cwd: this.host.cwd(),
|
|
250
224
|
agentDir: this.host.agentDir(),
|
|
251
225
|
});
|
|
252
226
|
const diskSkills = this.host.filterDiskSkills?.(discoveredSkills) ?? discoveredSkills;
|
|
253
|
-
// Rebuild membership from loaded and discovered resources so deleted
|
|
254
|
-
// disabled entries cannot keep themselves alive through the cache.
|
|
255
227
|
const keepSkills = new Set([...loadedSkills.map((s) => s.name), ...diskSkills.map((s) => s.name)]);
|
|
256
228
|
const keepExts = new Set([
|
|
257
229
|
...loadedExts.map((e) => extensionKey(e)),
|
|
@@ -297,13 +269,7 @@ export class SettingsService {
|
|
|
297
269
|
});
|
|
298
270
|
}
|
|
299
271
|
}
|
|
300
|
-
catch {
|
|
301
|
-
// Session not ready yet — keep whatever we already know.
|
|
302
|
-
}
|
|
303
|
-
// 清理“源文件已删除”的禁用残留记录:磁盘上已不存在的技能名从
|
|
304
|
-
// disabledSkills / reviewDisabledSkills 持久化记录中移除——否则每次
|
|
305
|
-
// 推送都会把已删除的 skill 以灰条形式永恒地补回面板(“关闭过的
|
|
306
|
-
// skill 被一直记录”)。session 未就绪时保守跳过。
|
|
272
|
+
catch { }
|
|
307
273
|
if (loadedSkillNames !== null) {
|
|
308
274
|
const stale = [
|
|
309
275
|
...new Set([
|
|
@@ -323,12 +289,6 @@ export class SettingsService {
|
|
|
323
289
|
});
|
|
324
290
|
}
|
|
325
291
|
}
|
|
326
|
-
// Disabled entries that still exist on disk are re-added (with the
|
|
327
|
-
// last-known description) so they can be re-enabled; entries whose
|
|
328
|
-
// source file was deleted are dropped instead of being resurrected.
|
|
329
|
-
// disabledExtensions 同理:已卸载(loader 里没有、磁盘/配置里也没有)的扩展
|
|
330
|
-
// 从禁用记录里剔除并持久化 —— 否则卸载过的扩展以“已禁用”灰条永生(issue #192)。
|
|
331
|
-
// loadedExtNames 非 null 即 session 就绪;取不到(catch 分支)时保守跳过。
|
|
332
292
|
if (loadedExtNames !== null) {
|
|
333
293
|
const staleExts = this.settings.disabledExtensions.filter((id) => isInternalExtension({ path: id }) || (!loadedExtNames.has(id) && !this.extensionStillOnDisk(id)));
|
|
334
294
|
if (staleExts.length > 0) {
|
|
@@ -345,8 +305,6 @@ export class SettingsService {
|
|
|
345
305
|
continue;
|
|
346
306
|
this.knownSkills.set(name, { name, description: "", enabled: false });
|
|
347
307
|
}
|
|
348
|
-
// (上面的 stale 清理已把卸载项移出禁用记录;这里再按磁盘挡一次,
|
|
349
|
-
// session 未就绪跳过清理时也不复活幽灵。)
|
|
350
308
|
for (const id of this.settings.disabledExtensions) {
|
|
351
309
|
if (isInternalExtension({ path: id }))
|
|
352
310
|
continue;
|
|
@@ -372,7 +330,6 @@ export class SettingsService {
|
|
|
372
330
|
this.knownSkills.clear();
|
|
373
331
|
this.knownExtensions.clear();
|
|
374
332
|
}
|
|
375
|
-
/** Publish persisted preferences and the current in-memory resource catalog. No discovery, writes or reloads. */
|
|
376
333
|
push() {
|
|
377
334
|
if (this.disposed || this.host.isDisposed())
|
|
378
335
|
return;
|
|
@@ -402,9 +359,7 @@ export class SettingsService {
|
|
|
402
359
|
});
|
|
403
360
|
}
|
|
404
361
|
}
|
|
405
|
-
catch {
|
|
406
|
-
// Session initialization may still be in progress.
|
|
407
|
-
}
|
|
362
|
+
catch { }
|
|
408
363
|
const skills = [...this.knownSkills.values()]
|
|
409
364
|
.map((s) => ({ ...s, enabled: !disabledSkills.has(s.name) }))
|
|
410
365
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -415,9 +370,7 @@ export class SettingsService {
|
|
|
415
370
|
.filter((e) => !isInternalExtension({ path: e.id }) && !isInternalExtension({ path: e.path }))
|
|
416
371
|
.map((e) => ({ ...e, enabled: !disabledExts.has(e.id) }))
|
|
417
372
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
418
|
-
// 统一工具开关是单源(disabledAgentTools),遗留三开关推送时推导,保证面板一致。
|
|
419
373
|
const legacyTools = deriveLegacy(this.settings.disabledAgentTools ?? []);
|
|
420
|
-
// 当前会话提示词快照:完整生效文本 + 各来源默认(自动)内容(只读预览)。
|
|
421
374
|
const promptSnap = this.host.promptSnapshot();
|
|
422
375
|
const mcp = this.host.getMcpServers?.() ?? {
|
|
423
376
|
servers: [],
|
|
@@ -435,6 +388,7 @@ export class SettingsService {
|
|
|
435
388
|
toolPromptOverrides: { ...this.settings.toolPromptOverrides },
|
|
436
389
|
disabledAgentTools: [...normalizeDisabledAgentTools(this.settings.disabledAgentTools)],
|
|
437
390
|
disabledPluginTools: [...normalizeDisabledPluginTools(this.settings.disabledPluginTools)],
|
|
391
|
+
nativeCliInheritModel: { ...this.settings.nativeCliInheritModel },
|
|
438
392
|
terminalToolsEnabled: legacyTools.terminalToolsEnabled,
|
|
439
393
|
terminalBash: this.settings.terminalBash,
|
|
440
394
|
terminalBashIdleMs: this.settings.terminalBashIdleMs,
|
|
@@ -471,6 +425,7 @@ export class SettingsService {
|
|
|
471
425
|
visionBridgePrompt: this.settings.visionBridgePrompt,
|
|
472
426
|
scmCommitMsgPromptMode: this.settings.scmCommitMsgPromptMode,
|
|
473
427
|
scmCommitMsgPrompt: this.settings.scmCommitMsgPrompt,
|
|
428
|
+
...normalizeQuickAskSettings(this.settings),
|
|
474
429
|
planModePromptMode: this.settings.planModePromptMode,
|
|
475
430
|
planModePrompt: this.settings.planModePrompt,
|
|
476
431
|
reviewPrompt: this.settings.reviewPrompt,
|
|
@@ -483,11 +438,8 @@ export class SettingsService {
|
|
|
483
438
|
skillsCatalogBudget: this.settings.skillsCatalogBudget,
|
|
484
439
|
skillsMaxFileBytes: this.settings.skillsMaxFileBytes,
|
|
485
440
|
skillsFullTextMaxBytes: this.settings.skillsFullTextMaxBytes,
|
|
486
|
-
// The composed system prompt actually in effect (read-only view).
|
|
487
441
|
effectiveSystemPrompt: promptSnap.full,
|
|
488
|
-
// 每个来源未覆盖时的默认(自动)内容(「各来源」行预览用)。
|
|
489
442
|
promptSourceDefaults: promptSnap.texts,
|
|
490
|
-
// 发给模型的工具 schema(name/description/parameters)—— 只读预览。
|
|
491
443
|
toolsSchema: promptSnap.toolsSchema,
|
|
492
444
|
visionBridgeDefaultPrompt: SYSTEM_PROMPT,
|
|
493
445
|
scmCommitMsgDefaultPrompt: COMMITMSG_SYSTEM_PROMPT,
|
|
@@ -519,6 +471,7 @@ export class SettingsService {
|
|
|
519
471
|
retryMaxAttempts: this.settings.retryMaxAttempts,
|
|
520
472
|
softCapTokens: this.settings.softCapTokens,
|
|
521
473
|
softCapByModel: { ...this.settings.softCapByModel },
|
|
474
|
+
autoCompactionInstructions: this.settings.autoCompactionInstructions ?? "",
|
|
522
475
|
subagentModels: this.collectSubagentModels(),
|
|
523
476
|
quickPhrases: [...this.settings.quickPhrases],
|
|
524
477
|
quickPhrasesEnabled: this.settings.quickPhrasesEnabled,
|
|
@@ -531,7 +484,6 @@ export class SettingsService {
|
|
|
531
484
|
},
|
|
532
485
|
});
|
|
533
486
|
}
|
|
534
|
-
/** Vision-capable configured models, for the settings-panel picker. */
|
|
535
487
|
collectVisionModels() {
|
|
536
488
|
try {
|
|
537
489
|
return findVisionModels(this.host.getSession().modelRuntime).map((m) => ({
|
|
@@ -541,11 +493,9 @@ export class SettingsService {
|
|
|
541
493
|
}));
|
|
542
494
|
}
|
|
543
495
|
catch {
|
|
544
|
-
// Session not ready yet — the picker stays empty until next push.
|
|
545
496
|
return [];
|
|
546
497
|
}
|
|
547
498
|
}
|
|
548
|
-
/** 已配置鉴权的全部模型(子代理模型选择器用;跟随视觉桥的收集方式但不限视觉)。 */
|
|
549
499
|
collectSubagentModels() {
|
|
550
500
|
try {
|
|
551
501
|
const runtime = this.host.getSession().modelRuntime;
|
|
@@ -561,16 +511,12 @@ export class SettingsService {
|
|
|
561
511
|
});
|
|
562
512
|
}
|
|
563
513
|
}
|
|
564
|
-
// 稳定排序:provider 名 → 模型名。
|
|
565
514
|
return out.sort((a, b) => a.provider === b.provider ? a.label.localeCompare(b.label) : a.provider.localeCompare(b.provider));
|
|
566
515
|
}
|
|
567
516
|
catch {
|
|
568
|
-
// Session not ready yet — the picker stays empty until next push.
|
|
569
517
|
return [];
|
|
570
518
|
}
|
|
571
519
|
}
|
|
572
|
-
/** Persist + apply a partial settings update (compose template / per-source
|
|
573
|
-
* overrides, skill/extension toggles). */
|
|
574
520
|
async set(partial) {
|
|
575
521
|
const before = this.host.stateStore.getSettings(this.host.clientId);
|
|
576
522
|
const next = structuredClone(before);
|
|
@@ -581,7 +527,6 @@ export class SettingsService {
|
|
|
581
527
|
partial.promptDisabled !== undefined ||
|
|
582
528
|
partial.disabledSkills !== undefined ||
|
|
583
529
|
partial.disabledExtensions !== undefined;
|
|
584
|
-
// 统一工具开关 live 生效(ActiveSet 加减,无需 reload),见末尾 applyToolGating。
|
|
585
530
|
const toolGatingChanged = partial.disabledAgentTools !== undefined ||
|
|
586
531
|
partial.disabledPluginTools !== undefined ||
|
|
587
532
|
partial.disabledPlugins !== undefined ||
|
|
@@ -599,7 +544,6 @@ export class SettingsService {
|
|
|
599
544
|
next.promptTemplate = partial.promptTemplate;
|
|
600
545
|
}
|
|
601
546
|
if (partial.promptOverrides !== undefined) {
|
|
602
|
-
// 只合并给出的 key;空串 = 清除该来源覆盖。
|
|
603
547
|
const overrides = { ...next.promptOverrides };
|
|
604
548
|
for (const [k, v] of Object.entries(partial.promptOverrides)) {
|
|
605
549
|
if (v && v.trim())
|
|
@@ -612,7 +556,6 @@ export class SettingsService {
|
|
|
612
556
|
if (partial.promptDisabled !== undefined)
|
|
613
557
|
next.promptDisabled = [...partial.promptDisabled];
|
|
614
558
|
if (partial.toolPromptOverrides !== undefined) {
|
|
615
|
-
// 逐工具合并:给出的键整体替换(归一化后为空 = 清除该工具覆盖)。
|
|
616
559
|
const overrides = { ...next.toolPromptOverrides };
|
|
617
560
|
const normalized = normalizeToolPromptOverrides(partial.toolPromptOverrides);
|
|
618
561
|
for (const key of Object.keys(partial.toolPromptOverrides)) {
|
|
@@ -629,16 +572,12 @@ export class SettingsService {
|
|
|
629
572
|
if (partial.disabledExtensions !== undefined) {
|
|
630
573
|
next.disabledExtensions = partial.disabledExtensions;
|
|
631
574
|
}
|
|
632
|
-
// 插件开关是纯 UI 隐藏(不进 needsReload——运行时无需重载)。
|
|
633
575
|
if (partial.disabledPlugins !== undefined) {
|
|
634
576
|
next.disabledPlugins = partial.disabledPlugins;
|
|
635
577
|
}
|
|
636
|
-
// UI 布局偏好只是渲染层的事(顶栏/底栏/右键菜单由前端拼),同样不需 reload。
|
|
637
578
|
if (partial.uiLayout !== undefined) {
|
|
638
579
|
next.uiLayout = normalizeUiLayout(partial.uiLayout);
|
|
639
580
|
}
|
|
640
|
-
// 统一工具开关:新字段优先;只给遗留单开关时折回新字段。两边写完再由
|
|
641
|
-
// deriveLegacy 回填遗留别名,保证内存/推送/落盘三处一致。
|
|
642
581
|
if (partial.disabledAgentTools !== undefined) {
|
|
643
582
|
next.disabledAgentTools = normalizeDisabledAgentTools(partial.disabledAgentTools);
|
|
644
583
|
}
|
|
@@ -660,6 +599,12 @@ export class SettingsService {
|
|
|
660
599
|
next.editSoftEnabled = legacy.editSoftEnabled;
|
|
661
600
|
next.questionnaireEnabled = legacy.questionnaireEnabled;
|
|
662
601
|
}
|
|
602
|
+
if (partial.nativeCliInheritModel !== undefined) {
|
|
603
|
+
next.nativeCliInheritModel = {
|
|
604
|
+
...before.nativeCliInheritModel,
|
|
605
|
+
...normalizeNativeCliInheritModel(partial.nativeCliInheritModel),
|
|
606
|
+
};
|
|
607
|
+
}
|
|
663
608
|
if (partial.terminalBash !== undefined) {
|
|
664
609
|
next.terminalBash = partial.terminalBash;
|
|
665
610
|
}
|
|
@@ -672,17 +617,12 @@ export class SettingsService {
|
|
|
672
617
|
if (partial.toolWatchdogTimeoutMs !== undefined) {
|
|
673
618
|
next.toolWatchdogTimeoutMs = normalizeToolWatchdogTimeoutMs(partial.toolWatchdogTimeoutMs);
|
|
674
619
|
}
|
|
675
|
-
// read 读目录开关:覆盖定义每次调用实时读取,改动即时生效,无需 reload。
|
|
676
620
|
if (partial.readDirEnabled !== undefined) {
|
|
677
621
|
next.readDirEnabled = partial.readDirEnabled;
|
|
678
622
|
}
|
|
679
|
-
// 「后台任务」自动清理阈值(分钟;0 = 关):bg-servers 的定时器每轮实时读,即时生效。
|
|
680
623
|
if (partial.bgAutoCleanupMin !== undefined) {
|
|
681
624
|
next.bgAutoCleanupMin = normalizeBgCleanupMinutes(partial.bgAutoCleanupMin);
|
|
682
625
|
}
|
|
683
|
-
// 工具延迟加载开关(默认关,设置页可开):门控每次实时读取,改动经 applyToolGating 重放生效
|
|
684
|
-
// (见 toolGatingChanged)——**只影响新会话与之后的门控重放**,已有对话的已加载
|
|
685
|
-
// 集合不会被反向清空(不想让在跑的对话凭空丢掉工具)。
|
|
686
626
|
if (partial.toolLazyLoading !== undefined) {
|
|
687
627
|
next.toolLazyLoading = partial.toolLazyLoading === true;
|
|
688
628
|
}
|
|
@@ -695,16 +635,12 @@ export class SettingsService {
|
|
|
695
635
|
next.codemodeInlineBudget = partial.codemodeInlineBudget;
|
|
696
636
|
codemodeChanged = true;
|
|
697
637
|
}
|
|
698
|
-
// 工具执行审批总开关:审批入口每次实时读取(askApproval 顶部门禁),无需 reload。
|
|
699
638
|
if (partial.toolApprovalEnabled !== undefined) {
|
|
700
639
|
next.toolApprovalEnabled = partial.toolApprovalEnabled;
|
|
701
640
|
}
|
|
702
|
-
// 目标模式总开关:运行时无需重载(goal bar / 服务端入口实时读取)。
|
|
703
|
-
// on→off 时立即停掉在飞的目标/调研 —— 不停的话循环照跑照派,开关名存实亡。
|
|
704
641
|
if (partial.goalModeEnabled !== undefined) {
|
|
705
642
|
next.goalModeEnabled = partial.goalModeEnabled;
|
|
706
643
|
}
|
|
707
|
-
// 同项目并行提醒开关:同上,发送入口逐轮实时读取,无需 reload。
|
|
708
644
|
if (partial.parallelReminderEnabled !== undefined) {
|
|
709
645
|
next.parallelReminderEnabled = partial.parallelReminderEnabled;
|
|
710
646
|
}
|
|
@@ -726,7 +662,6 @@ export class SettingsService {
|
|
|
726
662
|
if (partial.keepRecentMessages !== undefined) {
|
|
727
663
|
next.keepRecentMessages = normalizeKeepRecentMessages(partial.keepRecentMessages);
|
|
728
664
|
}
|
|
729
|
-
// 向上分页加载:前端 MessageList 实时读它(纯渲染策略),无需 reload runtime。
|
|
730
665
|
if (partial.reversePagination !== undefined) {
|
|
731
666
|
next.reversePagination = Boolean(partial.reversePagination);
|
|
732
667
|
}
|
|
@@ -744,8 +679,6 @@ export class SettingsService {
|
|
|
744
679
|
}
|
|
745
680
|
next.showForkedParentSessions = nextVal;
|
|
746
681
|
}
|
|
747
|
-
// 编排模式 / skill 全文注入:before_agent_start 逐 run 实时读取(agent-service
|
|
748
|
-
// composeInputs + 指导块追加),开关下一轮即生效,无需 reload runtime。
|
|
749
682
|
if (partial.skillsFullText !== undefined) {
|
|
750
683
|
next.skillsFullText = normalizeSkillList(partial.skillsFullText);
|
|
751
684
|
}
|
|
@@ -786,6 +719,7 @@ export class SettingsService {
|
|
|
786
719
|
if (partial.scmCommitMsgPrompt !== undefined) {
|
|
787
720
|
next.scmCommitMsgPrompt = partial.scmCommitMsgPrompt;
|
|
788
721
|
}
|
|
722
|
+
Object.assign(next, mergeQuickAskSettings(this.settings, partial));
|
|
789
723
|
if (partial.planModePromptMode !== undefined) {
|
|
790
724
|
next.planModePromptMode = partial.planModePromptMode;
|
|
791
725
|
}
|
|
@@ -799,7 +733,6 @@ export class SettingsService {
|
|
|
799
733
|
next.reviewDisabledSkills = partial.reviewDisabledSkills;
|
|
800
734
|
}
|
|
801
735
|
if (partial.subagentDefaultModel !== undefined) {
|
|
802
|
-
// 空串归一为 null(跟随主对话);其余剥空白后存格式 provider/id。
|
|
803
736
|
const m = partial.subagentDefaultModel?.trim() ?? "";
|
|
804
737
|
next.subagentDefaultModel = m ? m : null;
|
|
805
738
|
}
|
|
@@ -835,22 +768,18 @@ export class SettingsService {
|
|
|
835
768
|
next[key] = mode;
|
|
836
769
|
}
|
|
837
770
|
if (partial.retryMaxAttempts !== undefined) {
|
|
838
|
-
// 出错重试次数:持久化 + 即时注入各会话(SDK 在每次退避前都重读
|
|
839
|
-
// getRetrySettings,无需 reload runtime;见宿主 applyRetryOverrides)。
|
|
840
771
|
next.retryMaxAttempts = normalizeRetryMaxAttempts(partial.retryMaxAttempts);
|
|
841
772
|
}
|
|
773
|
+
if (partial.autoCompactionInstructions !== undefined) {
|
|
774
|
+
next.autoCompactionInstructions = normalizeAutoCompactionInstructions(partial.autoCompactionInstructions);
|
|
775
|
+
}
|
|
842
776
|
if (partial.softCapTokens !== undefined || partial.softCapByModel !== undefined) {
|
|
843
|
-
// 压缩软上限:持久化 + 即时重算各会话的 compaction reserveTokens
|
|
844
|
-
// 覆盖(SDK 每次自动压缩检查前都重读 getCompactionSettings,无需
|
|
845
|
-
// reload;见宿主 applyCompactionOverrides,issue #229)。
|
|
846
777
|
if (partial.softCapTokens !== undefined)
|
|
847
778
|
next.softCapTokens = normalizeSoftCapTokens(partial.softCapTokens);
|
|
848
779
|
if (partial.softCapByModel !== undefined)
|
|
849
780
|
next.softCapByModel = normalizeSoftCapByModel(partial.softCapByModel);
|
|
850
|
-
// 底栏标记线读快照的 contextUsage.softCap——推一次快照让在线页即时看到。
|
|
851
781
|
}
|
|
852
782
|
if (partial.quickPhrases !== undefined) {
|
|
853
|
-
// 归一化:去空白/空项/重名,单条 ≤200 字,最多 30 条。纯 UI 偏好,不 reload。
|
|
854
783
|
const seen = new Set();
|
|
855
784
|
next.quickPhrases = (Array.isArray(partial.quickPhrases) ? partial.quickPhrases : [])
|
|
856
785
|
.map((p) => String(p).trim().slice(0, 200))
|
|
@@ -866,8 +795,6 @@ export class SettingsService {
|
|
|
866
795
|
if (partial.preserveDraftAcrossConversations !== undefined) {
|
|
867
796
|
next.preserveDraftAcrossConversations = Boolean(partial.preserveDraftAcrossConversations);
|
|
868
797
|
}
|
|
869
|
-
// 统一工具开关 live 生效(ActiveSet 加减;失败静默,下次创建/reload 重放)。
|
|
870
|
-
// 必须在 this.push() 前生效,保证 promptSnapshot 收集到的是最新的活跃工具集与完整提示词!
|
|
871
798
|
const patch = {};
|
|
872
799
|
for (const key of Object.keys(partial)) {
|
|
873
800
|
if (key in next && partial[key] !== undefined) {
|
|
@@ -901,7 +828,6 @@ export class SettingsService {
|
|
|
901
828
|
if (needsReload)
|
|
902
829
|
await this.applyRuntime();
|
|
903
830
|
}
|
|
904
|
-
/** 保存当前设置为命名预设(同名覆盖)。 */
|
|
905
831
|
async savePreset(name) {
|
|
906
832
|
const n = name.trim();
|
|
907
833
|
if (!n) {
|
|
@@ -923,14 +849,10 @@ export class SettingsService {
|
|
|
923
849
|
this.host.stateStore.savePresets(this.host.clientId, this.presets);
|
|
924
850
|
this.push();
|
|
925
851
|
}
|
|
926
|
-
/** 把当前设置快照成一条预设(名字由调用方给定)。
|
|
927
|
-
* **全量**:`ClientSettings` 的每个字段都进预设(字段清单/分组见 `server/preset-fields.ts`),
|
|
928
|
-
* 导出/分享/导入共用同一张白名单;深层对象做一份拷贝,避免与当前设置共享引用。 */
|
|
929
852
|
snapshotPreset(name) {
|
|
930
853
|
const s = structuredClone(this.current);
|
|
931
854
|
return { ...s, name };
|
|
932
855
|
}
|
|
933
|
-
/** Replace the current settings with the named preset and apply it. */
|
|
934
856
|
async applyPreset(name, runtimeTarget) {
|
|
935
857
|
this.settings = this.current;
|
|
936
858
|
this.presets = this.host.stateStore.getPresets(this.host.clientId);
|
|
@@ -944,7 +866,6 @@ export class SettingsService {
|
|
|
944
866
|
});
|
|
945
867
|
return;
|
|
946
868
|
}
|
|
947
|
-
// 统一工具开关:新预设直接用它;旧预设(只有遗留两开关)按当前禁用名单折算。
|
|
948
869
|
const hasToolSettings = ["disabledAgentTools", "terminalToolsEnabled", "editSoftEnabled"].some((key) => Object.prototype.hasOwnProperty.call(p, key));
|
|
949
870
|
const presetDisabled = normalizeDisabledAgentTools(p.disabledAgentTools ??
|
|
950
871
|
foldLegacyIntoDisabled(this.settings.disabledAgentTools ?? [], {
|
|
@@ -952,8 +873,6 @@ export class SettingsService {
|
|
|
952
873
|
editSoftEnabled: p.editSoftEnabled,
|
|
953
874
|
}));
|
|
954
875
|
const presetLegacy = deriveLegacy(presetDisabled);
|
|
955
|
-
// 全量预设 = 当前设置叠加预设里**实际存在**的字段(缺字段保持当前值)。
|
|
956
|
-
// 旧预设(19 字段)、以及导入时只勾了一部分的预设,都靠这个 merge 落地。
|
|
957
876
|
const patch = { ...p };
|
|
958
877
|
delete patch.name;
|
|
959
878
|
delete patch.plugins;
|
|
@@ -963,7 +882,6 @@ export class SettingsService {
|
|
|
963
882
|
const prevShowForked = this.settings.showForkedParentSessions ?? false;
|
|
964
883
|
this.commitSettings({
|
|
965
884
|
...patch,
|
|
966
|
-
// 部分预设未携带工具字段时,保持当前设置;遗留别名仍统一派生。
|
|
967
885
|
...(hasToolSettings
|
|
968
886
|
? {
|
|
969
887
|
disabledAgentTools: presetDisabled,
|
|
@@ -972,7 +890,6 @@ export class SettingsService {
|
|
|
972
890
|
}
|
|
973
891
|
: {}),
|
|
974
892
|
});
|
|
975
|
-
// 统一收口重放配置覆盖与工具门控(包含 retry/compaction/codemode 与 toolGating)
|
|
976
893
|
if (this.host.applySessionOverrides) {
|
|
977
894
|
this.host.applySessionOverrides();
|
|
978
895
|
}
|
|
@@ -989,20 +906,14 @@ export class SettingsService {
|
|
|
989
906
|
}
|
|
990
907
|
await this.applyRuntime(true, runtimeTarget);
|
|
991
908
|
}
|
|
992
|
-
/** Remove a named preset. */
|
|
993
909
|
async deletePreset(name) {
|
|
994
910
|
this.presets = this.host.stateStore.getPresets(this.host.clientId).filter((p) => p.name !== name);
|
|
995
911
|
this.host.stateStore.savePresets(this.host.clientId, this.presets);
|
|
996
912
|
this.push();
|
|
997
913
|
}
|
|
998
|
-
/* ---------------------------------------------------------------- */
|
|
999
|
-
/* 预设分享:导出 / 导入 / 分享 / 社区目录(server/preset-share.ts) */
|
|
1000
|
-
/* ---------------------------------------------------------------- */
|
|
1001
|
-
/** 当前客户端语言(服务端文案用;与 agent-service 同源)。 */
|
|
1002
914
|
get lang() {
|
|
1003
915
|
return resolveServerLang(this.host.stateStore.get(this.host.clientId).locale);
|
|
1004
916
|
}
|
|
1005
|
-
/** 分享编排(server/preset-share.ts)需要的最小能力集合。 */
|
|
1006
917
|
sharePort() {
|
|
1007
918
|
return {
|
|
1008
919
|
lang: () => this.lang,
|
|
@@ -1027,28 +938,21 @@ export class SettingsService {
|
|
|
1027
938
|
emit: (msg) => this.host.emit(msg),
|
|
1028
939
|
};
|
|
1029
940
|
}
|
|
1030
|
-
/** 导出预设(name 命名的预设)或当前设置(source=current)为 JSON 文本。 */
|
|
1031
941
|
async exportPreset(msg) {
|
|
1032
942
|
exportPresetVia(this.sharePort(), msg);
|
|
1033
943
|
}
|
|
1034
|
-
/** 解析导入的预设 JSON:dryRun = 只回预览(不落盘);apply = 导入后立即应用。 */
|
|
1035
944
|
async importPreset(msg) {
|
|
1036
945
|
await importPresetVia(this.sharePort(), msg);
|
|
1037
946
|
}
|
|
1038
|
-
/** 按网址导入(服务端抓取:避开浏览器 CORS;内网地址已拦截)。 */
|
|
1039
947
|
async importPresetFromUrl(msg) {
|
|
1040
948
|
await importPresetFromUrlVia(this.sharePort(), msg);
|
|
1041
949
|
}
|
|
1042
|
-
/** 一键分享到社区共享仓库(gh issue create;gh 不可用时回落预填网页)。 */
|
|
1043
950
|
async sharePreset(msg) {
|
|
1044
951
|
await sharePresetVia(this.sharePort(), msg);
|
|
1045
952
|
}
|
|
1046
|
-
/** 拉社区共享目录(5 分钟缓存;失败保留上一次成功的列表)。 */
|
|
1047
953
|
async pushPresetCatalog(msg) {
|
|
1048
954
|
await pushPresetCatalogVia(this.sharePort(), msg);
|
|
1049
955
|
}
|
|
1050
|
-
/** Upsert 一个子代理模板(全局共享)。模板只影响未来派生的子代理,
|
|
1051
|
-
* 不需要 reload runtime —— 直接推送新设置状态即可。 */
|
|
1052
956
|
async saveTemplate(template) {
|
|
1053
957
|
const err = this.templates.upsert(template);
|
|
1054
958
|
if (err) {
|
|
@@ -1069,7 +973,6 @@ export class SettingsService {
|
|
|
1069
973
|
textEn: `Subagent template saved: ${n}`,
|
|
1070
974
|
});
|
|
1071
975
|
}
|
|
1072
|
-
/** 删除一个子代理模板。 */
|
|
1073
976
|
async deleteTemplate(name) {
|
|
1074
977
|
this.templates.remove(name);
|
|
1075
978
|
this.push();
|
|
@@ -1080,7 +983,6 @@ export class SettingsService {
|
|
|
1080
983
|
textEn: `Subagent template deleted: ${name}`,
|
|
1081
984
|
});
|
|
1082
985
|
}
|
|
1083
|
-
/** Upsert 一条审批规则(全局共享)。 */
|
|
1084
986
|
async saveApprovalRule(rule) {
|
|
1085
987
|
if (!this.approvalRules)
|
|
1086
988
|
return;
|
|
@@ -1102,7 +1004,6 @@ export class SettingsService {
|
|
|
1102
1004
|
textEn: `Approval rule saved: ${rule.labelEn || rule.label}`,
|
|
1103
1005
|
});
|
|
1104
1006
|
}
|
|
1105
|
-
/** 批量更新审批规则列表(重排或批量保存,全局共享)。 */
|
|
1106
1007
|
async saveApprovalRules(rules) {
|
|
1107
1008
|
if (!this.approvalRules)
|
|
1108
1009
|
return;
|
|
@@ -1124,7 +1025,6 @@ export class SettingsService {
|
|
|
1124
1025
|
textEn: "Approval rules updated",
|
|
1125
1026
|
});
|
|
1126
1027
|
}
|
|
1127
|
-
/** 删除一条自定义审批规则。 */
|
|
1128
1028
|
async deleteApprovalRule(id) {
|
|
1129
1029
|
if (!this.approvalRules)
|
|
1130
1030
|
return;
|
|
@@ -1146,7 +1046,6 @@ export class SettingsService {
|
|
|
1146
1046
|
textEn: "Approval rule deleted",
|
|
1147
1047
|
});
|
|
1148
1048
|
}
|
|
1149
|
-
/** 恢复某条内置审批规则到系统默认设定。 */
|
|
1150
1049
|
async resetBuiltinApprovalRule(id) {
|
|
1151
1050
|
if (!this.approvalRules)
|
|
1152
1051
|
return;
|
|
@@ -1168,11 +1067,6 @@ export class SettingsService {
|
|
|
1168
1067
|
textEn: "Built-in rule reset to default",
|
|
1169
1068
|
});
|
|
1170
1069
|
}
|
|
1171
|
-
/**
|
|
1172
|
-
* Make settings changes effective in the running runtime. The resource-loader
|
|
1173
|
-
* overrides read this.settings at call time, so a reload re-applies them.
|
|
1174
|
-
* Reloading mid-stream would tear down the in-flight run — defer instead.
|
|
1175
|
-
*/
|
|
1176
1070
|
async applyRuntime(throwOnError = false, runtimeTarget) {
|
|
1177
1071
|
if (this.disposed || this.host.isDisposed())
|
|
1178
1072
|
return;
|
|
@@ -1188,7 +1082,6 @@ export class SettingsService {
|
|
|
1188
1082
|
}
|
|
1189
1083
|
await this.applyReload(throwOnError, runtimeTarget);
|
|
1190
1084
|
}
|
|
1191
|
-
/** session.reload() + refresh the slash-command catalog + push state. */
|
|
1192
1085
|
async applyReload(throwOnError = false, runtimeTarget) {
|
|
1193
1086
|
if (this.disposed || this.host.isDisposed())
|
|
1194
1087
|
return;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** Validate a candidate without mutating runtime state; publish its token only after save succeeds. */
|
|
2
1
|
export function saveSetupConfig(input, previous, current, save) {
|
|
3
2
|
const body = (input ?? {});
|
|
4
3
|
const next = { ...previous };
|
|
@@ -29,7 +28,6 @@ export function saveSetupConfig(input, previous, current, save) {
|
|
|
29
28
|
delete next[key];
|
|
30
29
|
}
|
|
31
30
|
if (body.port !== undefined && body.port !== "" && body.port !== null) {
|
|
32
|
-
// HTTP JSON inputs can include objects/arrays; never let coercion throw or accept booleans.
|
|
33
31
|
const p = typeof body.port === "string" || typeof body.port === "number" ? Number(body.port) : NaN;
|
|
34
32
|
if (!Number.isInteger(p) || p <= 0 || p > 65535) {
|
|
35
33
|
return { ok: false, status: 400, error: `port 必须是 1-65535:${String(body.port)}` };
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modern /setup page HTML generation.
|
|
3
|
-
* Features:
|
|
4
|
-
* - Sleek modern dark mode (Tailwind / Radix / Vercel style)
|
|
5
|
-
* - Visual Token generation, toggle visibility, one-click copy with direct token URL
|
|
6
|
-
* - Status pills (active, pending restart, secure / insecure)
|
|
7
|
-
* - Clear guidance and tooltips
|
|
8
|
-
* - Security note: only localhost/loopback non-proxy requests can reach this page.
|
|
9
|
-
*/
|
|
10
1
|
export function renderSetupHtml() {
|
|
11
2
|
return `<!doctype html>
|
|
12
3
|
<html lang="zh-CN">
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* skill-content-filler — 技能全文注入({{skills}} 全文模式)内容填充器。
|
|
3
|
-
*
|
|
4
|
-
* 负责读取名单里技能的文件正文。
|
|
5
|
-
* 单文件上限(默认 8KB)与总量预算(默认 32KB)都由调用方传入,缺省即历史硬编码值
|
|
6
|
-
* (设置项 skillsMaxFileBytes / skillsFullTextMaxBytes,见 issue #819);
|
|
7
|
-
* 失败/超限/不在名单回落名录(无 content)。
|
|
8
|
-
* 名单为空时零开销:原样返回,不碰磁盘。
|
|
9
|
-
*
|
|
10
|
-
* 预算口径是 **UTF-8 字节**:注入的是文本,模型按 token 付费,而字节数才是文件大小
|
|
11
|
-
* 与上下文占用的共同尺度。以前按 `raw.length`(JavaScript 字符数)扣预算,同样的
|
|
12
|
-
* 中文技能会被低估约 3 倍,总量可以冲出上限。
|
|
13
|
-
*
|
|
14
|
-
* 从 agent-service.ts 抽出为独立模块。
|
|
15
|
-
*/
|
|
16
1
|
import { readFileSync, statSync } from "node:fs";
|
|
17
2
|
import { decodeText } from "./text-sniff.js";
|
|
18
3
|
import { DEFAULT_SKILLS_FULL_TEXT_MAX_BYTES, DEFAULT_SKILLS_MAX_FILE_BYTES, normalizeSkillList, normalizeSkillsFullTextMaxBytes, normalizeSkillsMaxFileBytes, } from "./client-state.js";
|
|
@@ -26,7 +11,6 @@ export function fillSkillContents(skills, skillsFullTextConfig, limits = {}) {
|
|
|
26
11
|
const maxTotal = limits.maxTotalBytes === undefined
|
|
27
12
|
? DEFAULT_SKILLS_FULL_TEXT_MAX_BYTES
|
|
28
13
|
: normalizeSkillsFullTextMaxBytes(limits.maxTotalBytes);
|
|
29
|
-
// 0 = 显式不设限:用 Infinity 让下面的预算判断保持单一路径。
|
|
30
14
|
let budget = maxTotal > 0 ? maxTotal : Number.POSITIVE_INFINITY;
|
|
31
15
|
return skills.map((s) => {
|
|
32
16
|
if (!wanted.has(s.name) || !s.filePath || budget <= 0)
|
|
@@ -39,7 +23,6 @@ export function fillSkillContents(skills, skillsFullTextConfig, limits = {}) {
|
|
|
39
23
|
return s;
|
|
40
24
|
const room = Math.min(st.size, budget);
|
|
41
25
|
const slice = readFileSync(s.filePath).subarray(0, room);
|
|
42
|
-
// 按预算截断时末尾可能是半个多字节字符,解码成 U+FFFD —— 丢掉它,别把乱码塞进提示词。
|
|
43
26
|
const text = decodeText(slice);
|
|
44
27
|
const raw = (room < st.size ? text.replace(/\uFFFD+$/u, "") : text).trim();
|
|
45
28
|
if (!raw)
|