@songsid/agend 2.4.0-beta.3 → 2.4.0-beta.30
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/README.md +11 -1
- package/README.zh-TW.md +11 -1
- package/dist/accounts-profiles.d.ts +1 -1
- package/dist/accounts-view.d.ts +32 -0
- package/dist/accounts-view.js +2 -14
- package/dist/accounts-view.js.map +1 -1
- package/dist/agend-home.js +5 -5
- package/dist/agend-home.js.map +1 -1
- package/dist/agent-cli-instructions.md +19 -7
- package/dist/agent-cli.js +199 -51
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-endpoint.d.ts +5 -1
- package/dist/agent-endpoint.js +62 -11
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/agent-export.d.ts +3 -1
- package/dist/agent-export.js +18 -1
- package/dist/agent-export.js.map +1 -1
- package/dist/agent-file-read.js +3 -3
- package/dist/agent-file-read.js.map +1 -1
- package/dist/agent-whats-new.js +35 -0
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/agent-workspace.d.ts +18 -2
- package/dist/agent-workspace.js +15 -4
- package/dist/agent-workspace.js.map +1 -1
- package/dist/app-message-origin.d.ts +2 -0
- package/dist/app-message-origin.js +3 -0
- package/dist/app-message-origin.js.map +1 -0
- package/dist/apply-job.d.ts +2 -2
- package/dist/auth-api.d.ts +12 -0
- package/dist/auth-api.js +87 -5
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/authority-state.d.ts +7 -0
- package/dist/authority/authority-state.js +17 -2
- package/dist/authority/authority-state.js.map +1 -1
- package/dist/authority/web-authority.d.ts +28 -4
- package/dist/authority/web-authority.js +67 -4
- package/dist/authority/web-authority.js.map +1 -1
- package/dist/backend/agy-model-switch.d.ts +22 -0
- package/dist/backend/agy-model-switch.js +62 -0
- package/dist/backend/agy-model-switch.js.map +1 -0
- package/dist/backend/antigravity.d.ts +9 -2
- package/dist/backend/antigravity.js +82 -13
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/claude-carry.d.ts +11 -0
- package/dist/backend/claude-carry.js +88 -6
- package/dist/backend/claude-carry.js.map +1 -1
- package/dist/backend/claude-code.d.ts +39 -7
- package/dist/backend/claude-code.js +234 -32
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/claude-mcp-carry.d.ts +63 -0
- package/dist/backend/claude-mcp-carry.js +242 -0
- package/dist/backend/claude-mcp-carry.js.map +1 -0
- package/dist/backend/claude-transcript-errors.d.ts +4 -0
- package/dist/backend/claude-transcript-errors.js +5 -1
- package/dist/backend/claude-transcript-errors.js.map +1 -1
- package/dist/backend/claude-usage-credits.d.ts +8 -0
- package/dist/backend/claude-usage-credits.js +121 -0
- package/dist/backend/claude-usage-credits.js.map +1 -0
- package/dist/backend/cli-env-probe.js +1 -1
- package/dist/backend/cli-env-probe.js.map +1 -1
- package/dist/backend/cli-runtime-switch.d.ts +90 -0
- package/dist/backend/cli-runtime-switch.js +273 -0
- package/dist/backend/cli-runtime-switch.js.map +1 -0
- package/dist/backend/codex-footer-hints.d.ts +1 -0
- package/dist/backend/codex-footer-hints.js +15 -0
- package/dist/backend/codex-footer-hints.js.map +1 -1
- package/dist/backend/codex-model-switch.d.ts +41 -0
- package/dist/backend/codex-model-switch.js +170 -0
- package/dist/backend/codex-model-switch.js.map +1 -0
- package/dist/backend/codex-precaution.d.ts +7 -0
- package/dist/backend/codex-precaution.js +103 -0
- package/dist/backend/codex-precaution.js.map +1 -0
- package/dist/backend/codex.d.ts +7 -4
- package/dist/backend/codex.js +56 -10
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/grok-model-switch.d.ts +16 -0
- package/dist/backend/grok-model-switch.js +45 -0
- package/dist/backend/grok-model-switch.js.map +1 -0
- package/dist/backend/grok.js +33 -7
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/kiro-auth-store.d.ts +15 -2
- package/dist/backend/kiro-auth-store.js +64 -0
- package/dist/backend/kiro-auth-store.js.map +1 -1
- package/dist/backend/kiro.js +10 -5
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/muse.d.ts +2 -0
- package/dist/backend/muse.js +7 -3
- package/dist/backend/muse.js.map +1 -1
- package/dist/backend/native-pane.js +1 -1
- package/dist/backend/native-pane.js.map +1 -1
- package/dist/backend/types.d.ts +59 -2
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-availability.d.ts +23 -16
- package/dist/backend-availability.js +73 -93
- package/dist/backend-availability.js.map +1 -1
- package/dist/backend-command.d.ts +4 -2
- package/dist/backend-command.js +3 -0
- package/dist/backend-command.js.map +1 -1
- package/dist/backend-signin-guide.js +1 -1
- package/dist/backend-signin-guide.js.map +1 -1
- package/dist/backend-version-static.d.ts +15 -0
- package/dist/backend-version-static.js +95 -0
- package/dist/backend-version-static.js.map +1 -0
- package/dist/browser-backend-signins.d.ts +1 -0
- package/dist/browser-backend-signins.js +3 -1
- package/dist/browser-backend-signins.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/cache-ledger.d.ts +23 -21
- package/dist/cache-ledger.js +70 -6
- package/dist/cache-ledger.js.map +1 -1
- package/dist/cache-prices.d.ts +8 -6
- package/dist/cache-prices.js +12 -5
- package/dist/cache-prices.js.map +1 -1
- package/dist/cache-service.d.ts +9 -5
- package/dist/cache-service.js +202 -50
- package/dist/cache-service.js.map +1 -1
- package/dist/channel/adapters/discord.d.ts +23 -1
- package/dist/channel/adapters/discord.js +97 -26
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.d.ts +2 -0
- package/dist/channel/adapters/telegram.js +9 -4
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/ipc-bridge.d.ts +7 -0
- package/dist/channel/ipc-bridge.js +45 -11
- package/dist/channel/ipc-bridge.js.map +1 -1
- package/dist/channel/mcp-server.js +39 -5
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.d.ts +27 -1
- package/dist/channel/mcp-tools.js +107 -14
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/tool-router.d.ts +4 -0
- package/dist/channel/tool-router.js +51 -19
- package/dist/channel/tool-router.js.map +1 -1
- package/dist/channel/types.d.ts +10 -0
- package/dist/chat-task-refs.d.ts +61 -0
- package/dist/chat-task-refs.js +112 -0
- package/dist/chat-task-refs.js.map +1 -0
- package/dist/classic-channel-manager.d.ts +6 -2
- package/dist/classic-channel-manager.js +29 -4
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/classic-cli-guard.d.ts +66 -0
- package/dist/classic-cli-guard.js +209 -0
- package/dist/classic-cli-guard.js.map +1 -0
- package/dist/claude-credential-change.d.ts +22 -0
- package/dist/claude-credential-change.js +47 -0
- package/dist/claude-credential-change.js.map +1 -0
- package/dist/claude-credential-launch.d.ts +69 -0
- package/dist/claude-credential-launch.js +328 -0
- package/dist/claude-credential-launch.js.map +1 -0
- package/dist/claude-credential-runner.d.ts +1 -0
- package/dist/claude-credential-runner.js +58 -0
- package/dist/claude-credential-runner.js.map +1 -0
- package/dist/claude-credential-vault.d.ts +57 -0
- package/dist/claude-credential-vault.js +277 -0
- package/dist/claude-credential-vault.js.map +1 -0
- package/dist/claude-install-kind.d.ts +19 -0
- package/dist/claude-install-kind.js +54 -0
- package/dist/claude-install-kind.js.map +1 -0
- package/dist/claude-request-observation.d.ts +7 -0
- package/dist/claude-request-observation.js +26 -0
- package/dist/claude-request-observation.js.map +1 -0
- package/dist/claude-setup-token-transport.d.ts +9 -0
- package/dist/claude-setup-token-transport.js +104 -0
- package/dist/claude-setup-token-transport.js.map +1 -0
- package/dist/claude-setup-token.d.ts +51 -0
- package/dist/claude-setup-token.js +83 -0
- package/dist/claude-setup-token.js.map +1 -0
- package/dist/claude-turn-boundaries.d.ts +15 -0
- package/dist/claude-turn-boundaries.js +88 -0
- package/dist/claude-turn-boundaries.js.map +1 -0
- package/dist/cli-audited.js +30 -17
- package/dist/cli-audited.js.map +1 -1
- package/dist/cli-capability.d.ts +3 -0
- package/dist/cli-capability.js.map +1 -1
- package/dist/cli-registry-check.js +1 -1
- package/dist/cli-registry-check.js.map +1 -1
- package/dist/cli-registry.d.ts +1 -0
- package/dist/cli-spec-antigravity.d.ts +1 -0
- package/dist/cli-spec-antigravity.js +3 -1
- package/dist/cli-spec-antigravity.js.map +1 -1
- package/dist/cli.js +231 -24
- package/dist/cli.js.map +1 -1
- package/dist/command-report.d.ts +11 -0
- package/dist/command-report.js +2 -0
- package/dist/command-report.js.map +1 -0
- package/dist/composite-tools.d.ts +11 -0
- package/dist/composite-tools.js +29 -0
- package/dist/composite-tools.js.map +1 -0
- package/dist/config-validator.js +69 -3
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +17 -2
- package/dist/config.js.map +1 -1
- package/dist/connect/control.d.ts +20 -0
- package/dist/connect/control.js +236 -0
- package/dist/connect/control.js.map +1 -0
- package/dist/connect/install.d.ts +13 -0
- package/dist/connect/install.js +12 -0
- package/dist/connect/install.js.map +1 -0
- package/dist/connect/mcp.d.ts +9 -0
- package/dist/connect/mcp.js +10 -0
- package/dist/connect/mcp.js.map +1 -0
- package/dist/connect/protocol.d.ts +38 -0
- package/dist/connect/protocol.js +36 -0
- package/dist/connect/protocol.js.map +1 -0
- package/dist/connect/service.d.ts +19 -0
- package/dist/connect/service.js +79 -0
- package/dist/connect/service.js.map +1 -0
- package/dist/connect/stdio-entry.d.ts +1 -0
- package/dist/connect/stdio-entry.js +6 -0
- package/dist/connect/stdio-entry.js.map +1 -0
- package/dist/connect/stdio.d.ts +5 -0
- package/dist/connect/stdio.js +33 -0
- package/dist/connect/stdio.js.map +1 -0
- package/dist/contact-auth-api.d.ts +17 -0
- package/dist/contact-auth-api.js +90 -0
- package/dist/contact-auth-api.js.map +1 -0
- package/dist/contact-auth-files.d.ts +6 -0
- package/dist/contact-auth-files.js +29 -0
- package/dist/contact-auth-files.js.map +1 -0
- package/dist/contact-auth-policy.d.ts +81 -0
- package/dist/contact-auth-policy.js +26 -0
- package/dist/contact-auth-policy.js.map +1 -0
- package/dist/contact-auth-service.d.ts +32 -0
- package/dist/contact-auth-service.js +110 -0
- package/dist/contact-auth-service.js.map +1 -0
- package/dist/contact-auth-store.d.ts +149 -0
- package/dist/contact-auth-store.js +573 -0
- package/dist/contact-auth-store.js.map +1 -0
- package/dist/contact-auth-types.d.ts +202 -0
- package/dist/contact-auth-types.js +7 -0
- package/dist/contact-auth-types.js.map +1 -0
- package/dist/contact-change-proposals.d.ts +98 -0
- package/dist/contact-change-proposals.js +166 -0
- package/dist/contact-change-proposals.js.map +1 -0
- package/dist/contact-state-view.d.ts +103 -0
- package/dist/contact-state-view.js +80 -0
- package/dist/contact-state-view.js.map +1 -0
- package/dist/cross-instance-notice.d.ts +1 -0
- package/dist/cross-instance-notice.js +9 -8
- package/dist/cross-instance-notice.js.map +1 -1
- package/dist/daemon.d.ts +247 -3
- package/dist/daemon.js +1714 -181
- package/dist/daemon.js.map +1 -1
- package/dist/darwin-memory.js +2 -1
- package/dist/darwin-memory.js.map +1 -1
- package/dist/dashboard-permissions.d.ts +23 -8
- package/dist/dashboard-permissions.js +33 -10
- package/dist/dashboard-permissions.js.map +1 -1
- package/dist/delivery-consumed-watch.js +3 -0
- package/dist/delivery-consumed-watch.js.map +1 -1
- package/dist/delivery-outbox.d.ts +213 -10
- package/dist/delivery-outbox.js +664 -49
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/delivery-outbox.test.js +132 -96
- package/dist/delivery-outbox.test.js.map +1 -1
- package/dist/detached-fleet-stop.d.ts +40 -0
- package/dist/detached-fleet-stop.js +126 -0
- package/dist/detached-fleet-stop.js.map +1 -0
- package/dist/dispatcher-liveness.d.ts +51 -1
- package/dist/dispatcher-liveness.js +94 -4
- package/dist/dispatcher-liveness.js.map +1 -1
- package/dist/event-log.d.ts +12 -0
- package/dist/event-log.js +40 -0
- package/dist/event-log.js.map +1 -1
- package/dist/fleet-context.d.ts +9 -0
- package/dist/fleet-level-config.d.ts +1 -1
- package/dist/fleet-level-config.js +1 -0
- package/dist/fleet-level-config.js.map +1 -1
- package/dist/fleet-lock.d.ts +88 -2
- package/dist/fleet-lock.js +296 -3
- package/dist/fleet-lock.js.map +1 -1
- package/dist/fleet-manager.d.ts +1397 -29
- package/dist/fleet-manager.js +8180 -623
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-windows-runtime.d.ts +59 -4
- package/dist/fleet-windows-runtime.js +307 -40
- package/dist/fleet-windows-runtime.js.map +1 -1
- package/dist/fleet-yaml-stringify.d.ts +3 -0
- package/dist/fleet-yaml-stringify.js +132 -0
- package/dist/fleet-yaml-stringify.js.map +1 -0
- package/dist/general-knowledge/skills/admin/SKILL.md +52 -0
- package/dist/general-knowledge/skills/concepts/SKILL.md +106 -23
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +19 -1
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +68 -1
- package/dist/general-knowledge/skills/fleet-config/SKILL.md +24 -4
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +9 -1
- package/dist/general-knowledge/skills/hub/SKILL.md +393 -27
- package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +6 -2
- package/dist/general-knowledge/skills/model-discovery/SKILL.md +7 -2
- package/dist/general-knowledge/skills/persona-emoji/SKILL.md +3 -0
- package/dist/general-knowledge/skills/task-board/SKILL.md +98 -0
- package/dist/general-knowledge/skills/web-appearance/SKILL.md +35 -3
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +391 -70
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +7 -1
- package/dist/general-knowledge/steering/core-rules.md +15 -78
- package/dist/general-role-block.d.ts +19 -0
- package/dist/general-role-block.js +56 -0
- package/dist/general-role-block.js.map +1 -0
- package/dist/general-role.d.ts +1 -1
- package/dist/general-role.js +2 -0
- package/dist/general-role.js.map +1 -1
- package/dist/home-update-lock.d.ts +35 -0
- package/dist/home-update-lock.js +81 -0
- package/dist/home-update-lock.js.map +1 -0
- package/dist/host-memory.d.ts +24 -1
- package/dist/host-memory.js +30 -4
- package/dist/host-memory.js.map +1 -1
- package/dist/host-monitoring/darwin/collector.d.ts +18 -0
- package/dist/host-monitoring/darwin/collector.js +65 -0
- package/dist/host-monitoring/darwin/collector.js.map +1 -0
- package/dist/host-monitoring/darwin/defaults.d.ts +2 -0
- package/dist/host-monitoring/darwin/defaults.js +9 -0
- package/dist/host-monitoring/darwin/defaults.js.map +1 -0
- package/dist/host-monitoring/darwin/interpretation.d.ts +20 -0
- package/dist/host-monitoring/darwin/interpretation.js +73 -0
- package/dist/host-monitoring/darwin/interpretation.js.map +1 -0
- package/dist/host-monitoring/linux/collector.d.ts +17 -0
- package/dist/host-monitoring/linux/collector.js +55 -0
- package/dist/host-monitoring/linux/collector.js.map +1 -0
- package/dist/host-monitoring/linux/defaults.d.ts +2 -0
- package/dist/host-monitoring/linux/defaults.js +9 -0
- package/dist/host-monitoring/linux/defaults.js.map +1 -0
- package/dist/host-monitoring/linux/interpretation.d.ts +22 -0
- package/dist/host-monitoring/linux/interpretation.js +76 -0
- package/dist/host-monitoring/linux/interpretation.js.map +1 -0
- package/dist/host-monitoring/transport.d.ts +42 -0
- package/dist/host-monitoring/transport.js +101 -0
- package/dist/host-monitoring/transport.js.map +1 -0
- package/dist/host-monitoring/wsl/collector.d.ts +19 -0
- package/dist/host-monitoring/wsl/collector.js +72 -0
- package/dist/host-monitoring/wsl/collector.js.map +1 -0
- package/dist/host-monitoring/wsl/defaults.d.ts +2 -0
- package/dist/host-monitoring/wsl/defaults.js +9 -0
- package/dist/host-monitoring/wsl/defaults.js.map +1 -0
- package/dist/host-monitoring/wsl/interpretation.d.ts +22 -0
- package/dist/host-monitoring/wsl/interpretation.js +77 -0
- package/dist/host-monitoring/wsl/interpretation.js.map +1 -0
- package/dist/host-monitoring-alert-policy.d.ts +73 -0
- package/dist/host-monitoring-alert-policy.js +152 -0
- package/dist/host-monitoring-alert-policy.js.map +1 -0
- package/dist/host-monitoring-alert-resources.d.ts +11 -0
- package/dist/host-monitoring-alert-resources.js +16 -0
- package/dist/host-monitoring-alert-resources.js.map +1 -0
- package/dist/host-monitoring-alert-settings.d.ts +16 -0
- package/dist/host-monitoring-alert-settings.js +68 -0
- package/dist/host-monitoring-alert-settings.js.map +1 -0
- package/dist/host-monitoring-alert-store.d.ts +49 -0
- package/dist/host-monitoring-alert-store.js +228 -0
- package/dist/host-monitoring-alert-store.js.map +1 -0
- package/dist/host-monitoring-alert-text.d.ts +7 -0
- package/dist/host-monitoring-alert-text.js +10 -0
- package/dist/host-monitoring-alert-text.js.map +1 -0
- package/dist/host-monitoring-alerts.d.ts +79 -0
- package/dist/host-monitoring-alerts.js +276 -0
- package/dist/host-monitoring-alerts.js.map +1 -0
- package/dist/host-monitoring-config.d.ts +15 -0
- package/dist/host-monitoring-config.js +36 -0
- package/dist/host-monitoring-config.js.map +1 -0
- package/dist/host-monitoring-defaults.d.ts +19 -0
- package/dist/host-monitoring-defaults.js +10 -0
- package/dist/host-monitoring-defaults.js.map +1 -0
- package/dist/host-monitoring-footprint-policy.d.ts +45 -0
- package/dist/host-monitoring-footprint-policy.js +150 -0
- package/dist/host-monitoring-footprint-policy.js.map +1 -0
- package/dist/host-monitoring-footprint.d.ts +42 -0
- package/dist/host-monitoring-footprint.js +169 -0
- package/dist/host-monitoring-footprint.js.map +1 -0
- package/dist/host-monitoring-history-files.d.ts +2 -0
- package/dist/host-monitoring-history-files.js +16 -0
- package/dist/host-monitoring-history-files.js.map +1 -0
- package/dist/host-monitoring-history-policy.d.ts +57 -0
- package/dist/host-monitoring-history-policy.js +107 -0
- package/dist/host-monitoring-history-policy.js.map +1 -0
- package/dist/host-monitoring-history-store.d.ts +52 -0
- package/dist/host-monitoring-history-store.js +178 -0
- package/dist/host-monitoring-history-store.js.map +1 -0
- package/dist/host-monitoring-history-worker.d.ts +1 -0
- package/dist/host-monitoring-history-worker.js +66 -0
- package/dist/host-monitoring-history-worker.js.map +1 -0
- package/dist/host-monitoring-history.d.ts +80 -0
- package/dist/host-monitoring-history.js +301 -0
- package/dist/host-monitoring-history.js.map +1 -0
- package/dist/host-monitoring-platform.d.ts +21 -0
- package/dist/host-monitoring-platform.js +18 -0
- package/dist/host-monitoring-platform.js.map +1 -0
- package/dist/host-monitoring-process-identity.d.ts +8 -0
- package/dist/host-monitoring-process-identity.js +81 -0
- package/dist/host-monitoring-process-identity.js.map +1 -0
- package/dist/host-monitoring-runtime.d.ts +42 -0
- package/dist/host-monitoring-runtime.js +95 -0
- package/dist/host-monitoring-runtime.js.map +1 -0
- package/dist/host-monitoring-settings-store.d.ts +5 -0
- package/dist/host-monitoring-settings-store.js +49 -0
- package/dist/host-monitoring-settings-store.js.map +1 -0
- package/dist/host-monitoring.d.ts +123 -0
- package/dist/host-monitoring.js +157 -0
- package/dist/host-monitoring.js.map +1 -0
- package/dist/hub/admin-dashboard.d.ts +85 -0
- package/dist/hub/admin-dashboard.js +177 -0
- package/dist/hub/admin-dashboard.js.map +1 -0
- package/dist/hub/agent-catalog-model.d.ts +297 -0
- package/dist/hub/agent-catalog-model.js +57 -0
- package/dist/hub/agent-catalog-model.js.map +1 -0
- package/dist/hub/agent-catalog.d.ts +140 -0
- package/dist/hub/agent-catalog.js +130 -0
- package/dist/hub/agent-catalog.js.map +1 -0
- package/dist/hub/agent-intro-model.d.ts +38 -0
- package/dist/hub/agent-intro-model.js +14 -0
- package/dist/hub/agent-intro-model.js.map +1 -0
- package/dist/hub/agent-intro-tool.d.ts +35 -0
- package/dist/hub/agent-intro-tool.js +83 -0
- package/dist/hub/agent-intro-tool.js.map +1 -0
- package/dist/hub/agent-intro.d.ts +31 -0
- package/dist/hub/agent-intro.js +51 -0
- package/dist/hub/agent-intro.js.map +1 -0
- package/dist/hub/agent-pictures-model.d.ts +275 -0
- package/dist/hub/agent-pictures-model.js +103 -0
- package/dist/hub/agent-pictures-model.js.map +1 -0
- package/dist/hub/agent-pictures.d.ts +64 -0
- package/dist/hub/agent-pictures.js +256 -0
- package/dist/hub/agent-pictures.js.map +1 -0
- package/dist/hub/attachments/store.d.ts +2 -0
- package/dist/hub/attachments/store.js +6 -0
- package/dist/hub/attachments/store.js.map +1 -1
- package/dist/hub/audit/index.d.ts +5 -1
- package/dist/hub/audit/index.js +43 -3
- package/dist/hub/audit/index.js.map +1 -1
- package/dist/hub/buttons.js +3 -1
- package/dist/hub/buttons.js.map +1 -1
- package/dist/hub/catalog.d.ts +19 -6
- package/dist/hub/catalog.js +102 -27
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.d.ts +20 -0
- package/dist/hub/client.js +175 -12
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +65 -8
- package/dist/hub/compose/member.js +404 -35
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +30 -5
- package/dist/hub/compose/server.js +140 -20
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/direct-posts-model.d.ts +1 -0
- package/dist/hub/direct-posts-model.js +2 -0
- package/dist/hub/direct-posts-model.js.map +1 -0
- package/dist/hub/direct-posts.d.ts +36 -0
- package/dist/hub/direct-posts.js +145 -0
- package/dist/hub/direct-posts.js.map +1 -0
- package/dist/hub/directory/directory.js +27 -7
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/types.d.ts +10 -4
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/display-name.d.ts +10 -0
- package/dist/hub/display-name.js +35 -0
- package/dist/hub/display-name.js.map +1 -0
- package/dist/hub/execution/service.d.ts +2 -1
- package/dist/hub/execution/service.js +2 -1
- package/dist/hub/execution/service.js.map +1 -1
- package/dist/hub/fleet-info.d.ts +12 -0
- package/dist/hub/fleet-info.js +14 -0
- package/dist/hub/fleet-info.js.map +1 -0
- package/dist/hub/fleet-update-model.d.ts +100 -0
- package/dist/hub/fleet-update-model.js +15 -0
- package/dist/hub/fleet-update-model.js.map +1 -0
- package/dist/hub/fleet-updates.d.ts +46 -0
- package/dist/hub/fleet-updates.js +284 -0
- package/dist/hub/fleet-updates.js.map +1 -0
- package/dist/hub/fleet-versions.d.ts +28 -0
- package/dist/hub/fleet-versions.js +81 -0
- package/dist/hub/fleet-versions.js.map +1 -0
- package/dist/hub/group-policy/admin-api.d.ts +1 -0
- package/dist/hub/group-policy/admin-api.js +10 -1
- package/dist/hub/group-policy/admin-api.js.map +1 -1
- package/dist/hub/group-policy/admin-control.d.ts +1 -0
- package/dist/hub/group-policy/admin-control.js +13 -4
- package/dist/hub/group-policy/admin-control.js.map +1 -1
- package/dist/hub/group-policy/admin-dto.d.ts +39 -1
- package/dist/hub/group-policy/admin-dto.js.map +1 -1
- package/dist/hub/group-policy/admin-facts.d.ts +4 -2
- package/dist/hub/group-policy/admin-facts.js +17 -2
- package/dist/hub/group-policy/admin-facts.js.map +1 -1
- package/dist/hub/group-policy/admin-impact.d.ts +36 -6
- package/dist/hub/group-policy/admin-impact.js +21 -7
- package/dist/hub/group-policy/admin-impact.js.map +1 -1
- package/dist/hub/group-policy/admin-inventory.d.ts +2 -0
- package/dist/hub/group-policy/admin-inventory.js +13 -4
- package/dist/hub/group-policy/admin-inventory.js.map +1 -1
- package/dist/hub/group-policy/admin-search.d.ts +2 -1
- package/dist/hub/group-policy/admin-search.js +56 -7
- package/dist/hub/group-policy/admin-search.js.map +1 -1
- package/dist/hub/group-policy/authorization.d.ts +2 -0
- package/dist/hub/group-policy/authorization.js +7 -2
- package/dist/hub/group-policy/authorization.js.map +1 -1
- package/dist/hub/group-policy/impact-inventory.d.ts +4 -1
- package/dist/hub/group-policy/impact-inventory.js +23 -2
- package/dist/hub/group-policy/impact-inventory.js.map +1 -1
- package/dist/hub/group-policy/model.d.ts +52 -1
- package/dist/hub/group-policy/model.js +20 -7
- package/dist/hub/group-policy/model.js.map +1 -1
- package/dist/hub/group-policy/resources.d.ts +2 -0
- package/dist/hub/group-policy/resources.js +12 -1
- package/dist/hub/group-policy/resources.js.map +1 -1
- package/dist/hub/group-policy/store.js +22 -3
- package/dist/hub/group-policy/store.js.map +1 -1
- package/dist/hub/group-policy/team-subjects.d.ts +16 -0
- package/dist/hub/group-policy/team-subjects.js +32 -0
- package/dist/hub/group-policy/team-subjects.js.map +1 -0
- package/dist/hub/http/compose.d.ts +17 -0
- package/dist/hub/http/compose.js +903 -100
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.d.ts +11 -1
- package/dist/hub/http/core.js +70 -10
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +21 -0
- package/dist/hub/http/schema.js +54 -1
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/init/text.js +1 -1
- package/dist/hub/invitations.js +15 -7
- package/dist/hub/invitations.js.map +1 -1
- package/dist/hub/join/client.js +75 -42
- package/dist/hub/join/client.js.map +1 -1
- package/dist/hub/join/service.d.ts +9 -1
- package/dist/hub/join/service.js +17 -3
- package/dist/hub/join/service.js.map +1 -1
- package/dist/hub/lapse-carry.d.ts +45 -0
- package/dist/hub/lapse-carry.js +62 -0
- package/dist/hub/lapse-carry.js.map +1 -0
- package/dist/hub/mcp/auth-schema.d.ts +7 -0
- package/dist/hub/mcp/auth-schema.js +31 -0
- package/dist/hub/mcp/auth-schema.js.map +1 -0
- package/dist/hub/mcp/auth.d.ts +89 -0
- package/dist/hub/mcp/auth.js +374 -0
- package/dist/hub/mcp/auth.js.map +1 -0
- package/dist/hub/mcp/catalog.d.ts +44 -0
- package/dist/hub/mcp/catalog.js +31 -0
- package/dist/hub/mcp/catalog.js.map +1 -0
- package/dist/hub/mcp/door-schema.d.ts +7 -0
- package/dist/hub/mcp/door-schema.js +20 -0
- package/dist/hub/mcp/door-schema.js.map +1 -0
- package/dist/hub/mcp/http.d.ts +25 -0
- package/dist/hub/mcp/http.js +259 -0
- package/dist/hub/mcp/http.js.map +1 -0
- package/dist/hub/mcp/policy.d.ts +65 -0
- package/dist/hub/mcp/policy.js +153 -0
- package/dist/hub/mcp/policy.js.map +1 -0
- package/dist/hub/mcp/server.d.ts +3 -0
- package/dist/hub/mcp/server.js +32 -0
- package/dist/hub/mcp/server.js.map +1 -0
- package/dist/hub/mcp/tools.d.ts +31 -0
- package/dist/hub/mcp/tools.js +177 -0
- package/dist/hub/mcp/tools.js.map +1 -0
- package/dist/hub/member/agent-catalog.d.ts +31 -0
- package/dist/hub/member/agent-catalog.js +91 -0
- package/dist/hub/member/agent-catalog.js.map +1 -0
- package/dist/hub/member/agent-intro.d.ts +29 -0
- package/dist/hub/member/agent-intro.js +73 -0
- package/dist/hub/member/agent-intro.js.map +1 -0
- package/dist/hub/member/agent-pictures.d.ts +76 -0
- package/dist/hub/member/agent-pictures.js +196 -0
- package/dist/hub/member/agent-pictures.js.map +1 -0
- package/dist/hub/member/direct-rooms.d.ts +9 -0
- package/dist/hub/member/direct-rooms.js +14 -0
- package/dist/hub/member/direct-rooms.js.map +1 -0
- package/dist/hub/member/display-name.d.ts +9 -0
- package/dist/hub/member/display-name.js +71 -0
- package/dist/hub/member/display-name.js.map +1 -0
- package/dist/hub/member/exposure-api.d.ts +11 -3
- package/dist/hub/member/exposure-api.js +24 -10
- package/dist/hub/member/exposure-api.js.map +1 -1
- package/dist/hub/member/exposures.d.ts +16 -4
- package/dist/hub/member/exposures.js +47 -13
- package/dist/hub/member/exposures.js.map +1 -1
- package/dist/hub/member/pairing-api.js +3 -2
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/member/recommendations.d.ts +37 -0
- package/dist/hub/member/recommendations.js +129 -0
- package/dist/hub/member/recommendations.js.map +1 -0
- package/dist/hub/member/room-ask.d.ts +104 -6
- package/dist/hub/member/room-ask.js +505 -34
- package/dist/hub/member/room-ask.js.map +1 -1
- package/dist/hub/member/room-asker-store.d.ts +48 -0
- package/dist/hub/member/room-asker-store.js +181 -0
- package/dist/hub/member/room-asker-store.js.map +1 -0
- package/dist/hub/member/room-context-budget.d.ts +5 -0
- package/dist/hub/member/room-context-budget.js +34 -0
- package/dist/hub/member/room-context-budget.js.map +1 -0
- package/dist/hub/member/room-mention-feedback.d.ts +46 -0
- package/dist/hub/member/room-mention-feedback.js +121 -0
- package/dist/hub/member/room-mention-feedback.js.map +1 -0
- package/dist/hub/member/room-notification.d.ts +9 -0
- package/dist/hub/member/room-notification.js +2 -0
- package/dist/hub/member/room-notification.js.map +1 -0
- package/dist/hub/member/room-post-answers.d.ts +48 -0
- package/dist/hub/member/room-post-answers.js +152 -0
- package/dist/hub/member/room-post-answers.js.map +1 -0
- package/dist/hub/member/room-post-receipt.d.ts +21 -0
- package/dist/hub/member/room-post-receipt.js +49 -0
- package/dist/hub/member/room-post-receipt.js.map +1 -0
- package/dist/hub/member/room-post.d.ts +144 -0
- package/dist/hub/member/room-post.js +339 -0
- package/dist/hub/member/room-post.js.map +1 -0
- package/dist/hub/member/room-reaction-acks.d.ts +12 -0
- package/dist/hub/member/room-reaction-acks.js +44 -0
- package/dist/hub/member/room-reaction-acks.js.map +1 -0
- package/dist/hub/member/sharing-journal.d.ts +252 -0
- package/dist/hub/member/sharing-journal.js +212 -0
- package/dist/hub/member/sharing-journal.js.map +1 -0
- package/dist/hub/member/sharing-link.d.ts +25 -0
- package/dist/hub/member/sharing-link.js +68 -0
- package/dist/hub/member/sharing-link.js.map +1 -0
- package/dist/hub/member/sharing-result.d.ts +6 -0
- package/dist/hub/member/sharing-result.js +46 -0
- package/dist/hub/member/sharing-result.js.map +1 -0
- package/dist/hub/member/sharing.d.ts +39 -0
- package/dist/hub/member/sharing.js +188 -0
- package/dist/hub/member/sharing.js.map +1 -0
- package/dist/hub/member/updates.d.ts +98 -0
- package/dist/hub/member/updates.js +322 -0
- package/dist/hub/member/updates.js.map +1 -0
- package/dist/hub/pairing.d.ts +15 -1
- package/dist/hub/pairing.js +33 -2
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/personal/owner-host.d.ts +146 -0
- package/dist/hub/personal/owner-host.js +289 -0
- package/dist/hub/personal/owner-host.js.map +1 -0
- package/dist/hub/personal/refusals.d.ts +11 -0
- package/dist/hub/personal/refusals.js +33 -0
- package/dist/hub/personal/refusals.js.map +1 -0
- package/dist/hub/personal/runtime-host.d.ts +26 -0
- package/dist/hub/personal/runtime-host.js +51 -0
- package/dist/hub/personal/runtime-host.js.map +1 -0
- package/dist/hub/personal/schema.d.ts +4 -0
- package/dist/hub/personal/schema.js +54 -0
- package/dist/hub/personal/schema.js.map +1 -0
- package/dist/hub/personal/turns.d.ts +39 -0
- package/dist/hub/personal/turns.js +221 -0
- package/dist/hub/personal/turns.js.map +1 -0
- package/dist/hub/personal/types.d.ts +42 -0
- package/dist/hub/personal/types.js +2 -0
- package/dist/hub/personal/types.js.map +1 -0
- package/dist/hub/policy.d.ts +12 -3
- package/dist/hub/policy.js +107 -23
- package/dist/hub/policy.js.map +1 -1
- package/dist/hub/protocol.d.ts +1481 -49
- package/dist/hub/protocol.js +130 -17
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/published-version.d.ts +3 -0
- package/dist/hub/published-version.js +35 -0
- package/dist/hub/published-version.js.map +1 -0
- package/dist/hub/question-close-model.d.ts +17 -0
- package/dist/hub/question-close-model.js +7 -0
- package/dist/hub/question-close-model.js.map +1 -0
- package/dist/hub/quota.d.ts +2 -2
- package/dist/hub/quota.js +9 -5
- package/dist/hub/quota.js.map +1 -1
- package/dist/hub/read-statement.d.ts +6 -0
- package/dist/hub/read-statement.js +33 -0
- package/dist/hub/read-statement.js.map +1 -0
- package/dist/hub/recommendation-model.d.ts +36 -0
- package/dist/hub/recommendation-model.js +9 -0
- package/dist/hub/recommendation-model.js.map +1 -0
- package/dist/hub/recommendations.d.ts +58 -0
- package/dist/hub/recommendations.js +212 -0
- package/dist/hub/recommendations.js.map +1 -0
- package/dist/hub/representative.d.ts +57 -0
- package/dist/hub/representative.js +239 -19
- package/dist/hub/representative.js.map +1 -1
- package/dist/hub/roles/admin-control.d.ts +29 -0
- package/dist/hub/roles/admin-control.js +187 -0
- package/dist/hub/roles/admin-control.js.map +1 -0
- package/dist/hub/roles/admin-types.d.ts +72 -0
- package/dist/hub/roles/admin-types.js +2 -0
- package/dist/hub/roles/admin-types.js.map +1 -0
- package/dist/hub/roles/allowed-list-control.d.ts +34 -0
- package/dist/hub/roles/allowed-list-control.js +179 -0
- package/dist/hub/roles/allowed-list-control.js.map +1 -0
- package/dist/hub/roles/allowed-list.d.ts +8 -0
- package/dist/hub/roles/allowed-list.js +49 -0
- package/dist/hub/roles/allowed-list.js.map +1 -0
- package/dist/hub/roles/audit-details.d.ts +146 -0
- package/dist/hub/roles/audit-details.js +26 -0
- package/dist/hub/roles/audit-details.js.map +1 -0
- package/dist/hub/roles/authority.d.ts +20 -3
- package/dist/hub/roles/authority.js +165 -87
- package/dist/hub/roles/authority.js.map +1 -1
- package/dist/hub/roles/change.d.ts +3 -1
- package/dist/hub/roles/change.js +7 -2
- package/dist/hub/roles/change.js.map +1 -1
- package/dist/hub/roles/clock.d.ts +4 -1
- package/dist/hub/roles/clock.js +15 -12
- package/dist/hub/roles/clock.js.map +1 -1
- package/dist/hub/roles/convert.js +1 -1
- package/dist/hub/roles/convert.js.map +1 -1
- package/dist/hub/roles/cutover-clock-facts.d.ts +13 -0
- package/dist/hub/roles/cutover-clock-facts.js +25 -0
- package/dist/hub/roles/cutover-clock-facts.js.map +1 -0
- package/dist/hub/roles/cutover-inventory.d.ts +5 -0
- package/dist/hub/roles/cutover-inventory.js +27 -4
- package/dist/hub/roles/cutover-inventory.js.map +1 -1
- package/dist/hub/roles/cutover-marker.d.ts +18 -2
- package/dist/hub/roles/cutover-marker.js +6 -2
- package/dist/hub/roles/cutover-marker.js.map +1 -1
- package/dist/hub/roles/cutover.d.ts +2 -2
- package/dist/hub/roles/cutover.js +3 -4
- package/dist/hub/roles/cutover.js.map +1 -1
- package/dist/hub/roles/delegation.d.ts +4 -1
- package/dist/hub/roles/delegation.js +9 -4
- package/dist/hub/roles/delegation.js.map +1 -1
- package/dist/hub/roles/evaluate.d.ts +2 -1
- package/dist/hub/roles/evaluate.js +14 -0
- package/dist/hub/roles/evaluate.js.map +1 -1
- package/dist/hub/roles/expiry-effects.d.ts +8 -0
- package/dist/hub/roles/expiry-effects.js +50 -0
- package/dist/hub/roles/expiry-effects.js.map +1 -0
- package/dist/hub/roles/migrations.d.ts +7 -0
- package/dist/hub/roles/migrations.js +44 -0
- package/dist/hub/roles/migrations.js.map +1 -0
- package/dist/hub/roles/model.d.ts +30 -2
- package/dist/hub/roles/model.js +14 -7
- package/dist/hub/roles/model.js.map +1 -1
- package/dist/hub/roles/overview.d.ts +8 -0
- package/dist/hub/roles/overview.js +15 -0
- package/dist/hub/roles/overview.js.map +1 -0
- package/dist/hub/roles/read.d.ts +4 -0
- package/dist/hub/roles/read.js +37 -7
- package/dist/hub/roles/read.js.map +1 -1
- package/dist/hub/roles/resource-effects.d.ts +17 -0
- package/dist/hub/roles/resource-effects.js +62 -0
- package/dist/hub/roles/resource-effects.js.map +1 -0
- package/dist/hub/roles/review.d.ts +16 -0
- package/dist/hub/roles/review.js +42 -0
- package/dist/hub/roles/review.js.map +1 -0
- package/dist/hub/roles/writer.d.ts +14 -3
- package/dist/hub/roles/writer.js +64 -16
- package/dist/hub/roles/writer.js.map +1 -1
- package/dist/hub/room-agent-discovery-model.d.ts +29 -0
- package/dist/hub/room-agent-discovery-model.js +33 -0
- package/dist/hub/room-agent-discovery-model.js.map +1 -0
- package/dist/hub/room-agent-discovery.d.ts +14 -0
- package/dist/hub/room-agent-discovery.js +65 -0
- package/dist/hub/room-agent-discovery.js.map +1 -0
- package/dist/hub/room-agent-requests.d.ts +71 -0
- package/dist/hub/room-agent-requests.js +377 -0
- package/dist/hub/room-agent-requests.js.map +1 -0
- package/dist/hub/room-answer-status-model.d.ts +3 -0
- package/dist/hub/room-answer-status-model.js +4 -0
- package/dist/hub/room-answer-status-model.js.map +1 -0
- package/dist/hub/room-asker-identity-model.d.ts +53 -0
- package/dist/hub/room-asker-identity-model.js +14 -0
- package/dist/hub/room-asker-identity-model.js.map +1 -0
- package/dist/hub/room-asker-identity.d.ts +22 -0
- package/dist/hub/room-asker-identity.js +43 -0
- package/dist/hub/room-asker-identity.js.map +1 -0
- package/dist/hub/room-brief-model.d.ts +30 -0
- package/dist/hub/room-brief-model.js +38 -0
- package/dist/hub/room-brief-model.js.map +1 -0
- package/dist/hub/room-context-model.d.ts +45 -0
- package/dist/hub/room-context-model.js +12 -0
- package/dist/hub/room-context-model.js.map +1 -0
- package/dist/hub/room-history-model.d.ts +87 -0
- package/dist/hub/room-history-model.js +14 -0
- package/dist/hub/room-history-model.js.map +1 -0
- package/dist/hub/room-members-model.d.ts +63 -0
- package/dist/hub/room-members-model.js +7 -0
- package/dist/hub/room-members-model.js.map +1 -0
- package/dist/hub/room-mention-feedback-model.d.ts +12 -0
- package/dist/hub/room-mention-feedback-model.js +12 -0
- package/dist/hub/room-mention-feedback-model.js.map +1 -0
- package/dist/hub/room-react-ack-model.d.ts +2 -0
- package/dist/hub/room-react-ack-model.js +3 -0
- package/dist/hub/room-react-ack-model.js.map +1 -0
- package/dist/hub/rooms/admin.d.ts +6 -0
- package/dist/hub/rooms/admin.js +33 -0
- package/dist/hub/rooms/admin.js.map +1 -1
- package/dist/hub/rooms/agents.d.ts +52 -11
- package/dist/hub/rooms/agents.js +418 -37
- package/dist/hub/rooms/agents.js.map +1 -1
- package/dist/hub/rooms/asker-identity.d.ts +21 -0
- package/dist/hub/rooms/asker-identity.js +86 -0
- package/dist/hub/rooms/asker-identity.js.map +1 -0
- package/dist/hub/rooms/assistant.d.ts +1 -6
- package/dist/hub/rooms/assistant.js +7 -2
- package/dist/hub/rooms/assistant.js.map +1 -1
- package/dist/hub/rooms/automation.d.ts +24 -0
- package/dist/hub/rooms/automation.js +66 -0
- package/dist/hub/rooms/automation.js.map +1 -0
- package/dist/hub/rooms/brief.d.ts +18 -0
- package/dist/hub/rooms/brief.js +39 -0
- package/dist/hub/rooms/brief.js.map +1 -0
- package/dist/hub/rooms/buttons.d.ts +85 -0
- package/dist/hub/rooms/buttons.js +62 -0
- package/dist/hub/rooms/buttons.js.map +1 -0
- package/dist/hub/rooms/context-cursor.d.ts +18 -0
- package/dist/hub/rooms/context-cursor.js +61 -0
- package/dist/hub/rooms/context-cursor.js.map +1 -0
- package/dist/hub/rooms/context.d.ts +1 -1
- package/dist/hub/rooms/context.js +4 -4
- package/dist/hub/rooms/context.js.map +1 -1
- package/dist/hub/rooms/direct-view.d.ts +12 -3
- package/dist/hub/rooms/direct-view.js +26 -10
- package/dist/hub/rooms/direct-view.js.map +1 -1
- package/dist/hub/rooms/directory.d.ts +13 -0
- package/dist/hub/rooms/directory.js +12 -3
- package/dist/hub/rooms/directory.js.map +1 -1
- package/dist/hub/rooms/history.d.ts +8 -0
- package/dist/hub/rooms/history.js +31 -0
- package/dist/hub/rooms/history.js.map +1 -0
- package/dist/hub/rooms/members-page.d.ts +33 -0
- package/dist/hub/rooms/members-page.js +37 -0
- package/dist/hub/rooms/members-page.js.map +1 -0
- package/dist/hub/rooms/mentions.d.ts +15 -0
- package/dist/hub/rooms/mentions.js +43 -0
- package/dist/hub/rooms/mentions.js.map +1 -0
- package/dist/hub/rooms/office.d.ts +141 -0
- package/dist/hub/rooms/office.js +81 -0
- package/dist/hub/rooms/office.js.map +1 -0
- package/dist/hub/rooms/post-replies.d.ts +23 -0
- package/dist/hub/rooms/post-replies.js +114 -0
- package/dist/hub/rooms/post-replies.js.map +1 -0
- package/dist/hub/rooms/purpose.d.ts +7 -0
- package/dist/hub/rooms/purpose.js +14 -0
- package/dist/hub/rooms/purpose.js.map +1 -0
- package/dist/hub/rooms/schema.d.ts +16 -0
- package/dist/hub/rooms/schema.js +56 -0
- package/dist/hub/rooms/schema.js.map +1 -1
- package/dist/hub/rooms/service.d.ts +400 -8
- package/dist/hub/rooms/service.js +1231 -72
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +48 -4
- package/dist/hub/rooms.d.ts +33 -6
- package/dist/hub/rooms.js +236 -51
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/runtime.d.ts +1 -1
- package/dist/hub/runtime.js +17 -4
- package/dist/hub/runtime.js.map +1 -1
- package/dist/hub/send-timing.d.ts +6 -0
- package/dist/hub/send-timing.js +39 -0
- package/dist/hub/send-timing.js.map +1 -0
- package/dist/hub/server.d.ts +8 -1
- package/dist/hub/server.js +187 -7
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/session-directory-transition.d.ts +3 -1
- package/dist/hub/session-directory-transition.js +25 -12
- package/dist/hub/session-directory-transition.js.map +1 -1
- package/dist/hub/session-epoch.js +2 -1
- package/dist/hub/session-epoch.js.map +1 -1
- package/dist/hub/session-limits.d.ts +58 -0
- package/dist/hub/session-limits.js +121 -0
- package/dist/hub/session-limits.js.map +1 -0
- package/dist/hub/sessions.d.ts +5 -2
- package/dist/hub/sessions.js +84 -12
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/settings-commit.d.ts +32 -1
- package/dist/hub/settings-commit.js +11 -4
- package/dist/hub/settings-commit.js.map +1 -1
- package/dist/hub/settings-directory-ca.js +1 -1
- package/dist/hub/settings-directory-ca.js.map +1 -1
- package/dist/hub/settings-directory-control.js +7 -7
- package/dist/hub/settings-directory-control.js.map +1 -1
- package/dist/hub/settings-directory-decision.js +15 -8
- package/dist/hub/settings-directory-decision.js.map +1 -1
- package/dist/hub/settings-directory-http.d.ts +2 -0
- package/dist/hub/settings-directory-http.js +21 -6
- package/dist/hub/settings-directory-http.js.map +1 -1
- package/dist/hub/settings-directory-proof.d.ts +5 -1
- package/dist/hub/settings-directory-proof.js +49 -10
- package/dist/hub/settings-directory-proof.js.map +1 -1
- package/dist/hub/settings-directory-recovery.js +2 -1
- package/dist/hub/settings-directory-recovery.js.map +1 -1
- package/dist/hub/settings-directory-save.d.ts +2 -0
- package/dist/hub/settings-directory-save.js +9 -6
- package/dist/hub/settings-directory-save.js.map +1 -1
- package/dist/hub/settings-member-address-decision.js +3 -2
- package/dist/hub/settings-member-address-decision.js.map +1 -1
- package/dist/hub/settings-web-address-decision.js +2 -1
- package/dist/hub/settings-web-address-decision.js.map +1 -1
- package/dist/hub/sharing-previous-access.d.ts +22 -0
- package/dist/hub/sharing-previous-access.js +93 -0
- package/dist/hub/sharing-previous-access.js.map +1 -0
- package/dist/hub/sharing-requests.d.ts +174 -0
- package/dist/hub/sharing-requests.js +326 -0
- package/dist/hub/sharing-requests.js.map +1 -0
- package/dist/hub/sharing-retention.d.ts +47 -0
- package/dist/hub/sharing-retention.js +83 -0
- package/dist/hub/sharing-retention.js.map +1 -0
- package/dist/hub/sharing-withdrawal.d.ts +14 -0
- package/dist/hub/sharing-withdrawal.js +28 -0
- package/dist/hub/sharing-withdrawal.js.map +1 -0
- package/dist/hub/sharing.js +2 -2
- package/dist/hub/sharing.js.map +1 -1
- package/dist/hub/socket.d.ts +1 -0
- package/dist/hub/socket.js +39 -2
- package/dist/hub/socket.js.map +1 -1
- package/dist/hub/store.d.ts +5 -0
- package/dist/hub/store.js +28 -5
- package/dist/hub/store.js.map +1 -1
- package/dist/hub/teams/index.d.ts +8 -3
- package/dist/hub/teams/index.js +106 -31
- package/dist/hub/teams/index.js.map +1 -1
- package/dist/hub/teams/store.d.ts +5 -1
- package/dist/hub/teams/store.js +25 -2
- package/dist/hub/teams/store.js.map +1 -1
- package/dist/hub/teams/types.d.ts +19 -2
- package/dist/hub/types.d.ts +176 -5
- package/dist/hub-agent-incarnation-record.d.ts +24 -0
- package/dist/hub-agent-incarnation-record.js +46 -0
- package/dist/hub-agent-incarnation-record.js.map +1 -0
- package/dist/hub-character-plan.d.ts +47 -0
- package/dist/hub-character-plan.js +70 -0
- package/dist/hub-character-plan.js.map +1 -0
- package/dist/hub-classic-private.d.ts +19 -0
- package/dist/hub-classic-private.js +64 -0
- package/dist/hub-classic-private.js.map +1 -0
- package/dist/hub-contact-windows.d.ts +23 -0
- package/dist/hub-contact-windows.js +89 -0
- package/dist/hub-contact-windows.js.map +1 -0
- package/dist/hub-page-sharing-settings.d.ts +6 -0
- package/dist/hub-page-sharing-settings.js +19 -0
- package/dist/hub-page-sharing-settings.js.map +1 -0
- package/dist/hub-pairing-summary.d.ts +1 -1
- package/dist/hub-picture-reduce.d.ts +34 -0
- package/dist/hub-picture-reduce.js +101 -0
- package/dist/hub-picture-reduce.js.map +1 -0
- package/dist/hub-picture-worker.d.ts +1 -0
- package/dist/hub-picture-worker.js +19 -0
- package/dist/hub-picture-worker.js.map +1 -0
- package/dist/hub-report-target.d.ts +6 -0
- package/dist/hub-report-target.js +6 -0
- package/dist/hub-report-target.js.map +1 -1
- package/dist/hub-room-conversation.d.ts +14 -0
- package/dist/hub-room-conversation.js +60 -0
- package/dist/hub-room-conversation.js.map +1 -0
- package/dist/hub-room-reply-warning.d.ts +2 -0
- package/dist/hub-room-reply-warning.js +16 -0
- package/dist/hub-room-reply-warning.js.map +1 -0
- package/dist/hub-sharing-notice.d.ts +43 -0
- package/dist/hub-sharing-notice.js +34 -0
- package/dist/hub-sharing-notice.js.map +1 -0
- package/dist/hub-update-notice.d.ts +12 -0
- package/dist/hub-update-notice.js +35 -0
- package/dist/hub-update-notice.js.map +1 -0
- package/dist/human-delivery-receipts.d.ts +27 -5
- package/dist/human-delivery-receipts.js +52 -8
- package/dist/human-delivery-receipts.js.map +1 -1
- package/dist/install-lock.d.ts +15 -1
- package/dist/install-lock.js +16 -8
- package/dist/install-lock.js.map +1 -1
- package/dist/install-ownership.d.ts +165 -0
- package/dist/install-ownership.js +404 -0
- package/dist/install-ownership.js.map +1 -0
- package/dist/instance-config-impact.js +7 -2
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +32 -4
- package/dist/instance-lifecycle.js +111 -25
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instruction-file-sizes.d.ts +46 -0
- package/dist/instruction-file-sizes.js +115 -0
- package/dist/instruction-file-sizes.js.map +1 -0
- package/dist/instructions.d.ts +40 -2
- package/dist/instructions.js +68 -34
- package/dist/instructions.js.map +1 -1
- package/dist/local-pane-endpoint.d.ts +18 -1
- package/dist/local-pane-endpoint.js +44 -2
- package/dist/local-pane-endpoint.js.map +1 -1
- package/dist/locale.d.ts +2 -0
- package/dist/locale.js +956 -295
- package/dist/locale.js.map +1 -1
- package/dist/log-steps.d.ts +5 -0
- package/dist/log-steps.js +6 -2
- package/dist/log-steps.js.map +1 -1
- package/dist/login-controller.d.ts +45 -2
- package/dist/login-controller.js +98 -10
- package/dist/login-controller.js.map +1 -1
- package/dist/login-flows.js +1 -1
- package/dist/login-flows.js.map +1 -1
- package/dist/ls-rows.d.ts +2 -0
- package/dist/ls-rows.js.map +1 -1
- package/dist/memory-guidance.d.ts +5 -0
- package/dist/memory-guidance.js +14 -0
- package/dist/memory-guidance.js.map +1 -0
- package/dist/memory-pressure.js +8 -1
- package/dist/memory-pressure.js.map +1 -1
- package/dist/model-defaults.d.ts +5 -0
- package/dist/model-defaults.js +6 -0
- package/dist/model-defaults.js.map +1 -0
- package/dist/native-agent-admission.d.ts +7 -0
- package/dist/native-agent-admission.js +55 -3
- package/dist/native-agent-admission.js.map +1 -1
- package/dist/native-exec-context.d.ts +11 -0
- package/dist/native-exec-context.js +18 -0
- package/dist/native-exec-context.js.map +1 -0
- package/dist/native-exec-input.d.ts +56 -0
- package/dist/native-exec-input.js +89 -0
- package/dist/native-exec-input.js.map +1 -0
- package/dist/native-mcp.d.ts +26 -1
- package/dist/native-mcp.js +85 -18
- package/dist/native-mcp.js.map +1 -1
- package/dist/native-model-catalog.d.ts +15 -0
- package/dist/native-model-catalog.js +43 -3
- package/dist/native-model-catalog.js.map +1 -1
- package/dist/native-pane-lifecycle.d.ts +12 -0
- package/dist/native-pane-lifecycle.js +28 -2
- package/dist/native-pane-lifecycle.js.map +1 -1
- package/dist/native-pane-manager.d.ts +37 -6
- package/dist/native-pane-manager.js +160 -8
- package/dist/native-pane-manager.js.map +1 -1
- package/dist/native-pane-tools.js +3 -0
- package/dist/native-pane-tools.js.map +1 -1
- package/dist/needs-you-hub.d.ts +7 -0
- package/dist/needs-you-hub.js +48 -7
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +66 -2
- package/dist/needs-you.js +26 -1
- package/dist/needs-you.js.map +1 -1
- package/dist/office-share-page.js +5 -5
- package/dist/office-share-page.js.map +1 -1
- package/dist/office-share.js +2 -1
- package/dist/office-share.js.map +1 -1
- package/dist/outbound-handlers.d.ts +49 -4
- package/dist/outbound-handlers.js +263 -20
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +44 -0
- package/dist/outbound-schemas.js +56 -30
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/package-preimage.js +4 -0
- package/dist/package-preimage.js.map +1 -1
- package/dist/pane-port.d.ts +3 -0
- package/dist/pause-marker.d.ts +1 -1
- package/dist/pause-marker.js +1 -1
- package/dist/pause-marker.js.map +1 -1
- package/dist/plist-args.d.ts +9 -0
- package/dist/plist-args.js +22 -0
- package/dist/plist-args.js.map +1 -0
- package/dist/profile-signins.d.ts +1 -0
- package/dist/profile-signins.js +3 -1
- package/dist/profile-signins.js.map +1 -1
- package/dist/public-preview.d.ts +4 -6
- package/dist/public-preview.js +5 -2
- package/dist/public-preview.js.map +1 -1
- package/dist/public-web-gateway.d.ts +20 -0
- package/dist/public-web-gateway.js +262 -9
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +34 -3
- package/dist/public-web-link.js +50 -3
- package/dist/public-web-link.js.map +1 -1
- package/dist/queued-handoffs.d.ts +16 -4
- package/dist/queued-handoffs.js +18 -1
- package/dist/queued-handoffs.js.map +1 -1
- package/dist/quickstart-api.d.ts +0 -1
- package/dist/quickstart-api.js +8 -1
- package/dist/quickstart-api.js.map +1 -1
- package/dist/quickstart.d.ts +1 -1
- package/dist/quickstart.js +2 -3
- package/dist/quickstart.js.map +1 -1
- package/dist/recover.cjs +2639 -0
- package/dist/remote-card-answer.d.ts +1 -1
- package/dist/remote-card-answer.js +8 -1
- package/dist/remote-card-answer.js.map +1 -1
- package/dist/remote-card-prompt.d.ts +7 -2
- package/dist/remote-card-prompt.js +13 -4
- package/dist/remote-card-prompt.js.map +1 -1
- package/dist/reply-buttons-controller.d.ts +3 -1
- package/dist/reply-buttons-controller.js +1 -1
- package/dist/reply-buttons-controller.js.map +1 -1
- package/dist/reply-dedup.js +3 -1
- package/dist/reply-dedup.js.map +1 -1
- package/dist/reply-draft.d.ts +12 -0
- package/dist/reply-draft.js +81 -0
- package/dist/reply-draft.js.map +1 -0
- package/dist/reply-preview-files.d.ts +38 -0
- package/dist/reply-preview-files.js +142 -0
- package/dist/reply-preview-files.js.map +1 -0
- package/dist/reply-preview-spec.d.ts +18 -0
- package/dist/reply-preview-spec.js +27 -0
- package/dist/reply-preview-spec.js.map +1 -0
- package/dist/request-contact-api.d.ts +15 -0
- package/dist/request-contact-api.js +120 -0
- package/dist/request-contact-api.js.map +1 -0
- package/dist/request-contact-card.d.ts +36 -0
- package/dist/request-contact-card.js +206 -0
- package/dist/request-contact-card.js.map +1 -0
- package/dist/request-contact-gate.d.ts +81 -0
- package/dist/request-contact-gate.js +267 -0
- package/dist/request-contact-gate.js.map +1 -0
- package/dist/request-contact-native.d.ts +52 -0
- package/dist/request-contact-native.js +87 -0
- package/dist/request-contact-native.js.map +1 -0
- package/dist/request-contact-types.d.ts +86 -0
- package/dist/request-contact-types.js +7 -0
- package/dist/request-contact-types.js.map +1 -0
- package/dist/request-context-activation.d.ts +29 -0
- package/dist/request-context-activation.js +85 -0
- package/dist/request-context-activation.js.map +1 -0
- package/dist/request-context-admission.d.ts +22 -0
- package/dist/request-context-admission.js +12 -0
- package/dist/request-context-admission.js.map +1 -0
- package/dist/request-context-boot.d.ts +35 -0
- package/dist/request-context-boot.js +97 -0
- package/dist/request-context-boot.js.map +1 -0
- package/dist/request-context-call-protocol.d.ts +12 -0
- package/dist/request-context-call-protocol.js +14 -0
- package/dist/request-context-call-protocol.js.map +1 -0
- package/dist/request-context-call.d.ts +25 -0
- package/dist/request-context-call.js +35 -0
- package/dist/request-context-call.js.map +1 -0
- package/dist/request-context-compatibility.d.ts +20 -0
- package/dist/request-context-compatibility.js +82 -0
- package/dist/request-context-compatibility.js.map +1 -0
- package/dist/request-context-continuation.d.ts +6 -0
- package/dist/request-context-continuation.js +24 -0
- package/dist/request-context-continuation.js.map +1 -0
- package/dist/request-context-control-api.d.ts +119 -0
- package/dist/request-context-control-api.js +179 -0
- package/dist/request-context-control-api.js.map +1 -0
- package/dist/request-context-control-copy.d.ts +3 -0
- package/dist/request-context-control-copy.js +7 -0
- package/dist/request-context-control-copy.js.map +1 -0
- package/dist/request-context-controller.d.ts +44 -0
- package/dist/request-context-controller.js +129 -0
- package/dist/request-context-controller.js.map +1 -0
- package/dist/request-context-delivery-resolver.d.ts +13 -0
- package/dist/request-context-delivery-resolver.js +30 -0
- package/dist/request-context-delivery-resolver.js.map +1 -0
- package/dist/request-context-drain-projection.d.ts +8 -0
- package/dist/request-context-drain-projection.js +40 -0
- package/dist/request-context-drain-projection.js.map +1 -0
- package/dist/request-context-drain.d.ts +61 -0
- package/dist/request-context-drain.js +291 -0
- package/dist/request-context-drain.js.map +1 -0
- package/dist/request-context-enable-offer.d.ts +13 -0
- package/dist/request-context-enable-offer.js +31 -0
- package/dist/request-context-enable-offer.js.map +1 -0
- package/dist/request-context-exec-owner.d.ts +39 -0
- package/dist/request-context-exec-owner.js +128 -0
- package/dist/request-context-exec-owner.js.map +1 -0
- package/dist/request-context-fence.d.ts +28 -0
- package/dist/request-context-fence.js +58 -0
- package/dist/request-context-fence.js.map +1 -0
- package/dist/request-context-go-back-view.d.ts +1 -0
- package/dist/request-context-go-back-view.js +17 -0
- package/dist/request-context-go-back-view.js.map +1 -0
- package/dist/request-context-helper-readiness.d.ts +14 -0
- package/dist/request-context-helper-readiness.js +23 -0
- package/dist/request-context-helper-readiness.js.map +1 -0
- package/dist/request-context-helper.d.ts +20 -0
- package/dist/request-context-helper.js +41 -0
- package/dist/request-context-helper.js.map +1 -0
- package/dist/request-context-hub-resolver.d.ts +29 -0
- package/dist/request-context-hub-resolver.js +90 -0
- package/dist/request-context-hub-resolver.js.map +1 -0
- package/dist/request-context-human-resolver.d.ts +20 -0
- package/dist/request-context-human-resolver.js +77 -0
- package/dist/request-context-human-resolver.js.map +1 -0
- package/dist/request-context-human.d.ts +112 -0
- package/dist/request-context-human.js +176 -0
- package/dist/request-context-human.js.map +1 -0
- package/dist/request-context-inputs.d.ts +21 -0
- package/dist/request-context-inputs.js +63 -0
- package/dist/request-context-inputs.js.map +1 -0
- package/dist/request-context-installation.d.ts +117 -0
- package/dist/request-context-installation.js +328 -0
- package/dist/request-context-installation.js.map +1 -0
- package/dist/request-context-knowledge.d.ts +5 -0
- package/dist/request-context-knowledge.js +32 -0
- package/dist/request-context-knowledge.js.map +1 -0
- package/dist/request-context-migration.d.ts +75 -0
- package/dist/request-context-migration.js +171 -0
- package/dist/request-context-migration.js.map +1 -0
- package/dist/request-context-native-human.d.ts +20 -0
- package/dist/request-context-native-human.js +91 -0
- package/dist/request-context-native-human.js.map +1 -0
- package/dist/request-context-native-output.d.ts +15 -0
- package/dist/request-context-native-output.js +46 -0
- package/dist/request-context-native-output.js.map +1 -0
- package/dist/request-context-native-result.d.ts +15 -0
- package/dist/request-context-native-result.js +46 -0
- package/dist/request-context-native-result.js.map +1 -0
- package/dist/request-context-off.d.ts +22 -0
- package/dist/request-context-off.js +77 -0
- package/dist/request-context-off.js.map +1 -0
- package/dist/request-context-outside-label.d.ts +5 -0
- package/dist/request-context-outside-label.js +28 -0
- package/dist/request-context-outside-label.js.map +1 -0
- package/dist/request-context-pane.d.ts +33 -0
- package/dist/request-context-pane.js +67 -0
- package/dist/request-context-pane.js.map +1 -0
- package/dist/request-context-pending-work.d.ts +11 -0
- package/dist/request-context-pending-work.js +43 -0
- package/dist/request-context-pending-work.js.map +1 -0
- package/dist/request-context-policy.d.ts +90 -0
- package/dist/request-context-policy.js +194 -0
- package/dist/request-context-policy.js.map +1 -0
- package/dist/request-context-protocol.d.ts +137 -0
- package/dist/request-context-protocol.js +38 -0
- package/dist/request-context-protocol.js.map +1 -0
- package/dist/request-context-readiness.d.ts +49 -0
- package/dist/request-context-readiness.js +64 -0
- package/dist/request-context-readiness.js.map +1 -0
- package/dist/request-context-recovery.d.ts +18 -0
- package/dist/request-context-recovery.js +81 -0
- package/dist/request-context-recovery.js.map +1 -0
- package/dist/request-context-relay.d.ts +19 -0
- package/dist/request-context-relay.js +63 -0
- package/dist/request-context-relay.js.map +1 -0
- package/dist/request-context-reply-pending.d.ts +16 -0
- package/dist/request-context-reply-pending.js +77 -0
- package/dist/request-context-reply-pending.js.map +1 -0
- package/dist/request-context-resolution.d.ts +35 -0
- package/dist/request-context-resolution.js +86 -0
- package/dist/request-context-resolution.js.map +1 -0
- package/dist/request-context-retirement.d.ts +21 -0
- package/dist/request-context-retirement.js +16 -0
- package/dist/request-context-retirement.js.map +1 -0
- package/dist/request-context-returns.d.ts +67 -0
- package/dist/request-context-returns.js +211 -0
- package/dist/request-context-returns.js.map +1 -0
- package/dist/request-context-start.d.ts +15 -0
- package/dist/request-context-start.js +2 -0
- package/dist/request-context-start.js.map +1 -0
- package/dist/request-context-store.d.ts +26 -0
- package/dist/request-context-store.js +144 -0
- package/dist/request-context-store.js.map +1 -0
- package/dist/request-context-turns.d.ts +99 -0
- package/dist/request-context-turns.js +216 -0
- package/dist/request-context-turns.js.map +1 -0
- package/dist/request-context-unproved-label.d.ts +4 -0
- package/dist/request-context-unproved-label.js +25 -0
- package/dist/request-context-unproved-label.js.map +1 -0
- package/dist/request-context-update-guard.d.ts +15 -0
- package/dist/request-context-update-guard.js +54 -0
- package/dist/request-context-update-guard.js.map +1 -0
- package/dist/request-context-view.d.ts +33 -0
- package/dist/request-context-view.js +36 -0
- package/dist/request-context-view.js.map +1 -0
- package/dist/request-context-work.d.ts +50 -0
- package/dist/request-context-work.js +178 -0
- package/dist/request-context-work.js.map +1 -0
- package/dist/request-hub-context.d.ts +131 -0
- package/dist/request-hub-context.js +89 -0
- package/dist/request-hub-context.js.map +1 -0
- package/dist/request-hub-output.d.ts +13 -0
- package/dist/request-hub-output.js +33 -0
- package/dist/request-hub-output.js.map +1 -0
- package/dist/restart-progress.d.ts +6 -0
- package/dist/restart-progress.js +5 -0
- package/dist/restart-progress.js.map +1 -1
- package/dist/retained-human-control.d.ts +11 -0
- package/dist/retained-human-control.js +11 -0
- package/dist/retained-human-control.js.map +1 -0
- package/dist/runtime-api.js +10 -2
- package/dist/runtime-api.js.map +1 -1
- package/dist/runtime-build-info.js +2 -1
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli-install.js +20 -14
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/runtime-cli.js +31 -5
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client-store.d.ts +5 -0
- package/dist/runtime-client-store.js +35 -1
- package/dist/runtime-client-store.js.map +1 -1
- package/dist/runtime-client.d.ts +6 -0
- package/dist/runtime-client.js +63 -15
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +31 -3
- package/dist/runtime-coordinator.js +145 -12
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-install.d.ts +6 -1
- package/dist/runtime-install.js +12 -4
- package/dist/runtime-install.js.map +1 -1
- package/dist/runtime-pane-assets.d.ts +1 -1
- package/dist/runtime-pane-assets.js +1 -1
- package/dist/runtime-pane-assets.js.map +1 -1
- package/dist/runtime-pane-host.d.ts +3 -0
- package/dist/runtime-pane-host.js +39 -21
- package/dist/runtime-pane-host.js.map +1 -1
- package/dist/runtime-pane-link.d.ts +6 -2
- package/dist/runtime-pane-link.js +17 -4
- package/dist/runtime-pane-link.js.map +1 -1
- package/dist/runtime-pane-mcp-relay.d.ts +11 -1
- package/dist/runtime-pane-mcp-relay.js +69 -3
- package/dist/runtime-pane-mcp-relay.js.map +1 -1
- package/dist/runtime-pane-mcp.d.ts +37 -1
- package/dist/runtime-pane-mcp.js +120 -19
- package/dist/runtime-pane-mcp.js.map +1 -1
- package/dist/runtime-pane-native.js +5 -2
- package/dist/runtime-pane-native.js.map +1 -1
- package/dist/runtime-pane-port.d.ts +6 -0
- package/dist/runtime-pane-port.js +23 -4
- package/dist/runtime-pane-port.js.map +1 -1
- package/dist/runtime-pane-protocol.d.ts +4 -0
- package/dist/runtime-pane-protocol.js +11 -4
- package/dist/runtime-pane-protocol.js.map +1 -1
- package/dist/runtime-pane-service.d.ts +1 -0
- package/dist/runtime-pane-service.js +25 -9
- package/dist/runtime-pane-service.js.map +1 -1
- package/dist/runtime-pane-stdio-protocol.d.ts +4 -0
- package/dist/runtime-pane-stdio-protocol.js +12 -5
- package/dist/runtime-pane-stdio-protocol.js.map +1 -1
- package/dist/runtime-pane-stdio.js +5 -5
- package/dist/runtime-pane-stdio.js.map +1 -1
- package/dist/runtime-personal-answer-only-probe.d.ts +3 -0
- package/dist/runtime-personal-answer-only-probe.js +134 -0
- package/dist/runtime-personal-answer-only-probe.js.map +1 -0
- package/dist/runtime-personal-answer-only.d.ts +16 -0
- package/dist/runtime-personal-answer-only.js +54 -0
- package/dist/runtime-personal-answer-only.js.map +1 -0
- package/dist/runtime-personal-answer.d.ts +30 -0
- package/dist/runtime-personal-answer.js +124 -0
- package/dist/runtime-personal-answer.js.map +1 -0
- package/dist/runtime-personal-preflight.d.ts +8 -0
- package/dist/runtime-personal-preflight.js +103 -0
- package/dist/runtime-personal-preflight.js.map +1 -0
- package/dist/runtime-personal-profile.d.ts +40 -0
- package/dist/runtime-personal-profile.js +81 -0
- package/dist/runtime-personal-profile.js.map +1 -0
- package/dist/runtime-personal-protocol.d.ts +10 -0
- package/dist/runtime-personal-protocol.js +15 -0
- package/dist/runtime-personal-protocol.js.map +1 -0
- package/dist/runtime-personal-stage.d.ts +37 -0
- package/dist/runtime-personal-stage.js +167 -0
- package/dist/runtime-personal-stage.js.map +1 -0
- package/dist/runtime-protocol.d.ts +7 -0
- package/dist/runtime-protocol.js.map +1 -1
- package/dist/runtime-update-controller.js +1 -1
- package/dist/runtime-update-controller.js.map +1 -1
- package/dist/runtime-windows-bridge.d.ts +8 -0
- package/dist/runtime-windows-bridge.js +50 -3
- package/dist/runtime-windows-bridge.js.map +1 -1
- package/dist/scheduler/db.js +37 -0
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/scheduler.d.ts +15 -0
- package/dist/scheduler/scheduler.js +45 -1
- package/dist/scheduler/scheduler.js.map +1 -1
- package/dist/scheduler/scheduler.test.js +17 -0
- package/dist/scheduler/scheduler.test.js.map +1 -1
- package/dist/scheduler/task-board-mentions.d.ts +32 -0
- package/dist/scheduler/task-board-mentions.js +97 -0
- package/dist/scheduler/task-board-mentions.js.map +1 -0
- package/dist/scheduler/task-board-text.d.ts +5 -6
- package/dist/scheduler/task-board-text.js +30 -10
- package/dist/scheduler/task-board-text.js.map +1 -1
- package/dist/scheduler/task-board-unread.d.ts +90 -0
- package/dist/scheduler/task-board-unread.js +192 -0
- package/dist/scheduler/task-board-unread.js.map +1 -0
- package/dist/scheduler/task-board.d.ts +628 -10
- package/dist/scheduler/task-board.js +1496 -48
- package/dist/scheduler/task-board.js.map +1 -1
- package/dist/scheduler/task-files.d.ts +80 -0
- package/dist/scheduler/task-files.js +357 -0
- package/dist/scheduler/task-files.js.map +1 -0
- package/dist/scheduler/types.d.ts +1 -1
- package/dist/service-activation.js +3 -13
- package/dist/service-activation.js.map +1 -1
- package/dist/service-install-handover.d.ts +52 -0
- package/dist/service-install-handover.js +50 -0
- package/dist/service-install-handover.js.map +1 -0
- package/dist/service-installer.d.ts +12 -0
- package/dist/service-installer.js +24 -10
- package/dist/service-installer.js.map +1 -1
- package/dist/service-lock.d.ts +28 -0
- package/dist/service-lock.js +85 -0
- package/dist/service-lock.js.map +1 -0
- package/dist/settings-api.d.ts +46 -1
- package/dist/settings-api.js +642 -97
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +6 -0
- package/dist/settings-baseline.js +11 -8
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-change.js +60 -7
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-confirmation.d.ts +2 -0
- package/dist/settings-confirmation.js +6 -0
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.d.ts +11 -0
- package/dist/settings-effect.js +154 -7
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +3 -0
- package/dist/settings-http-confirmation.js +46 -43
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-instance-patch.js +3 -1
- package/dist/settings-instance-patch.js.map +1 -1
- package/dist/settings-route-lifetime.d.ts +3 -1
- package/dist/settings-route-lifetime.js +15 -5
- package/dist/settings-route-lifetime.js.map +1 -1
- package/dist/settings-transaction.d.ts +3 -2
- package/dist/settings-transaction.js.map +1 -1
- package/dist/setup-form.js +10 -0
- package/dist/setup-form.js.map +1 -1
- package/dist/setup-host.d.ts +2 -3
- package/dist/setup-host.js +3 -5
- package/dist/setup-host.js.map +1 -1
- package/dist/setup-i18n.js +2 -2
- package/dist/setup-i18n.js.map +1 -1
- package/dist/setup-wizard.js +0 -2
- package/dist/setup-wizard.js.map +1 -1
- package/dist/shared-default-adoption.d.ts +24 -0
- package/dist/shared-default-adoption.js +73 -0
- package/dist/shared-default-adoption.js.map +1 -0
- package/dist/state-lease.d.ts +24 -0
- package/dist/state-lease.js +103 -0
- package/dist/state-lease.js.map +1 -0
- package/dist/subagent-records.d.ts +2 -0
- package/dist/subagent-records.js +64 -12
- package/dist/subagent-records.js.map +1 -1
- package/dist/subagent-service.d.ts +3 -0
- package/dist/subagent-service.js +27 -5
- package/dist/subagent-service.js.map +1 -1
- package/dist/task-attach-client.d.ts +43 -0
- package/dist/task-attach-client.js +125 -0
- package/dist/task-attach-client.js.map +1 -0
- package/dist/task-board-tool.d.ts +60 -0
- package/dist/task-board-tool.js +216 -11
- package/dist/task-board-tool.js.map +1 -1
- package/dist/task-board-waker.d.ts +75 -31
- package/dist/task-board-waker.js +311 -101
- package/dist/task-board-waker.js.map +1 -1
- package/dist/task-file-limits.d.ts +15 -0
- package/dist/task-file-limits.js +21 -0
- package/dist/task-file-limits.js.map +1 -0
- package/dist/tips.js +4 -4
- package/dist/tips.js.map +1 -1
- package/dist/tmux-binary.js +1 -1
- package/dist/tmux-binary.js.map +1 -1
- package/dist/tmux-manager.d.ts +2 -0
- package/dist/tmux-manager.js +2 -0
- package/dist/tmux-manager.js.map +1 -1
- package/dist/tool-permissions.d.ts +32 -0
- package/dist/tool-permissions.js +68 -2
- package/dist/tool-permissions.js.map +1 -1
- package/dist/tool-progress.d.ts +9 -0
- package/dist/tool-progress.js +141 -32
- package/dist/tool-progress.js.map +1 -1
- package/dist/tool-receipt-output.d.ts +8 -6
- package/dist/topic-commands.d.ts +7 -1
- package/dist/topic-commands.js +124 -92
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-monitor.d.ts +7 -1
- package/dist/transcript-monitor.js +79 -3
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-turns.d.ts +3 -0
- package/dist/transcript-turns.js +5 -0
- package/dist/transcript-turns.js.map +1 -1
- package/dist/tunnel/lease.d.ts +14 -0
- package/dist/tunnel/lease.js +23 -0
- package/dist/tunnel/lease.js.map +1 -1
- package/dist/tunnel/named-link-test.d.ts +27 -0
- package/dist/tunnel/named-link-test.js +41 -0
- package/dist/tunnel/named-link-test.js.map +1 -1
- package/dist/turn-reply-guard.d.ts +18 -3
- package/dist/turn-reply-guard.js +23 -5
- package/dist/turn-reply-guard.js.map +1 -1
- package/dist/types.d.ts +50 -2
- package/dist/ui/accounts-keepalive.js +4 -2
- package/dist/ui/accounts-view.js +18 -9
- package/dist/ui/agent-details-settings.js +11 -7
- package/dist/ui/agent-export-dialog.js +4 -3
- package/dist/ui/agent-export-strings.js +5 -5
- package/dist/ui/agent-page-strings.js +23 -5
- package/dist/ui/agent-who-can-use-strings.js +125 -0
- package/dist/ui/agent-who-can-use.js +238 -0
- package/dist/ui/app.html +2 -2
- package/dist/ui/backend-signin.js +94 -23
- package/dist/ui/chat-activity-groups.js +42 -9
- package/dist/ui/chat-activity.js +24 -4
- package/dist/ui/chat-commands.js +2 -0
- package/dist/ui/chat-mentions.js +13 -0
- package/dist/ui/chat-msg-actions.js +3 -222
- package/dist/ui/chat-pins.js +107 -0
- package/dist/ui/chat-popout-header.js +2 -2
- package/dist/ui/chat-popout-transport.js +49 -19
- package/dist/ui/chat-popout.js +15 -1
- package/dist/ui/chat-quote.js +3 -261
- package/dist/ui/chat-store.js +182 -19
- package/dist/ui/chat-task-ref-strings.js +24 -0
- package/dist/ui/chat-task-refs.js +131 -0
- package/dist/ui/chat-tour.js +1 -1
- package/dist/ui/chat-workspace.js +3 -3
- package/dist/ui/claude-credentials.js +124 -0
- package/dist/ui/claude-setup-token.js +36 -0
- package/dist/ui/contact-auth-client.js +55 -0
- package/dist/ui/contact-auth-strings.js +272 -0
- package/dist/ui/contact-authorizations.js +159 -0
- package/dist/ui/contact-grant-editor.js +110 -0
- package/dist/ui/contact-needs.js +124 -0
- package/dist/ui/contact-permissions.js +278 -0
- package/dist/ui/contact-ticket-badge.js +54 -0
- package/dist/ui/contact-tool-groups.js +39 -0
- package/dist/ui/contact-verify-need.js +46 -0
- package/dist/ui/fleet-cache.js +7 -6
- package/dist/ui/fleet-canvas.js +21 -8
- package/dist/ui/fleet-office-card.js +505 -45
- package/dist/ui/fleet-office-carousel.d.ts +14 -0
- package/dist/ui/fleet-office-carousel.js +95 -0
- package/dist/ui/fleet-office-dialogue.d.ts +6 -3
- package/dist/ui/fleet-office-dialogue.js +16 -6
- package/dist/ui/fleet-office-editor.js +11 -6
- package/dist/ui/fleet-office-layout.js +15 -15
- package/dist/ui/fleet-office-model.js +5 -3
- package/dist/ui/fleet-office-overview.js +1 -1
- package/dist/ui/fleet-office-pack.d.ts +92 -5
- package/dist/ui/fleet-office-pack.js +596 -50
- package/dist/ui/fleet-office-play.js +498 -0
- package/dist/ui/fleet-office-skin.js +360 -52
- package/dist/ui/fleet-office-store.js +121 -5
- package/dist/ui/fleet-office-talk.js +423 -0
- package/dist/ui/fleet-office-vehicles.js +147 -0
- package/dist/ui/fleet-office-view.js +58 -17
- package/dist/ui/fleet-office-zones.js +174 -39
- package/dist/ui/fleet-office.js +1462 -188
- package/dist/ui/fleet-org.js +9 -4
- package/dist/ui/fleet-route.js +44 -6
- package/dist/ui/fleet-tab-icons.js +19 -0
- package/dist/ui/fleet-task-activity.js +430 -0
- package/dist/ui/fleet-task-archive.js +111 -0
- package/dist/ui/fleet-task-card.js +386 -317
- package/dist/ui/fleet-task-common.js +117 -13
- package/dist/ui/fleet-task-create.js +67 -0
- package/dist/ui/fleet-task-edit.js +211 -0
- package/dist/ui/fleet-task-files.js +196 -0
- package/dist/ui/fleet-task-flow.js +353 -0
- package/dist/ui/fleet-task-follow.js +123 -0
- package/dist/ui/fleet-task-md.js +98 -0
- package/dist/ui/fleet-task-menu.js +2 -2
- package/dist/ui/fleet-task-owner.js +252 -0
- package/dist/ui/fleet-task-run.js +333 -0
- package/dist/ui/fleet-task-sort.js +88 -0
- package/dist/ui/fleet-task-stats.js +2 -2
- package/dist/ui/fleet-task-thread.js +245 -0
- package/dist/ui/fleet-task-unread.js +100 -0
- package/dist/ui/fleet-task-view.js +221 -46
- package/dist/ui/fleet-task-wake.js +140 -0
- package/dist/ui/fleet-task-work.js +2 -2
- package/dist/ui/fleet-tasks.js +336 -145
- package/dist/ui/fleet-usage.js +8 -7
- package/dist/ui/host-alerts.js +23 -0
- package/dist/ui/host-footprint.js +17 -0
- package/dist/ui/host-health-model.js +42 -0
- package/dist/ui/host-health.js +82 -0
- package/dist/ui/host-install.js +87 -7
- package/dist/ui/host-monitoring-darwin.js +6 -0
- package/dist/ui/host-monitoring-help.js +7 -0
- package/dist/ui/host-monitoring-linux.js +6 -0
- package/dist/ui/host-monitoring-wsl.js +6 -0
- package/dist/ui/host-time.js +5 -0
- package/dist/ui/hub-admin-overview.js +190 -0
- package/dist/ui/hub-admin-rooms-strings.js +6 -2
- package/dist/ui/hub-admin-rooms.js +4 -2
- package/dist/ui/hub-agent-copy.js +8 -2
- package/dist/ui/hub-agent-intro.js +36 -0
- package/dist/ui/hub-ai-apps-strings.js +6 -0
- package/dist/ui/hub-ai-apps.js +84 -0
- package/dist/ui/hub-assistant-admin.js +2 -1
- package/dist/ui/hub-attachments.js +81 -3
- package/dist/ui/hub-chat-store.js +4 -3
- package/dist/ui/hub-chat-strings.js +14 -4
- package/dist/ui/hub-client.js +126 -12
- package/dist/ui/hub-directory-editor-strings.js +2 -2
- package/dist/ui/hub-directory-editor.js +1 -0
- package/dist/ui/hub-directory-notices.js +2 -1
- package/dist/ui/hub-enrolment-code.js +2 -1
- package/dist/ui/hub-fleet-versions.js +393 -0
- package/dist/ui/hub-grant-picker.js +28 -47
- package/dist/ui/hub-group-policy.js +26 -13
- package/dist/ui/hub-group-search.js +2 -2
- package/dist/ui/hub-group-strings.js +28 -18
- package/dist/ui/hub-intro-notice.js +16 -0
- package/dist/ui/hub-invitations.js +5 -1
- package/dist/ui/hub-join-steps.js +27 -15
- package/dist/ui/hub-my-agents-model.js +42 -0
- package/dist/ui/hub-my-agents-strings.js +20 -0
- package/dist/ui/hub-my-agents.js +170 -0
- package/dist/ui/hub-notify-keep.js +49 -0
- package/dist/ui/hub-owner-strings.js +9 -8
- package/dist/ui/hub-personal-agent-strings.js +246 -0
- package/dist/ui/hub-personal-agent.js +119 -0
- package/dist/ui/hub-policy-subjects.js +35 -0
- package/dist/ui/hub-quick-pairing.js +9 -3
- package/dist/ui/hub-quota.js +2 -1
- package/dist/ui/hub-role-audit.js +40 -0
- package/dist/ui/hub-role-forms.js +100 -0
- package/dist/ui/hub-role-notices.js +11 -0
- package/dist/ui/hub-role-view.js +87 -0
- package/dist/ui/hub-roles-strings.js +444 -0
- package/dist/ui/hub-roles.js +84 -0
- package/dist/ui/hub-room-agent-strings.js +29 -0
- package/dist/ui/hub-room-composer.js +174 -17
- package/dist/ui/hub-room-list.js +8 -5
- package/dist/ui/hub-room-members-strings.js +11 -4
- package/dist/ui/hub-room-members.js +134 -18
- package/dist/ui/hub-room-new-strings.js +2 -1
- package/dist/ui/hub-room-new.js +17 -7
- package/dist/ui/hub-room-notify.js +162 -0
- package/dist/ui/hub-room-office.js +271 -0
- package/dist/ui/hub-room-owner-requests-strings.js +114 -0
- package/dist/ui/hub-room-owner-requests.js +265 -0
- package/dist/ui/hub-room-pins.js +44 -0
- package/dist/ui/hub-room-presence.js +19 -2
- package/dist/ui/hub-room-purpose.js +35 -0
- package/dist/ui/hub-room-search.js +126 -0
- package/dist/ui/hub-room-settings-strings.js +8 -0
- package/dist/ui/hub-room-settings.js +110 -3
- package/dist/ui/hub-room-source-strings.js +17 -0
- package/dist/ui/hub-room-source.js +37 -0
- package/dist/ui/hub-room-strings.js +102 -7
- package/dist/ui/hub-room-thread.js +522 -69
- package/dist/ui/hub-room-unread.js +2 -1
- package/dist/ui/hub-room-working.js +37 -0
- package/dist/ui/hub-session-limits.js +79 -0
- package/dist/ui/hub-strings.js +23 -10
- package/dist/ui/hub-subject-picker.js +58 -0
- package/dist/ui/hub-switcher.js +2 -2
- package/dist/ui/hub-teams-strings.js +10 -6
- package/dist/ui/hub-teams.js +58 -29
- package/dist/ui/hub-this-hub.js +2 -2
- package/dist/ui/hub-welcome.js +122 -75
- package/dist/ui/icons/hub-apple-touch-icon.png +0 -0
- package/dist/ui/icons/hub-favicon.ico +0 -0
- package/dist/ui/icons/hub-favicon.svg +10 -0
- package/dist/ui/icons/hub-icon-192.png +0 -0
- package/dist/ui/icons/hub-icon-512.png +0 -0
- package/dist/ui/icons/hub-icon-maskable-192.png +0 -0
- package/dist/ui/icons/hub-icon-maskable-512.png +0 -0
- package/dist/ui/icons/hub-maskable.svg +12 -0
- package/dist/ui/image-annotate.js +2 -283
- package/dist/ui/image-lightbox.js +2 -176
- package/dist/ui/image-zoom.js +2 -242
- package/dist/ui/log-row.js +11 -8
- package/dist/ui/model-picker.js +7 -3
- package/dist/ui/native-instance-settings.js +4 -2
- package/dist/ui/notice-hub-sharing.js +81 -0
- package/dist/ui/notice-hub-update.js +94 -0
- package/dist/ui/office-share-dialog.js +4 -3
- package/dist/ui/office-share-page.js +7 -2
- package/dist/ui/page-share-dialog.js +3 -2
- package/dist/ui/panel-chat.js +515 -81
- package/dist/ui/panel-details.js +27 -3
- package/dist/ui/panel-fleet.js +61 -21
- package/dist/ui/panel-hub.js +478 -135
- package/dist/ui/panel-log.js +7 -7
- package/dist/ui/panel-needs.js +139 -28
- package/dist/ui/panel-notices.js +6 -2
- package/dist/ui/panel-runtimes.js +6 -4
- package/dist/ui/panel-settings.js +150 -61
- package/dist/ui/panel-windows-cli.js +4 -3
- package/dist/ui/preview-panel.js +3 -1
- package/dist/ui/preview-popout.js +134 -0
- package/dist/ui/reply-file-preview.js +65 -0
- package/dist/ui/request-contact-card.js +287 -0
- package/dist/ui/request-contact-client.js +83 -0
- package/dist/ui/request-contact-page.js +78 -0
- package/dist/ui/request-context-control.js +209 -0
- package/dist/ui/runtime-cli-install.js +3 -2
- package/dist/ui/runtime-commands.d.ts +2 -2
- package/dist/ui/runtime-commands.js +7 -4
- package/dist/ui/runtime-update-status.js +1 -1
- package/dist/ui/search-dialog.js +8 -1
- package/dist/ui/settings-access-overview.js +5 -4
- package/dist/ui/settings-access-strings.js +1 -1
- package/dist/ui/settings-appearance.js +15 -12
- package/dist/ui/settings-apply.js +8 -3
- package/dist/ui/settings-archive-files.js +109 -0
- package/dist/ui/settings-build-version.js +2 -2
- package/dist/ui/settings-capabilities.js +2 -0
- package/dist/ui/settings-catalog.js +22 -0
- package/dist/ui/settings-connector-strings.js +23 -0
- package/dist/ui/settings-connector.js +40 -0
- package/dist/ui/settings-default-model-scope.js +40 -0
- package/dist/ui/settings-default-model-strings.js +43 -0
- package/dist/ui/settings-dialogs.js +9 -5
- package/dist/ui/settings-guests-entries.js +16 -0
- package/dist/ui/settings-guests.js +61 -18
- package/dist/ui/settings-host-alerts.js +23 -0
- package/dist/ui/settings-host-monitoring.js +71 -0
- package/dist/ui/settings-hub-connection.js +6 -7
- package/dist/ui/settings-hub-member-address.js +2 -1
- package/dist/ui/settings-hub-membership.js +6 -7
- package/dist/ui/settings-hub-page-sharing.js +52 -0
- package/dist/ui/settings-hub-section.js +2 -4
- package/dist/ui/settings-hub-setup-strings.js +1 -1
- package/dist/ui/settings-hub-setup.js +4 -2
- package/dist/ui/settings-hub-updates.js +67 -0
- package/dist/ui/settings-hub-web-address.js +2 -1
- package/dist/ui/settings-hub.js +37 -8
- package/dist/ui/settings-layout.js +18 -15
- package/dist/ui/settings-model.js +9 -5
- package/dist/ui/settings-named-test.js +16 -16
- package/dist/ui/settings-preview-address.js +156 -0
- package/dist/ui/settings-public-session-strings.js +2 -2
- package/dist/ui/settings-quota-notice.js +3 -3
- package/dist/ui/settings-registry.js +32 -5
- package/dist/ui/settings-revoke-strings.js +1 -1
- package/dist/ui/settings-shared-strings.js +35 -2
- package/dist/ui/settings-shared.js +67 -14
- package/dist/ui/settings-strings.js +58 -49
- package/dist/ui/settings-update.js +28 -7
- package/dist/ui/settings-web-authority.js +9 -6
- package/dist/ui/shared/access-overview.css +2 -2
- package/dist/ui/shared/accounts-keepalive.css +1 -1
- package/dist/ui/shared/accounts.css +9 -5
- package/dist/ui/shared/agent-sheet.js +121 -0
- package/dist/ui/shared/agent-widget.js +1 -2
- package/dist/ui/shared/app-i18n.js +12 -4
- package/dist/ui/shared/app-install.js +123 -0
- package/dist/ui/shared/app-nav.js +9 -5
- package/dist/ui/shared/app-needs.js +8 -1
- package/dist/ui/shared/app-prefs.js +9 -3
- package/dist/ui/shared/app-route.js +5 -3
- package/dist/ui/shared/app-session.js +4 -3
- package/dist/ui/shared/app-shell.js +218 -46
- package/dist/ui/shared/app-store.js +7 -3
- package/dist/ui/shared/app-stream.js +11 -2
- package/dist/ui/shared/app-swipe.js +3 -1
- package/dist/ui/shared/app-themes.js +3 -5
- package/dist/ui/shared/app-update.js +107 -10
- package/dist/ui/shared/app.css +1398 -275
- package/dist/ui/shared/app.js +34 -5
- package/dist/ui/shared/asset-url.d.ts +2 -0
- package/dist/ui/shared/asset-url.js +20 -0
- package/dist/ui/shared/chat-composer.js +30 -8
- package/dist/ui/shared/chat-msg-actions.js +233 -0
- package/dist/ui/shared/chat-quote.js +285 -0
- package/dist/ui/shared/chat-render.js +63 -10
- package/dist/ui/shared/chat-strings.js +49 -24
- package/dist/ui/shared/chat-table-select.js +175 -0
- package/dist/ui/shared/chat-thread.js +181 -29
- package/dist/ui/shared/chat-time.js +7 -4
- package/dist/ui/shared/chat-work-bar.css +97 -15
- package/dist/ui/shared/clock-text.js +57 -0
- package/dist/ui/shared/composer-focus.js +21 -0
- package/dist/ui/shared/connector-prompt.d.ts +3 -0
- package/dist/ui/shared/connector-prompt.js +20 -0
- package/dist/ui/shared/device-roles.js +6 -5
- package/dist/ui/shared/hub-ai-apps.css +12 -0
- package/dist/ui/shared/hub-chat.css +114 -4
- package/dist/ui/shared/hub-groups.css +19 -15
- package/dist/ui/shared/hub-my-agents.css +41 -0
- package/dist/ui/shared/hub-owner.css +123 -3
- package/dist/ui/shared/hub-roles.css +99 -0
- package/dist/ui/shared/hub-rooms-u2.css +98 -0
- package/dist/ui/shared/hub-signin.css +2 -0
- package/dist/ui/shared/hub.css +23 -5
- package/dist/ui/shared/image-annotate.css +22 -3
- package/dist/ui/shared/image-annotate.js +416 -0
- package/dist/ui/shared/image-lightbox.js +218 -0
- package/dist/ui/shared/image-zoom.js +316 -0
- package/dist/ui/shared/info-tip.js +64 -0
- package/dist/ui/shared/instance-nav.js +197 -21
- package/dist/ui/shared/jump-idle.js +36 -0
- package/dist/ui/shared/loading.css +1 -1
- package/dist/ui/shared/model-picker.css +28 -1
- package/dist/ui/shared/module-warm.d.ts +3 -0
- package/dist/ui/shared/module-warm.js +39 -0
- package/dist/ui/shared/office-dialogue.css +122 -0
- package/dist/ui/shared/owner-css.js +1 -1
- package/dist/ui/shared/panel-view.js +7 -1
- package/dist/ui/shared/preview-panel-actions.js +1 -1
- package/dist/ui/shared/preview-panel.js +51 -21
- package/dist/ui/shared/preview-popout.css +11 -0
- package/dist/ui/shared/preview.js +11 -2
- package/dist/ui/shared/reply-previews.css +4 -0
- package/dist/ui/shared/runtime-install.css +5 -0
- package/dist/ui/shared/settings-connector.css +7 -0
- package/dist/ui/shared/signin.js +27 -12
- package/dist/ui/shared/task-board.css +733 -11
- package/dist/ui/shared/text-undo.js +17 -3
- package/dist/ui/shared/theme-picker.js +46 -0
- package/dist/ui/shared/theme.js +101 -2
- package/dist/ui/shared/tokens.css +318 -13
- package/dist/ui/shared/ui-confirm.js +10 -5
- package/dist/ui/shared/ui-icons.js +7 -0
- package/dist/ui/shared/ui-menu.js +17 -11
- package/dist/ui/shared/ui-states.js +9 -2
- package/dist/ui/shared/ui-toast.js +4 -4
- package/dist/ui/shared/update-card-ui.js +586 -0
- package/dist/ui/shared/usage-dialog.js +90 -18
- package/dist/ui/shared/view-history.js +2 -1
- package/dist/ui/shared/view-strings.js +57 -13
- package/dist/ui/shared/web-authorize.js +6 -5
- package/dist/ui/shared/workspace.css +7 -0
- package/dist/ui/signin.html +4 -2
- package/dist/ui/structured-signin.js +64 -12
- package/dist/ui/subagent-row.js +5 -3
- package/dist/ui/task-unread.js +70 -0
- package/dist/ui/trigger-complete.js +71 -0
- package/dist/ui/usage-credits-card.js +84 -0
- package/dist/ui/usage-pool.js +2 -1
- package/dist/ui/web-terminal/terminal.css +1 -1
- package/dist/ui/windows-cli-catalog.js +33 -6
- package/dist/ui/workspace-ignored-strings.js +16 -0
- package/dist/ui/workspace-panel.js +21 -10
- package/dist/update-abandon.d.ts +26 -0
- package/dist/update-abandon.js +111 -0
- package/dist/update-abandon.js.map +1 -0
- package/dist/update-card.d.ts +193 -0
- package/dist/update-card.js +620 -0
- package/dist/update-card.js.map +1 -0
- package/dist/update-dispatch.d.ts +24 -2
- package/dist/update-dispatch.js +28 -5
- package/dist/update-dispatch.js.map +1 -1
- package/dist/update-fix.d.ts +66 -0
- package/dist/update-fix.js +67 -0
- package/dist/update-fix.js.map +1 -0
- package/dist/update-forward.d.ts +59 -0
- package/dist/update-forward.js +227 -0
- package/dist/update-forward.js.map +1 -0
- package/dist/update-goback.d.ts +90 -0
- package/dist/update-goback.js +272 -0
- package/dist/update-goback.js.map +1 -0
- package/dist/update-idle.d.ts +66 -0
- package/dist/update-idle.js +199 -0
- package/dist/update-idle.js.map +1 -0
- package/dist/update-install.d.ts +2 -1
- package/dist/update-install.js +18 -10
- package/dist/update-install.js.map +1 -1
- package/dist/update-journal.d.ts +359 -0
- package/dist/update-journal.js +723 -0
- package/dist/update-journal.js.map +1 -0
- package/dist/update-launch.d.ts +1 -1
- package/dist/update-launch.js +10 -3
- package/dist/update-launch.js.map +1 -1
- package/dist/update-npm-env.d.ts +45 -12
- package/dist/update-npm-env.js +48 -0
- package/dist/update-npm-env.js.map +1 -1
- package/dist/update-package-restore.d.ts +84 -0
- package/dist/update-package-restore.js +329 -0
- package/dist/update-package-restore.js.map +1 -0
- package/dist/update-quiescence.d.ts +221 -0
- package/dist/update-quiescence.js +370 -0
- package/dist/update-quiescence.js.map +1 -0
- package/dist/update-readiness-host.d.ts +61 -0
- package/dist/update-readiness-host.js +297 -0
- package/dist/update-readiness-host.js.map +1 -0
- package/dist/update-readiness.d.ts +85 -0
- package/dist/update-readiness.js +463 -0
- package/dist/update-readiness.js.map +1 -0
- package/dist/update-recovery/kit.d.ts +35 -0
- package/dist/update-recovery/kit.js +99 -0
- package/dist/update-recovery/kit.js.map +1 -0
- package/dist/update-recovery/pre-start.d.ts +34 -0
- package/dist/update-recovery/pre-start.js +103 -0
- package/dist/update-recovery/pre-start.js.map +1 -0
- package/dist/update-recovery/recover-main.d.ts +1 -0
- package/dist/update-recovery/recover-main.js +4 -0
- package/dist/update-recovery/recover-main.js.map +1 -0
- package/dist/update-recovery/recover.d.ts +22 -0
- package/dist/update-recovery/recover.js +134 -0
- package/dist/update-recovery/recover.js.map +1 -0
- package/dist/update-recovery/route.d.ts +53 -0
- package/dist/update-recovery/route.js +262 -0
- package/dist/update-recovery/route.js.map +1 -0
- package/dist/update-recovery/runner.d.ts +62 -0
- package/dist/update-recovery/runner.js +229 -0
- package/dist/update-recovery/runner.js.map +1 -0
- package/dist/update-recovery/service-manager.d.ts +39 -0
- package/dist/update-recovery/service-manager.js +57 -0
- package/dist/update-recovery/service-manager.js.map +1 -0
- package/dist/update-restore.d.ts +50 -0
- package/dist/update-restore.js +360 -0
- package/dist/update-restore.js.map +1 -0
- package/dist/update-retained.d.ts +65 -0
- package/dist/update-retained.js +116 -0
- package/dist/update-retained.js.map +1 -0
- package/dist/update-rollback.d.ts +74 -0
- package/dist/update-rollback.js +221 -0
- package/dist/update-rollback.js.map +1 -0
- package/dist/update-settings.d.ts +63 -0
- package/dist/update-settings.js +162 -0
- package/dist/update-settings.js.map +1 -0
- package/dist/update-snapshot-manifest.d.ts +32 -0
- package/dist/update-snapshot-manifest.js +65 -0
- package/dist/update-snapshot-manifest.js.map +1 -0
- package/dist/update-snapshot-scope.d.ts +67 -0
- package/dist/update-snapshot-scope.js +174 -0
- package/dist/update-snapshot-scope.js.map +1 -0
- package/dist/update-snapshot.d.ts +34 -0
- package/dist/update-snapshot.js +246 -0
- package/dist/update-snapshot.js.map +1 -0
- package/dist/update-writers.d.ts +71 -0
- package/dist/update-writers.js +235 -0
- package/dist/update-writers.js.map +1 -0
- package/dist/usage/i18n-keys.d.ts +1 -1
- package/dist/usage/i18n-keys.js +10 -1
- package/dist/usage/i18n-keys.js.map +1 -1
- package/dist/usage/profile-timeline.d.ts +2 -0
- package/dist/usage/profile-timeline.js +4 -0
- package/dist/usage/profile-timeline.js.map +1 -1
- package/dist/usage/providers.d.ts +4 -11
- package/dist/usage/providers.js +109 -134
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/usage-api.js +5 -2
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/wake-coordinator.js +3 -2
- package/dist/wake-coordinator.js.map +1 -1
- package/dist/web-api.d.ts +132 -9
- package/dist/web-api.js +1468 -242
- package/dist/web-api.js.map +1 -1
- package/dist/web-asset-version.d.ts +65 -0
- package/dist/web-asset-version.js +259 -0
- package/dist/web-asset-version.js.map +1 -0
- package/dist/web-backend-login.d.ts +5 -1
- package/dist/web-backend-login.js +8 -2
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-chat-archive.d.ts +147 -0
- package/dist/web-chat-archive.js +530 -0
- package/dist/web-chat-archive.js.map +1 -0
- package/dist/web-chat-history.d.ts +137 -2
- package/dist/web-chat-history.js +335 -12
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-claude-credentials.d.ts +31 -0
- package/dist/web-claude-credentials.js +138 -0
- package/dist/web-claude-credentials.js.map +1 -0
- package/dist/web-commands.d.ts +9 -5
- package/dist/web-commands.js +7 -4
- package/dist/web-commands.js.map +1 -1
- package/dist/web-guest-access.d.ts +3 -0
- package/dist/web-guest-access.js +8 -4
- package/dist/web-guest-access.js.map +1 -1
- package/dist/web-host-guard.js +3 -1
- package/dist/web-host-guard.js.map +1 -1
- package/dist/web-host-install.d.ts +30 -3
- package/dist/web-host-install.js +50 -4
- package/dist/web-host-install.js.map +1 -1
- package/dist/web-icons.d.ts +20 -3
- package/dist/web-icons.js +79 -10
- package/dist/web-icons.js.map +1 -1
- package/dist/web-login.d.ts +13 -1
- package/dist/web-login.js +16 -4
- package/dist/web-login.js.map +1 -1
- package/dist/web-mentions.d.ts +29 -8
- package/dist/web-mentions.js +128 -1
- package/dist/web-mentions.js.map +1 -1
- package/dist/web-notices.d.ts +20 -0
- package/dist/web-notices.js +64 -8
- package/dist/web-notices.js.map +1 -1
- package/dist/web-office-acts.d.ts +16 -0
- package/dist/web-office-acts.js +30 -9
- package/dist/web-office-acts.js.map +1 -1
- package/dist/web-office-pack-read.js +1 -1
- package/dist/web-office-pack-read.js.map +1 -1
- package/dist/web-office-skins.d.ts +19 -6
- package/dist/web-office-skins.js +85 -36
- package/dist/web-office-skins.js.map +1 -1
- package/dist/web-office-store.d.ts +2 -0
- package/dist/web-office-store.js +20 -6
- package/dist/web-office-store.js.map +1 -1
- package/dist/web-pin-store.d.ts +58 -0
- package/dist/web-pin-store.js +170 -0
- package/dist/web-pin-store.js.map +1 -0
- package/dist/web-prefs.js +5 -1
- package/dist/web-prefs.js.map +1 -1
- package/dist/web-preview.d.ts +5 -0
- package/dist/web-preview.js +1 -1
- package/dist/web-preview.js.map +1 -1
- package/dist/web-reply-files.d.ts +1 -0
- package/dist/web-reply-files.js +2 -0
- package/dist/web-reply-files.js.map +1 -1
- package/dist/web-session-authorization.d.ts +27 -0
- package/dist/web-session-authorization.js +32 -0
- package/dist/web-session-authorization.js.map +1 -1
- package/dist/web-session.d.ts +26 -5
- package/dist/web-session.js +32 -3
- package/dist/web-session.js.map +1 -1
- package/dist/web-settings-patch.d.ts +51 -3
- package/dist/web-settings-patch.js +124 -1
- package/dist/web-settings-patch.js.map +1 -1
- package/dist/web-shell-routes.d.ts +2 -2
- package/dist/web-shell-routes.js +3 -2
- package/dist/web-shell-routes.js.map +1 -1
- package/dist/web-terminal.d.ts +9 -0
- package/dist/web-terminal.js +27 -1
- package/dist/web-terminal.js.map +1 -1
- package/dist/web-theme.js +2 -2
- package/dist/web-update.d.ts +30 -1
- package/dist/web-upload.d.ts +37 -1
- package/dist/web-upload.js +105 -5
- package/dist/web-upload.js.map +1 -1
- package/dist/windows-agents.d.ts +36 -2
- package/dist/windows-agents.js +115 -4
- package/dist/windows-agents.js.map +1 -1
- package/dist/windows-cli-api.d.ts +10 -7
- package/dist/windows-cli-api.js +17 -14
- package/dist/windows-cli-api.js.map +1 -1
- package/dist/windows-cli-worker.d.ts +10 -0
- package/dist/windows-cli-worker.js +118 -15
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/windows-cli.d.ts +65 -2
- package/dist/windows-cli.js +192 -28
- package/dist/windows-cli.js.map +1 -1
- package/dist/windows-native-mcp.js +5 -2
- package/dist/windows-native-mcp.js.map +1 -1
- package/dist/windows-shortcuts.d.ts +3 -22
- package/dist/windows-shortcuts.js +5 -45
- package/dist/windows-shortcuts.js.map +1 -1
- package/dist/workflow-templates/default.md +8 -8
- package/dist/wsl-host.d.ts +52 -0
- package/dist/wsl-host.js +97 -0
- package/dist/wsl-host.js.map +1 -0
- package/launcher/agend +4 -1
- package/launcher/agend-agent +4 -1
- package/launcher/agend-install.cjs +63 -14
- package/launcher/install-admission.d.cts +8 -0
- package/launcher/npm-allow-scripts.cjs +72 -0
- package/launcher/npm-global-prefix.cjs +81 -0
- package/launcher/postinstall.cjs +9 -8
- package/launcher/runtime-select.cjs +8 -2
- package/package.json +4 -3
- package/scripts/preinstall-guard.cjs +1 -1
- package/templates/runtime-install/install.ps1 +24 -4
package/dist/recover.cjs
ADDED
|
@@ -0,0 +1,2639 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
try {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw mod = 0, e;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
// launcher/install-admission.cjs
|
|
33
|
+
var require_install_admission = __commonJS({
|
|
34
|
+
"launcher/install-admission.cjs"(exports2, module2) {
|
|
35
|
+
"use strict";
|
|
36
|
+
var fs = require("fs");
|
|
37
|
+
var path = require("path");
|
|
38
|
+
var childProcess = require("child_process");
|
|
39
|
+
var LOCK = ".agend-install.lock";
|
|
40
|
+
var TOKEN_ENV = "AGEND_INSTALL_TOKEN";
|
|
41
|
+
function globalPrefix(pkgDir) {
|
|
42
|
+
var scope = path.dirname(pkgDir);
|
|
43
|
+
var nodeModules = path.dirname(scope);
|
|
44
|
+
var lib = path.dirname(nodeModules);
|
|
45
|
+
if (path.basename(pkgDir) !== "agend" || path.basename(scope) !== "@songsid" || path.basename(nodeModules) !== "node_modules" || path.basename(lib) !== "lib") return null;
|
|
46
|
+
return path.dirname(lib);
|
|
47
|
+
}
|
|
48
|
+
var PS = ["/bin/ps", "/usr/bin/ps"].filter(function(p) {
|
|
49
|
+
try {
|
|
50
|
+
fs.accessSync(p, fs.constants.X_OK);
|
|
51
|
+
return true;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
})[0] || "ps";
|
|
56
|
+
function processStart2(pid) {
|
|
57
|
+
try {
|
|
58
|
+
var env = {};
|
|
59
|
+
Object.keys(process.env).forEach(function(k) {
|
|
60
|
+
env[k] = process.env[k];
|
|
61
|
+
});
|
|
62
|
+
env.LC_ALL = "C";
|
|
63
|
+
env.TZ = "UTC";
|
|
64
|
+
var r = childProcess.spawnSync(PS, ["-o", "lstart=", "-p", String(pid)], { encoding: "utf8", timeout: 15e3, env, stdio: ["ignore", "pipe", "ignore"] });
|
|
65
|
+
var text = String(r.stdout || "").trim();
|
|
66
|
+
return r.status === 0 && text ? text : null;
|
|
67
|
+
} catch (e) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function startTicks2(pid) {
|
|
72
|
+
if (process.platform !== "linux") return null;
|
|
73
|
+
var text;
|
|
74
|
+
try {
|
|
75
|
+
text = fs.readFileSync("/proc/" + pid + "/stat", "utf8");
|
|
76
|
+
} catch (e) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
var fields = text.slice(text.lastIndexOf(")") + 2).split(" ");
|
|
80
|
+
var ticks = fields[19];
|
|
81
|
+
return /^\d+$/.test(ticks || "") ? ticks : null;
|
|
82
|
+
}
|
|
83
|
+
function bootId2() {
|
|
84
|
+
var text;
|
|
85
|
+
try {
|
|
86
|
+
text = fs.readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
87
|
+
} catch (e) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return /^[0-9a-f-]{36}$/.test(text) ? text : null;
|
|
91
|
+
}
|
|
92
|
+
var START_TOLERANCE_MS2 = 2e3;
|
|
93
|
+
function sameStartText2(recorded, seen) {
|
|
94
|
+
if (recorded === seen) return true;
|
|
95
|
+
var a = Date.parse(recorded + " UTC"), b = Date.parse(seen + " UTC");
|
|
96
|
+
return isFinite(a) && isFinite(b) && Math.abs(a - b) <= START_TOLERANCE_MS2;
|
|
97
|
+
}
|
|
98
|
+
function exists2(pid) {
|
|
99
|
+
try {
|
|
100
|
+
process.kill(pid, 0);
|
|
101
|
+
return true;
|
|
102
|
+
} catch (e) {
|
|
103
|
+
return e.code !== "ESRCH";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function holderState2(lock, deps) {
|
|
107
|
+
var d = deps || {};
|
|
108
|
+
if (!(d.exists || exists2)(lock.pid)) return "stale";
|
|
109
|
+
if (typeof lock.startTicks === "string") {
|
|
110
|
+
var boot = (d.bootId || bootId2)();
|
|
111
|
+
if (boot === null || boot === void 0) return "unknown";
|
|
112
|
+
if (boot !== lock.bootId) return "stale";
|
|
113
|
+
var ticks = (d.startTicks || startTicks2)(lock.pid);
|
|
114
|
+
if (ticks === null || ticks === void 0) return "unknown";
|
|
115
|
+
return ticks === lock.startTicks ? "live" : "stale";
|
|
116
|
+
}
|
|
117
|
+
var seen = (d.processStart || processStart2)(lock.pid);
|
|
118
|
+
if (seen === null || seen === void 0) return "unknown";
|
|
119
|
+
return sameStartText2(lock.processStart, seen) ? "live" : "stale";
|
|
120
|
+
}
|
|
121
|
+
function parse(text) {
|
|
122
|
+
var r;
|
|
123
|
+
try {
|
|
124
|
+
r = JSON.parse(text);
|
|
125
|
+
} catch (e) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return r && typeof r === "object" && Number.isSafeInteger(r.pid) && r.pid > 0 && typeof r.processStart === "string" && r.processStart && typeof r.prefix === "string" && typeof r.token === "string" && /^[0-9a-f]{32,}$/.test(r.token) && typeof r.targetSpec === "string" && typeof r.agendHome === "string" && typeof r.createdAt === "string" && (r.startTicks === void 0 && r.bootId === void 0 || typeof r.startTicks === "string" && /^\d+$/.test(r.startTicks) && typeof r.bootId === "string" && /^[0-9a-f-]{36}$/.test(r.bootId)) ? r : null;
|
|
129
|
+
}
|
|
130
|
+
module2.exports = {
|
|
131
|
+
LOCK,
|
|
132
|
+
TOKEN_ENV,
|
|
133
|
+
globalPrefix,
|
|
134
|
+
processStart: processStart2,
|
|
135
|
+
startTicks: startTicks2,
|
|
136
|
+
bootId: bootId2,
|
|
137
|
+
sameStartText: sameStartText2,
|
|
138
|
+
START_TOLERANCE_MS: START_TOLERANCE_MS2,
|
|
139
|
+
exists: exists2,
|
|
140
|
+
holderState: holderState2,
|
|
141
|
+
parse
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// src/update-recovery/recover.ts
|
|
147
|
+
var import_node_child_process3 = require("node:child_process");
|
|
148
|
+
var import_node_crypto7 = require("node:crypto");
|
|
149
|
+
var import_node_path14 = require("node:path");
|
|
150
|
+
var import_install_admission = __toESM(require_install_admission(), 1);
|
|
151
|
+
|
|
152
|
+
// src/update-journal.ts
|
|
153
|
+
var import_node_fs2 = require("node:fs");
|
|
154
|
+
var import_node_path2 = require("node:path");
|
|
155
|
+
|
|
156
|
+
// src/install-lock.ts
|
|
157
|
+
var import_node_fs = require("node:fs");
|
|
158
|
+
var import_node_path = require("node:path");
|
|
159
|
+
var INSTALL_LOCK_FILE = ".agend-install.lock";
|
|
160
|
+
function parseInstallLock(text) {
|
|
161
|
+
let value;
|
|
162
|
+
try {
|
|
163
|
+
value = JSON.parse(text);
|
|
164
|
+
} catch {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
const r = value;
|
|
168
|
+
return r && Number.isSafeInteger(r.pid) && r.pid > 0 && typeof r.processStart === "string" && r.processStart && typeof r.prefix === "string" && typeof r.token === "string" && /^[0-9a-f]{32,}$/.test(r.token) && typeof r.targetSpec === "string" && typeof r.agendHome === "string" && typeof r.createdAt === "string" && (r.installPrefix === void 0 || typeof r.installPrefix === "string" && r.installPrefix !== "") && (r.startTicks === void 0 && r.bootId === void 0 || typeof r.startTicks === "string" && /^\d+$/.test(r.startTicks) && typeof r.bootId === "string" && /^[0-9a-f-]{36}$/.test(r.bootId)) ? r : null;
|
|
169
|
+
}
|
|
170
|
+
var pidExists = (pid) => {
|
|
171
|
+
try {
|
|
172
|
+
process.kill(pid, 0);
|
|
173
|
+
return true;
|
|
174
|
+
} catch (err) {
|
|
175
|
+
return err.code !== "ESRCH";
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
function holderState(record, deps) {
|
|
179
|
+
if (!(deps.exists ?? pidExists)(record.pid)) return "stale";
|
|
180
|
+
if (record.startTicks !== void 0) {
|
|
181
|
+
const boot = deps.bootId?.() ?? null;
|
|
182
|
+
if (boot === null) return "unknown";
|
|
183
|
+
if (boot !== record.bootId) return "stale";
|
|
184
|
+
const ticks = deps.startTicks?.(record.pid) ?? null;
|
|
185
|
+
if (ticks === null) return "unknown";
|
|
186
|
+
return ticks === record.startTicks ? "live" : "stale";
|
|
187
|
+
}
|
|
188
|
+
const seen = deps.processStart(record.pid);
|
|
189
|
+
if (seen === null) return "unknown";
|
|
190
|
+
return sameStartText(record.processStart, seen) ? "live" : "stale";
|
|
191
|
+
}
|
|
192
|
+
var START_TOLERANCE_MS = 2e3;
|
|
193
|
+
function sameStartText(recorded, seen) {
|
|
194
|
+
if (recorded === seen) return true;
|
|
195
|
+
const a = Date.parse(`${recorded} UTC`), b = Date.parse(`${seen} UTC`);
|
|
196
|
+
return Number.isFinite(a) && Number.isFinite(b) && Math.abs(a - b) <= START_TOLERANCE_MS;
|
|
197
|
+
}
|
|
198
|
+
var readOrNull = (path) => {
|
|
199
|
+
try {
|
|
200
|
+
return (0, import_node_fs.readFileSync)(path, "utf8");
|
|
201
|
+
} catch {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
function acquireInstallLock(prefix, target, deps, opts = {}) {
|
|
206
|
+
const file = opts.file ?? INSTALL_LOCK_FILE, name = opts.name ?? "install lock";
|
|
207
|
+
let canonical;
|
|
208
|
+
try {
|
|
209
|
+
canonical = (0, import_node_fs.realpathSync)(prefix);
|
|
210
|
+
} catch {
|
|
211
|
+
return { ok: false, path: (0, import_node_path.join)(prefix, file), reason: `the ${opts.file ? "directory" : "npm prefix"} ${prefix} does not exist` };
|
|
212
|
+
}
|
|
213
|
+
const path = (0, import_node_path.join)(canonical, file);
|
|
214
|
+
const ownStart = deps.processStart(deps.pid);
|
|
215
|
+
if (!ownStart) return { ok: false, path, reason: "this process's own start time cannot be read, so its lock could not be told from a stale one" };
|
|
216
|
+
const ownTicks = deps.startTicks?.(deps.pid) ?? null;
|
|
217
|
+
const ownBoot = deps.bootId?.() ?? null;
|
|
218
|
+
const record = {
|
|
219
|
+
pid: deps.pid,
|
|
220
|
+
processStart: ownStart,
|
|
221
|
+
...ownTicks !== null && ownBoot !== null ? { startTicks: ownTicks, bootId: ownBoot } : {},
|
|
222
|
+
prefix: canonical,
|
|
223
|
+
targetSpec: target.spec,
|
|
224
|
+
agendHome: target.agendHome,
|
|
225
|
+
token: deps.newToken(),
|
|
226
|
+
createdAt: deps.now().toISOString(),
|
|
227
|
+
...target.installPrefix !== void 0 ? { installPrefix: target.installPrefix } : {}
|
|
228
|
+
};
|
|
229
|
+
const serialized = JSON.stringify(record) + "\n";
|
|
230
|
+
const claim = () => {
|
|
231
|
+
try {
|
|
232
|
+
(0, import_node_fs.writeFileSync)(path, serialized, { flag: "wx", mode: 384 });
|
|
233
|
+
return true;
|
|
234
|
+
} catch (err) {
|
|
235
|
+
if (err.code === "EEXIST") return false;
|
|
236
|
+
throw err;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const ours = { ok: true, path, token: record.token, release: () => releaseIfOurs(path, serialized, deps) };
|
|
240
|
+
try {
|
|
241
|
+
if (claim()) return ours;
|
|
242
|
+
} catch (err) {
|
|
243
|
+
return { ok: false, path, reason: `the ${name} ${path} could not be created (${err.message})` };
|
|
244
|
+
}
|
|
245
|
+
const seen = readOrNull(path);
|
|
246
|
+
if (seen === null) return { ok: false, path, reason: `another install is starting on ${canonical} (its lock ${path} appeared and went); retry` };
|
|
247
|
+
const holder = parseInstallLock(seen);
|
|
248
|
+
if (!holder) return { ok: false, path, reason: `the ${name} ${path} cannot be read as a lock; if no other \`agend update\` is running, remove it and retry` };
|
|
249
|
+
const state = holderState(holder, deps);
|
|
250
|
+
if (state === "live") {
|
|
251
|
+
return { ok: false, path, reason: `another AgEnD install is running on ${canonical} (pid ${holder.pid}, installing ${holder.targetSpec} for ${holder.agendHome}); wait for it to finish` };
|
|
252
|
+
}
|
|
253
|
+
if (state === "unknown") {
|
|
254
|
+
return { ok: false, path, reason: `whether the install that holds ${path} (pid ${holder.pid}) is still running cannot be told; retry, or remove the lock once no \`agend update\` runs` };
|
|
255
|
+
}
|
|
256
|
+
const marker = `${path}.reclaim`;
|
|
257
|
+
deps.afterStaleJudged?.();
|
|
258
|
+
try {
|
|
259
|
+
(0, import_node_fs.writeFileSync)(marker, serialized, { flag: "wx", mode: 384 });
|
|
260
|
+
} catch (err) {
|
|
261
|
+
if (err.code !== "EEXIST") return { ok: false, path, reason: `the reclaim marker ${marker} could not be created (${err.message})` };
|
|
262
|
+
const other = parseInstallLock(readOrNull(marker) ?? "");
|
|
263
|
+
const otherState = other ? holderState(other, deps) : "unknown";
|
|
264
|
+
return otherState === "live" ? { ok: false, path, reason: `another install is replacing the stale lock on ${canonical}; retry` } : { ok: false, path, reason: `a reclaim marker ${marker} was left behind (pid ${other?.pid ?? "unknown"}); if no \`agend update\` runs, remove it and retry` };
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
if (readOrNull(path) !== seen) return { ok: false, path, reason: `another install is starting on ${canonical}; retry` };
|
|
268
|
+
const aside = `${path}.stale-${deps.pid}-${record.token.slice(0, 8)}`;
|
|
269
|
+
try {
|
|
270
|
+
(0, import_node_fs.renameSync)(path, aside);
|
|
271
|
+
} catch {
|
|
272
|
+
return { ok: false, path, reason: `another install is starting on ${canonical}; retry` };
|
|
273
|
+
}
|
|
274
|
+
deps.afterStaleMoved?.();
|
|
275
|
+
if (readOrNull(aside) !== seen) {
|
|
276
|
+
try {
|
|
277
|
+
(0, import_node_fs.linkSync)(aside, path);
|
|
278
|
+
(0, import_node_fs.unlinkSync)(aside);
|
|
279
|
+
} catch {
|
|
280
|
+
deps.log(` \u26A0 A ${name} changed while it was being replaced; left at ${aside}.`);
|
|
281
|
+
}
|
|
282
|
+
return { ok: false, path, reason: `another install is starting on ${canonical}; retry` };
|
|
283
|
+
}
|
|
284
|
+
try {
|
|
285
|
+
(0, import_node_fs.unlinkSync)(aside);
|
|
286
|
+
} catch {
|
|
287
|
+
}
|
|
288
|
+
deps.log(` Replaced a stale ${name} (pid ${holder.pid} is gone, was installing ${holder.targetSpec}).`);
|
|
289
|
+
try {
|
|
290
|
+
if (claim()) return ours;
|
|
291
|
+
} catch (err) {
|
|
292
|
+
return { ok: false, path, reason: `the ${name} ${path} could not be created (${err.message})` };
|
|
293
|
+
}
|
|
294
|
+
return { ok: false, path, reason: `another install is starting on ${canonical}; retry` };
|
|
295
|
+
} finally {
|
|
296
|
+
releaseIfOurs(marker, serialized, deps);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function releaseIfOurs(path, serialized, deps) {
|
|
300
|
+
if (readOrNull(path) !== serialized) return;
|
|
301
|
+
const aside = `${path}.release-${deps.pid}`;
|
|
302
|
+
try {
|
|
303
|
+
(0, import_node_fs.renameSync)(path, aside);
|
|
304
|
+
} catch {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (readOrNull(aside) === serialized) {
|
|
308
|
+
try {
|
|
309
|
+
(0, import_node_fs.unlinkSync)(aside);
|
|
310
|
+
} catch {
|
|
311
|
+
}
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
(0, import_node_fs.linkSync)(aside, path);
|
|
316
|
+
} catch {
|
|
317
|
+
deps.log(` \u26A0 The install lock changed while being released; left at ${aside}.`);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
try {
|
|
321
|
+
(0, import_node_fs.unlinkSync)(aside);
|
|
322
|
+
} catch {
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/update-journal.ts
|
|
327
|
+
var TERMINAL = /* @__PURE__ */ new Set(["committed", "rolled-back", "abandoned", "manual-recovery"]);
|
|
328
|
+
var NEXT = {
|
|
329
|
+
opened: ["barrier", "abandoning"],
|
|
330
|
+
barrier: ["stopping", "abandoning"],
|
|
331
|
+
stopping: ["snapshotted", "abandoning"],
|
|
332
|
+
abandoning: ["abandoned"],
|
|
333
|
+
snapshotted: ["installing", "rolling-back"],
|
|
334
|
+
installing: ["trial", "rolling-back"],
|
|
335
|
+
trial: ["proving", "rolling-back"],
|
|
336
|
+
proving: ["committing", "rolling-back"],
|
|
337
|
+
committing: ["committed"],
|
|
338
|
+
"rolling-back": ["rolled-back"],
|
|
339
|
+
abandoned: [],
|
|
340
|
+
committed: [],
|
|
341
|
+
"rolled-back": [],
|
|
342
|
+
"manual-recovery": []
|
|
343
|
+
};
|
|
344
|
+
function canAdvance(from, to) {
|
|
345
|
+
if (TERMINAL.has(from)) return false;
|
|
346
|
+
return to === "manual-recovery" || NEXT[from].includes(to);
|
|
347
|
+
}
|
|
348
|
+
var fsyncDirReal = (dir) => {
|
|
349
|
+
const fd = (0, import_node_fs2.openSync)(dir, "r");
|
|
350
|
+
try {
|
|
351
|
+
(0, import_node_fs2.fsyncSync)(fd);
|
|
352
|
+
} finally {
|
|
353
|
+
(0, import_node_fs2.closeSync)(fd);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
var defaultJournalIo = {
|
|
357
|
+
now: () => /* @__PURE__ */ new Date(),
|
|
358
|
+
writeSynced: (path, data) => {
|
|
359
|
+
const fd = (0, import_node_fs2.openSync)(path, "wx", 384);
|
|
360
|
+
try {
|
|
361
|
+
(0, import_node_fs2.writeSync)(fd, data);
|
|
362
|
+
(0, import_node_fs2.fsyncSync)(fd);
|
|
363
|
+
} finally {
|
|
364
|
+
(0, import_node_fs2.closeSync)(fd);
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
rename: (from, to) => (0, import_node_fs2.renameSync)(from, to),
|
|
368
|
+
link: (from, to) => (0, import_node_fs2.linkSync)(from, to),
|
|
369
|
+
unlink: (path) => (0, import_node_fs2.unlinkSync)(path),
|
|
370
|
+
mkdir: (path) => (0, import_node_fs2.mkdirSync)(path, { mode: 448 }),
|
|
371
|
+
fsyncDir: fsyncDirReal,
|
|
372
|
+
read: (path) => {
|
|
373
|
+
try {
|
|
374
|
+
return (0, import_node_fs2.readFileSync)(path, "utf8");
|
|
375
|
+
} catch (err) {
|
|
376
|
+
if (err.code === "ENOENT") return null;
|
|
377
|
+
throw err;
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
list: (path) => {
|
|
381
|
+
try {
|
|
382
|
+
return (0, import_node_fs2.readdirSync)(path);
|
|
383
|
+
} catch (err) {
|
|
384
|
+
if (err.code === "ENOENT") return [];
|
|
385
|
+
throw err;
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
step: () => {
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
var tmpSeq = 0;
|
|
392
|
+
var tmpOf = (path) => `${path}.tmp-${process.pid}-${Date.now().toString(36)}-${(tmpSeq++).toString(36)}`;
|
|
393
|
+
function writeAtomic(io, path, data) {
|
|
394
|
+
const tmp = tmpOf(path);
|
|
395
|
+
io.writeSynced(tmp, data);
|
|
396
|
+
io.step(`write:${(0, import_node_path2.basename)(tmp)}`);
|
|
397
|
+
io.rename(tmp, path);
|
|
398
|
+
io.step(`rename:${(0, import_node_path2.basename)(path)}`);
|
|
399
|
+
io.fsyncDir((0, import_node_path2.dirname)(path));
|
|
400
|
+
io.step(`fsync-dir:${(0, import_node_path2.basename)((0, import_node_path2.dirname)(path))}`);
|
|
401
|
+
}
|
|
402
|
+
function writeNew(io, path, data) {
|
|
403
|
+
const tmp = tmpOf(path);
|
|
404
|
+
io.writeSynced(tmp, data);
|
|
405
|
+
io.step(`write:${(0, import_node_path2.basename)(tmp)}`);
|
|
406
|
+
try {
|
|
407
|
+
io.link(tmp, path);
|
|
408
|
+
} catch (err) {
|
|
409
|
+
try {
|
|
410
|
+
io.unlink(tmp);
|
|
411
|
+
} catch {
|
|
412
|
+
}
|
|
413
|
+
if (err.code !== "EEXIST") throw err;
|
|
414
|
+
if (io.read(path) !== data) throw new Error(`${path} already exists with other content; the original is kept`);
|
|
415
|
+
io.fsyncDir((0, import_node_path2.dirname)(path));
|
|
416
|
+
io.step(`fsync-dir:${(0, import_node_path2.basename)((0, import_node_path2.dirname)(path))}`);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
io.step(`link:${(0, import_node_path2.basename)(path)}`);
|
|
420
|
+
io.unlink(tmp);
|
|
421
|
+
io.fsyncDir((0, import_node_path2.dirname)(path));
|
|
422
|
+
io.step(`fsync-dir:${(0, import_node_path2.basename)((0, import_node_path2.dirname)(path))}`);
|
|
423
|
+
}
|
|
424
|
+
function renameDurable(io, from, to) {
|
|
425
|
+
io.rename(from, to);
|
|
426
|
+
io.step(`rename:${(0, import_node_path2.basename)(to)}`);
|
|
427
|
+
io.fsyncDir((0, import_node_path2.dirname)(to));
|
|
428
|
+
io.step(`fsync-dir:${(0, import_node_path2.basename)((0, import_node_path2.dirname)(to))}`);
|
|
429
|
+
if ((0, import_node_path2.dirname)(from) !== (0, import_node_path2.dirname)(to)) {
|
|
430
|
+
io.fsyncDir((0, import_node_path2.dirname)(from));
|
|
431
|
+
io.step(`fsync-dir:${(0, import_node_path2.basename)((0, import_node_path2.dirname)(from))}`);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function mkdirDurable(io, base2, path, exclusive = false) {
|
|
435
|
+
const root = base2.replace(/\/+$/, "");
|
|
436
|
+
const rel = path.slice(root.length).split("/").filter(Boolean);
|
|
437
|
+
if (!path.startsWith(root + "/") || rel.length === 0) throw new Error(`${path} is not below ${base2}`);
|
|
438
|
+
let dir = root;
|
|
439
|
+
rel.forEach((part, i) => {
|
|
440
|
+
dir = (0, import_node_path2.join)(dir, part);
|
|
441
|
+
const last = i === rel.length - 1;
|
|
442
|
+
try {
|
|
443
|
+
io.mkdir(dir);
|
|
444
|
+
io.step(`mkdir:${part}`);
|
|
445
|
+
} catch (err) {
|
|
446
|
+
if (err.code !== "EEXIST") throw err;
|
|
447
|
+
if (last && exclusive) throw new Error(`${dir} already exists; an attempt's directory is never reused`);
|
|
448
|
+
}
|
|
449
|
+
io.fsyncDir((0, import_node_path2.dirname)(dir));
|
|
450
|
+
io.step(`fsync-dir:${(0, import_node_path2.basename)((0, import_node_path2.dirname)(dir))}`);
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
var journalDir = (home2) => (0, import_node_path2.join)(home2, ".update-journal");
|
|
454
|
+
var currentPath = (home2) => (0, import_node_path2.join)(journalDir(home2), "current");
|
|
455
|
+
var attemptDir = (home2, id) => (0, import_node_path2.join)(journalDir(home2), "attempts", id);
|
|
456
|
+
var recordPath = (home2, id) => (0, import_node_path2.join)(attemptDir(home2, id), "attempt.json");
|
|
457
|
+
var marksPath = (home2) => (0, import_node_path2.join)(journalDir(home2), "marks.json");
|
|
458
|
+
var ID = /^\d{8}T\d{6}Z-[0-9a-f]{8}$/;
|
|
459
|
+
var isAttemptId = (v) => ID.test(v);
|
|
460
|
+
var STAGES = new Set(Object.keys(NEXT));
|
|
461
|
+
var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
462
|
+
var nonEmpty = (v) => typeof v === "string" && v.length > 0;
|
|
463
|
+
var isTime = (v) => nonEmpty(v) && Number.isFinite(Date.parse(v));
|
|
464
|
+
var isPid = (v) => Number.isSafeInteger(v) && v > 0;
|
|
465
|
+
var isArtifact = (v) => isObj(v) && nonEmpty(v.name) && nonEmpty(v.version) && (v.integrity === null || nonEmpty(v.integrity));
|
|
466
|
+
var isStart = (v) => isObj(v) && nonEmpty(v.processStart) && (v.startTicks === void 0 || typeof v.startTicks === "string" && /^\d+$/.test(v.startTicks)) && (v.bootId === void 0 || nonEmpty(v.bootId));
|
|
467
|
+
function parseRecord(text, id) {
|
|
468
|
+
let r;
|
|
469
|
+
try {
|
|
470
|
+
r = JSON.parse(text);
|
|
471
|
+
} catch {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
if (!isObj(r) || r.schema !== 1 || r.id !== id || !(r.kind === "update" || r.kind === "go-back") || !isTime(r.createdAt)) return null;
|
|
475
|
+
if (!isObj(r.updater) || !isPid(r.updater.pid) || !isStart(r.updater.start) || !isArtifact(r.from) || !isArtifact(r.to)) return null;
|
|
476
|
+
const stage = r.stage;
|
|
477
|
+
if (!STAGES.has(stage) || r.substep !== void 0 && !nonEmpty(r.substep)) return null;
|
|
478
|
+
if (r.goBackOf !== void 0 && !(typeof r.goBackOf === "string" && ID.test(r.goBackOf))) return null;
|
|
479
|
+
if (r.kind === "go-back" && r.goBackOf === void 0) return null;
|
|
480
|
+
const h = r.history;
|
|
481
|
+
if (!Array.isArray(h) || h.length === 0 || h[0]?.stage !== "opened") return null;
|
|
482
|
+
for (const e of h) {
|
|
483
|
+
if (!isObj(e) || !STAGES.has(e.stage) || !isTime(e.at) || e.substep !== void 0 && !nonEmpty(e.substep) || e.note !== void 0 && typeof e.note !== "string") return null;
|
|
484
|
+
}
|
|
485
|
+
if (h[h.length - 1].stage !== stage) return null;
|
|
486
|
+
const terminal = TERMINAL.has(stage);
|
|
487
|
+
if (terminal !== (r.outcome !== void 0)) return null;
|
|
488
|
+
if (terminal) {
|
|
489
|
+
const o = r.outcome;
|
|
490
|
+
if (!isObj(o) || o.kind !== stage || !isTime(o.at) || o.reason !== void 0 && typeof o.reason !== "string") return null;
|
|
491
|
+
}
|
|
492
|
+
return r;
|
|
493
|
+
}
|
|
494
|
+
function readCurrent(home2, io = defaultJournalIo) {
|
|
495
|
+
let text;
|
|
496
|
+
try {
|
|
497
|
+
text = io.read(currentPath(home2));
|
|
498
|
+
} catch (err) {
|
|
499
|
+
return { state: "unknown", reason: `current can't be read (${err.message})`, path: currentPath(home2) };
|
|
500
|
+
}
|
|
501
|
+
if (text === null) return { state: "none" };
|
|
502
|
+
const id = text.trim();
|
|
503
|
+
if (!ID.test(id)) return { state: "unknown", reason: "current names no attempt", path: currentPath(home2) };
|
|
504
|
+
let body;
|
|
505
|
+
try {
|
|
506
|
+
body = io.read(recordPath(home2, id));
|
|
507
|
+
} catch (err) {
|
|
508
|
+
return { state: "unknown", reason: `the attempt record can't be read (${err.message})`, path: recordPath(home2, id) };
|
|
509
|
+
}
|
|
510
|
+
if (body === null) return { state: "unknown", reason: "current names an attempt with no record", path: recordPath(home2, id) };
|
|
511
|
+
const attempt = parseRecord(body, id);
|
|
512
|
+
if (!attempt) return { state: "unknown", reason: "the attempt record isn't valid", path: recordPath(home2, id) };
|
|
513
|
+
if (attempt.stage === "manual-recovery") return { state: "manual", attempt };
|
|
514
|
+
if (TERMINAL.has(attempt.stage)) return { state: "closing", attempt };
|
|
515
|
+
return { state: "open", attempt };
|
|
516
|
+
}
|
|
517
|
+
function finishClosing(home2, attempt, io = defaultJournalIo) {
|
|
518
|
+
if (!TERMINAL.has(attempt.stage) || attempt.stage === "manual-recovery") throw new Error(`attempt ${attempt.id} is not closing`);
|
|
519
|
+
renameDurable(io, currentPath(home2), (0, import_node_path2.join)(attemptDir(home2, attempt.id), "current.closed"));
|
|
520
|
+
io.step("current-cleared");
|
|
521
|
+
}
|
|
522
|
+
function write(home2, attempt, io, step) {
|
|
523
|
+
writeAtomic(io, recordPath(home2, attempt.id), JSON.stringify(attempt, null, 2) + "\n");
|
|
524
|
+
io.step(step);
|
|
525
|
+
}
|
|
526
|
+
function advance(home2, attempt, to, opts = {}, io = defaultJournalIo) {
|
|
527
|
+
if (TERMINAL.has(to)) throw new Error(`a terminal stage (${to}) is written by finish()`);
|
|
528
|
+
if (!canAdvance(attempt.stage, to)) throw new Error(`attempt ${attempt.id}: ${attempt.stage} \u2192 ${to} is not allowed`);
|
|
529
|
+
const at = io.now().toISOString();
|
|
530
|
+
const next = { ...attempt, stage: to, history: [...attempt.history, { stage: to, at, ...opts.substep ? { substep: opts.substep } : {}, ...opts.note ? { note: opts.note } : {} }] };
|
|
531
|
+
if (opts.substep) next.substep = opts.substep;
|
|
532
|
+
else delete next.substep;
|
|
533
|
+
write(home2, next, io, `stage-${to}`);
|
|
534
|
+
return next;
|
|
535
|
+
}
|
|
536
|
+
function substep(home2, attempt, name, io = defaultJournalIo) {
|
|
537
|
+
if (TERMINAL.has(attempt.stage)) throw new Error(`attempt ${attempt.id} is ${attempt.stage}`);
|
|
538
|
+
const next = { ...attempt, substep: name, history: [...attempt.history, { stage: attempt.stage, substep: name, at: io.now().toISOString() }] };
|
|
539
|
+
write(home2, next, io, `substep-${name}`);
|
|
540
|
+
return next;
|
|
541
|
+
}
|
|
542
|
+
function finish(home2, attempt, outcome, io = defaultJournalIo) {
|
|
543
|
+
const to = outcome.kind;
|
|
544
|
+
const allowed = to === "manual-recovery" ? !TERMINAL.has(attempt.stage) : to === "abandoned" && attempt.stage === "abandoning" || to === "rolled-back" && attempt.stage === "rolling-back" || to === "committed" && attempt.stage === "committing";
|
|
545
|
+
if (!allowed) throw new Error(`attempt ${attempt.id}: ${attempt.stage} \u2192 ${to} is not allowed`);
|
|
546
|
+
if (outcome.kind === "rolled-back") appendMark(home2, { version: attempt.to.version, integrity: attempt.to.integrity, attemptId: attempt.id }, io);
|
|
547
|
+
const at = io.now().toISOString();
|
|
548
|
+
const next = {
|
|
549
|
+
...attempt,
|
|
550
|
+
stage: to,
|
|
551
|
+
history: [...attempt.history, { stage: to, at, ...outcome.reason ? { note: outcome.reason } : {} }],
|
|
552
|
+
outcome: { kind: outcome.kind, ...outcome.reason ? { reason: outcome.reason } : {}, at }
|
|
553
|
+
};
|
|
554
|
+
delete next.substep;
|
|
555
|
+
write(home2, next, io, `terminal-${to}`);
|
|
556
|
+
if (to !== "manual-recovery") finishClosing(home2, next, io);
|
|
557
|
+
return next;
|
|
558
|
+
}
|
|
559
|
+
function readMarks(home2, io = defaultJournalIo) {
|
|
560
|
+
let text;
|
|
561
|
+
try {
|
|
562
|
+
text = io.read(marksPath(home2));
|
|
563
|
+
} catch (err) {
|
|
564
|
+
return { ok: false, reason: err.message };
|
|
565
|
+
}
|
|
566
|
+
if (text === null) return { ok: true, marks: [] };
|
|
567
|
+
try {
|
|
568
|
+
const v = JSON.parse(text);
|
|
569
|
+
const valid = (m) => isObj(m) && nonEmpty(m.version) && (m.integrity === null || nonEmpty(m.integrity)) && typeof m.attemptId === "string" && ID.test(m.attemptId) && isTime(m.at);
|
|
570
|
+
if (!Array.isArray(v) || !v.every(valid)) return { ok: false, reason: "marks.json isn't a list of valid marks" };
|
|
571
|
+
return { ok: true, marks: v };
|
|
572
|
+
} catch {
|
|
573
|
+
return { ok: false, reason: "marks.json isn't JSON" };
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
function appendMark(home2, mark, io = defaultJournalIo) {
|
|
577
|
+
const read = readMarks(home2, io);
|
|
578
|
+
if (!read.ok) throw new Error(`marks.json can't be read, so no mark is written over it: ${read.reason}`);
|
|
579
|
+
const landed = read.marks.find((m) => m.attemptId === mark.attemptId);
|
|
580
|
+
if (landed) {
|
|
581
|
+
if (landed.version !== mark.version || landed.integrity !== mark.integrity) throw new Error(`marks.json holds another mark for attempt ${mark.attemptId}`);
|
|
582
|
+
io.fsyncDir(journalDir(home2));
|
|
583
|
+
io.step(`fsync-dir:${(0, import_node_path2.basename)(journalDir(home2))}`);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
mkdirDurable(io, home2, journalDir(home2));
|
|
587
|
+
writeAtomic(io, marksPath(home2), JSON.stringify([...read.marks, { ...mark, at: mark.at ?? io.now().toISOString() }], null, 2) + "\n");
|
|
588
|
+
io.step("mark-written");
|
|
589
|
+
}
|
|
590
|
+
function listHandback(home2, attemptId, io = defaultJournalIo) {
|
|
591
|
+
const out = [];
|
|
592
|
+
const inbox = (0, import_node_path2.join)(attemptDir(home2, attemptId), "inbox"), deferred = (0, import_node_path2.join)(attemptDir(home2, attemptId), "deferred");
|
|
593
|
+
const inboxFiles = io.list(inbox), deferredFiles = io.list(deferred);
|
|
594
|
+
for (const f of inboxFiles) {
|
|
595
|
+
const m = /^(\d{12})-(outbox|adapter|web|hub)\.json$/.exec(f);
|
|
596
|
+
if (!m) continue;
|
|
597
|
+
const text = io.read((0, import_node_path2.join)(inbox, f));
|
|
598
|
+
if (text === null) throw new Error(`inbox item ${f} vanished`);
|
|
599
|
+
const item = JSON.parse(text);
|
|
600
|
+
if (!(item.kind === "reference" && typeof item.deliveryId === "string" && Number.isSafeInteger(item.createdSeq)) && !(item.kind === "copy" && "body" in item && typeof item.target === "string" && item.target !== "")) throw new Error(`inbox item ${f} isn't valid`);
|
|
601
|
+
out.push({ seq: Number(m[1]), kind: "inbox", source: m[2], file: (0, import_node_path2.join)(inbox, f), item, acked: inboxFiles.includes(`${f}.acked`) });
|
|
602
|
+
}
|
|
603
|
+
for (const f of deferredFiles) {
|
|
604
|
+
const m = /^(\d{12})\.json$/.exec(f);
|
|
605
|
+
if (!m) continue;
|
|
606
|
+
const text = io.read((0, import_node_path2.join)(deferred, f));
|
|
607
|
+
if (text === null) throw new Error(`deferred job ${f} vanished`);
|
|
608
|
+
const job = JSON.parse(text);
|
|
609
|
+
if (job.seq !== Number(m[1]) || typeof job.scheduleId !== "string" || typeof job.runId !== "string") throw new Error(`deferred job ${f} isn't valid`);
|
|
610
|
+
out.push({
|
|
611
|
+
seq: job.seq,
|
|
612
|
+
kind: "deferred",
|
|
613
|
+
file: (0, import_node_path2.join)(deferred, f),
|
|
614
|
+
job: { scheduleId: job.scheduleId, runId: job.runId },
|
|
615
|
+
started: deferredFiles.includes(`${f}.started`),
|
|
616
|
+
acked: deferredFiles.includes(`${f}.acked`)
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
const seqs = out.map((e) => e.seq);
|
|
620
|
+
if (new Set(seqs).size !== seqs.length) throw new Error("two hand-back items share a sequence number");
|
|
621
|
+
return out.sort((a, b) => a.seq - b.seq);
|
|
622
|
+
}
|
|
623
|
+
function handbackAction(entry) {
|
|
624
|
+
if (entry.acked) return "skip";
|
|
625
|
+
if (entry.kind === "inbox") return entry.item.kind === "reference" ? "claim" : "admit-then-claim";
|
|
626
|
+
return entry.started ? "record-interrupted" : "run";
|
|
627
|
+
}
|
|
628
|
+
function recoveryPlan(read, updater, ownStart = false) {
|
|
629
|
+
switch (read.state) {
|
|
630
|
+
case "none":
|
|
631
|
+
return { kind: "start" };
|
|
632
|
+
case "unknown":
|
|
633
|
+
return { kind: "refuse", reason: "unknown" };
|
|
634
|
+
case "manual":
|
|
635
|
+
return { kind: "refuse", reason: "manual", attemptId: read.attempt.id, stage: read.attempt.stage };
|
|
636
|
+
case "closing":
|
|
637
|
+
return { kind: "finish-closing", attemptId: read.attempt.id };
|
|
638
|
+
}
|
|
639
|
+
const a = read.attempt;
|
|
640
|
+
if (updater === "live") return ownStart ? { kind: "start" } : { kind: "refuse", reason: "in-progress", attemptId: a.id, stage: a.stage };
|
|
641
|
+
if (updater === "unknown") return { kind: "refuse", reason: "updater-unknown", attemptId: a.id, stage: a.stage };
|
|
642
|
+
const sub = a.substep ? { substep: a.substep } : {};
|
|
643
|
+
switch (a.stage) {
|
|
644
|
+
case "opened":
|
|
645
|
+
case "barrier":
|
|
646
|
+
case "stopping":
|
|
647
|
+
case "abandoning":
|
|
648
|
+
return { kind: "resume-abandoning", attemptId: a.id, ...sub };
|
|
649
|
+
case "snapshotted":
|
|
650
|
+
case "installing":
|
|
651
|
+
case "trial":
|
|
652
|
+
case "proving":
|
|
653
|
+
case "rolling-back":
|
|
654
|
+
return { kind: "resume-rolling-back", attemptId: a.id, ...sub };
|
|
655
|
+
case "committing":
|
|
656
|
+
return { kind: "resume-committing", attemptId: a.id, ...sub };
|
|
657
|
+
default:
|
|
658
|
+
return { kind: "refuse", reason: "unknown" };
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
var generationsOf = (a) => Array.isArray(a.fleets) ? a.fleets : [];
|
|
662
|
+
function planGeneration(home2, attempt, gen, nonce, io = defaultJournalIo) {
|
|
663
|
+
if (!/^[0-9a-f]{32}$/.test(nonce)) throw new Error("a handoff nonce is 32 hex digits");
|
|
664
|
+
if (generationsOf(attempt).some((g) => g.nonce === nonce)) throw new Error("a nonce is never reused");
|
|
665
|
+
const fleets = [...generationsOf(attempt), { gen, nonce, plannedAt: io.now().toISOString() }];
|
|
666
|
+
return substep(home2, { ...attempt, fleets }, "start-planned", io);
|
|
667
|
+
}
|
|
668
|
+
function ackGeneration(home2, attempt, nonce, pid, opts = {}, io = defaultJournalIo) {
|
|
669
|
+
if (!isPid(pid)) throw new Error("a generation's pid is a positive integer");
|
|
670
|
+
const fleets = generationsOf(attempt).map((g) => g.nonce === nonce ? { ...g, pid, consumed: true, ...opts.dead ? { dead: true } : {} } : g);
|
|
671
|
+
if (!fleets.some((g) => g.nonce === nonce)) throw new Error("no generation was planned with that nonce");
|
|
672
|
+
return substep(home2, { ...attempt, fleets }, opts.dead ? "start-dead" : "start-acknowledged", io);
|
|
673
|
+
}
|
|
674
|
+
var startOf = (pid, start) => ({ pid, processStart: start.processStart, ...start.startTicks !== void 0 ? { startTicks: start.startTicks, bootId: start.bootId } : {} });
|
|
675
|
+
function updaterState(attempt, deps) {
|
|
676
|
+
const state = holderState(startOf(attempt.updater.pid, attempt.updater.start), deps);
|
|
677
|
+
return state === "stale" ? "gone" : state;
|
|
678
|
+
}
|
|
679
|
+
var RUNNER_FILE = "runner.json";
|
|
680
|
+
var runnerPath = (home2, id) => (0, import_node_path2.join)(attemptDir(home2, id), RUNNER_FILE);
|
|
681
|
+
function writeRunnerRecord(home2, attemptId, runner, io = defaultJournalIo) {
|
|
682
|
+
if (!isPid(runner.pid) || !isStart(runner.start)) throw new Error("a runner record needs a pid and a start");
|
|
683
|
+
writeAtomic(io, runnerPath(home2, attemptId), JSON.stringify({ pid: runner.pid, start: runner.start }) + "\n");
|
|
684
|
+
}
|
|
685
|
+
function readRunnerRecord(home2, attemptId, io = defaultJournalIo) {
|
|
686
|
+
let text;
|
|
687
|
+
try {
|
|
688
|
+
text = io.read(runnerPath(home2, attemptId));
|
|
689
|
+
} catch {
|
|
690
|
+
return "unreadable";
|
|
691
|
+
}
|
|
692
|
+
if (text === null) return null;
|
|
693
|
+
try {
|
|
694
|
+
const r = JSON.parse(text);
|
|
695
|
+
return isObj(r) && isPid(r.pid) && isStart(r.start) ? { pid: r.pid, start: r.start } : "unreadable";
|
|
696
|
+
} catch {
|
|
697
|
+
return "unreadable";
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
function ownerState(home2, attempt, deps, io = defaultJournalIo) {
|
|
701
|
+
const updater = updaterState(attempt, deps);
|
|
702
|
+
const record = readRunnerRecord(home2, attempt.id, io);
|
|
703
|
+
const runner = record === null ? "gone" : record === "unreadable" ? "unknown" : /* @__PURE__ */ ((s) => s === "stale" ? "gone" : s)(holderState(startOf(record.pid, record.start), deps));
|
|
704
|
+
if (updater === "unknown" || runner === "unknown") return "unknown";
|
|
705
|
+
if (updater === "live" || runner === "live") return "live";
|
|
706
|
+
return "gone";
|
|
707
|
+
}
|
|
708
|
+
function revokeHandoff(home2, attemptId, nonce, updater, liveness, io = defaultJournalIo) {
|
|
709
|
+
if (!/^[0-9a-f]{32}$/.test(nonce)) throw new Error("a handoff nonce is 32 hex digits");
|
|
710
|
+
const path = (0, import_node_path2.join)(attemptDir(home2, attemptId), `handoff-${nonce}.claim`);
|
|
711
|
+
try {
|
|
712
|
+
writeNew(io, path, JSON.stringify({ revokedBy: updater.pid, start: updater.start }) + "\n");
|
|
713
|
+
return "revoked";
|
|
714
|
+
} catch {
|
|
715
|
+
}
|
|
716
|
+
try {
|
|
717
|
+
const claim = JSON.parse(io.read(path) ?? "null");
|
|
718
|
+
if (!isObj(claim) || !isPid(claim.pid) || !isStart(claim.start)) return "claimant-unknown";
|
|
719
|
+
const state = holderState(startOf(claim.pid, claim.start), liveness);
|
|
720
|
+
return state === "stale" ? "claimant-gone" : state === "live" ? "claimed-live" : "claimant-unknown";
|
|
721
|
+
} catch {
|
|
722
|
+
return "claimant-unknown";
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
function voidGeneration(home2, attempt, nonce, io = defaultJournalIo) {
|
|
726
|
+
const fleets = generationsOf(attempt).map((g) => g.nonce === nonce ? { ...g, consumed: true, dead: true } : g);
|
|
727
|
+
return substep(home2, { ...attempt, fleets }, "start-voided", io);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// src/update-recovery/pre-start.ts
|
|
731
|
+
var import_node_path3 = require("node:path");
|
|
732
|
+
var HANDOFF_ENV = "handoff.env";
|
|
733
|
+
var handoffEnvPath = (home2, attemptId) => (0, import_node_path3.join)(attemptDir(home2, attemptId), HANDOFF_ENV);
|
|
734
|
+
var kitDir = (home2, attemptId) => (0, import_node_path3.join)(journalDir(home2), "recovery", attemptId);
|
|
735
|
+
var shellWord = (word) => /^[A-Za-z0-9_./:=@%+,-]+$/.test(word) ? word : `'${word.replace(/'/g, `'\\''`)}'`;
|
|
736
|
+
function operatorCommand(home2, attemptId) {
|
|
737
|
+
const kit = kitDir(home2, attemptId);
|
|
738
|
+
return [(0, import_node_path3.join)(kit, "node"), (0, import_node_path3.join)(kit, "recover.cjs"), "--home", home2, "--attempt", attemptId, "--run"].map(shellWord).join(" ");
|
|
739
|
+
}
|
|
740
|
+
function plannedForStart(attempt) {
|
|
741
|
+
const fleets = Array.isArray(attempt.fleets) ? attempt.fleets : [];
|
|
742
|
+
for (let i = fleets.length - 1; i >= 0; i--) {
|
|
743
|
+
const g = fleets[i];
|
|
744
|
+
if (!g.consumed && !g.dead && g.pid === void 0) return g;
|
|
745
|
+
}
|
|
746
|
+
return null;
|
|
747
|
+
}
|
|
748
|
+
function preStartDecision(home2, read, owner, routeAttempt) {
|
|
749
|
+
switch (read.state) {
|
|
750
|
+
case "none":
|
|
751
|
+
case "closing":
|
|
752
|
+
return { kind: "start" };
|
|
753
|
+
case "unknown":
|
|
754
|
+
return { kind: "refuse", reason: `AgEnD's update journal can't be read (${read.reason}: ${read.path}). This start is refused; run \`agend update --resolve\`.` };
|
|
755
|
+
case "manual":
|
|
756
|
+
return { kind: "refuse", reason: `Update attempt ${read.attempt.id} needs manual recovery. This start is refused; run ${operatorCommand(home2, read.attempt.id)}` };
|
|
757
|
+
}
|
|
758
|
+
const a = read.attempt;
|
|
759
|
+
if (a.id !== routeAttempt) return { kind: "refuse", reason: `AgEnD's update route on this service names attempt ${routeAttempt}, but attempt ${a.id} is open (${a.stage}). This start is refused; run ${operatorCommand(home2, a.id)}` };
|
|
760
|
+
if (owner === "unknown") return { kind: "refuse", reason: `Update attempt ${a.id} (${a.stage}): whether its updater still runs can't be told. This start is refused; if no update is running, run ${operatorCommand(home2, a.id)}` };
|
|
761
|
+
if (owner === "gone") return a.stage === "committing" ? { kind: "start" } : { kind: "start-runner", attemptId: a.id, stage: a.stage };
|
|
762
|
+
const planned = plannedForStart(a);
|
|
763
|
+
if (planned) return { kind: "handoff", attemptId: a.id, nonce: planned.nonce };
|
|
764
|
+
return { kind: "refuse", reason: `AgEnD is updating (attempt ${a.id}, ${a.stage}); this start is refused. The update owns the service until it ends.` };
|
|
765
|
+
}
|
|
766
|
+
function applyHandoffEnv(home2, decision, routeAttempt, io = defaultJournalIo) {
|
|
767
|
+
if (decision.kind === "handoff") {
|
|
768
|
+
if (decision.attemptId !== routeAttempt) throw new Error(`a handoff for attempt ${decision.attemptId} can't go through attempt ${routeAttempt}'s route`);
|
|
769
|
+
const path = handoffEnvPath(home2, decision.attemptId);
|
|
770
|
+
const tmp = `${path}.tmp-${process.pid}`;
|
|
771
|
+
try {
|
|
772
|
+
io.unlink(tmp);
|
|
773
|
+
} catch {
|
|
774
|
+
}
|
|
775
|
+
io.writeSynced(tmp, `AGEND_UPDATE_HANDOFF=${decision.nonce}
|
|
776
|
+
`);
|
|
777
|
+
io.rename(tmp, path);
|
|
778
|
+
io.fsyncDir(attemptDir(home2, decision.attemptId));
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
const absent = (err) => ["ENOENT", "ENOTDIR"].includes(err.code ?? "");
|
|
782
|
+
try {
|
|
783
|
+
io.unlink(handoffEnvPath(home2, routeAttempt));
|
|
784
|
+
} catch (err) {
|
|
785
|
+
if (!absent(err)) throw err;
|
|
786
|
+
}
|
|
787
|
+
try {
|
|
788
|
+
io.fsyncDir(attemptDir(home2, routeAttempt));
|
|
789
|
+
} catch (err) {
|
|
790
|
+
if (!absent(err)) throw err;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// src/update-recovery/runner.ts
|
|
795
|
+
var import_node_path12 = require("node:path");
|
|
796
|
+
|
|
797
|
+
// src/home-update-lock.ts
|
|
798
|
+
var import_node_path4 = require("node:path");
|
|
799
|
+
var import_node_fs3 = require("node:fs");
|
|
800
|
+
var HOME_UPDATE_LOCK_FILE = ".update.lock";
|
|
801
|
+
|
|
802
|
+
// src/install-ownership.ts
|
|
803
|
+
var import_node_fs4 = require("node:fs");
|
|
804
|
+
var import_node_path5 = require("node:path");
|
|
805
|
+
var BIN_NAMES = ["agend", "agend-agent"];
|
|
806
|
+
var isObj2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
807
|
+
var nonEmpty2 = (v) => typeof v === "string" && v.length > 0;
|
|
808
|
+
var strOrNull = (v) => v === null || nonEmpty2(v);
|
|
809
|
+
var argvOrNull = (v) => v === null || Array.isArray(v) && v.length > 0 && v.every((x) => typeof x === "string");
|
|
810
|
+
function validOwnership(v) {
|
|
811
|
+
if (!isObj2(v) || !Number.isSafeInteger(v.uid) || v.uid < 0 || !nonEmpty2(v.home) || !nonEmpty2(v.prefix) || !nonEmpty2(v.packagePath)) return false;
|
|
812
|
+
const links = v.binLinks;
|
|
813
|
+
if (!isObj2(links) || !BIN_NAMES.every((name) => nonEmpty2(links[name])) || Object.keys(links).length !== BIN_NAMES.length) return false;
|
|
814
|
+
if (v.service === null) return true;
|
|
815
|
+
const s = v.service;
|
|
816
|
+
return isObj2(s) && (s.kind === "systemd" || s.kind === "launchd") && nonEmpty2(s.unit) && nonEmpty2(s.fragmentPath);
|
|
817
|
+
}
|
|
818
|
+
function validTuple(v) {
|
|
819
|
+
if (!isObj2(v) || !nonEmpty2(v.version) || !strOrNull(v.integrity) || !nonEmpty2(v.entry) || !nonEmpty2(v.interpreter) || !argvOrNull(v.execStart)) return false;
|
|
820
|
+
const bins = v.bins;
|
|
821
|
+
return isObj2(bins) && BIN_NAMES.every((name) => strOrNull(bins[name])) && Object.keys(bins).every((k) => BIN_NAMES.includes(k));
|
|
822
|
+
}
|
|
823
|
+
function validIntent(v) {
|
|
824
|
+
if (!isObj2(v) || !isObj2(v.preimage) || !nonEmpty2(v.preimage.dir) || !/^[0-9a-f]{64}$/.test(String(v.preimage.manifestSha256))) return false;
|
|
825
|
+
const d = v.destination, t = v.target;
|
|
826
|
+
if (!isObj2(d) || !nonEmpty2(d.packagePath) || !Array.isArray(d.binLinks) || !d.binLinks.every(nonEmpty2)) return false;
|
|
827
|
+
if (!isObj2(t) || !nonEmpty2(t.name) || !nonEmpty2(t.version) || !strOrNull(t.integrity)) return false;
|
|
828
|
+
return Array.isArray(v.command) && v.command.length > 0 && v.command.every((x) => typeof x === "string");
|
|
829
|
+
}
|
|
830
|
+
function identityOf(attempt) {
|
|
831
|
+
const expected = attempt.expected;
|
|
832
|
+
if (!validOwnership(attempt.ownership) || !isObj2(expected) || !validTuple(expected.old)) return null;
|
|
833
|
+
if (expected.new !== void 0 && !validTuple(expected.new)) return null;
|
|
834
|
+
if (attempt.intent !== void 0 && !validIntent(attempt.intent)) return null;
|
|
835
|
+
return { ownership: attempt.ownership, expected: { old: expected.old, ...expected.new ? { new: expected.new } : {} }, ...attempt.intent ? { intent: attempt.intent } : {} };
|
|
836
|
+
}
|
|
837
|
+
function stopTarget(attempt, lock, mainPid) {
|
|
838
|
+
const want = attempt.stage === "stopping" ? "old" : attempt.stage === "rolling-back" ? "trial" : null;
|
|
839
|
+
if (!want) return { ok: false, reason: `no fleet is stopped in ${attempt.stage}` };
|
|
840
|
+
if (!lock) return { ok: false, reason: "fleet.lock names no holder" };
|
|
841
|
+
const fleets = Array.isArray(attempt.fleets) ? attempt.fleets : [];
|
|
842
|
+
const gen = fleets.find((g) => g.nonce === lock.nonce);
|
|
843
|
+
if (!gen || gen.pid !== lock.pid) return { ok: false, reason: `fleet.lock's holder (pid ${lock.pid}) is no recorded generation` };
|
|
844
|
+
if (gen.gen !== want) return { ok: false, reason: `fleet.lock's holder is generation ${gen.gen}, not ${want}` };
|
|
845
|
+
const id = identityOf(attempt);
|
|
846
|
+
if (!id) return { ok: false, reason: "the attempt's recorded ownership is missing or malformed" };
|
|
847
|
+
if (id.ownership.service) {
|
|
848
|
+
if (mainPid === null) return { ok: false, reason: `the service ${id.ownership.service.unit}'s MainPID can't be read` };
|
|
849
|
+
if (mainPid !== lock.pid) return { ok: false, reason: `the service's MainPID ${mainPid} matches no recorded generation` };
|
|
850
|
+
} else if (mainPid !== null) return { ok: false, reason: `a detached attempt has no service, yet a MainPID ${mainPid} was given` };
|
|
851
|
+
return { ok: true, generation: gen };
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// src/update-rollback.ts
|
|
855
|
+
var import_node_crypto6 = require("node:crypto");
|
|
856
|
+
|
|
857
|
+
// src/agend-home.ts
|
|
858
|
+
var import_node_module = require("node:module");
|
|
859
|
+
var import_node_worker_threads = require("node:worker_threads");
|
|
860
|
+
|
|
861
|
+
// src/fleet-lock.ts
|
|
862
|
+
var import_node_fs5 = require("node:fs");
|
|
863
|
+
var import_node_child_process = require("node:child_process");
|
|
864
|
+
var import_node_crypto = require("node:crypto");
|
|
865
|
+
var import_node_path6 = require("node:path");
|
|
866
|
+
function processAlive(pid) {
|
|
867
|
+
try {
|
|
868
|
+
process.kill(pid, 0);
|
|
869
|
+
return true;
|
|
870
|
+
} catch {
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
function parseRecord2(raw) {
|
|
875
|
+
try {
|
|
876
|
+
const value = JSON.parse(raw);
|
|
877
|
+
if (!Number.isSafeInteger(value.pid) || (value.pid ?? 0) <= 1 || typeof value.nonce !== "string") {
|
|
878
|
+
return null;
|
|
879
|
+
}
|
|
880
|
+
if (value.role === "update" && (typeof value.attemptId !== "string" || !value.attemptId)) return null;
|
|
881
|
+
if (value.handoff != null && (typeof value.handoff.nonce !== "string" || !/^[0-9a-f]{32}$/.test(value.handoff.nonce) || !["old", "trial", "rollback"].includes(value.handoff.gen))) return null;
|
|
882
|
+
return value;
|
|
883
|
+
} catch {
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
function releaseFleetLock(handle) {
|
|
888
|
+
if (!handle || !(0, import_node_fs5.existsSync)(handle.path)) return false;
|
|
889
|
+
if (handle.record.role === "update" && handle.record.handoff) return false;
|
|
890
|
+
try {
|
|
891
|
+
if ((0, import_node_fs5.readFileSync)(handle.path, "utf8") !== handle.serialized) return false;
|
|
892
|
+
(0, import_node_fs5.unlinkSync)(handle.path);
|
|
893
|
+
return true;
|
|
894
|
+
} catch {
|
|
895
|
+
return false;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
var fsyncDir = (dir) => {
|
|
899
|
+
const fd = (0, import_node_fs5.openSync)(dir, "r");
|
|
900
|
+
try {
|
|
901
|
+
(0, import_node_fs5.fsyncSync)(fd);
|
|
902
|
+
} finally {
|
|
903
|
+
(0, import_node_fs5.closeSync)(fd);
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
function setFleetLockHandoff(handle, handoff, revoke) {
|
|
907
|
+
if (handle.record.role !== "update") throw new Error("only an update fence plans a handoff");
|
|
908
|
+
if (handoff && !/^[0-9a-f]{32}$/.test(handoff.nonce)) throw new Error("a handoff nonce is 32 hex digits");
|
|
909
|
+
const planned = handle.record.handoff;
|
|
910
|
+
if (planned) {
|
|
911
|
+
if (!revoke) throw new Error("a planned handoff is replaced only after its nonce is revoked");
|
|
912
|
+
if (!revoke(handle.record.attemptId, planned.nonce)) return null;
|
|
913
|
+
}
|
|
914
|
+
let current;
|
|
915
|
+
try {
|
|
916
|
+
current = (0, import_node_fs5.readFileSync)(handle.path, "utf8");
|
|
917
|
+
} catch {
|
|
918
|
+
return null;
|
|
919
|
+
}
|
|
920
|
+
if (current !== handle.serialized) return null;
|
|
921
|
+
const record = { ...handle.record, handoff };
|
|
922
|
+
const serialized = JSON.stringify(record) + "\n";
|
|
923
|
+
const tmp = `${handle.path}.plan-${record.pid}-${(0, import_node_crypto.randomBytes)(4).toString("hex")}`;
|
|
924
|
+
const fd = (0, import_node_fs5.openSync)(tmp, "wx", 384);
|
|
925
|
+
try {
|
|
926
|
+
(0, import_node_fs5.writeSync)(fd, serialized);
|
|
927
|
+
(0, import_node_fs5.fsyncSync)(fd);
|
|
928
|
+
} finally {
|
|
929
|
+
(0, import_node_fs5.closeSync)(fd);
|
|
930
|
+
}
|
|
931
|
+
(0, import_node_fs5.renameSync)(tmp, handle.path);
|
|
932
|
+
fsyncDir((0, import_node_path6.dirname)(handle.path));
|
|
933
|
+
return { path: handle.path, record, serialized };
|
|
934
|
+
}
|
|
935
|
+
function retakeDeadFleetLock(dataDir, fence, probe = {}) {
|
|
936
|
+
return replaceDeadHolder(dataDir, fence, (owner) => (owner.role ?? "fleet") === "fleet" && owner.nonce === fence.nonce ? null : "fleet.lock doesn't hold that generation's record", probe);
|
|
937
|
+
}
|
|
938
|
+
function adoptUpdateFence(dataDir, fence, probe = {}) {
|
|
939
|
+
const pid = fence.pid ?? process.pid;
|
|
940
|
+
let current;
|
|
941
|
+
try {
|
|
942
|
+
current = (0, import_node_fs5.readFileSync)((0, import_node_path6.join)(dataDir, "fleet.lock"), "utf8");
|
|
943
|
+
} catch (err) {
|
|
944
|
+
return { ok: false, reason: `fleet.lock can't be read (${err.message})` };
|
|
945
|
+
}
|
|
946
|
+
const owner = parseRecord2(current);
|
|
947
|
+
if (owner && owner.role === "update" && owner.attemptId === fence.attemptId && owner.pid === pid) {
|
|
948
|
+
clearCrashedReclaim(dataDir, fence.attemptId, pid, probe);
|
|
949
|
+
return { ok: true, handle: { path: (0, import_node_path6.join)(dataDir, "fleet.lock"), record: owner, serialized: current } };
|
|
950
|
+
}
|
|
951
|
+
return replaceDeadHolder(dataDir, { pid, attemptId: fence.attemptId }, (o) => o.role === "update" && o.attemptId === fence.attemptId ? null : "fleet.lock isn't this attempt's fence", probe);
|
|
952
|
+
}
|
|
953
|
+
var reclaimMarkerPath = (dataDir) => `${(0, import_node_path6.join)(dataDir, "fleet.lock")}.reclaim`;
|
|
954
|
+
function clearCrashedReclaim(dataDir, attemptId, selfPid, probe) {
|
|
955
|
+
const marker = reclaimMarkerPath(dataDir);
|
|
956
|
+
let text;
|
|
957
|
+
try {
|
|
958
|
+
text = (0, import_node_fs5.readFileSync)(marker, "utf8");
|
|
959
|
+
} catch {
|
|
960
|
+
return false;
|
|
961
|
+
}
|
|
962
|
+
const rec = parseRecord2(text);
|
|
963
|
+
if (!rec || rec.role !== "update" || rec.attemptId !== attemptId || rec.pid !== selfPid && (probe.isProcessAlive ?? processAlive)(rec.pid)) return false;
|
|
964
|
+
try {
|
|
965
|
+
(0, import_node_fs5.unlinkSync)(marker);
|
|
966
|
+
fsyncDir(dataDir);
|
|
967
|
+
return true;
|
|
968
|
+
} catch {
|
|
969
|
+
return false;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
function replaceDeadHolder(dataDir, fence, accept, probe) {
|
|
973
|
+
const lockPath = (0, import_node_path6.join)(dataDir, "fleet.lock"), marker = reclaimMarkerPath(dataDir);
|
|
974
|
+
let observed;
|
|
975
|
+
try {
|
|
976
|
+
observed = (0, import_node_fs5.readFileSync)(lockPath, "utf8");
|
|
977
|
+
} catch (err) {
|
|
978
|
+
return { ok: false, reason: `fleet.lock can't be read (${err.message})` };
|
|
979
|
+
}
|
|
980
|
+
const owner = parseRecord2(observed);
|
|
981
|
+
if (!owner) return { ok: false, reason: "fleet.lock can't be read as a record" };
|
|
982
|
+
const why = accept(owner);
|
|
983
|
+
if (why) return { ok: false, reason: why };
|
|
984
|
+
if ((probe.isProcessAlive ?? processAlive)(owner.pid)) return { ok: false, reason: `fleet.lock's holder (pid ${owner.pid}) is still a live process; it is never taken` };
|
|
985
|
+
const pid = fence.pid ?? process.pid;
|
|
986
|
+
const record = { pid, nonce: (0, import_node_crypto.randomBytes)(16).toString("hex"), createdAt: (/* @__PURE__ */ new Date()).toISOString(), role: "update", attemptId: fence.attemptId, handoff: null };
|
|
987
|
+
const serialized = JSON.stringify(record) + "\n";
|
|
988
|
+
const takeMarker = () => (0, import_node_fs5.writeFileSync)(marker, serialized, { flag: "wx", mode: 384 });
|
|
989
|
+
try {
|
|
990
|
+
takeMarker();
|
|
991
|
+
} catch (err) {
|
|
992
|
+
if (err.code !== "EEXIST") return { ok: false, reason: `the reclaim marker can't be created (${err.message})` };
|
|
993
|
+
if (!clearCrashedReclaim(dataDir, fence.attemptId, fence.pid ?? process.pid, probe)) return { ok: false, reason: `a reclaim marker ${marker} is present (another reclaim, or one left by a crash); nothing is taken` };
|
|
994
|
+
try {
|
|
995
|
+
takeMarker();
|
|
996
|
+
} catch (again) {
|
|
997
|
+
return { ok: false, reason: `the reclaim marker can't be taken (${again.message})` };
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
try {
|
|
1001
|
+
if ((0, import_node_fs5.readFileSync)(lockPath, "utf8") !== observed) return { ok: false, reason: "fleet.lock changed during the reclaim" };
|
|
1002
|
+
const tmp = `${lockPath}.retake-${pid}-${(0, import_node_crypto.randomBytes)(4).toString("hex")}`;
|
|
1003
|
+
const fd = (0, import_node_fs5.openSync)(tmp, "wx", 384);
|
|
1004
|
+
try {
|
|
1005
|
+
(0, import_node_fs5.writeSync)(fd, serialized);
|
|
1006
|
+
(0, import_node_fs5.fsyncSync)(fd);
|
|
1007
|
+
} finally {
|
|
1008
|
+
(0, import_node_fs5.closeSync)(fd);
|
|
1009
|
+
}
|
|
1010
|
+
(0, import_node_fs5.renameSync)(tmp, lockPath);
|
|
1011
|
+
fsyncDir(dataDir);
|
|
1012
|
+
return { ok: true, handle: { path: lockPath, record, serialized } };
|
|
1013
|
+
} catch (err) {
|
|
1014
|
+
return { ok: false, reason: `fleet.lock can't be re-taken (${err.message})` };
|
|
1015
|
+
} finally {
|
|
1016
|
+
try {
|
|
1017
|
+
(0, import_node_fs5.unlinkSync)(marker);
|
|
1018
|
+
fsyncDir(dataDir);
|
|
1019
|
+
} catch {
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
function createUpdateFence(dataDir, fence) {
|
|
1024
|
+
if (!/^\d{8}T\d{6}Z-[0-9a-f]{8}$/.test(fence.attemptId)) return { ok: false, reason: "an update fence needs its attempt id" };
|
|
1025
|
+
const lockPath = (0, import_node_path6.join)(dataDir, "fleet.lock");
|
|
1026
|
+
const record = { pid: fence.pid, nonce: (0, import_node_crypto.randomBytes)(16).toString("hex"), createdAt: (/* @__PURE__ */ new Date()).toISOString(), role: "update", attemptId: fence.attemptId, handoff: null };
|
|
1027
|
+
const serialized = JSON.stringify(record) + "\n";
|
|
1028
|
+
let fd;
|
|
1029
|
+
try {
|
|
1030
|
+
fd = (0, import_node_fs5.openSync)(lockPath, "wx", 384);
|
|
1031
|
+
} catch (err) {
|
|
1032
|
+
return { ok: false, reason: err.code === "EEXIST" ? "fleet.lock appeared meanwhile" : `fleet.lock can't be created (${err.message})` };
|
|
1033
|
+
}
|
|
1034
|
+
try {
|
|
1035
|
+
try {
|
|
1036
|
+
(0, import_node_fs5.writeSync)(fd, serialized);
|
|
1037
|
+
(0, import_node_fs5.fsyncSync)(fd);
|
|
1038
|
+
} finally {
|
|
1039
|
+
(0, import_node_fs5.closeSync)(fd);
|
|
1040
|
+
}
|
|
1041
|
+
fsyncDir(dataDir);
|
|
1042
|
+
} catch (err) {
|
|
1043
|
+
try {
|
|
1044
|
+
(0, import_node_fs5.unlinkSync)(lockPath);
|
|
1045
|
+
fsyncDir(dataDir);
|
|
1046
|
+
} catch {
|
|
1047
|
+
}
|
|
1048
|
+
return { ok: false, reason: `fleet.lock can't be written (${err.message})` };
|
|
1049
|
+
}
|
|
1050
|
+
return { ok: true, handle: { path: lockPath, record, serialized } };
|
|
1051
|
+
}
|
|
1052
|
+
function readFleetLockRecord(dataDir) {
|
|
1053
|
+
try {
|
|
1054
|
+
return parseRecord2((0, import_node_fs5.readFileSync)((0, import_node_path6.join)(dataDir, "fleet.lock"), "utf8"));
|
|
1055
|
+
} catch {
|
|
1056
|
+
return null;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// src/update-restore.ts
|
|
1061
|
+
var import_node_crypto3 = require("node:crypto");
|
|
1062
|
+
var import_node_fs7 = require("node:fs");
|
|
1063
|
+
var import_node_path8 = require("node:path");
|
|
1064
|
+
|
|
1065
|
+
// src/update-snapshot-scope.ts
|
|
1066
|
+
var under = (dir) => (rel) => rel === dir || rel.startsWith(`${dir}/`);
|
|
1067
|
+
var exactly = (...names) => (rel) => names.includes(rel);
|
|
1068
|
+
var base = (rel) => rel.slice(rel.lastIndexOf("/") + 1);
|
|
1069
|
+
var EXCLUDED = [
|
|
1070
|
+
{ rule: ".update-journal/", kind: "journal", match: under(".update-journal") },
|
|
1071
|
+
{ rule: "update-in-progress.json", kind: "journal", match: exactly("update-in-progress.json") },
|
|
1072
|
+
{ rule: "workspaces/", kind: "user-state", match: under("workspaces") },
|
|
1073
|
+
{ rule: "credential-profiles/", kind: "user-state", match: under("credential-profiles") },
|
|
1074
|
+
{ rule: "cx/", kind: "user-state", match: under("cx") },
|
|
1075
|
+
// muse's isolated XDG home per instance (backend/muse.ts): links into the user's ~/.config — the CLI's own config
|
|
1076
|
+
// home, the same kind as cx/ and credential-profiles/ (Fable #4523 F3).
|
|
1077
|
+
{ rule: "instances/*/muse-xdg/", kind: "user-state", match: (rel) => /^instances\/[^/]+\/muse-xdg(\/|$)/.test(rel) },
|
|
1078
|
+
{ rule: "cache/", kind: "cache", match: under("cache") },
|
|
1079
|
+
{ rule: "cache-codex-rollouts.json, usage-last-good.json", kind: "cache", match: exactly("cache-codex-rollouts.json", "usage-last-good.json") },
|
|
1080
|
+
{ rule: "search.db*", kind: "cache", match: (rel) => !rel.includes("/") && rel.startsWith("search.db") },
|
|
1081
|
+
{ rule: "*.log", kind: "log", match: (rel) => base(rel).endsWith(".log") },
|
|
1082
|
+
{ rule: "profiles/", kind: "log", match: under("profiles") },
|
|
1083
|
+
{ rule: "tmux/, operator/", kind: "runtime", match: (rel) => under("tmux")(rel) || under("operator")(rel) },
|
|
1084
|
+
{ rule: "*.sock", kind: "runtime", match: (rel) => base(rel).endsWith(".sock") },
|
|
1085
|
+
{ rule: "fleet.pid, fleet.lock (+ its reclaim/handoff/tmp files)", kind: "runtime", match: (rel) => rel === "fleet.pid" || rel === "fleet.lock" || rel.startsWith("fleet.lock.") },
|
|
1086
|
+
{ rule: ".update.lock, .service.lock (+ reclaim markers)", kind: "runtime", match: (rel) => /^\.(update|service)\.lock(\.reclaim)?$/.test(rel) },
|
|
1087
|
+
{ rule: "tunnel.lease, web.token, view.token", kind: "runtime", match: exactly("tunnel.lease", "web.token", "view.token") },
|
|
1088
|
+
{ rule: ".state-lease.sqlite (+ -journal)", kind: "lease", match: exactly(".state-lease.sqlite", ".state-lease.sqlite-journal") }
|
|
1089
|
+
];
|
|
1090
|
+
function classify(rel) {
|
|
1091
|
+
if (rel === "" || rel.startsWith("/") || rel.split("/").some((p) => p === "" || p === "." || p === "..")) throw new Error(`not a relative path in the home: ${JSON.stringify(rel)}`);
|
|
1092
|
+
for (const r of EXCLUDED) if (r.match(rel)) return { included: false, kind: r.kind, rule: r.rule };
|
|
1093
|
+
return { included: true };
|
|
1094
|
+
}
|
|
1095
|
+
var home = (path, phase, by, extra = {}) => ({ path, where: "home", phase, by, ...extra });
|
|
1096
|
+
var outside = (path, phase, by, restoredBy) => ({ path, where: "outside", phase, by, ...restoredBy ? { restoredBy } : {} });
|
|
1097
|
+
var WRITER_INVENTORY = [
|
|
1098
|
+
// ── Fleet startup and migrations (pre-commit: the trial fleet starts before commit) ──
|
|
1099
|
+
home("fleet.yaml", "pre-commit", "config load and migrations (fleet-yaml-patch, cli)"),
|
|
1100
|
+
home("fleet.pid", "pre-commit", "fleet start"),
|
|
1101
|
+
home("fleet.lock", "pre-commit", "fleet start (fleet-lock)"),
|
|
1102
|
+
home("fleet.lock.reclaim", "pre-commit", "fleet-lock's reclaim marker (the update's owned re-take of a dead holder)"),
|
|
1103
|
+
home("fleet.log", "pre-commit", "fleet logger"),
|
|
1104
|
+
home("fleet-fatal.log", "pre-commit", "fleet fatal handler"),
|
|
1105
|
+
home("daemon.log", "pre-commit", "daemon logger"),
|
|
1106
|
+
home("update.log", "pre-commit", "agend update"),
|
|
1107
|
+
home("service-install.log", "pre-commit", "web Install as a service (the fleet, whenever an admin presses it; S-246)"),
|
|
1108
|
+
home("update-in-progress.json", "pre-commit", "agend update (marker)"),
|
|
1109
|
+
home("events.db", "pre-commit", "event log (opened at start)"),
|
|
1110
|
+
home("scheduler.db", "pre-commit", "scheduler (opened at start; CLI under the state lease)"),
|
|
1111
|
+
home("delivery-outbox.db", "pre-commit", "delivery outbox (opened at start)"),
|
|
1112
|
+
home("profiles.db", "pre-commit", "web profiles (opened at start)"),
|
|
1113
|
+
home("reply-buttons.db", "pre-commit", "reply buttons (opened at start)"),
|
|
1114
|
+
home("instances", "pre-commit", "instance state at start (instances/<name>/\u2026)"),
|
|
1115
|
+
home("tmux", "pre-commit", "private tmux server"),
|
|
1116
|
+
home("tmux-migration.json", "pre-commit", "tmux migration"),
|
|
1117
|
+
home("operator", "pre-commit", "operator socket"),
|
|
1118
|
+
home("web.token", "pre-commit", "web server start"),
|
|
1119
|
+
home("view.token", "pre-commit", "web server start"),
|
|
1120
|
+
home("tunnel.lease", "pre-commit", "tunnel at start"),
|
|
1121
|
+
home("cli-env", "pre-commit", "CLI environment files at start"),
|
|
1122
|
+
home("hub-member", "pre-commit", "Hub member state at start"),
|
|
1123
|
+
home("hub-member-invalidate.pending", "pre-commit", "Hub member invalidation"),
|
|
1124
|
+
home("kiro-v3", "pre-commit", "kiro engine at start"),
|
|
1125
|
+
home("kiro-engine-ledger.json", "pre-commit", "kiro engine at start"),
|
|
1126
|
+
home("kiro-identity", "pre-commit", "kiro engine identity"),
|
|
1127
|
+
home(".update-journal", "pre-commit", "the update transaction"),
|
|
1128
|
+
home("host-monitoring.sqlite", "pre-commit", "host monitoring (a SQLite database opened at fleet start; \xA75.3 treats it as one)"),
|
|
1129
|
+
home("rollback.json", "pre-commit", "tmux migration rollback (tmux-rollback)"),
|
|
1130
|
+
home("kiro-classic-archives", "pre-commit", "kiro classic migration (kiro-classic-archive, kiro-migration-verify)"),
|
|
1131
|
+
home("kiro-reconciliations", "pre-commit", "kiro reconcile store"),
|
|
1132
|
+
home("search.db", "pre-commit", "search index (startSearchIndex at fleet start); another schema \u2192 rebuilt (search-store meta.schema)", { olderBuildRebuilds: true }),
|
|
1133
|
+
home("cache-codex-rollouts.json", "pre-commit", "cache service's codex rollout metadata; unknown entries are skipped (cache-service)", { olderBuildRebuilds: true }),
|
|
1134
|
+
home("usage-last-good.json", "pre-commit", "usage last-good rows; another version or shape is ignored (usage-api loadLastGood)", { olderBuildRebuilds: true }),
|
|
1135
|
+
// ── Ordinary operation (post-commit) ──
|
|
1136
|
+
home("workspaces", "post-commit", "agent launch (the agents' working directories)"),
|
|
1137
|
+
home("credential-profiles", "post-commit", "agent launch (the CLIs' homes, each profile's .claude.json)"),
|
|
1138
|
+
home("cx", "post-commit", "codex backend at agent launch"),
|
|
1139
|
+
home("instances/*/muse-xdg", "post-commit", "muse backend at agent launch (its isolated XDG home: links into ~/.config)"),
|
|
1140
|
+
home("cache", "post-commit", "caches"),
|
|
1141
|
+
home("usage-quota-history.jsonl", "post-commit", "usage"),
|
|
1142
|
+
home("quota-notices.json", "post-commit", "usage notices"),
|
|
1143
|
+
home("profiles", "post-commit", "CPU profiles"),
|
|
1144
|
+
home("access", "post-commit", "channel access lists"),
|
|
1145
|
+
home("inbox", "post-commit", "attachments inbox"),
|
|
1146
|
+
home("avatars", "post-commit", "web avatars"),
|
|
1147
|
+
home("cards", "post-commit", "web cards"),
|
|
1148
|
+
home("archived-topics.json", "post-commit", "topic archive"),
|
|
1149
|
+
home("backend-signin-pending.json", "post-commit", "backend sign-in"),
|
|
1150
|
+
home("bin", "post-commit", "cloudflared install"),
|
|
1151
|
+
home(".env", "post-commit", "quickstart settings"),
|
|
1152
|
+
home("classicBot.yaml", "post-commit", "ClassicBot"),
|
|
1153
|
+
home("credential-vault", "post-commit", "credential vault"),
|
|
1154
|
+
home("delivery-audit", "post-commit", "delivery audit"),
|
|
1155
|
+
home("forged-envelope-reports.json", "post-commit", "envelope reports"),
|
|
1156
|
+
home("hub-assistant", "post-commit", "Hub room assistant"),
|
|
1157
|
+
home("hub-classic-private.json", "post-commit", "Hub ClassicBot sharing"),
|
|
1158
|
+
home("hub-contact-windows.json", "post-commit", "Hub contact windows"),
|
|
1159
|
+
home("pending-owner-notices.json", "post-commit", "owner notices"),
|
|
1160
|
+
home("skipped-skills.json", "post-commit", "skill sync"),
|
|
1161
|
+
home("web-app-icon", "post-commit", "web settings"),
|
|
1162
|
+
home("web-authority.json", "post-commit", "web sign-in"),
|
|
1163
|
+
home("web-authorizations.json", "post-commit", "web sign-in"),
|
|
1164
|
+
home("web-devices.json", "post-commit", "web sign-in"),
|
|
1165
|
+
home("web-host-authorized", "post-commit", "web host"),
|
|
1166
|
+
home("web-mods", "post-commit", "web mods"),
|
|
1167
|
+
home("web-mods.json", "post-commit", "web mods"),
|
|
1168
|
+
home("web-office-skins", "post-commit", "web office"),
|
|
1169
|
+
home("web-offices.json", "post-commit", "web office"),
|
|
1170
|
+
home("web-owner-css", "post-commit", "web theme"),
|
|
1171
|
+
home("web-pins.json", "post-commit", "web pins"),
|
|
1172
|
+
home("web-sessions.json", "post-commit", "web sessions"),
|
|
1173
|
+
home("web-seen-users.json", "post-commit", "web chat mention names (M-3827)"),
|
|
1174
|
+
home("web-themes", "post-commit", "web themes"),
|
|
1175
|
+
home("web-themes.json", "post-commit", "web themes"),
|
|
1176
|
+
home("needs-you-message.json", "post-commit", "Needs-you hub"),
|
|
1177
|
+
home("agy-statusline.sh", "post-commit", "antigravity backend at agent launch"),
|
|
1178
|
+
home("shared", "post-commit", "web office packs (web-office-pack-read; its stateDir is the home)"),
|
|
1179
|
+
home("signin-launch", "post-commit", "web sign-in links \u2014 via web-signin-link's join over the home it is passed (cli.ts passes DATA_DIR)"),
|
|
1180
|
+
// ── Outside the home ──
|
|
1181
|
+
outside(".claude.json", "post-commit", "claude-code backend at agent launch (trust, onboarding); $CLAUDE_CONFIG_DIR/.claude.json when set"),
|
|
1182
|
+
outside(".claude", "post-commit", "claude-code backend and usage at agent launch"),
|
|
1183
|
+
outside(".codex", "post-commit", "codex backend at agent launch"),
|
|
1184
|
+
outside(".gemini", "post-commit", "gemini profiles at agent launch"),
|
|
1185
|
+
outside(".grok", "post-commit", "grok backend at agent launch"),
|
|
1186
|
+
outside(".kiro", "post-commit", "kiro backend at agent launch"),
|
|
1187
|
+
outside(".local", "post-commit", "backend CLIs' data at agent launch"),
|
|
1188
|
+
outside("AppData", "post-commit", "Windows pane stdio"),
|
|
1189
|
+
outside(".agend", "pre-commit", "the default AgEnD home itself (paths.ts) \u2014 the home, not outside it"),
|
|
1190
|
+
outside(".config", "pre-commit", "the systemd user unit (service-installer)", "unit-preimage"),
|
|
1191
|
+
outside("Library", "pre-commit", "the launchd agent plist (service-installer)", "unit-preimage"),
|
|
1192
|
+
outside(".npm-global", "pre-commit", "the npm prefix (the install itself)", "package-preimage"),
|
|
1193
|
+
outside(".nvm", "pre-commit", "nvm's Node prefix (the install itself)", "package-preimage")
|
|
1194
|
+
];
|
|
1195
|
+
|
|
1196
|
+
// src/update-snapshot-manifest.ts
|
|
1197
|
+
var import_node_crypto2 = require("node:crypto");
|
|
1198
|
+
var import_node_fs6 = require("node:fs");
|
|
1199
|
+
var import_node_path7 = require("node:path");
|
|
1200
|
+
var SNAPSHOT_DIR = "snapshot";
|
|
1201
|
+
var SNAPSHOT_MANIFEST = "snapshot.json";
|
|
1202
|
+
var sha256File = (path) => (0, import_node_crypto2.createHash)("sha256").update((0, import_node_fs6.readFileSync)(path)).digest("hex");
|
|
1203
|
+
function readManifest(attemptDir2) {
|
|
1204
|
+
try {
|
|
1205
|
+
const m = JSON.parse((0, import_node_fs6.readFileSync)((0, import_node_path7.join)(attemptDir2, SNAPSHOT_MANIFEST), "utf8"));
|
|
1206
|
+
return m && m.schema === 1 && Array.isArray(m.entries) && Array.isArray(m.databases) ? m : null;
|
|
1207
|
+
} catch {
|
|
1208
|
+
return null;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
function verifySnapshot(attemptDir2, manifest) {
|
|
1212
|
+
const out = (0, import_node_path7.join)(attemptDir2, SNAPSHOT_DIR);
|
|
1213
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1214
|
+
const visit = (rel) => {
|
|
1215
|
+
for (const name of (0, import_node_fs6.readdirSync)(rel ? (0, import_node_path7.join)(out, rel) : out).sort()) {
|
|
1216
|
+
const r = rel ? `${rel}/${name}` : name;
|
|
1217
|
+
const st = (0, import_node_fs6.lstatSync)((0, import_node_path7.join)(out, r));
|
|
1218
|
+
if (st.isSymbolicLink()) seen.set(r, { rel: r, type: "link", mode: 0, target: (0, import_node_fs6.readlinkSync)((0, import_node_path7.join)(out, r)) });
|
|
1219
|
+
else if (st.isDirectory()) {
|
|
1220
|
+
seen.set(r, { rel: r, type: "dir", mode: st.mode & 4095 });
|
|
1221
|
+
visit(r);
|
|
1222
|
+
} else if (st.isFile()) seen.set(r, { rel: r, type: "file", mode: st.mode & 4095, size: st.size, sha256: sha256File((0, import_node_path7.join)(out, r)) });
|
|
1223
|
+
else seen.set(r, { rel: r, type: "file", mode: -1 });
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1226
|
+
try {
|
|
1227
|
+
visit("");
|
|
1228
|
+
} catch (err) {
|
|
1229
|
+
return { ok: false, reason: `the snapshot can't be read (${err.message})` };
|
|
1230
|
+
}
|
|
1231
|
+
if (seen.size !== manifest.entries.length) return { ok: false, reason: `the snapshot holds ${seen.size} entries, its manifest ${manifest.entries.length}` };
|
|
1232
|
+
for (const e of manifest.entries) {
|
|
1233
|
+
const s = seen.get(e.rel);
|
|
1234
|
+
if (!s) return { ok: false, reason: `${e.rel} is missing from the snapshot` };
|
|
1235
|
+
if (s.type !== e.type) return { ok: false, reason: `${e.rel} is a ${s.type}, not a ${e.type}` };
|
|
1236
|
+
if (e.type === "link" && s.target !== e.target) return { ok: false, reason: `${e.rel} points elsewhere` };
|
|
1237
|
+
if (e.type === "file" && (s.sha256 !== e.sha256 || s.size !== e.size || s.mode !== e.mode)) return { ok: false, reason: `${e.rel} differs from its manifest` };
|
|
1238
|
+
if (e.type === "dir" && s.mode !== e.mode) return { ok: false, reason: `${e.rel}'s mode differs from its manifest` };
|
|
1239
|
+
}
|
|
1240
|
+
return { ok: true };
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
// src/update-restore.ts
|
|
1244
|
+
var RESTORE_LOG = "restore.log";
|
|
1245
|
+
var REPLACED_DIR = "replaced";
|
|
1246
|
+
var TMP_SUFFIX = ".restore-tmp";
|
|
1247
|
+
var defaultRestoreIo = { step: () => {
|
|
1248
|
+
} };
|
|
1249
|
+
var Manual = class extends Error {
|
|
1250
|
+
};
|
|
1251
|
+
var Retryable = class extends Error {
|
|
1252
|
+
};
|
|
1253
|
+
var fsyncPath = (p) => {
|
|
1254
|
+
const fd = (0, import_node_fs7.openSync)(p, "r");
|
|
1255
|
+
try {
|
|
1256
|
+
(0, import_node_fs7.fsyncSync)(fd);
|
|
1257
|
+
} finally {
|
|
1258
|
+
(0, import_node_fs7.closeSync)(fd);
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
var sha256File2 = (p) => (0, import_node_crypto3.createHash)("sha256").update((0, import_node_fs7.readFileSync)(p)).digest("hex");
|
|
1262
|
+
var parentRel = (rel) => rel.includes("/") ? rel.slice(0, rel.lastIndexOf("/")) : "";
|
|
1263
|
+
var under2 = (rel, u) => rel === u || rel.startsWith(`${u}/`);
|
|
1264
|
+
function identOf(path) {
|
|
1265
|
+
try {
|
|
1266
|
+
const st = (0, import_node_fs7.lstatSync)(path);
|
|
1267
|
+
return { type: st.isSymbolicLink() ? "link" : st.isDirectory() ? "dir" : "file", dev: st.dev, ino: st.ino, size: st.size, mtimeMs: st.mtimeMs };
|
|
1268
|
+
} catch {
|
|
1269
|
+
return null;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
var sameIdent = (a, b) => !!a && !!b && a.type === b.type && a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeMs === b.mtimeMs;
|
|
1273
|
+
function currentScope(home2) {
|
|
1274
|
+
const entries = /* @__PURE__ */ new Map(), containers = /* @__PURE__ */ new Set([""]);
|
|
1275
|
+
const visit = (rel) => {
|
|
1276
|
+
let excludedBelow = false;
|
|
1277
|
+
for (const name of (0, import_node_fs7.readdirSync)(rel ? (0, import_node_path8.join)(home2, rel) : home2).sort()) {
|
|
1278
|
+
const r = rel ? `${rel}/${name}` : name;
|
|
1279
|
+
if (r.endsWith(TMP_SUFFIX) && classify(r.slice(0, -TMP_SUFFIX.length)).included) continue;
|
|
1280
|
+
if (!classify(r).included) {
|
|
1281
|
+
excludedBelow = true;
|
|
1282
|
+
continue;
|
|
1283
|
+
}
|
|
1284
|
+
const st = (0, import_node_fs7.lstatSync)((0, import_node_path8.join)(home2, r));
|
|
1285
|
+
if (st.isSymbolicLink()) entries.set(r, { rel: r, type: "link", mode: 0, target: (0, import_node_fs7.readlinkSync)((0, import_node_path8.join)(home2, r)) });
|
|
1286
|
+
else if (st.isDirectory()) {
|
|
1287
|
+
entries.set(r, { rel: r, type: "dir", mode: st.mode & 4095 });
|
|
1288
|
+
if (visit(r)) {
|
|
1289
|
+
containers.add(r);
|
|
1290
|
+
excludedBelow = true;
|
|
1291
|
+
}
|
|
1292
|
+
} else entries.set(r, { rel: r, type: "file", mode: st.mode & 4095, size: st.size });
|
|
1293
|
+
}
|
|
1294
|
+
return excludedBelow;
|
|
1295
|
+
};
|
|
1296
|
+
visit("");
|
|
1297
|
+
return { entries, containers };
|
|
1298
|
+
}
|
|
1299
|
+
function unitsOf(rels, containers) {
|
|
1300
|
+
return [...rels].filter((r) => containers.has(parentRel(r)) && !containers.has(r));
|
|
1301
|
+
}
|
|
1302
|
+
function matchesManifest(home2, u, manifest) {
|
|
1303
|
+
const want = manifest.entries.filter((e) => under2(e.rel, u));
|
|
1304
|
+
const seen = [];
|
|
1305
|
+
const add = (r) => {
|
|
1306
|
+
let st;
|
|
1307
|
+
try {
|
|
1308
|
+
st = (0, import_node_fs7.lstatSync)((0, import_node_path8.join)(home2, r));
|
|
1309
|
+
} catch {
|
|
1310
|
+
return false;
|
|
1311
|
+
}
|
|
1312
|
+
if (st.isSymbolicLink()) seen.push({ rel: r, type: "link", mode: 0, target: (0, import_node_fs7.readlinkSync)((0, import_node_path8.join)(home2, r)) });
|
|
1313
|
+
else if (st.isDirectory()) {
|
|
1314
|
+
seen.push({ rel: r, type: "dir", mode: st.mode & 4095 });
|
|
1315
|
+
for (const n of (0, import_node_fs7.readdirSync)((0, import_node_path8.join)(home2, r))) if (!add(`${r}/${n}`)) return false;
|
|
1316
|
+
} else seen.push({ rel: r, type: "file", mode: st.mode & 4095, size: st.size, sha256: sha256File2((0, import_node_path8.join)(home2, r)) });
|
|
1317
|
+
return true;
|
|
1318
|
+
};
|
|
1319
|
+
if (!add(u) || seen.length !== want.length) return false;
|
|
1320
|
+
const byRel = new Map(seen.map((e) => [e.rel, e]));
|
|
1321
|
+
return want.every((e) => {
|
|
1322
|
+
const s = byRel.get(e.rel);
|
|
1323
|
+
if (!s || s.type !== e.type) return false;
|
|
1324
|
+
if (e.type === "link") return s.target === e.target;
|
|
1325
|
+
if (e.type === "dir") return s.mode === e.mode;
|
|
1326
|
+
return s.sha256 === e.sha256 && s.size === e.size && s.mode === e.mode;
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
function build(snapshot, u, dst, manifest) {
|
|
1330
|
+
const entries = manifest.entries.filter((e) => under2(e.rel, u)).sort((a, b) => a.rel.length - b.rel.length || a.rel.localeCompare(b.rel));
|
|
1331
|
+
const dirs = [];
|
|
1332
|
+
for (const e of entries) {
|
|
1333
|
+
const to = e.rel === u ? dst : (0, import_node_path8.join)(dst, e.rel.slice(u.length + 1));
|
|
1334
|
+
if (e.type === "dir") {
|
|
1335
|
+
(0, import_node_fs7.mkdirSync)(to, { mode: 448 });
|
|
1336
|
+
dirs.push(to);
|
|
1337
|
+
continue;
|
|
1338
|
+
}
|
|
1339
|
+
if (e.type === "link") {
|
|
1340
|
+
(0, import_node_fs7.symlinkSync)(e.target, to);
|
|
1341
|
+
continue;
|
|
1342
|
+
}
|
|
1343
|
+
const from = (0, import_node_path8.join)(snapshot, e.rel);
|
|
1344
|
+
(0, import_node_fs7.copyFileSync)(from, to, import_node_fs7.constants.COPYFILE_EXCL | import_node_fs7.constants.COPYFILE_FICLONE);
|
|
1345
|
+
(0, import_node_fs7.chmodSync)(to, e.mode);
|
|
1346
|
+
const st = (0, import_node_fs7.lstatSync)(from);
|
|
1347
|
+
(0, import_node_fs7.utimesSync)(to, st.atime, st.mtime);
|
|
1348
|
+
fsyncPath(to);
|
|
1349
|
+
}
|
|
1350
|
+
for (const e of entries) if (e.type === "dir") (0, import_node_fs7.chmodSync)(e.rel === u ? dst : (0, import_node_path8.join)(dst, e.rel.slice(u.length + 1)), e.mode);
|
|
1351
|
+
for (const d of dirs.sort((a, b) => b.length - a.length)) fsyncPath(d);
|
|
1352
|
+
}
|
|
1353
|
+
function restoreHome(home2, attemptDir2, deps, opts = {}) {
|
|
1354
|
+
const io = deps.io ?? defaultRestoreIo;
|
|
1355
|
+
const source = opts.snapshotFrom ?? attemptDir2;
|
|
1356
|
+
const snapshot = (0, import_node_path8.join)(source, SNAPSHOT_DIR), replaced = (0, import_node_path8.join)(attemptDir2, REPLACED_DIR), logPath = (0, import_node_path8.join)(attemptDir2, RESTORE_LOG);
|
|
1357
|
+
const manifest = readManifest(source);
|
|
1358
|
+
if (!manifest) return { ok: false, manual: true, reason: "the snapshot's manifest can't be read" };
|
|
1359
|
+
const intact = verifySnapshot(source, manifest);
|
|
1360
|
+
if (!intact.ok) return { ok: false, manual: true, reason: `the snapshot doesn't verify: ${intact.reason}` };
|
|
1361
|
+
const manifestSha256 = (0, import_node_crypto3.createHash)("sha256").update((0, import_node_fs7.readFileSync)((0, import_node_path8.join)(source, SNAPSHOT_MANIFEST))).digest("hex");
|
|
1362
|
+
try {
|
|
1363
|
+
let header, logged;
|
|
1364
|
+
let text = null;
|
|
1365
|
+
try {
|
|
1366
|
+
text = (0, import_node_fs7.readFileSync)(logPath, "utf8");
|
|
1367
|
+
} catch (err) {
|
|
1368
|
+
if (err.code !== "ENOENT") throw err;
|
|
1369
|
+
}
|
|
1370
|
+
if (text === null) {
|
|
1371
|
+
const now = currentScope(home2);
|
|
1372
|
+
const manifestRels = new Set(manifest.entries.map((e) => e.rel));
|
|
1373
|
+
const currentUnits = unitsOf(now.entries.keys(), now.containers);
|
|
1374
|
+
const manifestUnits = unitsOf(manifestRels, now.containers);
|
|
1375
|
+
const all = [.../* @__PURE__ */ new Set([...currentUnits, ...manifestUnits])].sort();
|
|
1376
|
+
const units = all.map((rel) => {
|
|
1377
|
+
const inCurrent = currentUnits.includes(rel), inManifest = manifestUnits.includes(rel);
|
|
1378
|
+
const current = inCurrent ? identOf((0, import_node_path8.join)(home2, rel)) ?? void 0 : void 0;
|
|
1379
|
+
return { rel, kind: inCurrent && inManifest ? "both" : inCurrent ? "new-only" : "manifest-only", ...current ? { current } : {} };
|
|
1380
|
+
});
|
|
1381
|
+
header = { schema: 1, manifestSha256, units, containers: [...now.containers].filter((c) => c !== "").sort() };
|
|
1382
|
+
const tmp = `${logPath}.tmp-${process.pid}`;
|
|
1383
|
+
const fd = (0, import_node_fs7.openSync)(tmp, "wx", 384);
|
|
1384
|
+
try {
|
|
1385
|
+
(0, import_node_fs7.writeSync)(fd, JSON.stringify(header) + "\n");
|
|
1386
|
+
(0, import_node_fs7.fsyncSync)(fd);
|
|
1387
|
+
} finally {
|
|
1388
|
+
(0, import_node_fs7.closeSync)(fd);
|
|
1389
|
+
}
|
|
1390
|
+
(0, import_node_fs7.renameSync)(tmp, logPath);
|
|
1391
|
+
fsyncPath(attemptDir2);
|
|
1392
|
+
io.step("header");
|
|
1393
|
+
logged = [];
|
|
1394
|
+
} else {
|
|
1395
|
+
const end = text.lastIndexOf("\n") + 1;
|
|
1396
|
+
if (end < text.length) {
|
|
1397
|
+
(0, import_node_fs7.truncateSync)(logPath, Buffer.byteLength(text.slice(0, end)));
|
|
1398
|
+
fsyncPath(logPath);
|
|
1399
|
+
io.step("truncate-torn");
|
|
1400
|
+
text = text.slice(0, end);
|
|
1401
|
+
}
|
|
1402
|
+
const lines = text.split("\n").filter(Boolean);
|
|
1403
|
+
if (lines.length === 0) throw new Manual("restore.log has no header");
|
|
1404
|
+
try {
|
|
1405
|
+
header = JSON.parse(lines[0]);
|
|
1406
|
+
} catch {
|
|
1407
|
+
throw new Manual("restore.log's header can't be read");
|
|
1408
|
+
}
|
|
1409
|
+
if (header.schema !== 1 || header.manifestSha256 !== manifestSha256) throw new Manual("restore.log's header doesn't match this snapshot");
|
|
1410
|
+
logged = [];
|
|
1411
|
+
for (const l of lines.slice(1)) {
|
|
1412
|
+
try {
|
|
1413
|
+
logged.push(JSON.parse(l));
|
|
1414
|
+
} catch {
|
|
1415
|
+
throw new Manual("restore.log has an unreadable line");
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
const log = (line) => {
|
|
1420
|
+
const fd = (0, import_node_fs7.openSync)(logPath, "a");
|
|
1421
|
+
try {
|
|
1422
|
+
(0, import_node_fs7.writeSync)(fd, JSON.stringify(line) + "\n");
|
|
1423
|
+
(0, import_node_fs7.fsyncSync)(fd);
|
|
1424
|
+
} finally {
|
|
1425
|
+
(0, import_node_fs7.closeSync)(fd);
|
|
1426
|
+
}
|
|
1427
|
+
logged.push(line);
|
|
1428
|
+
io.step("step" in line && "u" in line ? `log:${line.step}:${line.u}` : `log:${line.step}`);
|
|
1429
|
+
};
|
|
1430
|
+
const has = (u, step) => logged.some((l) => "u" in l && l.u === u && l.step === step);
|
|
1431
|
+
const aside = (u) => {
|
|
1432
|
+
const to = (0, import_node_path8.join)(replaced, u);
|
|
1433
|
+
(0, import_node_fs7.mkdirSync)((0, import_node_path8.dirname)(to), { recursive: true, mode: 448 });
|
|
1434
|
+
(0, import_node_fs7.renameSync)((0, import_node_path8.join)(home2, u), to);
|
|
1435
|
+
io.step(`rename-aside:${u}`);
|
|
1436
|
+
fsyncPath((0, import_node_path8.dirname)((0, import_node_path8.join)(home2, u)));
|
|
1437
|
+
fsyncPath((0, import_node_path8.dirname)(to));
|
|
1438
|
+
io.step(`fsync-aside:${u}`);
|
|
1439
|
+
log({ u, step: "aside" });
|
|
1440
|
+
};
|
|
1441
|
+
const restore = (u) => {
|
|
1442
|
+
const tmp = (0, import_node_path8.join)(home2, u + TMP_SUFFIX);
|
|
1443
|
+
(0, import_node_fs7.rmSync)(tmp, { recursive: true, force: true });
|
|
1444
|
+
build(snapshot, u, tmp, manifest);
|
|
1445
|
+
io.step(`built:${u}`);
|
|
1446
|
+
(0, import_node_fs7.renameSync)(tmp, (0, import_node_path8.join)(home2, u));
|
|
1447
|
+
io.step(`rename-restore:${u}`);
|
|
1448
|
+
fsyncPath((0, import_node_path8.dirname)((0, import_node_path8.join)(home2, u)));
|
|
1449
|
+
io.step(`fsync-restore:${u}`);
|
|
1450
|
+
log({ u, step: "restored" });
|
|
1451
|
+
};
|
|
1452
|
+
for (const unit of header.units) {
|
|
1453
|
+
const u = unit.rel, at = (0, import_node_path8.join)(home2, u), moved = (0, import_node_path8.join)(replaced, u);
|
|
1454
|
+
const complete = has(u, "restored") || unit.kind === "new-only" && has(u, "aside");
|
|
1455
|
+
if (complete) continue;
|
|
1456
|
+
const here = identOf(at), there = identOf(moved);
|
|
1457
|
+
if (unit.kind === "new-only") {
|
|
1458
|
+
if (!here && sameIdent(there, unit.current)) {
|
|
1459
|
+
log({ u, step: "aside" });
|
|
1460
|
+
continue;
|
|
1461
|
+
}
|
|
1462
|
+
if (here && !there) {
|
|
1463
|
+
aside(u);
|
|
1464
|
+
continue;
|
|
1465
|
+
}
|
|
1466
|
+
throw new Manual(`${u} (new since the snapshot) is in a state the restore doesn't cover`);
|
|
1467
|
+
}
|
|
1468
|
+
if (unit.kind === "both" && !has(u, "aside")) {
|
|
1469
|
+
if (!here && sameIdent(there, unit.current)) log({ u, step: "aside" });
|
|
1470
|
+
else if (sameIdent(here, unit.current) && !there) aside(u);
|
|
1471
|
+
else throw new Manual(`${u} is in a state the restore doesn't cover (present: ${!!here}, set aside: ${!!there})`);
|
|
1472
|
+
}
|
|
1473
|
+
if (identOf(at)) {
|
|
1474
|
+
if (matchesManifest(home2, u, manifest)) {
|
|
1475
|
+
log({ u, step: "restored" });
|
|
1476
|
+
continue;
|
|
1477
|
+
}
|
|
1478
|
+
throw new Manual(`${u} is present and matches neither the snapshot nor the plan`);
|
|
1479
|
+
}
|
|
1480
|
+
restore(u);
|
|
1481
|
+
}
|
|
1482
|
+
if (!logged.some((l) => l.step === "containers")) {
|
|
1483
|
+
const modes = new Map(manifest.entries.filter((e) => e.type === "dir").map((e) => [e.rel, e.mode]));
|
|
1484
|
+
for (const c of header.containers) {
|
|
1485
|
+
if (!identOf((0, import_node_path8.join)(home2, c))) (0, import_node_fs7.mkdirSync)((0, import_node_path8.join)(home2, c), { recursive: true, mode: 448 });
|
|
1486
|
+
const mode = modes.get(c);
|
|
1487
|
+
if (mode !== void 0) (0, import_node_fs7.chmodSync)((0, import_node_path8.join)(home2, c), mode);
|
|
1488
|
+
}
|
|
1489
|
+
fsyncPath(home2);
|
|
1490
|
+
log({ step: "containers" });
|
|
1491
|
+
}
|
|
1492
|
+
if (!logged.some((l) => l.step === "verified")) {
|
|
1493
|
+
const now = currentScope(home2).entries;
|
|
1494
|
+
const want = new Map(manifest.entries.map((e) => [e.rel, e]));
|
|
1495
|
+
const newContainers = new Set(header.containers.filter((c) => !want.has(c)));
|
|
1496
|
+
for (const rel of now.keys()) {
|
|
1497
|
+
if (want.has(rel) || newContainers.has(rel)) continue;
|
|
1498
|
+
throw new Manual(`after the restore, ${rel} is in the home but not in the snapshot`);
|
|
1499
|
+
}
|
|
1500
|
+
for (const e of manifest.entries) if (!now.has(e.rel)) throw new Manual(`after the restore, ${e.rel} is missing`);
|
|
1501
|
+
for (const u of header.units) if (want.has(u.rel) && !matchesManifest(home2, u.rel, manifest)) throw new Manual(`after the restore, ${u.rel} doesn't match the snapshot`);
|
|
1502
|
+
const writers = deps.proveWritersGone();
|
|
1503
|
+
if (!writers.ok) throw new Retryable(`a writer appeared during the restore: ${writers.reason}`);
|
|
1504
|
+
log({ step: "verified" });
|
|
1505
|
+
}
|
|
1506
|
+
return { ok: true };
|
|
1507
|
+
} catch (err) {
|
|
1508
|
+
if (err instanceof Manual) return { ok: false, manual: true, reason: err.message };
|
|
1509
|
+
if (err instanceof Retryable) return { ok: false, manual: false, reason: err.message };
|
|
1510
|
+
throw err;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
// src/update-package-restore.ts
|
|
1515
|
+
var import_node_crypto4 = require("node:crypto");
|
|
1516
|
+
var import_node_fs9 = require("node:fs");
|
|
1517
|
+
var import_node_path10 = require("node:path");
|
|
1518
|
+
|
|
1519
|
+
// src/update-recovery/route.ts
|
|
1520
|
+
var import_node_fs8 = require("node:fs");
|
|
1521
|
+
var import_node_path9 = require("node:path");
|
|
1522
|
+
var DROP_IN_NAME = "agend-update-recovery.conf";
|
|
1523
|
+
var WRAPPER_ARG0 = "agend-update-recovery";
|
|
1524
|
+
var UNIT_PREIMAGE = "unit.preimage";
|
|
1525
|
+
var NONCE_CASE = Array.from({ length: 32 }, () => "[0-9a-f]").join("");
|
|
1526
|
+
var WRAPPER_SCRIPT = [
|
|
1527
|
+
`"$1" "$2" --home "$3" --attempt "$4" --pre-start || exit $?`,
|
|
1528
|
+
`f="$3/.update-journal/attempts/$4/handoff.env"`,
|
|
1529
|
+
`if [ -f "$f" ]; then`,
|
|
1530
|
+
` IFS= read -r line < "$f" || true`,
|
|
1531
|
+
` case "$line" in`,
|
|
1532
|
+
` AGEND_UPDATE_HANDOFF=${NONCE_CASE}) AGEND_UPDATE_HANDOFF=\${line#AGEND_UPDATE_HANDOFF=}; export AGEND_UPDATE_HANDOFF ;;`,
|
|
1533
|
+
` esac`,
|
|
1534
|
+
`fi`,
|
|
1535
|
+
`shift 4`,
|
|
1536
|
+
`exec "$@"`
|
|
1537
|
+
].join("\n");
|
|
1538
|
+
var dropInPath = (service) => (0, import_node_path9.join)((0, import_node_path9.dirname)(service.fragmentPath), `${service.unit}.d`, DROP_IN_NAME);
|
|
1539
|
+
var unitPreimagePath = (home2, attemptId) => (0, import_node_path9.join)(attemptDir(home2, attemptId), UNIT_PREIMAGE);
|
|
1540
|
+
var unitSafe = (path) => /^\/[A-Za-z0-9_./@+:,-]*$/.test(path);
|
|
1541
|
+
function writeDurable(path, data, io, mode = 384) {
|
|
1542
|
+
const tmp = `${path}.tmp-${process.pid}-${Date.now().toString(36)}`;
|
|
1543
|
+
const fileMode = mode === "keep" ? (0, import_node_fs8.statSync)(path).mode & 4095 : mode;
|
|
1544
|
+
const fd = (0, import_node_fs8.openSync)(tmp, "wx", fileMode);
|
|
1545
|
+
try {
|
|
1546
|
+
(0, import_node_fs8.writeSync)(fd, typeof data === "string" ? Buffer.from(data) : data);
|
|
1547
|
+
(0, import_node_fs8.fchmodSync)(fd, fileMode);
|
|
1548
|
+
(0, import_node_fs8.fsyncSync)(fd);
|
|
1549
|
+
} finally {
|
|
1550
|
+
(0, import_node_fs8.closeSync)(fd);
|
|
1551
|
+
}
|
|
1552
|
+
(0, import_node_fs8.renameSync)(tmp, path);
|
|
1553
|
+
io.fsyncDir((0, import_node_path9.dirname)(path));
|
|
1554
|
+
}
|
|
1555
|
+
function dropInText(home2, attemptId) {
|
|
1556
|
+
const kit = kitDir(home2, attemptId);
|
|
1557
|
+
return [
|
|
1558
|
+
"# AgEnD update recovery (M-3770): every start of this service first asks the update journal.",
|
|
1559
|
+
"[Service]",
|
|
1560
|
+
`ExecStartPre=${(0, import_node_path9.join)(kit, "node")} ${(0, import_node_path9.join)(kit, "recover.cjs")} --home ${home2} --attempt ${attemptId} --pre-start`,
|
|
1561
|
+
`EnvironmentFile=-${handoffEnvPath(home2, attemptId)}`,
|
|
1562
|
+
""
|
|
1563
|
+
].join("\n");
|
|
1564
|
+
}
|
|
1565
|
+
var xmlEscape = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1566
|
+
var PROGRAM_ARGS = /(<key>ProgramArguments<\/key>\s*<array>)([\s\S]*?)(\s*<\/array>)/;
|
|
1567
|
+
function wrapPlist(xml, home2, attemptId, originalArgs) {
|
|
1568
|
+
if (/<key>Program<\/key>/.test(xml) || (xml.match(/<key>ProgramArguments<\/key>/g) ?? []).length !== 1) return null;
|
|
1569
|
+
const kit = kitDir(home2, attemptId);
|
|
1570
|
+
const words = ["/bin/sh", "-c", WRAPPER_SCRIPT, WRAPPER_ARG0, (0, import_node_path9.join)(kit, "node"), (0, import_node_path9.join)(kit, "recover.cjs"), home2, attemptId, ...originalArgs];
|
|
1571
|
+
return xml.replace(PROGRAM_ARGS, (_all, open, _body, close) => `${open}
|
|
1572
|
+
${words.map((w) => ` <string>${xmlEscape(w)}</string>`).join("\n")}${close}`);
|
|
1573
|
+
}
|
|
1574
|
+
function wrappedFromPreimage(home2, attemptId, preimage, plistArgs) {
|
|
1575
|
+
const original = plistArgs(preimage);
|
|
1576
|
+
if (!original || original.length === 0) return { ok: false, reason: "the job's original arguments can't be read" };
|
|
1577
|
+
const xml = wrapPlist(preimage, home2, attemptId, original);
|
|
1578
|
+
return xml ? { ok: true, xml } : { ok: false, reason: "it has no single ProgramArguments array to wrap" };
|
|
1579
|
+
}
|
|
1580
|
+
function writeRecoveryRoute(home2, attempt, deps, io = defaultJournalIo) {
|
|
1581
|
+
const service = identityOf(attempt)?.ownership.service;
|
|
1582
|
+
if (!service) return { ok: false, reason: "the attempt records no service to route through" };
|
|
1583
|
+
let bytes;
|
|
1584
|
+
try {
|
|
1585
|
+
bytes = (0, import_node_fs8.readFileSync)(service.fragmentPath);
|
|
1586
|
+
} catch (err) {
|
|
1587
|
+
return { ok: false, reason: `the service definition ${service.fragmentPath} can't be read (${err.message})` };
|
|
1588
|
+
}
|
|
1589
|
+
const pre = unitPreimagePath(home2, attempt.id);
|
|
1590
|
+
let kept = null;
|
|
1591
|
+
try {
|
|
1592
|
+
kept = (0, import_node_fs8.readFileSync)(pre);
|
|
1593
|
+
} catch (err) {
|
|
1594
|
+
if (err.code !== "ENOENT") return { ok: false, reason: `${pre} can't be read (${err.message})` };
|
|
1595
|
+
}
|
|
1596
|
+
if (kept === null) {
|
|
1597
|
+
try {
|
|
1598
|
+
mkdirDurable(io, home2, attemptDir(home2, attempt.id));
|
|
1599
|
+
writeDurable(pre, bytes, io);
|
|
1600
|
+
} catch (err) {
|
|
1601
|
+
return { ok: false, reason: `the unit's preimage can't be kept (${err.message})` };
|
|
1602
|
+
}
|
|
1603
|
+
} else if (service.kind === "systemd" && !kept.equals(bytes)) {
|
|
1604
|
+
return { ok: false, reason: `the unit ${service.fragmentPath} changed since its preimage was kept` };
|
|
1605
|
+
}
|
|
1606
|
+
if (service.kind === "systemd") {
|
|
1607
|
+
const kit = kitDir(home2, attempt.id);
|
|
1608
|
+
for (const p of [home2, kit, handoffEnvPath(home2, attempt.id)]) if (!unitSafe(p)) return { ok: false, reason: `${p} can't be written into a unit file as one plain word` };
|
|
1609
|
+
const path = dropInPath(service);
|
|
1610
|
+
try {
|
|
1611
|
+
mkdirDurable(io, (0, import_node_path9.dirname)((0, import_node_path9.dirname)(path)), (0, import_node_path9.dirname)(path));
|
|
1612
|
+
writeDurable(path, dropInText(home2, attempt.id), io, 420);
|
|
1613
|
+
} catch (err) {
|
|
1614
|
+
return { ok: false, reason: `the drop-in ${path} can't be written (${err.message})` };
|
|
1615
|
+
}
|
|
1616
|
+
return { ok: true, path };
|
|
1617
|
+
}
|
|
1618
|
+
const wrapped = wrappedFromPreimage(home2, attempt.id, (kept ?? bytes).toString("utf8"), deps.plistArgs);
|
|
1619
|
+
if (!wrapped.ok) return { ok: false, reason: `${service.fragmentPath}: ${wrapped.reason}` };
|
|
1620
|
+
const current = bytes.toString("utf8");
|
|
1621
|
+
if (kept !== null && current !== kept.toString("utf8") && current !== wrapped.xml) {
|
|
1622
|
+
return { ok: false, reason: `${service.fragmentPath} changed since its preimage was kept (it is neither the preimage nor this route's wrapper)` };
|
|
1623
|
+
}
|
|
1624
|
+
if (current === wrapped.xml) return { ok: true, path: service.fragmentPath };
|
|
1625
|
+
try {
|
|
1626
|
+
writeDurable(service.fragmentPath, wrapped.xml, io, "keep");
|
|
1627
|
+
} catch (err) {
|
|
1628
|
+
return { ok: false, reason: `${service.fragmentPath} can't be written (${err.message})` };
|
|
1629
|
+
}
|
|
1630
|
+
return { ok: true, path: service.fragmentPath };
|
|
1631
|
+
}
|
|
1632
|
+
function removeRecoveryRoute(home2, attempt, deps, io = defaultJournalIo) {
|
|
1633
|
+
const service = identityOf(attempt)?.ownership.service;
|
|
1634
|
+
if (!service) return { ok: false, reason: "the attempt records no service" };
|
|
1635
|
+
if (service.kind === "systemd") {
|
|
1636
|
+
const path = dropInPath(service);
|
|
1637
|
+
try {
|
|
1638
|
+
(0, import_node_fs8.unlinkSync)(path);
|
|
1639
|
+
} catch (err) {
|
|
1640
|
+
if (err.code !== "ENOENT") return { ok: false, reason: `${path} can't be removed (${err.message})` };
|
|
1641
|
+
}
|
|
1642
|
+
try {
|
|
1643
|
+
io.fsyncDir((0, import_node_path9.dirname)(path));
|
|
1644
|
+
} catch (err) {
|
|
1645
|
+
if (err.code !== "ENOENT") return { ok: false, reason: `${(0, import_node_path9.dirname)(path)} can't be synced (${err.message})` };
|
|
1646
|
+
}
|
|
1647
|
+
return { ok: true, path };
|
|
1648
|
+
}
|
|
1649
|
+
let kept, current;
|
|
1650
|
+
try {
|
|
1651
|
+
kept = (0, import_node_fs8.readFileSync)(unitPreimagePath(home2, attempt.id));
|
|
1652
|
+
} catch (err) {
|
|
1653
|
+
return { ok: false, reason: `the unit's preimage can't be read (${err.message}); the wrapper stays` };
|
|
1654
|
+
}
|
|
1655
|
+
try {
|
|
1656
|
+
current = (0, import_node_fs8.readFileSync)(service.fragmentPath, "utf8");
|
|
1657
|
+
} catch (err) {
|
|
1658
|
+
return { ok: false, reason: `${service.fragmentPath} can't be read (${err.message}); the wrapper stays` };
|
|
1659
|
+
}
|
|
1660
|
+
if (current === kept.toString("utf8")) return { ok: true, path: service.fragmentPath };
|
|
1661
|
+
const wrapped = wrappedFromPreimage(home2, attempt.id, kept.toString("utf8"), deps.plistArgs);
|
|
1662
|
+
if (!wrapped.ok || current !== wrapped.xml) return { ok: false, reason: `${service.fragmentPath} isn't this route's wrapper any more; it is left as it is` };
|
|
1663
|
+
try {
|
|
1664
|
+
writeDurable(service.fragmentPath, kept, io, "keep");
|
|
1665
|
+
} catch (err) {
|
|
1666
|
+
return { ok: false, reason: `${service.fragmentPath} can't be written back (${err.message})` };
|
|
1667
|
+
}
|
|
1668
|
+
return { ok: true, path: service.fragmentPath };
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
// src/update-package-restore.ts
|
|
1672
|
+
var ATTEMPT_PREIMAGE_PREFIX = "attempt-";
|
|
1673
|
+
var PREIMAGE_MANIFEST = "preimage.json";
|
|
1674
|
+
var attemptPreimageDir = (prefix, attemptId) => (0, import_node_path10.join)(prefix, ".agend-rollback", `${ATTEMPT_PREIMAGE_PREFIX}${attemptId}`);
|
|
1675
|
+
var fsyncPath2 = (p) => {
|
|
1676
|
+
const fd = (0, import_node_fs9.openSync)(p, "r");
|
|
1677
|
+
try {
|
|
1678
|
+
(0, import_node_fs9.fsyncSync)(fd);
|
|
1679
|
+
} finally {
|
|
1680
|
+
(0, import_node_fs9.closeSync)(fd);
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
var sha256 = (b) => (0, import_node_crypto4.createHash)("sha256").update(b).digest("hex");
|
|
1684
|
+
function treeOf(root) {
|
|
1685
|
+
const out = [];
|
|
1686
|
+
const visit = (rel) => {
|
|
1687
|
+
for (const name of (0, import_node_fs9.readdirSync)(rel ? (0, import_node_path10.join)(root, rel) : root).sort()) {
|
|
1688
|
+
const r = rel ? `${rel}/${name}` : name, st = (0, import_node_fs9.lstatSync)((0, import_node_path10.join)(root, r));
|
|
1689
|
+
if (st.isSymbolicLink()) out.push({ rel: r, type: "link", mode: 0, target: (0, import_node_fs9.readlinkSync)((0, import_node_path10.join)(root, r)) });
|
|
1690
|
+
else if (st.isDirectory()) {
|
|
1691
|
+
out.push({ rel: r, type: "dir", mode: st.mode & 4095 });
|
|
1692
|
+
visit(r);
|
|
1693
|
+
} else out.push({ rel: r, type: "file", mode: st.mode & 4095, sha256: sha256((0, import_node_fs9.readFileSync)((0, import_node_path10.join)(root, r))) });
|
|
1694
|
+
}
|
|
1695
|
+
};
|
|
1696
|
+
visit("");
|
|
1697
|
+
return out;
|
|
1698
|
+
}
|
|
1699
|
+
function treeMatches(root, entries) {
|
|
1700
|
+
if (!(0, import_node_fs9.existsSync)(root)) return false;
|
|
1701
|
+
let now;
|
|
1702
|
+
try {
|
|
1703
|
+
now = treeOf(root);
|
|
1704
|
+
} catch {
|
|
1705
|
+
return false;
|
|
1706
|
+
}
|
|
1707
|
+
return JSON.stringify(now) === JSON.stringify(entries);
|
|
1708
|
+
}
|
|
1709
|
+
function fsyncTree(root) {
|
|
1710
|
+
const dirs = [root];
|
|
1711
|
+
for (const e of treeOf(root)) {
|
|
1712
|
+
if (e.type === "dir") dirs.push((0, import_node_path10.join)(root, e.rel));
|
|
1713
|
+
else if (e.type === "file") fsyncPath2((0, import_node_path10.join)(root, e.rel));
|
|
1714
|
+
}
|
|
1715
|
+
for (const d of dirs.sort((a, b) => b.length - a.length)) fsyncPath2(d);
|
|
1716
|
+
}
|
|
1717
|
+
function readAttemptPreimage(dir, manifestSha256) {
|
|
1718
|
+
let text;
|
|
1719
|
+
try {
|
|
1720
|
+
text = (0, import_node_fs9.readFileSync)((0, import_node_path10.join)(dir, PREIMAGE_MANIFEST), "utf8");
|
|
1721
|
+
} catch (err) {
|
|
1722
|
+
return { ok: false, reason: `the preimage's manifest can't be read (${err.message})` };
|
|
1723
|
+
}
|
|
1724
|
+
if (sha256(text) !== manifestSha256) return { ok: false, reason: "the preimage's manifest isn't the one the attempt recorded" };
|
|
1725
|
+
const manifest = JSON.parse(text);
|
|
1726
|
+
if (!treeMatches((0, import_node_path10.join)(dir, "agend"), manifest.entries)) return { ok: false, reason: "the preimage's tree doesn't match its manifest" };
|
|
1727
|
+
return { ok: true, manifest };
|
|
1728
|
+
}
|
|
1729
|
+
var Manual2 = class extends Error {
|
|
1730
|
+
};
|
|
1731
|
+
function restorePackage(ownership, attemptId, manifestSha256, steps, opts = {}) {
|
|
1732
|
+
const dir = attemptPreimageDir(ownership.prefix, attemptId);
|
|
1733
|
+
const pre = readAttemptPreimage(dir, manifestSha256);
|
|
1734
|
+
if (!pre.ok) return { ok: false, manual: true, reason: pre.reason };
|
|
1735
|
+
const { manifest } = pre;
|
|
1736
|
+
const work = opts.work ?? attemptId, workDir = attemptPreimageDir(ownership.prefix, work);
|
|
1737
|
+
if (opts.work) (0, import_node_fs9.mkdirSync)(workDir, { recursive: true, mode: 448 });
|
|
1738
|
+
const pkg = ownership.packagePath, scope = (0, import_node_path10.dirname)(pkg), staged = (0, import_node_path10.join)(scope, opts.work ? `.agend-goback-${work}` : `.agend-restore-${attemptId}`), replaced = (0, import_node_path10.join)(workDir, opts.work ? "go-back-replaced-package" : "replaced-package");
|
|
1739
|
+
try {
|
|
1740
|
+
if (pkg !== manifest.packagePath) throw new Manual2(`the preimage was taken for ${manifest.packagePath}, not ${pkg}`);
|
|
1741
|
+
if (!steps.done("pkg-aside")) {
|
|
1742
|
+
const here = (0, import_node_fs9.existsSync)(pkg) || isLink(pkg), there = (0, import_node_fs9.existsSync)(replaced) || isLink(replaced);
|
|
1743
|
+
if (here && !there) {
|
|
1744
|
+
(0, import_node_fs9.renameSync)(pkg, replaced);
|
|
1745
|
+
fsyncPath2(scope);
|
|
1746
|
+
fsyncPath2(workDir);
|
|
1747
|
+
} else if (here && there) throw new Manual2(`${pkg} and ${replaced} both exist`);
|
|
1748
|
+
steps.record("pkg-aside");
|
|
1749
|
+
}
|
|
1750
|
+
if (!steps.done("pkg-staged")) {
|
|
1751
|
+
(0, import_node_fs9.rmSync)(staged, { recursive: true, force: true });
|
|
1752
|
+
(0, import_node_fs9.cpSync)((0, import_node_path10.join)(dir, "agend"), staged, { recursive: true, verbatimSymlinks: true, preserveTimestamps: true });
|
|
1753
|
+
fsyncTree(staged);
|
|
1754
|
+
fsyncPath2(scope);
|
|
1755
|
+
steps.record("pkg-staged");
|
|
1756
|
+
}
|
|
1757
|
+
if (!steps.done("pkg-placed")) {
|
|
1758
|
+
if (treeMatches(pkg, manifest.entries) && !(0, import_node_fs9.existsSync)(staged)) {
|
|
1759
|
+
} else if ((0, import_node_fs9.existsSync)(staged) && !(0, import_node_fs9.existsSync)(pkg) && !isLink(pkg)) {
|
|
1760
|
+
(0, import_node_fs9.renameSync)(staged, pkg);
|
|
1761
|
+
fsyncPath2(scope);
|
|
1762
|
+
} else throw new Manual2(`${pkg} can't be placed: ${(0, import_node_fs9.existsSync)(pkg) ? "something else is there" : "the staged tree is missing"}`);
|
|
1763
|
+
steps.record("pkg-placed");
|
|
1764
|
+
}
|
|
1765
|
+
if (!steps.done("bins")) {
|
|
1766
|
+
for (const before of Object.values(manifest.bins)) {
|
|
1767
|
+
const { link } = before;
|
|
1768
|
+
const st = (0, import_node_fs9.lstatSync)(link, { throwIfNoEntry: false });
|
|
1769
|
+
if (before.kind === "file") {
|
|
1770
|
+
if (!st || !st.isFile() || sha256((0, import_node_fs9.readFileSync)(link)) !== before.sha256) throw new Manual2(`${link} was a file before the install, and isn't that file now`);
|
|
1771
|
+
continue;
|
|
1772
|
+
}
|
|
1773
|
+
if (before.kind === "absent") {
|
|
1774
|
+
if (st) {
|
|
1775
|
+
if (st.isSymbolicLink()) (0, import_node_fs9.unlinkSync)(link);
|
|
1776
|
+
else throw new Manual2(`${link} wasn't there before, and isn't a link now`);
|
|
1777
|
+
}
|
|
1778
|
+
continue;
|
|
1779
|
+
}
|
|
1780
|
+
if (st?.isSymbolicLink() && (0, import_node_fs9.readlinkSync)(link) === before.target) continue;
|
|
1781
|
+
if (st && !st.isSymbolicLink()) throw new Manual2(`${link} is a file now, not the link it was`);
|
|
1782
|
+
const tmp = `${link}.restore-tmp`;
|
|
1783
|
+
(0, import_node_fs9.rmSync)(tmp, { force: true });
|
|
1784
|
+
(0, import_node_fs9.symlinkSync)(before.target, tmp);
|
|
1785
|
+
(0, import_node_fs9.renameSync)(tmp, link);
|
|
1786
|
+
}
|
|
1787
|
+
for (const d of new Set(Object.values(manifest.bins).map((b) => (0, import_node_path10.dirname)(b.link)))) fsyncPath2(d);
|
|
1788
|
+
steps.record("bins");
|
|
1789
|
+
}
|
|
1790
|
+
return { ok: true };
|
|
1791
|
+
} catch (err) {
|
|
1792
|
+
if (err instanceof Manual2) return { ok: false, manual: true, reason: err.message };
|
|
1793
|
+
throw err;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
function isLink(p) {
|
|
1797
|
+
try {
|
|
1798
|
+
return (0, import_node_fs9.lstatSync)(p).isSymbolicLink();
|
|
1799
|
+
} catch {
|
|
1800
|
+
return false;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
function restoreUnit(home2, attempt, opts, steps) {
|
|
1804
|
+
const service = identityOf(attempt)?.ownership.service;
|
|
1805
|
+
if (!service) return { ok: false, manual: true, reason: "the attempt records no service" };
|
|
1806
|
+
if (opts.preimageOf && service.kind !== "systemd") return { ok: false, manual: true, reason: "Go back restores a systemd unit only" };
|
|
1807
|
+
let preimage;
|
|
1808
|
+
try {
|
|
1809
|
+
preimage = (0, import_node_fs9.readFileSync)(unitPreimagePath(home2, opts.preimageOf ?? attempt.id));
|
|
1810
|
+
} catch (err) {
|
|
1811
|
+
return { ok: false, manual: true, reason: `the unit's preimage can't be read (${err.message})` };
|
|
1812
|
+
}
|
|
1813
|
+
let want = preimage;
|
|
1814
|
+
if (service.kind === "launchd" && opts.keepRoute) {
|
|
1815
|
+
const original = opts.plistArgs(preimage.toString("utf8"));
|
|
1816
|
+
const wrapped = original ? wrapPlist(preimage.toString("utf8"), home2, attempt.id, original) : null;
|
|
1817
|
+
if (!wrapped) return { ok: false, manual: true, reason: "the job's original arguments can't be wrapped" };
|
|
1818
|
+
want = Buffer.from(wrapped);
|
|
1819
|
+
}
|
|
1820
|
+
try {
|
|
1821
|
+
if (!steps.done("unit-written")) {
|
|
1822
|
+
const tmp = `${service.fragmentPath}.restore-tmp`;
|
|
1823
|
+
(0, import_node_fs9.rmSync)(tmp, { force: true });
|
|
1824
|
+
let mode = 420;
|
|
1825
|
+
try {
|
|
1826
|
+
mode = (0, import_node_fs9.lstatSync)(service.fragmentPath).mode & 4095;
|
|
1827
|
+
} catch {
|
|
1828
|
+
}
|
|
1829
|
+
const fd = (0, import_node_fs9.openSync)(tmp, "wx", mode);
|
|
1830
|
+
try {
|
|
1831
|
+
(0, import_node_fs9.writeSync)(fd, want);
|
|
1832
|
+
(0, import_node_fs9.fsyncSync)(fd);
|
|
1833
|
+
} finally {
|
|
1834
|
+
(0, import_node_fs9.closeSync)(fd);
|
|
1835
|
+
}
|
|
1836
|
+
(0, import_node_fs9.renameSync)(tmp, service.fragmentPath);
|
|
1837
|
+
fsyncPath2((0, import_node_path10.dirname)(service.fragmentPath));
|
|
1838
|
+
steps.record("unit-written");
|
|
1839
|
+
}
|
|
1840
|
+
if (opts.keepRoute && service.kind === "systemd" && !steps.done("unit-route-kept")) {
|
|
1841
|
+
const path = dropInPath(service), want2 = dropInText(home2, attempt.id);
|
|
1842
|
+
let now = null;
|
|
1843
|
+
try {
|
|
1844
|
+
now = (0, import_node_fs9.readFileSync)(path, "utf8");
|
|
1845
|
+
} catch (err) {
|
|
1846
|
+
if (err.code !== "ENOENT") throw err;
|
|
1847
|
+
}
|
|
1848
|
+
if (now !== null && now !== want2) throw new Manual2(`${path} isn't this attempt's drop-in any more`);
|
|
1849
|
+
if (now === null) {
|
|
1850
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(path), { recursive: true, mode: 493 });
|
|
1851
|
+
const tmp = `${path}.restore-tmp`;
|
|
1852
|
+
(0, import_node_fs9.rmSync)(tmp, { force: true });
|
|
1853
|
+
const fd = (0, import_node_fs9.openSync)(tmp, "wx", 420);
|
|
1854
|
+
try {
|
|
1855
|
+
(0, import_node_fs9.writeSync)(fd, want2);
|
|
1856
|
+
(0, import_node_fs9.fsyncSync)(fd);
|
|
1857
|
+
} finally {
|
|
1858
|
+
(0, import_node_fs9.closeSync)(fd);
|
|
1859
|
+
}
|
|
1860
|
+
(0, import_node_fs9.renameSync)(tmp, path);
|
|
1861
|
+
fsyncPath2((0, import_node_path10.dirname)(path));
|
|
1862
|
+
fsyncPath2((0, import_node_path10.dirname)((0, import_node_path10.dirname)(path)));
|
|
1863
|
+
}
|
|
1864
|
+
steps.record("unit-route-kept");
|
|
1865
|
+
}
|
|
1866
|
+
if (!opts.keepRoute && service.kind === "systemd" && !steps.done("unit-route-removed")) {
|
|
1867
|
+
const removed = removeRecoveryRoute(home2, attempt, { plistArgs: opts.plistArgs });
|
|
1868
|
+
if (!removed.ok) throw new Manual2(removed.reason);
|
|
1869
|
+
steps.record("unit-route-removed");
|
|
1870
|
+
}
|
|
1871
|
+
if (!steps.done("unit-reloaded")) {
|
|
1872
|
+
if (!opts.reload()) return { ok: false, manual: false, reason: `the service manager couldn't reload ${(0, import_node_path10.basename)(service.fragmentPath)}; retry` };
|
|
1873
|
+
steps.record("unit-reloaded");
|
|
1874
|
+
}
|
|
1875
|
+
return { ok: true };
|
|
1876
|
+
} catch (err) {
|
|
1877
|
+
if (err instanceof Manual2) return { ok: false, manual: true, reason: err.message };
|
|
1878
|
+
throw err;
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
// src/update-recovery/kit.ts
|
|
1883
|
+
var import_node_crypto5 = require("node:crypto");
|
|
1884
|
+
var import_node_fs10 = require("node:fs");
|
|
1885
|
+
var import_node_child_process2 = require("node:child_process");
|
|
1886
|
+
var import_node_path11 = require("node:path");
|
|
1887
|
+
var KIT_FILE = "kit.json";
|
|
1888
|
+
var sha2562 = (data) => (0, import_node_crypto5.createHash)("sha256").update(data).digest("hex");
|
|
1889
|
+
function verifyRecoveryKit(home2, attemptId) {
|
|
1890
|
+
const dir = kitDir(home2, attemptId);
|
|
1891
|
+
let manifest;
|
|
1892
|
+
try {
|
|
1893
|
+
manifest = JSON.parse((0, import_node_fs10.readFileSync)((0, import_node_path11.join)(dir, KIT_FILE), "utf8"));
|
|
1894
|
+
} catch (err) {
|
|
1895
|
+
return { ok: false, reason: `the kit's manifest can't be read (${err.message})` };
|
|
1896
|
+
}
|
|
1897
|
+
if (typeof manifest !== "object" || manifest === null || Array.isArray(manifest)) return { ok: false, reason: "the kit's manifest isn't an object" };
|
|
1898
|
+
if (manifest.schema !== 1 || manifest.attemptId !== attemptId || manifest.home !== home2) return { ok: false, reason: "the kit's manifest names another attempt or home" };
|
|
1899
|
+
for (const [file, want] of [["node", manifest.node?.sha256], ["recover.cjs", manifest.recover?.sha256]]) {
|
|
1900
|
+
let got;
|
|
1901
|
+
try {
|
|
1902
|
+
got = sha2562((0, import_node_fs10.readFileSync)((0, import_node_path11.join)(dir, file)));
|
|
1903
|
+
} catch (err) {
|
|
1904
|
+
return { ok: false, reason: `the kit's ${file} can't be read (${err.message})` };
|
|
1905
|
+
}
|
|
1906
|
+
if (got !== want) return { ok: false, reason: `the kit's ${file} doesn't match its manifest` };
|
|
1907
|
+
}
|
|
1908
|
+
return { ok: true, dir, manifest };
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
// src/update-rollback.ts
|
|
1912
|
+
var import_node_fs11 = require("node:fs");
|
|
1913
|
+
var ROLLBACK_FROM = /* @__PURE__ */ new Set(["snapshotted", "installing", "trial", "proving"]);
|
|
1914
|
+
var generationsOf2 = (a) => Array.isArray(a.fleets) ? a.fleets : [];
|
|
1915
|
+
var didSubstep = (a, name) => a.history.some((h) => h.stage === "rolling-back" && h.substep === name);
|
|
1916
|
+
function ensureFence(home2, attempt, d) {
|
|
1917
|
+
let a = attempt;
|
|
1918
|
+
for (let round = 0; round < 3; round++) {
|
|
1919
|
+
const rec = readFleetLockRecord(home2);
|
|
1920
|
+
if (!rec) return { ok: false, reason: `fleet.lock is missing or unreadable in ${a.stage}`, attempt: a };
|
|
1921
|
+
if (rec.role === "update") {
|
|
1922
|
+
if (rec.attemptId !== a.id) return { ok: false, reason: `fleet.lock fences another attempt (${rec.attemptId})`, attempt: a };
|
|
1923
|
+
const adopted = adoptUpdateFence(home2, { pid: d.self.pid, attemptId: a.id }, { isProcessAlive: d.isProcessAlive });
|
|
1924
|
+
if (adopted.ok) return { ok: true, handle: adopted.handle, attempt: a };
|
|
1925
|
+
if (/changed during/.test(adopted.reason)) continue;
|
|
1926
|
+
return { ok: false, reason: adopted.reason, attempt: a };
|
|
1927
|
+
}
|
|
1928
|
+
let gen = generationsOf2(a).find((g) => g.nonce === rec.nonce);
|
|
1929
|
+
if (!gen) return { ok: false, reason: `fleet.lock's holder (pid ${rec.pid}) is no recorded generation`, attempt: a };
|
|
1930
|
+
if (!gen.consumed && !gen.dead) {
|
|
1931
|
+
a = ackGeneration(home2, a, gen.nonce, rec.pid, {}, d.io);
|
|
1932
|
+
gen = generationsOf2(a).find((g) => g.nonce === rec.nonce);
|
|
1933
|
+
}
|
|
1934
|
+
if (d.isProcessAlive(rec.pid)) {
|
|
1935
|
+
const target = stopTarget(a, { pid: rec.pid, nonce: rec.nonce }, d.manager.mainPid());
|
|
1936
|
+
if (!target.ok) return { ok: false, reason: target.reason, attempt: a };
|
|
1937
|
+
if (!d.manager.stop()) return { ok: false, reason: `the ${gen.gen} fleet (pid ${rec.pid}) didn't stop`, attempt: a };
|
|
1938
|
+
if (d.isProcessAlive(rec.pid)) return { ok: false, reason: `the ${gen.gen} fleet (pid ${rec.pid}) is still running after the stop`, attempt: a };
|
|
1939
|
+
}
|
|
1940
|
+
if (!gen.dead || gen.pid !== rec.pid) a = ackGeneration(home2, a, gen.nonce, rec.pid, { dead: true }, d.io);
|
|
1941
|
+
const retaken = retakeDeadFleetLock(home2, { pid: d.self.pid, attemptId: a.id, nonce: rec.nonce }, { isProcessAlive: d.isProcessAlive });
|
|
1942
|
+
if (retaken.ok) return { ok: true, handle: retaken.handle, attempt: a };
|
|
1943
|
+
if (!/changed during/.test(retaken.reason)) return { ok: false, reason: retaken.reason, attempt: a };
|
|
1944
|
+
}
|
|
1945
|
+
return { ok: false, reason: `fleet.lock kept changing in ${a.stage}`, attempt: a };
|
|
1946
|
+
}
|
|
1947
|
+
function startGeneration(home2, attempt, gen, fence, d) {
|
|
1948
|
+
const io = d.io ?? defaultJournalIo;
|
|
1949
|
+
let a = attempt;
|
|
1950
|
+
const fail = (reason, manual = true) => ({ ok: false, manual, reason, attempt: a });
|
|
1951
|
+
const id = identityOf(a);
|
|
1952
|
+
if (!id) return fail("the attempt's recorded ownership is missing or malformed");
|
|
1953
|
+
if (generationsOf2(a).some((g) => g.gen === gen && g.consumed && !g.dead)) return { ok: true, attempt: a };
|
|
1954
|
+
let handle = fence;
|
|
1955
|
+
const planned = generationsOf2(a).find((g) => !g.consumed && !g.dead);
|
|
1956
|
+
if (planned) {
|
|
1957
|
+
const taken = readFleetLockRecord(home2);
|
|
1958
|
+
if (taken?.role === "fleet" && taken.nonce === planned.nonce) {
|
|
1959
|
+
if (planned.gen !== gen) return fail(`the ${planned.gen} generation took fleet.lock over; the ${gen} generation can't start`);
|
|
1960
|
+
return { ok: true, attempt: ackGeneration(home2, a, planned.nonce, taken.pid, {}, io) };
|
|
1961
|
+
}
|
|
1962
|
+
const revoked = revokeHandoff(home2, a.id, planned.nonce, d.self, d.liveness, io);
|
|
1963
|
+
if (revoked === "claimed-live" || revoked === "claimant-unknown") return fail(`the ${planned.gen} generation's claim is held (${revoked})`);
|
|
1964
|
+
if (!handle) return fail(`fleet.lock holds no fence to hand the ${gen} generation over from`);
|
|
1965
|
+
if (handle.record.handoff) {
|
|
1966
|
+
const cleared = setFleetLockHandoff(handle, null, () => true);
|
|
1967
|
+
if (!cleared) return fail("fleet.lock changed while the old handoff was cleared");
|
|
1968
|
+
handle = cleared;
|
|
1969
|
+
}
|
|
1970
|
+
a = voidGeneration(home2, a, planned.nonce, io);
|
|
1971
|
+
}
|
|
1972
|
+
if (!handle) return fail(`no fence to hand the ${gen} generation over from`);
|
|
1973
|
+
const nonce = d.newNonce?.() ?? (0, import_node_crypto6.randomBytes)(16).toString("hex");
|
|
1974
|
+
a = planGeneration(home2, a, gen, nonce, io);
|
|
1975
|
+
if (id.ownership.service) {
|
|
1976
|
+
const kit = verifyRecoveryKit(home2, a.id);
|
|
1977
|
+
if (!kit.ok) return fail(`the ${gen} generation can't start through the recovery route: ${kit.reason}`);
|
|
1978
|
+
}
|
|
1979
|
+
const handed = setFleetLockHandoff(handle, { nonce, gen }, (attemptId, n) => {
|
|
1980
|
+
const r = revokeHandoff(home2, attemptId, n, d.self, d.liveness, io);
|
|
1981
|
+
return r === "revoked" || r === "claimant-gone";
|
|
1982
|
+
});
|
|
1983
|
+
if (!handed) return fail("fleet.lock isn't this attempt's fence any more");
|
|
1984
|
+
if (!d.manager.start({ nonce, gen })) return fail(`the service didn't start for the ${gen} generation; retry`, false);
|
|
1985
|
+
const pid = d.waitTakeover(nonce);
|
|
1986
|
+
if (pid === null) return fail(`the ${gen} generation didn't take fleet.lock over in time; retry`, false);
|
|
1987
|
+
return { ok: true, attempt: ackGeneration(home2, a, nonce, pid, {}, io) };
|
|
1988
|
+
}
|
|
1989
|
+
function rollBack(home2, attempt, d) {
|
|
1990
|
+
const io = d.io ?? defaultJournalIo;
|
|
1991
|
+
let a = attempt;
|
|
1992
|
+
const fail = (reason, manual = true) => ({ ok: false, manual, reason, attempt: a });
|
|
1993
|
+
const id = identityOf(a);
|
|
1994
|
+
if (!id) return fail("the attempt's recorded ownership is missing or malformed");
|
|
1995
|
+
if (a.stage !== "rolling-back") {
|
|
1996
|
+
if (!ROLLBACK_FROM.has(a.stage)) return fail(`attempt ${a.id} can't roll back from ${a.stage}`);
|
|
1997
|
+
a = advance(home2, a, "rolling-back", { note: "the update didn't prove itself" }, io);
|
|
1998
|
+
}
|
|
1999
|
+
const holder = readFleetLockRecord(home2);
|
|
2000
|
+
const rollbackHolds = holder?.role === "fleet" && generationsOf2(a).some((g) => g.gen === "rollback" && g.nonce === holder.nonce);
|
|
2001
|
+
let fenceHandle = null;
|
|
2002
|
+
if (!rollbackHolds) {
|
|
2003
|
+
const fence = ensureFence(home2, a, d);
|
|
2004
|
+
a = fence.attempt;
|
|
2005
|
+
if (!fence.ok) return fail(fence.reason);
|
|
2006
|
+
fenceHandle = fence.handle;
|
|
2007
|
+
}
|
|
2008
|
+
const steps = { done: (n) => didSubstep(a, n), record: (n) => {
|
|
2009
|
+
a = substep(home2, a, n, io);
|
|
2010
|
+
} };
|
|
2011
|
+
if (!steps.done("home-restored")) {
|
|
2012
|
+
const r = restoreHome(home2, attemptDir(home2, a.id), { proveWritersGone: d.proveWritersGone });
|
|
2013
|
+
if (!r.ok) return fail(r.reason, r.manual);
|
|
2014
|
+
steps.record("home-restored");
|
|
2015
|
+
}
|
|
2016
|
+
const intent = a.intent;
|
|
2017
|
+
if (intent?.preimage?.manifestSha256 && !steps.done("bins")) {
|
|
2018
|
+
const r = restorePackage(id.ownership, a.id, intent.preimage.manifestSha256, steps);
|
|
2019
|
+
if (!r.ok) return fail(r.reason, r.manual);
|
|
2020
|
+
}
|
|
2021
|
+
if (id.ownership.service && !(0, import_node_fs11.existsSync)(unitPreimagePath(home2, a.id))) {
|
|
2022
|
+
const kit = verifyRecoveryKit(home2, a.id);
|
|
2023
|
+
if (!kit.ok) return fail(`the recovery route can't be made: ${kit.reason}`);
|
|
2024
|
+
const route = writeRecoveryRoute(home2, a, { plistArgs: d.plistArgs }, io);
|
|
2025
|
+
if (!route.ok) return fail(route.reason);
|
|
2026
|
+
}
|
|
2027
|
+
if (id.ownership.service && !steps.done("unit-reloaded")) {
|
|
2028
|
+
const r = restoreUnit(home2, a, { keepRoute: true, plistArgs: d.plistArgs, reload: d.manager.reload }, steps);
|
|
2029
|
+
if (!r.ok) return fail(r.reason, r.manual);
|
|
2030
|
+
}
|
|
2031
|
+
const started = startGeneration(home2, a, "rollback", fenceHandle, d);
|
|
2032
|
+
a = started.attempt;
|
|
2033
|
+
if (!started.ok) return fail(started.reason, started.manual);
|
|
2034
|
+
if (id.ownership.service && !steps.done("route-removed")) {
|
|
2035
|
+
const removed = removeRecoveryRoute(home2, a, { plistArgs: d.plistArgs }, io);
|
|
2036
|
+
if (!removed.ok) return fail(removed.reason);
|
|
2037
|
+
if (!d.manager.reload()) return fail("the service manager couldn't reload after the route was taken off; retry", false);
|
|
2038
|
+
steps.record("route-removed");
|
|
2039
|
+
}
|
|
2040
|
+
a = finish(home2, a, { kind: "rolled-back", reason: "rolled back to the previous version" }, io);
|
|
2041
|
+
return { ok: true, attempt: a };
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
// src/update-abandon.ts
|
|
2045
|
+
var import_node_fs12 = require("node:fs");
|
|
2046
|
+
var generationsOf3 = (a) => Array.isArray(a.fleets) ? a.fleets : [];
|
|
2047
|
+
var didSubstep2 = (a, stage, name) => a.history.some((h) => h.stage === stage && h.substep === name);
|
|
2048
|
+
function abandonAttempt(home2, attempt, d, reason, fence = null) {
|
|
2049
|
+
const io = d.io ?? defaultJournalIo;
|
|
2050
|
+
let a = attempt;
|
|
2051
|
+
const fail = (why, isManual = true) => isManual ? journalManual(home2, a, why, io) : { ok: false, outcome: "retry", reason: why, attempt: a };
|
|
2052
|
+
const id = identityOf(a);
|
|
2053
|
+
if (!id) return journalManual(home2, a, "the attempt's recorded ownership is missing or malformed", io);
|
|
2054
|
+
if (a.stage !== "abandoning") a = advance(home2, a, "abandoning", { note: reason }, io);
|
|
2055
|
+
const done = (n) => didSubstep2(a, "abandoning", n);
|
|
2056
|
+
if (!done("hand-back")) {
|
|
2057
|
+
const holder = readFleetLockRecord(home2);
|
|
2058
|
+
const old = generationsOf3(a).find((g) => g.gen === "old");
|
|
2059
|
+
if (holder?.role === "fleet" && d.isProcessAlive(holder.pid)) {
|
|
2060
|
+
const gen = generationsOf3(a).find((g) => g.nonce === holder.nonce && !g.dead);
|
|
2061
|
+
if (!gen || gen.gen !== "old") return fail(`fleet.lock's holder (pid ${holder.pid}) isn't the running old fleet`);
|
|
2062
|
+
if (!gen.consumed) a = startGeneration(home2, a, "old", null, d).attempt;
|
|
2063
|
+
} else if (holder) {
|
|
2064
|
+
if (holder.role === "update" && holder.attemptId !== a.id) return fail(`fleet.lock fences another attempt (${holder.attemptId})`);
|
|
2065
|
+
let own = fence;
|
|
2066
|
+
if (!own) {
|
|
2067
|
+
const f = ensureFence(home2, a, d);
|
|
2068
|
+
a = f.attempt;
|
|
2069
|
+
if (!f.ok) return fail(`this attempt's fence can't be held to restart the old fleet: ${f.reason}`);
|
|
2070
|
+
own = f.handle;
|
|
2071
|
+
}
|
|
2072
|
+
if (old) {
|
|
2073
|
+
const started = startGeneration(home2, a, "old", own, d);
|
|
2074
|
+
a = started.attempt;
|
|
2075
|
+
if (!started.ok) return fail(`the old fleet didn't restart: ${started.reason}`, started.manual);
|
|
2076
|
+
} else {
|
|
2077
|
+
const clear = own.record.handoff ? setFleetLockHandoff(own, null, () => true) : own;
|
|
2078
|
+
if (!clear || !releaseFleetLock(clear)) return fail("this attempt's fence couldn't be released");
|
|
2079
|
+
}
|
|
2080
|
+
} else if (old) {
|
|
2081
|
+
const last = [...generationsOf3(a)].reverse().find((g) => g.gen === "old" && g.consumed && !g.dead);
|
|
2082
|
+
if (last?.pid !== void 0) {
|
|
2083
|
+
if (d.isProcessAlive(last.pid)) return fail(`the old fleet (pid ${last.pid}) runs without holding fleet.lock`);
|
|
2084
|
+
a = ackGeneration(home2, a, last.nonce, last.pid, { dead: true }, io);
|
|
2085
|
+
}
|
|
2086
|
+
const created = createUpdateFence(home2, { pid: d.self.pid, attemptId: a.id });
|
|
2087
|
+
if (!created.ok) return fail(`fleet.lock can't be taken as this attempt's fence (${created.reason})`, false);
|
|
2088
|
+
const started = startGeneration(home2, a, "old", created.handle, d);
|
|
2089
|
+
a = started.attempt;
|
|
2090
|
+
if (!started.ok) return fail(`the old fleet didn't restart: ${started.reason}`, started.manual);
|
|
2091
|
+
}
|
|
2092
|
+
if (!done("restart-old")) a = substep(home2, a, "restart-old", io);
|
|
2093
|
+
if (!d.handBack(a)) return fail("the old fleet didn't take the held messages and jobs back; it resumes on the next start", false);
|
|
2094
|
+
a = substep(home2, a, "hand-back", io);
|
|
2095
|
+
}
|
|
2096
|
+
if (id.ownership.service && !done("route-removed") && (0, import_node_fs12.existsSync)(unitPreimagePath(home2, a.id))) {
|
|
2097
|
+
const r = removeRecoveryRoute(home2, a, { plistArgs: d.plistArgs }, io);
|
|
2098
|
+
if (!r.ok) return fail(r.reason);
|
|
2099
|
+
if (!d.manager.reload()) return fail("the service manager couldn't reload after the route was taken off", false);
|
|
2100
|
+
a = substep(home2, a, "route-removed", io);
|
|
2101
|
+
}
|
|
2102
|
+
a = finish(home2, a, { kind: "abandoned", reason }, io);
|
|
2103
|
+
return { ok: false, outcome: "abandoned", reason, attempt: a };
|
|
2104
|
+
}
|
|
2105
|
+
function journalManual(home2, attempt, reason, io) {
|
|
2106
|
+
const a = finish(home2, attempt, { kind: "manual-recovery", reason }, io);
|
|
2107
|
+
return { ok: false, outcome: "manual", reason, attempt: a };
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
// src/plist-args.ts
|
|
2111
|
+
var xmlUnescape = (text) => text.replace(/&(?:#(\d+)|#x([0-9a-fA-F]+)|(lt|gt|quot|apos|amp));/g, (whole, dec, hex, name) => {
|
|
2112
|
+
if (dec !== void 0 || hex !== void 0) {
|
|
2113
|
+
const code = dec !== void 0 ? Number.parseInt(dec, 10) : Number.parseInt(hex, 16);
|
|
2114
|
+
return code <= 1114111 ? String.fromCodePoint(code) : whole;
|
|
2115
|
+
}
|
|
2116
|
+
return { lt: "<", gt: ">", quot: '"', apos: "'", amp: "&" }[name];
|
|
2117
|
+
});
|
|
2118
|
+
function plistProgramArguments(xml) {
|
|
2119
|
+
const args = /<key>ProgramArguments<\/key>\s*<array>([\s\S]*?)<\/array>/.exec(xml);
|
|
2120
|
+
if (!args) return null;
|
|
2121
|
+
const argv = [...args[1].matchAll(/<string>([\s\S]*?)<\/string>/g)].map((m) => xmlUnescape(m[1]));
|
|
2122
|
+
return argv.length ? argv : null;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
// src/update-recovery/runner.ts
|
|
2126
|
+
var SERVICE_LOCK_FILE = ".service.lock";
|
|
2127
|
+
function handedBack(home2, attemptId, io) {
|
|
2128
|
+
try {
|
|
2129
|
+
return listHandback(home2, attemptId, io).every((e) => handbackAction(e) === "skip");
|
|
2130
|
+
} catch {
|
|
2131
|
+
return false;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
var startOf2 = (pid, d) => {
|
|
2135
|
+
const processStart2 = d.lock.processStart(pid);
|
|
2136
|
+
if (!processStart2) return null;
|
|
2137
|
+
const ticks = d.lock.startTicks?.(pid) ?? null, boot = d.lock.bootId?.() ?? null;
|
|
2138
|
+
return { processStart: processStart2, ...ticks !== null && boot !== null ? { startTicks: ticks, bootId: boot } : {} };
|
|
2139
|
+
};
|
|
2140
|
+
function evidence(home2, attemptId, d) {
|
|
2141
|
+
const read = readCurrent(home2, d.io);
|
|
2142
|
+
if (read.state === "none") return { ok: false, done: true, words: "No AgEnD update attempt is open; there is nothing to recover." };
|
|
2143
|
+
if (read.state === "unknown") return { ok: false, done: false, words: `the update journal can't be read (${read.reason}: ${read.path}). Run \`agend update --resolve\`.` };
|
|
2144
|
+
if (read.attempt.id !== attemptId) return { ok: false, done: false, words: `the journal's attempt is ${read.attempt.id}, not this kit's.` };
|
|
2145
|
+
if (read.state === "manual") return { ok: false, done: false, words: "it needs manual recovery. Run `agend update --resolve`." };
|
|
2146
|
+
if (read.state === "open") {
|
|
2147
|
+
const updater = updaterState(read.attempt, d.liveness);
|
|
2148
|
+
if (updater === "live") return { ok: false, done: false, words: "its updater is still running; the update owns it until it ends." };
|
|
2149
|
+
if (updater === "unknown") return { ok: false, done: false, words: "whether its updater still runs can't be told; nothing is taken over." };
|
|
2150
|
+
}
|
|
2151
|
+
const runner = readRunnerRecord(home2, attemptId, d.io);
|
|
2152
|
+
if (runner === "unreadable") return { ok: false, done: false, words: "its recovery runner's record can't be read." };
|
|
2153
|
+
if (runner !== null && runner.pid !== d.pid) {
|
|
2154
|
+
const s = holderState({ pid: runner.pid, ...runner.start }, d.liveness);
|
|
2155
|
+
if (s !== "stale") return { ok: false, done: false, words: s === "live" ? `another recovery runner (pid ${runner.pid}) is acting for it.` : `whether its recovery runner (pid ${runner.pid}) still runs can't be told.` };
|
|
2156
|
+
}
|
|
2157
|
+
const prefix = identityOf(read.attempt)?.ownership.prefix;
|
|
2158
|
+
if (!prefix) return { ok: false, done: false, words: "its recorded ownership (the npm prefix) is missing or malformed, so the prefix lock can't be taken." };
|
|
2159
|
+
return { ok: true, read, prefix };
|
|
2160
|
+
}
|
|
2161
|
+
function runRecovery(home2, attemptId, d) {
|
|
2162
|
+
const refuse = (why) => {
|
|
2163
|
+
d.err(`AgEnD's update recovery for attempt ${attemptId} is refused: ${why}`);
|
|
2164
|
+
return 1;
|
|
2165
|
+
};
|
|
2166
|
+
const first = evidence(home2, attemptId, d);
|
|
2167
|
+
if (!first.ok) {
|
|
2168
|
+
if (first.done) {
|
|
2169
|
+
d.out(first.words);
|
|
2170
|
+
return 0;
|
|
2171
|
+
}
|
|
2172
|
+
return refuse(first.words);
|
|
2173
|
+
}
|
|
2174
|
+
const held = [];
|
|
2175
|
+
const releaseAll = () => {
|
|
2176
|
+
for (const l of held.reverse()) if (l.ok) l.release();
|
|
2177
|
+
};
|
|
2178
|
+
const lockDeps = { ...d.lock, pid: d.pid };
|
|
2179
|
+
const locks = [
|
|
2180
|
+
[home2, `recover:${attemptId}`, { file: HOME_UPDATE_LOCK_FILE, name: "home update lock" }],
|
|
2181
|
+
[first.prefix, `recover:${attemptId}`, {}],
|
|
2182
|
+
[home2, `attempt:${attemptId}`, { file: SERVICE_LOCK_FILE, name: "service lock" }]
|
|
2183
|
+
];
|
|
2184
|
+
for (const [dir, spec, opts] of locks) {
|
|
2185
|
+
const taken = acquireInstallLock(dir, { spec, agendHome: home2 }, lockDeps, opts);
|
|
2186
|
+
if (!taken.ok) {
|
|
2187
|
+
releaseAll();
|
|
2188
|
+
return refuse(taken.reason);
|
|
2189
|
+
}
|
|
2190
|
+
held.push(taken);
|
|
2191
|
+
}
|
|
2192
|
+
try {
|
|
2193
|
+
const now = evidence(home2, attemptId, d);
|
|
2194
|
+
if (!now.ok) {
|
|
2195
|
+
if (now.done) {
|
|
2196
|
+
d.out(`The attempt was closed meanwhile. ${now.words}`);
|
|
2197
|
+
return 0;
|
|
2198
|
+
}
|
|
2199
|
+
return refuse(`${now.words} (found again under the locks)`);
|
|
2200
|
+
}
|
|
2201
|
+
if (now.prefix !== first.prefix) return refuse(`its recorded npm prefix changed while the locks were taken (${first.prefix} \u2192 ${now.prefix}).`);
|
|
2202
|
+
const start = startOf2(d.pid, d);
|
|
2203
|
+
if (!start) return refuse("this process's own start time can't be read, so it can't record itself.");
|
|
2204
|
+
writeRunnerRecord(home2, attemptId, { pid: d.pid, start }, d.io);
|
|
2205
|
+
const read = now.read;
|
|
2206
|
+
const plan = recoveryPlan(read, "gone");
|
|
2207
|
+
switch (plan.kind) {
|
|
2208
|
+
case "finish-closing":
|
|
2209
|
+
finishClosing(home2, read.attempt, d.io);
|
|
2210
|
+
d.out(`AgEnD update attempt ${attemptId} (${read.attempt.stage}) is closed.`);
|
|
2211
|
+
return 0;
|
|
2212
|
+
case "start":
|
|
2213
|
+
return 0;
|
|
2214
|
+
case "refuse":
|
|
2215
|
+
return refuse(plan.reason === "manual" ? "it needs manual recovery. Run `agend update --resolve`." : `the journal reads ${plan.reason}.`);
|
|
2216
|
+
case "resume-abandoning": {
|
|
2217
|
+
const service = identityOf(read.attempt)?.ownership.service ?? null;
|
|
2218
|
+
if (!d.hands) return refuse("this kit can't drive an abandon (no service manager given).");
|
|
2219
|
+
if (!service) return refuse("the attempt records no service to restart the previous version through; start it yourself, then run `agend update --resolve`.");
|
|
2220
|
+
const manager = d.hands.manager(service);
|
|
2221
|
+
if (!manager.waitSettled()) return refuse("the service's refused start hasn't settled; run the recovery again.");
|
|
2222
|
+
const hands = d.hands;
|
|
2223
|
+
const res = abandonAttempt(home2, read.attempt, {
|
|
2224
|
+
self: { pid: d.pid, start },
|
|
2225
|
+
liveness: d.liveness,
|
|
2226
|
+
isProcessAlive: (pid) => (d.liveness.exists ?? (() => true))(pid),
|
|
2227
|
+
plistArgs: plistProgramArguments,
|
|
2228
|
+
manager,
|
|
2229
|
+
waitTakeover: (nonce) => hands.waitTakeover(nonce),
|
|
2230
|
+
io: d.io,
|
|
2231
|
+
handBack: (a) => hands.waitHandedBack(() => handedBack(home2, a.id, d.io))
|
|
2232
|
+
}, "the update stopped before its snapshot was taken");
|
|
2233
|
+
if (res.ok === false && res.outcome === "abandoned") {
|
|
2234
|
+
d.out(`AgEnD update attempt ${attemptId} is abandoned; the previous version runs again.`);
|
|
2235
|
+
return 0;
|
|
2236
|
+
}
|
|
2237
|
+
const why = res.ok ? "" : res.reason;
|
|
2238
|
+
return refuse(`${why}${!res.ok && res.outcome === "manual" ? " Run `agend update --resolve`." : " Run the recovery again."}`);
|
|
2239
|
+
}
|
|
2240
|
+
case "resume-rolling-back": {
|
|
2241
|
+
const service = identityOf(read.attempt)?.ownership.service ?? null;
|
|
2242
|
+
if (!d.hands) return refuse("this kit can't drive a rollback (no service manager given).");
|
|
2243
|
+
if (!service) return refuse("the attempt records no service to roll back through; start the previous version yourself, then run `agend update --resolve`.");
|
|
2244
|
+
const manager = d.hands.manager(service);
|
|
2245
|
+
if (!manager.waitSettled()) return refuse("the service's refused start hasn't settled; run the recovery again.");
|
|
2246
|
+
const self = { pid: d.pid, start };
|
|
2247
|
+
const res = rollBack(home2, read.attempt, {
|
|
2248
|
+
self,
|
|
2249
|
+
liveness: d.liveness,
|
|
2250
|
+
isProcessAlive: (pid) => (d.liveness.exists ?? (() => true))(pid),
|
|
2251
|
+
proveWritersGone: () => d.hands.proveWritersGone({ updater: read.attempt.updater, runner: self, helpers: [] }),
|
|
2252
|
+
plistArgs: plistProgramArguments,
|
|
2253
|
+
manager,
|
|
2254
|
+
waitTakeover: (nonce) => d.hands.waitTakeover(nonce),
|
|
2255
|
+
io: d.io
|
|
2256
|
+
});
|
|
2257
|
+
if (res.ok) {
|
|
2258
|
+
d.out(`AgEnD update attempt ${attemptId} is rolled back; the previous version runs again.`);
|
|
2259
|
+
return 0;
|
|
2260
|
+
}
|
|
2261
|
+
return refuse(`${res.reason}${res.manual ? " Run `agend update --resolve`." : " Run the recovery again."}`);
|
|
2262
|
+
}
|
|
2263
|
+
case "resume-committing":
|
|
2264
|
+
return refuse(`it is committing ${read.attempt.to.version}, which only the new version's own fleet start finishes, never this recovery kit. Nothing was changed; if the fleet's start can't finish it, run \`agend update --resolve\`.`);
|
|
2265
|
+
}
|
|
2266
|
+
} finally {
|
|
2267
|
+
releaseAll();
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
function runnerLaunchCommand(home2, attempt, uid) {
|
|
2271
|
+
const service = identityOf(attempt)?.ownership.service;
|
|
2272
|
+
if (!service) return null;
|
|
2273
|
+
const kit = kitDir(home2, attempt.id);
|
|
2274
|
+
const runner = [(0, import_node_path12.join)(kit, "node"), (0, import_node_path12.join)(kit, "recover.cjs"), "--home", home2, "--attempt", attempt.id, "--run"];
|
|
2275
|
+
if (service.kind === "systemd") {
|
|
2276
|
+
return { command: "systemd-run", args: [...uid !== 0 ? ["--user"] : [], `--unit=agend-update-recovery-${attempt.id}`, "--collect", "--property=KillMode=process", ...runner] };
|
|
2277
|
+
}
|
|
2278
|
+
return { command: "launchctl", args: ["submit", "-l", `com.agend.update-recovery.${attempt.id}`, "--", ...runner] };
|
|
2279
|
+
}
|
|
2280
|
+
function launchRunner(home2, attempt, d, waitMs = 1e4) {
|
|
2281
|
+
const cmd = runnerLaunchCommand(home2, attempt, d.uid());
|
|
2282
|
+
const manual = `run ${operatorCommand(home2, attempt.id)}`;
|
|
2283
|
+
if (!cmd) return { started: false, reason: `the attempt has no recorded service to start a runner beside; ${manual}` };
|
|
2284
|
+
const status = d.run(cmd.command, cmd.args);
|
|
2285
|
+
if (status !== 0) return { started: false, reason: `${cmd.command} couldn't start the recovery runner (${status === null ? "not run" : `exit ${status}`}); ${manual}` };
|
|
2286
|
+
const until = d.now() + waitMs;
|
|
2287
|
+
for (; ; ) {
|
|
2288
|
+
const r = readRunnerRecord(home2, attempt.id, d.io);
|
|
2289
|
+
if (r !== null && r !== "unreadable" && holderState({ pid: r.pid, ...r.start }, d.liveness) === "live") return { started: true, pid: r.pid };
|
|
2290
|
+
if (d.now() >= until) return { started: false, reason: `the recovery runner didn't answer within ${Math.round(waitMs / 1e3)} s; ${manual}` };
|
|
2291
|
+
d.sleep(200);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
// src/update-recovery/service-manager.ts
|
|
2296
|
+
var SETTLE_MS = 3e4;
|
|
2297
|
+
var POLL_MS = 250;
|
|
2298
|
+
function serviceManager(service, d) {
|
|
2299
|
+
const poll = (ok, timeoutMs) => {
|
|
2300
|
+
const until = d.now() + timeoutMs;
|
|
2301
|
+
for (; ; ) {
|
|
2302
|
+
if (ok()) return true;
|
|
2303
|
+
if (d.now() >= until) return false;
|
|
2304
|
+
d.sleep(POLL_MS);
|
|
2305
|
+
}
|
|
2306
|
+
};
|
|
2307
|
+
if (service.kind === "systemd") {
|
|
2308
|
+
const sc = (...args) => d.run("systemctl", [...d.uid !== 0 ? ["--user"] : [], ...args]);
|
|
2309
|
+
const state = () => sc("is-active", service.unit).stdout.trim();
|
|
2310
|
+
return {
|
|
2311
|
+
mainPid: () => {
|
|
2312
|
+
const r = sc("show", "-p", "MainPID", "--value", service.unit);
|
|
2313
|
+
const pid = Number(r.stdout.trim());
|
|
2314
|
+
return r.status === 0 && Number.isSafeInteger(pid) && pid > 0 ? pid : null;
|
|
2315
|
+
},
|
|
2316
|
+
stop: () => sc("stop", service.unit).status === 0 && poll(() => ["inactive", "failed"].includes(state()), SETTLE_MS),
|
|
2317
|
+
reload: () => sc("daemon-reload").status === 0,
|
|
2318
|
+
start: () => {
|
|
2319
|
+
sc("reset-failed", service.unit);
|
|
2320
|
+
return sc("start", "--no-block", service.unit).status === 0;
|
|
2321
|
+
},
|
|
2322
|
+
waitSettled: (timeoutMs = SETTLE_MS) => poll(() => !["activating", "deactivating", "reloading"].includes(state()), timeoutMs)
|
|
2323
|
+
};
|
|
2324
|
+
}
|
|
2325
|
+
const target = `gui/${d.uid}/${service.unit}`;
|
|
2326
|
+
const printed = () => d.run("launchctl", ["print", target]);
|
|
2327
|
+
const pidOf = (text) => {
|
|
2328
|
+
const m = /^\s*pid = (\d+)\s*$/m.exec(text);
|
|
2329
|
+
return m ? Number(m[1]) : null;
|
|
2330
|
+
};
|
|
2331
|
+
return {
|
|
2332
|
+
mainPid: () => {
|
|
2333
|
+
const r = printed();
|
|
2334
|
+
return r.status === 0 ? pidOf(r.stdout) : null;
|
|
2335
|
+
},
|
|
2336
|
+
stop: () => {
|
|
2337
|
+
const r = d.run("launchctl", ["bootout", target]);
|
|
2338
|
+
if (r.status !== 0 && printed().status === 0) return false;
|
|
2339
|
+
return poll(() => printed().status !== 0, SETTLE_MS);
|
|
2340
|
+
},
|
|
2341
|
+
reload: () => true,
|
|
2342
|
+
start: () => {
|
|
2343
|
+
const loaded = printed();
|
|
2344
|
+
if (loaded.status === 0) {
|
|
2345
|
+
if (pidOf(loaded.stdout) !== null) return false;
|
|
2346
|
+
const out = d.run("launchctl", ["bootout", target]);
|
|
2347
|
+
if (out.status !== 0 && printed().status === 0) return false;
|
|
2348
|
+
if (!poll(() => printed().status !== 0, SETTLE_MS)) return false;
|
|
2349
|
+
}
|
|
2350
|
+
if (d.run("launchctl", ["bootstrap", `gui/${d.uid}`, service.fragmentPath]).status !== 0) return false;
|
|
2351
|
+
return d.run("launchctl", ["kickstart", target]).status === 0;
|
|
2352
|
+
},
|
|
2353
|
+
waitSettled: (timeoutMs = SETTLE_MS) => poll(() => {
|
|
2354
|
+
const r = printed();
|
|
2355
|
+
return r.status !== 0 || !/^\s*state = (spawn scheduled|xpcproxy)\s*$/m.test(r.stdout);
|
|
2356
|
+
}, timeoutMs)
|
|
2357
|
+
};
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
// src/update-writers.ts
|
|
2361
|
+
var import_node_fs13 = require("node:fs");
|
|
2362
|
+
var import_node_path13 = require("node:path");
|
|
2363
|
+
var isUnder = (path, root) => path === root || path.startsWith(root + import_node_path13.sep);
|
|
2364
|
+
function capsExceed(targetStatus, readerStatus) {
|
|
2365
|
+
const caps = (text) => BigInt(`0x${/^CapPrm:\s+([0-9a-f]+)/m.exec(text)?.[1] ?? "0"}`);
|
|
2366
|
+
return (caps(targetStatus) & ~caps(readerStatus)) !== 0n;
|
|
2367
|
+
}
|
|
2368
|
+
var UNREADABLE_RETRIES = 5;
|
|
2369
|
+
var UNREADABLE_BACKOFF_MS = 20;
|
|
2370
|
+
function proveWritersGone(home2, exempt, d) {
|
|
2371
|
+
if (d.platform !== "linux") return { ok: false, incomplete: true, reason: `no writers scan exists on ${d.platform} yet` };
|
|
2372
|
+
let root;
|
|
2373
|
+
try {
|
|
2374
|
+
root = (0, import_node_fs13.realpathSync)(home2);
|
|
2375
|
+
} catch (err) {
|
|
2376
|
+
return { ok: false, incomplete: true, reason: `the home can't be resolved (${err.message})` };
|
|
2377
|
+
}
|
|
2378
|
+
const pids = d.listPids();
|
|
2379
|
+
if (!pids) return { ok: false, incomplete: true, reason: "the process list can't be read" };
|
|
2380
|
+
const isExact = (pid, who) => !!who && who.pid === pid && d.sameProcess(pid, who.start);
|
|
2381
|
+
const owners = [exempt.updater, ...exempt.runner ? [exempt.runner] : []];
|
|
2382
|
+
const isHelper = (pid) => {
|
|
2383
|
+
const helper = exempt.helpers.find((h) => h.pid === pid);
|
|
2384
|
+
if (!helper || !d.sameProcess(pid, helper.start)) return false;
|
|
2385
|
+
let cur = pid;
|
|
2386
|
+
for (let hops = 0; hops < 64 && typeof cur === "number" && cur > 1; hops++) {
|
|
2387
|
+
const parent = d.ppidOf(cur);
|
|
2388
|
+
if (typeof parent !== "number") return false;
|
|
2389
|
+
if (owners.some((o) => isExact(parent, o))) return true;
|
|
2390
|
+
const step = exempt.helpers.find((h) => h.pid === parent);
|
|
2391
|
+
if (!step || !d.sameProcess(parent, step.start)) return false;
|
|
2392
|
+
cur = parent;
|
|
2393
|
+
}
|
|
2394
|
+
return false;
|
|
2395
|
+
};
|
|
2396
|
+
const writers = [];
|
|
2397
|
+
const uninspectable = [];
|
|
2398
|
+
const look = (pid) => {
|
|
2399
|
+
const uid = d.uidOf(pid);
|
|
2400
|
+
if (uid === "gone") return { kind: "skip" };
|
|
2401
|
+
if (uid === null) return { kind: "unreadable", what: "owner" };
|
|
2402
|
+
if (uid !== d.uid) return { kind: "skip" };
|
|
2403
|
+
if (owners.some((o) => isExact(pid, o)) || isHelper(pid)) return { kind: "skip" };
|
|
2404
|
+
const sealed = d.sealed(pid);
|
|
2405
|
+
if (sealed) return { kind: "uninspectable", why: sealed };
|
|
2406
|
+
const env = d.agendHomeOf(pid), cwd = d.cwdOf(pid), files = d.filesOf(pid);
|
|
2407
|
+
if (env === "gone" || cwd === "gone" || files === "gone") return { kind: "skip" };
|
|
2408
|
+
if (env === null || cwd === null || files === null) return { kind: "unreadable", what: env === null ? "environment" : cwd === null ? "working directory" : "open files" };
|
|
2409
|
+
return { kind: "read", env, cwd, files };
|
|
2410
|
+
};
|
|
2411
|
+
for (const pid of pids) {
|
|
2412
|
+
let r = look(pid);
|
|
2413
|
+
let seen = r.kind === "unreadable" ? d.startOf(pid) : null;
|
|
2414
|
+
for (let tries = 0, renewals = 0; r.kind === "unreadable" && tries < UNREADABLE_RETRIES; tries++) {
|
|
2415
|
+
d.sleep(UNREADABLE_BACKOFF_MS);
|
|
2416
|
+
const start = d.startOf(pid);
|
|
2417
|
+
if (start && seen && !d.sameProcess(pid, seen) && renewals < 3) {
|
|
2418
|
+
seen = start;
|
|
2419
|
+
tries = -1;
|
|
2420
|
+
renewals++;
|
|
2421
|
+
} else if (!seen) seen = start;
|
|
2422
|
+
r = look(pid);
|
|
2423
|
+
}
|
|
2424
|
+
if (r.kind === "skip") continue;
|
|
2425
|
+
if (r.kind === "uninspectable") {
|
|
2426
|
+
uninspectable.push({ pid, name: d.nameOf?.(pid) ?? null, why: r.why });
|
|
2427
|
+
continue;
|
|
2428
|
+
}
|
|
2429
|
+
if (r.kind === "unreadable") {
|
|
2430
|
+
const name = d.nameOf?.(pid);
|
|
2431
|
+
return { ok: false, incomplete: true, reason: `pid ${pid}${name ? ` (${name})` : ""}, this user's, stays unreadable (its ${r.what}) through ${UNREADABLE_RETRIES} re-reads` };
|
|
2432
|
+
}
|
|
2433
|
+
const { env, cwd, files } = r;
|
|
2434
|
+
const real = (p) => {
|
|
2435
|
+
try {
|
|
2436
|
+
return (0, import_node_fs13.realpathSync)(p);
|
|
2437
|
+
} catch {
|
|
2438
|
+
return p;
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2441
|
+
if (env !== void 0 && real(env) === root) {
|
|
2442
|
+
writers.push({ pid, why: `its AGEND_HOME is this home` });
|
|
2443
|
+
continue;
|
|
2444
|
+
}
|
|
2445
|
+
if (isUnder(real(cwd), root)) {
|
|
2446
|
+
writers.push({ pid, why: `its working directory is under the home (${cwd})` });
|
|
2447
|
+
continue;
|
|
2448
|
+
}
|
|
2449
|
+
const scoped = files.find((f) => {
|
|
2450
|
+
if (!isUnder(f, root) || f === root) return false;
|
|
2451
|
+
const rel = f.slice(root.length + 1).split(import_node_path13.sep).join("/");
|
|
2452
|
+
try {
|
|
2453
|
+
return classify(rel).included;
|
|
2454
|
+
} catch {
|
|
2455
|
+
return false;
|
|
2456
|
+
}
|
|
2457
|
+
});
|
|
2458
|
+
if (scoped) writers.push({ pid, why: `it has ${scoped} open or mapped` });
|
|
2459
|
+
}
|
|
2460
|
+
return writers.length ? { ok: false, incomplete: false, writers, reason: writers.map((w) => `pid ${w.pid}: ${w.why}`).join("; ") } : { ok: true, ...uninspectable.length ? { uninspectable } : {} };
|
|
2461
|
+
}
|
|
2462
|
+
function procWritersDeps(sameProcess, startOf3) {
|
|
2463
|
+
const gone = (err) => ["ENOENT", "ESRCH"].includes(err.code ?? "");
|
|
2464
|
+
const read = (fn) => {
|
|
2465
|
+
try {
|
|
2466
|
+
return fn();
|
|
2467
|
+
} catch (err) {
|
|
2468
|
+
return gone(err) ? "gone" : null;
|
|
2469
|
+
}
|
|
2470
|
+
};
|
|
2471
|
+
return {
|
|
2472
|
+
listPids: () => {
|
|
2473
|
+
try {
|
|
2474
|
+
return (0, import_node_fs13.readdirSync)("/proc").filter((n) => /^\d+$/.test(n)).map(Number);
|
|
2475
|
+
} catch {
|
|
2476
|
+
return null;
|
|
2477
|
+
}
|
|
2478
|
+
},
|
|
2479
|
+
uidOf: (pid) => read(() => (0, import_node_fs13.statSync)(`/proc/${pid}`).uid),
|
|
2480
|
+
agendHomeOf: (pid) => read(() => {
|
|
2481
|
+
const env = (0, import_node_fs13.readFileSync)(`/proc/${pid}/environ`, "latin1").split("\0").find((e) => e.startsWith("AGEND_HOME="));
|
|
2482
|
+
return env === void 0 ? void 0 : env.slice("AGEND_HOME=".length);
|
|
2483
|
+
}),
|
|
2484
|
+
cwdOf: (pid) => read(() => (0, import_node_fs13.readlinkSync)(`/proc/${pid}/cwd`)),
|
|
2485
|
+
filesOf: (pid) => read(() => {
|
|
2486
|
+
const out = [];
|
|
2487
|
+
for (const fd of (0, import_node_fs13.readdirSync)(`/proc/${pid}/fd`)) {
|
|
2488
|
+
try {
|
|
2489
|
+
const t = (0, import_node_fs13.readlinkSync)((0, import_node_path13.join)(`/proc/${pid}/fd`, fd));
|
|
2490
|
+
if (t.startsWith("/")) out.push(t.replace(/ \(deleted\)$/, ""));
|
|
2491
|
+
} catch (err) {
|
|
2492
|
+
if (!gone(err)) throw err;
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
for (const line of (0, import_node_fs13.readFileSync)(`/proc/${pid}/maps`, "utf8").split("\n")) {
|
|
2496
|
+
const at = line.indexOf("/");
|
|
2497
|
+
if (at >= 0) out.push(line.slice(at).replace(/ \(deleted\)$/, ""));
|
|
2498
|
+
}
|
|
2499
|
+
return out;
|
|
2500
|
+
}),
|
|
2501
|
+
ppidOf: (pid) => read(() => {
|
|
2502
|
+
const stat = (0, import_node_fs13.readFileSync)(`/proc/${pid}/stat`, "utf8");
|
|
2503
|
+
return Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1]);
|
|
2504
|
+
}),
|
|
2505
|
+
startOf: (pid) => {
|
|
2506
|
+
const t = startOf3(pid);
|
|
2507
|
+
return t ? { processStart: t } : null;
|
|
2508
|
+
},
|
|
2509
|
+
sleep: (ms) => {
|
|
2510
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
2511
|
+
},
|
|
2512
|
+
sealed: (pid) => {
|
|
2513
|
+
try {
|
|
2514
|
+
const status = (0, import_node_fs13.readFileSync)(`/proc/${pid}/status`, "utf8");
|
|
2515
|
+
const real = /^Uid:\s+(\d+)/m.exec(status)?.[1];
|
|
2516
|
+
if (real === void 0 || Number(real) === 0) return false;
|
|
2517
|
+
if ((0, import_node_fs13.statSync)(`/proc/${pid}/fd`).uid === 0) return "non-dumpable";
|
|
2518
|
+
return capsExceed(status, (0, import_node_fs13.readFileSync)("/proc/self/status", "utf8")) ? "privileged" : false;
|
|
2519
|
+
} catch {
|
|
2520
|
+
return false;
|
|
2521
|
+
}
|
|
2522
|
+
},
|
|
2523
|
+
nameOf: (pid) => {
|
|
2524
|
+
try {
|
|
2525
|
+
return /^Name:\s+(.*)$/m.exec((0, import_node_fs13.readFileSync)(`/proc/${pid}/status`, "utf8"))?.[1] ?? null;
|
|
2526
|
+
} catch {
|
|
2527
|
+
return null;
|
|
2528
|
+
}
|
|
2529
|
+
},
|
|
2530
|
+
sameProcess,
|
|
2531
|
+
uid: typeof process.getuid === "function" ? process.getuid() : -1,
|
|
2532
|
+
platform: process.platform
|
|
2533
|
+
};
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
// src/update-recovery/recover.ts
|
|
2537
|
+
var sleepSync = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
2538
|
+
function realHands(home2, takeoverMs = 6e4) {
|
|
2539
|
+
const uid = typeof process.getuid === "function" ? process.getuid() : 0;
|
|
2540
|
+
const run = (command, args) => {
|
|
2541
|
+
const r = (0, import_node_child_process3.spawnSync)(command, args, { encoding: "utf8", timeout: 3e4 });
|
|
2542
|
+
return { status: r.error ? null : r.status, stdout: r.stdout ?? "" };
|
|
2543
|
+
};
|
|
2544
|
+
return {
|
|
2545
|
+
manager: (service) => serviceManager(service, { run, uid, sleep: sleepSync, now: () => performance.now() }),
|
|
2546
|
+
waitTakeover: (nonce) => {
|
|
2547
|
+
const until = performance.now() + takeoverMs;
|
|
2548
|
+
for (; ; ) {
|
|
2549
|
+
const rec = readFleetLockRecord(home2);
|
|
2550
|
+
if (rec?.role === "fleet" && rec.nonce === nonce) return rec.pid;
|
|
2551
|
+
if (performance.now() >= until) return null;
|
|
2552
|
+
sleepSync(250);
|
|
2553
|
+
}
|
|
2554
|
+
},
|
|
2555
|
+
waitHandedBack: (done) => {
|
|
2556
|
+
const until = performance.now() + takeoverMs;
|
|
2557
|
+
for (; ; ) {
|
|
2558
|
+
if (done()) return true;
|
|
2559
|
+
if (performance.now() >= until) return false;
|
|
2560
|
+
sleepSync(250);
|
|
2561
|
+
}
|
|
2562
|
+
},
|
|
2563
|
+
proveWritersGone: (exempt) => {
|
|
2564
|
+
const res = proveWritersGone(home2, exempt, procWritersDeps((pid, s) => (0, import_install_admission.processStart)(pid) === s.processStart, (pid) => (0, import_install_admission.processStart)(pid)));
|
|
2565
|
+
return res.ok ? { ok: true } : { ok: false, reason: res.reason };
|
|
2566
|
+
}
|
|
2567
|
+
};
|
|
2568
|
+
}
|
|
2569
|
+
var defaultRecoverDeps = () => ({
|
|
2570
|
+
liveness: { processStart: import_install_admission.processStart, startTicks: import_install_admission.startTicks, bootId: import_install_admission.bootId, exists: import_install_admission.exists },
|
|
2571
|
+
io: defaultJournalIo,
|
|
2572
|
+
err: (line) => process.stderr.write(line + "\n"),
|
|
2573
|
+
out: (line) => process.stdout.write(line + "\n"),
|
|
2574
|
+
runner: {
|
|
2575
|
+
pid: process.pid,
|
|
2576
|
+
lock: { processStart: import_install_admission.processStart, startTicks: import_install_admission.startTicks, bootId: import_install_admission.bootId, exists: import_install_admission.exists, newToken: () => (0, import_node_crypto7.randomBytes)(16).toString("hex"), now: () => /* @__PURE__ */ new Date(), log: () => {
|
|
2577
|
+
} }
|
|
2578
|
+
},
|
|
2579
|
+
launch: {
|
|
2580
|
+
run: (command, args) => {
|
|
2581
|
+
const r = (0, import_node_child_process3.spawnSync)(command, args, { stdio: "ignore", timeout: 15e3 });
|
|
2582
|
+
return r.error ? null : r.status;
|
|
2583
|
+
},
|
|
2584
|
+
sleep: sleepSync,
|
|
2585
|
+
now: () => Date.now(),
|
|
2586
|
+
uid: () => typeof process.getuid === "function" ? process.getuid() : 0
|
|
2587
|
+
}
|
|
2588
|
+
});
|
|
2589
|
+
function parseArgs(argv) {
|
|
2590
|
+
let home2 = null, attempt = null, mode = null;
|
|
2591
|
+
for (let i = 0; i < argv.length; i++) {
|
|
2592
|
+
const a = argv[i];
|
|
2593
|
+
if (a === "--home" && argv[i + 1] && home2 === null) home2 = argv[++i];
|
|
2594
|
+
else if (a === "--attempt" && argv[i + 1] && attempt === null) attempt = argv[++i];
|
|
2595
|
+
else if (a === "--pre-start" && !mode) mode = "pre-start";
|
|
2596
|
+
else if (a === "--run" && !mode) mode = "run";
|
|
2597
|
+
else return null;
|
|
2598
|
+
}
|
|
2599
|
+
return home2 && attempt && mode && (0, import_node_path14.isAbsolute)(home2) && isAttemptId(attempt) ? { home: home2, attempt, mode } : null;
|
|
2600
|
+
}
|
|
2601
|
+
function main(argv, deps = defaultRecoverDeps()) {
|
|
2602
|
+
const args = parseArgs(argv);
|
|
2603
|
+
if (!args) {
|
|
2604
|
+
deps.err("usage: recover.cjs --home <absolute home> --attempt <attempt id> (--pre-start | --run)");
|
|
2605
|
+
return 2;
|
|
2606
|
+
}
|
|
2607
|
+
const { home: home2, attempt } = args;
|
|
2608
|
+
if (args.mode === "run") {
|
|
2609
|
+
return runRecovery(home2, attempt, { ...deps.runner, hands: deps.runner.hands ?? realHands(home2), liveness: deps.liveness, io: deps.io, err: deps.err, out: deps.out });
|
|
2610
|
+
}
|
|
2611
|
+
const read = readCurrent(home2, deps.io);
|
|
2612
|
+
const owner = read.state === "open" ? ownerState(home2, read.attempt, deps.liveness, deps.io) : "gone";
|
|
2613
|
+
const decision = preStartDecision(home2, read, owner, attempt);
|
|
2614
|
+
try {
|
|
2615
|
+
applyHandoffEnv(home2, decision, attempt, deps.io);
|
|
2616
|
+
} catch (err) {
|
|
2617
|
+
deps.err(`AgEnD's update pre-start check couldn't write the handoff (${err.message}). This start is refused.`);
|
|
2618
|
+
return 1;
|
|
2619
|
+
}
|
|
2620
|
+
switch (decision.kind) {
|
|
2621
|
+
case "start":
|
|
2622
|
+
return 0;
|
|
2623
|
+
case "handoff":
|
|
2624
|
+
deps.out(`AgEnD update attempt ${decision.attemptId}: this start takes the planned handoff.`);
|
|
2625
|
+
return 0;
|
|
2626
|
+
case "refuse":
|
|
2627
|
+
deps.err(decision.reason);
|
|
2628
|
+
return 1;
|
|
2629
|
+
case "start-runner": {
|
|
2630
|
+
if (read.state !== "open") return 1;
|
|
2631
|
+
const launched = launchRunner(home2, read.attempt, { ...deps.launch, liveness: deps.liveness, io: deps.io });
|
|
2632
|
+
deps.err(launched.started ? `Update attempt ${decision.attemptId} (${decision.stage}) was interrupted: its updater is gone. The recovery runner (pid ${launched.pid}) took over; this start is refused.` : `Update attempt ${decision.attemptId} (${decision.stage}) was interrupted: its updater is gone. This start is refused; ${launched.reason}`);
|
|
2633
|
+
return 1;
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
// src/update-recovery/recover-main.ts
|
|
2639
|
+
process.exitCode = main(process.argv.slice(2));
|