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
|
@@ -2,6 +2,7 @@ import http, {} from "node:http";
|
|
|
2
2
|
import { projectTaskActivity } from "./task-progress.js";
|
|
3
3
|
import https from "node:https";
|
|
4
4
|
import { WebSocket } from "ws";
|
|
5
|
+
import { createDeviceLanServer } from "./device-lan.js";
|
|
5
6
|
import { deviceTaskFailure } from "./task-error.js";
|
|
6
7
|
import { uploadTaskReport } from "./report-upload.js";
|
|
7
8
|
import { reportUploadMetadata } from "./report-metadata.js";
|
|
@@ -26,11 +27,31 @@ export function createDeviceConnector(options) {
|
|
|
26
27
|
const endpoint = new URL("/device-connect", hub);
|
|
27
28
|
endpoint.protocol = hub.protocol === "https:" || hub.protocol === "wss:" ? "wss:" : "ws:";
|
|
28
29
|
endpoint.searchParams.set("deviceId", options.deviceId);
|
|
30
|
+
const deviceLan = createDeviceLanServer({ localOrigin: local.origin, localAuthToken: options.localAuthToken });
|
|
29
31
|
let closed = false;
|
|
30
32
|
let tasksDisabled = false;
|
|
31
33
|
const waitingForHumanTaskIds = new Set();
|
|
32
34
|
const planAcks = new Map();
|
|
33
35
|
const runningTasks = new Map();
|
|
36
|
+
function sendOutboxEntry(ws, item) {
|
|
37
|
+
options.recovery?.markOutboxAttempt(item.id);
|
|
38
|
+
sendFrame(ws, {
|
|
39
|
+
type: "task_event",
|
|
40
|
+
taskId: item.taskId,
|
|
41
|
+
botId: item.botId,
|
|
42
|
+
attemptId: item.attemptId,
|
|
43
|
+
status: item.status,
|
|
44
|
+
report: item.report,
|
|
45
|
+
error: item.error,
|
|
46
|
+
reportMetadata: item.reportMetadata,
|
|
47
|
+
leaseToken: item.leaseToken,
|
|
48
|
+
leaseGeneration: item.leaseGeneration,
|
|
49
|
+
fingerprint: item.fingerprint,
|
|
50
|
+
artifact: item.artifact,
|
|
51
|
+
executionCompleted: item.executionCompleted,
|
|
52
|
+
artifactProduced: item.artifactProduced,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
34
55
|
function stopTasks(forceAll = false) {
|
|
35
56
|
for (const pending of planAcks.values())
|
|
36
57
|
pending.settle(false);
|
|
@@ -40,8 +61,6 @@ export function createDeviceConnector(options) {
|
|
|
40
61
|
task.controller.abort();
|
|
41
62
|
}
|
|
42
63
|
else {
|
|
43
|
-
// Passive network disconnect: ONLY retain tasks that have an active lease and recovery enabled!
|
|
44
|
-
// Tasks without leaseToken or without recovery cannot be claimed on reconnect; abort them.
|
|
45
64
|
for (const task of runningTasks.values()) {
|
|
46
65
|
if (!options.recovery || !task.leaseToken) {
|
|
47
66
|
task.controller.abort();
|
|
@@ -140,9 +159,25 @@ export function createDeviceConnector(options) {
|
|
|
140
159
|
handshakeTimeout: 10_000,
|
|
141
160
|
});
|
|
142
161
|
socket = ws;
|
|
143
|
-
const rpc = createCommandChannel(ws,
|
|
162
|
+
const rpc = createCommandChannel(ws, async (action, payload, signal) => {
|
|
163
|
+
if (action !== "device_lan") {
|
|
164
|
+
if (!options.onCommand)
|
|
165
|
+
throw new Error("Device command unavailable");
|
|
166
|
+
return options.onCommand(action, payload, signal);
|
|
167
|
+
}
|
|
168
|
+
if (signal.aborted)
|
|
169
|
+
throw new Error("Device access cancelled");
|
|
170
|
+
const grant = await deviceLan.issueGrant();
|
|
171
|
+
if (signal.aborted || closed || socket !== ws || ws.readyState !== WebSocket.OPEN) {
|
|
172
|
+
if (grant)
|
|
173
|
+
deviceLan.revoke(grant.identity);
|
|
174
|
+
throw new Error("Device connection changed");
|
|
175
|
+
}
|
|
176
|
+
return grant;
|
|
177
|
+
});
|
|
144
178
|
const messages = createWsMessageChannel(ws);
|
|
145
179
|
const cancellations = new Set();
|
|
180
|
+
const steerings = new Set();
|
|
146
181
|
ws.on("open", () => {
|
|
147
182
|
if (socket !== ws || closed) {
|
|
148
183
|
ws.terminate();
|
|
@@ -152,7 +187,6 @@ export function createDeviceConnector(options) {
|
|
|
152
187
|
tasksDisabled = false;
|
|
153
188
|
lastPong = Date.now();
|
|
154
189
|
retryReports();
|
|
155
|
-
// === Task Recovery / Reconnect Claim / Outbox Replay ===
|
|
156
190
|
const claimsToSend = new Map();
|
|
157
191
|
if (options.recovery) {
|
|
158
192
|
for (const claim of options.recovery.prepareClaims()) {
|
|
@@ -181,22 +215,9 @@ export function createDeviceConnector(options) {
|
|
|
181
215
|
});
|
|
182
216
|
}
|
|
183
217
|
if (options.recovery) {
|
|
184
|
-
for (const item of options.recovery.getPendingOutbox())
|
|
185
|
-
|
|
186
|
-
sendFrame(ws, {
|
|
187
|
-
type: "task_event",
|
|
188
|
-
taskId: item.taskId,
|
|
189
|
-
botId: item.botId,
|
|
190
|
-
attemptId: item.attemptId,
|
|
191
|
-
status: item.status,
|
|
192
|
-
...(item.report ? { report: item.report } : {}),
|
|
193
|
-
...(item.error ? { error: item.error } : {}),
|
|
194
|
-
...(item.reportMetadata ? { reportMetadata: item.reportMetadata } : {}),
|
|
195
|
-
...(item.fingerprint ? { fingerprint: item.fingerprint } : {}),
|
|
196
|
-
});
|
|
197
|
-
}
|
|
218
|
+
for (const item of options.recovery.getPendingOutbox())
|
|
219
|
+
sendOutboxEntry(ws, item);
|
|
198
220
|
}
|
|
199
|
-
// =======================================================
|
|
200
221
|
void Promise.resolve()
|
|
201
222
|
.then(() => options.onConnect?.())
|
|
202
223
|
.catch(() => ws.close(1011, "Bot sync failed"));
|
|
@@ -211,7 +232,6 @@ export function createDeviceConnector(options) {
|
|
|
211
232
|
const frame = parseFrame(Buffer.from(raw));
|
|
212
233
|
if (rpc.handle(frame))
|
|
213
234
|
return;
|
|
214
|
-
// === Task Recovery / Reconnect Results ===
|
|
215
235
|
if (frame.type === "task_claim_result") {
|
|
216
236
|
if (typeof frame.taskId === "string" && typeof frame.attemptId === "string" && frame.accepted === false) {
|
|
217
237
|
const task = runningTasks.get(frame.taskId);
|
|
@@ -242,13 +262,34 @@ export function createDeviceConnector(options) {
|
|
|
242
262
|
return;
|
|
243
263
|
}
|
|
244
264
|
if (frame.type === "task_result_ack") {
|
|
245
|
-
if (
|
|
265
|
+
if ([frame.fingerprint, frame.artifactDigest, frame.contractDigest, frame.manifestDigest].some((value) => value !== undefined && typeof value !== "string"))
|
|
266
|
+
return;
|
|
267
|
+
const pending = typeof frame.taskId === "string" && typeof frame.attemptId === "string"
|
|
268
|
+
? options.recovery?.getPendingOutboxEntry(frame.taskId, frame.attemptId)
|
|
269
|
+
: undefined;
|
|
270
|
+
if ((frame.contractDigest !== undefined && frame.contractDigest !== pending?.contractDigest) ||
|
|
271
|
+
(frame.manifestDigest !== undefined && frame.manifestDigest !== pending?.manifestDigest))
|
|
272
|
+
return;
|
|
273
|
+
if (frame.accepted === false &&
|
|
274
|
+
frame.permanent === true &&
|
|
275
|
+
typeof frame.taskId === "string" &&
|
|
276
|
+
typeof frame.attemptId === "string") {
|
|
277
|
+
options.recovery?.quarantineOutbox(frame.taskId, frame.attemptId, frame.fingerprint, frame.reasonCode, frame.status, frame.artifactDigest);
|
|
278
|
+
}
|
|
279
|
+
if (frame.accepted === true &&
|
|
280
|
+
typeof frame.taskId === "string" &&
|
|
281
|
+
typeof frame.attemptId === "string" &&
|
|
282
|
+
typeof frame.status === "string") {
|
|
246
283
|
const fp = typeof frame.fingerprint === "string" ? frame.fingerprint : undefined;
|
|
247
|
-
options.recovery?.ackOutbox(frame.taskId, frame.attemptId, fp
|
|
284
|
+
options.recovery?.ackOutbox(frame.taskId, frame.attemptId, fp, {
|
|
285
|
+
status: frame.status,
|
|
286
|
+
artifactDigest: typeof frame.artifactDigest === "string" ? frame.artifactDigest : undefined,
|
|
287
|
+
contractDigest: typeof frame.contractDigest === "string" ? frame.contractDigest : undefined,
|
|
288
|
+
manifestDigest: typeof frame.manifestDigest === "string" ? frame.manifestDigest : undefined,
|
|
289
|
+
});
|
|
248
290
|
}
|
|
249
291
|
return;
|
|
250
292
|
}
|
|
251
|
-
// =========================================
|
|
252
293
|
if (frame.type === "task_cancel") {
|
|
253
294
|
if (typeof frame.id !== "string" ||
|
|
254
295
|
!frame.id ||
|
|
@@ -277,6 +318,38 @@ export function createDeviceConnector(options) {
|
|
|
277
318
|
});
|
|
278
319
|
return;
|
|
279
320
|
}
|
|
321
|
+
if (frame.type === "task_steer") {
|
|
322
|
+
if (typeof frame.id !== "string" ||
|
|
323
|
+
!frame.id ||
|
|
324
|
+
frame.id.length > 128 ||
|
|
325
|
+
typeof frame.taskId !== "string" ||
|
|
326
|
+
typeof frame.attemptId !== "string" ||
|
|
327
|
+
typeof frame.text !== "string" ||
|
|
328
|
+
steerings.size >= RELAY_LIMITS.steerings ||
|
|
329
|
+
steerings.has(frame.id))
|
|
330
|
+
throw new Error("Invalid task steer");
|
|
331
|
+
const id = frame.id;
|
|
332
|
+
const taskId = frame.taskId;
|
|
333
|
+
const text = frame.text;
|
|
334
|
+
const task = runningTasks.get(taskId);
|
|
335
|
+
const matched = task?.ws === ws && task.attemptId === frame.attemptId;
|
|
336
|
+
steerings.add(id);
|
|
337
|
+
void Promise.resolve()
|
|
338
|
+
.then(() => (matched && options.onSteer ? options.onSteer(taskId, text) : false))
|
|
339
|
+
.catch(() => false)
|
|
340
|
+
.then((steered) => {
|
|
341
|
+
steerings.delete(id);
|
|
342
|
+
if (socket === ws && !closed)
|
|
343
|
+
sendFrame(ws, {
|
|
344
|
+
type: "task_steered",
|
|
345
|
+
id,
|
|
346
|
+
taskId,
|
|
347
|
+
attemptId: frame.attemptId,
|
|
348
|
+
steered: Boolean(steered),
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
280
353
|
if (frame.type === "task_interaction_answer") {
|
|
281
354
|
if (!validInteractionAnswer(frame.answer))
|
|
282
355
|
return;
|
|
@@ -354,27 +427,32 @@ export function createDeviceConnector(options) {
|
|
|
354
427
|
};
|
|
355
428
|
const emit = (status, report) => {
|
|
356
429
|
const activeWs = execution.ws;
|
|
357
|
-
if (activeWs
|
|
358
|
-
activeWs.readyState
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
taskId: task.id,
|
|
368
|
-
botId: task.botId,
|
|
369
|
-
attemptId: task.attemptId,
|
|
370
|
-
status,
|
|
371
|
-
...(report ? { report } : {}),
|
|
372
|
-
...(status !== "running"
|
|
373
|
-
? { reportMetadata: reportUploadMetadata(options.reportOutbox?.get(task)) }
|
|
374
|
-
: {}),
|
|
375
|
-
...(outboxItem?.fingerprint ? { fingerprint: outboxItem.fingerprint } : {}),
|
|
376
|
-
});
|
|
430
|
+
if (!activeWs ||
|
|
431
|
+
activeWs.readyState !== WebSocket.OPEN ||
|
|
432
|
+
closed ||
|
|
433
|
+
runningTasks.get(task.id) !== execution)
|
|
434
|
+
return;
|
|
435
|
+
if (status !== "running" && options.recovery) {
|
|
436
|
+
const item = options.recovery.getPendingOutboxEntry(task.id, task.attemptId);
|
|
437
|
+
if (item)
|
|
438
|
+
sendOutboxEntry(activeWs, item);
|
|
439
|
+
return;
|
|
377
440
|
}
|
|
441
|
+
if (controller.signal.aborted)
|
|
442
|
+
return;
|
|
443
|
+
sendFrame(activeWs, {
|
|
444
|
+
type: "task_event",
|
|
445
|
+
taskId: task.id,
|
|
446
|
+
botId: task.botId,
|
|
447
|
+
attemptId: task.attemptId,
|
|
448
|
+
leaseToken: task.leaseToken,
|
|
449
|
+
leaseGeneration: task.leaseGeneration,
|
|
450
|
+
status,
|
|
451
|
+
...(report ? { report } : {}),
|
|
452
|
+
...(status !== "running"
|
|
453
|
+
? { reportMetadata: reportUploadMetadata(options.reportOutbox?.get(task)) }
|
|
454
|
+
: {}),
|
|
455
|
+
});
|
|
378
456
|
};
|
|
379
457
|
emit("running");
|
|
380
458
|
execution.settled = Promise.resolve()
|
|
@@ -467,8 +545,11 @@ export function createDeviceConnector(options) {
|
|
|
467
545
|
});
|
|
468
546
|
})
|
|
469
547
|
.then(async (result) => {
|
|
470
|
-
if (
|
|
548
|
+
if (options.recovery) {
|
|
549
|
+
emit("completed");
|
|
550
|
+
retryReports();
|
|
471
551
|
return;
|
|
552
|
+
}
|
|
472
553
|
const safeReport = typeof result === "string" ? result : undefined;
|
|
473
554
|
const reportEntry = options.reportOutbox?.get(task) ?? options.reportOutbox?.markMissing(task);
|
|
474
555
|
if (reportEntry)
|
|
@@ -530,7 +611,6 @@ export function createDeviceConnector(options) {
|
|
|
530
611
|
void (async () => {
|
|
531
612
|
let bytes = 0;
|
|
532
613
|
try {
|
|
533
|
-
// Pull only as fast as the relay socket drains, instead of aborting bursts.
|
|
534
614
|
for await (const data of res) {
|
|
535
615
|
const chunk = Buffer.from(data);
|
|
536
616
|
bytes += chunk.length;
|
|
@@ -636,7 +716,8 @@ export function createDeviceConnector(options) {
|
|
|
636
716
|
if (socket !== ws)
|
|
637
717
|
return;
|
|
638
718
|
socket = undefined;
|
|
639
|
-
|
|
719
|
+
deviceLan.close();
|
|
720
|
+
stopTasks(false);
|
|
640
721
|
for (const id of streams.keys())
|
|
641
722
|
dispose(id);
|
|
642
723
|
if (!closed) {
|
|
@@ -653,7 +734,6 @@ export function createDeviceConnector(options) {
|
|
|
653
734
|
else
|
|
654
735
|
socket.ping();
|
|
655
736
|
retryReports();
|
|
656
|
-
// === Heartbeat Lease Renewal ===
|
|
657
737
|
if (options.recovery) {
|
|
658
738
|
const renews = options.recovery.prepareLeaseRenews({ waitingForHumanTaskIds });
|
|
659
739
|
for (const renew of renews) {
|
|
@@ -666,7 +746,6 @@ export function createDeviceConnector(options) {
|
|
|
666
746
|
}
|
|
667
747
|
}
|
|
668
748
|
}
|
|
669
|
-
// ===============================
|
|
670
749
|
}
|
|
671
750
|
}, 15_000);
|
|
672
751
|
heartbeat.unref();
|
|
@@ -675,6 +754,7 @@ export function createDeviceConnector(options) {
|
|
|
675
754
|
isOnline: () => socket?.readyState === WebSocket.OPEN,
|
|
676
755
|
close() {
|
|
677
756
|
closed = true;
|
|
757
|
+
deviceLan.close();
|
|
678
758
|
reportAbort.abort();
|
|
679
759
|
stopTasks(true);
|
|
680
760
|
clearInterval(heartbeat);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { artifactRefsMatch } from "./delivery-subject.js";
|
|
2
|
+
import { validateCodeArtifactOutcome, validateContextManifest, validateWorkContract } from "./work-contract.js";
|
|
3
|
+
function conflict(message) {
|
|
4
|
+
throw Object.assign(new Error(message), { status: 409 });
|
|
5
|
+
}
|
|
6
|
+
export function assertLatestContract(state, task) {
|
|
7
|
+
const contract = task.contract;
|
|
8
|
+
if (!contract)
|
|
9
|
+
conflict("Artifact contract missing");
|
|
10
|
+
for (const other of state.tasks) {
|
|
11
|
+
if (other.accountId !== task.accountId || other.roomId !== task.roomId || other.contract?.id !== contract.id)
|
|
12
|
+
continue;
|
|
13
|
+
if (other.contract.revision > contract.revision ||
|
|
14
|
+
(other.contract.revision === contract.revision && other.contract.digest !== contract.digest))
|
|
15
|
+
conflict("Artifact contract version is no longer authoritative");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function deriveArtifactSubject(state, task, options) {
|
|
19
|
+
if (task.status !== "completed" ||
|
|
20
|
+
task.cancelRequested ||
|
|
21
|
+
task.executionCompleted !== true ||
|
|
22
|
+
task.artifactProduced !== true ||
|
|
23
|
+
!task.contract ||
|
|
24
|
+
!task.contextManifest ||
|
|
25
|
+
!task.artifact ||
|
|
26
|
+
task.contract.executionMode !== "code")
|
|
27
|
+
conflict("Completed code artifact required");
|
|
28
|
+
const contract = validateWorkContract(task.contract);
|
|
29
|
+
const manifest = validateContextManifest(task.contextManifest, task.contract);
|
|
30
|
+
const artifact = validateCodeArtifactOutcome({
|
|
31
|
+
task,
|
|
32
|
+
artifact: task.artifact,
|
|
33
|
+
executionCompleted: task.executionCompleted,
|
|
34
|
+
artifactProduced: task.artifactProduced,
|
|
35
|
+
});
|
|
36
|
+
if (!contract.valid ||
|
|
37
|
+
!manifest.valid ||
|
|
38
|
+
!artifact.valid ||
|
|
39
|
+
!artifact.artifact ||
|
|
40
|
+
!task.artifact.baseline ||
|
|
41
|
+
!task.artifact.inputTree ||
|
|
42
|
+
!task.artifact.outputTree ||
|
|
43
|
+
task.artifact.producer.contractDigest !== task.contract.digest ||
|
|
44
|
+
task.artifact.producer.manifestDigest !== task.contextManifest.digest ||
|
|
45
|
+
task.contextManifest.executionPolicy?.botRevision !== task.botRevision ||
|
|
46
|
+
task.contextManifest.executionPolicy?.botId !== task.botId ||
|
|
47
|
+
task.contextManifest.executionPolicy?.deviceId !== task.deviceId)
|
|
48
|
+
conflict("Invalid sealed artifact evidence");
|
|
49
|
+
if (!options?.allowSuperseded)
|
|
50
|
+
assertLatestContract(state, task);
|
|
51
|
+
return {
|
|
52
|
+
artifactTaskId: task.id,
|
|
53
|
+
attemptId: task.attemptId,
|
|
54
|
+
artifactId: task.artifact.id,
|
|
55
|
+
artifactDigest: task.artifact.digest,
|
|
56
|
+
contractId: task.contract.id,
|
|
57
|
+
contractRevision: task.contract.revision,
|
|
58
|
+
contractDigest: task.contract.digest,
|
|
59
|
+
manifestDigest: task.contextManifest.digest,
|
|
60
|
+
baselineCommit: task.artifact.baseline.commit,
|
|
61
|
+
repositoryId: task.artifact.baseline.repositoryId,
|
|
62
|
+
inputTree: task.artifact.inputTree,
|
|
63
|
+
outputTree: task.artifact.outputTree,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function assertDeliveryAuthority(state, delivery) {
|
|
67
|
+
if (!delivery.artifactRef)
|
|
68
|
+
return undefined;
|
|
69
|
+
const task = state.tasks.find((t) => t.id === delivery.artifactRef.artifactTaskId &&
|
|
70
|
+
t.accountId === delivery.accountId &&
|
|
71
|
+
t.roomId === delivery.roomId &&
|
|
72
|
+
t.conversationId === delivery.conversationId &&
|
|
73
|
+
t.botId === delivery.botId);
|
|
74
|
+
if (!task || !artifactRefsMatch(delivery.artifactRef, deriveArtifactSubject(state, task)))
|
|
75
|
+
conflict("Delivery artifact subject changed");
|
|
76
|
+
return task;
|
|
77
|
+
}
|
|
78
|
+
export function isLegacyPublicationUnknown(integration) {
|
|
79
|
+
return (!integration.publishIntent &&
|
|
80
|
+
(integration.status === "applying" || !!integration.error?.startsWith("Apply failed; check target outcome:")));
|
|
81
|
+
}
|
|
82
|
+
export function hasOpenPublication(integration) {
|
|
83
|
+
return (!!integration.publishIntent &&
|
|
84
|
+
((!!integration.publishStop && !integration.publishStop.stopConfirmed) ||
|
|
85
|
+
(!integration.publishReceipt && !(integration.publishStop?.closed && integration.publishStop.stopConfirmed))));
|
|
86
|
+
}
|
|
87
|
+
export function assertNoApplyingIntegration(state, accountId, roomId, conversationId, contractId) {
|
|
88
|
+
if (state.integrations.some((i) => i.accountId === accountId &&
|
|
89
|
+
i.roomId === roomId &&
|
|
90
|
+
(hasOpenPublication(i) || isLegacyPublicationUnknown(i)) &&
|
|
91
|
+
((!conversationId && !contractId) ||
|
|
92
|
+
(conversationId && i.conversationId === conversationId) ||
|
|
93
|
+
(contractId && i.artifactRef?.contractId === contractId))))
|
|
94
|
+
conflict("Integration apply freezes delivery, review and contract evidence");
|
|
95
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function artifactRefsMatch(a, b) {
|
|
2
|
+
return (!!a &&
|
|
3
|
+
!!b &&
|
|
4
|
+
a.artifactTaskId === b.artifactTaskId &&
|
|
5
|
+
a.attemptId === b.attemptId &&
|
|
6
|
+
a.artifactId === b.artifactId &&
|
|
7
|
+
a.artifactDigest === b.artifactDigest &&
|
|
8
|
+
a.contractId === b.contractId &&
|
|
9
|
+
a.contractRevision === b.contractRevision &&
|
|
10
|
+
a.contractDigest === b.contractDigest &&
|
|
11
|
+
a.manifestDigest === b.manifestDigest &&
|
|
12
|
+
a.baselineCommit === b.baselineCommit &&
|
|
13
|
+
a.repositoryId === b.repositoryId &&
|
|
14
|
+
a.inputTree === b.inputTree &&
|
|
15
|
+
a.outputTree === b.outputTree);
|
|
16
|
+
}
|
|
17
|
+
export function deliveryReviewMatches(delivery, review) {
|
|
18
|
+
if (!delivery ||
|
|
19
|
+
!review ||
|
|
20
|
+
delivery.id !== review.deliveryId ||
|
|
21
|
+
delivery.accountId !== review.accountId ||
|
|
22
|
+
delivery.roomId !== review.roomId ||
|
|
23
|
+
delivery.conversationId !== review.conversationId)
|
|
24
|
+
return false;
|
|
25
|
+
if (delivery.artifactRef)
|
|
26
|
+
return (review.artifactDigest === delivery.artifactRef.artifactDigest &&
|
|
27
|
+
artifactRefsMatch(delivery.artifactRef, review.artifactRef));
|
|
28
|
+
return !review.artifactRef && !review.artifactDigest && !!delivery.commit && delivery.commit === review.commit;
|
|
29
|
+
}
|
|
@@ -14,9 +14,7 @@ function executable(name) {
|
|
|
14
14
|
if (statSync(candidate).isFile())
|
|
15
15
|
return candidate;
|
|
16
16
|
}
|
|
17
|
-
catch {
|
|
18
|
-
/* Missing or inaccessible PATH entry. */
|
|
19
|
-
}
|
|
17
|
+
catch { }
|
|
20
18
|
}
|
|
21
19
|
return undefined;
|
|
22
20
|
}
|
|
@@ -24,7 +22,6 @@ export function linuxDesktopStatus() {
|
|
|
24
22
|
const unsupported = (reason) => ({ supported: false, backend: "x11", reason });
|
|
25
23
|
if (process.platform !== "linux")
|
|
26
24
|
return unsupported("Linux X11 desktop capture requires Linux.");
|
|
27
|
-
// XWayland only captures X11 windows, not the full Wayland desktop.
|
|
28
25
|
if (process.env.XDG_SESSION_TYPE?.toLowerCase() === "wayland" || process.env.WAYLAND_DISPLAY)
|
|
29
26
|
return unsupported("Wayland desktop capture requires Portal/PipeWire and is not supported yet.");
|
|
30
27
|
if (!process.env.DISPLAY)
|
|
@@ -51,9 +48,7 @@ function screenSize() {
|
|
|
51
48
|
if (match && +match[1] > 0 && +match[2] > 0)
|
|
52
49
|
return [+match[1], +match[2]];
|
|
53
50
|
}
|
|
54
|
-
catch {
|
|
55
|
-
/* Try xrandr when xdpyinfo cannot query this display. */
|
|
56
|
-
}
|
|
51
|
+
catch { }
|
|
57
52
|
}
|
|
58
53
|
const randr = executable("xrandr");
|
|
59
54
|
if (randr) {
|
|
@@ -63,9 +58,7 @@ function screenSize() {
|
|
|
63
58
|
if (match && +match[1] > 0 && +match[2] > 0)
|
|
64
59
|
return [+match[1], +match[2]];
|
|
65
60
|
}
|
|
66
|
-
catch {
|
|
67
|
-
/* Report a useful dependency/display error below. */
|
|
68
|
-
}
|
|
61
|
+
catch { }
|
|
69
62
|
}
|
|
70
63
|
throw new Error("Cannot determine X11 screen dimensions; install xdpyinfo or xrandr and check DISPLAY/XAUTHORITY.");
|
|
71
64
|
}
|
|
@@ -145,7 +138,6 @@ export function startLinuxDesktop(options) {
|
|
|
145
138
|
buttons.clear();
|
|
146
139
|
if (!control || !args.length)
|
|
147
140
|
return;
|
|
148
|
-
// One bounded, directly spawned cleanup command; never starts a shell.
|
|
149
141
|
execFile(control, args, { timeout: 2000, killSignal: "SIGKILL", maxBuffer: 16384, shell: false }, () => { });
|
|
150
142
|
};
|
|
151
143
|
const close = () => {
|
|
@@ -159,7 +151,6 @@ export function startLinuxDesktop(options) {
|
|
|
159
151
|
killTimer = setTimeout(() => capture?.kill("SIGKILL"), 1000);
|
|
160
152
|
killTimer.unref();
|
|
161
153
|
}
|
|
162
|
-
// Wait for the active command's callback before releasing, avoiding a late keydown.
|
|
163
154
|
if (command)
|
|
164
155
|
command.kill("SIGKILL");
|
|
165
156
|
else
|
|
@@ -180,7 +171,6 @@ export function startLinuxDesktop(options) {
|
|
|
180
171
|
if (closed || command || !queue.length || !control)
|
|
181
172
|
return;
|
|
182
173
|
const args = queue.shift();
|
|
183
|
-
// Track attempted downs too: an interrupted xdotool can already have injected them.
|
|
184
174
|
for (let i = 0; i < args.length - 1; i++) {
|
|
185
175
|
if (args[i] === "keydown")
|
|
186
176
|
keys.add(args[i + 1]);
|
|
@@ -318,7 +308,6 @@ export function startLinuxDesktop(options) {
|
|
|
318
308
|
capture.stdout.on("data", (chunk) => {
|
|
319
309
|
if (closed)
|
|
320
310
|
return;
|
|
321
|
-
// Slice large writes so a single producer chunk cannot grow retained memory unboundedly.
|
|
322
311
|
for (let offset = 0; offset < chunk.length && !closed; offset += 65536) {
|
|
323
312
|
pending = Buffer.concat([pending, chunk.subarray(offset, offset + 65536)]);
|
|
324
313
|
while (pending.length && !closed) {
|
|
@@ -365,7 +354,6 @@ export function startLinuxDesktop(options) {
|
|
|
365
354
|
});
|
|
366
355
|
}
|
|
367
356
|
catch (error) {
|
|
368
|
-
// Defer setup failures so callers can store the returned handle before onClose.
|
|
369
357
|
queueMicrotask(() => fail(String(error)));
|
|
370
358
|
}
|
|
371
359
|
return { input, close };
|
|
@@ -43,7 +43,6 @@ const specialKeys = new Set([
|
|
|
43
43
|
"Period",
|
|
44
44
|
"Slash",
|
|
45
45
|
]);
|
|
46
|
-
// Rebuild a bounded wire object: never forward untrusted extra fields to the helper.
|
|
47
46
|
function validatedInput(value) {
|
|
48
47
|
if (!value || typeof value !== "object")
|
|
49
48
|
return;
|
|
@@ -82,7 +81,6 @@ function validatedInput(value) {
|
|
|
82
81
|
function powershellPath() {
|
|
83
82
|
return join(process.env.SystemRoot || "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
84
83
|
}
|
|
85
|
-
/** Availability of the capture runtime; OS permissions are checked by the helper at startup. */
|
|
86
84
|
export function nativeDesktopStatus() {
|
|
87
85
|
if (process.platform === "win32") {
|
|
88
86
|
return existsSync(powershellPath())
|
|
@@ -109,9 +107,7 @@ export function nativeDesktopStatus() {
|
|
|
109
107
|
stdio: ["ignore", "pipe", "ignore"],
|
|
110
108
|
}).trim());
|
|
111
109
|
}
|
|
112
|
-
catch {
|
|
113
|
-
/* Missing/unselected developer tools or a stalled xcrun. */
|
|
114
|
-
}
|
|
110
|
+
catch { }
|
|
115
111
|
return swiftAvailable
|
|
116
112
|
? { supported: true, backend: "macos-screencapturekit" }
|
|
117
113
|
: {
|
|
@@ -126,7 +122,6 @@ export function nativeDesktopStatus() {
|
|
|
126
122
|
reason: "Native desktop capture is unavailable on this platform; Linux requires a separate X11/Wayland backend.",
|
|
127
123
|
};
|
|
128
124
|
}
|
|
129
|
-
/** Explicit local permission action; callers must enforce local-device access. */
|
|
130
125
|
export async function requestNativeDesktopPermissions(kind, signal) {
|
|
131
126
|
if (signal?.aborted)
|
|
132
127
|
throw new Error("Native desktop permission request aborted.");
|
|
@@ -151,7 +146,6 @@ export async function requestNativeDesktopPermissions(kind, signal) {
|
|
|
151
146
|
clearTimeout(timeout);
|
|
152
147
|
clearTimeout(killTimer);
|
|
153
148
|
signal?.removeEventListener("abort", abort);
|
|
154
|
-
// Never remove a running helper's script, or block the event loop on retries.
|
|
155
149
|
if (directory)
|
|
156
150
|
rm(directory, { recursive: true, force: true, maxRetries: 2 }, () => { });
|
|
157
151
|
}
|
|
@@ -236,7 +230,6 @@ export async function requestNativeDesktopPermissions(kind, signal) {
|
|
|
236
230
|
}
|
|
237
231
|
});
|
|
238
232
|
}
|
|
239
|
-
/** Main-display JPEG stream. Read-only is immutable per handle and defaults to true. */
|
|
240
233
|
export function startNativeDesktop(options) {
|
|
241
234
|
const status = nativeDesktopStatus();
|
|
242
235
|
const readOnly = options.readOnly !== false;
|
|
@@ -273,8 +266,6 @@ export function startNativeDesktop(options) {
|
|
|
273
266
|
finish();
|
|
274
267
|
return;
|
|
275
268
|
}
|
|
276
|
-
// EOF/close is processed on a dedicated input thread: held keys/buttons are
|
|
277
|
-
// released before exit, even when capture is waiting for frame acknowledgment.
|
|
278
269
|
if (!child.stdin.destroyed)
|
|
279
270
|
child.stdin.end('{"type":"close"}\n');
|
|
280
271
|
timer = setTimeout(() => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** Self-contained native JPEG desktop client. All URLs stay relative to the mounted page. */
|
|
2
1
|
export function desktopPage() {
|
|
3
2
|
return `<!doctype html>
|
|
4
3
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Remote desktop</title>
|
|
@@ -126,8 +125,8 @@ function connect() {
|
|
|
126
125
|
pendingFrame = {blob:event.data, generation:currentGeneration, socket:current}; void decodeFrames();
|
|
127
126
|
}
|
|
128
127
|
};
|
|
129
|
-
current.onerror = () => { if (isCurrent()) fail(t('connectionError')); };
|
|
130
|
-
current.onclose = event => { if (isCurrent()) { stop(); status(t('closed') + ' (' + event.code + ')' + (event.reason ? ': ' + event.reason : ''), true); } };
|
|
128
|
+
current.onerror = () => { if (isCurrent()) { fail(t('connectionError')); parent.postMessage({type:'device-portal-disconnected'}, '*'); } };
|
|
129
|
+
current.onclose = event => { if (isCurrent()) { stop(); status(t('closed') + ' (' + event.code + ')' + (event.reason ? ': ' + event.reason : ''), true); parent.postMessage({type:'device-portal-disconnected'}, '*'); } };
|
|
131
130
|
}
|
|
132
131
|
async function request(path, options = {}) {
|
|
133
132
|
const response = await fetch(appUrl(path), {...options, credentials:'same-origin', cache:'no-store'});
|
|
@@ -9,9 +9,7 @@ export function createDesktopSetup(options) {
|
|
|
9
9
|
try {
|
|
10
10
|
storedEnabled = JSON.parse(readFileSync(settingsFile, "utf8"))?.enabled === true;
|
|
11
11
|
}
|
|
12
|
-
catch {
|
|
13
|
-
// Missing or unreadable settings leave desktop access disabled by default.
|
|
14
|
-
}
|
|
12
|
+
catch { }
|
|
15
13
|
let closed = false;
|
|
16
14
|
return {
|
|
17
15
|
get enabled() {
|
|
@@ -13,7 +13,6 @@ export const DESKTOP_LIMITS = Object.freeze({
|
|
|
13
13
|
idleMs: 30 * 60_000,
|
|
14
14
|
});
|
|
15
15
|
const loopback = (host) => ["127.0.0.1", "::1", "[::1]", "localhost"].includes(host);
|
|
16
|
-
/** Independent local authorization. Connector rewrites Host/Origin and injects local credentials. */
|
|
17
16
|
export function desktopLocalRequest(req) {
|
|
18
17
|
if (!loopback(req.socket.remoteAddress?.replace(/^::ffff:/, "") ?? ""))
|
|
19
18
|
return false;
|
|
@@ -35,7 +34,6 @@ export function desktopLocalRequest(req) {
|
|
|
35
34
|
return false;
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
/** Validate the entire input at the trust boundary, before invoking any native API. */
|
|
39
37
|
export function parseDesktopInput(value) {
|
|
40
38
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
41
39
|
return;
|
|
@@ -145,7 +143,6 @@ export function createDeviceDesktop({ app, authorize, env = process.env, dataDir
|
|
|
145
143
|
}
|
|
146
144
|
next();
|
|
147
145
|
};
|
|
148
|
-
// Both Hub and connector reject these routes. Require a loopback browser as well.
|
|
149
146
|
const localGuard = (req, res, next) => {
|
|
150
147
|
if (!allowed(req) || req.headers["sec-fetch-site"] === "cross-site") {
|
|
151
148
|
res.status(403).json({ error: "Open Device Center on this device to manage desktop permissions." });
|
|
@@ -296,9 +293,7 @@ export function createDeviceDesktop({ app, authorize, env = process.env, dataDir
|
|
|
296
293
|
}
|
|
297
294
|
input = parseDesktopInput(value);
|
|
298
295
|
}
|
|
299
|
-
catch {
|
|
300
|
-
/* Invalid input closes this connection. */
|
|
301
|
-
}
|
|
296
|
+
catch { }
|
|
302
297
|
if (!input)
|
|
303
298
|
return cleanup();
|
|
304
299
|
lastActivity = Date.now();
|
|
@@ -324,7 +319,6 @@ export function createDeviceDesktop({ app, authorize, env = process.env, dataDir
|
|
|
324
319
|
clearTimeout(connectTimer);
|
|
325
320
|
ws.send(JSON.stringify({ type: "ready" }));
|
|
326
321
|
}
|
|
327
|
-
// Slow clients drop frames rather than building latency or an unbounded queue.
|
|
328
322
|
if (sending ||
|
|
329
323
|
awaitingAck ||
|
|
330
324
|
queued + jpeg.length > DESKTOP_LIMITS.queue ||
|