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,18 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createHash } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
2
|
import { readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
4
4
|
import { writeJsonAtomicSync } from "../atomic-file.js";
|
|
5
|
+
import { VerificationStopUnconfirmedError } from "./local-verification.js";
|
|
6
|
+
import { canonicalPath, computeCanonicalRepositoryId, git, verifyRepoRoot } from "../workspace-handle.js";
|
|
5
7
|
import { createDeviceCollabService } from "./collab-service.js";
|
|
8
|
+
import { deviceCancelIntegration, deviceConfirmIntegration, devicePublicationStatus, deviceCancelPublication, devicePrepareIntegration, deviceVerifyIntegration, loadPersistentSessions, } from "./device-integration.js";
|
|
9
|
+
import { executionRoot, executionRootsOverlap } from "./execution-workspace.js";
|
|
6
10
|
import { createDeviceTaskExecutor } from "./executor.js";
|
|
11
|
+
import { loadExecutionSettings, saveExecutionSettings } from "./execution-settings.js";
|
|
7
12
|
import { createDeviceFileSync } from "./file-sync.js";
|
|
13
|
+
import { reportUploadMetadata } from "./report-metadata.js";
|
|
8
14
|
import { DeviceTaskError } from "./task-error.js";
|
|
9
15
|
import { TaskRecoveryManager } from "./task-recovery.js";
|
|
10
16
|
import { createTaskReportOutbox } from "./task-report-outbox.js";
|
|
11
|
-
import { reportUploadMetadata } from "./report-metadata.js";
|
|
12
17
|
import { DeviceTaskScheduler } from "./task-scheduler.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
18
|
+
import { cleanupTaskWorkspace, captureTaskArtifact, prepareTaskWorkspace, resolveTrustedTaskWorkspace, getTaskWorkspaceCapability, } from "./task-workspace.js";
|
|
19
|
+
import { canonicalizeJson, validateContextManifest, validateWorkContract } from "./work-contract.js";
|
|
20
|
+
import { assertPublishIntentScope, validatePublishIntent } from "./publish-intent.js";
|
|
21
|
+
import { readPublicationJournal, loadPublicationJournals } from "./publication-journal.js";
|
|
22
|
+
import { PublicationStopUnconfirmedError } from "./local-publication.js";
|
|
16
23
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
17
24
|
function samePath(a, b) {
|
|
18
25
|
if (!a || !b)
|
|
@@ -20,7 +27,6 @@ function samePath(a, b) {
|
|
|
20
27
|
const fold = (p) => (process.platform === "win32" ? resolve(p).toLowerCase() : resolve(p));
|
|
21
28
|
return fold(a) === fold(b);
|
|
22
29
|
}
|
|
23
|
-
/** The task settled, but its executor has not confirmed that execution stopped. */
|
|
24
30
|
export class DeviceTaskStopUnconfirmedError extends Error {
|
|
25
31
|
stopUnconfirmed = true;
|
|
26
32
|
constructor(cause) {
|
|
@@ -54,7 +60,6 @@ export function createDeviceRuntime(options) {
|
|
|
54
60
|
return JSON.parse(readFileSync(schedulerFile, "utf8"));
|
|
55
61
|
}
|
|
56
62
|
catch {
|
|
57
|
-
// Corrupt or missing fairness state only means a restart starts with neutral fairness.
|
|
58
63
|
return undefined;
|
|
59
64
|
}
|
|
60
65
|
}
|
|
@@ -65,9 +70,7 @@ export function createDeviceRuntime(options) {
|
|
|
65
70
|
try {
|
|
66
71
|
writeJsonAtomicSync(schedulerFile, scheduler.snapshotState());
|
|
67
72
|
}
|
|
68
|
-
catch {
|
|
69
|
-
/* fairness state is best-effort; never fail dispatch on persistence */
|
|
70
|
-
}
|
|
73
|
+
catch { }
|
|
71
74
|
}
|
|
72
75
|
function scheduleSchedulerStateSave() {
|
|
73
76
|
if (!schedulerFile)
|
|
@@ -138,12 +141,46 @@ export function createDeviceRuntime(options) {
|
|
|
138
141
|
await entry.files.close();
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
|
-
async function
|
|
144
|
+
async function assertPublicationWorkspaceIdle(botId, root) {
|
|
145
|
+
if (!options.dataDir)
|
|
146
|
+
return;
|
|
147
|
+
try {
|
|
148
|
+
const journals = await loadPublicationJournals(options.dataDir);
|
|
149
|
+
if (journals.some((journal) => journal.casStarted &&
|
|
150
|
+
!journal.processStopped &&
|
|
151
|
+
!journal.stop?.stopConfirmed &&
|
|
152
|
+
(journal.intent.targetBotId === botId ||
|
|
153
|
+
(!!journal.repository &&
|
|
154
|
+
executionRootsOverlap(executionRoot(journal.repository.repoRoot), executionRoot(root))))))
|
|
155
|
+
throw new Error("Publication process stop unconfirmed; original workspace blocked");
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
throw new DeviceTaskStopUnconfirmedError(error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function acquire(botId, signal, cancellationId) {
|
|
142
162
|
enabled(signal);
|
|
143
163
|
await sweep();
|
|
144
164
|
const lease = await bots.acquire(botId);
|
|
145
165
|
try {
|
|
146
166
|
enabled(signal);
|
|
167
|
+
await assertPublicationWorkspaceIdle(botId, lease.root);
|
|
168
|
+
if (options.dataDir) {
|
|
169
|
+
const pending = await loadPersistentSessions(options.dataDir);
|
|
170
|
+
for (const session of pending.values()) {
|
|
171
|
+
const legacyStopUnknown = session.verificationStopConfirmed !== true && !session.localVerification;
|
|
172
|
+
if (!session.verificationInFlight && !session.stopUnconfirmed && !legacyStopUnknown)
|
|
173
|
+
continue;
|
|
174
|
+
if (session.targetBotId !== botId &&
|
|
175
|
+
!executionRootsOverlap(executionRoot(session.repoRoot), executionRoot(lease.root)))
|
|
176
|
+
continue;
|
|
177
|
+
const canCancel = cancellationId === session.integrationId &&
|
|
178
|
+
((!session.verificationInFlight && !session.stopUnconfirmed && legacyStopUnknown) ||
|
|
179
|
+
[...active].some((owner) => !owner.blocked && owner.taskId === `integration:${cancellationId}` && owner.botId === botId));
|
|
180
|
+
if (!canCancel)
|
|
181
|
+
throw new DeviceTaskStopUnconfirmedError(new Error("Integration process stop unconfirmed; workspace blocked"));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
147
184
|
if ([...active].some((owner) => owner.blocked && conflicts(owner, { botId, root: executionRoot(lease.root) })))
|
|
148
185
|
throw new DeviceTaskError("Task stop unconfirmed; workspace blocked until service restart");
|
|
149
186
|
return lease;
|
|
@@ -226,6 +263,11 @@ export function createDeviceRuntime(options) {
|
|
|
226
263
|
function onTask(task, signal, callbacks) {
|
|
227
264
|
try {
|
|
228
265
|
enabled(signal);
|
|
266
|
+
if (task.deviceId !== config.deviceId ||
|
|
267
|
+
![task.id, task.attemptId, task.botId, task.roomId].every((value) => typeof value === "string" && value.length > 0 && value.length <= 128) ||
|
|
268
|
+
!Number.isSafeInteger(task.botRevision) ||
|
|
269
|
+
task.botRevision < 1)
|
|
270
|
+
throw new DeviceTaskError("Invalid task route or execution identity");
|
|
229
271
|
}
|
|
230
272
|
catch (error) {
|
|
231
273
|
return Promise.reject(error);
|
|
@@ -281,6 +323,7 @@ export function createDeviceRuntime(options) {
|
|
|
281
323
|
catch (error) {
|
|
282
324
|
return Promise.reject(error);
|
|
283
325
|
}
|
|
326
|
+
task = structuredClone(task);
|
|
284
327
|
if (typeof task.leaseToken !== "string" || !task.leaseToken) {
|
|
285
328
|
return Promise.reject(new DeviceTaskError("Hub task lease grant required"));
|
|
286
329
|
}
|
|
@@ -288,6 +331,70 @@ export function createDeviceRuntime(options) {
|
|
|
288
331
|
if (!capacityCheck.available) {
|
|
289
332
|
return Promise.reject(new DeviceTaskError(capacityCheck.reason ?? "Recovery outbox capacity reached"));
|
|
290
333
|
}
|
|
334
|
+
const isCode = task.executionMode === "code" || task.contract?.executionMode === "code";
|
|
335
|
+
let contract = task.contract;
|
|
336
|
+
let contextManifest = task.contextManifest;
|
|
337
|
+
if (contract) {
|
|
338
|
+
const cCheck = validateWorkContract(contract);
|
|
339
|
+
if (!cCheck.valid) {
|
|
340
|
+
return Promise.reject(new DeviceTaskError(`Invalid work contract: ${cCheck.reason}`));
|
|
341
|
+
}
|
|
342
|
+
contract = cCheck.contract;
|
|
343
|
+
}
|
|
344
|
+
if (contextManifest) {
|
|
345
|
+
const mCheck = validateContextManifest(contextManifest, contract);
|
|
346
|
+
if (!mCheck.valid) {
|
|
347
|
+
return Promise.reject(new DeviceTaskError(`Invalid context manifest: ${mCheck.reason}`));
|
|
348
|
+
}
|
|
349
|
+
contextManifest = mCheck.manifest;
|
|
350
|
+
}
|
|
351
|
+
if (contextManifest?.executionPolicy) {
|
|
352
|
+
const policy = contextManifest.executionPolicy;
|
|
353
|
+
if (policy.deviceId !== config.deviceId ||
|
|
354
|
+
policy.botId !== task.botId ||
|
|
355
|
+
policy.botRevision !== task.botRevision) {
|
|
356
|
+
return Promise.reject(new DeviceTaskError(`Context manifest execution policy mismatch: expected device=${config.deviceId}, bot=${task.botId}@${task.botRevision}; manifest specifies device=${policy.deviceId}, bot=${policy.botId}@${policy.botRevision}`));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
let effectiveContext = task.context;
|
|
360
|
+
let effectiveTaskState = task.taskState;
|
|
361
|
+
if (contextManifest) {
|
|
362
|
+
if (contextManifest.context !== null && contextManifest.context !== undefined) {
|
|
363
|
+
if (task.context !== undefined &&
|
|
364
|
+
canonicalizeJson(task.context) !== canonicalizeJson(contextManifest.context)) {
|
|
365
|
+
return Promise.reject(new DeviceTaskError("Task wire context does not match sealed contextManifest"));
|
|
366
|
+
}
|
|
367
|
+
effectiveContext = contextManifest.context;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
if (task.context !== undefined && task.context !== null)
|
|
371
|
+
return Promise.reject(new DeviceTaskError("Task wire context does not match sealed contextManifest"));
|
|
372
|
+
effectiveContext = undefined;
|
|
373
|
+
}
|
|
374
|
+
if (contextManifest.taskState !== null && contextManifest.taskState !== undefined) {
|
|
375
|
+
if (task.taskState !== undefined &&
|
|
376
|
+
canonicalizeJson(task.taskState) !== canonicalizeJson(contextManifest.taskState)) {
|
|
377
|
+
return Promise.reject(new DeviceTaskError("Task wire taskState does not match sealed contextManifest"));
|
|
378
|
+
}
|
|
379
|
+
effectiveTaskState = contextManifest.taskState;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
if (task.taskState !== undefined && task.taskState !== null)
|
|
383
|
+
return Promise.reject(new DeviceTaskError("Task wire taskState does not match sealed contextManifest"));
|
|
384
|
+
effectiveTaskState = undefined;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (isCode) {
|
|
388
|
+
if (task.resume) {
|
|
389
|
+
return Promise.reject(new DeviceTaskError("Code execution mode refuses resuming old sessions in first slice"));
|
|
390
|
+
}
|
|
391
|
+
if (!contract || contract.executionMode !== "code") {
|
|
392
|
+
return Promise.reject(new DeviceTaskError("Code task requires a valid code work contract"));
|
|
393
|
+
}
|
|
394
|
+
if (!contextManifest) {
|
|
395
|
+
return Promise.reject(new DeviceTaskError("Code task requires sealed contextManifest"));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
291
398
|
const owner = {
|
|
292
399
|
controller: new AbortController(),
|
|
293
400
|
botId: task.botId,
|
|
@@ -295,7 +402,6 @@ export function createDeviceRuntime(options) {
|
|
|
295
402
|
taskId: task.id,
|
|
296
403
|
attemptId: task.attemptId,
|
|
297
404
|
};
|
|
298
|
-
// Transactional Admission: reverse cleanup on any failure before execution starts
|
|
299
405
|
let leaseRecorded = false;
|
|
300
406
|
let activeItem;
|
|
301
407
|
try {
|
|
@@ -309,6 +415,9 @@ export function createDeviceRuntime(options) {
|
|
|
309
415
|
leaseToken: task.leaseToken,
|
|
310
416
|
leaseGeneration: task.leaseGeneration ?? 1,
|
|
311
417
|
conversationId: task.conversationId,
|
|
418
|
+
contractDigest: contract?.digest,
|
|
419
|
+
manifestDigest: contextManifest?.digest,
|
|
420
|
+
executionMode: isCode ? "code" : "chat",
|
|
312
421
|
});
|
|
313
422
|
leaseRecorded = true;
|
|
314
423
|
activeItem = scheduler.registerActive({
|
|
@@ -330,7 +439,26 @@ export function createDeviceRuntime(options) {
|
|
|
330
439
|
callbacks?.onStarted?.();
|
|
331
440
|
const taskSignal = AbortSignal.any([owner.controller.signal, ...(signal ? [signal] : [])]);
|
|
332
441
|
const operation = (async () => {
|
|
442
|
+
let publishingOutcome = false;
|
|
443
|
+
const outcomeTask = {
|
|
444
|
+
id: task.id,
|
|
445
|
+
attemptId: task.attemptId,
|
|
446
|
+
botId: task.botId,
|
|
447
|
+
deviceId: config.deviceId,
|
|
448
|
+
roomId: task.roomId,
|
|
449
|
+
leaseToken: task.leaseToken,
|
|
450
|
+
leaseGeneration: task.leaseGeneration ?? 1,
|
|
451
|
+
contractDigest: contract?.digest,
|
|
452
|
+
manifestDigest: contextManifest?.digest,
|
|
453
|
+
};
|
|
333
454
|
let lease;
|
|
455
|
+
let workspaceHandle;
|
|
456
|
+
let workspaceCapability;
|
|
457
|
+
let workspaceBinding;
|
|
458
|
+
let executionCwd = root;
|
|
459
|
+
let executionCompleted = false;
|
|
460
|
+
let artifactProduced = false;
|
|
461
|
+
let capturedArtifact;
|
|
334
462
|
let stopping;
|
|
335
463
|
const stop = () => {
|
|
336
464
|
if (!stopping)
|
|
@@ -358,12 +486,61 @@ export function createDeviceRuntime(options) {
|
|
|
358
486
|
lease = await acquire(task.botId, taskSignal);
|
|
359
487
|
if (task.botRevision !== lease.bot.revision || executionRoot(lease.root) !== root)
|
|
360
488
|
throw new Error("Task Bot revision or workspace mismatch");
|
|
489
|
+
const policy = contextManifest?.executionPolicy;
|
|
490
|
+
if (policy &&
|
|
491
|
+
(policy.deviceId !== config.deviceId ||
|
|
492
|
+
policy.botId !== lease.bot.id ||
|
|
493
|
+
policy.botRevision !== lease.bot.revision))
|
|
494
|
+
throw new Error("Context manifest execution policy mismatch with acquired lease");
|
|
361
495
|
}
|
|
362
496
|
catch (error) {
|
|
363
497
|
if (taskSignal.aborted)
|
|
364
498
|
throw error;
|
|
365
499
|
throw new DeviceTaskError("目标 Bot 不可用、配置已变更或正在忙碌。 / Target Bot unavailable or busy.");
|
|
366
500
|
}
|
|
501
|
+
executionCwd = lease.root;
|
|
502
|
+
if (isCode) {
|
|
503
|
+
if (contract?.baseline) {
|
|
504
|
+
const canonicalRepoId = await computeCanonicalRepositoryId(lease.root, taskSignal);
|
|
505
|
+
const expectedRepoId = contract.baseline.repositoryId.trim();
|
|
506
|
+
if (expectedRepoId !== canonicalRepoId && expectedRepoId !== "default" && expectedRepoId !== "local") {
|
|
507
|
+
let matchesRoot = false;
|
|
508
|
+
try {
|
|
509
|
+
const roots = (await git(lease.root, ["rev-list", "--max-parents=0", "HEAD"], taskSignal))
|
|
510
|
+
.trim()
|
|
511
|
+
.split("\n")
|
|
512
|
+
.map((c) => c.trim().toLowerCase());
|
|
513
|
+
matchesRoot = roots.includes(expectedRepoId.toLowerCase());
|
|
514
|
+
}
|
|
515
|
+
catch { }
|
|
516
|
+
if (!matchesRoot) {
|
|
517
|
+
throw new DeviceTaskError(`Repository identity mismatch: baseline specifies '${expectedRepoId}', local repository is '${canonicalRepoId}'`);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
workspaceBinding = {
|
|
522
|
+
deviceId: config.deviceId,
|
|
523
|
+
botId: task.botId,
|
|
524
|
+
botRevision: lease.bot.revision,
|
|
525
|
+
taskId: task.id,
|
|
526
|
+
attemptId: task.attemptId,
|
|
527
|
+
};
|
|
528
|
+
workspaceHandle = await prepareTaskWorkspace({
|
|
529
|
+
dataDir: options.dataDir ?? process.cwd(),
|
|
530
|
+
deviceId: config.deviceId,
|
|
531
|
+
botId: task.botId,
|
|
532
|
+
botRevision: lease.bot.revision,
|
|
533
|
+
taskId: task.id,
|
|
534
|
+
attemptId: task.attemptId,
|
|
535
|
+
repoRoot: lease.root,
|
|
536
|
+
contract: contract,
|
|
537
|
+
contextManifest: contextManifest,
|
|
538
|
+
signal: taskSignal,
|
|
539
|
+
});
|
|
540
|
+
workspaceCapability = getTaskWorkspaceCapability(workspaceHandle, workspaceBinding);
|
|
541
|
+
const resolved = await resolveTrustedTaskWorkspace(workspaceCapability, workspaceBinding);
|
|
542
|
+
executionCwd = resolved.cwd;
|
|
543
|
+
}
|
|
367
544
|
let binding;
|
|
368
545
|
let resumePath;
|
|
369
546
|
let transcriptPath;
|
|
@@ -372,7 +549,7 @@ export function createDeviceRuntime(options) {
|
|
|
372
549
|
throw new DeviceTaskError("Invalid resume flag");
|
|
373
550
|
if (task.resume && !task.conversationId)
|
|
374
551
|
throw new DeviceTaskError("Resume conversation address required");
|
|
375
|
-
if (task.conversationId !== undefined) {
|
|
552
|
+
if (!isCode && task.conversationId !== undefined) {
|
|
376
553
|
if (!UUID.test(task.conversationId) || !transcriptFile || transcriptLoadError)
|
|
377
554
|
throw new DeviceTaskError("Persistent conversation storage unavailable or invalid address");
|
|
378
555
|
binding = createHash("sha256")
|
|
@@ -419,7 +596,6 @@ export function createDeviceRuntime(options) {
|
|
|
419
596
|
recovery.recordActivity(taskId, attemptId);
|
|
420
597
|
if (taskId !== task.id || attemptId !== task.attemptId)
|
|
421
598
|
throw new Error("Report task binding mismatch");
|
|
422
|
-
// Persist the original before notifying transport or settling the task.
|
|
423
599
|
reportOutbox.capture(task, fullReport);
|
|
424
600
|
return callbacks?.onFullReport?.(taskId, attemptId, fullReport);
|
|
425
601
|
},
|
|
@@ -440,6 +616,10 @@ export function createDeviceRuntime(options) {
|
|
|
440
616
|
localOrigin: options.localOrigin,
|
|
441
617
|
localAuthToken: options.localAuthToken,
|
|
442
618
|
cwd: lease.root,
|
|
619
|
+
executionCwd,
|
|
620
|
+
executionMode: isCode ? "code" : "chat",
|
|
621
|
+
workspaceHandleId: workspaceHandle?.handleId,
|
|
622
|
+
workspaceCapability,
|
|
443
623
|
bot: lease.bot,
|
|
444
624
|
allowExecution: config.allowExecution,
|
|
445
625
|
resumePath,
|
|
@@ -451,7 +631,7 @@ export function createDeviceRuntime(options) {
|
|
|
451
631
|
!isAbsolute(path) ||
|
|
452
632
|
(resumePath && !samePath(path, resumePath)))
|
|
453
633
|
throw new Error("Transcript ownership mismatch");
|
|
454
|
-
if (task.conversationId) {
|
|
634
|
+
if (!isCode && task.conversationId) {
|
|
455
635
|
const currentBot = bots.get(task.botId);
|
|
456
636
|
if (!binding ||
|
|
457
637
|
!currentBot?.enabled ||
|
|
@@ -459,9 +639,6 @@ export function createDeviceRuntime(options) {
|
|
|
459
639
|
resolve(currentBot.cwd) !== resolve(lease.root))
|
|
460
640
|
throw new DeviceTaskError("Conversation transcript ownership changed");
|
|
461
641
|
try {
|
|
462
|
-
// Fresh SDK sessions allocate a path before the first message creates
|
|
463
|
-
// the file. Bind it now so failed first turns remain recoverable.
|
|
464
|
-
// Existing resume paths must still refer to a real transcript.
|
|
465
642
|
if (resumePath && !statSync(path).isFile())
|
|
466
643
|
throw new Error();
|
|
467
644
|
const next = { ...transcripts, [task.conversationId]: { binding, path } };
|
|
@@ -484,9 +661,9 @@ export function createDeviceRuntime(options) {
|
|
|
484
661
|
if (sessionId && !taskSignal.aborted)
|
|
485
662
|
sessions.set(sessionId, {
|
|
486
663
|
taskId,
|
|
487
|
-
...(
|
|
664
|
+
...(effectiveTaskState ? { taskState: structuredClone(effectiveTaskState) } : {}),
|
|
488
665
|
roomId: task.roomId,
|
|
489
|
-
root:
|
|
666
|
+
root: executionCwd,
|
|
490
667
|
botId: task.botId,
|
|
491
668
|
conversationId: task.conversationId,
|
|
492
669
|
sourceConversationId: task.sourceConversationId,
|
|
@@ -497,10 +674,32 @@ export function createDeviceRuntime(options) {
|
|
|
497
674
|
});
|
|
498
675
|
taskSignal.addEventListener("abort", stop, { once: true });
|
|
499
676
|
taskSignal.throwIfAborted();
|
|
500
|
-
const result = await owner.executor.run(
|
|
677
|
+
const result = await owner.executor.run({
|
|
678
|
+
...task,
|
|
679
|
+
context: effectiveContext,
|
|
680
|
+
taskState: effectiveTaskState,
|
|
681
|
+
executionMode: isCode ? "code" : "chat",
|
|
682
|
+
contract,
|
|
683
|
+
contextManifest,
|
|
684
|
+
workspaceHandleId: workspaceHandle?.handleId,
|
|
685
|
+
executionCwd,
|
|
686
|
+
});
|
|
501
687
|
await confirmStop();
|
|
502
688
|
taskSignal.throwIfAborted();
|
|
503
|
-
|
|
689
|
+
executionCompleted = true;
|
|
690
|
+
if (isCode && workspaceHandle && workspaceBinding) {
|
|
691
|
+
try {
|
|
692
|
+
capturedArtifact = await captureTaskArtifact(workspaceHandle, workspaceBinding, taskSignal);
|
|
693
|
+
artifactProduced = true;
|
|
694
|
+
}
|
|
695
|
+
catch (captureErr) {
|
|
696
|
+
const msg = captureErr instanceof Error
|
|
697
|
+
? `Task artifact capture failed: ${captureErr.message}`
|
|
698
|
+
: "Task artifact capture failed";
|
|
699
|
+
throw new DeviceTaskError(msg, msg);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
if (!isCode && task.conversationId) {
|
|
504
703
|
const currentBot = bots.get(task.botId);
|
|
505
704
|
if (!transcriptPath ||
|
|
506
705
|
!binding ||
|
|
@@ -516,39 +715,40 @@ export function createDeviceRuntime(options) {
|
|
|
516
715
|
throw new DeviceTaskError("Conversation transcript unavailable after execution");
|
|
517
716
|
}
|
|
518
717
|
}
|
|
519
|
-
|
|
520
|
-
recovery.recordTaskFinish({
|
|
521
|
-
id: task.id,
|
|
522
|
-
attemptId: task.attemptId,
|
|
523
|
-
botId: task.botId,
|
|
524
|
-
deviceId: config.deviceId,
|
|
525
|
-
roomId: task.roomId,
|
|
526
|
-
}, {
|
|
718
|
+
publishingOutcome = true;
|
|
719
|
+
recovery.recordTaskFinish(outcomeTask, {
|
|
527
720
|
status: "completed",
|
|
528
721
|
report: result,
|
|
529
722
|
reportMetadata: reportUploadMetadata(reportOutbox.get(task) ?? reportOutbox.markMissing(task)),
|
|
723
|
+
artifact: capturedArtifact,
|
|
724
|
+
executionCompleted,
|
|
725
|
+
artifactProduced,
|
|
530
726
|
});
|
|
531
727
|
return result;
|
|
532
728
|
}
|
|
533
729
|
catch (error) {
|
|
534
|
-
|
|
535
|
-
error
|
|
536
|
-
|
|
730
|
+
if (publishingOutcome)
|
|
731
|
+
throw error;
|
|
732
|
+
let failure = error;
|
|
537
733
|
try {
|
|
538
|
-
|
|
539
|
-
id: task.id,
|
|
540
|
-
attemptId: task.attemptId,
|
|
541
|
-
botId: task.botId,
|
|
542
|
-
deviceId: config.deviceId,
|
|
543
|
-
roomId: task.roomId,
|
|
544
|
-
}, {
|
|
545
|
-
status: isUnconfirmed ? "interrupted" : "failed",
|
|
546
|
-
error,
|
|
547
|
-
reportMetadata: reportUploadMetadata(reportOutbox.get(task) ?? reportOutbox.markMissing(task)),
|
|
548
|
-
});
|
|
734
|
+
await confirmStop();
|
|
549
735
|
}
|
|
550
|
-
catch {
|
|
551
|
-
|
|
736
|
+
catch (stopError) {
|
|
737
|
+
failure = stopError;
|
|
738
|
+
}
|
|
739
|
+
if (owner.blocked || failure instanceof DeviceTaskStopUnconfirmedError) {
|
|
740
|
+
throw failure;
|
|
741
|
+
}
|
|
742
|
+
const interrupted = taskSignal.aborted;
|
|
743
|
+
recovery.recordTaskFinish(outcomeTask, {
|
|
744
|
+
status: interrupted ? "interrupted" : "failed",
|
|
745
|
+
error: failure,
|
|
746
|
+
reportMetadata: reportUploadMetadata(reportOutbox.get(task) ?? reportOutbox.markMissing(task)),
|
|
747
|
+
artifact: capturedArtifact,
|
|
748
|
+
executionCompleted,
|
|
749
|
+
artifactProduced,
|
|
750
|
+
});
|
|
751
|
+
throw failure;
|
|
552
752
|
}
|
|
553
753
|
finally {
|
|
554
754
|
taskSignal.removeEventListener("abort", stop);
|
|
@@ -561,6 +761,12 @@ export function createDeviceRuntime(options) {
|
|
|
561
761
|
for (const [id, bound] of sessions)
|
|
562
762
|
if (bound.taskId === task.id && bound.roomId === task.roomId)
|
|
563
763
|
sessions.delete(id);
|
|
764
|
+
if (stoppedCleanly && !owner.blocked && workspaceHandle && workspaceBinding) {
|
|
765
|
+
try {
|
|
766
|
+
await cleanupTaskWorkspace(workspaceHandle, workspaceBinding, { force: false });
|
|
767
|
+
}
|
|
768
|
+
catch { }
|
|
769
|
+
}
|
|
564
770
|
if (!owner.blocked && stoppedCleanly) {
|
|
565
771
|
lease?.release();
|
|
566
772
|
if (activeItem)
|
|
@@ -572,8 +778,88 @@ export function createDeviceRuntime(options) {
|
|
|
572
778
|
owner.done = operation;
|
|
573
779
|
return track(operation);
|
|
574
780
|
}
|
|
781
|
+
async function originalPublicationCommand(command, historical) {
|
|
782
|
+
const intent = validatePublishIntent(command.publishIntent);
|
|
783
|
+
assertPublishIntentScope(intent, {
|
|
784
|
+
accountId: config.accountId ?? intent.accountId,
|
|
785
|
+
targetDeviceId: config.deviceId,
|
|
786
|
+
});
|
|
787
|
+
if (command.accountId !== intent.accountId ||
|
|
788
|
+
command.roomId !== intent.roomId ||
|
|
789
|
+
command.conversationId !== intent.conversationId ||
|
|
790
|
+
command.integrationId !== intent.integrationId ||
|
|
791
|
+
command.targetBotId !== intent.targetBotId ||
|
|
792
|
+
command.targetBotRevision !== intent.targetBotRevision)
|
|
793
|
+
throw new Error("Publication command original scope mismatch");
|
|
794
|
+
const original = await readPublicationJournal(options.dataDir ?? process.cwd(), intent);
|
|
795
|
+
if (!config.accountId) {
|
|
796
|
+
if (!historical || !original)
|
|
797
|
+
throw new Error("Authenticated publication account context required");
|
|
798
|
+
}
|
|
799
|
+
return intent;
|
|
800
|
+
}
|
|
801
|
+
async function ownerCleanup(command, signal) {
|
|
802
|
+
if (!options.dataDir || typeof command.integrationId !== "string")
|
|
803
|
+
throw new Error("Original integration session required for owner cleanup");
|
|
804
|
+
const session = (await loadPersistentSessions(options.dataDir)).get(command.integrationId);
|
|
805
|
+
if (!session ||
|
|
806
|
+
session.targetBotId !== command.targetBotId ||
|
|
807
|
+
session.targetBotRevision !== command.targetBotRevision)
|
|
808
|
+
throw new Error("Original integration cleanup identity mismatch");
|
|
809
|
+
await assertPublicationWorkspaceIdle(session.targetBotId, session.repoRoot);
|
|
810
|
+
const identity = { botId: session.targetBotId, root: executionRoot(session.repoRoot) };
|
|
811
|
+
const existing = [...active].find((owner) => owner.taskId === `integration:${session.integrationId}` && owner.botId === session.targetBotId);
|
|
812
|
+
if ([...active].some((owner) => conflicts(owner, identity) && owner !== existing))
|
|
813
|
+
throw new Error("Target Bot or workspace is busy");
|
|
814
|
+
let owner;
|
|
815
|
+
let item;
|
|
816
|
+
if (!existing) {
|
|
817
|
+
owner = {
|
|
818
|
+
...identity,
|
|
819
|
+
controller: new AbortController(),
|
|
820
|
+
taskId: `integration:${session.integrationId}`,
|
|
821
|
+
attemptId: randomUUID(),
|
|
822
|
+
};
|
|
823
|
+
item = scheduler.registerActive({
|
|
824
|
+
id: owner.taskId,
|
|
825
|
+
attemptId: owner.attemptId,
|
|
826
|
+
roomId: "integration",
|
|
827
|
+
botId: owner.botId,
|
|
828
|
+
botRevision: String(session.targetBotRevision),
|
|
829
|
+
root: owner.root,
|
|
830
|
+
}, owner.controller);
|
|
831
|
+
active.add(owner);
|
|
832
|
+
}
|
|
833
|
+
try {
|
|
834
|
+
return await deviceCancelIntegration({
|
|
835
|
+
integrationId: session.integrationId,
|
|
836
|
+
targetBotId: session.targetBotId,
|
|
837
|
+
targetBotRevision: session.targetBotRevision,
|
|
838
|
+
repoRoot: session.repoRoot,
|
|
839
|
+
dataDir: options.dataDir,
|
|
840
|
+
priorStatus: command.priorStatus,
|
|
841
|
+
verificationMayBeRunning: command.verificationMayBeRunning === true,
|
|
842
|
+
}, { signal });
|
|
843
|
+
}
|
|
844
|
+
catch (error) {
|
|
845
|
+
if (error instanceof VerificationStopUnconfirmedError && owner) {
|
|
846
|
+
owner.blocked = error;
|
|
847
|
+
scheduler.markBlocked(owner.taskId, owner.attemptId, error);
|
|
848
|
+
}
|
|
849
|
+
throw error;
|
|
850
|
+
}
|
|
851
|
+
finally {
|
|
852
|
+
if (owner && !owner.blocked) {
|
|
853
|
+
if (item)
|
|
854
|
+
scheduler.releaseActive(item);
|
|
855
|
+
active.delete(owner);
|
|
856
|
+
drain();
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
575
860
|
function onCommand(action, payload, signal) {
|
|
576
|
-
const
|
|
861
|
+
const integrationController = new AbortController();
|
|
862
|
+
const commandSignal = AbortSignal.any([signal, generation.signal, integrationController.signal]);
|
|
577
863
|
if (action === "transfer_fence") {
|
|
578
864
|
return track((async () => {
|
|
579
865
|
enabled(commandSignal);
|
|
@@ -582,20 +868,62 @@ export function createDeviceRuntime(options) {
|
|
|
582
868
|
})());
|
|
583
869
|
}
|
|
584
870
|
const operation = (async () => {
|
|
585
|
-
enabled(commandSignal);
|
|
586
871
|
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
587
872
|
throw new Error("Invalid transfer command");
|
|
588
873
|
const command = payload;
|
|
874
|
+
if (action === "integration_publication_status" || (action === "integration_cancel" && command.publishIntent)) {
|
|
875
|
+
const intent = await originalPublicationCommand(command, true);
|
|
876
|
+
const historical = { dataDir: options.dataDir ?? process.cwd(), publishIntent: intent };
|
|
877
|
+
return action === "integration_publication_status"
|
|
878
|
+
? devicePublicationStatus(historical)
|
|
879
|
+
: deviceCancelPublication(historical);
|
|
880
|
+
}
|
|
881
|
+
enabled(commandSignal);
|
|
882
|
+
if (action === "integration_confirm")
|
|
883
|
+
await originalPublicationCommand(command, false);
|
|
589
884
|
if (typeof command.roomId !== "string" && !action.startsWith("integration_"))
|
|
590
885
|
throw new Error("Room required");
|
|
591
886
|
if (typeof command.targetBotId !== "string" || !command.targetBotId)
|
|
592
887
|
throw new Error("Target Bot required");
|
|
593
|
-
|
|
888
|
+
if (action === "integration_cancel" && command.ownerCleanup === true)
|
|
889
|
+
return ownerCleanup(command, commandSignal);
|
|
890
|
+
const lease = await acquire(command.targetBotId, commandSignal, action === "integration_cancel" ? String(command.integrationId) : undefined);
|
|
891
|
+
let integrationOwner;
|
|
892
|
+
let integrationItem;
|
|
594
893
|
try {
|
|
595
894
|
if (!action.startsWith("integration_")
|
|
596
895
|
? command.targetBotRevision !== lease.bot.revision
|
|
597
896
|
: command.targetBotRevision !== undefined && command.targetBotRevision !== lease.bot.revision)
|
|
598
897
|
throw new Error("Transfer Bot revision mismatch");
|
|
898
|
+
if (action.startsWith("integration_")) {
|
|
899
|
+
const repo = await verifyRepoRoot(lease.root, commandSignal);
|
|
900
|
+
if (repo.repoRoot !== (await canonicalPath(lease.root)))
|
|
901
|
+
throw new Error("Integration Bot workspace must be the canonical repository root");
|
|
902
|
+
}
|
|
903
|
+
if (action === "integration_cancel" &&
|
|
904
|
+
[...active].some((owner) => conflicts(owner, { botId: lease.bot.id, root: executionRoot(lease.root) }) &&
|
|
905
|
+
owner.taskId !== `integration:${String(command.integrationId)}`))
|
|
906
|
+
throw new Error("Target Bot or workspace is busy");
|
|
907
|
+
if (action.startsWith("integration_") &&
|
|
908
|
+
!(action === "integration_cancel" &&
|
|
909
|
+
[...active].some((owner) => owner.taskId === `integration:${String(command.integrationId)}` && owner.botId === lease.bot.id))) {
|
|
910
|
+
integrationOwner = {
|
|
911
|
+
controller: integrationController,
|
|
912
|
+
botId: lease.bot.id,
|
|
913
|
+
root: executionRoot(lease.root),
|
|
914
|
+
taskId: `integration:${String(command.integrationId)}`,
|
|
915
|
+
attemptId: randomUUID(),
|
|
916
|
+
};
|
|
917
|
+
integrationItem = scheduler.registerActive({
|
|
918
|
+
id: integrationOwner.taskId,
|
|
919
|
+
attemptId: integrationOwner.attemptId,
|
|
920
|
+
roomId: typeof command.roomId === "string" ? command.roomId : "integration",
|
|
921
|
+
botId: lease.bot.id,
|
|
922
|
+
botRevision: String(lease.bot.revision),
|
|
923
|
+
root: integrationOwner.root,
|
|
924
|
+
}, integrationController);
|
|
925
|
+
active.add(integrationOwner);
|
|
926
|
+
}
|
|
599
927
|
if (action === "integration_prepare") {
|
|
600
928
|
return await devicePrepareIntegration({
|
|
601
929
|
integrationId: command.integrationId,
|
|
@@ -605,16 +933,28 @@ export function createDeviceRuntime(options) {
|
|
|
605
933
|
dataDir: options.dataDir ?? process.cwd(),
|
|
606
934
|
targetBranch: command.targetBranch,
|
|
607
935
|
commit: command.commit,
|
|
936
|
+
artifactRef: command.artifactRef,
|
|
937
|
+
artifact: command.artifact,
|
|
938
|
+
accountId: config.accountId,
|
|
939
|
+
roomId: command.roomId,
|
|
940
|
+
conversationId: command.conversationId,
|
|
941
|
+
targetDeviceId: config.deviceId,
|
|
608
942
|
}, { signal: commandSignal });
|
|
609
943
|
}
|
|
610
944
|
if (action === "integration_verify") {
|
|
945
|
+
if (!lease.bot.tools.includes("bash"))
|
|
946
|
+
throw new Error("Target Bot bash command permission required");
|
|
611
947
|
return await deviceVerifyIntegration({
|
|
612
948
|
integrationId: command.integrationId,
|
|
613
949
|
targetBotId: lease.bot.id,
|
|
614
950
|
targetBotRevision: lease.bot.revision,
|
|
615
951
|
repoRoot: lease.root,
|
|
616
952
|
dataDir: options.dataDir ?? process.cwd(),
|
|
617
|
-
|
|
953
|
+
verificationPlan: command.verificationPlan,
|
|
954
|
+
artifactRef: command.artifactRef,
|
|
955
|
+
materializedCommit: command.materializedCommit,
|
|
956
|
+
preparedTree: command.preparedTree,
|
|
957
|
+
expectedTargetSha: command.expectedTargetSha,
|
|
618
958
|
}, { signal: commandSignal });
|
|
619
959
|
}
|
|
620
960
|
if (action === "integration_confirm") {
|
|
@@ -626,7 +966,10 @@ export function createDeviceRuntime(options) {
|
|
|
626
966
|
dataDir: options.dataDir ?? process.cwd(),
|
|
627
967
|
deliveryId: command.deliveryId,
|
|
628
968
|
commit: command.commit,
|
|
969
|
+
materializedCommit: command.materializedCommit,
|
|
629
970
|
expectedTargetSha: command.expectedTargetSha,
|
|
971
|
+
publishIntent: validatePublishIntent(command.publishIntent),
|
|
972
|
+
mode: command.mode === "resume" ? "resume" : "first",
|
|
630
973
|
}, { signal: commandSignal });
|
|
631
974
|
}
|
|
632
975
|
if (action === "integration_cancel") {
|
|
@@ -636,6 +979,8 @@ export function createDeviceRuntime(options) {
|
|
|
636
979
|
targetBotRevision: lease.bot.revision,
|
|
637
980
|
repoRoot: lease.root,
|
|
638
981
|
dataDir: options.dataDir ?? process.cwd(),
|
|
982
|
+
priorStatus: command.priorStatus,
|
|
983
|
+
verificationMayBeRunning: command.verificationMayBeRunning === true,
|
|
639
984
|
}, { signal: commandSignal });
|
|
640
985
|
}
|
|
641
986
|
if (action === "transfer_fence") {
|
|
@@ -747,8 +1092,23 @@ export function createDeviceRuntime(options) {
|
|
|
747
1092
|
}
|
|
748
1093
|
throw new Error("Unsupported device command");
|
|
749
1094
|
}
|
|
1095
|
+
catch (error) {
|
|
1096
|
+
if ((error instanceof VerificationStopUnconfirmedError || error instanceof PublicationStopUnconfirmedError) &&
|
|
1097
|
+
integrationOwner) {
|
|
1098
|
+
integrationOwner.blocked = error;
|
|
1099
|
+
scheduler.markBlocked(integrationOwner.taskId, integrationOwner.attemptId, error);
|
|
1100
|
+
}
|
|
1101
|
+
throw error;
|
|
1102
|
+
}
|
|
750
1103
|
finally {
|
|
751
|
-
|
|
1104
|
+
if (!integrationOwner?.blocked) {
|
|
1105
|
+
lease.release();
|
|
1106
|
+
if (integrationItem)
|
|
1107
|
+
scheduler.releaseActive(integrationItem);
|
|
1108
|
+
if (integrationOwner)
|
|
1109
|
+
active.delete(integrationOwner);
|
|
1110
|
+
drain();
|
|
1111
|
+
}
|
|
752
1112
|
}
|
|
753
1113
|
})();
|
|
754
1114
|
if (action.startsWith("transfer_") && action !== "transfer_fence") {
|
|
@@ -788,6 +1148,13 @@ export function createDeviceRuntime(options) {
|
|
|
788
1148
|
cancelScheduledTask(taskId, attemptId) {
|
|
789
1149
|
return scheduler.cancelTask(taskId, attemptId);
|
|
790
1150
|
},
|
|
1151
|
+
async steerTask(taskId, text) {
|
|
1152
|
+
const owner = [...active].find((item) => item.taskId === taskId);
|
|
1153
|
+
if (!owner || owner.controller.signal.aborted || owner.blocked || !owner.executor?.steer) {
|
|
1154
|
+
return false;
|
|
1155
|
+
}
|
|
1156
|
+
return owner.executor.steer(text);
|
|
1157
|
+
},
|
|
791
1158
|
answerTaskInteraction(taskId, attemptId, answer) {
|
|
792
1159
|
const owner = [...active].find((item) => item.taskId === taskId && item.attemptId === attemptId);
|
|
793
1160
|
return !!owner && !owner.controller.signal.aborted && !owner.blocked && !!owner.answer?.(answer);
|