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
package/bin/device-hub-cli.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/** Standalone Hub lifecycle. Only Node built-ins; never imports the main CLI or agent SDK. */
|
|
2
1
|
import { spawnSync } from "node:child_process";
|
|
3
2
|
import { randomUUID } from "node:crypto";
|
|
4
3
|
import { createServer } from "node:net";
|
|
5
4
|
import { request } from "node:http";
|
|
6
5
|
import {
|
|
7
6
|
mkdirSync,
|
|
7
|
+
appendFileSync,
|
|
8
8
|
readFileSync,
|
|
9
9
|
writeFileSync,
|
|
10
10
|
renameSync,
|
|
@@ -15,14 +15,16 @@ import {
|
|
|
15
15
|
} from "node:fs";
|
|
16
16
|
import { homedir, hostname } from "node:os";
|
|
17
17
|
import { setTimeout as delay, setImmediate as yieldImmediate } from "node:timers/promises";
|
|
18
|
-
import { join, resolve } from "node:path";
|
|
18
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
19
19
|
import { fileURLToPath } from "node:url";
|
|
20
20
|
|
|
21
|
-
export const HUB_HELP = `Usage: pi-web-ui hub [install|start|stop|restart|status|uninstall] [options]
|
|
21
|
+
export const HUB_HELP = `Usage: pi-web-ui hub [install|start|stop|restart|status|uninstall|update] [options]
|
|
22
22
|
Without a command, run in the foreground (Ctrl+C to stop).
|
|
23
23
|
Options: --host HOST --port PORT --public-url URL --data-dir PATH
|
|
24
24
|
--allow-registration[=true|false] --help
|
|
25
25
|
install saves configuration, enables login autostart and starts the Hub.
|
|
26
|
+
update installs the latest Hub package in a managed release directory, restarts and verifies it.
|
|
27
|
+
If the new release cannot start, the previous service definition is restored.
|
|
26
28
|
Other lifecycle commands use the saved configuration; status accepts --json.
|
|
27
29
|
Close registration after the first account: hub restart --allow-registration=false
|
|
28
30
|
Only that saved setting changes; all other settings are retained.
|
|
@@ -31,16 +33,15 @@ Service: systemd --user (Linux), launchd user agent (macOS), logon scheduled tas
|
|
|
31
33
|
Linux boot without login requires an administrator to enable linger for your user.
|
|
32
34
|
uninstall stops and removes the service; Hub account/device data is retained.`;
|
|
33
35
|
const ENTRY = fileURLToPath(new URL("./pi-device-hub.mjs", import.meta.url));
|
|
34
|
-
const LABEL = "com.xingshuyin.pi-device-hub";
|
|
35
36
|
const TASK = "pi-device-hub";
|
|
36
37
|
const UNIT = "pi-device-hub.service";
|
|
37
38
|
const flags = { "--host": "HOST", "--port": "PORT", "--public-url": "PUBLIC_URL", "--data-dir": "DATA_DIR" };
|
|
38
|
-
const optionalEnv = ["DEVICE_DOMAIN", "PATH_ACCESS", "PORTAL_PORTS"];
|
|
39
|
+
const optionalEnv = ["DEVICE_DOMAIN", "PATH_ACCESS", "PORTAL_PORTS", "UPDATE_SOURCE", "SERVICE_NAME"];
|
|
39
40
|
|
|
40
41
|
export function parseHubArgs(argv, env = process.env) {
|
|
41
42
|
const args = [...argv];
|
|
42
43
|
const command = args[0] && !args[0].startsWith("-") ? args.shift() : "foreground";
|
|
43
|
-
if (!["foreground", "install", "start", "stop", "restart", "status", "uninstall"].includes(command))
|
|
44
|
+
if (!["foreground", "install", "start", "stop", "restart", "status", "uninstall", "update"].includes(command))
|
|
44
45
|
throw new Error(`Unknown Hub command: ${command}`);
|
|
45
46
|
const values = {};
|
|
46
47
|
if (command === "status" && args.length === 1 && args[0] === "--json") return { command, json: true };
|
|
@@ -70,7 +71,6 @@ export function parseHubArgs(argv, env = process.env) {
|
|
|
70
71
|
settings.PI_DEVICE_HUB_HOST ??= "127.0.0.1";
|
|
71
72
|
settings.PI_DEVICE_HUB_PORT ??= "8790";
|
|
72
73
|
settings.PI_DEVICE_HUB_DATA_DIR = resolve(settings.PI_DEVICE_HUB_DATA_DIR ?? join(homedir(), ".pi-device-hub"));
|
|
73
|
-
// Installing must not inherit an accidentally enabled registration environment variable.
|
|
74
74
|
settings.PI_DEVICE_HUB_ALLOW_REGISTRATION =
|
|
75
75
|
values.ALLOW_REGISTRATION ?? (command === "foreground" && env.PI_DEVICE_HUB_ALLOW_REGISTRATION === "1" ? "1" : "0");
|
|
76
76
|
validateSettings(settings);
|
|
@@ -96,7 +96,6 @@ function validateSettings(settings) {
|
|
|
96
96
|
|
|
97
97
|
const xml = (s) =>
|
|
98
98
|
String(s).replace(/[<>&"']/g, (c) => ({ "<": "<", ">": ">", "&": "&", '"': """, "'": "'" })[c]);
|
|
99
|
-
// CommandLineToArgvW quoting, not shell quoting. Every argument is passed directly to node.exe.
|
|
100
99
|
export const windowsArg = (s) =>
|
|
101
100
|
`"${String(s)
|
|
102
101
|
.replace(/(\\*)"/g, '$1$1\\"')
|
|
@@ -117,16 +116,26 @@ export function hubServicePlan({
|
|
|
117
116
|
uid = process.getuid?.(),
|
|
118
117
|
user = env.USERNAME,
|
|
119
118
|
} = {}) {
|
|
119
|
+
const serviceName = env.PI_DEVICE_HUB_SERVICE_NAME || "pi-device-hub";
|
|
120
|
+
if (!/^pi-device-hub(?:-[a-z0-9-]{1,48})?$/.test(serviceName)) throw new Error("Invalid Hub service name");
|
|
121
|
+
const taskName = serviceName;
|
|
122
|
+
const unitName = `${serviceName}.service`;
|
|
123
|
+
const labelName = `com.xingshuyin.${serviceName}`;
|
|
120
124
|
const root =
|
|
121
125
|
platform === "win32"
|
|
122
|
-
? join(env.APPDATA || join(home, "AppData", "Roaming"),
|
|
123
|
-
: join(home, ".config",
|
|
126
|
+
? join(env.APPDATA || join(home, "AppData", "Roaming"), `${serviceName}-cli`)
|
|
127
|
+
: join(home, ".config", `${serviceName}-cli`);
|
|
124
128
|
const config = join(root, "service.json");
|
|
125
129
|
const args = [entry, "--service-config", config];
|
|
130
|
+
const serviceOptions = { platform, home, env, node, uid, user };
|
|
131
|
+
const UNIT = unitName,
|
|
132
|
+
TASK = taskName,
|
|
133
|
+
LABEL = labelName;
|
|
126
134
|
if (platform === "linux")
|
|
127
135
|
return {
|
|
128
136
|
root,
|
|
129
137
|
config,
|
|
138
|
+
serviceOptions,
|
|
130
139
|
file: join(home, ".config", "systemd", "user", UNIT),
|
|
131
140
|
content: `[Unit]\nDescription=pi device Hub\nAfter=network.target\n\n[Service]\nExecStart=${[node, ...args].map(systemdArg).join(" ")}\nRestart=on-failure\nRestartSec=5\n\n[Install]\nWantedBy=default.target\n`,
|
|
132
141
|
manager: "systemctl",
|
|
@@ -138,6 +147,10 @@ export function hubServicePlan({
|
|
|
138
147
|
start: [["--user", "start", UNIT]],
|
|
139
148
|
stop: [["--user", "stop", UNIT]],
|
|
140
149
|
restart: [["--user", "restart", UNIT]],
|
|
150
|
+
update: [
|
|
151
|
+
["--user", "daemon-reload"],
|
|
152
|
+
["--user", "restart", UNIT],
|
|
153
|
+
],
|
|
141
154
|
status: [["--user", "show", UNIT, "--property=ActiveState,SubState,UnitFileState"]],
|
|
142
155
|
uninstall: [["--user", "disable", "--now", UNIT]],
|
|
143
156
|
},
|
|
@@ -149,6 +162,7 @@ export function hubServicePlan({
|
|
|
149
162
|
root,
|
|
150
163
|
config,
|
|
151
164
|
file,
|
|
165
|
+
serviceOptions,
|
|
152
166
|
content: `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0"><dict><key>Label</key><string>${LABEL}</string><key>ProgramArguments</key><array>${[node, ...args].map((s) => `<string>${xml(s)}</string>`).join("")}</array><key>RunAtLoad</key><true/><key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict><key>StandardOutPath</key><string>${xml(join(root, "stdout.log"))}</string><key>StandardErrorPath</key><string>${xml(join(root, "stderr.log"))}</string></dict></plist>\n`,
|
|
153
167
|
manager: "launchctl",
|
|
154
168
|
commands: {
|
|
@@ -159,6 +173,10 @@ export function hubServicePlan({
|
|
|
159
173
|
["bootout", target],
|
|
160
174
|
["bootstrap", `gui/${uid}`, file],
|
|
161
175
|
],
|
|
176
|
+
update: [
|
|
177
|
+
["bootout", target],
|
|
178
|
+
["bootstrap", `gui/${uid}`, file],
|
|
179
|
+
],
|
|
162
180
|
status: [["print", target]],
|
|
163
181
|
uninstall: [["bootout", target]],
|
|
164
182
|
},
|
|
@@ -170,6 +188,7 @@ export function hubServicePlan({
|
|
|
170
188
|
return {
|
|
171
189
|
root,
|
|
172
190
|
config,
|
|
191
|
+
serviceOptions,
|
|
173
192
|
file: join(root, "task.xml"),
|
|
174
193
|
content: `<?xml version="1.0" encoding="UTF-16"?>\n<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"><Triggers><LogonTrigger><Enabled>true</Enabled><UserId>${xml(identity)}</UserId></LogonTrigger></Triggers><Principals><Principal id="Author"><UserId>${xml(identity)}</UserId><LogonType>InteractiveToken</LogonType><RunLevel>LeastPrivilege</RunLevel></Principal></Principals><Settings><MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy><DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries><StopIfGoingOnBatteries>false</StopIfGoingOnBatteries><ExecutionTimeLimit>PT0S</ExecutionTimeLimit><RestartOnFailure><Interval>PT1M</Interval><Count>3</Count></RestartOnFailure></Settings><Actions Context="Author"><Exec><Command>${xml(node)}</Command><Arguments>${xml(args.map(windowsArg).join(" "))}</Arguments></Exec></Actions></Task>`,
|
|
175
194
|
manager: "schtasks.exe",
|
|
@@ -184,6 +203,11 @@ export function hubServicePlan({
|
|
|
184
203
|
["/End", "/TN", TASK],
|
|
185
204
|
["/Run", "/TN", TASK],
|
|
186
205
|
],
|
|
206
|
+
update: [
|
|
207
|
+
["/End", "/TN", TASK],
|
|
208
|
+
["/Create", "/TN", TASK, "/XML", join(root, "task.xml"), "/F"],
|
|
209
|
+
["/Run", "/TN", TASK],
|
|
210
|
+
],
|
|
187
211
|
status: [["/Query", "/TN", TASK, "/V", "/FO", "LIST"]],
|
|
188
212
|
uninstall: [
|
|
189
213
|
["/End", "/TN", TASK],
|
|
@@ -195,8 +219,6 @@ export function hubServicePlan({
|
|
|
195
219
|
throw new Error(`Unsupported Hub service platform: ${platform}`);
|
|
196
220
|
}
|
|
197
221
|
|
|
198
|
-
// One budget per composite native phase, rather than a fresh timeout per subprocess.
|
|
199
|
-
// SIGKILL prevents a timed-out native command from extending the runner's 45s grace.
|
|
200
222
|
function nativePhase(inspect, now) {
|
|
201
223
|
const deadline = now() + 30000;
|
|
202
224
|
return (file, args) => {
|
|
@@ -217,15 +239,16 @@ export function assertServiceAbsent(plan, inspect = spawnSync, now = () => perfo
|
|
|
217
239
|
const result = native(
|
|
218
240
|
plan.manager,
|
|
219
241
|
plan.manager === "systemctl"
|
|
220
|
-
? ["--user", "show", UNIT, "--property=LoadState", "--value"]
|
|
242
|
+
? ["--user", "show", plan.commands.status?.[0]?.[2] ?? UNIT, "--property=LoadState", "--value"]
|
|
221
243
|
: plan.commands.status[0],
|
|
222
244
|
);
|
|
223
245
|
if (result.error) throw result.error;
|
|
224
246
|
if (plan.manager === "systemctl" && result.status === 0 && result.stdout.trim() === "not-found") return;
|
|
225
247
|
if (plan.manager === "launchctl" && result.status !== 0 && /Could not find service/i.test(result.stderr)) return;
|
|
226
248
|
if (plan.manager === "schtasks.exe") {
|
|
227
|
-
|
|
228
|
-
const
|
|
249
|
+
const statusArgs = plan.commands.status?.[0];
|
|
250
|
+
const taskName = (statusArgs ? statusArgs[statusArgs.indexOf("/TN") + 1] : TASK).replace(/'/g, "''");
|
|
251
|
+
const script = `$s=New-Object -ComObject Schedule.Service; $s.Connect(); try { $null=$s.GetFolder('\\').GetTask('${taskName}'); exit 0 } catch { if ($_.Exception.HResult -eq -2147024894) { exit 3 }; exit 4 }`;
|
|
229
252
|
const check = native("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script]);
|
|
230
253
|
if (!check.error && check.status === 3) return;
|
|
231
254
|
}
|
|
@@ -280,6 +303,21 @@ export function probeHub(settings, signal) {
|
|
|
280
303
|
});
|
|
281
304
|
},
|
|
282
305
|
);
|
|
306
|
+
req.on("socket", (socket) => {
|
|
307
|
+
const rejectSelfConnection = () => {
|
|
308
|
+
// A client ephemeral port can equal the stopped Hub's port (TCP self-connect).
|
|
309
|
+
if (
|
|
310
|
+
socket.localPort &&
|
|
311
|
+
socket.localPort === socket.remotePort &&
|
|
312
|
+
socket.localAddress === socket.remoteAddress
|
|
313
|
+
) {
|
|
314
|
+
socket.once("close", () => done(null));
|
|
315
|
+
socket.resetAndDestroy();
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
if (socket.connecting) socket.once("connect", rejectSelfConnection);
|
|
319
|
+
else rejectSelfConnection();
|
|
320
|
+
});
|
|
283
321
|
req.on("timeout", () => req.destroy());
|
|
284
322
|
req.on("error", () => done(null));
|
|
285
323
|
req.end();
|
|
@@ -305,10 +343,16 @@ async function waitForHub(settings, signal) {
|
|
|
305
343
|
throw new Error("Hub did not become healthy within 15 seconds; service configuration retained for diagnosis");
|
|
306
344
|
}
|
|
307
345
|
|
|
308
|
-
export function runManager(
|
|
346
|
+
export function runManager(
|
|
347
|
+
file,
|
|
348
|
+
args,
|
|
349
|
+
inspect = spawnSync,
|
|
350
|
+
now = () => performance.now(),
|
|
351
|
+
pause = () => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 50),
|
|
352
|
+
) {
|
|
309
353
|
const native = nativePhase(inspect, now);
|
|
310
354
|
if (file === "launchctl" && ["bootout", "bootstrap"].includes(args[0])) {
|
|
311
|
-
const target = args[0] === "bootout" ? args[1] : `${args[1]}/${
|
|
355
|
+
const target = args[0] === "bootout" ? args[1] : `${args[1]}/${basename(args[2], ".plist")}`;
|
|
312
356
|
const state = native(file, ["print", target]);
|
|
313
357
|
if (state.error) throw state.error;
|
|
314
358
|
if (state.status === 0 && args[0] === "bootstrap") return "Hub is already loaded";
|
|
@@ -318,14 +362,15 @@ export function runManager(file, args, inspect = spawnSync, now = () => performa
|
|
|
318
362
|
if (args[0] === "bootout") return "Hub is already stopped";
|
|
319
363
|
}
|
|
320
364
|
}
|
|
321
|
-
// Ending an already stopped task is successful; scheduler errors still propagate.
|
|
322
365
|
if (file === "schtasks.exe" && args[0] === "/End") {
|
|
366
|
+
// Stop must also cancel queued instances; /Run with IgnoreNew can otherwise keep the old action.
|
|
367
|
+
const taskName = args[args.indexOf("/TN") + 1].replace(/'/g, "''");
|
|
323
368
|
file = "powershell.exe";
|
|
324
369
|
args = [
|
|
325
370
|
"-NoProfile",
|
|
326
371
|
"-NonInteractive",
|
|
327
372
|
"-Command",
|
|
328
|
-
`$ErrorActionPreference='Stop'; $s=New-Object -ComObject Schedule.Service; $s.Connect(); $
|
|
373
|
+
`$ErrorActionPreference='Stop'; $s=New-Object -ComObject Schedule.Service; $s.Connect(); $f=$s.GetFolder('\\'); $t=$f.GetTask('${taskName}'); if ($t.State -in @(2,4) -or $t.GetInstances(0).Count -gt 0) { $t.Stop(0) }; $clock=[Diagnostics.Stopwatch]::StartNew(); while ($true) { $t=$f.GetTask('${taskName}'); if ($t.State -in @(1,3) -and $t.GetInstances(0).Count -eq 0) { break }; if ($clock.ElapsedMilliseconds -ge 25000) { throw 'Hub scheduled task did not stop within 25s' }; Start-Sleep -Milliseconds 50 }`,
|
|
329
374
|
];
|
|
330
375
|
}
|
|
331
376
|
const result = native(file, args);
|
|
@@ -333,6 +378,17 @@ export function runManager(file, args, inspect = spawnSync, now = () => performa
|
|
|
333
378
|
throw new Error(
|
|
334
379
|
`${file} ${args.join(" ")}: ${result.error?.message || result.stderr || result.stdout || `exit ${result.status}`}`,
|
|
335
380
|
);
|
|
381
|
+
if (file === "launchctl" && args[0] === "bootout") {
|
|
382
|
+
while (true) {
|
|
383
|
+
const state = native(file, ["print", args[1]]);
|
|
384
|
+
if (state.error) throw state.error;
|
|
385
|
+
if (state.status !== 0) {
|
|
386
|
+
if (/Could not find service/i.test(state.stderr)) break;
|
|
387
|
+
throw new Error(state.stderr || "Could not confirm launchd job removal");
|
|
388
|
+
}
|
|
389
|
+
pause();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
336
392
|
return result.stdout?.trim();
|
|
337
393
|
}
|
|
338
394
|
export function acquireHubLock(
|
|
@@ -370,7 +426,6 @@ export function acquireHubLock(
|
|
|
370
426
|
alive(previous.pid)
|
|
371
427
|
)
|
|
372
428
|
throw new Error(`Hub lifecycle operation is locked by PID ${previous.pid}: ${lock}`);
|
|
373
|
-
// Remove only the observed unique owner file. Competing recovery cannot delete a new owner's file.
|
|
374
429
|
unlinkSync(previousPath);
|
|
375
430
|
rmdirSync(lock);
|
|
376
431
|
mkdirSync(lock);
|
|
@@ -391,14 +446,11 @@ export function acquireHubLock(
|
|
|
391
446
|
};
|
|
392
447
|
}
|
|
393
448
|
|
|
394
|
-
/** Cancel orchestration without killing a native service manager or the installed service. */
|
|
395
449
|
export async function runHubCliEntry(argv = process.argv.slice(2), options = {}) {
|
|
396
450
|
if (!["install", "start", "stop", "restart", "status", "uninstall"].includes(argv[0]))
|
|
397
451
|
return runHubCli(argv, options);
|
|
398
452
|
const controller = new AbortController();
|
|
399
453
|
const abort = () => controller.abort(new Error("Hub CLI cancelled; installed configuration is retained"));
|
|
400
|
-
// The runner uses IPC on Windows, where kill(SIGTERM) terminates the process immediately.
|
|
401
|
-
// A queued message is handled after spawnSync returns and the orchestration yields.
|
|
402
454
|
const onMessage = (message) => {
|
|
403
455
|
if (message && typeof message === "object" && !Array.isArray(message) && message.type === "cancel-hub-operation")
|
|
404
456
|
abort();
|
|
@@ -434,22 +486,95 @@ export async function runHubCli(
|
|
|
434
486
|
inspect = spawnSync,
|
|
435
487
|
log = console.log,
|
|
436
488
|
foreground = runForeground,
|
|
489
|
+
upgrade,
|
|
437
490
|
signal,
|
|
438
491
|
} = {},
|
|
439
492
|
) {
|
|
440
493
|
signal?.throwIfAborted();
|
|
441
|
-
// Internal service entry uses an explicit saved environment, never ambient Hub overrides.
|
|
442
494
|
if (argv[0] === "--service-config") {
|
|
443
495
|
if (argv.length !== 2) throw new Error("Invalid service configuration arguments");
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
496
|
+
let hubPort;
|
|
497
|
+
const record = (event, error) => {
|
|
498
|
+
try {
|
|
499
|
+
const at = new Date().toISOString();
|
|
500
|
+
let tcp;
|
|
501
|
+
if (
|
|
502
|
+
process.platform === "win32" &&
|
|
503
|
+
error?.code === "EADDRINUSE" &&
|
|
504
|
+
Number.isInteger(error.port) &&
|
|
505
|
+
error.port >= 1 &&
|
|
506
|
+
error.port <= 65535
|
|
507
|
+
) {
|
|
508
|
+
try {
|
|
509
|
+
const result = inspect(
|
|
510
|
+
"powershell.exe",
|
|
511
|
+
[
|
|
512
|
+
"-NoProfile",
|
|
513
|
+
"-NonInteractive",
|
|
514
|
+
"-Command",
|
|
515
|
+
`$ErrorActionPreference='Stop'; $rows=@(Get-NetTCPConnection -LocalPort ${error.port} -ErrorAction SilentlyContinue | Select-Object -First 32 | ForEach-Object { [pscustomobject]@{state=[int]$_.State;pid=[int]$_.OwningProcess} }); ConvertTo-Json -InputObject $rows -Compress`,
|
|
516
|
+
],
|
|
517
|
+
{ encoding: "utf8", windowsHide: true, timeout: 5000, maxBuffer: 8192 },
|
|
518
|
+
);
|
|
519
|
+
if (result.status === 0) {
|
|
520
|
+
const rows = JSON.parse(result.stdout);
|
|
521
|
+
if (Array.isArray(rows))
|
|
522
|
+
tcp = rows
|
|
523
|
+
.slice(0, 32)
|
|
524
|
+
.filter(
|
|
525
|
+
(row) =>
|
|
526
|
+
Number.isInteger(row?.state) &&
|
|
527
|
+
row.state >= 1 &&
|
|
528
|
+
row.state <= 12 &&
|
|
529
|
+
Number.isSafeInteger(row?.pid) &&
|
|
530
|
+
row.pid >= 0,
|
|
531
|
+
)
|
|
532
|
+
.map(({ state, pid }) => ({ state, pid }));
|
|
533
|
+
}
|
|
534
|
+
} catch {}
|
|
535
|
+
}
|
|
536
|
+
appendFileSync(
|
|
537
|
+
join(dirname(resolve(argv[1])), "service-runtime.log"),
|
|
538
|
+
`${JSON.stringify({
|
|
539
|
+
at,
|
|
540
|
+
event,
|
|
541
|
+
pid: process.pid,
|
|
542
|
+
version: JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version,
|
|
543
|
+
...(error ? { code: /^[A-Z][A-Z0-9_]{0,63}$/.test(error.code) ? error.code : "STARTUP_FAILED" } : {}),
|
|
544
|
+
...(Number.isInteger(error?.port) && error.port >= 1 && error.port <= 65535 ? { port: error.port } : {}),
|
|
545
|
+
...(hubPort ? { hubPort } : {}),
|
|
546
|
+
...(typeof error?.syscall === "string" && /^[a-z_]{1,32}$/.test(error.syscall)
|
|
547
|
+
? { syscall: error.syscall }
|
|
548
|
+
: {}),
|
|
549
|
+
...(["127.0.0.1", "::1", "0.0.0.0", "::"].includes(error?.address) ? { address: error.address } : {}),
|
|
550
|
+
...(tcp ? { tcp } : {}),
|
|
551
|
+
})}\n`,
|
|
552
|
+
{ mode: 0o600 },
|
|
553
|
+
);
|
|
554
|
+
} catch {}
|
|
555
|
+
};
|
|
556
|
+
record("starting");
|
|
557
|
+
try {
|
|
558
|
+
const settings = JSON.parse(readFileSync(argv[1], "utf8"));
|
|
559
|
+
validateSettings(settings);
|
|
560
|
+
hubPort = Number(settings.PI_DEVICE_HUB_PORT);
|
|
561
|
+
const hub = await foreground({ ...settings, PI_DEVICE_HUB_SERVICE_CONFIG: resolve(argv[1]) });
|
|
562
|
+
record("ready");
|
|
563
|
+
return hub;
|
|
564
|
+
} catch (error) {
|
|
565
|
+
record("failed", error);
|
|
566
|
+
throw error;
|
|
567
|
+
}
|
|
447
568
|
}
|
|
448
569
|
const parsed = parseHubArgs(argv, env);
|
|
449
570
|
if (parsed.help) return log(HUB_HELP);
|
|
450
571
|
if (parsed.command === "foreground") return foreground(parsed.settings);
|
|
451
572
|
const plan = suppliedPlan ?? hubServicePlan({ env });
|
|
452
573
|
const command = parsed.command;
|
|
574
|
+
if (command === "update") {
|
|
575
|
+
const performUpgrade = upgrade ?? (await import("./hub-upgrade.mjs")).updateInstalledHub;
|
|
576
|
+
return performUpgrade({ plan, env, log, signal });
|
|
577
|
+
}
|
|
453
578
|
if (command === "status") {
|
|
454
579
|
const installed = existsSync(plan.config);
|
|
455
580
|
const settings = installed ? JSON.parse(readFileSync(plan.config, "utf8")) : undefined;
|
|
@@ -485,7 +610,6 @@ export async function runHubCli(
|
|
|
485
610
|
throw new Error(
|
|
486
611
|
`Hub service configuration already exists at ${plan.config}. Inspect with 'hub status --json'; recover with 'hub start' or 'hub restart'. To replace configuration, 'hub uninstall' first (data retained).`,
|
|
487
612
|
);
|
|
488
|
-
// A failed query is not proof of absence unless the native manager says so.
|
|
489
613
|
assertServiceAbsent(plan, inspect);
|
|
490
614
|
await yieldForCancellation(signal);
|
|
491
615
|
await assertPortAvailable(parsed.settings);
|
|
@@ -511,17 +635,12 @@ export async function runHubCli(
|
|
|
511
635
|
try {
|
|
512
636
|
assertServiceAbsent(plan, inspect);
|
|
513
637
|
serviceMissing = true;
|
|
514
|
-
} catch {
|
|
515
|
-
/* Native commands must still report failures for an existing or inaccessible service. */
|
|
516
|
-
}
|
|
638
|
+
} catch {}
|
|
517
639
|
}
|
|
518
|
-
// Absence checks are native phases too: drain pending IPC before another phase.
|
|
519
640
|
await yieldForCancellation(signal);
|
|
520
641
|
for (const args of serviceMissing ? [] : plan.commands[command]) {
|
|
521
642
|
signal?.throwIfAborted();
|
|
522
643
|
const output = run(plan.manager, args);
|
|
523
|
-
// Timer callbacks can precede IPC polling. Cross a full poll/check cycle before
|
|
524
|
-
// starting another native command, including when entered outside an I/O callback.
|
|
525
644
|
await yieldForCancellation(signal);
|
|
526
645
|
signal?.throwIfAborted();
|
|
527
646
|
if (output) log(output);
|
|
@@ -531,7 +650,7 @@ export async function runHubCli(
|
|
|
531
650
|
if (plan.manager === "systemctl") run(plan.manager, ["--user", "daemon-reload"]);
|
|
532
651
|
unlinkSync(plan.config);
|
|
533
652
|
}
|
|
534
|
-
if (["install", "start", "restart"].includes(command)) {
|
|
653
|
+
if (["install", "start", "restart", "update"].includes(command)) {
|
|
535
654
|
const settings = JSON.parse(readFileSync(plan.config, "utf8"));
|
|
536
655
|
await waitForHub(settings, signal);
|
|
537
656
|
}
|
|
@@ -547,13 +666,21 @@ export async function runHubCli(
|
|
|
547
666
|
|
|
548
667
|
async function runForeground(settings) {
|
|
549
668
|
const { startDeviceHub } = await import("../dist/server/device-center/main.js");
|
|
550
|
-
const
|
|
669
|
+
const bootId = randomUUID();
|
|
670
|
+
const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
671
|
+
const hub = await startDeviceHub({
|
|
672
|
+
...settings,
|
|
673
|
+
PI_DEVICE_HUB_BOOT_ID: bootId,
|
|
674
|
+
PI_DEVICE_HUB_PACKAGE_ROOT: fileURLToPath(new URL("../", import.meta.url)),
|
|
675
|
+
});
|
|
551
676
|
hub.app.get("/health", (_req, res) => {
|
|
552
677
|
res.setHeader("Cache-Control", "no-store");
|
|
553
678
|
res.json({
|
|
554
679
|
schemaVersion: 1,
|
|
555
680
|
service: "pi-device-hub",
|
|
556
681
|
status: "ok",
|
|
682
|
+
version,
|
|
683
|
+
bootId,
|
|
557
684
|
instanceId: settings.PI_DEVICE_HUB_INSTANCE_ID ?? null,
|
|
558
685
|
publicUrl: settings.PI_DEVICE_HUB_PUBLIC_URL,
|
|
559
686
|
port: Number(settings.PI_DEVICE_HUB_PORT),
|