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,15 +1,19 @@
|
|
|
1
1
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
2
2
|
import { parseReportMetadata } from "./report-metadata.js";
|
|
3
|
+
import { computeLegacyOutcomeFingerprint } from "./task-outcome.js";
|
|
3
4
|
import { integrationErrorFromCode } from "./integration-errors.js";
|
|
5
|
+
import { INTEGRATION_RPC_TIMEOUT_MS, VERIFICATION_RPC_TIMEOUT_MS } from "./verification-limits.js";
|
|
4
6
|
import { WebSocket, WebSocketServer } from "ws";
|
|
5
|
-
import { capabilityBase, createPortalResponse, parseDevicePath, portalHeaders, wrapperHtml } from "./path-portal.js";
|
|
7
|
+
import { capabilityBase, createPortalResponse, nativeResourceContentType, parseDevicePath, portalHeaders, wrapperHtml, } from "./path-portal.js";
|
|
8
|
+
import { nativeOrigin } from "./hub-auth.js";
|
|
6
9
|
export const RELAY_LIMITS = {
|
|
7
|
-
frame:
|
|
10
|
+
frame: 512 * 1024,
|
|
8
11
|
chunk: 32 * 1024,
|
|
9
|
-
queue:
|
|
12
|
+
queue: 4 * 1024 * 1024,
|
|
10
13
|
body: 64 * 1024 * 1024,
|
|
11
14
|
streams: 32,
|
|
12
15
|
cancellations: 16,
|
|
16
|
+
steerings: 16,
|
|
13
17
|
devices: 128,
|
|
14
18
|
sessions: 2048,
|
|
15
19
|
};
|
|
@@ -95,11 +99,9 @@ export function safePath(path, method = "GET") {
|
|
|
95
99
|
if (/%|[\\\x00-\x20]/.test(decoded))
|
|
96
100
|
return false;
|
|
97
101
|
const normalized = new URL(decoded, "http://local").pathname.toLowerCase();
|
|
98
|
-
// OS authorization is initiated only on the device itself, never through a Hub portal.
|
|
99
102
|
if (normalized === "/api/device-desktop/local" || normalized.startsWith("/api/device-desktop/local/"))
|
|
100
103
|
return false;
|
|
101
104
|
if (normalized === "/api/device-center" || normalized.startsWith("/api/device-center/")) {
|
|
102
|
-
// Only account-scoped chat routes may cross a device portal.
|
|
103
105
|
if (method === "GET") {
|
|
104
106
|
return /^\/api\/device-center\/(chat-status|devices|bots|rooms(?:\/[^/]+(?:\/(?:events|interactions|conversations(?:\/[^/]+)?))?)?)$/.test(normalized);
|
|
105
107
|
}
|
|
@@ -114,6 +116,8 @@ export function safePath(path, method = "GET") {
|
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
export const COMMANDS = [
|
|
119
|
+
"device_lan",
|
|
120
|
+
"group_router_models",
|
|
117
121
|
"transfer_stage",
|
|
118
122
|
"transfer_preview",
|
|
119
123
|
"transfer_apply",
|
|
@@ -127,6 +131,7 @@ export const COMMANDS = [
|
|
|
127
131
|
"integration_prepare",
|
|
128
132
|
"integration_verify",
|
|
129
133
|
"integration_confirm",
|
|
134
|
+
"integration_publication_status",
|
|
130
135
|
"integration_cancel",
|
|
131
136
|
];
|
|
132
137
|
const RPC_BYTES = 12 * 1024 * 1024;
|
|
@@ -145,14 +150,18 @@ export function createCommandChannel(ws, handler) {
|
|
|
145
150
|
if (error)
|
|
146
151
|
item.reject?.(error);
|
|
147
152
|
}
|
|
148
|
-
function add(id, incoming) {
|
|
153
|
+
function add(id, incoming, action) {
|
|
149
154
|
if (ended || pending.size >= 4 || pending.has(id))
|
|
150
155
|
throw new Error("Command capacity exceeded");
|
|
151
156
|
const timer = setTimeout(() => {
|
|
152
157
|
sendFrame(ws, { type: "rpc_cancel", id });
|
|
153
158
|
const err = Object.assign(new Error("Command timed out"), { stopUnconfirmed: true });
|
|
154
159
|
remove(id, err);
|
|
155
|
-
},
|
|
160
|
+
}, action === "integration_verify"
|
|
161
|
+
? VERIFICATION_RPC_TIMEOUT_MS
|
|
162
|
+
: action.startsWith("integration_")
|
|
163
|
+
? INTEGRATION_RPC_TIMEOUT_MS
|
|
164
|
+
: 60_000);
|
|
156
165
|
timer.unref();
|
|
157
166
|
const item = {
|
|
158
167
|
chunks: [],
|
|
@@ -202,7 +211,7 @@ export function createCommandChannel(ws, handler) {
|
|
|
202
211
|
const id = randomUUID();
|
|
203
212
|
let item;
|
|
204
213
|
try {
|
|
205
|
-
item = add(id, false);
|
|
214
|
+
item = add(id, false, action);
|
|
206
215
|
}
|
|
207
216
|
catch (error) {
|
|
208
217
|
reject(error);
|
|
@@ -250,7 +259,7 @@ export function createCommandChannel(ws, handler) {
|
|
|
250
259
|
sendFrame(ws, { type: "rpc_error", id });
|
|
251
260
|
return true;
|
|
252
261
|
}
|
|
253
|
-
const item = add(id, true);
|
|
262
|
+
const item = add(id, true, frame.action);
|
|
254
263
|
item.action = frame.action;
|
|
255
264
|
return true;
|
|
256
265
|
}
|
|
@@ -271,7 +280,10 @@ export function createCommandChannel(ws, handler) {
|
|
|
271
280
|
}
|
|
272
281
|
if (frame.type === "rpc_error") {
|
|
273
282
|
const safeError = item.action?.startsWith("integration_") ? integrationErrorFromCode(frame.code) : undefined;
|
|
274
|
-
|
|
283
|
+
const error = safeError ?? new Error("Remote command rejected");
|
|
284
|
+
if (frame.stopUnconfirmed === true)
|
|
285
|
+
Object.assign(error, { stopUnconfirmed: true });
|
|
286
|
+
remove(id, error);
|
|
275
287
|
return true;
|
|
276
288
|
}
|
|
277
289
|
if (item.executing)
|
|
@@ -298,12 +310,18 @@ export function createCommandChannel(ws, handler) {
|
|
|
298
310
|
item.executing = true;
|
|
299
311
|
const run = async () => {
|
|
300
312
|
let wasAborted = false;
|
|
313
|
+
let stopUnconfirmed = false;
|
|
301
314
|
const onAbort = () => {
|
|
302
315
|
wasAborted = true;
|
|
303
316
|
};
|
|
304
317
|
item.controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
305
318
|
try {
|
|
306
319
|
const result = await handler(item.action, value, item.controller.signal);
|
|
320
|
+
const stop = result && typeof result === "object" && "publishStop" in result ? result.publishStop : undefined;
|
|
321
|
+
stopUnconfirmed =
|
|
322
|
+
!!stop && typeof stop === "object" && "stopConfirmed" in stop && stop.stopConfirmed === false;
|
|
323
|
+
if (stopUnconfirmed && (wasAborted || item.controller.signal.aborted) && pending.get(id) === item)
|
|
324
|
+
sendFrame(ws, { type: "rpc_error", id, stopUnconfirmed: true });
|
|
307
325
|
if (pending.get(id) !== item)
|
|
308
326
|
return;
|
|
309
327
|
if (wasAborted || item.controller.signal.aborted)
|
|
@@ -311,7 +329,11 @@ export function createCommandChannel(ws, handler) {
|
|
|
311
329
|
await transmit(id, "rpc_response", result, item.controller.signal);
|
|
312
330
|
}
|
|
313
331
|
catch (error) {
|
|
314
|
-
|
|
332
|
+
stopUnconfirmed =
|
|
333
|
+
!!error && typeof error === "object" && "stopUnconfirmed" in error && error.stopUnconfirmed === true;
|
|
334
|
+
if (stopUnconfirmed && pending.get(id) === item)
|
|
335
|
+
sendFrame(ws, { type: "rpc_error", id, stopUnconfirmed: true });
|
|
336
|
+
if (!stopUnconfirmed && !wasAborted && !item.controller.signal.aborted && pending.get(id) === item) {
|
|
315
337
|
const code = error && typeof error === "object" && "code" in error ? error.code : undefined;
|
|
316
338
|
const safeError = item.action?.startsWith("integration_") ? integrationErrorFromCode(code) : undefined;
|
|
317
339
|
sendFrame(ws, { type: "rpc_error", id, ...(safeError ? { code } : {}) });
|
|
@@ -319,7 +341,7 @@ export function createCommandChannel(ws, handler) {
|
|
|
319
341
|
}
|
|
320
342
|
finally {
|
|
321
343
|
item.controller.signal.removeEventListener("abort", onAbort);
|
|
322
|
-
if (wasAborted || item.controller.signal.aborted) {
|
|
344
|
+
if (!stopUnconfirmed && (wasAborted || item.controller.signal.aborted)) {
|
|
323
345
|
sendFrame(ws, { type: "rpc_cancel_ack", id });
|
|
324
346
|
}
|
|
325
347
|
remove(id);
|
|
@@ -340,7 +362,6 @@ export function createCommandChannel(ws, handler) {
|
|
|
340
362
|
};
|
|
341
363
|
}
|
|
342
364
|
export const WS_MESSAGE_BYTES = 16 * 1024 * 1024;
|
|
343
|
-
/** Connection-scoped, bounded message assembly and outbound queue. */
|
|
344
365
|
export function createWsMessageChannel(transport) {
|
|
345
366
|
const assemblies = new Map();
|
|
346
367
|
let aggregate = 0;
|
|
@@ -466,7 +487,6 @@ export function createDeviceRelay(options) {
|
|
|
466
487
|
const interactionAcks = new Map();
|
|
467
488
|
const deviceGenerations = new Map();
|
|
468
489
|
const devices = new Map();
|
|
469
|
-
// Slow browser responses apply transport backpressure instead of losing resource bodies.
|
|
470
490
|
const stalledResponses = new WeakMap();
|
|
471
491
|
function pauseForResponse(ws, res) {
|
|
472
492
|
let stalled = stalledResponses.get(ws);
|
|
@@ -489,6 +509,7 @@ export function createDeviceRelay(options) {
|
|
|
489
509
|
const tickets = new Map();
|
|
490
510
|
const sessions = new Map();
|
|
491
511
|
const capabilities = new Map();
|
|
512
|
+
const nativeSockets = new Map();
|
|
492
513
|
const pathRequest = (req) => {
|
|
493
514
|
if (req.headers.host?.toLowerCase() !== hub.host.toLowerCase())
|
|
494
515
|
return null;
|
|
@@ -498,16 +519,23 @@ export function createDeviceRelay(options) {
|
|
|
498
519
|
? path
|
|
499
520
|
: null;
|
|
500
521
|
};
|
|
501
|
-
function pathAuthorized(req, id, websocket = false) {
|
|
522
|
+
async function pathAuthorized(req, id, websocket = false) {
|
|
502
523
|
const path = pathRequest(req);
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
path?.path
|
|
508
|
-
(
|
|
509
|
-
|
|
510
|
-
|
|
524
|
+
const grant = path?.token ? capabilities.get(path.token) : undefined;
|
|
525
|
+
if (!grant ||
|
|
526
|
+
grant.deviceId !== id ||
|
|
527
|
+
grant.expiresAt <= Date.now() ||
|
|
528
|
+
!path?.path ||
|
|
529
|
+
(websocket && !safePath(path.path, "WS")))
|
|
530
|
+
return false;
|
|
531
|
+
if (!grant.nativeOrigin)
|
|
532
|
+
return (!req.headers.origin || req.headers.origin === "null") && (!websocket || req.headers.origin === "null");
|
|
533
|
+
if (req.headers.origin !== grant.nativeOrigin || !grant.isSessionActive?.())
|
|
534
|
+
return false;
|
|
535
|
+
if (!websocket && !path.path.startsWith("/api/") && !nativeResourceContentType(path.path, req.method || "GET"))
|
|
536
|
+
return false;
|
|
537
|
+
const owns = await options.ownsDevice(grant.accountId, id);
|
|
538
|
+
return owns && grant.expiresAt > Date.now() && grant.isSessionActive() && capabilities.get(path.token) === grant;
|
|
511
539
|
}
|
|
512
540
|
const wss = new WebSocketServer({ noServer: true, maxPayload: RELAY_LIMITS.frame, perMessageDeflate: false });
|
|
513
541
|
const browserWss = new WebSocketServer({ noServer: true, maxPayload: WS_MESSAGE_BYTES, perMessageDeflate: false });
|
|
@@ -558,15 +586,19 @@ export function createDeviceRelay(options) {
|
|
|
558
586
|
pending.finish(false);
|
|
559
587
|
for (const pending of entry.cancellations.values())
|
|
560
588
|
pending.finish(false);
|
|
589
|
+
for (const pending of entry.steerings.values())
|
|
590
|
+
pending.finish(false);
|
|
561
591
|
entry.rpc.close();
|
|
562
592
|
entry.messages.close();
|
|
563
|
-
for (const [taskId, { attemptId, botId, hasLease }] of entry.tasks) {
|
|
593
|
+
for (const [taskId, { attemptId, botId, hasLease, leaseToken, leaseGeneration }] of entry.tasks) {
|
|
564
594
|
if (optionsDrop?.isRevoke || !hasLease) {
|
|
565
595
|
Promise.resolve()
|
|
566
596
|
.then(() => options.onTaskEvent?.(id, {
|
|
567
597
|
taskId,
|
|
568
598
|
botId,
|
|
569
599
|
attemptId,
|
|
600
|
+
leaseToken,
|
|
601
|
+
leaseGeneration,
|
|
570
602
|
status: "interrupted",
|
|
571
603
|
report: optionsDrop?.isRevoke
|
|
572
604
|
? "Device revoked; task interrupted."
|
|
@@ -575,7 +607,6 @@ export function createDeviceRelay(options) {
|
|
|
575
607
|
.catch(() => { });
|
|
576
608
|
}
|
|
577
609
|
else {
|
|
578
|
-
// Retain recovery grace window on Hub for tasks with active lease!
|
|
579
610
|
Promise.resolve()
|
|
580
611
|
.then(() => options.onTaskDisconnect?.(id, taskId, attemptId))
|
|
581
612
|
.catch(() => { });
|
|
@@ -603,7 +634,7 @@ export function createDeviceRelay(options) {
|
|
|
603
634
|
entry.streams.set(id, item);
|
|
604
635
|
return item;
|
|
605
636
|
}
|
|
606
|
-
async function handleOpen(req, res, id, redirect = false) {
|
|
637
|
+
async function handleOpen(req, res, id, redirect = false, preferLan = false) {
|
|
607
638
|
const generation = revision;
|
|
608
639
|
const account = await options.getAccount(req);
|
|
609
640
|
const accountId = typeof account === "string" ? account : account?.id;
|
|
@@ -631,6 +662,18 @@ export function createDeviceRelay(options) {
|
|
|
631
662
|
res.writeHead(503).end();
|
|
632
663
|
return;
|
|
633
664
|
}
|
|
665
|
+
let deviceLan;
|
|
666
|
+
if (preferLan && !redirect) {
|
|
667
|
+
const entry = devices.get(id);
|
|
668
|
+
try {
|
|
669
|
+
deviceLan = await entry.rpc.call("device_lan", {}, { signal: AbortSignal.timeout(1500) });
|
|
670
|
+
}
|
|
671
|
+
catch { }
|
|
672
|
+
if (closed || generation !== revision || devices.get(id) !== entry || res.destroyed) {
|
|
673
|
+
res.writeHead(409).end();
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
634
677
|
const ticket = randomBytes(32).toString("hex");
|
|
635
678
|
const expiresAt = Date.now() + 30_000;
|
|
636
679
|
tickets.set(ticket, { deviceId: id, accountId, generation, expiresAt });
|
|
@@ -642,7 +685,7 @@ export function createDeviceRelay(options) {
|
|
|
642
685
|
else
|
|
643
686
|
res
|
|
644
687
|
.writeHead(200, { "content-type": "application/json", "cache-control": "no-store" })
|
|
645
|
-
.end(JSON.stringify({ url, expiresAt }));
|
|
688
|
+
.end(JSON.stringify({ url, expiresAt, ...(deviceLan ? { deviceLan } : {}) }));
|
|
646
689
|
}
|
|
647
690
|
function sendWrapper(res, id, accountId, initialPath = "") {
|
|
648
691
|
if (closed || !devices.has(id)) {
|
|
@@ -657,7 +700,7 @@ export function createDeviceRelay(options) {
|
|
|
657
700
|
capabilities.set(token, { deviceId: id, accountId, expiresAt: Date.now() + 8 * 60 * 60_000 });
|
|
658
701
|
const name = options.getDeviceName?.(id)?.trim();
|
|
659
702
|
const label = name && name !== id ? `${name} (${id})` : id;
|
|
660
|
-
const wrapper = wrapperHtml(capabilityBase(id, token), initialPath, initialPath === "desktop" ? hub : undefined, label);
|
|
703
|
+
const wrapper = wrapperHtml(capabilityBase(id, token), initialPath, initialPath === "desktop" ? hub : undefined, label, JSON.stringify([accountId, id]));
|
|
661
704
|
res
|
|
662
705
|
.writeHead(200, {
|
|
663
706
|
"content-type": "text/html; charset=utf-8",
|
|
@@ -705,6 +748,15 @@ export function createDeviceRelay(options) {
|
|
|
705
748
|
}
|
|
706
749
|
return false;
|
|
707
750
|
}
|
|
751
|
+
void handleDeviceRequest(req, res, id).catch(() => {
|
|
752
|
+
if (!res.headersSent)
|
|
753
|
+
res.writeHead(403).end();
|
|
754
|
+
else
|
|
755
|
+
res.destroy();
|
|
756
|
+
});
|
|
757
|
+
return true;
|
|
758
|
+
}
|
|
759
|
+
async function handleDeviceRequest(req, res, id) {
|
|
708
760
|
res.setHeader("Cache-Control", "no-store");
|
|
709
761
|
res.setHeader("Referrer-Policy", "no-referrer");
|
|
710
762
|
const path = pathRequest(req);
|
|
@@ -757,22 +809,21 @@ export function createDeviceRelay(options) {
|
|
|
757
809
|
.end();
|
|
758
810
|
return true;
|
|
759
811
|
}
|
|
760
|
-
if (!(path ? pathAuthorized(req, id) : authorized(req, id))) {
|
|
812
|
+
if (!(path ? await pathAuthorized(req, id) : authorized(req, id))) {
|
|
761
813
|
res.writeHead(403).end();
|
|
762
814
|
return true;
|
|
763
815
|
}
|
|
816
|
+
const requestNativeOrigin = path?.token ? capabilities.get(path.token)?.nativeOrigin : undefined;
|
|
764
817
|
if (path && req.method === "OPTIONS") {
|
|
765
|
-
res.writeHead(204, portalHeaders(hub, capabilityBase(id, path.token))).end();
|
|
818
|
+
res.writeHead(204, portalHeaders(hub, capabilityBase(id, path.token), requestNativeOrigin)).end();
|
|
766
819
|
return true;
|
|
767
820
|
}
|
|
768
821
|
// Only authenticated capability requests receive opaque-origin response headers.
|
|
769
822
|
if (path) {
|
|
770
|
-
for (const [key, value] of Object.entries(portalHeaders(hub, capabilityBase(id, path.token))))
|
|
823
|
+
for (const [key, value] of Object.entries(portalHeaders(hub, capabilityBase(id, path.token), requestNativeOrigin)))
|
|
771
824
|
res.setHeader(key, value);
|
|
772
825
|
}
|
|
773
826
|
const forwardPath = path ? path.path : req.url;
|
|
774
|
-
// Serve account binding at the Hub, including compatibility for older device UIs.
|
|
775
|
-
// Never forward the local management status endpoint or expose its settings.
|
|
776
827
|
if (path &&
|
|
777
828
|
req.method === "GET" &&
|
|
778
829
|
["/api/device-center/chat-status", "/api/device-center/status"].includes(forwardPath?.split("?")[0] ?? "")) {
|
|
@@ -789,14 +840,13 @@ export function createDeviceRelay(options) {
|
|
|
789
840
|
res.writeHead(400).end();
|
|
790
841
|
return true;
|
|
791
842
|
}
|
|
792
|
-
// Only entry documents are rewritten; preserve negotiated compression for assets.
|
|
793
843
|
const rewriteHtml = !!path && ["/", "/desktop"].includes(path.path.split("?")[0]);
|
|
794
844
|
const streamId = randomBytes(12).toString("hex");
|
|
795
845
|
addStream(entry, streamId, {
|
|
796
846
|
res,
|
|
797
847
|
...(path
|
|
798
848
|
? {
|
|
799
|
-
portal: createPortalResponse(res, hub, capabilityBase(id, path.token), rewriteHtml),
|
|
849
|
+
portal: createPortalResponse(res, hub, capabilityBase(id, path.token), rewriteHtml, requestNativeOrigin, requestNativeOrigin ? nativeResourceContentType(forwardPath, req.method || "GET") : undefined),
|
|
800
850
|
}
|
|
801
851
|
: {}),
|
|
802
852
|
});
|
|
@@ -838,13 +888,18 @@ export function createDeviceRelay(options) {
|
|
|
838
888
|
const path = pathRequest(req);
|
|
839
889
|
const entry = devices.get(id);
|
|
840
890
|
if (!entry ||
|
|
841
|
-
!(path ? pathAuthorized(req, id, true) : authorized(req, id, true)) ||
|
|
891
|
+
!(path ? await pathAuthorized(req, id, true) : authorized(req, id, true)) ||
|
|
892
|
+
devices.get(id) !== entry ||
|
|
842
893
|
entry.streams.size >= RELAY_LIMITS.streams ||
|
|
843
894
|
!safePath(path ? path.path : req.url, "WS")) {
|
|
844
895
|
socket.destroy();
|
|
845
896
|
return;
|
|
846
897
|
}
|
|
847
898
|
browserWss.handleUpgrade(req, socket, head, (ws) => {
|
|
899
|
+
if (path?.token && capabilities.get(path.token)?.nativeOrigin) {
|
|
900
|
+
nativeSockets.set(ws, () => pathAuthorized(req, id, true));
|
|
901
|
+
ws.once("close", () => nativeSockets.delete(ws));
|
|
902
|
+
}
|
|
848
903
|
const streamId = randomBytes(12).toString("hex");
|
|
849
904
|
addStream(entry, streamId, { ws });
|
|
850
905
|
ws.pause();
|
|
@@ -920,6 +975,7 @@ export function createDeviceRelay(options) {
|
|
|
920
975
|
streams: new Map(),
|
|
921
976
|
tasks: new Map(),
|
|
922
977
|
cancellations: new Map(),
|
|
978
|
+
steerings: new Map(),
|
|
923
979
|
rpc: createCommandChannel(ws),
|
|
924
980
|
messages: createWsMessageChannel(ws),
|
|
925
981
|
};
|
|
@@ -944,6 +1000,17 @@ export function createDeviceRelay(options) {
|
|
|
944
1000
|
pending.finish(frame.stopped);
|
|
945
1001
|
return;
|
|
946
1002
|
}
|
|
1003
|
+
if (frame.type === "task_steered") {
|
|
1004
|
+
const pending = typeof frame.id === "string" ? entry.steerings.get(frame.id) : undefined;
|
|
1005
|
+
if (!pending)
|
|
1006
|
+
return;
|
|
1007
|
+
if (pending.taskId !== frame.taskId ||
|
|
1008
|
+
pending.attemptId !== frame.attemptId ||
|
|
1009
|
+
typeof frame.steered !== "boolean")
|
|
1010
|
+
throw new Error("Invalid task steer acknowledgement");
|
|
1011
|
+
pending.finish(frame.steered);
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
947
1014
|
if (frame.type === "task_interaction_result") {
|
|
948
1015
|
const pending = typeof frame.id === "string" ? interactionAcks.get(frame.id) : undefined;
|
|
949
1016
|
if (pending?.ws === ws)
|
|
@@ -1017,33 +1084,74 @@ export function createDeviceRelay(options) {
|
|
|
1017
1084
|
if (frame.reportMetadata !== undefined)
|
|
1018
1085
|
frame.reportMetadata = parseReportMetadata(frame.reportMetadata);
|
|
1019
1086
|
const current = entry.tasks.get(taskId);
|
|
1020
|
-
if (current &&
|
|
1087
|
+
if (current &&
|
|
1088
|
+
(current.botId !== botId || (frame.status === "running" && current.attemptId !== attemptId)))
|
|
1021
1089
|
throw new Error("Unknown task");
|
|
1022
1090
|
Promise.resolve()
|
|
1023
1091
|
.then(() => options.onTaskEvent?.(device, frame))
|
|
1024
|
-
.then(() => {
|
|
1025
|
-
if (devices.get(device)
|
|
1092
|
+
.then((committed) => {
|
|
1093
|
+
if (devices.get(device) !== entry)
|
|
1094
|
+
return;
|
|
1095
|
+
if (frame.status === "completed" || frame.status === "failed" || frame.status === "interrupted") {
|
|
1026
1096
|
const postCheck = entry.tasks.get(taskId);
|
|
1027
|
-
if (postCheck
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1097
|
+
if (postCheck?.attemptId === attemptId && postCheck.botId === botId)
|
|
1098
|
+
entry.tasks.delete(taskId);
|
|
1099
|
+
if (committed &&
|
|
1100
|
+
committed.id === taskId &&
|
|
1101
|
+
committed.attemptId === attemptId &&
|
|
1102
|
+
committed.botId === botId &&
|
|
1103
|
+
committed.status === frame.status) {
|
|
1104
|
+
const outcome = frame;
|
|
1105
|
+
const legacyDuplicate = outcome.leaseToken === undefined &&
|
|
1106
|
+
outcome.leaseGeneration === undefined &&
|
|
1107
|
+
outcome.artifact === undefined &&
|
|
1108
|
+
outcome.executionCompleted === undefined &&
|
|
1109
|
+
outcome.artifactProduced === undefined &&
|
|
1110
|
+
outcome.fingerprint ===
|
|
1111
|
+
computeLegacyOutcomeFingerprint(taskId, attemptId, outcome.status, outcome.report, outcome.error, outcome.reportMetadata);
|
|
1112
|
+
if (!committed.outcomeFingerprint && !legacyDuplicate)
|
|
1113
|
+
return;
|
|
1033
1114
|
sendFrame(ws, {
|
|
1034
1115
|
type: "task_result_ack",
|
|
1035
|
-
taskId
|
|
1036
|
-
attemptId
|
|
1037
|
-
|
|
1038
|
-
|
|
1116
|
+
taskId,
|
|
1117
|
+
attemptId,
|
|
1118
|
+
accepted: true,
|
|
1119
|
+
status: committed.status,
|
|
1120
|
+
fingerprint: legacyDuplicate ? outcome.fingerprint : committed.outcomeFingerprint,
|
|
1121
|
+
artifactDigest: committed.artifact?.digest,
|
|
1039
1122
|
});
|
|
1040
1123
|
}
|
|
1041
1124
|
}
|
|
1042
1125
|
})
|
|
1043
|
-
.catch(() =>
|
|
1126
|
+
.catch((error) => {
|
|
1127
|
+
const rejection = error;
|
|
1128
|
+
if (devices.get(device) === entry &&
|
|
1129
|
+
frame.status !== "running" &&
|
|
1130
|
+
rejection?.permanent === true &&
|
|
1131
|
+
["terminal_conflict", "attempt_expired", "legacy_lease_missing"].includes(String(rejection.reasonCode)) &&
|
|
1132
|
+
typeof frame.fingerprint === "string") {
|
|
1133
|
+
const pending = entry.tasks.get(taskId);
|
|
1134
|
+
if (pending?.attemptId === attemptId && pending.botId === botId)
|
|
1135
|
+
entry.tasks.delete(taskId);
|
|
1136
|
+
sendFrame(ws, {
|
|
1137
|
+
type: "task_result_ack",
|
|
1138
|
+
taskId,
|
|
1139
|
+
attemptId,
|
|
1140
|
+
accepted: false,
|
|
1141
|
+
status: frame.status,
|
|
1142
|
+
permanent: true,
|
|
1143
|
+
reasonCode: rejection.reasonCode,
|
|
1144
|
+
fingerprint: frame.fingerprint,
|
|
1145
|
+
artifactDigest: typeof frame.artifact?.digest === "string"
|
|
1146
|
+
? frame.artifact.digest
|
|
1147
|
+
: undefined,
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
else
|
|
1151
|
+
ws.terminate();
|
|
1152
|
+
});
|
|
1044
1153
|
return;
|
|
1045
1154
|
}
|
|
1046
|
-
// === Task Recovery / Reconnect Claim / Lease Renewal ===
|
|
1047
1155
|
if (frame.type === "task_claim") {
|
|
1048
1156
|
const rawClaim = frame.claim ?? frame;
|
|
1049
1157
|
if (!rawClaim ||
|
|
@@ -1067,6 +1175,8 @@ export function createDeviceRelay(options) {
|
|
|
1067
1175
|
attemptId: claim.attemptId,
|
|
1068
1176
|
botId: claim.botId,
|
|
1069
1177
|
hasLease: true,
|
|
1178
|
+
leaseToken: claim.leaseToken,
|
|
1179
|
+
leaseGeneration: claim.leaseGeneration,
|
|
1070
1180
|
});
|
|
1071
1181
|
}
|
|
1072
1182
|
sendFrame(ws, {
|
|
@@ -1116,7 +1226,6 @@ export function createDeviceRelay(options) {
|
|
|
1116
1226
|
.catch(() => { });
|
|
1117
1227
|
return;
|
|
1118
1228
|
}
|
|
1119
|
-
// ========================================================
|
|
1120
1229
|
const item = entry.streams.get(frame.id);
|
|
1121
1230
|
if (!item)
|
|
1122
1231
|
return;
|
|
@@ -1176,6 +1285,9 @@ export function createDeviceRelay(options) {
|
|
|
1176
1285
|
}
|
|
1177
1286
|
});
|
|
1178
1287
|
ws.on("close", () => drop(device, entry));
|
|
1288
|
+
void Promise.resolve()
|
|
1289
|
+
.then(() => options.onDeviceConnect?.(device))
|
|
1290
|
+
.catch((cause) => console.warn("[DeviceRelay] Queued task recovery failed", cause));
|
|
1179
1291
|
ws.on("error", () => ws.terminate());
|
|
1180
1292
|
});
|
|
1181
1293
|
}
|
|
@@ -1192,6 +1304,11 @@ export function createDeviceRelay(options) {
|
|
|
1192
1304
|
options.server.on("upgrade", upgradeListener);
|
|
1193
1305
|
const heartbeat = setInterval(() => {
|
|
1194
1306
|
const now = Date.now();
|
|
1307
|
+
for (const [ws, valid] of nativeSockets)
|
|
1308
|
+
void valid().then((ok) => {
|
|
1309
|
+
if (!ok)
|
|
1310
|
+
ws.terminate();
|
|
1311
|
+
}, () => ws.terminate());
|
|
1195
1312
|
for (const map of [tickets, sessions, capabilities])
|
|
1196
1313
|
for (const [key, value] of map)
|
|
1197
1314
|
if (value.expiresAt <= now)
|
|
@@ -1207,6 +1324,30 @@ export function createDeviceRelay(options) {
|
|
|
1207
1324
|
}, 15_000);
|
|
1208
1325
|
heartbeat.unref();
|
|
1209
1326
|
return {
|
|
1327
|
+
async createNativeCapability(request) {
|
|
1328
|
+
const { deviceId, accountId, nativeOrigin: origin, isSessionActive } = request;
|
|
1329
|
+
const generation = revision;
|
|
1330
|
+
if (!nativeOrigin(origin) || !isSessionActive() || !(await options.ownsDevice(accountId, deviceId)))
|
|
1331
|
+
return null;
|
|
1332
|
+
for (const [key, grant] of capabilities)
|
|
1333
|
+
if (grant.expiresAt <= Date.now() || (grant.isSessionActive && !grant.isSessionActive()))
|
|
1334
|
+
capabilities.delete(key);
|
|
1335
|
+
if (closed ||
|
|
1336
|
+
generation !== revision ||
|
|
1337
|
+
!devices.has(deviceId) ||
|
|
1338
|
+
!isSessionActive() ||
|
|
1339
|
+
capabilities.size >= RELAY_LIMITS.sessions)
|
|
1340
|
+
return null;
|
|
1341
|
+
const token = randomBytes(32).toString("hex");
|
|
1342
|
+
capabilities.set(token, {
|
|
1343
|
+
deviceId,
|
|
1344
|
+
accountId,
|
|
1345
|
+
expiresAt: Date.now() + 8 * 60 * 60_000,
|
|
1346
|
+
nativeOrigin: origin,
|
|
1347
|
+
isSessionActive,
|
|
1348
|
+
});
|
|
1349
|
+
return hub.origin + capabilityBase(deviceId, token).replace(/\/$/, "");
|
|
1350
|
+
},
|
|
1210
1351
|
async answerInteraction(deviceId, answer) {
|
|
1211
1352
|
const entry = devices.get(deviceId);
|
|
1212
1353
|
if (!entry ||
|
|
@@ -1254,6 +1395,28 @@ export function createDeviceRelay(options) {
|
|
|
1254
1395
|
finish(false);
|
|
1255
1396
|
});
|
|
1256
1397
|
},
|
|
1398
|
+
steerTask(deviceId, taskId, attemptId, text) {
|
|
1399
|
+
const entry = devices.get(deviceId);
|
|
1400
|
+
if (!entry ||
|
|
1401
|
+
entry.ws.readyState !== WebSocket.OPEN ||
|
|
1402
|
+
entry.tasks.get(taskId)?.attemptId !== attemptId ||
|
|
1403
|
+
entry.steerings.size >= RELAY_LIMITS.steerings)
|
|
1404
|
+
return Promise.resolve({ steered: false });
|
|
1405
|
+
const id = randomUUID();
|
|
1406
|
+
return new Promise((resolve) => {
|
|
1407
|
+
const finish = (steered) => {
|
|
1408
|
+
if (!entry.steerings.delete(id))
|
|
1409
|
+
return;
|
|
1410
|
+
clearTimeout(timer);
|
|
1411
|
+
resolve({ steered });
|
|
1412
|
+
};
|
|
1413
|
+
const timer = setTimeout(() => finish(false), 10_000);
|
|
1414
|
+
timer.unref();
|
|
1415
|
+
entry.steerings.set(id, { taskId, attemptId, finish });
|
|
1416
|
+
if (!sendFrame(entry.ws, { type: "task_steer", id, taskId, attemptId, text }))
|
|
1417
|
+
finish(false);
|
|
1418
|
+
});
|
|
1419
|
+
},
|
|
1257
1420
|
callDevice(id, action, payload, options) {
|
|
1258
1421
|
const entry = devices.get(id);
|
|
1259
1422
|
return entry ? entry.rpc.call(action, payload, options) : Promise.reject(new Error("Device offline"));
|
|
@@ -1288,6 +1451,8 @@ export function createDeviceRelay(options) {
|
|
|
1288
1451
|
attemptId: task.attemptId,
|
|
1289
1452
|
botId: task.botId,
|
|
1290
1453
|
hasLease: typeof task.leaseToken === "string" && !!task.leaseToken,
|
|
1454
|
+
leaseToken: task.leaseToken,
|
|
1455
|
+
leaseGeneration: task.leaseGeneration,
|
|
1291
1456
|
});
|
|
1292
1457
|
if (!sendFrame(entry.ws, { type: "task", task })) {
|
|
1293
1458
|
entry.tasks.delete(task.id);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { checkedUrl } from "./relay.js";
|
|
3
|
-
/** 16 KiB raw text remains below the authenticated 128 KiB JSON budget even after escaping. */
|
|
4
3
|
export async function uploadTaskReport(options) {
|
|
5
4
|
const { entry } = options;
|
|
6
5
|
const bytes = Buffer.from(options.text, "utf8");
|