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,13 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* universal-session.ts — 通用 Agent 会话控制器(实现 DispatchSession)。
|
|
3
|
-
*
|
|
4
|
-
* 职责:
|
|
5
|
-
* 1. 桥接 BaseAgentDriver 与 Web 前端 Wire 协议;
|
|
6
|
-
* 2. 自动维护严格线性的 UiMessage[] 历史与流式 streamingMessage;
|
|
7
|
-
* 3. 60ms 节流下发 snapshot / message_delta,实现高帧率低开销的前端流式渲染;
|
|
8
|
-
* 4. 无缝复用宿主 FilesService(文件树/预览/SCM/上传)、TerminalManager(终端)与 BgServerTracker(后台服务)。
|
|
9
|
-
*/
|
|
10
1
|
import { startTurnTiming, finishTurnTiming } from "../turn-timing.js";
|
|
2
|
+
import { normalizeQuickAskSettings } from "../quick-ask-settings.js";
|
|
3
|
+
import { captureQuickAskConversation } from "../quick-ask-context.js";
|
|
11
4
|
import { randomUUID } from "node:crypto";
|
|
12
5
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
13
6
|
import { homedir } from "node:os";
|
|
@@ -88,8 +81,6 @@ export class UniversalSession {
|
|
|
88
81
|
activeConvId;
|
|
89
82
|
conversations = new Map();
|
|
90
83
|
isStreaming = false;
|
|
91
|
-
/** 在途回合归属的会话 id(#700/#701):prompt 开始时锚定,finalizeTurn 收尾时消费并清空。
|
|
92
|
-
* 会话切换/回滚不再让流式回写与回合收尾锚错会话,避免跨对话内容污染落盘。 */
|
|
93
84
|
turnConvId = null;
|
|
94
85
|
turn = null;
|
|
95
86
|
projectGeneration = 0;
|
|
@@ -292,13 +283,11 @@ export class UniversalSession {
|
|
|
292
283
|
else {
|
|
293
284
|
this.currentModel = opts.driver.currentModel ?? "default";
|
|
294
285
|
}
|
|
295
|
-
// 恢复上次使用的模型(按引擎独立记录:项目记忆优先 > 全局默认)
|
|
296
286
|
const savedModel = opts.stateStore?.getProjectModel(opts.clientId, opts.cwd, this.engine) ??
|
|
297
287
|
opts.stateStore?.getDefaultModel(this.engine);
|
|
298
288
|
if (savedModel) {
|
|
299
289
|
this.currentModel = savedModel;
|
|
300
290
|
}
|
|
301
|
-
// 恢复思考强度记忆:模型专属记忆 > 全局默认 > 既有默认
|
|
302
291
|
const rememberedThinking = getModelThinkingLevelFromSettings(this.currentModel, this.agentDir);
|
|
303
292
|
if (rememberedThinking) {
|
|
304
293
|
this.thinkingLevel = rememberedThinking;
|
|
@@ -335,7 +324,6 @@ export class UniversalSession {
|
|
|
335
324
|
cleanupMinutes: () => 0,
|
|
336
325
|
workspaceCwd: () => this.cwd,
|
|
337
326
|
});
|
|
338
|
-
// 加载现有会话或创建初始会话
|
|
339
327
|
const existing = this.store.listConversations(this.cwd);
|
|
340
328
|
if (existing.length > 0) {
|
|
341
329
|
for (const conv of existing) {
|
|
@@ -349,7 +337,6 @@ export class UniversalSession {
|
|
|
349
337
|
this.conversations.set(initialConv.id, initialConv);
|
|
350
338
|
this.store.saveConversation(this.cwd, initialConv);
|
|
351
339
|
}
|
|
352
|
-
// 记录当前客户端访问的工作区
|
|
353
340
|
if (typeof this.stateStore?.remember === "function" && this.cwd) {
|
|
354
341
|
this.stateStore.remember(this.clientId, this.cwd);
|
|
355
342
|
}
|
|
@@ -361,7 +348,6 @@ export class UniversalSession {
|
|
|
361
348
|
})
|
|
362
349
|
.catch(() => { });
|
|
363
350
|
}
|
|
364
|
-
// 若驱动为 Claude Code,异步探测环境并下发安装指引
|
|
365
351
|
if (this.driver instanceof ClaudeCodeDriver) {
|
|
366
352
|
void probeClaudeCode().then((probe) => {
|
|
367
353
|
if (!probe.installed && !this.disposed) {
|
|
@@ -501,9 +487,7 @@ export class UniversalSession {
|
|
|
501
487
|
try {
|
|
502
488
|
sink(msg);
|
|
503
489
|
}
|
|
504
|
-
catch {
|
|
505
|
-
/* ignore send error on broken pipe */
|
|
506
|
-
}
|
|
490
|
+
catch { }
|
|
507
491
|
}
|
|
508
492
|
}
|
|
509
493
|
flushSnapshot(_forceFull = false) {
|
|
@@ -536,7 +520,6 @@ export class UniversalSession {
|
|
|
536
520
|
messages: this.turnConvId === conv.id && this.pendingToolResults.length > 0
|
|
537
521
|
? [...conv.messages, ...this.pendingToolResults]
|
|
538
522
|
: conv.messages,
|
|
539
|
-
// 回合归属会话才携带流式态:切走后的前台会话快照不再混入后台回合内容(#701)
|
|
540
523
|
streamingMessage: !this.turnConvId || this.turnConvId === conv.id ? this.streamingMessage : null,
|
|
541
524
|
isStreaming: !this.turnConvId || this.turnConvId === conv.id ? this.isStreaming : false,
|
|
542
525
|
turnTiming: conv.turnTiming ?? null,
|
|
@@ -590,9 +573,6 @@ export class UniversalSession {
|
|
|
590
573
|
this.flushSnapshot();
|
|
591
574
|
}, SNAPSHOT_INTERVAL_MS);
|
|
592
575
|
}
|
|
593
|
-
// ---------------------------------------------------------------------------
|
|
594
|
-
// 核心 Prompt 流程
|
|
595
|
-
// ---------------------------------------------------------------------------
|
|
596
576
|
static isDefaultTitle(title) {
|
|
597
577
|
const t = (title ?? "").trim();
|
|
598
578
|
return !t || t === "新对话" || t === "New chat" || t === "New Chat" || t === "对话" || t === "Chat";
|
|
@@ -613,11 +593,9 @@ export class UniversalSession {
|
|
|
613
593
|
this.emitNotice("info", "已加入排队,将在当前回复生成完成后自动发送", "Queued — will send after current response settles");
|
|
614
594
|
return;
|
|
615
595
|
}
|
|
616
|
-
// 插队(steer):中断当前轮次并提交新问题
|
|
617
596
|
this.emitNotice("info", "正在插队,中断当前生成并提交新问题...", "Steering: aborting current turn and submitting prompt...");
|
|
618
597
|
await this.abort();
|
|
619
598
|
}
|
|
620
|
-
// 1. 拦截与执行斜杠命令(内置 / 插件 / 驱动扩展 / 技能指令 / 子代理命令)
|
|
621
599
|
const slash = parseSlash(text);
|
|
622
600
|
if (slash) {
|
|
623
601
|
if (slash.name === "subagent" || slash.name.startsWith("subagent:")) {
|
|
@@ -666,7 +644,6 @@ export class UniversalSession {
|
|
|
666
644
|
const isCurrent = () => this.turn === turn && !this.disposed;
|
|
667
645
|
this.turnConvId = conv.id;
|
|
668
646
|
const now = Date.now();
|
|
669
|
-
// 2. 扫描用户文本中的 @ 提及(文件路径与技能指令)
|
|
670
647
|
try {
|
|
671
648
|
const availableSkills = await this.collectUniversalSkills();
|
|
672
649
|
if (!isCurrent())
|
|
@@ -674,7 +651,6 @@ export class UniversalSession {
|
|
|
674
651
|
const scanResult = scanAtMentions(text, turn.cwd, availableSkills, attachments ?? []);
|
|
675
652
|
const effectiveAttachments = [...(attachments ?? []), ...scanResult.detectedAttachments];
|
|
676
653
|
const finalPrompt = formatPromptWithSkills(text, scanResult.detectedSkills);
|
|
677
|
-
// 3. 自动根据首条提问为新会话命名(首条提问立即刷新左侧栏运行与历史列表)
|
|
678
654
|
const hasNoUserMessages = !conv.messages.some((m) => m.role === "user");
|
|
679
655
|
if (UniversalSession.isDefaultTitle(conv.title) && hasNoUserMessages && text.trim()) {
|
|
680
656
|
const trimmed = text.trim().replace(/\s+/g, " ");
|
|
@@ -688,7 +664,6 @@ export class UniversalSession {
|
|
|
688
664
|
}
|
|
689
665
|
void this.refreshSessions();
|
|
690
666
|
}
|
|
691
|
-
// 4. 插入用户消息以及附件卡片(保证 Web UI 附件卡片折叠呈现与历史复原)
|
|
692
667
|
const userMsg = {
|
|
693
668
|
id: `u-${now}-${randomUUID().slice(0, 6)}`,
|
|
694
669
|
role: "user",
|
|
@@ -706,9 +681,7 @@ export class UniversalSession {
|
|
|
706
681
|
if (!conv.isEphemeral) {
|
|
707
682
|
this.store.saveConversation(this.cwd, conv);
|
|
708
683
|
}
|
|
709
|
-
// 用户发送了提示词,消费并清除当前会话的草稿
|
|
710
684
|
this.sessionDrafts.delete(conv.id);
|
|
711
|
-
// 确保底层驱动与当前对话的 driverSessionId 上下文同步(保证多轮对话连续且新建对话隔离)
|
|
712
685
|
if (conv.driverSessionId) {
|
|
713
686
|
await this.driver.resumeSession(conv.driverSessionId);
|
|
714
687
|
if (!isCurrent())
|
|
@@ -723,7 +696,6 @@ export class UniversalSession {
|
|
|
723
696
|
this.store.saveConversation(turn.cwd, conv);
|
|
724
697
|
}
|
|
725
698
|
}
|
|
726
|
-
// 3. 准备助手流式消息
|
|
727
699
|
const assistantMsgId = `a-${now}-${randomUUID().slice(0, 6)}`;
|
|
728
700
|
this.streamingThinking = "";
|
|
729
701
|
this.streamingText = "";
|
|
@@ -735,7 +707,6 @@ export class UniversalSession {
|
|
|
735
707
|
model: this.currentModel,
|
|
736
708
|
};
|
|
737
709
|
this.flushSnapshot();
|
|
738
|
-
// 4. 构建 AgentEventSink(时序保真:思考 -> 前置正文 -> 工具调用 -> 总结正文)
|
|
739
710
|
const sink = {
|
|
740
711
|
onSessionStarted: (sessionId) => {
|
|
741
712
|
conv.driverSessionId = sessionId;
|
|
@@ -778,8 +749,6 @@ export class UniversalSession {
|
|
|
778
749
|
argumentsText: JSON.stringify(args, null, 2),
|
|
779
750
|
};
|
|
780
751
|
this.streamingMessage.content.push(toolBlock);
|
|
781
|
-
// Publish the structural boundary before a following text/thinking delta.
|
|
782
|
-
// Otherwise the reducer can merge it into the block preceding this tool.
|
|
783
752
|
this.flushSnapshot();
|
|
784
753
|
},
|
|
785
754
|
onToolEnd: (callId, result) => {
|
|
@@ -837,7 +806,6 @@ export class UniversalSession {
|
|
|
837
806
|
if (this.streamingText) {
|
|
838
807
|
content.push({ type: "text", text: this.streamingText });
|
|
839
808
|
}
|
|
840
|
-
// 保留之前追加的 toolCall blocks
|
|
841
809
|
for (const b of this.streamingMessage.content) {
|
|
842
810
|
if (b.type === "toolCall") {
|
|
843
811
|
content.push(b);
|
|
@@ -876,7 +844,6 @@ export class UniversalSession {
|
|
|
876
844
|
conv.messages.push(...this.pendingToolResults);
|
|
877
845
|
this.pendingToolResults = [];
|
|
878
846
|
}
|
|
879
|
-
// 累计会话统计与上下文占用(底座统一驱动底栏上下文环、Token 计数、缓存命中率与累计成本)
|
|
880
847
|
if (!conv.stats) {
|
|
881
848
|
conv.stats = {
|
|
882
849
|
tokens: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
@@ -903,7 +870,6 @@ export class UniversalSession {
|
|
|
903
870
|
percent: totalCtx !== null && win > 0 ? Math.min(100, Math.round((totalCtx / win) * 100)) : null,
|
|
904
871
|
};
|
|
905
872
|
}
|
|
906
|
-
// 回写 Claude 分配的 session ID(保证多轮上下文连续)
|
|
907
873
|
if (typeof this.driver.getActiveSessionId === "function") {
|
|
908
874
|
const activeSid = this.driver.getActiveSessionId();
|
|
909
875
|
if (activeSid && conv.driverSessionId !== activeSid) {
|
|
@@ -913,23 +879,18 @@ export class UniversalSession {
|
|
|
913
879
|
finishTurnTiming(conv);
|
|
914
880
|
this.isStreaming = false;
|
|
915
881
|
this.streamingThinking = "";
|
|
916
|
-
// 先取本轮全文再清空:内联标记解析在清空之后读 streamingText,
|
|
917
|
-
// 条件恒为 false,[[conv:rename]]/[[action:suggest]] 在 universal
|
|
918
|
-
// 引擎(claude/durable 等驱动)下从不被解析。
|
|
919
882
|
const finalText = this.streamingText;
|
|
920
883
|
this.streamingText = "";
|
|
921
884
|
conv.updatedAt = Date.now();
|
|
922
885
|
if (!conv.isEphemeral) {
|
|
923
886
|
this.store.saveConversation(turn.cwd, conv);
|
|
924
887
|
}
|
|
925
|
-
// 解析本轮生成的内联标记(如 [[conv:rename:...]] / [[action:suggest:...]])
|
|
926
888
|
if (finalText && finalText.includes("[[")) {
|
|
927
889
|
this.markerOrigins.set(conv.id, turn);
|
|
928
890
|
void this.markerSvc.handleAssistantText(conv.id, finalText);
|
|
929
891
|
}
|
|
930
892
|
this.flushSnapshot();
|
|
931
893
|
void this.refreshSessions();
|
|
932
|
-
// 检查排队消息并自动处理
|
|
933
894
|
if (!this.switchingProject && !this.disposed && this.followUpQueue.length > 0) {
|
|
934
895
|
const next = this.followUpQueue.shift();
|
|
935
896
|
this.flushSnapshot(true);
|
|
@@ -941,7 +902,6 @@ export class UniversalSession {
|
|
|
941
902
|
return this.abortPromise;
|
|
942
903
|
if (!this.isStreaming)
|
|
943
904
|
return;
|
|
944
|
-
// Install the gate before finalizeTurn can dispatch a queued prompt.
|
|
945
905
|
this.abortPromise = Promise.resolve().then(async () => {
|
|
946
906
|
this.finalizeTurn();
|
|
947
907
|
await this.driver.abort();
|
|
@@ -959,7 +919,6 @@ export class UniversalSession {
|
|
|
959
919
|
}
|
|
960
920
|
async retryLast() {
|
|
961
921
|
const conv = this.activeConv;
|
|
962
|
-
// 找到最后一条 user 消息重新发送
|
|
963
922
|
for (let i = conv.messages.length - 1; i >= 0; i--) {
|
|
964
923
|
const m = conv.messages[i];
|
|
965
924
|
if (m.role === "user") {
|
|
@@ -980,9 +939,6 @@ export class UniversalSession {
|
|
|
980
939
|
}
|
|
981
940
|
}
|
|
982
941
|
}
|
|
983
|
-
// ---------------------------------------------------------------------------
|
|
984
|
-
// 对话生命周期
|
|
985
|
-
// ---------------------------------------------------------------------------
|
|
986
942
|
async newChat(_preset, ephemeral = false, onReady) {
|
|
987
943
|
const newConv = this.createEmptyConversation("新对话", Boolean(ephemeral));
|
|
988
944
|
this.conversations.set(newConv.id, newConv);
|
|
@@ -995,6 +951,16 @@ export class UniversalSession {
|
|
|
995
951
|
onReady?.(newConv.id);
|
|
996
952
|
return true;
|
|
997
953
|
}
|
|
954
|
+
async readQuickAskConversation(source, signal) {
|
|
955
|
+
signal.throwIfAborted();
|
|
956
|
+
const id = source.conversationId ?? source.sessionFile;
|
|
957
|
+
if (!id ||
|
|
958
|
+
!/^[a-zA-Z0-9_-]+$/.test(id) ||
|
|
959
|
+
(source.conversationId && source.sessionFile && source.conversationId !== source.sessionFile))
|
|
960
|
+
return undefined;
|
|
961
|
+
const conv = this.conversations.get(id) ?? this.store.loadConversation(this.cwd, id);
|
|
962
|
+
return conv ? captureQuickAskConversation(conv.title, conv.id, conv.messages, this.cwd) : undefined;
|
|
963
|
+
}
|
|
998
964
|
async switchConversation(id) {
|
|
999
965
|
assertEngineWorkspaceSupported(this.sandboxes, this.cwd, this.engine);
|
|
1000
966
|
let conv = this.conversations.get(id);
|
|
@@ -1005,7 +971,6 @@ export class UniversalSession {
|
|
|
1005
971
|
}
|
|
1006
972
|
if (conv) {
|
|
1007
973
|
this.activeConvId = conv.id;
|
|
1008
|
-
// 同步底层驱动会话上下文(若存在)
|
|
1009
974
|
if (conv.driverSessionId) {
|
|
1010
975
|
await this.driver.resumeSession(conv.driverSessionId).catch(() => { });
|
|
1011
976
|
}
|
|
@@ -1070,9 +1035,7 @@ export class UniversalSession {
|
|
|
1070
1035
|
}
|
|
1071
1036
|
async deleteSession(path) {
|
|
1072
1037
|
const targetId = path.trim() || this.activeConvId;
|
|
1073
|
-
// 1. 从磁盘删除持久化会话记录
|
|
1074
1038
|
this.store.deleteConversation(this.cwd, targetId);
|
|
1075
|
-
// 2. 若内存中存在该会话,将其从内存中移除
|
|
1076
1039
|
if (this.conversations.has(targetId)) {
|
|
1077
1040
|
await this.dismissConversation(targetId, true, true);
|
|
1078
1041
|
}
|
|
@@ -1085,18 +1048,15 @@ export class UniversalSession {
|
|
|
1085
1048
|
const conv = this.conversations.get(id);
|
|
1086
1049
|
if (!conv)
|
|
1087
1050
|
return;
|
|
1088
|
-
// 若指定 withFinishedSubagents,级联清理该父会话下的已结束子代理
|
|
1089
1051
|
if (withFinishedSubagents) {
|
|
1090
1052
|
const kids = Array.from(this.conversations.values()).filter((c) => c.isSubagent && c.subagentParentId === id && !c.subagentStreaming);
|
|
1091
1053
|
for (const kid of kids) {
|
|
1092
1054
|
await this.dismissConversation(kid.id, false, force);
|
|
1093
1055
|
}
|
|
1094
1056
|
}
|
|
1095
|
-
// 若清理的本身是运行中的子代理,立即中止并清理其驱动
|
|
1096
1057
|
if (conv.isSubagent && conv.subagentStreaming) {
|
|
1097
1058
|
await this.stopSubagent(id);
|
|
1098
1059
|
}
|
|
1099
|
-
// 仅从运行中会话映射与草稿中移除,保留磁盘持久化记录(供历史面板随时回溯打开)
|
|
1100
1060
|
this.conversations.delete(id);
|
|
1101
1061
|
this.sessionDrafts.delete(id);
|
|
1102
1062
|
if (this.activeConvId === id) {
|
|
@@ -1157,7 +1117,6 @@ export class UniversalSession {
|
|
|
1157
1117
|
if (!targetConv) {
|
|
1158
1118
|
targetConv = this.activeConv;
|
|
1159
1119
|
}
|
|
1160
|
-
// 回滚与在途回合互斥:先落定在途回合再截断,否则 finalize 与 slice 交错导致截断/错位(#700)
|
|
1161
1120
|
if (targetConv.id === this.activeConvId && (this.isStreaming || this.streamingMessage)) {
|
|
1162
1121
|
await this.abort();
|
|
1163
1122
|
targetConv = this.activeConv;
|
|
@@ -1168,7 +1127,6 @@ export class UniversalSession {
|
|
|
1168
1127
|
this.flushSnapshot();
|
|
1169
1128
|
return;
|
|
1170
1129
|
}
|
|
1171
|
-
// 回滚截断到该消息之前
|
|
1172
1130
|
targetConv.messages = targetConv.messages.slice(0, idx);
|
|
1173
1131
|
targetConv.updatedAt = Date.now();
|
|
1174
1132
|
if (!targetConv.isEphemeral) {
|
|
@@ -1215,7 +1173,6 @@ export class UniversalSession {
|
|
|
1215
1173
|
if (forkedMessages.length > 0) {
|
|
1216
1174
|
forkedConv.updatedAt = Date.now();
|
|
1217
1175
|
}
|
|
1218
|
-
// 若底层驱动支持原生会话分叉(如 Durable 引擎的原生 CoW 分叉),保持事务级上下文关联
|
|
1219
1176
|
if (targetConv.driverSessionId && typeof this.driver.forkSession === "function") {
|
|
1220
1177
|
try {
|
|
1221
1178
|
const forkedSid = await this.driver.forkSession(targetConv.driverSessionId);
|
|
@@ -1223,9 +1180,7 @@ export class UniversalSession {
|
|
|
1223
1180
|
forkedConv.driverSessionId = forkedSid;
|
|
1224
1181
|
}
|
|
1225
1182
|
}
|
|
1226
|
-
catch {
|
|
1227
|
-
/* fallback */
|
|
1228
|
-
}
|
|
1183
|
+
catch { }
|
|
1229
1184
|
}
|
|
1230
1185
|
this.conversations.set(forkedConv.id, forkedConv);
|
|
1231
1186
|
if (!forkedConv.isEphemeral) {
|
|
@@ -1255,7 +1210,6 @@ export class UniversalSession {
|
|
|
1255
1210
|
this.flushSnapshot();
|
|
1256
1211
|
return;
|
|
1257
1212
|
}
|
|
1258
|
-
// Remove the question, its file asides and the abandoned suffix in place.
|
|
1259
1213
|
let cutIdx = idx;
|
|
1260
1214
|
while (cutIdx > 0 &&
|
|
1261
1215
|
conv.messages[cutIdx - 1]?.role === "custom" &&
|
|
@@ -1263,8 +1217,6 @@ export class UniversalSession {
|
|
|
1263
1217
|
cutIdx--;
|
|
1264
1218
|
}
|
|
1265
1219
|
conv.messages.splice(cutIdx);
|
|
1266
|
-
// Drivers expose no in-place history replacement. A fresh backend handle
|
|
1267
|
-
// prevents resume from restoring the discarded suffix; the UI identity stays.
|
|
1268
1220
|
conv.driverSessionId = undefined;
|
|
1269
1221
|
const context = conv.messages.map((m) => `[${m.role}] ${messageTextWithQuotes(m)}`).join("\n");
|
|
1270
1222
|
conv.updatedAt = Date.now();
|
|
@@ -1274,7 +1226,6 @@ export class UniversalSession {
|
|
|
1274
1226
|
}
|
|
1275
1227
|
this.flushSnapshot(true);
|
|
1276
1228
|
void this.refreshSessions();
|
|
1277
|
-
// Capture the destination before any asynchronous slash/skill lookup.
|
|
1278
1229
|
await this.prompt(text, attachments, undefined, conv, context ? `Previous conversation context:\n${context}` : "");
|
|
1279
1230
|
}
|
|
1280
1231
|
async refreshSessions() {
|
|
@@ -1315,7 +1266,6 @@ export class UniversalSession {
|
|
|
1315
1266
|
isEphemeral: Boolean(c.isEphemeral),
|
|
1316
1267
|
}));
|
|
1317
1268
|
this.send({ type: "conversations", conversations: convs, activeId: this.activeConvId });
|
|
1318
|
-
// 左侧栏历史对话读取的是 sessions 消息(轻量临时子代理不污染长期历史列表):
|
|
1319
1269
|
const sessionSummaries = allList
|
|
1320
1270
|
.filter((c) => !c.isSubagent || !c.isEphemeral)
|
|
1321
1271
|
.map((c) => {
|
|
@@ -1338,7 +1288,6 @@ export class UniversalSession {
|
|
|
1338
1288
|
});
|
|
1339
1289
|
this.send({ type: "sessions", sessions: sessionSummaries });
|
|
1340
1290
|
}
|
|
1341
|
-
/** 引擎自属的会话展示名解析回调(定制 Universal/Claude 的首条截断 + 自定义命名策略) */
|
|
1342
1291
|
resolveSessionDisplayName(conv, firstMsg) {
|
|
1343
1292
|
if (conv.title && !UniversalSession.isDefaultTitle(conv.title)) {
|
|
1344
1293
|
return conv.title;
|
|
@@ -1431,9 +1380,6 @@ export class UniversalSession {
|
|
|
1431
1380
|
this.send({ type: "session_search_results", reqId, query, ok: false, results: [] });
|
|
1432
1381
|
}
|
|
1433
1382
|
}
|
|
1434
|
-
// ---------------------------------------------------------------------------
|
|
1435
|
-
// 文件、终端与 Git SCM 委托
|
|
1436
|
-
// ---------------------------------------------------------------------------
|
|
1437
1383
|
async listFiles(path) {
|
|
1438
1384
|
await this.files.listFiles(path);
|
|
1439
1385
|
}
|
|
@@ -1484,9 +1430,6 @@ export class UniversalSession {
|
|
|
1484
1430
|
getTerminalCwd() {
|
|
1485
1431
|
return this.cwd;
|
|
1486
1432
|
}
|
|
1487
|
-
// ---------------------------------------------------------------------------
|
|
1488
|
-
// 后台服务生命周期委托
|
|
1489
|
-
// ---------------------------------------------------------------------------
|
|
1490
1433
|
async killBackgroundServer(port, _taskId) {
|
|
1491
1434
|
if (port === undefined)
|
|
1492
1435
|
return false;
|
|
@@ -1511,9 +1454,6 @@ export class UniversalSession {
|
|
|
1511
1454
|
const minutes = Number.isFinite(override) && override > 0 ? override : 30;
|
|
1512
1455
|
return this.bg.cleanStale(minutes * 60_000, { manual: true });
|
|
1513
1456
|
}
|
|
1514
|
-
// ---------------------------------------------------------------------------
|
|
1515
|
-
// 模型与偏好控制
|
|
1516
|
-
// ---------------------------------------------------------------------------
|
|
1517
1457
|
async listModels() {
|
|
1518
1458
|
if (this.driver.listModels) {
|
|
1519
1459
|
const models = await this.driver.listModels();
|
|
@@ -1553,12 +1493,10 @@ export class UniversalSession {
|
|
|
1553
1493
|
if (this.driver.setModel) {
|
|
1554
1494
|
await this.driver.setModel(modelId);
|
|
1555
1495
|
}
|
|
1556
|
-
// 优先恢复该模型的全局思考强度记忆或全局默认强度
|
|
1557
1496
|
const remembered = getModelThinkingLevelFromSettings(modelId, this.agentDir);
|
|
1558
1497
|
if (remembered) {
|
|
1559
1498
|
this.thinkingLevel = remembered;
|
|
1560
1499
|
}
|
|
1561
|
-
// 校验并平滑适应新模型支持的思考强度
|
|
1562
1500
|
if (typeof this.driver.getSupportedThinkingLevels === "function") {
|
|
1563
1501
|
const supported = this.driver.getSupportedThinkingLevels(modelId);
|
|
1564
1502
|
if (supported.length > 0 && !supported.includes(this.thinkingLevel)) {
|
|
@@ -1594,7 +1532,6 @@ export class UniversalSession {
|
|
|
1594
1532
|
if (typeof this.driver.setThinkingLevel === "function") {
|
|
1595
1533
|
this.driver.setThinkingLevel(level);
|
|
1596
1534
|
}
|
|
1597
|
-
// 同步持久化至全局 settings.json 的 modelThinkingLevels
|
|
1598
1535
|
if (this.currentModel) {
|
|
1599
1536
|
saveModelThinkingLevelToSettings(this.currentModel, level, this.agentDir);
|
|
1600
1537
|
}
|
|
@@ -1606,7 +1543,6 @@ export class UniversalSession {
|
|
|
1606
1543
|
throw new Error("Workspace switch already in progress");
|
|
1607
1544
|
this.switchingProject = true;
|
|
1608
1545
|
try {
|
|
1609
|
-
// Finish the captured old turn before replacing the driver's workspace.
|
|
1610
1546
|
this.followUpQueue = [];
|
|
1611
1547
|
await this.abort();
|
|
1612
1548
|
for (const id of this.subagentDrivers.keys())
|
|
@@ -1614,7 +1550,6 @@ export class UniversalSession {
|
|
|
1614
1550
|
this.projectGeneration++;
|
|
1615
1551
|
this.cwd = path;
|
|
1616
1552
|
this.driver.setCwd(path);
|
|
1617
|
-
// 切换工作区 CWD:清空旧目录会话缓存与草稿,并加载属于新目录的会话
|
|
1618
1553
|
this.conversations.clear();
|
|
1619
1554
|
this.sessionDrafts.clear();
|
|
1620
1555
|
const existing = this.store.listConversations(this.cwd);
|
|
@@ -1636,7 +1571,6 @@ export class UniversalSession {
|
|
|
1636
1571
|
this.stateStore.remember(this.clientId, path);
|
|
1637
1572
|
}
|
|
1638
1573
|
void this.pushProjects();
|
|
1639
|
-
// 切换目录后恢复该目录按引擎隔离的项目记忆模型
|
|
1640
1574
|
const savedModel = this.stateStore?.getProjectModel(this.clientId, path, this.engine) ??
|
|
1641
1575
|
this.stateStore?.getDefaultModel(this.engine);
|
|
1642
1576
|
if (savedModel && savedModel !== this.currentModel) {
|
|
@@ -1662,11 +1596,9 @@ export class UniversalSession {
|
|
|
1662
1596
|
this.worktreeInfo = info;
|
|
1663
1597
|
this.flushSnapshot();
|
|
1664
1598
|
}
|
|
1665
|
-
/** 获取通用底座持有的持久终端交互工具集 */
|
|
1666
1599
|
getTerminalTools() {
|
|
1667
1600
|
return makePersistentTerminalTools(this.terminals, this.cwd, () => this.lang);
|
|
1668
1601
|
}
|
|
1669
|
-
/** 执行通用底座持久终端工具(供外部驱动或模型调用) */
|
|
1670
1602
|
async execTerminalTool(name, args, signal) {
|
|
1671
1603
|
const tools = this.getTerminalTools();
|
|
1672
1604
|
const tool = tools.find((t) => t.name === name);
|
|
@@ -1881,9 +1813,6 @@ export class UniversalSession {
|
|
|
1881
1813
|
async makeDir(path) {
|
|
1882
1814
|
await this.files.makeDir(path);
|
|
1883
1815
|
}
|
|
1884
|
-
// ---------------------------------------------------------------------------
|
|
1885
|
-
// 辅助方法与空实现
|
|
1886
|
-
// ---------------------------------------------------------------------------
|
|
1887
1816
|
emitNotice(level, text, textEn) {
|
|
1888
1817
|
this.send({ type: "notice", level, text, textEn });
|
|
1889
1818
|
}
|
|
@@ -1918,9 +1847,7 @@ export class UniversalSession {
|
|
|
1918
1847
|
}
|
|
1919
1848
|
}
|
|
1920
1849
|
}
|
|
1921
|
-
catch {
|
|
1922
|
-
/* ignore driver model query error */
|
|
1923
|
-
}
|
|
1850
|
+
catch { }
|
|
1924
1851
|
}
|
|
1925
1852
|
return out;
|
|
1926
1853
|
}
|
|
@@ -1941,9 +1868,7 @@ export class UniversalSession {
|
|
|
1941
1868
|
}
|
|
1942
1869
|
}
|
|
1943
1870
|
}
|
|
1944
|
-
catch {
|
|
1945
|
-
/* ignore driver skills query error */
|
|
1946
|
-
}
|
|
1871
|
+
catch { }
|
|
1947
1872
|
}
|
|
1948
1873
|
this.skillsCache = out;
|
|
1949
1874
|
return out;
|
|
@@ -1984,15 +1909,14 @@ export class UniversalSession {
|
|
|
1984
1909
|
async listCommands() {
|
|
1985
1910
|
this.send({ type: "commands", commands: [], path: "" });
|
|
1986
1911
|
}
|
|
1987
|
-
async saveCommands(_commands) {
|
|
1988
|
-
/* no-op */
|
|
1989
|
-
}
|
|
1912
|
+
async saveCommands(_commands) { }
|
|
1990
1913
|
refreshSettings() {
|
|
1991
1914
|
this.pushSettings();
|
|
1992
1915
|
}
|
|
1993
1916
|
pushSettings() {
|
|
1994
1917
|
const s = this.stateStore?.getSettings(this.clientId);
|
|
1995
1918
|
const settings = {
|
|
1919
|
+
...normalizeQuickAskSettings(s ?? {}),
|
|
1996
1920
|
steeringMode: s?.steeringMode ?? "all",
|
|
1997
1921
|
followUpMode: s?.followUpMode ?? "all",
|
|
1998
1922
|
promptMode: s?.promptMode ?? "append",
|
|
@@ -2001,6 +1925,7 @@ export class UniversalSession {
|
|
|
2001
1925
|
disabledExtensions: s?.disabledExtensions ?? [],
|
|
2002
1926
|
disabledAgentTools: [],
|
|
2003
1927
|
disabledPluginTools: [],
|
|
1928
|
+
nativeCliInheritModel: { ...s?.nativeCliInheritModel },
|
|
2004
1929
|
terminalToolsEnabled: s?.terminalToolsEnabled ?? true,
|
|
2005
1930
|
terminalBash: s?.terminalBash ?? true,
|
|
2006
1931
|
terminalBashIdleMs: s?.terminalBashIdleMs ?? 3000,
|
|
@@ -2008,7 +1933,6 @@ export class UniversalSession {
|
|
|
2008
1933
|
toolWatchdogTimeoutMs: s?.toolWatchdogTimeoutMs ?? 1200000,
|
|
2009
1934
|
readDirEnabled: true,
|
|
2010
1935
|
bgAutoCleanupMin: s?.bgAutoCleanupMin ?? 0,
|
|
2011
|
-
// 同一字段的含义在本引擎不适用(无 pi 工具注册面):恒为 false 占位,保协议完整。
|
|
2012
1936
|
toolLazyLoading: false,
|
|
2013
1937
|
codemodeMode: "on",
|
|
2014
1938
|
codemodeInlineBudget: 3000,
|
|
@@ -2016,6 +1940,7 @@ export class UniversalSession {
|
|
|
2016
1940
|
retryMaxAttempts: 0,
|
|
2017
1941
|
softCapTokens: 0,
|
|
2018
1942
|
softCapByModel: {},
|
|
1943
|
+
autoCompactionInstructions: "",
|
|
2019
1944
|
questionnaireEnabled: false,
|
|
2020
1945
|
toolApprovalEnabled: true,
|
|
2021
1946
|
approvalPolicy: { allowAll: false, categories: [] },
|
|
@@ -2090,15 +2015,9 @@ export class UniversalSession {
|
|
|
2090
2015
|
}
|
|
2091
2016
|
this.pushSettings();
|
|
2092
2017
|
}
|
|
2093
|
-
async reloadExtensions() {
|
|
2094
|
-
|
|
2095
|
-
}
|
|
2096
|
-
async checkUpdate() {
|
|
2097
|
-
/* no-op */
|
|
2098
|
-
}
|
|
2099
|
-
async checkUpdatesAll() {
|
|
2100
|
-
/* no-op */
|
|
2101
|
-
}
|
|
2018
|
+
async reloadExtensions() { }
|
|
2019
|
+
async checkUpdate() { }
|
|
2020
|
+
async checkUpdatesAll() { }
|
|
2102
2021
|
resolveDialog(id, value) {
|
|
2103
2022
|
this.webUi.resolveDialog(id, value);
|
|
2104
2023
|
}
|
|
@@ -2112,7 +2031,6 @@ export class UniversalSession {
|
|
|
2112
2031
|
this.webUi.handleTuiOverlayCancel(id);
|
|
2113
2032
|
}
|
|
2114
2033
|
installPiAgent() {
|
|
2115
|
-
/* no-op */
|
|
2116
2034
|
return Promise.resolve();
|
|
2117
2035
|
}
|
|
2118
2036
|
setProviderApiKey(provider, apiKey) {
|
|
@@ -2192,15 +2110,12 @@ export class UniversalSession {
|
|
|
2192
2110
|
return Promise.resolve();
|
|
2193
2111
|
}
|
|
2194
2112
|
clearGoal() {
|
|
2195
|
-
/* no-op */
|
|
2196
2113
|
return Promise.resolve();
|
|
2197
2114
|
}
|
|
2198
2115
|
startGoalWizard() {
|
|
2199
|
-
/* no-op */
|
|
2200
2116
|
return Promise.resolve();
|
|
2201
2117
|
}
|
|
2202
2118
|
setGoalPrefs() {
|
|
2203
|
-
/* no-op */
|
|
2204
2119
|
return Promise.resolve();
|
|
2205
2120
|
}
|
|
2206
2121
|
async savePreset(name) {
|
|
@@ -2223,6 +2138,7 @@ export class UniversalSession {
|
|
|
2223
2138
|
retryMaxAttempts: s.retryMaxAttempts,
|
|
2224
2139
|
softCapTokens: s.softCapTokens,
|
|
2225
2140
|
softCapByModel: s.softCapByModel,
|
|
2141
|
+
autoCompactionInstructions: s.autoCompactionInstructions ?? "",
|
|
2226
2142
|
});
|
|
2227
2143
|
this.stateStore.savePresets(this.clientId, filtered);
|
|
2228
2144
|
this.pushSettings();
|
|
@@ -2237,7 +2153,6 @@ export class UniversalSession {
|
|
|
2237
2153
|
this.emitNotice("error", `未找到名为「${name}」的设置预设`, `Settings preset "${name}" not found`);
|
|
2238
2154
|
return;
|
|
2239
2155
|
}
|
|
2240
|
-
// Missing settings retain their current values; metadata never enters settings.
|
|
2241
2156
|
const { settings } = sanitizePresetSettings(found);
|
|
2242
2157
|
this.stateStore.saveSettings(this.clientId, settings);
|
|
2243
2158
|
this.pushSettings();
|
|
@@ -2437,10 +2352,6 @@ export class UniversalSession {
|
|
|
2437
2352
|
error: res.error,
|
|
2438
2353
|
});
|
|
2439
2354
|
}
|
|
2440
|
-
// ---------------------------------------------------------------------------
|
|
2441
|
-
// 通用底座第一方子代理(Subagent)生命周期与调度管理
|
|
2442
|
-
// ---------------------------------------------------------------------------
|
|
2443
|
-
/** 统计当前活跃(流式运行中)的子代理数量 */
|
|
2444
2355
|
getLiveSubagentsCount() {
|
|
2445
2356
|
let count = 0;
|
|
2446
2357
|
for (const conv of this.conversations.values()) {
|
|
@@ -2450,7 +2361,6 @@ export class UniversalSession {
|
|
|
2450
2361
|
}
|
|
2451
2362
|
return count;
|
|
2452
2363
|
}
|
|
2453
|
-
/** 创建并启动一个子代理会话 */
|
|
2454
2364
|
async spawnSubagent(prompt, type, cwd, templateName, model, parentId, persist = false, title, _thinking, _notifyOnDone) {
|
|
2455
2365
|
if (_notifyOnDone === "manual") {
|
|
2456
2366
|
throw new Error("notifyOnDone=manual is only supported by the pi engine.");
|
|
@@ -2464,7 +2374,6 @@ export class UniversalSession {
|
|
|
2464
2374
|
if (liveCount >= maxSubagents) {
|
|
2465
2375
|
throw new Error(pick(this.lang, `同时运行的子代理数量已达上限(${maxSubagents} 个),请先用 wait 等一部分完成、或用 stop 停掉不需要的再派发`, `Active subagent limit reached (${maxSubagents} live). Wait for some with wait_all or stop unneeded ones with stop before spawning more`));
|
|
2466
2376
|
}
|
|
2467
|
-
// 检查并解析模板
|
|
2468
2377
|
let template;
|
|
2469
2378
|
let effectivePrompt = prompt;
|
|
2470
2379
|
if (templateName) {
|
|
@@ -2521,7 +2430,6 @@ export class UniversalSession {
|
|
|
2521
2430
|
}
|
|
2522
2431
|
this.flushSnapshot();
|
|
2523
2432
|
void this.refreshSessions();
|
|
2524
|
-
// 为该子代理创建独立的 Driver 实例
|
|
2525
2433
|
let subDriver;
|
|
2526
2434
|
if (this.driverFactory) {
|
|
2527
2435
|
subDriver = this.driverFactory(targetCwd);
|
|
@@ -2538,22 +2446,17 @@ export class UniversalSession {
|
|
|
2538
2446
|
subDriver = this.driver;
|
|
2539
2447
|
}
|
|
2540
2448
|
this.subagentDrivers.set(convId, subDriver);
|
|
2541
|
-
// 若驱动支持 setModel,应用子代理指定的模型
|
|
2542
2449
|
if (effectiveModel && subDriver.setModel) {
|
|
2543
2450
|
try {
|
|
2544
2451
|
await subDriver.setModel(effectiveModel);
|
|
2545
2452
|
}
|
|
2546
|
-
catch {
|
|
2547
|
-
// 驱动不支持或模型设置失败时平滑降级
|
|
2548
|
-
}
|
|
2453
|
+
catch { }
|
|
2549
2454
|
}
|
|
2550
2455
|
if (this.disposed || generation !== this.projectGeneration || this.subagentDrivers.get(convId) !== subDriver)
|
|
2551
2456
|
return { convId };
|
|
2552
|
-
// 异步启动子代理执行流程
|
|
2553
2457
|
void this.runSubagent(convId, subDriver, effectivePrompt, targetCwd);
|
|
2554
2458
|
return { convId };
|
|
2555
2459
|
}
|
|
2556
|
-
/** 后台异步执行子代理 Prompt */
|
|
2557
2460
|
async runSubagent(convId, subDriver, prompt, cwd) {
|
|
2558
2461
|
const conv = this.conversations.get(convId);
|
|
2559
2462
|
if (!conv)
|
|
@@ -2586,7 +2489,6 @@ export class UniversalSession {
|
|
|
2586
2489
|
assistantMsg.content.push({ type: "thinking", thinking: delta });
|
|
2587
2490
|
}
|
|
2588
2491
|
if (this.activeConvId === convId) {
|
|
2589
|
-
// Subagents stream through conv.messages snapshots, not the main turn's message.
|
|
2590
2492
|
this.scheduleThrottledSnapshot();
|
|
2591
2493
|
}
|
|
2592
2494
|
},
|
|
@@ -2650,9 +2552,7 @@ export class UniversalSession {
|
|
|
2650
2552
|
try {
|
|
2651
2553
|
void subDriver.dispose();
|
|
2652
2554
|
}
|
|
2653
|
-
catch {
|
|
2654
|
-
// 忽略 dispose 异常
|
|
2655
|
-
}
|
|
2555
|
+
catch { }
|
|
2656
2556
|
this.notifySubagentWaitListeners();
|
|
2657
2557
|
this.flushSnapshot();
|
|
2658
2558
|
void this.refreshSessions();
|
|
@@ -2670,9 +2570,7 @@ export class UniversalSession {
|
|
|
2670
2570
|
try {
|
|
2671
2571
|
void subDriver.dispose();
|
|
2672
2572
|
}
|
|
2673
|
-
catch {
|
|
2674
|
-
// 忽略 dispose 异常
|
|
2675
|
-
}
|
|
2573
|
+
catch { }
|
|
2676
2574
|
this.notifySubagentWaitListeners();
|
|
2677
2575
|
this.flushSnapshot();
|
|
2678
2576
|
void this.refreshSessions();
|
|
@@ -2701,7 +2599,6 @@ export class UniversalSession {
|
|
|
2701
2599
|
sink.onError(msg);
|
|
2702
2600
|
}
|
|
2703
2601
|
}
|
|
2704
|
-
/** 获取单个子代理运行态快照结果 */
|
|
2705
2602
|
async getSubagentResult(convId) {
|
|
2706
2603
|
const conv = this.conversations.get(convId);
|
|
2707
2604
|
if (!conv || !conv.isSubagent) {
|
|
@@ -2709,7 +2606,6 @@ export class UniversalSession {
|
|
|
2709
2606
|
}
|
|
2710
2607
|
return this.subagentToSnapshot(conv);
|
|
2711
2608
|
}
|
|
2712
|
-
/** 提取子代理会话的最终 assistant 正文输出 */
|
|
2713
2609
|
extractSubagentOutput(conv) {
|
|
2714
2610
|
const assistantMsgs = conv.messages.filter((m) => m.role === "assistant");
|
|
2715
2611
|
const pieces = [];
|
|
@@ -2722,7 +2618,6 @@ export class UniversalSession {
|
|
|
2722
2618
|
}
|
|
2723
2619
|
return pieces.join("\n").trim();
|
|
2724
2620
|
}
|
|
2725
|
-
/** 将 UniversalConversation 转换成标准 SubagentSnapshot */
|
|
2726
2621
|
subagentToSnapshot(conv) {
|
|
2727
2622
|
const output = this.extractSubagentOutput(conv);
|
|
2728
2623
|
const state = conv.subagentState ?? (conv.subagentStreaming ? "running" : conv.subagentCanceled ? "canceled" : "done");
|
|
@@ -2744,7 +2639,6 @@ export class UniversalSession {
|
|
|
2744
2639
|
handoffFrom: conv.subagentHandoffFrom ? [...conv.subagentHandoffFrom] : undefined,
|
|
2745
2640
|
};
|
|
2746
2641
|
}
|
|
2747
|
-
/** 停止指定的子代理运行 */
|
|
2748
2642
|
async stopSubagent(convId) {
|
|
2749
2643
|
const conv = this.conversations.get(convId);
|
|
2750
2644
|
if (!conv)
|
|
@@ -2760,15 +2654,12 @@ export class UniversalSession {
|
|
|
2760
2654
|
await driver.abort();
|
|
2761
2655
|
void driver.dispose();
|
|
2762
2656
|
}
|
|
2763
|
-
catch {
|
|
2764
|
-
// 忽略驱动中止失败
|
|
2765
|
-
}
|
|
2657
|
+
catch { }
|
|
2766
2658
|
}
|
|
2767
2659
|
this.notifySubagentWaitListeners();
|
|
2768
2660
|
this.flushSnapshot();
|
|
2769
2661
|
void this.refreshSessions();
|
|
2770
2662
|
}
|
|
2771
|
-
/** 等待指定的子代理到达终态 */
|
|
2772
2663
|
async waitSubagents(timeoutSeconds, runIds, callerId) {
|
|
2773
2664
|
const waitCapMs = computeWaitCapMs();
|
|
2774
2665
|
const requestedMs = typeof timeoutSeconds === "number" && timeoutSeconds > 0 ? Math.floor(timeoutSeconds * 1000) : waitCapMs;
|
|
@@ -2821,18 +2712,14 @@ export class UniversalSession {
|
|
|
2821
2712
|
this.subagentWaitListeners.add(onUpdate);
|
|
2822
2713
|
});
|
|
2823
2714
|
}
|
|
2824
|
-
/** 唤醒所有等待中的子代理监听者 */
|
|
2825
2715
|
notifySubagentWaitListeners() {
|
|
2826
2716
|
for (const listener of this.subagentWaitListeners) {
|
|
2827
2717
|
try {
|
|
2828
2718
|
listener();
|
|
2829
2719
|
}
|
|
2830
|
-
catch {
|
|
2831
|
-
// 忽略监听者异常
|
|
2832
|
-
}
|
|
2720
|
+
catch { }
|
|
2833
2721
|
}
|
|
2834
2722
|
}
|
|
2835
|
-
/** 列出子代理快照列表 */
|
|
2836
2723
|
listSubagents(scope = "all") {
|
|
2837
2724
|
const snaps = [];
|
|
2838
2725
|
for (const conv of this.conversations.values()) {
|
|
@@ -2846,7 +2733,6 @@ export class UniversalSession {
|
|
|
2846
2733
|
}
|
|
2847
2734
|
return snaps;
|
|
2848
2735
|
}
|
|
2849
|
-
/** 向指定子代理发送引导/追加消息 */
|
|
2850
2736
|
async steerSubagent(convId, message) {
|
|
2851
2737
|
const conv = this.conversations.get(convId);
|
|
2852
2738
|
if (!conv || !conv.isSubagent) {
|
|
@@ -2861,7 +2747,6 @@ export class UniversalSession {
|
|
|
2861
2747
|
conv.updatedAt = Date.now();
|
|
2862
2748
|
this.flushSnapshot();
|
|
2863
2749
|
}
|
|
2864
|
-
/** 跨代理协作交接 */
|
|
2865
2750
|
async handoffSubagent(fromRunId, toRunId, payload) {
|
|
2866
2751
|
const fromConv = this.conversations.get(fromRunId);
|
|
2867
2752
|
const toConv = this.conversations.get(toRunId);
|
|
@@ -2878,7 +2763,6 @@ export class UniversalSession {
|
|
|
2878
2763
|
timestamp: Date.now(),
|
|
2879
2764
|
};
|
|
2880
2765
|
this.subagentHandoffs = recordSubagentHandoff(this.subagentHandoffs, record, 50);
|
|
2881
|
-
// 向目标子代理注入交接卡片消息
|
|
2882
2766
|
const now = Date.now();
|
|
2883
2767
|
const fromType = fromConv?.subagentType ?? "peer";
|
|
2884
2768
|
toConv.messages.push({
|
|
@@ -2903,9 +2787,7 @@ export class UniversalSession {
|
|
|
2903
2787
|
void driver.abort();
|
|
2904
2788
|
void driver.dispose();
|
|
2905
2789
|
}
|
|
2906
|
-
catch {
|
|
2907
|
-
// 忽略驱动释放异常
|
|
2908
|
-
}
|
|
2790
|
+
catch { }
|
|
2909
2791
|
}
|
|
2910
2792
|
this.subagentDrivers.clear();
|
|
2911
2793
|
this.subagentWaitListeners.clear();
|