pi-web-ui 0.117.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 +48 -2
- 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 +147 -43
- 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 +56 -444
- 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 +160 -374
- package/dist/server/agent-service.js +875 -2978
- 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 +26 -30
- 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 +6 -213
- 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 +3 -76
- 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 +0 -82
- 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 +0 -8
- 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 +1 -3
- package/dist/server/device-center/collab-tool.js +0 -10
- package/dist/server/device-center/connector.js +21 -11
- package/dist/server/device-center/delivery-authority.js +0 -3
- package/dist/server/device-center/delivery-subject.js +0 -1
- 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 +1 -27
- 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 +0 -1
- 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 +0 -27
- 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 +0 -12
- package/dist/server/device-center/hub-deliveries.js +0 -1
- package/dist/server/device-center/hub-integration.js +0 -8
- 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 +25 -7
- package/dist/server/device-center/hub-setup.js +0 -6
- package/dist/server/device-center/hub-transaction-log.js +0 -22
- 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 +210 -86
- 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 +0 -2
- package/dist/server/device-center/local-hub.js +0 -2
- package/dist/server/device-center/local-publication.js +1 -8
- package/dist/server/device-center/local-verification-job.js +0 -2
- package/dist/server/device-center/local-verification.js +0 -1
- package/dist/server/device-center/local.js +267 -39
- package/dist/server/device-center/main.js +14 -1
- 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 +0 -31
- package/dist/server/device-center/path-portal.js +42 -12
- package/dist/server/device-center/publication-journal.js +0 -7
- package/dist/server/device-center/publish-intent.js +0 -5
- package/dist/server/device-center/relay.js +85 -30
- package/dist/server/device-center/report-upload.js +0 -1
- package/dist/server/device-center/runtime.js +1 -18
- package/dist/server/device-center/store.js +13 -33
- 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 +0 -13
- 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 +5 -88
- 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 +0 -18
- package/dist/server/device-center/task-state.js +0 -12
- package/dist/server/device-center/task-workspace.js +0 -50
- 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 +0 -1
- package/dist/server/device-center/work-contract.js +1 -73
- 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 +190 -32
- package/dist/server/dispatch-plugin-handlers.js +2 -19
- package/dist/server/dsh/dsh-agent-service.js +69 -599
- 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 +177 -680
- 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 +3 -43
- package/dist/server/patch-remote-catalog.js +1 -32
- 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 +9 -62
- package/dist/server/preset-plugin-dependencies.js +0 -2
- package/dist/server/preset-share.js +3 -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 +34 -1
- package/dist/server/quick-ask.js +123 -27
- 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 +0 -26
- 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 +3 -54
- 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 +17 -25
- package/dist/server/session-open.js +2 -26
- package/dist/server/session-parser.js +1 -55
- package/dist/server/session-scan.js +1 -17
- package/dist/server/session-search.js +0 -56
- package/dist/server/settings-service.js +11 -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 +0 -42
- 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 +1 -19
- 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 +12 -172
- 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 +26 -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 +1 -56
- 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 +37 -1
- package/docs/device-center.md +28 -2
- 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 +7 -3
- package/plugin-sdk/README.md +6 -0
- package/plugin-sdk/client-utils.mjs +0 -7
- package/plugin-sdk/client.d.ts +0 -1
- package/plugin-sdk/client.mjs +1 -31
- package/plugin-sdk/import-check.mjs +4 -51
- package/plugin-sdk/index.d.ts +120 -119
- package/plugin-sdk/index.mjs +0 -6
- package/plugin-sdk/ssh-host-trust.mjs +0 -12
- package/plugin-sdk/testing.d.ts +0 -1
- package/plugin-sdk/testing.mjs +31 -86
- 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 +1 -9
- package/themes/flow-ink.css +1 -10
- package/themes/flow-light.css +1 -10
- package/themes/flow-obsidian.css +1 -10
- package/themes/flow-zurich.css +1 -10
- 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-BjNRIUIc.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-CQtstPGv.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-ChTW8o1m.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-BX5rUuoI.js → PiSetupModal-DZKY5Wiw.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
- package/web/dist/assets/{SCMPanel-DPAyY2sW.js → SCMPanel-CuEgzAlO.js} +2 -2
- 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-Dzi-eEyE.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
- package/web/dist/assets/theme-DGL7hLUs.js +1 -0
- package/web/dist/index.html +11 -10
- package/web/dist/sw.js +15 -61
- package/web/public/sw.js +14 -60
- package/web/dist/assets/BgTasksModal-C0zuU8FE.js +0 -1
- package/web/dist/assets/CanvasStudio-BWvdmJ0M.js +0 -1579
- package/web/dist/assets/CanvasStudio-VQFjmTGq.js +0 -1579
- package/web/dist/assets/DeviceCenter-DI9_0aBB.js +0 -3
- package/web/dist/assets/DeviceCenter-DsNtXqzY.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-BLP1Su5G.js +0 -1
- package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +0 -1
- package/web/dist/assets/DeviceGroups-CP7CcyPD.js +0 -1
- package/web/dist/assets/FilePreview-BMB2tNyT.js +0 -2
- package/web/dist/assets/FilePreview-RGFQUbJo.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BM5wxiqU.js +0 -1
- package/web/dist/assets/GlobalSearchModal-DGv_WINq.js +0 -1
- package/web/dist/assets/GroupConversation-B7SnuXj1.js +0 -61
- package/web/dist/assets/GroupConversation-Dda69q-2.js +0 -61
- package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +0 -2
- package/web/dist/assets/ModelConfigModal-yqeadyab.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-DY4SCfXg.js +0 -1
- package/web/dist/assets/SCMPanel-C4KbQvvK.js +0 -2
- package/web/dist/assets/SettingsModal-DxZp6D_g.js +0 -32
- package/web/dist/assets/SettingsModal-WhQzaOPt.js +0 -32
- package/web/dist/assets/TerminalPanel-D4By_RVc.js +0 -3
- package/web/dist/assets/TerminalPanel-lZw8-i3j.js +0 -3
- package/web/dist/assets/TuiOverlayModal-C3pAVuC8.js +0 -1
- package/web/dist/assets/TuiOverlayModal-D7_rEXcJ.js +0 -1
- package/web/dist/assets/app-globals-KqOVtmp1.js +0 -123
- package/web/dist/assets/canvas-client-BY6ojmle.js +0 -1
- package/web/dist/assets/desktop-CV6KKp9R.js +0 -1
- package/web/dist/assets/index-BawF7ZP5.js +0 -397
- package/web/dist/assets/index-BoGCoq5X.js +0 -397
- package/web/dist/assets/index-CVW9FoY2.css +0 -1
- package/web/dist/assets/plugin-host-Dn8Dd6SC.js +0 -1
- package/web/dist/assets/theme-D_bihpdN.js +0 -1
|
@@ -1,75 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* subagent-templates.ts — 子代理模板库(全局共享,<dataDir>/subagent-templates.json)。
|
|
3
|
-
*
|
|
4
|
-
* 模板 = 派生子代理时套用的预设:角色系统提示词(replace/append 同主设置语义)+
|
|
5
|
-
* 技能白名单 + 扩展白名单 + 可选模型 + 可选思考强度。白名单空数组 = 该维度不限定,
|
|
6
|
-
* 子代理跟随主会话设置。
|
|
7
|
-
* `model` 为 "provider/id"(与 subagent_spawn 的 model 参数、设置面板子代理默认模型
|
|
8
|
-
* 同格式);空字符串 = 跟随主对话当前模型。
|
|
9
|
-
* `thinkingLevel` 为 SDK 的思考强度(off…max,见 THINKING_LEVELS);空字符串 = 跟随
|
|
10
|
-
* 主对话当前思考强度(与 model 的「跟随主对话」同语义)。
|
|
11
|
-
* 带 `enabled: false` 的模板停用:设置面板仍可见、可重新启用,但 AI 工具
|
|
12
|
-
* (subagent_templates / subagent_spawn)查询不到它、也不能选择它——「关闭 =
|
|
13
|
-
* 对 AI 不可见」。
|
|
14
|
-
*
|
|
15
|
-
* 与 per-client 的 client-state.json 不同:模板是配置品而非个人偏好,所有浏览器
|
|
16
|
-
* 客户端共用同一份。文件 I/O 一律 best-effort:持久化故障绝不能弄崩 server。
|
|
17
|
-
*
|
|
18
|
-
* 双语约定(issue #91):description/systemPrompt 为中文(zh 用),descriptionEn/
|
|
19
|
-
* systemPromptEn 为英文(en 用,缺失回落中文);调用方用 pickTemplateDescription/
|
|
20
|
-
* pickTemplatePrompt 按语言选用。
|
|
21
|
-
*
|
|
22
|
-
* 繁中视图:内置模板出厂只有简中 + 英文,resolveServerLang 又把 zh-TW / zh-HK / zh-Hant
|
|
23
|
-
* 都折成 "zh",繁中用户会拿到简体。localizeTemplate 按**原始 locale** 在内置模板文字仍等于
|
|
24
|
-
* 出厂简中时换上 subagent-templates-hant.ts 的繁中文案(一份台湾用语,三个繁中界面共用);
|
|
25
|
-
* 它只是展示/取用视图,不回写库——canonicalizeTemplate 在 upsert 时把「恰为出厂繁中」的
|
|
26
|
-
* 文字还原成出厂简中,库里始终是出厂简中或用户自己的文字。
|
|
27
|
-
*/
|
|
28
1
|
import { readFileSync } from "node:fs";
|
|
29
2
|
import { writeJsonAtomicSync } from "./atomic-file.js";
|
|
30
3
|
import { isTraditionalLocale } from "./i18n.js";
|
|
31
4
|
import { BUILTIN_TEMPLATES_HANT } from "./subagent-templates-hant.js";
|
|
32
|
-
/**
|
|
33
|
-
* 思考强度取值:与 SDK 的 THINKING_LEVEL_OPTIONS(前端 ModelThinking 的 THINKING_VALUES)
|
|
34
|
-
* 一致。SDK 未从包根导出该常量,这里照抄一份作输入校验(写错的值一律当未配置)。
|
|
35
|
-
* 注意模型能力收敛(reasoning / thinkingLevelMap)由 SDK 的 setThinkingLevel 负责:
|
|
36
|
-
* 非推理模型只会得到 "off",这里不做也不该做模型相关的判断。
|
|
37
|
-
*/
|
|
38
5
|
export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
39
|
-
/** 按语言选模板简介:zh 用 description;en 优先 descriptionEn、缺失回落 description。 */
|
|
40
6
|
export function pickTemplateDescription(t, lang) {
|
|
41
7
|
if (lang === "zh")
|
|
42
8
|
return t.description;
|
|
43
9
|
return t.descriptionEn || t.description;
|
|
44
10
|
}
|
|
45
|
-
/** 按语言选模板提示词:zh 用 systemPrompt;en 优先 systemPromptEn、缺失回落 systemPrompt。 */
|
|
46
11
|
export function pickTemplatePrompt(t, lang) {
|
|
47
12
|
if (lang === "zh")
|
|
48
13
|
return t.systemPrompt;
|
|
49
14
|
return t.systemPromptEn || t.systemPrompt;
|
|
50
15
|
}
|
|
51
|
-
/** 名字去空白折叠后非空且 ≤ 60 字符(工具参数可读,允许中文)。 */
|
|
52
16
|
const NAME_MAX = 60;
|
|
53
|
-
/**
|
|
54
|
-
* 模板体积上限(保存期拒绝,不静默截断):模板会整体进入设置面板快照并被
|
|
55
|
-
* subagent_templates 工具列给 AI,systemPrompt 还会拼进子代理上下文,无上限
|
|
56
|
-
* 的单条模板能把快照推送与子代理首响都拖爆。对齐常见上下文预算的保守值。
|
|
57
|
-
*/
|
|
58
17
|
export const TEMPLATE_LIMITS = {
|
|
59
|
-
/** 模板系统提示词上限(systemPrompt / systemPromptEn 各自计)。 */
|
|
60
18
|
systemPrompt: 32_768,
|
|
61
|
-
/** 模板简介上限(description / descriptionEn 各自计)。 */
|
|
62
19
|
description: 2_000,
|
|
63
|
-
/** 技能/扩展白名单各自最多条目数。 */
|
|
64
20
|
whitelistEntries: 64,
|
|
65
|
-
/** 白名单单条字符上限。 */
|
|
66
21
|
whitelistEntryLength: 200,
|
|
67
22
|
};
|
|
68
|
-
/**
|
|
69
|
-
* 保存期体积校验:超限返回明确错误文本(让设置面板能原样提示),null = 通过。
|
|
70
|
-
* 只拦新保存,不拦读盘老数据(向后兼容,与 replace 空提示词的拦截口径一致);
|
|
71
|
-
* 拒绝而非截断——静默截断会让用户以为保存的是完整内容。
|
|
72
|
-
*/
|
|
73
23
|
export function validateTemplateLimits(t) {
|
|
74
24
|
if (t.systemPrompt.length > TEMPLATE_LIMITS.systemPrompt) {
|
|
75
25
|
return `模板 "${t.name}" 的系统提示词超长(${t.systemPrompt.length} > ${TEMPLATE_LIMITS.systemPrompt} 字符),请精简后再保存`;
|
|
@@ -97,15 +47,7 @@ export function validateTemplateLimits(t) {
|
|
|
97
47
|
}
|
|
98
48
|
return null;
|
|
99
49
|
}
|
|
100
|
-
/**
|
|
101
|
-
* 内置默认模板(第一次运行时种子进列表;用户改动后以 <dataDir> 文件为准)。
|
|
102
|
-
* 文案改编自 pi-subagents 社区项目(tintinweb / nicobailon)的角色提示词,
|
|
103
|
-
* 剔除了本项目没有的专有工具引用(contact_supervisor / web_search / workflow…)。
|
|
104
|
-
* 白名单留空 = 技能/扩展跟随主会话设置,开箱即用。
|
|
105
|
-
*/
|
|
106
50
|
export const DEFAULT_TEMPLATES = [
|
|
107
|
-
// 全部内置模板默认 model / thinkingLevel 为空字符串 = 跟随主对话当前模型与思考强度
|
|
108
|
-
// (面板改模板时可指定专属模型与强度)。
|
|
109
51
|
{
|
|
110
52
|
name: "review",
|
|
111
53
|
description: "代码 / 计划 / 方案 / PR 审查:有证据的 P0-P2 发现与合并结论",
|
|
@@ -339,10 +281,6 @@ export const DEFAULT_TEMPLATES = [
|
|
|
339
281
|
thinkingLevel: "",
|
|
340
282
|
enabled: true,
|
|
341
283
|
},
|
|
342
|
-
// ---- oh-my-pi specialist 系列(移植自 oh-my-pi 内置 agents + persona 包装模板,
|
|
343
|
-
// 见 tests/scratch/ohmy-essence.md §2-§3):oh-my-pi 的 subagent 只是 persona 自演,
|
|
344
|
-
// 这里是真子代理(独立会话、可继续追问),提示词按 persona 模板改写(角色 + 只读约束 +
|
|
345
|
-
// 输出格式 + 回报纪律)。全部 model:"" = 跟随主对话模型,白名单留空 = 跟随主会话开关。
|
|
346
284
|
{
|
|
347
285
|
name: "oracle",
|
|
348
286
|
description: "只读高智顾问:架构设计、难调的 bug、多系统权衡,复杂决策前先咨询",
|
|
@@ -544,13 +482,7 @@ export const DEFAULT_TEMPLATES = [
|
|
|
544
482
|
enabled: true,
|
|
545
483
|
},
|
|
546
484
|
];
|
|
547
|
-
/** 出厂简中文案索引(按模板名):判断「文字是否仍是出厂原样」的唯一基准。 */
|
|
548
485
|
const SHIPPED_BY_NAME = new Map(DEFAULT_TEMPLATES.map((t) => [t.name, t]));
|
|
549
|
-
/**
|
|
550
|
-
* 繁中界面(zh-TW / zh-HK / zh-Hant)看到的模板视图:内置模板的 description / systemPrompt
|
|
551
|
-
* 若仍等于出厂简中,换成繁中文案;两个字段逐一判断、互不牵连。用户改过的字段、自建模板、
|
|
552
|
-
* 非繁中界面一律原样返回(同一个对象)。返回值只作展示/取用,不要回写进库。
|
|
553
|
-
*/
|
|
554
486
|
export function localizeTemplate(t, locale) {
|
|
555
487
|
if (!isTraditionalLocale(locale))
|
|
556
488
|
return t;
|
|
@@ -564,12 +496,6 @@ export function localizeTemplate(t, locale) {
|
|
|
564
496
|
return t;
|
|
565
497
|
return { ...t, description, systemPrompt };
|
|
566
498
|
}
|
|
567
|
-
/**
|
|
568
|
-
* localizeTemplate 的逆运算:内置模板里恰好等于出厂繁中的 description / systemPrompt 还原成
|
|
569
|
-
* 出厂简中。设置页在繁中界面显示的是繁中视图,单击启用开关或只改模型都会把整个模板连同
|
|
570
|
-
* 繁中文字回传;不还原的话,库(所有客户端共享)就会被悄悄改写成繁体,其它语言的用户再
|
|
571
|
-
* 也看不到出厂简中。用户真正改过的文字与自建模板原样保留。
|
|
572
|
-
*/
|
|
573
499
|
export function canonicalizeTemplate(t) {
|
|
574
500
|
const shipped = SHIPPED_BY_NAME.get(t.name);
|
|
575
501
|
const hant = shipped && BUILTIN_TEMPLATES_HANT[t.name];
|
|
@@ -581,7 +507,6 @@ export function canonicalizeTemplate(t) {
|
|
|
581
507
|
return t;
|
|
582
508
|
return { ...t, description, systemPrompt };
|
|
583
509
|
}
|
|
584
|
-
/** 容忍脏数据/旧版本:非法条目整体丢弃。 */
|
|
585
510
|
function normalize(raw) {
|
|
586
511
|
if (!raw || typeof raw !== "object")
|
|
587
512
|
return null;
|
|
@@ -602,16 +527,13 @@ function normalize(raw) {
|
|
|
602
527
|
enabledExtensions: Array.isArray(o.enabledExtensions)
|
|
603
528
|
? o.enabledExtensions.filter((x) => typeof x === "string")
|
|
604
529
|
: [],
|
|
605
|
-
// 空字符串 = 跟随主对话;其余剥掉首尾空白,超长当脏数据丢弃。
|
|
606
530
|
model: typeof o.model === "string" ? o.model.trim() : "",
|
|
607
|
-
// 只认 THINKING_LEVELS 里的档位;老文件没有该字段 / 值写错 → 空 = 跟随主对话。
|
|
608
531
|
thinkingLevel: typeof o.thinkingLevel === "string" && THINKING_LEVELS.includes(o.thinkingLevel.trim())
|
|
609
532
|
? o.thinkingLevel.trim()
|
|
610
533
|
: "",
|
|
611
534
|
enabled: o.enabled !== false,
|
|
612
535
|
};
|
|
613
536
|
}
|
|
614
|
-
/** 全局子代理模板库(原子写;失败静默)。 */
|
|
615
537
|
export class SubagentTemplatesStore {
|
|
616
538
|
filePath;
|
|
617
539
|
templates = null;
|
|
@@ -628,18 +550,12 @@ export class SubagentTemplatesStore {
|
|
|
628
550
|
: [];
|
|
629
551
|
}
|
|
630
552
|
catch {
|
|
631
|
-
// 文件不存在/损坏:以内置默认模板为种子(不落盘——用户一旦增删改,
|
|
632
|
-
// persist() 会把当前完整列表写盘,此后以文件为准,默认模板可删可改)。
|
|
633
553
|
this.templates = DEFAULT_TEMPLATES.map((t) => ({
|
|
634
554
|
...t,
|
|
635
555
|
enabledSkills: [...t.enabledSkills],
|
|
636
556
|
enabledExtensions: [...t.enabledExtensions],
|
|
637
557
|
}));
|
|
638
558
|
}
|
|
639
|
-
// 老用户已有文件时:把「从未播种过」的内置模板合并进来(发版新增的内置
|
|
640
|
-
// 模板才能送达)。seeded 名单记在同目录 sidecar 文件里:用户删掉的内置模板
|
|
641
|
-
// 已在名单里,不会复活;sidecar 缺失的老用户做一次性全量补齐。
|
|
642
|
-
// name 即去重键,用户改过的同名条目原样保留。
|
|
643
559
|
const names = new Set(this.templates.map((t) => t.name));
|
|
644
560
|
const seeded = this.loadSeeded();
|
|
645
561
|
let grown = false;
|
|
@@ -663,11 +579,8 @@ export class SubagentTemplatesStore {
|
|
|
663
579
|
try {
|
|
664
580
|
writeJsonAtomicSync(this.filePath, this.templates);
|
|
665
581
|
}
|
|
666
|
-
catch {
|
|
667
|
-
// best effort
|
|
668
|
-
}
|
|
582
|
+
catch { }
|
|
669
583
|
}
|
|
670
|
-
/** 已播种过的内置模板名(sidecar 文件,best-effort;缺失=老用户,做一次性补齐)。 */
|
|
671
584
|
seededNames = null;
|
|
672
585
|
seededPath() {
|
|
673
586
|
return /\.json$/i.test(this.filePath)
|
|
@@ -685,9 +598,7 @@ export class SubagentTemplatesStore {
|
|
|
685
598
|
if (typeof n === "string" && n)
|
|
686
599
|
out.add(n);
|
|
687
600
|
}
|
|
688
|
-
catch {
|
|
689
|
-
// 无 sidecar:老用户,返回空集触发一次性补齐(下次 load 即建档)。
|
|
690
|
-
}
|
|
601
|
+
catch { }
|
|
691
602
|
this.seededNames = out;
|
|
692
603
|
return out;
|
|
693
604
|
}
|
|
@@ -696,11 +607,8 @@ export class SubagentTemplatesStore {
|
|
|
696
607
|
try {
|
|
697
608
|
writeJsonAtomicSync(this.seededPath(), [...names].sort());
|
|
698
609
|
}
|
|
699
|
-
catch {
|
|
700
|
-
// best effort
|
|
701
|
-
}
|
|
610
|
+
catch { }
|
|
702
611
|
}
|
|
703
|
-
/** 全部模板(含停用的)。设置面板展示用。 */
|
|
704
612
|
list() {
|
|
705
613
|
return this.load().map((t) => ({
|
|
706
614
|
...t,
|
|
@@ -708,24 +616,17 @@ export class SubagentTemplatesStore {
|
|
|
708
616
|
enabledExtensions: [...t.enabledExtensions],
|
|
709
617
|
}));
|
|
710
618
|
}
|
|
711
|
-
/** 按名取模板(含停用的;spawn 时由宿主做启用校验)。 */
|
|
712
619
|
get(name) {
|
|
713
620
|
return this.load().find((t) => t.name === name);
|
|
714
621
|
}
|
|
715
|
-
/** Upsert 一个模板(同名覆盖)。返回错误文本;成功返回 null。 */
|
|
716
622
|
upsert(input) {
|
|
717
623
|
const normalized = normalize(input);
|
|
718
624
|
if (!normalized)
|
|
719
625
|
return `模板名称不合法(去空白后 1-${NAME_MAX} 字符)`;
|
|
720
|
-
// 设置页在繁中界面回传的是繁中视图:恰为出厂繁中的文字还原成出厂简中再入库。
|
|
721
626
|
const t = canonicalizeTemplate(normalized);
|
|
722
|
-
// replace + 空提示词 = 子代理静默用默认 persona 运行(模板等于没生效),
|
|
723
|
-
// 在保存期直接拦下:只想限定白名单请用 append 模式。读盘的老数据不拦
|
|
724
|
-
// (向后兼容,只拦新保存)。
|
|
725
627
|
if (t.promptMode === "replace" && !t.systemPrompt.trim() && !(t.systemPromptEn ?? "").trim()) {
|
|
726
628
|
return `模板 "${t.name}" 用了 replace 模式但系统提示词为空:replace 会整体替换子代理 persona,空提示词等于模板没生效。请填写提示词(中文或英文至少一个),只想限定技能/扩展白名单请用 append 模式`;
|
|
727
629
|
}
|
|
728
|
-
// 体积上限同样只在保存期拦:超限明确报错,绝不静默截断。
|
|
729
630
|
const limitError = validateTemplateLimits(t);
|
|
730
631
|
if (limitError)
|
|
731
632
|
return limitError;
|
|
@@ -738,7 +639,6 @@ export class SubagentTemplatesStore {
|
|
|
738
639
|
this.persist();
|
|
739
640
|
return null;
|
|
740
641
|
}
|
|
741
|
-
/** 删除一个模板(不存在时静默)。 */
|
|
742
642
|
remove(name) {
|
|
743
643
|
const list = this.load();
|
|
744
644
|
const next = list.filter((t) => t.name !== name);
|
package/dist/server/subagents.js
CHANGED
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// subagents.ts — 第一方轻量子代理:工具定义与运行态模型
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// 架构(相对参考项目的大幅简化):
|
|
5
|
-
//
|
|
6
|
-
// 参考项目(tintinweb / nicobailon 的 pi-subagents)把子代理做成「完整子会话」
|
|
7
|
-
// —— 独立 SessionManager / SettingsManager / 模型 / 工具隔离 / resume /
|
|
8
|
-
// steer / 并发池 / 工作区隔离,复杂度来自「要独立支撑一个完整会话」。
|
|
9
|
-
//
|
|
10
|
-
// pi-web-ui 的 ClientSession 天生就是多会话并发的:一个 conversation 就有
|
|
11
|
-
// 一个独立 AgentSessionRuntime + TerminalManager,所有 conversation 共享
|
|
12
|
-
// 同一个 modelRuntime,创建走 createAgentSessionServices + FromServices(已
|
|
13
|
-
// 封装好)。因此本模块把子代理定义为:
|
|
14
|
-
//
|
|
15
|
-
// 子代理 = 一个标记了 isSubagent 的普通 Conversation(inMemory session,
|
|
16
|
-
// 不落盘、不进历史/resume 列表)
|
|
17
|
-
// - 出现在左栏「运行的对话」列表,带「子代理」徽标
|
|
18
|
-
// - 用户可以像普通对话一样:点开查看实时消息流、输入补充(= steer)、
|
|
19
|
-
// 中止(= abort)、完成后移出(= dismiss)
|
|
20
|
-
// - 运行态经现有快照/消息管线推送,不需要单独的可视化桥
|
|
21
|
-
//
|
|
22
|
-
// 本文件只定义:运行态快照类型、host 接口(由 ClientSession 实现,操作的是
|
|
23
|
-
// 它的 conversation 体系)、以及注册给每个会话的 subagent_* 工具。真正创建
|
|
24
|
-
// conversation / 跑 prompt 全部在 agent-service.ts 的 spawnSubagent 里完成。
|
|
25
|
-
//
|
|
26
|
-
// 返回文本按 lang 取 pick(lang, zh, en)。
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
1
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
29
2
|
import { Type } from "typebox";
|
|
30
3
|
import { pick } from "./i18n.js";
|
|
@@ -32,12 +5,6 @@ import { resolveSecurityMode } from "./subagent-security-gate.js";
|
|
|
32
5
|
import { THINKING_LEVELS } from "./subagent-templates.js";
|
|
33
6
|
import { CONVERSATION_TOOL_NAME, SUBAGENT_TOOL_NAME } from "./tool-manager.js";
|
|
34
7
|
export { CONVERSATION_TOOL_NAME, SUBAGENT_TOOL_NAME } from "./tool-manager.js";
|
|
35
|
-
/**
|
|
36
|
-
* subagent_wait_all 的最长阻塞时间:必须短暂低于工具看门狗(默认 20 分钟,
|
|
37
|
-
* PI_WEB_TOOL_TIMEOUT_MS 可调),否则看门狗会先中止整个会话而不是让 wait
|
|
38
|
-
* 干净地超时返回。取 0.8×看门狗(默认 ~16min,支持 PI_WEB_SUBAGENT_WAIT_CAP_SECONDS 覆盖),
|
|
39
|
-
* 兜底不低于 5s。
|
|
40
|
-
*/
|
|
41
8
|
export function computeWaitCapMs(watchdogMs) {
|
|
42
9
|
const customSecs = Number(process.env.PI_WEB_SUBAGENT_WAIT_CAP_SECONDS);
|
|
43
10
|
if (Number.isFinite(customSecs) && customSecs > 0) {
|
|
@@ -51,25 +18,13 @@ export function computeWaitCapMs(watchdogMs) {
|
|
|
51
18
|
: 20 * 60_000;
|
|
52
19
|
return Math.max(Math.floor(watchdog * 0.8), 5_000);
|
|
53
20
|
}
|
|
54
|
-
/** Idle is terminal only when the host has no pending task dependencies.
|
|
55
|
-
* Idle failures/cancellations remain terminal regardless of pending dependencies. */
|
|
56
21
|
export function isSubagentTerminal(r) {
|
|
57
22
|
return !!r && !r.streaming && (!r.taskPending || !!r.error || !!r.canceled);
|
|
58
23
|
}
|
|
59
|
-
/** 从 prompt 取首行作为标题(截断 40 字符)。 */
|
|
60
24
|
export function subagentTitle(prompt) {
|
|
61
25
|
const line = prompt.split("\n")[0]?.trim() ?? "";
|
|
62
26
|
return line.length > 40 ? `${line.slice(0, 40)}…` : line;
|
|
63
27
|
}
|
|
64
|
-
/**
|
|
65
|
-
* 返回注入 ownerId 的 host 包装:每次 spawn 时自动把 ownerId(真正的派发会话)
|
|
66
|
-
* 作为子代理的 parentId 传给底层 host。
|
|
67
|
-
*
|
|
68
|
-
* 背景(issue #95):子代理左栏嵌套靠 parentId,而派发方是某个会话的 runtime ——
|
|
69
|
-
* 必须按 runtime 归属记父对话,而不是派发瞬间的 active。后台对话继续产出时用户
|
|
70
|
-
* 可能已切到别的项目,直接读 activeId 会把孩子记到无关会话名下(错组/沉底)。
|
|
71
|
-
* 每个会话创建 runtime 时用本函数包一层,让它的 spawn 天然带自己的会话 id。
|
|
72
|
-
*/
|
|
73
28
|
export function withSubagentOwner(host, ownerId, resolveOwner = () => ownerId) {
|
|
74
29
|
return {
|
|
75
30
|
...host,
|
|
@@ -115,20 +70,7 @@ export const SUBAGENT_ACTIONS = [
|
|
|
115
70
|
"answer",
|
|
116
71
|
"escalate",
|
|
117
72
|
];
|
|
118
|
-
/**
|
|
119
|
-
* 单 action 子代理总工具(注册进每个会话的 customTools,供主 agent 驱动子代理)。
|
|
120
|
-
* 合并原 subagent_* 8 个工具为一个统一入口,节省会话上下文 token。
|
|
121
|
-
*
|
|
122
|
-
* `selfConvId`(可选):这套工具所注册进的会话 convId。`wait_all`
|
|
123
|
-
* 永远排除调用者自身——子代理会话上同样注册了该工具,不传 runIds 时
|
|
124
|
-
* 「全部」会含它自己,而它正在执行本工具(streaming=true),不排除就是
|
|
125
|
-
* 自己等自己、永远到超时(self-wait deadlock)。主会话调用时传它自己的
|
|
126
|
-
* 普通对话 id 即可(不在子代理列表里,delete 是 no-op)。
|
|
127
|
-
*/
|
|
128
73
|
export function makeSubagentTool(host, lang, selfConvId) {
|
|
129
|
-
// B20:过户会把对话改名(撞 id 时 remap),自省 id 必须在调用时刻解析
|
|
130
|
-
// (按 runtime 身份查当前持有方),不能死用建时的旧 id —— 否则 wait_all
|
|
131
|
-
// 排除自省/展开后代时拿错锚点。传函数形式由建时点按 findConversationHome 解析。
|
|
132
74
|
const selfIdOf = () => (typeof selfConvId === "function" ? selfConvId() : selfConvId);
|
|
133
75
|
const executionOf = (snapshot) => snapshot.executionId ?? snapshot.convId;
|
|
134
76
|
const executionOfId = (id) => host.getSubagent(id)?.executionId ?? id;
|
|
@@ -138,15 +80,12 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
138
80
|
content: [{ type: "text", text: t }],
|
|
139
81
|
details,
|
|
140
82
|
});
|
|
141
|
-
// Share delivery memory across the primary tool and legacy alias. Keep only live requests.
|
|
142
83
|
const deliveredConsults = new Set();
|
|
143
84
|
const consultKey = (parentId, runId, requestId) => JSON.stringify([parentId, runId, requestId]);
|
|
144
85
|
const expandDescendants = (roots) => {
|
|
145
86
|
if (roots instanceof Set ? roots.size === 0 : roots.length === 0)
|
|
146
87
|
return [];
|
|
147
88
|
const rootSet = new Set([...roots].map(executionOfId));
|
|
148
|
-
// B20:带 forSelfId(本会话的族)展开 —— 过户把整族搬到别的会话后,
|
|
149
|
-
// 只列本会话自己的列表会展不开后代,wait_all 会误报「没有需要等待的子代理」。
|
|
150
89
|
const all = host.listSubagents(undefined, selfIdOf());
|
|
151
90
|
const out = [];
|
|
152
91
|
for (const s of all) {
|
|
@@ -481,6 +420,7 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
481
420
|
kindLabel: kindLabelEn,
|
|
482
421
|
kindLabelEn,
|
|
483
422
|
kindLabelZh,
|
|
423
|
+
addressLine,
|
|
484
424
|
}), {
|
|
485
425
|
convId,
|
|
486
426
|
executionId,
|
|
@@ -510,7 +450,6 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
510
450
|
const runningOutput = r.output || (getLang() === "zh" ? "(暂无输出)" : "(no output yet)");
|
|
511
451
|
return text(pick(getLang(), `子代理 ${runningId}(${r.type}${modelTag})仍在运行(状态 ${r.state})。\n当前输出:\n${runningOutput}`, `Subagent ${runningId} (${r.type}${modelTag}) is still running (state ${r.state}).\nCurrent output:\n${runningOutput}`, "subagents.get.running", { runningId, "r.type": r.type, modelTag, "r.state": r.state, runningOutput }), r);
|
|
512
452
|
}
|
|
513
|
-
// 终态结果被父对话取走,标记已消费,避免后续重复触发自动通知
|
|
514
453
|
const targetAddress = executionOf(r);
|
|
515
454
|
host.markSubagentsConsumed?.([targetAddress]);
|
|
516
455
|
if (host.finalizeSubagentWorktree) {
|
|
@@ -635,7 +574,6 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
635
574
|
const parentId = selfIdOf();
|
|
636
575
|
if (!parentId || !host.getPendingConsults || signal?.aborted)
|
|
637
576
|
return;
|
|
638
|
-
// The host authorizes direct-child requests for this parent, independent of runIds.
|
|
639
577
|
const pending = host.getPendingConsults(parentId);
|
|
640
578
|
const liveKeys = new Set(pending.map((r) => consultKey(parentId, r.runId, r.requestId)));
|
|
641
579
|
for (const key of deliveredConsults) {
|
|
@@ -681,9 +619,6 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
681
619
|
return consults;
|
|
682
620
|
const allDone = Array.from(wanted).every((id) => {
|
|
683
621
|
const r = host.getSubagent(id);
|
|
684
|
-
// #488:getSubagent 返回 undefined = 已被移出(强行关闭/收尾清理)
|
|
685
|
-
// ——视为终态,与下方报告段「已移出或不存在」口径一致;否则等待
|
|
686
|
-
// 集合含被移出子代理时 allDone 恒 false,必然白等满 timeoutMs。
|
|
687
622
|
return r === undefined || isSubagentTerminal(r);
|
|
688
623
|
});
|
|
689
624
|
if (allDone)
|
|
@@ -699,7 +634,6 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
699
634
|
const tLang = getLang();
|
|
700
635
|
const waitedSecs = Math.max(1, Math.round((Date.now() - startedAt) / 1000));
|
|
701
636
|
const timeoutSecs = Math.round(timeoutMs / 1000);
|
|
702
|
-
// 收口的子代理标记已消费,避免后续重复自动通知打扰父对话;同时结算隔离工作树
|
|
703
637
|
const finishedIds = Array.from(wanted).filter((id) => {
|
|
704
638
|
const r = host.getSubagent(id);
|
|
705
639
|
return r === undefined || isSubagentTerminal(r);
|
|
@@ -840,7 +774,6 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
840
774
|
const descIds = new Set(expandDescendants(new Set([selfId])));
|
|
841
775
|
inScopeList = all.filter((s) => descIds.has(executionOf(s)));
|
|
842
776
|
}
|
|
843
|
-
// 口径与 finishedSubagentCount 一致:isSubagent、非 streaming、非当前 active
|
|
844
777
|
candidateIds = inScopeList
|
|
845
778
|
.filter((s) => {
|
|
846
779
|
if (s.streaming || s.state === "running")
|
|
@@ -988,9 +921,6 @@ export function makeSubagentTool(host, lang, selfConvId) {
|
|
|
988
921
|
},
|
|
989
922
|
});
|
|
990
923
|
}
|
|
991
|
-
/**
|
|
992
|
-
* 保持数组签名的子代理工具导出,兼容原有调用点与批处理包装。
|
|
993
|
-
*/
|
|
994
924
|
export function makeSubagentTools(host, lang, selfConvId) {
|
|
995
925
|
const primary = makeSubagentTool(host, lang, selfConvId);
|
|
996
926
|
return [
|
|
@@ -1004,15 +934,9 @@ export function makeSubagentTools(host, lang, selfConvId) {
|
|
|
1004
934
|
},
|
|
1005
935
|
];
|
|
1006
936
|
}
|
|
1007
|
-
/** 短 id 前缀(前端展示/日志用)。 */
|
|
1008
937
|
function shortId(id) {
|
|
1009
938
|
return id.slice(0, 8);
|
|
1010
939
|
}
|
|
1011
|
-
/**
|
|
1012
|
-
* wait_all 收口时的长输出截断:留头(任务复述)+ 留尾(最终结论),中间折叠。
|
|
1013
|
-
* 旧实现只取前 30 行,长输出的子代理结论(一般在尾部)会被丢掉,模型收回一个
|
|
1014
|
-
* 没结论的摘要。短输出原样返回。
|
|
1015
|
-
*/
|
|
1016
940
|
function clipSubagentOutput(output, lang) {
|
|
1017
941
|
const HEAD = 10;
|
|
1018
942
|
const TAIL = 30;
|
|
@@ -1023,13 +947,6 @@ function clipSubagentOutput(output, lang) {
|
|
|
1023
947
|
const marker = lang === "zh" ? `… [中间省略 ${omitted} 行,头尾保留] …` : `… [${omitted} lines omitted, head and tail kept] …`;
|
|
1024
948
|
return [...lines.slice(0, HEAD), marker, ...lines.slice(-TAIL)].join("\n");
|
|
1025
949
|
}
|
|
1026
|
-
/**
|
|
1027
|
-
* 收集 root 的传递子代理后代 id(parentId 链向上能走到 root 的;含嵌套的嵌套)。
|
|
1028
|
-
* root 自身不含;非子代理对话不含(普通对话不参与子代理清理口径)。
|
|
1029
|
-
* parentId 环(理论上不应出现)按 visited 截断,不会死循环。
|
|
1030
|
-
* 纯函数:后端 dismiss 流程与单测共用(前端左栏按同样口径镜像实现,见
|
|
1031
|
-
* LeftPanel finishedSubagentCount)。
|
|
1032
|
-
*/
|
|
1033
950
|
export function collectSubagentDescendantIds(items, rootId) {
|
|
1034
951
|
const byId = new Map(items.map((c) => [c.id, c]));
|
|
1035
952
|
const out = [];
|
|
@@ -1053,7 +970,6 @@ export function collectSubagentDescendantIds(items, rootId) {
|
|
|
1053
970
|
}
|
|
1054
971
|
return out;
|
|
1055
972
|
}
|
|
1056
|
-
/** 人类可读的终态判定:报错 > 中止 > done > running。 */
|
|
1057
973
|
function subagentVerdict(r, lang = "en") {
|
|
1058
974
|
if (r.error)
|
|
1059
975
|
return pick(lang, "error(报错)", "error", "subagents.verdict.error");
|
|
@@ -1061,7 +977,6 @@ function subagentVerdict(r, lang = "en") {
|
|
|
1061
977
|
return pick(lang, "canceled(已中止)", "canceled", "subagents.verdict.canceled");
|
|
1062
978
|
return r.taskPending ? "pending" : r.state;
|
|
1063
979
|
}
|
|
1064
|
-
/** 终态的可读说明(错误文本 / 中止说明 / 空)。运行中返回空。 */
|
|
1065
980
|
function verdictText(r, lang = "en") {
|
|
1066
981
|
if (r.error)
|
|
1067
982
|
return pick(lang, `错误:${r.error}`, `Error: ${r.error}`, "subagents.verdict.error.detail", {
|
|
@@ -1071,7 +986,6 @@ function verdictText(r, lang = "en") {
|
|
|
1071
986
|
return pick(lang, "(被中止,未产出结论)", "(Aborted, no conclusion produced.)", "subagents.verdict.aborted");
|
|
1072
987
|
return "";
|
|
1073
988
|
}
|
|
1074
|
-
/** 未完成部分的引导文案。 */
|
|
1075
989
|
function promptRemaining(remaining, lang = "en") {
|
|
1076
990
|
if (remaining.length === 0)
|
|
1077
991
|
return "";
|