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,7 +1,3 @@
|
|
|
1
|
-
/** Slash commands implemented natively by the web server (the pi CLI's built-in
|
|
2
|
-
* interactive commands like /model and /new are NOT handled by the SDK's
|
|
3
|
-
* prompt() — without this they'd be sent to the model as plain text). Keep in
|
|
4
|
-
* sync with exec(). */
|
|
5
1
|
export const NATIVE_COMMANDS = [
|
|
6
2
|
{
|
|
7
3
|
name: "new",
|
|
@@ -58,7 +54,6 @@ export const NATIVE_COMMANDS = [
|
|
|
58
54
|
{ name: "copy", description: "复制上一条助手回复", descriptionEn: "Copy last assistant reply" },
|
|
59
55
|
{ name: "pi-web-ui:quit", description: "退出服务", descriptionEn: "Quit server (supervisor will restart)" },
|
|
60
56
|
];
|
|
61
|
-
/** Parse a prompt into "/command args" — returns null when it isn't one. */
|
|
62
57
|
export function parseSlash(text) {
|
|
63
58
|
const trimmed = text.trim();
|
|
64
59
|
if (!trimmed.startsWith("/"))
|
|
@@ -73,12 +68,6 @@ export class SlashCommandsService {
|
|
|
73
68
|
constructor(host) {
|
|
74
69
|
this.host = host;
|
|
75
70
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Catalog of slash commands for the chat input: web-native builtins first,
|
|
78
|
-
* then the SDK's invokable commands for the ACTIVE conversation (extension
|
|
79
|
-
* commands, prompt templates, skills) — the same set the SDK expands when a
|
|
80
|
-
* prompt text starts with "/" (see AgentSession.prompt).
|
|
81
|
-
*/
|
|
82
71
|
async push() {
|
|
83
72
|
const commands = [];
|
|
84
73
|
const seen = new Set();
|
|
@@ -90,9 +79,6 @@ export class SlashCommandsService {
|
|
|
90
79
|
try {
|
|
91
80
|
const s = this.host.getSession();
|
|
92
81
|
if (s) {
|
|
93
|
-
// Extension commands — the SDK already suffixes collisions with builtin
|
|
94
|
-
// names ("new:2"), and those still reach the SDK since exec() only
|
|
95
|
-
// intercepts the exact native names.
|
|
96
82
|
for (const cmd of s.extensionRunner?.getRegisteredCommands?.() ?? []) {
|
|
97
83
|
if (seen.has(cmd.invocationName))
|
|
98
84
|
continue;
|
|
@@ -103,7 +89,6 @@ export class SlashCommandsService {
|
|
|
103
89
|
});
|
|
104
90
|
seen.add(cmd.invocationName);
|
|
105
91
|
}
|
|
106
|
-
// Prompt templates: /templatename args
|
|
107
92
|
for (const t of s.promptTemplates ?? []) {
|
|
108
93
|
if (seen.has(t.name))
|
|
109
94
|
continue;
|
|
@@ -114,7 +99,6 @@ export class SlashCommandsService {
|
|
|
114
99
|
});
|
|
115
100
|
seen.add(t.name);
|
|
116
101
|
}
|
|
117
|
-
// Skills: /skill:name args
|
|
118
102
|
for (const skill of s.resourceLoader?.getSkills?.()?.skills ?? []) {
|
|
119
103
|
const name = `skill:${skill.name}`;
|
|
120
104
|
if (seen.has(name))
|
|
@@ -128,11 +112,8 @@ export class SlashCommandsService {
|
|
|
128
112
|
}
|
|
129
113
|
}
|
|
130
114
|
}
|
|
131
|
-
catch {
|
|
132
|
-
// Session not ready yet — native-only catalog still serves the picker.
|
|
133
|
-
}
|
|
115
|
+
catch { }
|
|
134
116
|
}
|
|
135
|
-
// 外部或通用引擎注入的技能(Universal / DSH)
|
|
136
117
|
if (this.host.getSkills) {
|
|
137
118
|
try {
|
|
138
119
|
const skills = await this.host.getSkills();
|
|
@@ -148,11 +129,8 @@ export class SlashCommandsService {
|
|
|
148
129
|
seen.add(name);
|
|
149
130
|
}
|
|
150
131
|
}
|
|
151
|
-
catch {
|
|
152
|
-
/* ignore */
|
|
153
|
-
}
|
|
132
|
+
catch { }
|
|
154
133
|
}
|
|
155
|
-
// 驱动自定义斜杠命令(如 Claude Code: /cost, /doctor, /init 等)
|
|
156
134
|
if (this.host.getExtraCommands) {
|
|
157
135
|
try {
|
|
158
136
|
const extra = await this.host.getExtraCommands();
|
|
@@ -163,14 +141,11 @@ export class SlashCommandsService {
|
|
|
163
141
|
seen.add(cmd.name);
|
|
164
142
|
}
|
|
165
143
|
}
|
|
166
|
-
catch {
|
|
167
|
-
/* ignore */
|
|
168
|
-
}
|
|
144
|
+
catch { }
|
|
169
145
|
}
|
|
170
|
-
// UI 插件注册的命令(host.registerCommand)——全局,不依赖会话就绪。
|
|
171
146
|
for (const cmd of this.host.pluginCommands?.() ?? []) {
|
|
172
147
|
if (seen.has(cmd.name))
|
|
173
|
-
continue;
|
|
148
|
+
continue;
|
|
174
149
|
commands.push({
|
|
175
150
|
name: cmd.name,
|
|
176
151
|
description: cmd.description,
|
|
@@ -183,19 +158,11 @@ export class SlashCommandsService {
|
|
|
183
158
|
}
|
|
184
159
|
this.host.emit({ type: "slash_commands", commands });
|
|
185
160
|
}
|
|
186
|
-
/** Run a native slash command (see NATIVE_COMMANDS). Returns false when the
|
|
187
|
-
* name is not a native command (the prompt falls through to the SDK). */
|
|
188
161
|
async exec(name, args) {
|
|
189
162
|
switch (name) {
|
|
190
163
|
case "new": {
|
|
191
164
|
const first = args.trim();
|
|
192
165
|
const ready = await this.host.newChat();
|
|
193
|
-
// /new <prompt>: deliver the text as the new session's first
|
|
194
|
-
// prompt, exactly as if typed after the switch. Empty = old
|
|
195
|
-
// behavior (blank chat, no send). Only when the switch actually
|
|
196
|
-
// landed on a blank chat — newChat() reports false when it bailed
|
|
197
|
-
// (cap reached / runtime creation failed) and sending anyway would
|
|
198
|
-
// drop the text into the conversation the user was already in.
|
|
199
166
|
if (ready !== false && first && this.host.prompt)
|
|
200
167
|
await this.host.prompt(first);
|
|
201
168
|
return true;
|
|
@@ -258,7 +225,6 @@ export class SlashCommandsService {
|
|
|
258
225
|
}
|
|
259
226
|
const hasLister = Boolean(this.host.getSession || this.host.getAvailableModels);
|
|
260
227
|
if (hasLister) {
|
|
261
|
-
// Prefer an exact "provider/id" match, else id/name substring.
|
|
262
228
|
const exact = available.find((m) => (m.provider ? `${m.provider}/${m.id}` : m.id) === args.trim());
|
|
263
229
|
const matches = exact
|
|
264
230
|
? [exact]
|
|
@@ -307,11 +273,7 @@ export class SlashCommandsService {
|
|
|
307
273
|
});
|
|
308
274
|
}
|
|
309
275
|
}
|
|
310
|
-
catch {
|
|
311
|
-
// 压缩过程/结果/错误反馈统一由 agent-service onEvent 的
|
|
312
|
-
// compaction_start / compaction_end 事件处理(含 errorMessage),
|
|
313
|
-
// 这里不重复发通知;SDK 在 throw 前必发 compaction_end(issue #33)。
|
|
314
|
-
}
|
|
276
|
+
catch { }
|
|
315
277
|
return true;
|
|
316
278
|
case "cwd":
|
|
317
279
|
if (!args) {
|
|
@@ -376,15 +338,12 @@ export class SlashCommandsService {
|
|
|
376
338
|
return true;
|
|
377
339
|
case "reload":
|
|
378
340
|
try {
|
|
379
|
-
// Re-discovers extensions / skills / prompt templates from disk and
|
|
380
|
-
// re-pushes the picker catalog (the CLI's /reload semantics).
|
|
381
341
|
if (this.host.reload) {
|
|
382
342
|
await this.host.reload();
|
|
383
343
|
}
|
|
384
344
|
else if (this.host.getSession) {
|
|
385
345
|
await this.host.getSession().reload();
|
|
386
346
|
}
|
|
387
|
-
// reload() 会把 custom 工具加回活跃集——重放设置门控(终端开关等)。
|
|
388
347
|
this.host.afterReload?.();
|
|
389
348
|
await this.push();
|
|
390
349
|
this.host.emit({
|
|
@@ -432,17 +391,13 @@ export class SlashCommandsService {
|
|
|
432
391
|
return true;
|
|
433
392
|
}
|
|
434
393
|
case "copy":
|
|
435
|
-
// Client-side UI actions — the client handles them before sending;
|
|
436
|
-
// swallow here so the SDK never sees them as plain prompt text.
|
|
437
394
|
return true;
|
|
438
395
|
default:
|
|
439
|
-
// 驱动扩展命令优先拦截
|
|
440
396
|
if (this.host.execExtraCommand) {
|
|
441
397
|
const handled = await this.host.execExtraCommand(name, args);
|
|
442
398
|
if (handled)
|
|
443
399
|
return true;
|
|
444
400
|
}
|
|
445
|
-
// 插件命令:拦截执行(纯配置动作,与内置命令同级,不到 SDK)。
|
|
446
401
|
return (await this.host.execPluginCommand?.(name, args)) ?? false;
|
|
447
402
|
}
|
|
448
403
|
}
|
package/dist/server/soft-cap.js
CHANGED
|
@@ -1,37 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 自定义上下文压缩阈值(Soft Cap,issue #229,issue #716,issue #773)。
|
|
3
|
-
*
|
|
4
|
-
* 背景:SDK 的自动压缩只看物理上限(shouldCompact:tokens > window - reserveTokens,
|
|
5
|
-
* reserveTokens 默认 16384)。对 1M 上下文的模型会堆到 ~900K 才压;对 Grok 这类
|
|
6
|
-
* 200K 起阶梯翻倍计费的模型,会在高价区跑很久,还伴随长上下文降智。
|
|
7
|
-
*
|
|
8
|
-
* 实现机制(双层管控,两层共用同一个软上限 cap):
|
|
9
|
-
* 1. 回合内层(SDK reserve,issue #773):把 compaction.reserveTokens 逐会话算成
|
|
10
|
-
* cw - cap(下限仍是默认 16384),让 SDK 在**每次工具调用间隙**的
|
|
11
|
-
* _compactBeforeNextAssistantResponse 里就能在 cap 处压缩。自治长跑(子代理、
|
|
12
|
-
* 单回合几十次工具调用)全程没有空闲态,只有这一层能拦住它。
|
|
13
|
-
* 必须是「逐会话无状态重算」(各自用自己当前模型算),否则换模型会残留上一模型的
|
|
14
|
-
* W - C,这正是 #716 当初撤掉注入的原因;重算点见 applyCompactionOverrides。
|
|
15
|
-
* 2. 空闲态层(pi-web-ui 主动压缩):回合结算后 / 新一轮提问前,若有效 token 已达 cap
|
|
16
|
-
* 则主动 session.compact()。它负责 reserve 管不到的场景:cap 中途下调、附件注入
|
|
17
|
-
* 超阈、从磁盘恢复的已超阈会话(首个请求前没有任何检查点)。
|
|
18
|
-
* 3. 物理防爆始终在:reserve 只取 max(默认 16384, cw - cap),触发点永远不晚于
|
|
19
|
-
* cw - 16384;cap 关闭/非法时 reserve 回落默认值,等于原样的物理兜底线。
|
|
20
|
-
*
|
|
21
|
-
* softCapToReserve / softCapReserveFor 同时服务分层上下文预算裁剪(context-budget-runner)。
|
|
22
|
-
*/
|
|
23
1
|
import { DEFAULT_COMPACTION_SETTINGS } from "@earendil-works/pi-coding-agent";
|
|
24
|
-
/** SDK 默认保留 token(软上限关闭时的回填值)。 */
|
|
25
2
|
export const DEFAULT_COMPACTION_RESERVE_TOKENS = DEFAULT_COMPACTION_SETTINGS.reserveTokens;
|
|
26
|
-
/** 软上限下限(tokens):低于此值每轮都压,无意义,直接视为关闭。 */
|
|
27
3
|
export const SOFT_CAP_MIN_TOKENS = 2000;
|
|
28
|
-
/** 压缩后至少要剩这么多工作空间(摘要本身也要占 reserve*0.8 的预算)。 */
|
|
29
4
|
export const SOFT_CAP_MIN_HEADROOM = 2048;
|
|
30
|
-
/** 单客户端最多存多少条按模型覆盖(防手滑粘贴刷爆 client-state)。 */
|
|
31
5
|
export const SOFT_CAP_MAX_OVERRIDES = 64;
|
|
32
|
-
/** 归一化全局软上限:支持数字或带单位字符串(如 "300k", "1.5m", "300,000");
|
|
33
|
-
* <= 1000 的正数智能识别为 K tokens(如 300 -> 300,000);<=0 或非法 = 关闭;
|
|
34
|
-
* 钳制到 [0, 10_000_000] 整数。纯函数。 */
|
|
35
6
|
export function normalizeSoftCapTokens(v) {
|
|
36
7
|
if (v === null || v === undefined)
|
|
37
8
|
return 0;
|
|
@@ -70,8 +41,6 @@ export function normalizeSoftCapTokens(v) {
|
|
|
70
41
|
}
|
|
71
42
|
return Math.min(10_000_000, Math.max(0, tokens));
|
|
72
43
|
}
|
|
73
|
-
/** 归一化按模型覆盖:key = "provider/id" 非空(≤200 字),value 走
|
|
74
|
-
* normalizeSoftCapTokens;0 值条目丢弃(= 用全局);上限 64 条。纯函数。 */
|
|
75
44
|
export function normalizeSoftCapByModel(v) {
|
|
76
45
|
if (!v || typeof v !== "object" || Array.isArray(v))
|
|
77
46
|
return {};
|
|
@@ -88,7 +57,9 @@ export function normalizeSoftCapByModel(v) {
|
|
|
88
57
|
}
|
|
89
58
|
return out;
|
|
90
59
|
}
|
|
91
|
-
|
|
60
|
+
export function normalizeAutoCompactionInstructions(v) {
|
|
61
|
+
return typeof v === "string" ? v.slice(0, 2000) : "";
|
|
62
|
+
}
|
|
92
63
|
export function effectiveSoftCap(globalCap, byModel, modelId) {
|
|
93
64
|
if (modelId) {
|
|
94
65
|
const per = byModel?.[modelId.trim()];
|
|
@@ -97,8 +68,6 @@ export function effectiveSoftCap(globalCap, byModel, modelId) {
|
|
|
97
68
|
}
|
|
98
69
|
return globalCap > 0 ? globalCap : 0;
|
|
99
70
|
}
|
|
100
|
-
/** 软上限 → SDK reserveTokens(null = 不合法/关闭,走 SDK 默认)。
|
|
101
|
-
* 合法条件:cap ≥ SOFT_CAP_MIN_TOKENS 且压完至少剩 SOFT_CAP_MIN_HEADROOM。 */
|
|
102
71
|
export function softCapToReserve(contextWindow, cap) {
|
|
103
72
|
if (!Number.isFinite(contextWindow) || contextWindow <= 0)
|
|
104
73
|
return null;
|
|
@@ -109,12 +78,6 @@ export function softCapToReserve(contextWindow, cap) {
|
|
|
109
78
|
return null;
|
|
110
79
|
return reserve;
|
|
111
80
|
}
|
|
112
|
-
/** 注入 SDK 的 reserveTokens(issue #773):软上限合法时 = cw - cap,否则回落默认值。
|
|
113
|
-
*
|
|
114
|
-
* 额外守卫(keepRecentTokens):SDK 压缩按 keepRecentTokens(默认 20000)留尾部,
|
|
115
|
-
* 若 cap ≤ keepRecent + SOFT_CAP_MIN_HEADROOM,压完立刻又超阈 → 回合内每个工具间隙
|
|
116
|
-
* 都重压一次(每次都要付摘要请求的钱),比撞墙还贵。这种「压不下来」的 cap 一律不注射,
|
|
117
|
-
* 交给空闲态层与物理兜底。keepRecentTokens 未知(0/非法)时不做该守卫。 */
|
|
118
81
|
export function softCapReserveFor(contextWindow, cap, keepRecentTokens = 0) {
|
|
119
82
|
const reserve = softCapToReserve(contextWindow, cap);
|
|
120
83
|
if (reserve === null)
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import { isLoopbackHost } from "./host-guard.js";
|
|
2
|
-
/**
|
|
3
|
-
* 计算服务对外展示的主入口 URL。
|
|
4
|
-
* - 当配置了 token 时,自动追加 `/?token=...`,确保用户从控制台或脚本直达 Web 界面并完成认证;
|
|
5
|
-
* - 回环地址与 0.0.0.0 归一化为 localhost,保证浏览器直接点击可达。
|
|
6
|
-
*/
|
|
7
2
|
export function buildMainUrl(port, host, token) {
|
|
8
3
|
const trimmedToken = token?.trim() ?? "";
|
|
9
4
|
const urlHost = isLoopbackHost(host) || host === "0.0.0.0" ? "localhost" : host;
|
|
10
5
|
const tokenQuery = trimmedToken ? `/?token=${encodeURIComponent(trimmedToken)}` : "";
|
|
11
6
|
return `http://${urlHost}:${port}${tokenQuery}`;
|
|
12
7
|
}
|
|
13
|
-
/**
|
|
14
|
-
* 格式化启动横幅日志文本行列表。
|
|
15
|
-
*/
|
|
16
8
|
export function formatStartupBannerLines(params) {
|
|
17
9
|
const mainUrl = buildMainUrl(params.port, params.host, params.token);
|
|
18
10
|
const lines = [
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* subagent-handoff — 子代理对等直接交接消息格式化与历史记录工具。
|
|
3
|
-
*
|
|
4
|
-
* 负责:
|
|
5
|
-
* - formatSubagentHandoffMessage: 格式化带角色与源 ID 的交接指令
|
|
6
|
-
* - recordSubagentHandoff: 维护限制容量的交接历史时间戳队列
|
|
7
|
-
*
|
|
8
|
-
* 从 agent-service.ts 抽出为独立模块。
|
|
9
|
-
*/
|
|
10
|
-
/** 格式化对等交接注入给目标子代理的消息 */
|
|
11
1
|
export function formatSubagentHandoffMessage(fromType, fromRunId, payload) {
|
|
12
2
|
return `[Peer Hand-off from ${fromType} subagent (${fromRunId.slice(0, 8)})]:\n\n${payload}`;
|
|
13
3
|
}
|
|
14
|
-
/** 追加交接记录并维持最近 N 条的滑动窗口 */
|
|
15
4
|
export function recordSubagentHandoff(history, record, maxHistory = 50) {
|
|
16
5
|
const next = [...history, record];
|
|
17
6
|
return next.length > maxHistory ? next.slice(-maxHistory) : next;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { SUBAGENT_PROMPT_SNAPSHOT_CAP } from "./agent-formatters.js";
|
|
2
2
|
import { conversationIdentity, parentConversationIdentity, conversationParent } from "./conversation-identity.js";
|
|
3
|
-
/** 子代理是否处于活跃(流式运行中或首轮投递启动中)状态。
|
|
4
|
-
* #589:名额与可见性解耦——仅活跃(非终态)子代理占用 MAX_SUBAGENTS 并发名额;
|
|
5
|
-
* 已结束(done / canceled / error)的子代理保留在左栏供用户审阅追溯,不再占名额。 */
|
|
6
3
|
export function isSubagentActive(conv) {
|
|
7
4
|
if (!conv.isSubagent)
|
|
8
5
|
return false;
|
|
@@ -15,7 +12,6 @@ export function isSubagentActive(conv) {
|
|
|
15
12
|
return false;
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
/** 统计当前占用并发名额的活跃子代理数(含正在创建 runtime 的在途 spawn,不含已终态子代理,#589)。 */
|
|
19
15
|
export function countActiveSubagents(convs, spawningCount = 0) {
|
|
20
16
|
let count = Math.max(0, Math.floor(spawningCount));
|
|
21
17
|
for (const c of convs) {
|
|
@@ -24,11 +20,7 @@ export function countActiveSubagents(convs, spawningCount = 0) {
|
|
|
24
20
|
}
|
|
25
21
|
return count;
|
|
26
22
|
}
|
|
27
|
-
/** 子代理最近一次运行的结局:最后一条 assistant 消息的 errorMessage / stopReason。
|
|
28
|
-
* 报错 > 中止 > 正常,三者互斥;无 assistant 消息时返回空。 */
|
|
29
23
|
export function subagentRunOutcome(conv) {
|
|
30
|
-
// 自动重试等待期结局未定:瞬时 error 不算失败,避免向主对话误报
|
|
31
|
-
// 「子代理运行失败」(耗尽后 auto_retry_end 清旗,真正失败照常通知)。
|
|
32
24
|
if (conv.subagentTaskStopped)
|
|
33
25
|
return { canceled: true };
|
|
34
26
|
if (conv.retryState)
|
|
@@ -50,12 +42,9 @@ export function subagentRunOutcome(conv) {
|
|
|
50
42
|
break;
|
|
51
43
|
}
|
|
52
44
|
}
|
|
53
|
-
catch {
|
|
54
|
-
// session being replaced — treat as no outcome yet
|
|
55
|
-
}
|
|
45
|
+
catch { }
|
|
56
46
|
return {};
|
|
57
47
|
}
|
|
58
|
-
/** 对话结局 → 角色轮结局(报错 > 中止 > 正常)。 */
|
|
59
48
|
export function roleOutcomeOf(conv) {
|
|
60
49
|
const { error, canceled } = subagentRunOutcome(conv);
|
|
61
50
|
if (error)
|
|
@@ -64,7 +53,6 @@ export function roleOutcomeOf(conv) {
|
|
|
64
53
|
return "canceled";
|
|
65
54
|
return "done";
|
|
66
55
|
}
|
|
67
|
-
/** 序列化对话为前端可消费的子代理快照 */
|
|
68
56
|
export function toSubagentSnapshot(conv) {
|
|
69
57
|
let sessionStreaming = false;
|
|
70
58
|
try {
|
|
@@ -80,9 +68,7 @@ export function toSubagentSnapshot(conv) {
|
|
|
80
68
|
try {
|
|
81
69
|
messageCount = conv.session.getSessionStats().totalMessages;
|
|
82
70
|
}
|
|
83
|
-
catch {
|
|
84
|
-
// session being replaced — report defaults
|
|
85
|
-
}
|
|
71
|
+
catch { }
|
|
86
72
|
let thinkingLevel;
|
|
87
73
|
try {
|
|
88
74
|
thinkingLevel = conv.session.thinkingLevel ?? conv.subagentThinking;
|
|
@@ -130,7 +116,6 @@ export function toSubagentSnapshot(conv) {
|
|
|
130
116
|
: undefined,
|
|
131
117
|
};
|
|
132
118
|
}
|
|
133
|
-
/** 列举并排序子代理快照集合 */
|
|
134
119
|
export function listSubagentSnapshots(convs, scope) {
|
|
135
120
|
return [...convs]
|
|
136
121
|
.filter((c) => {
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// subagent-notify.ts — 子代理终态自动通知与结构化交付契约(issue #713)
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// 负责:
|
|
5
|
-
// 1. extractSubagentConclusion: 提炼子代理输出的核心结论(保留首尾重点,折叠冗余日志)
|
|
6
|
-
// 2. formatSubagentsCompletionNotice: 将批处理/防抖收敛的一组终态子代理格式化为
|
|
7
|
-
// 高信噪比、低 Token 占用的父对话唤醒汇报
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
1
|
import { pick } from "./i18n.js";
|
|
10
2
|
import { subagentRunOutcome } from "./subagent-helpers.js";
|
|
11
|
-
/**
|
|
12
|
-
* 从子代理的长文本输出中提取核心结论:
|
|
13
|
-
* - 输出较短(<= 20 行)时原样返回;
|
|
14
|
-
* - 输出较长时保留前 3 行任务概况与后 15 行最终总结/结论,中间过程性输出自适应折叠;
|
|
15
|
-
* - 空输出给出可读占位符。
|
|
16
|
-
*/
|
|
17
3
|
export function extractSubagentConclusion(output, lang = "en") {
|
|
18
4
|
const trimmed = (output ?? "").trim();
|
|
19
5
|
if (!trimmed) {
|
|
@@ -31,14 +17,9 @@ export function extractSubagentConclusion(output, lang = "en") {
|
|
|
31
17
|
: `… [${omitted} lines omitted, full transcript available via get_result] …`;
|
|
32
18
|
return `${head}\n${omitMarker}\n${tail}`;
|
|
33
19
|
}
|
|
34
|
-
/** 短 id(前 8 字符) */
|
|
35
20
|
function shortId(id) {
|
|
36
21
|
return id.slice(0, 8);
|
|
37
22
|
}
|
|
38
|
-
/**
|
|
39
|
-
* 格式化聚合的一组终态子代理为父对话的入站通知。
|
|
40
|
-
* 多个子代理同时完成时合成一条结构化汇报,避免碎片化打断父对话。
|
|
41
|
-
*/
|
|
42
23
|
export function formatSubagentsCompletionNotice(subagents, lang = "en", fallbackOriginalParentId) {
|
|
43
24
|
if (subagents.length === 0)
|
|
44
25
|
return "";
|
|
@@ -2,16 +2,8 @@ import { pick } from "./i18n.js";
|
|
|
2
2
|
import { bashCommandHasSupportedSyntax, bashCommandIsReadOnly, readOnlyToolCallAllowed } from "./plan-mode.js";
|
|
3
3
|
import { goalReviewBashAllowed } from "./goal-review-gate.js";
|
|
4
4
|
import { isReadOnlyConversationAction, conversationToolAllowed, isConversationTool, } from "./conversation-tool-names.js";
|
|
5
|
-
/** 常见只读角色关键词(转小写后包含即判定为 readonly)。 */
|
|
6
5
|
const READONLY_ROLE_KEYWORDS = ["explore", "scout", "research", "oracle", "librarian", "reader"];
|
|
7
|
-
/** 常见审查验证角色关键词(转小写后包含即判定为 verify)。 */
|
|
8
6
|
const VERIFY_ROLE_KEYWORDS = ["review", "audit", "verify", "inspector"];
|
|
9
|
-
/**
|
|
10
|
-
* 解析并推导子代理的安全模式:
|
|
11
|
-
* 1. 优先使用模板显式声明的 securityMode;
|
|
12
|
-
* 2. 其次根据模板名或 type 关键词兜底(保障老用户无 securityMode 字段的模板或直接传 type 时自然生效);
|
|
13
|
-
* 3. 缺省返回 "normal"。
|
|
14
|
-
*/
|
|
15
7
|
export function resolveSecurityMode(nameOrType, template) {
|
|
16
8
|
if (template?.securityMode && template.securityMode !== "normal") {
|
|
17
9
|
return template.securityMode;
|
|
@@ -29,7 +21,6 @@ export function resolveSecurityMode(nameOrType, template) {
|
|
|
29
21
|
}
|
|
30
22
|
return "normal";
|
|
31
23
|
}
|
|
32
|
-
/** 别名映射:将调用方可能传入的泛称归一化为实际注册的工具名。 */
|
|
33
24
|
const TOOL_NAME_ALIASES = {
|
|
34
25
|
terminal: "terminal",
|
|
35
26
|
shell: "bash",
|
|
@@ -43,25 +34,13 @@ const TOOL_NAME_ALIASES = {
|
|
|
43
34
|
view: "read",
|
|
44
35
|
cat: "read",
|
|
45
36
|
};
|
|
46
|
-
/**
|
|
47
|
-
* 宽容解析 delegate_task 的 required_tools 文本。
|
|
48
|
-
* 支持:
|
|
49
|
-
* - 逗号/分号/空白分隔:"read, grep, find"
|
|
50
|
-
* - 换行列表:"- read\n- grep"
|
|
51
|
-
* - 预设代称识别:"read-only" / "readonly" -> 返回空 allowedTools 但可标明预设意图
|
|
52
|
-
*
|
|
53
|
-
* @param raw 模型传入的原始输入
|
|
54
|
-
* @param availableTools 当前环境可用工具名集合(可选,若提供则校验合法性)
|
|
55
|
-
*/
|
|
56
37
|
export function parseRequiredTools(raw, availableTools) {
|
|
57
38
|
if (typeof raw !== "string" || !raw.trim()) {
|
|
58
39
|
return {};
|
|
59
40
|
}
|
|
60
41
|
const text = raw.trim();
|
|
61
|
-
// 特殊标记识别
|
|
62
42
|
const lower = text.toLowerCase();
|
|
63
43
|
const requestedReadOnly = lower.includes("read-only") || lower.includes("readonly") || lower.includes("reader");
|
|
64
|
-
// 匹配单词 token(支持连字符与下划线,如 edit_soft)
|
|
65
44
|
const matches = text.match(/[A-Za-z0-9_-]+/g) || [];
|
|
66
45
|
const availableSet = availableTools instanceof Set ? availableTools : availableTools ? new Set(availableTools) : null;
|
|
67
46
|
const seen = new Set();
|
|
@@ -69,7 +48,6 @@ export function parseRequiredTools(raw, availableTools) {
|
|
|
69
48
|
const unrecognized = [];
|
|
70
49
|
for (const item of matches) {
|
|
71
50
|
const token = item.trim().toLowerCase();
|
|
72
|
-
// 跳过常见的介词、连接词与预设代称关键词
|
|
73
51
|
if ([
|
|
74
52
|
"and",
|
|
75
53
|
"or",
|
|
@@ -112,7 +90,6 @@ export function parseRequiredTools(raw, availableTools) {
|
|
|
112
90
|
requestedReadOnly,
|
|
113
91
|
};
|
|
114
92
|
}
|
|
115
|
-
/** 目标模式与只读模式下公认的硬写类工具名。 */
|
|
116
93
|
export const SUBAGENT_WRITE_TOOL_NAMES = new Set([
|
|
117
94
|
"write",
|
|
118
95
|
"create",
|
|
@@ -143,18 +120,14 @@ export const SUBAGENT_WRITE_TOOL_NAMES = new Set([
|
|
|
143
120
|
"codemode",
|
|
144
121
|
"powershell",
|
|
145
122
|
]);
|
|
146
|
-
/** 交互式终端输入工具:受限模式下必须禁用,防止通过交互输入写命令绕过检测。 */
|
|
147
123
|
export const SUBAGENT_TERMINAL_INPUT_TOOLS = new Set([
|
|
148
124
|
"terminal_input",
|
|
149
125
|
"terminal_key",
|
|
150
126
|
"terminal_create",
|
|
151
127
|
"terminal_close",
|
|
152
128
|
]);
|
|
153
|
-
/** 越权派发工具:受限子代理禁止再派生/操控其他子代理。 */
|
|
154
129
|
export const SUBAGENT_DISPATCH_TOOLS = new Set(["delegate_task"]);
|
|
155
|
-
/** bash 类工具名。 */
|
|
156
130
|
const BASH_TOOL_NAMES = new Set(["bash", "bash_execute", "run_command", "shell", "terminal_exec"]);
|
|
157
|
-
/** 取工具参数中的命令字段。 */
|
|
158
131
|
function commandOf(params) {
|
|
159
132
|
if (!params || typeof params !== "object")
|
|
160
133
|
return "";
|
|
@@ -166,15 +139,6 @@ function commandOf(params) {
|
|
|
166
139
|
}
|
|
167
140
|
return "";
|
|
168
141
|
}
|
|
169
|
-
/**
|
|
170
|
-
* 校验子代理对指定工具的调用是否违规(纯函数)。
|
|
171
|
-
*
|
|
172
|
-
* @param mode 子代理的安全模式
|
|
173
|
-
* @param toolName 被调用的工具名
|
|
174
|
-
* @param params 调用参数
|
|
175
|
-
* @param allowedTools 显式工具白名单集合(若设置)
|
|
176
|
-
*/
|
|
177
|
-
/** Keep legacy allowlists action-scoped; never upgrade terminal_read to unrestricted terminal. */
|
|
178
142
|
export function subagentAllowedToolCall(allowed, name, params) {
|
|
179
143
|
if (conversationToolAllowed(allowed, name))
|
|
180
144
|
return true;
|
|
@@ -185,7 +149,6 @@ export function subagentAllowedToolCall(allowed, name, params) {
|
|
|
185
149
|
["create", "list", "close", "input", "key", "read", "wait"].includes(action) &&
|
|
186
150
|
allowed.has(`terminal_${action}`));
|
|
187
151
|
}
|
|
188
|
-
/** Visibility only; execution must still call subagentAllowedToolCall with actual params. */
|
|
189
152
|
export function subagentAllowedToolVisible(allowed, name) {
|
|
190
153
|
return (conversationToolAllowed(allowed, name) ||
|
|
191
154
|
(name === "terminal" &&
|
|
@@ -193,7 +156,6 @@ export function subagentAllowedToolVisible(allowed, name) {
|
|
|
193
156
|
}
|
|
194
157
|
export function subagentSecurityDenial(mode, toolName, params, allowedTools) {
|
|
195
158
|
const name = (toolName ?? "").trim();
|
|
196
|
-
// 1. 显式白名单门控(若配置了 allowedTools)
|
|
197
159
|
if (allowedTools && allowedTools.size > 0 && !subagentAllowedToolCall(allowedTools, name, params)) {
|
|
198
160
|
return {
|
|
199
161
|
kind: "not-allowed-tool",
|
|
@@ -201,11 +163,9 @@ export function subagentSecurityDenial(mode, toolName, params, allowedTools) {
|
|
|
201
163
|
reasonEn: `Restricted subagent: tool "${name}" is not in the allowed tool whitelist for this task (only: ${[...allowedTools].join(", ")}).`,
|
|
202
164
|
};
|
|
203
165
|
}
|
|
204
|
-
// normal 模式下不追加写拦截与 bash 只读限制
|
|
205
166
|
if (mode === "normal") {
|
|
206
167
|
return undefined;
|
|
207
168
|
}
|
|
208
|
-
// 2. 派发工具拦截(只读/审查子代理禁止派发或操纵同伴,防止安全穿透)
|
|
209
169
|
if (SUBAGENT_DISPATCH_TOOLS.has(name)) {
|
|
210
170
|
return {
|
|
211
171
|
kind: "dispatch-tool",
|
|
@@ -227,10 +187,8 @@ export function subagentSecurityDenial(mode, toolName, params, allowedTools) {
|
|
|
227
187
|
if (isConversationTool(name)) {
|
|
228
188
|
const action = typeof params === "object" && params !== null ? params.action : undefined;
|
|
229
189
|
const act = typeof action === "string" ? action.trim().toLowerCase() : "";
|
|
230
|
-
// Completion reports this execution result; it does not dispatch or mutate another task.
|
|
231
190
|
if (act === "complete")
|
|
232
191
|
return undefined;
|
|
233
|
-
// Allow transcript inspection and collaboration queries; block dispatch and mutations.
|
|
234
192
|
if (!isReadOnlyConversationAction(act)) {
|
|
235
193
|
return {
|
|
236
194
|
kind: "dispatch-tool",
|
|
@@ -239,7 +197,6 @@ export function subagentSecurityDenial(mode, toolName, params, allowedTools) {
|
|
|
239
197
|
};
|
|
240
198
|
}
|
|
241
199
|
}
|
|
242
|
-
// 3. 硬写类工具拦截
|
|
243
200
|
if (SUBAGENT_WRITE_TOOL_NAMES.has(name)) {
|
|
244
201
|
return {
|
|
245
202
|
kind: "write-tool",
|
|
@@ -247,7 +204,6 @@ export function subagentSecurityDenial(mode, toolName, params, allowedTools) {
|
|
|
247
204
|
reasonEn: `Restricted subagent (${mode}): write tool "${name}" is blocked in read/verify mode. Use read/grep/read-only commands to inspect.`,
|
|
248
205
|
};
|
|
249
206
|
}
|
|
250
|
-
// 4. 交互式终端输入拦截(防绕过)
|
|
251
207
|
if (SUBAGENT_TERMINAL_INPUT_TOOLS.has(name)) {
|
|
252
208
|
return {
|
|
253
209
|
kind: "terminal-input",
|
|
@@ -255,7 +211,6 @@ export function subagentSecurityDenial(mode, toolName, params, allowedTools) {
|
|
|
255
211
|
reasonEn: `Restricted subagent (${mode}): interactive terminal tool "${name}" is blocked. Use one-shot read-only bash commands instead.`,
|
|
256
212
|
};
|
|
257
213
|
}
|
|
258
|
-
// 5. Bash 命令动态审查拦截
|
|
259
214
|
if (BASH_TOOL_NAMES.has(name)) {
|
|
260
215
|
const cmd = commandOf(params);
|
|
261
216
|
if (!cmd.trim()) {
|
|
@@ -266,7 +221,6 @@ export function subagentSecurityDenial(mode, toolName, params, allowedTools) {
|
|
|
266
221
|
};
|
|
267
222
|
}
|
|
268
223
|
if (mode === "readonly") {
|
|
269
|
-
// 严格只读模式:必须过 bashCommandIsReadOnly
|
|
270
224
|
if (!bashCommandIsReadOnly(cmd)) {
|
|
271
225
|
return {
|
|
272
226
|
kind: "bash-write",
|
|
@@ -276,7 +230,6 @@ export function subagentSecurityDenial(mode, toolName, params, allowedTools) {
|
|
|
276
230
|
}
|
|
277
231
|
}
|
|
278
232
|
else if (mode === "verify") {
|
|
279
|
-
// 审查验证模式:允许只读命令 + 测试套件(goalReviewBashAllowed)
|
|
280
233
|
if (!bashCommandHasSupportedSyntax(cmd) || !goalReviewBashAllowed(cmd)) {
|
|
281
234
|
return {
|
|
282
235
|
kind: "bash-write",
|
|
@@ -296,9 +249,6 @@ export function subagentSecurityDenial(mode, toolName, params, allowedTools) {
|
|
|
296
249
|
}
|
|
297
250
|
return undefined;
|
|
298
251
|
}
|
|
299
|
-
/**
|
|
300
|
-
* 将工具包裹上子代理安全门禁(withSubagentSecurityGate)。
|
|
301
|
-
*/
|
|
302
252
|
export function withSubagentSecurityGate(def, getSecurityInfo, getLang) {
|
|
303
253
|
return {
|
|
304
254
|
...def,
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
export function createSubagentTask(mode = true) {
|
|
2
2
|
return { mode, completionRequested: false, generation: 0 };
|
|
3
3
|
}
|
|
4
|
-
/** Only a NEW task/reset advances generation. Child replies and automatic wakes retain intent. */
|
|
5
4
|
export function restartSubagentTask(task) {
|
|
6
5
|
return { mode: task.mode, completionRequested: false, generation: task.generation + 1 };
|
|
7
6
|
}
|
|
8
|
-
/** Record intent only. The host must recheck live dependencies and idle state before closing. */
|
|
9
7
|
export function requestSubagentCompletion(task, summary, generation = task.generation) {
|
|
10
8
|
if (generation !== task.generation)
|
|
11
9
|
return task;
|
|
12
10
|
return { ...task, completionRequested: true, summary: summary.trim() };
|
|
13
11
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Pure snapshot predicate, never a completion side effect. The host resolves dependencies
|
|
16
|
-
* across owners immediately before settlement. complete cannot close a streaming task or
|
|
17
|
-
* bypass children/questions/communications. Manual idle without dependencies falls back to
|
|
18
|
-
* the final assistant summary, even without complete. Error/cancel bypass dependency waits;
|
|
19
|
-
* the host must notify these failures even in manual mode. Notifications are generation-bound.
|
|
20
|
-
*/
|
|
21
12
|
export function isSubagentTaskPending(task, activity) {
|
|
22
13
|
if (activity.error || activity.canceled)
|
|
23
14
|
return false;
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* subagent-templates-hant.ts — 内置子代理模板的繁体中文(台湾用语)文案。
|
|
3
|
-
*
|
|
4
|
-
* 内置模板(DEFAULT_TEMPLATES)出厂只有简中 + 英文。繁中界面(zh-TW / zh-Hant / zh-HK)
|
|
5
|
-
* 若直接用简中字段,设置页与子代理提示词都会是简体。这里按模板名存一份繁中文案,由
|
|
6
|
-
* localizeTemplate 在「模板文字仍等于出厂简中」时作为视图套用;用户改过的字段不动。
|
|
7
|
-
*
|
|
8
|
-
* 文案由 scripts/zh-tw-locale 的 OpenCC(twp)+ 台湾用语词表转出后人工校订。
|
|
9
|
-
* 简中出厂文案改动时,这里必须同步(守卫:tests/unit/subagent-templates.test.ts)。
|
|
10
|
-
*/
|
|
11
1
|
export const BUILTIN_TEMPLATES_HANT = {
|
|
12
2
|
review: {
|
|
13
3
|
description: "程式碼 / 計畫 / 方案 / PR 審查:有證據的 P0-P2 發現與合併結論",
|