pi-web-ui 0.117.0 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -2
- package/README.md +69 -138
- package/README.zh-CN.md +70 -179
- package/README.zh-TW.md +3 -1
- package/bin/device-hub-cli.mjs +147 -43
- package/bin/frp-manager.mjs +4 -80
- package/bin/hub-upgrade.mjs +561 -0
- package/bin/pi-device-hub.mjs +0 -1
- package/bin/pi-web-ui.mjs +56 -444
- package/deploy/nginx-subpath.conf +0 -33
- package/deploy/pi-web-ui.service +0 -20
- package/dist/server/agent-formatters.js +4 -38
- package/dist/server/agent-service-daemon.js +160 -374
- package/dist/server/agent-service.js +875 -2978
- package/dist/server/approval-audit.js +2 -23
- package/dist/server/approval-default-rules.js +0 -6
- package/dist/server/approval-rules.js +7 -105
- package/dist/server/ask-user-question-tool.js +1 -12
- package/dist/server/atomic-file.js +33 -5
- package/dist/server/attachment-store.js +0 -36
- package/dist/server/attachments.js +3 -112
- package/dist/server/auth-cookie.js +0 -21
- package/dist/server/bash-tool.js +1 -32
- package/dist/server/bg-servers.js +0 -96
- package/dist/server/browser-page-tool.js +11 -62
- package/dist/server/builtin-modules.js +7 -0
- package/dist/server/canvas/canvas-agent-tool.js +58 -47
- package/dist/server/canvas/canvas-cards.js +0 -14
- package/dist/server/canvas/canvas-dispatch.js +7 -4
- package/dist/server/canvas/canvas-orchestrator.js +167 -181
- package/dist/server/canvas/canvas-runtime-messages.js +30 -0
- package/dist/server/canvas/canvas-scheduled-task.js +0 -3
- package/dist/server/canvas/canvas-scheduler.js +5 -7
- package/dist/server/canvas/canvas-store.js +24 -35
- package/dist/server/canvas/canvas-validation.js +17 -14
- package/dist/server/canvas/canvas-workspace.js +26 -30
- package/dist/server/canvas/pstack-skills-data.js +0 -5
- package/dist/server/claim-files-tool.js +1 -15
- package/dist/server/claim-store.js +5 -49
- package/dist/server/client-id-utils.js +0 -16
- package/dist/server/client-state.js +6 -213
- package/dist/server/communicate-tool.js +0 -3
- package/dist/server/compact-context-tool.js +0 -30
- package/dist/server/compacted-history.js +0 -35
- package/dist/server/compaction-instructions.js +0 -13
- package/dist/server/compaction-markers.js +3 -76
- package/dist/server/compaction-state.js +0 -21
- package/dist/server/composer-drafts.js +0 -34
- package/dist/server/context-budget-runner.js +0 -11
- package/dist/server/context-budget.js +1 -70
- package/dist/server/context-evidence.js +0 -14
- package/dist/server/context-usage.js +0 -12
- package/dist/server/control-socket.js +4 -48
- package/dist/server/conversation-communication.js +0 -10
- package/dist/server/conversation-identity.js +0 -1
- package/dist/server/conversation-read-tool.js +0 -58
- package/dist/server/conversation-tool-names.js +0 -1
- package/dist/server/conversation-tool.js +0 -1
- package/dist/server/conversation-touches.js +4 -75
- package/dist/server/dangling-tools.js +0 -82
- package/dist/server/delegate-mode.js +0 -36
- package/dist/server/delegate-task.js +2 -28
- package/dist/server/device-center/approval-summary.js +0 -1
- package/dist/server/device-center/bot-catalog.js +0 -3
- package/dist/server/device-center/bot-execution.js +0 -8
- package/dist/server/device-center/bot-presets.js +0 -1
- package/dist/server/device-center/bots.js +0 -1
- package/dist/server/device-center/collab-service.js +1 -3
- package/dist/server/device-center/collab-tool.js +0 -10
- package/dist/server/device-center/connector.js +21 -11
- package/dist/server/device-center/delivery-authority.js +0 -3
- package/dist/server/device-center/delivery-subject.js +0 -1
- package/dist/server/device-center/desktop-linux.js +3 -15
- package/dist/server/device-center/desktop-native.js +1 -10
- package/dist/server/device-center/desktop-page.js +2 -3
- package/dist/server/device-center/desktop-setup.js +1 -3
- package/dist/server/device-center/desktop.js +1 -7
- package/dist/server/device-center/device-integration.js +1 -27
- package/dist/server/device-center/device-lan-access.js +403 -0
- package/dist/server/device-center/device-lan.js +484 -0
- package/dist/server/device-center/device-portals.js +0 -3
- package/dist/server/device-center/execution-failure.js +0 -2
- package/dist/server/device-center/execution-guides.js +0 -1
- package/dist/server/device-center/execution-instructions.js +0 -1
- package/dist/server/device-center/execution-settings.js +0 -1
- package/dist/server/device-center/execution-system-prompt.js +0 -3
- package/dist/server/device-center/execution-workspace.js +1 -4
- package/dist/server/device-center/executor.js +0 -27
- package/dist/server/device-center/file-sync-paths.js +0 -5
- package/dist/server/device-center/file-sync.js +0 -10
- package/dist/server/device-center/group-context-delta.js +0 -8
- package/dist/server/device-center/group-context-message.js +0 -14
- package/dist/server/device-center/group-context.js +0 -19
- package/dist/server/device-center/group-events.js +0 -2
- package/dist/server/device-center/group-plan-guard.js +1 -35
- package/dist/server/device-center/group-router-runtime.js +182 -0
- package/dist/server/device-center/group-router-worker.js +178 -0
- package/dist/server/device-center/group-router.js +359 -0
- package/dist/server/device-center/hub-auth.js +24 -2
- package/dist/server/device-center/hub-conversations.js +0 -12
- package/dist/server/device-center/hub-deliveries.js +0 -1
- package/dist/server/device-center/hub-integration.js +0 -8
- package/dist/server/device-center/hub-locks.js +1 -5
- package/dist/server/device-center/hub-mobile.js +147 -0
- package/dist/server/device-center/hub-orchestration.js +400 -0
- package/dist/server/device-center/hub-page.js +25 -7
- package/dist/server/device-center/hub-setup.js +0 -6
- package/dist/server/device-center/hub-transaction-log.js +0 -22
- package/dist/server/device-center/hub-upgrade.js +162 -0
- package/dist/server/device-center/hub-webhooks.js +1 -3
- package/dist/server/device-center/hub.js +210 -86
- package/dist/server/device-center/human-interaction.js +1 -4
- package/dist/server/device-center/integration-errors.js +0 -2
- package/dist/server/device-center/integration-verification.js +0 -2
- package/dist/server/device-center/local-hub.js +0 -2
- package/dist/server/device-center/local-publication.js +1 -8
- package/dist/server/device-center/local-verification-job.js +0 -2
- package/dist/server/device-center/local-verification.js +0 -1
- package/dist/server/device-center/local.js +267 -39
- package/dist/server/device-center/main.js +14 -1
- package/dist/server/device-center/mobile-notification-forwarder.js +292 -0
- package/dist/server/device-center/native-desktop/macos.js +0 -1
- package/dist/server/device-center/native-desktop/windows.js +0 -1
- package/dist/server/device-center/partition-log.js +0 -31
- package/dist/server/device-center/path-portal.js +42 -12
- package/dist/server/device-center/publication-journal.js +0 -7
- package/dist/server/device-center/publish-intent.js +0 -5
- package/dist/server/device-center/relay.js +85 -30
- package/dist/server/device-center/report-upload.js +0 -1
- package/dist/server/device-center/runtime.js +1 -18
- package/dist/server/device-center/store.js +13 -33
- package/dist/server/device-center/task-context-budget.js +0 -3
- package/dist/server/device-center/task-error.js +0 -1
- package/dist/server/device-center/task-journal.js +6 -23
- package/dist/server/device-center/task-outcome.js +0 -13
- package/dist/server/device-center/task-plan.js +0 -1
- package/dist/server/device-center/task-progress.js +0 -16
- package/dist/server/device-center/task-recovery.js +5 -88
- package/dist/server/device-center/task-report-outbox.js +0 -4
- package/dist/server/device-center/task-report.js +2 -10
- package/dist/server/device-center/task-scheduler.js +1 -35
- package/dist/server/device-center/task-settlement.js +0 -18
- package/dist/server/device-center/task-state.js +0 -12
- package/dist/server/device-center/task-workspace.js +0 -50
- package/dist/server/device-center/transfer-stream.js +5 -45
- package/dist/server/device-center/transfers.js +2 -10
- package/dist/server/device-center/verification-limits.js +0 -1
- package/dist/server/device-center/work-contract.js +1 -73
- package/dist/server/device-center/work-items.js +317 -0
- package/dist/server/device-center/workspaces.js +0 -1
- package/dist/server/dispatch-domain-handlers.js +190 -32
- package/dist/server/dispatch-plugin-handlers.js +2 -19
- package/dist/server/dsh/dsh-agent-service.js +69 -599
- package/dist/server/dsh/dsh-client.js +7 -111
- package/dist/server/dsh/dsh-market-service.js +4 -25
- package/dist/server/dsh/dsh-serialize.js +0 -49
- package/dist/server/dsh/dsh-sessions.js +0 -37
- package/dist/server/dsh/dsh-usage.js +0 -37
- package/dist/server/dsh/preset-clones.js +1 -65
- package/dist/server/dsh/runtime/custom-prompt.mjs +0 -14
- package/dist/server/dsh/runtime/goal-rpc.mjs +7 -176
- package/dist/server/dsh/runtime/launcher.mjs +2 -53
- package/dist/server/dsh/runtime/override.patch.yml +0 -29
- package/dist/server/dsh/runtime/runtime-root.mjs +0 -54
- package/dist/server/durable/durable-agent-service.js +5 -23
- package/dist/server/durable/durable-driver.js +12 -73
- package/dist/server/durable/durable-event-projector.js +1 -50
- package/dist/server/durable/durable-loader.js +0 -12
- package/dist/server/durable/durable-models.js +11 -80
- package/dist/server/durable/durable-storage.js +1 -17
- package/dist/server/durable/durable-tools.js +2 -20
- package/dist/server/durable/index.js +0 -3
- package/dist/server/edit-soft-tool.js +2 -81
- package/dist/server/engine-capabilities.js +0 -13
- package/dist/server/engine-catalog.js +74 -0
- package/dist/server/engine-cli.js +89 -0
- package/dist/server/engine-probe.js +35 -217
- package/dist/server/ensure-bash.js +2 -28
- package/dist/server/eval-tool.js +1 -50
- package/dist/server/evidence-tool-hooks.js +0 -2
- package/dist/server/file-archives.js +0 -10
- package/dist/server/file-save.js +1 -12
- package/dist/server/file-transfer-routes.js +0 -11
- package/dist/server/files-service.js +18 -271
- package/dist/server/global-loader.js +9 -89
- package/dist/server/goal-evidence.js +1 -35
- package/dist/server/goal-review-gate.js +0 -58
- package/dist/server/goal-service.js +19 -422
- package/dist/server/hashline-engine.js +8 -112
- package/dist/server/host-guard.js +0 -24
- package/dist/server/host-metrics.js +0 -6
- package/dist/server/http-proxy.js +1 -7
- package/dist/server/i18n.js +5 -72
- package/dist/server/icon-svg.js +0 -15
- package/dist/server/index.js +177 -680
- package/dist/server/json-utils.js +0 -12
- package/dist/server/launch-origin.js +0 -44
- package/dist/server/left-panel-running.js +0 -9
- package/dist/server/load-timing.js +1 -4
- package/dist/server/load-tools-tool.js +0 -20
- package/dist/server/locales.js +1 -46
- package/dist/server/lsp-tool.js +13 -126
- package/dist/server/managed.js +0 -48
- package/dist/server/marker-service.js +1 -22
- package/dist/server/markers/builtins/action.js +0 -19
- package/dist/server/markers/builtins/notify.js +1 -9
- package/dist/server/markers/builtins/rename.js +0 -13
- package/dist/server/markers/index.js +0 -3
- package/dist/server/markers/marker.js +0 -13
- package/dist/server/markers/registry.js +0 -3
- package/dist/server/markers/store.js +1 -12
- package/dist/server/market-service.js +7 -43
- package/dist/server/mcp-agent-tool.js +0 -10
- package/dist/server/mcp-bridge.js +6 -138
- package/dist/server/mcp-hot-reload.js +0 -25
- package/dist/server/mcp-manager.js +2 -44
- package/dist/server/mcp-oauth-login.js +0 -2
- package/dist/server/mcp-oauth-ui.js +1 -4
- package/dist/server/mcp-oauth.js +5 -79
- package/dist/server/mcp-project-runtime.js +0 -4
- package/dist/server/message-deletion.js +0 -2
- package/dist/server/message-entry-resolver.js +0 -8
- package/dist/server/message-window.js +0 -71
- package/dist/server/mobile-notification-events.js +16 -0
- package/dist/server/mobile-origin.js +79 -0
- package/dist/server/mobile-push.js +523 -0
- package/dist/server/model-admin.js +19 -358
- package/dist/server/model-enrich.js +0 -19
- package/dist/server/model-resolver.js +2 -61
- package/dist/server/native-cli-discovery.js +115 -0
- package/dist/server/native-cli-model.js +71 -0
- package/dist/server/native-cli-references.js +214 -0
- package/dist/server/native-cli-remote-cleanup.js +58 -0
- package/dist/server/native-cli-remote-files.js +282 -0
- package/dist/server/native-cli-routes.js +68 -0
- package/dist/server/native-cli-runtime.js +1 -0
- package/dist/server/native-cli-session-hooks.js +170 -0
- package/dist/server/native-cli-session.js +585 -0
- package/dist/server/native-cli-state.js +82 -0
- package/dist/server/native-cli.js +210 -0
- package/dist/server/net-guard.js +9 -71
- package/dist/server/office-parse.js +0 -50
- package/dist/server/orphan-manager.js +0 -18
- package/dist/server/patch-bash-process.js +0 -4
- package/dist/server/patch-executable-lookup.js +0 -77
- package/dist/server/patch-node-pty.js +3 -43
- package/dist/server/patch-remote-catalog.js +1 -32
- package/dist/server/patch-tool.js +0 -15
- package/dist/server/payload-limits.js +0 -5
- package/dist/server/pending-question.js +0 -5
- package/dist/server/permission-preset.js +4 -33
- package/dist/server/persona-chain.js +0 -26
- package/dist/server/pkg-info.js +1 -17
- package/dist/server/plan-manager.js +2 -49
- package/dist/server/plan-mode.js +0 -97
- package/dist/server/plan-update-tool.js +1 -15
- package/dist/server/plugin-api-catalog.js +6 -4
- package/dist/server/plugin-assets.js +1 -35
- package/dist/server/plugin-bundled.js +68 -0
- package/dist/server/plugin-catalog-sync.js +0 -37
- package/dist/server/plugin-catalog.js +13 -67
- package/dist/server/plugin-chat-attachments.js +0 -1
- package/dist/server/plugin-conversation-view.js +0 -20
- package/dist/server/plugin-dom.js +1 -23
- package/dist/server/plugin-facilities.js +4 -115
- package/dist/server/plugin-grants.js +2 -90
- package/dist/server/plugin-install-spec.js +0 -43
- package/dist/server/plugin-installer.js +34 -75
- package/dist/server/plugin-llm.js +4 -38
- package/dist/server/plugin-manifest-validate.js +0 -31
- package/dist/server/plugin-permissions.js +1 -24
- package/dist/server/plugin-project.js +7 -129
- package/dist/server/plugin-removal.js +1 -8
- package/dist/server/plugin-schedule.js +1 -38
- package/dist/server/plugin-secrets.js +3 -16
- package/dist/server/plugin-tool-guard.js +1 -28
- package/dist/server/plugin-ui-slots.js +0 -4
- package/dist/server/plugin-updater.js +15 -90
- package/dist/server/plugins.js +71 -619
- package/dist/server/present-files-tool.js +0 -57
- package/dist/server/preset-fields.js +9 -62
- package/dist/server/preset-plugin-dependencies.js +0 -2
- package/dist/server/preset-share.js +3 -172
- package/dist/server/process-utils.js +4 -80
- package/dist/server/prompt-assembler.js +2 -30
- package/dist/server/prompt-base-store.js +0 -47
- package/dist/server/prompt-composer.js +21 -98
- package/dist/server/prompt-templates.js +0 -2
- package/dist/server/protocol-version.js +1 -11
- package/dist/server/protocol.js +0 -5
- package/dist/server/queue-modes.js +0 -3
- package/dist/server/queue-utils.js +0 -40
- package/dist/server/quick-ask-context.js +384 -0
- package/dist/server/quick-ask-settings.js +34 -1
- package/dist/server/quick-ask.js +123 -27
- package/dist/server/read-tool.js +0 -65
- package/dist/server/reasoning-registry.js +1 -29
- package/dist/server/remote-cli-persistence.js +373 -0
- package/dist/server/remote-native-cli.js +78 -0
- package/dist/server/remote-ssh-service.js +481 -190
- package/dist/server/request-context.js +0 -9
- package/dist/server/resolve-global-sdk.js +0 -26
- package/dist/server/sandbox-data.js +0 -1
- package/dist/server/sandbox-engines.js +0 -1
- package/dist/server/sandbox-runtime-gate.js +0 -3
- package/dist/server/sandbox-service.js +0 -41
- package/dist/server/sandbox-tool.js +0 -20
- package/dist/server/schedule-agent-tool.js +2 -31
- package/dist/server/scheduler-tasks.js +3 -54
- package/dist/server/scm-commitmsg.js +0 -53
- package/dist/server/scm.js +3 -48
- package/dist/server/sdk-builtin-extensions.js +2 -29
- package/dist/server/sdk-origin.js +0 -45
- package/dist/server/serialize.js +2 -92
- package/dist/server/server-config.js +0 -11
- package/dist/server/session-branch.js +1 -87
- package/dist/server/session-list-scan.js +17 -25
- package/dist/server/session-open.js +2 -26
- package/dist/server/session-parser.js +1 -55
- package/dist/server/session-scan.js +1 -17
- package/dist/server/session-search.js +0 -56
- package/dist/server/settings-service.js +11 -126
- package/dist/server/setup-config.js +0 -2
- package/dist/server/setup-page.js +0 -9
- package/dist/server/skill-content-filler.js +0 -17
- package/dist/server/skill-discovery.js +5 -92
- package/dist/server/skill-maintenance.js +1 -28
- package/dist/server/skill-tool.js +0 -30
- package/dist/server/slash-commands.js +5 -50
- package/dist/server/soft-cap.js +0 -42
- package/dist/server/startup-banner.js +0 -8
- package/dist/server/subagent-handoff.js +0 -11
- package/dist/server/subagent-helpers.js +2 -17
- package/dist/server/subagent-notify.js +0 -19
- package/dist/server/subagent-security-gate.js +0 -50
- package/dist/server/subagent-task.js +0 -9
- package/dist/server/subagent-templates-hant.js +0 -10
- package/dist/server/subagent-templates.js +3 -103
- package/dist/server/subagents.js +1 -87
- package/dist/server/system-screenshot-windows.js +259 -0
- package/dist/server/system-screenshot.js +77 -0
- package/dist/server/tabs.js +3 -48
- package/dist/server/terminals.js +559 -586
- package/dist/server/text-quote.js +0 -12
- package/dist/server/text-sniff.js +2 -52
- package/dist/server/themes.js +2 -41
- package/dist/server/tool-approval.js +0 -47
- package/dist/server/tool-guards.js +0 -90
- package/dist/server/tool-host-factories.js +1 -16
- package/dist/server/tool-info.js +0 -13
- package/dist/server/tool-manager.js +1 -229
- package/dist/server/tool-overrides.js +1 -46
- package/dist/server/tool-prompt-overrides.js +1 -30
- package/dist/server/tool-prompts.js +0 -14
- package/dist/server/tool-signature.js +0 -25
- package/dist/server/transcript-prepare.js +1 -19
- package/dist/server/tts-routes.js +58 -0
- package/dist/server/tts-service.js +106 -0
- package/dist/server/tts-system.js +160 -0
- package/dist/server/turn-timing.js +0 -1
- package/dist/server/unauthorized-page.js +0 -8
- package/dist/server/universal/driver-base.js +2 -31
- package/dist/server/universal/drivers/claude-code.js +12 -172
- package/dist/server/universal/drivers/codex.js +12 -35
- package/dist/server/universal/drivers/mock-driver.js +1 -11
- package/dist/server/universal/index.js +0 -3
- package/dist/server/universal/session-store.js +4 -21
- package/dist/server/universal/universal-attachments.js +2 -36
- package/dist/server/universal/universal-service.js +5 -24
- package/dist/server/universal/universal-session.js +26 -148
- package/dist/server/universal/universal-types.js +0 -3
- package/dist/server/update-check.js +6 -182
- package/dist/server/uploads.js +4 -43
- package/dist/server/virtual-tui.js +2 -27
- package/dist/server/vision-bridge.js +0 -27
- package/dist/server/wait-subscription-scan.js +13 -115
- package/dist/server/webui-context.js +2 -87
- package/dist/server/workspace-handle.js +1 -56
- package/dist/server/workspace-snapshot.js +7 -113
- package/dist/server/worktree-service.js +2 -53
- package/dist/server/worktree-tool.js +0 -11
- package/dist/server/ws-client-id.js +0 -18
- package/dist/server/ws-pending-queue.js +0 -7
- package/dist/server/ws-unknown-types.js +0 -17
- package/docs/README.md +24 -17
- package/docs/architecture-plugins.md +37 -1
- package/docs/device-center.md +28 -2
- package/docs/device-desktop.md +3 -3
- package/docs/group-orchestration.md +142 -0
- package/docs/hub-upgrade-release-testing.md +46 -0
- package/extensions/webui.ts +3 -74
- package/package.json +7 -3
- package/plugin-sdk/README.md +6 -0
- package/plugin-sdk/client-utils.mjs +0 -7
- package/plugin-sdk/client.d.ts +0 -1
- package/plugin-sdk/client.mjs +1 -31
- package/plugin-sdk/import-check.mjs +4 -51
- package/plugin-sdk/index.d.ts +120 -119
- package/plugin-sdk/index.mjs +0 -6
- package/plugin-sdk/ssh-host-trust.mjs +0 -12
- package/plugin-sdk/testing.d.ts +0 -1
- package/plugin-sdk/testing.mjs +31 -86
- package/plugins/catalog.json +52 -4
- package/plugins/superagent/README.md +110 -0
- package/plugins/superagent/client/entry.mjs +21 -0
- package/plugins/superagent/index.mjs +8 -0
- package/plugins/superagent/main.mjs +218 -0
- package/plugins/superagent/manifest.json +15 -0
- package/plugins/superagent/server.mjs +572 -0
- package/plugins/superagent/style.css +167 -0
- package/themes/aetheris.css +1 -31
- package/themes/ayu-light.css +0 -1
- package/themes/bases/flow-base.css +2 -83
- package/themes/bases/obsidian-base.css +2 -37
- package/themes/bases/statusbar-flat-base.css +0 -1
- package/themes/bases/zhujian-base.css +0 -63
- package/themes/bases/zhupi-base.css +0 -64
- package/themes/catppuccin-latte.css +0 -1
- package/themes/catppuccin.css +0 -1
- package/themes/claude-code-dark.css +0 -1
- package/themes/codex.css +0 -1
- package/themes/dark-teal.css +22 -54
- package/themes/everforest-light.css +0 -1
- package/themes/flow-cristallo.css +1 -9
- package/themes/flow-ink.css +1 -10
- package/themes/flow-light.css +1 -10
- package/themes/flow-obsidian.css +1 -10
- package/themes/flow-zurich.css +1 -10
- package/themes/flow.css +1 -9
- package/themes/geist.css +0 -1
- package/themes/gruvbox-light.css +0 -1
- package/themes/kanagawa-lotus.css +0 -1
- package/themes/md-preview.css +1 -2
- package/themes/mist.css +0 -1
- package/themes/nord.css +0 -1
- package/themes/one-dark.css +0 -1
- package/themes/paper.css +0 -1
- package/themes/rose-pine-dawn.css +0 -1
- package/themes/sakura.css +0 -1
- package/themes/solarized-light.css +0 -1
- package/themes/tokyo-night.css +0 -1
- package/themes/translucent.css +4 -35
- package/themes/transparent.css +4 -41
- package/themes/vs-code-dark.css +0 -1
- package/themes/wallpaper-flow.css +3 -17
- package/themes/wallpaper-obsidian.css +1 -4
- package/themes/white.css +0 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BjNRIUIc.js → BgTasksModal-D-x7kA63.js} +1 -1
- package/web/dist/assets/CanvasStudio-CAWcs9tm.js +1579 -0
- package/web/dist/assets/DeviceCenter-Dc0whRcu.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +1 -0
- package/web/dist/assets/DeviceGroups-C_fZMNeK.js +1 -0
- package/web/dist/assets/{Dropdown-CQtstPGv.js → Dropdown-CTgVLUbp.js} +1 -1
- package/web/dist/assets/FilePreview-C6W0PvaK.js +2 -0
- package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +1 -0
- package/web/dist/assets/GroupConversation-C81YjF2C.js +61 -0
- package/web/dist/assets/GroupWorkItems-BIvZtr10.js +1 -0
- package/web/dist/assets/{HintTip-ChTW8o1m.js → HintTip-Da6qc566.js} +1 -1
- package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +2 -0
- package/web/dist/assets/NativeCliPanel-CU1rZmyu.js +5 -0
- package/web/dist/assets/{PiSetupModal-BX5rUuoI.js → PiSetupModal-DZKY5Wiw.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
- package/web/dist/assets/{SCMPanel-DPAyY2sW.js → SCMPanel-CuEgzAlO.js} +2 -2
- package/web/dist/assets/SettingsModal-Cdu5h29p.js +33 -0
- package/web/dist/assets/TermXterm-Bt5WKAxP.js +3 -0
- package/web/dist/assets/TerminalPanel-BCIBV8se.js +1 -0
- package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +1 -0
- package/web/dist/assets/app-globals-CZjFtI4F.js +129 -0
- package/web/dist/assets/canvas-client-WkhM55mR.js +1 -0
- package/web/dist/assets/composer-bridge-CImnjDHq.js +1 -0
- package/web/dist/assets/desktop-B8NZ3KW-.js +1 -0
- package/web/dist/assets/index-CQc3VrWa.css +1 -0
- package/web/dist/assets/index-D_AGu4Zv.js +404 -0
- package/web/dist/assets/plugin-host-uqZGpvCs.js +1 -0
- package/web/dist/assets/{remote-ssh-client-Dzi-eEyE.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
- package/web/dist/assets/theme-DGL7hLUs.js +1 -0
- package/web/dist/index.html +11 -10
- package/web/dist/sw.js +15 -61
- package/web/public/sw.js +14 -60
- package/web/dist/assets/BgTasksModal-C0zuU8FE.js +0 -1
- package/web/dist/assets/CanvasStudio-BWvdmJ0M.js +0 -1579
- package/web/dist/assets/CanvasStudio-VQFjmTGq.js +0 -1579
- package/web/dist/assets/DeviceCenter-DI9_0aBB.js +0 -3
- package/web/dist/assets/DeviceCenter-DsNtXqzY.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-BLP1Su5G.js +0 -1
- package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +0 -1
- package/web/dist/assets/DeviceGroups-CP7CcyPD.js +0 -1
- package/web/dist/assets/FilePreview-BMB2tNyT.js +0 -2
- package/web/dist/assets/FilePreview-RGFQUbJo.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BM5wxiqU.js +0 -1
- package/web/dist/assets/GlobalSearchModal-DGv_WINq.js +0 -1
- package/web/dist/assets/GroupConversation-B7SnuXj1.js +0 -61
- package/web/dist/assets/GroupConversation-Dda69q-2.js +0 -61
- package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +0 -2
- package/web/dist/assets/ModelConfigModal-yqeadyab.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-DY4SCfXg.js +0 -1
- package/web/dist/assets/SCMPanel-C4KbQvvK.js +0 -2
- package/web/dist/assets/SettingsModal-DxZp6D_g.js +0 -32
- package/web/dist/assets/SettingsModal-WhQzaOPt.js +0 -32
- package/web/dist/assets/TerminalPanel-D4By_RVc.js +0 -3
- package/web/dist/assets/TerminalPanel-lZw8-i3j.js +0 -3
- package/web/dist/assets/TuiOverlayModal-C3pAVuC8.js +0 -1
- package/web/dist/assets/TuiOverlayModal-D7_rEXcJ.js +0 -1
- package/web/dist/assets/app-globals-KqOVtmp1.js +0 -123
- package/web/dist/assets/canvas-client-BY6ojmle.js +0 -1
- package/web/dist/assets/desktop-CV6KKp9R.js +0 -1
- package/web/dist/assets/index-BawF7ZP5.js +0 -397
- package/web/dist/assets/index-BoGCoq5X.js +0 -397
- package/web/dist/assets/index-CVW9FoY2.css +0 -1
- package/web/dist/assets/plugin-host-Dn8Dd6SC.js +0 -1
- package/web/dist/assets/theme-D_bihpdN.js +0 -1
|
@@ -3,8 +3,8 @@ import { join } from "node:path";
|
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { sanitizeTextForJournal, sanitizeToolParameters } from "./task-progress.js";
|
|
5
5
|
export const MAX_JOURNAL_SEGMENT_ENTRIES = 50;
|
|
6
|
-
export const MAX_JOURNAL_SEGMENT_BYTES = 64 * 1024;
|
|
7
|
-
export const MAX_JOURNAL_RETAINED_SEGMENTS = 20;
|
|
6
|
+
export const MAX_JOURNAL_SEGMENT_BYTES = 64 * 1024;
|
|
7
|
+
export const MAX_JOURNAL_RETAINED_SEGMENTS = 20;
|
|
8
8
|
function sha256Hex(data) {
|
|
9
9
|
return createHash("sha256").update(data).digest("hex");
|
|
10
10
|
}
|
|
@@ -29,9 +29,7 @@ export function decodeJournalCursor(cursorStr) {
|
|
|
29
29
|
return { taskId: obj.taskId, attemptId: obj.attemptId, sequence: obj.sequence };
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
catch {
|
|
33
|
-
// invalid cursor
|
|
34
|
-
}
|
|
32
|
+
catch { }
|
|
35
33
|
return null;
|
|
36
34
|
}
|
|
37
35
|
async function writeAtomicAsync(filePath, content) {
|
|
@@ -49,9 +47,7 @@ async function writeAtomicAsync(filePath, content) {
|
|
|
49
47
|
export function createTaskJournalManager(baseDir) {
|
|
50
48
|
const rootDir = join(baseDir, "task-journals");
|
|
51
49
|
let closed = false;
|
|
52
|
-
// In-memory active task state cache to avoid repeated disk reads on progress loops
|
|
53
50
|
const activeTasks = new Map();
|
|
54
|
-
// Asynchronous serialization tail Promise per task
|
|
55
51
|
const taskLocks = new Map();
|
|
56
52
|
function taskDir(taskId) {
|
|
57
53
|
return join(rootDir, safeTaskDirName(taskId));
|
|
@@ -101,7 +97,6 @@ export function createTaskJournalManager(baseDir) {
|
|
|
101
97
|
await mkdir(dir, { recursive: true });
|
|
102
98
|
await writeAtomicAsync(join(dir, "meta.json"), JSON.stringify(meta, null, 2));
|
|
103
99
|
}
|
|
104
|
-
// Stat current active segment to track bytes and lines without full read
|
|
105
100
|
const segPath = join(dir, segmentFileName(meta.activeSegmentIndex));
|
|
106
101
|
let bytes = 0;
|
|
107
102
|
let lines = 0;
|
|
@@ -111,9 +106,7 @@ export function createTaskJournalManager(baseDir) {
|
|
|
111
106
|
const content = await readFile(segPath, "utf8");
|
|
112
107
|
lines = content.split("\n").filter((l) => l.trim().length > 0).length;
|
|
113
108
|
}
|
|
114
|
-
catch {
|
|
115
|
-
// Segment does not exist yet
|
|
116
|
-
}
|
|
109
|
+
catch { }
|
|
117
110
|
const state = {
|
|
118
111
|
meta,
|
|
119
112
|
currentSegBytes: bytes,
|
|
@@ -175,7 +168,6 @@ export function createTaskJournalManager(baseDir) {
|
|
|
175
168
|
const now = Date.now();
|
|
176
169
|
const timestamp = entryInput.timestamp || now;
|
|
177
170
|
const id = `${taskId}-${seq}`;
|
|
178
|
-
// Sanitize output, summary, reason, parameters
|
|
179
171
|
let sanitizedOutput;
|
|
180
172
|
if (typeof entryInput.output === "string") {
|
|
181
173
|
sanitizedOutput = sanitizeTextForJournal(entryInput.output).slice(0, 2048);
|
|
@@ -217,7 +209,6 @@ export function createTaskJournalManager(baseDir) {
|
|
|
217
209
|
};
|
|
218
210
|
const line = JSON.stringify(entry) + "\n";
|
|
219
211
|
const lineBytes = Buffer.byteLength(line, "utf8");
|
|
220
|
-
// Rotate segment if needed
|
|
221
212
|
if (taskState.currentSegLines >= MAX_JOURNAL_SEGMENT_ENTRIES ||
|
|
222
213
|
taskState.currentSegBytes + lineBytes >= MAX_JOURNAL_SEGMENT_BYTES) {
|
|
223
214
|
meta.activeSegmentIndex++;
|
|
@@ -226,13 +217,11 @@ export function createTaskJournalManager(baseDir) {
|
|
|
226
217
|
taskState.currentSegLines = 0;
|
|
227
218
|
}
|
|
228
219
|
const segPath = join(dir, segmentFileName(meta.activeSegmentIndex));
|
|
229
|
-
// Direct non-blocking append to file, no full segment rewrite
|
|
230
220
|
await appendFile(segPath, line, "utf8");
|
|
231
221
|
taskState.currentSegBytes += lineBytes;
|
|
232
222
|
taskState.currentSegLines++;
|
|
233
223
|
meta.totalEvents++;
|
|
234
224
|
meta.updatedAt = now;
|
|
235
|
-
// Segment bound pruning
|
|
236
225
|
if (meta.segmentCount > MAX_JOURNAL_RETAINED_SEGMENTS) {
|
|
237
226
|
const files = (await readdir(dir)).filter((f) => f.startsWith("segment-") && f.endsWith(".jsonl")).sort();
|
|
238
227
|
if (files.length > MAX_JOURNAL_RETAINED_SEGMENTS) {
|
|
@@ -243,9 +232,7 @@ export function createTaskJournalManager(baseDir) {
|
|
|
243
232
|
meta.droppedCount += oldLines.length;
|
|
244
233
|
await unlink(join(dir, f));
|
|
245
234
|
}
|
|
246
|
-
catch {
|
|
247
|
-
// ignore
|
|
248
|
-
}
|
|
235
|
+
catch { }
|
|
249
236
|
}
|
|
250
237
|
meta.truncated = true;
|
|
251
238
|
const remaining = (await readdir(dir))
|
|
@@ -259,13 +246,10 @@ export function createTaskJournalManager(baseDir) {
|
|
|
259
246
|
meta.minRetainedSequence = parsed.sequence;
|
|
260
247
|
}
|
|
261
248
|
}
|
|
262
|
-
catch {
|
|
263
|
-
// ignore
|
|
264
|
-
}
|
|
249
|
+
catch { }
|
|
265
250
|
}
|
|
266
251
|
}
|
|
267
252
|
}
|
|
268
|
-
// Asynchronous metadata atomic write
|
|
269
253
|
await writeAtomicAsync(join(dir, "meta.json"), JSON.stringify(meta, null, 2));
|
|
270
254
|
return entry;
|
|
271
255
|
});
|
|
@@ -323,7 +307,6 @@ export function createTaskJournalManager(baseDir) {
|
|
|
323
307
|
};
|
|
324
308
|
}
|
|
325
309
|
}
|
|
326
|
-
// Read retained segment entries asynchronously
|
|
327
310
|
const files = (await readdir(dir)).filter((f) => f.startsWith("segment-") && f.endsWith(".jsonl")).sort();
|
|
328
311
|
const allEntries = [];
|
|
329
312
|
let corrupted = false;
|
|
@@ -13,12 +13,6 @@ export function deepFreeze(obj) {
|
|
|
13
13
|
}
|
|
14
14
|
return obj;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Deterministically compute outcome fingerprint digest (first 16 hex chars of SHA-256).
|
|
18
|
-
* Pure function shared between Hub and Device endpoints to guarantee ACK binding.
|
|
19
|
-
* When artifactDigest or execution/artifact proof facts are provided, they are incorporated
|
|
20
|
-
* into the digest payload while preserving backward-compatibility for legacy 6-tuple payloads.
|
|
21
|
-
*/
|
|
22
16
|
export function computeOutcomeFingerprint(taskId, attemptId, status, report, error, reportMetadata, artifactDigest, executionCompleted, artifactProduced) {
|
|
23
17
|
const hasProofOrArtifact = artifactDigest !== undefined || executionCompleted !== undefined || artifactProduced !== undefined;
|
|
24
18
|
const payload = [
|
|
@@ -32,18 +26,12 @@ export function computeOutcomeFingerprint(taskId, attemptId, status, report, err
|
|
|
32
26
|
];
|
|
33
27
|
return createHash("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
|
|
34
28
|
}
|
|
35
|
-
/** Compatibility for outcomes persisted or sent by older devices. */
|
|
36
29
|
export function computeLegacyOutcomeFingerprint(taskId, attemptId, status, report, error, reportMetadata) {
|
|
37
30
|
return createHash("sha256")
|
|
38
31
|
.update(`${taskId}:${attemptId}:${status}:${report ?? ""}:${error ?? ""}${reportMetadata ? JSON.stringify(reportMetadata) : ""}`)
|
|
39
32
|
.digest("hex")
|
|
40
33
|
.slice(0, 16);
|
|
41
34
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Normalize raw outcome fields (bounding report length, sanitizing error, canonicalizing metadata,
|
|
44
|
-
* validating optional device artifact, and recording independent execution/artifact facts)
|
|
45
|
-
* and generate deterministic fingerprint.
|
|
46
|
-
*/
|
|
47
35
|
export function normalizeTaskOutcome(taskId, attemptId, outcome) {
|
|
48
36
|
const safeReport = outcome.report ? boundTaskReport(outcome.report) : undefined;
|
|
49
37
|
const safeError = outcome.error
|
|
@@ -56,7 +44,6 @@ export function normalizeTaskOutcome(taskId, attemptId, outcome) {
|
|
|
56
44
|
if (!res.valid) {
|
|
57
45
|
throw new Error(`Invalid device artifact: ${res.reason}`);
|
|
58
46
|
}
|
|
59
|
-
// Deep clone and freeze to prevent caller alias mutation from corrupting recorded evidence
|
|
60
47
|
validArtifact = deepFreeze(structuredClone(res.artifact));
|
|
61
48
|
}
|
|
62
49
|
if (outcome.executionCompleted !== undefined && typeof outcome.executionCompleted !== "boolean") {
|
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Filter out thought/reasoning fragments.
|
|
3
|
-
* Drops open or closed thought blocks entirely. If an open tag exists without closure,
|
|
4
|
-
* the trailing fragment is discarded to prevent streaming leaks.
|
|
5
|
-
*/
|
|
6
1
|
export function sanitizeTextForJournal(input) {
|
|
7
2
|
if (!input)
|
|
8
3
|
return "";
|
|
9
4
|
let text = input;
|
|
10
|
-
// Drop closed thought tags
|
|
11
5
|
text = text.replace(/<thought[\s\S]*?<\/thought>/gi, "");
|
|
12
6
|
text = text.replace(/<thinking[\s\S]*?<\/thinking>/gi, "");
|
|
13
|
-
// Drop unclosed trailing thought tags (streaming fragment)
|
|
14
7
|
text = text.replace(/<(thought|thinking)[\s\S]*$/gi, "");
|
|
15
|
-
// Drop credential/token patterns (best-effort defense in depth)
|
|
16
8
|
text = text.replace(/((?:bearer|token|key|secret|password|passwd|credential|auth|api[-_]?key)[\s:="']{1,4})([A-Za-z0-9_\-./+=]{8,})/gi, "$1[REDACTED]");
|
|
17
9
|
text = text.replace(/-----BEGIN[A-Z0-9\s_-]+PRIVATE KEY-----[\s\S]*?-----END[A-Z0-9\s_-]+PRIVATE KEY-----/gi, "[REDACTED PRIVATE KEY]");
|
|
18
10
|
return text.trim();
|
|
19
11
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Sanitize tool parameters into safe structural summaries.
|
|
22
|
-
* Never outputs raw commands, raw file contents, or raw sensitive file paths.
|
|
23
|
-
*/
|
|
24
12
|
export function sanitizeToolParameters(toolName, params) {
|
|
25
13
|
if (!params || typeof params !== "object" || Array.isArray(params))
|
|
26
14
|
return;
|
|
@@ -55,7 +43,6 @@ export function sanitizeToolParameters(toolName, params) {
|
|
|
55
43
|
}
|
|
56
44
|
}
|
|
57
45
|
else {
|
|
58
|
-
// Generic tool summary: count parameters without exposing unknown values
|
|
59
46
|
result.parameterCount = Object.keys(input).length;
|
|
60
47
|
result.action = `invoke_${toolName}`;
|
|
61
48
|
}
|
|
@@ -77,7 +64,6 @@ export function summarizeToolOutput(toolName, output, isError = false) {
|
|
|
77
64
|
}
|
|
78
65
|
return `[${toolName} completed: ${byteLen} bytes output]`;
|
|
79
66
|
}
|
|
80
|
-
/** Project tool lifecycle with strict parameter and credential redaction. */
|
|
81
67
|
export function projectToolLifecycle(value) {
|
|
82
68
|
if (!value || typeof value !== "object")
|
|
83
69
|
return;
|
|
@@ -100,7 +86,6 @@ export function projectToolLifecycle(value) {
|
|
|
100
86
|
lifecycle.parametersPreview = safeParams;
|
|
101
87
|
}
|
|
102
88
|
if (typeof val.output === "string") {
|
|
103
|
-
// Never leak raw read/bash/write outputs or environment secrets; emit safe structural summary
|
|
104
89
|
lifecycle.outputSnippet = summarizeToolOutput(val.toolName, val.output, phase === "failed");
|
|
105
90
|
}
|
|
106
91
|
if (typeof val.durationMs === "number" && Number.isFinite(val.durationMs) && val.durationMs >= 0) {
|
|
@@ -108,7 +93,6 @@ export function projectToolLifecycle(value) {
|
|
|
108
93
|
}
|
|
109
94
|
return lifecycle;
|
|
110
95
|
}
|
|
111
|
-
/** Project explicitly allowed fields; never spread tool arguments or approval payloads. */
|
|
112
96
|
export function projectTaskActivity(value) {
|
|
113
97
|
if (!value || typeof value !== "object")
|
|
114
98
|
return;
|
|
@@ -7,19 +7,17 @@ import { computeOutcomeFingerprint, computeLegacyOutcomeFingerprint, normalizeTa
|
|
|
7
7
|
import { validateDeviceArtifact } from "./work-contract.js";
|
|
8
8
|
export { computeOutcomeFingerprint, normalizeTaskOutcome };
|
|
9
9
|
export const TASK_QUARANTINE_LIMITS = { maxEntries: 128, maxTotalBytes: 2 * 1024 * 1024 };
|
|
10
|
-
/** Includes both outcome budgets, active leases and serialization overhead. */
|
|
11
10
|
export const TASK_RECOVERY_STATE_MAX_BYTES = 8 * 1024 * 1024;
|
|
12
11
|
export const TASK_RECOVERY_DEFAULTS = {
|
|
13
|
-
maxInactivityMs: 20 * 60 * 1000,
|
|
14
|
-
maxDurationMs: 0,
|
|
15
|
-
renewIntervalMs: 15 * 1000,
|
|
16
|
-
recoveryWindowMs: 60 * 1000,
|
|
12
|
+
maxInactivityMs: 20 * 60 * 1000,
|
|
13
|
+
maxDurationMs: 0,
|
|
14
|
+
renewIntervalMs: 15 * 1000,
|
|
15
|
+
recoveryWindowMs: 60 * 1000,
|
|
17
16
|
};
|
|
18
17
|
export const TASK_OUTBOX_LIMITS = {
|
|
19
18
|
maxEntries: 128,
|
|
20
|
-
maxTotalBytes: 2 * 1024 * 1024,
|
|
19
|
+
maxTotalBytes: 2 * 1024 * 1024,
|
|
21
20
|
};
|
|
22
|
-
// Reserve worst-case JSON escaping, artifact patchBase64, plus bounded identity and metadata overhead before execution.
|
|
23
21
|
export const TASK_ARTIFACT_WORST_CASE_BYTES = 256 * 1024;
|
|
24
22
|
export const TASK_OUTBOX_RESERVATION_BYTES = 6 * (TASK_REPORT_BYTES + TASK_OUTCOME_ERROR_BYTES) + 16 * 1024 + TASK_ARTIFACT_WORST_CASE_BYTES;
|
|
25
23
|
function validateOutboxItem(item, deviceId) {
|
|
@@ -71,13 +69,11 @@ function validateOutboxItem(item, deviceId) {
|
|
|
71
69
|
const hasProofOrArtifact = entry.artifact !== undefined || entry.executionCompleted !== undefined || entry.artifactProduced !== undefined;
|
|
72
70
|
const fingerprint = computeOutcomeFingerprint(entry.taskId, entry.attemptId, entry.status, entry.report, entry.error, entry.reportMetadata, entry.artifact?.digest, entry.executionCompleted, entry.artifactProduced);
|
|
73
71
|
if (hasProofOrArtifact) {
|
|
74
|
-
// 当有新字段时必须且只能匹配 canonical 指纹,禁止降级到旧指纹
|
|
75
72
|
if (entry.fingerprint !== undefined && entry.fingerprint !== fingerprint) {
|
|
76
73
|
throw new Error("Invalid outbox outcome fingerprint (proof bound artifact requires canonical fingerprint)");
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
else {
|
|
80
|
-
// 仅在无 artifact / proof 的旧项中允许 legacy 指纹
|
|
81
77
|
const legacyFingerprint = computeLegacyOutcomeFingerprint(entry.taskId, entry.attemptId, entry.status, entry.report, entry.error, entry.reportMetadata);
|
|
82
78
|
if (entry.fingerprint !== undefined &&
|
|
83
79
|
entry.fingerprint !== fingerprint &&
|
|
@@ -120,15 +116,6 @@ function validateLeaseItem(item, deviceId) {
|
|
|
120
116
|
}
|
|
121
117
|
return lease;
|
|
122
118
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Durable Task Recovery Manager:
|
|
125
|
-
* 1. Single unified versioned recovery state file for active leases & terminal outbox.
|
|
126
|
-
* 2. Atomic disk commit guarantees lease removal and terminal outcome entry happen in a single transaction.
|
|
127
|
-
* 3. Double-crash safe recovery: never blindly re-runs side effects; safely interrupts orphans and preserves outcomes.
|
|
128
|
-
* 4. Outcome immutability: identical retry is idempotent; conflicting outcome is strictly rejected.
|
|
129
|
-
* 5. ACK binding: strictly requires matching outcome fingerprint to clear outbox.
|
|
130
|
-
* 6. Hub fencing & isolation: leases carry leaseToken & generation into TaskOutboxEntry; entries are isolated per hubUrl.
|
|
131
|
-
*/
|
|
132
119
|
export class TaskRecoveryManager {
|
|
133
120
|
statePath;
|
|
134
121
|
legacyOutboxPath;
|
|
@@ -188,7 +175,6 @@ export class TaskRecoveryManager {
|
|
|
188
175
|
if (this.loadError) {
|
|
189
176
|
throw new Error("Outbox persistence blocked: corrupted storage was preserved");
|
|
190
177
|
}
|
|
191
|
-
// v2 prevents older readers from silently discarding archived terminal evidence.
|
|
192
178
|
const text = JSON.stringify({ ...state, version: 2, quarantine: state.quarantine ?? this.quarantine }, null, 2) + "\n";
|
|
193
179
|
if (Buffer.byteLength(text) > TASK_RECOVERY_STATE_MAX_BYTES)
|
|
194
180
|
throw new Error("Recovery state capacity exceeded; evidence retained");
|
|
@@ -198,7 +184,6 @@ export class TaskRecoveryManager {
|
|
|
198
184
|
if (!this.statePath)
|
|
199
185
|
return;
|
|
200
186
|
let loadedState = null;
|
|
201
|
-
// 1. Try reading the unified state file
|
|
202
187
|
try {
|
|
203
188
|
const raw = readFileSync(this.statePath, "utf8");
|
|
204
189
|
if (Buffer.byteLength(raw) > TASK_RECOVERY_STATE_MAX_BYTES)
|
|
@@ -267,7 +252,6 @@ export class TaskRecoveryManager {
|
|
|
267
252
|
outbox: validOutbox,
|
|
268
253
|
activeLeases: validLeases,
|
|
269
254
|
};
|
|
270
|
-
// Best-effort cleanup of any remaining legacy files
|
|
271
255
|
this.cleanupLegacyFiles();
|
|
272
256
|
}
|
|
273
257
|
catch (error) {
|
|
@@ -275,12 +259,10 @@ export class TaskRecoveryManager {
|
|
|
275
259
|
loadedState = null;
|
|
276
260
|
}
|
|
277
261
|
else {
|
|
278
|
-
// State file exists but is corrupted: FAIL CLOSED and forbid overwrites
|
|
279
262
|
this.loadError = true;
|
|
280
263
|
return;
|
|
281
264
|
}
|
|
282
265
|
}
|
|
283
|
-
// 2. If unified state does not exist, migrate from legacy 2 files if present
|
|
284
266
|
if (loadedState === null) {
|
|
285
267
|
let legacyOutbox = [];
|
|
286
268
|
let legacyLeases = [];
|
|
@@ -354,7 +336,6 @@ export class TaskRecoveryManager {
|
|
|
354
336
|
}
|
|
355
337
|
}
|
|
356
338
|
}
|
|
357
|
-
// Partition entries by hubUrl isolation
|
|
358
339
|
for (const entry of loadedState.outbox) {
|
|
359
340
|
if (this.matchesHub(entry.hubUrl)) {
|
|
360
341
|
this.outbox.set(entry.id, entry);
|
|
@@ -371,7 +352,6 @@ export class TaskRecoveryManager {
|
|
|
371
352
|
this.otherHubLeases.push(lease);
|
|
372
353
|
}
|
|
373
354
|
}
|
|
374
|
-
// 3. Crash detection: detect orphaned active leases for current hub from prior crash/restart
|
|
375
355
|
if (this.activeLeases.size > 0) {
|
|
376
356
|
const stored = Array.from(this.activeLeases.values());
|
|
377
357
|
const now = Date.now();
|
|
@@ -384,7 +364,6 @@ export class TaskRecoveryManager {
|
|
|
384
364
|
catch { }
|
|
385
365
|
const outboxKey = this.leaseKey(lease.taskId, lease.attemptId);
|
|
386
366
|
const existingOutbox = this.outbox.get(outboxKey);
|
|
387
|
-
// If outbox already has a terminal outcome, NEVER overwrite it!
|
|
388
367
|
if (!existingOutbox) {
|
|
389
368
|
const report = "Execution safely halted on device process restart to prevent duplicate side effects.";
|
|
390
369
|
const error = "Device process restarted during execution";
|
|
@@ -410,7 +389,6 @@ export class TaskRecoveryManager {
|
|
|
410
389
|
newOutboxEntries.push(outboxEntry);
|
|
411
390
|
}
|
|
412
391
|
}
|
|
413
|
-
// Atomic disk commit: empty activeLeases, augmented outbox in one shot, preserving other Hubs
|
|
414
392
|
const allOutbox = [...this.otherHubOutbox, ...Array.from(this.outbox.values()), ...newOutboxEntries];
|
|
415
393
|
const allLeases = [...this.otherHubLeases];
|
|
416
394
|
const nextState = {
|
|
@@ -427,18 +405,10 @@ export class TaskRecoveryManager {
|
|
|
427
405
|
this.activeLeases.clear();
|
|
428
406
|
}
|
|
429
407
|
}
|
|
430
|
-
/** Get list of orphaned tasks halted at process startup. */
|
|
431
408
|
getHaltedOrphans() {
|
|
432
409
|
return structuredClone(this.haltedOrphans);
|
|
433
410
|
}
|
|
434
|
-
/**
|
|
435
|
-
* Record a newly running task lease.
|
|
436
|
-
* Rejects if (taskId, attemptId) has already been finalized in Outbox.
|
|
437
|
-
* Rejects if an active lease is already registered for this task attempt.
|
|
438
|
-
* Validates inputs before persisting to disk to prevent state corruption.
|
|
439
|
-
*/
|
|
440
411
|
recordTaskStart(lease) {
|
|
441
|
-
// Strict pre-validation: reject invalid inputs BEFORE touching disk state
|
|
442
412
|
if (!lease ||
|
|
443
413
|
typeof lease !== "object" ||
|
|
444
414
|
typeof lease.taskId !== "string" ||
|
|
@@ -465,7 +435,6 @@ export class TaskRecoveryManager {
|
|
|
465
435
|
this.quarantine.some((item) => this.matchesHub(item.outcome.hubUrl) && item.outcome.id === key)) {
|
|
466
436
|
throw new Error(`Cannot start task: outcome for task ${lease.taskId} attempt ${lease.attemptId} already finalized in outbox`);
|
|
467
437
|
}
|
|
468
|
-
// Reject conflicting concurrent or prior attempts for the same taskId in active leases
|
|
469
438
|
for (const [existingKey, existingLease] of this.activeLeases) {
|
|
470
439
|
if (existingLease.taskId === lease.taskId) {
|
|
471
440
|
if (existingKey === key) {
|
|
@@ -503,9 +472,6 @@ export class TaskRecoveryManager {
|
|
|
503
472
|
this.activeLeases.set(key, record);
|
|
504
473
|
return structuredClone(record);
|
|
505
474
|
}
|
|
506
|
-
/**
|
|
507
|
-
* Record verified local activity (LLM streaming or tool invocation).
|
|
508
|
-
*/
|
|
509
475
|
recordActivity(taskId, attemptId) {
|
|
510
476
|
const record = this.activeLeases.get(this.leaseKey(taskId, attemptId));
|
|
511
477
|
if (!record)
|
|
@@ -513,9 +479,6 @@ export class TaskRecoveryManager {
|
|
|
513
479
|
record.lastActivityAt = Date.now();
|
|
514
480
|
return true;
|
|
515
481
|
}
|
|
516
|
-
/**
|
|
517
|
-
* Remove active lease when task ends locally.
|
|
518
|
-
*/
|
|
519
482
|
removeActiveLease(taskId, attemptId) {
|
|
520
483
|
const key = this.leaseKey(taskId, attemptId);
|
|
521
484
|
if (this.activeLeases.has(key)) {
|
|
@@ -533,23 +496,13 @@ export class TaskRecoveryManager {
|
|
|
533
496
|
this.activeLeases.delete(key);
|
|
534
497
|
}
|
|
535
498
|
}
|
|
536
|
-
/**
|
|
537
|
-
* Get an active lease by taskId and attemptId.
|
|
538
|
-
*/
|
|
539
499
|
getActiveLease(taskId, attemptId) {
|
|
540
500
|
const lease = this.activeLeases.get(this.leaseKey(taskId, attemptId));
|
|
541
501
|
return lease ? structuredClone(lease) : undefined;
|
|
542
502
|
}
|
|
543
|
-
/**
|
|
544
|
-
* Get all active leases for current Hub (used for reconnection claim).
|
|
545
|
-
*/
|
|
546
503
|
getActiveLeases() {
|
|
547
504
|
return structuredClone(Array.from(this.activeLeases.values()));
|
|
548
505
|
}
|
|
549
|
-
/**
|
|
550
|
-
* Prepare claim payload for all running tasks upon reconnection.
|
|
551
|
-
* Strictly isolated to current Hub.
|
|
552
|
-
*/
|
|
553
506
|
prepareClaims() {
|
|
554
507
|
const claims = [];
|
|
555
508
|
for (const lease of this.activeLeases.values()) {
|
|
@@ -563,10 +516,6 @@ export class TaskRecoveryManager {
|
|
|
563
516
|
}
|
|
564
517
|
return claims;
|
|
565
518
|
}
|
|
566
|
-
/**
|
|
567
|
-
* Prepare heartbeat renewal frames for tasks with verified recent activity.
|
|
568
|
-
* monotonic activity progression: only true if new activity occurred since last renewal.
|
|
569
|
-
*/
|
|
570
519
|
prepareLeaseRenews(options) {
|
|
571
520
|
const now = Date.now();
|
|
572
521
|
const renews = [];
|
|
@@ -593,9 +542,6 @@ export class TaskRecoveryManager {
|
|
|
593
542
|
}
|
|
594
543
|
return renews;
|
|
595
544
|
}
|
|
596
|
-
/**
|
|
597
|
-
* Check whether a task has timed out due to inactivity or hard duration ceiling.
|
|
598
|
-
*/
|
|
599
545
|
checkTaskTimeout(taskId, attemptId, isWaitingHuman = false) {
|
|
600
546
|
const lease = this.activeLeases.get(this.leaseKey(taskId, attemptId));
|
|
601
547
|
if (!lease)
|
|
@@ -615,10 +561,6 @@ export class TaskRecoveryManager {
|
|
|
615
561
|
}
|
|
616
562
|
return { expired: false };
|
|
617
563
|
}
|
|
618
|
-
/**
|
|
619
|
-
* Bounded capacity reservation guard: fail-closed before starting new execution
|
|
620
|
-
* if the recovery outbox has reached its budget ceiling, preserving existing results.
|
|
621
|
-
*/
|
|
622
564
|
hasOutboxCapacity() {
|
|
623
565
|
const reservations = this.activeLeases.size + this.otherHubLeases.length;
|
|
624
566
|
const totalEntries = this.outbox.size + this.otherHubOutbox.length + reservations;
|
|
@@ -643,12 +585,6 @@ export class TaskRecoveryManager {
|
|
|
643
585
|
}
|
|
644
586
|
return { available: true };
|
|
645
587
|
}
|
|
646
|
-
/**
|
|
647
|
-
* Enqueue task terminal outcome into durable outbox.
|
|
648
|
-
* Atomically writes to unified state file and removes active lease in a single transaction.
|
|
649
|
-
* Enforces outcome immutability: identical outcome is idempotent; conflicting outcome is rejected.
|
|
650
|
-
* Carries leaseToken & leaseGeneration for Hub fencing.
|
|
651
|
-
*/
|
|
652
588
|
recordTaskFinish(task, outcome) {
|
|
653
589
|
if (!task ||
|
|
654
590
|
typeof task !== "object" ||
|
|
@@ -678,8 +614,6 @@ export class TaskRecoveryManager {
|
|
|
678
614
|
this.quarantine.find((item) => this.matchesHub(item.outcome.hubUrl) && item.outcome.id === key)?.outcome;
|
|
679
615
|
if (existing) {
|
|
680
616
|
const targetDeviceId = task.deviceId || this.deviceId;
|
|
681
|
-
// Strict immutability: identical retry is idempotent; conflicting outcome is rejected.
|
|
682
|
-
// Lease fields must also be identical to prevent cross-generation outcome aliasing.
|
|
683
617
|
const leaseTokenMatches = leaseToken === undefined || existing.leaseToken === leaseToken;
|
|
684
618
|
const leaseGenMatches = leaseGeneration === undefined || existing.leaseGeneration === leaseGeneration;
|
|
685
619
|
const artifactMatches = existing.artifact?.digest === normalized.artifact?.digest;
|
|
@@ -734,7 +668,6 @@ export class TaskRecoveryManager {
|
|
|
734
668
|
activeLease.leaseToken !== leaseToken ||
|
|
735
669
|
activeLease.leaseGeneration !== leaseGeneration))
|
|
736
670
|
throw new Error("Task outcome lease identity mismatch");
|
|
737
|
-
// Transactional commit: add outbox and remove active lease atomically in unified state
|
|
738
671
|
const nextOutbox = [...Array.from(this.outbox.values()), entry];
|
|
739
672
|
const allPending = [...this.otherHubOutbox, ...nextOutbox];
|
|
740
673
|
if (allPending.length > TASK_OUTBOX_LIMITS.maxEntries ||
|
|
@@ -752,27 +685,17 @@ export class TaskRecoveryManager {
|
|
|
752
685
|
activeLeases: allLeases,
|
|
753
686
|
};
|
|
754
687
|
this.writeStateToDiskSync(state);
|
|
755
|
-
// Disk succeeded; update memory
|
|
756
688
|
this.outbox.set(entry.id, entry);
|
|
757
689
|
this.activeLeases.delete(key);
|
|
758
690
|
return structuredClone(entry);
|
|
759
691
|
}
|
|
760
|
-
/**
|
|
761
|
-
* List all pending outbox entries waiting for Hub ACK for the current Hub.
|
|
762
|
-
*/
|
|
763
692
|
getPendingOutbox() {
|
|
764
693
|
return structuredClone(Array.from(this.outbox.values()));
|
|
765
694
|
}
|
|
766
|
-
/**
|
|
767
|
-
* Find a pending outbox entry by taskId and attemptId.
|
|
768
|
-
*/
|
|
769
695
|
getPendingOutboxEntry(taskId, attemptId) {
|
|
770
696
|
const entry = this.outbox.get(this.leaseKey(taskId, attemptId));
|
|
771
697
|
return entry ? structuredClone(entry) : undefined;
|
|
772
698
|
}
|
|
773
|
-
/**
|
|
774
|
-
* Mark attempt sent to Hub for backoff/tracking.
|
|
775
|
-
*/
|
|
776
699
|
markOutboxAttempt(id) {
|
|
777
700
|
const entry = this.outbox.get(id);
|
|
778
701
|
if (entry) {
|
|
@@ -791,7 +714,6 @@ export class TaskRecoveryManager {
|
|
|
791
714
|
this.outbox.set(id, updated);
|
|
792
715
|
}
|
|
793
716
|
}
|
|
794
|
-
/** Durable rejected evidence remains inspectable and never participates in automatic replay. */
|
|
795
717
|
getQuarantinedOutcomes() {
|
|
796
718
|
return structuredClone(this.quarantine.filter((item) => this.matchesHub(item.outcome.hubUrl)));
|
|
797
719
|
}
|
|
@@ -819,7 +741,6 @@ export class TaskRecoveryManager {
|
|
|
819
741
|
if (next.length > TASK_QUARANTINE_LIMITS.maxEntries ||
|
|
820
742
|
Buffer.byteLength(JSON.stringify(next)) > TASK_QUARANTINE_LIMITS.maxTotalBytes)
|
|
821
743
|
return false;
|
|
822
|
-
// Commit archive + removal together. Keep all active leases and other hubs intact.
|
|
823
744
|
this.writeStateToDiskSync({
|
|
824
745
|
version: 2,
|
|
825
746
|
deviceId: this.deviceId,
|
|
@@ -832,10 +753,6 @@ export class TaskRecoveryManager {
|
|
|
832
753
|
this.outbox.delete(key);
|
|
833
754
|
return true;
|
|
834
755
|
}
|
|
835
|
-
/**
|
|
836
|
-
* Acknowledge outbox entry upon receiving task_result_ack from Hub.
|
|
837
|
-
* Strictly requires matching outcome fingerprint; rejects clearing without or with mismatched fingerprint.
|
|
838
|
-
*/
|
|
839
756
|
ackOutbox(taskId, attemptId, fingerprint, extra) {
|
|
840
757
|
const key = this.leaseKey(taskId, attemptId);
|
|
841
758
|
const entry = this.outbox.get(key);
|
|
@@ -54,11 +54,9 @@ function validEntry(value) {
|
|
|
54
54
|
(!e.uploadPending || (!e.rejected && !!e.sha256 && e.totalBytes <= MAX_TASK_FULL_REPORT_BYTES)) &&
|
|
55
55
|
(e.rejected || e.missing || (!!e.sha256 && !!e.reportRef)));
|
|
56
56
|
}
|
|
57
|
-
/** Separate from terminal-result ACKs: a result never acknowledges report bytes. */
|
|
58
57
|
export function createTaskReportOutbox(dataDir, deviceId, hubUrl = "") {
|
|
59
58
|
const scope = { deviceId, hubUrl: hubUrl ? checkedUrl(hubUrl).href.replace(/\/$/, "") : "" };
|
|
60
59
|
const scopeKey = createHash("sha256").update(JSON.stringify(scope)).digest("hex").slice(0, 32);
|
|
61
|
-
// Scope both the queue and report bytes, so rebinding never replays another Hub's reports.
|
|
62
60
|
const scopedDir = dataDir ? join(dataDir, "task-report-outboxes", scopeKey) : undefined;
|
|
63
61
|
const store = scopedDir ? createTaskReportStore(scopedDir, "device") : undefined;
|
|
64
62
|
const file = scopedDir ? join(scopedDir, "outbox.json") : undefined;
|
|
@@ -101,7 +99,6 @@ export function createTaskReportOutbox(dataDir, deviceId, hubUrl = "") {
|
|
|
101
99
|
}
|
|
102
100
|
if (next.length > REPORT_OUTBOX_MAX_ENTRIES || bytes(next) > REPORT_OUTBOX_MAX_BYTES)
|
|
103
101
|
throw new Error("Report outbox capacity exceeded; pending reports retained");
|
|
104
|
-
// Delete bytes before dropping their registry entry; a failed cleanup stays discoverable.
|
|
105
102
|
for (const old of removed) {
|
|
106
103
|
store?.removeReport(old.id, old.attemptId, deviceId, old.roomId);
|
|
107
104
|
memory.delete(key(old));
|
|
@@ -136,7 +133,6 @@ export function createTaskReportOutbox(dataDir, deviceId, hubUrl = "") {
|
|
|
136
133
|
rejected: true,
|
|
137
134
|
lastError: "Report exceeds 4 MiB quota",
|
|
138
135
|
});
|
|
139
|
-
// Commit intent first; recovery can read the store if interrupted after its atomic write.
|
|
140
136
|
update({
|
|
141
137
|
...task,
|
|
142
138
|
reportRef: store
|
|
@@ -3,9 +3,8 @@ import { join } from "node:path";
|
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { writeAtomicSync, writeJsonAtomicSync } from "../atomic-file.js";
|
|
5
5
|
export const TASK_REPORT_BYTES = 16 * 1024;
|
|
6
|
-
export const MAX_TASK_FULL_REPORT_BYTES = 4 * 1024 * 1024;
|
|
7
|
-
export const MAX_TASK_REPORT_CHUNK_BYTES = 64 * 1024;
|
|
8
|
-
/** Keep the opening context and final conclusions within the wire report budget. */
|
|
6
|
+
export const MAX_TASK_FULL_REPORT_BYTES = 4 * 1024 * 1024;
|
|
7
|
+
export const MAX_TASK_REPORT_CHUNK_BYTES = 64 * 1024;
|
|
9
8
|
export function boundTaskReport(text, limit = TASK_REPORT_BYTES) {
|
|
10
9
|
const bytes = Buffer.from(text, "utf8");
|
|
11
10
|
if (bytes.length <= limit)
|
|
@@ -16,7 +15,6 @@ export function boundTaskReport(text, limit = TASK_REPORT_BYTES) {
|
|
|
16
15
|
const budget = limit - Buffer.byteLength(marker);
|
|
17
16
|
let start = Math.floor(budget / 2);
|
|
18
17
|
let end = bytes.length - (budget - start);
|
|
19
|
-
// UTF-8 continuation bytes cannot begin either retained boundary.
|
|
20
18
|
while (start > 0 && (bytes[start] & 0xc0) === 0x80)
|
|
21
19
|
start--;
|
|
22
20
|
while (end < bytes.length && (bytes[end] & 0xc0) === 0x80)
|
|
@@ -87,7 +85,6 @@ export function createTaskReportStore(baseDir, role = "hub") {
|
|
|
87
85
|
return existing;
|
|
88
86
|
throw new TaskReportConflictError("Completed task report cannot be overwritten");
|
|
89
87
|
}
|
|
90
|
-
// Pre-flight quota check before writing any bytes to disk
|
|
91
88
|
if (bytes > quotaLimit) {
|
|
92
89
|
mkdirSync(dir, { recursive: true });
|
|
93
90
|
const meta = {
|
|
@@ -161,7 +158,6 @@ export function createTaskReportStore(baseDir, role = "hub") {
|
|
|
161
158
|
throw new Error("Account or room mismatch for report binding");
|
|
162
159
|
}
|
|
163
160
|
if (existing.complete) {
|
|
164
|
-
// Check idempotence
|
|
165
161
|
const chunkFile = join(chunksDir, `chunk-${String(chunkIndex).padStart(4, "0")}.txt`);
|
|
166
162
|
if (existsSync(chunkFile)) {
|
|
167
163
|
const prev = readFileSync(chunkFile, "utf8");
|
|
@@ -174,14 +170,12 @@ export function createTaskReportStore(baseDir, role = "hub") {
|
|
|
174
170
|
throw new TaskReportQuotaError("Task report was already rejected due to quota overflow", existing.totalBytes, quotaLimit);
|
|
175
171
|
}
|
|
176
172
|
}
|
|
177
|
-
// Pre-flight check cumulative bytes with new chunk before disk write
|
|
178
173
|
mkdirSync(chunksDir, { recursive: true });
|
|
179
174
|
const chunkFile = join(chunksDir, `chunk-${String(chunkIndex).padStart(4, "0")}.txt`);
|
|
180
175
|
if (existsSync(chunkFile)) {
|
|
181
176
|
const existingText = readFileSync(chunkFile, "utf8");
|
|
182
177
|
if (sha256Hex(existingText) !== chunkHash)
|
|
183
178
|
throw new TaskReportConflictError(`Conflicting content for chunk ${chunkIndex}`);
|
|
184
|
-
// Rebuild metadata below: a process may have stopped after writing the chunk.
|
|
185
179
|
}
|
|
186
180
|
let currentAccumulated = 0;
|
|
187
181
|
const chunkFiles = readdirSync(chunksDir).filter((f) => f.startsWith("chunk-") && f.endsWith(".txt"));
|
|
@@ -209,9 +203,7 @@ export function createTaskReportStore(baseDir, role = "hub") {
|
|
|
209
203
|
writeJsonAtomicSync(join(dir, "report-meta.json"), meta);
|
|
210
204
|
throw new TaskReportQuotaError(`Accumulated report chunks exceed quota (${currentAccumulated + chunkBytes} > ${quotaLimit})`, currentAccumulated + chunkBytes, quotaLimit);
|
|
211
205
|
}
|
|
212
|
-
// Safe atomic write chunk
|
|
213
206
|
writeAtomicSync(chunkFile, text);
|
|
214
|
-
// Count all chunks
|
|
215
207
|
const allChunkFiles = readdirSync(chunksDir)
|
|
216
208
|
.filter((f) => f.startsWith("chunk-") && f.endsWith(".txt"))
|
|
217
209
|
.sort();
|