@songsid/agend 2.3.4 → 2.3.5-alpha.11
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 +2 -0
- package/README.zh-TW.md +2 -0
- package/THIRD_PARTY_NOTICES.md +67 -0
- package/dist/accounts-profiles.d.ts +102 -0
- package/dist/accounts-profiles.js +194 -0
- package/dist/accounts-profiles.js.map +1 -0
- package/dist/accounts-signout.d.ts +59 -0
- package/dist/accounts-signout.js +181 -0
- package/dist/accounts-signout.js.map +1 -0
- package/dist/accounts-view.d.ts +182 -0
- package/dist/accounts-view.js +204 -0
- package/dist/accounts-view.js.map +1 -0
- package/dist/agent-cli-instructions.md +3 -3
- package/dist/agent-cli.js +5 -2
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-endpoint.d.ts +5 -1
- package/dist/agent-endpoint.js +12 -2
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/agent-file-read.js +1 -1
- package/dist/agent-file-read.js.map +1 -1
- package/dist/agent-runtime-api.d.ts +4 -0
- package/dist/agent-runtime-api.js +59 -0
- package/dist/agent-runtime-api.js.map +1 -0
- package/dist/agent-runtime-change.d.ts +76 -0
- package/dist/agent-runtime-change.js +114 -0
- package/dist/agent-runtime-change.js.map +1 -0
- package/dist/agent-whats-new.js +5 -0
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/agent-workspace.d.ts +104 -0
- package/dist/agent-workspace.js +381 -0
- package/dist/agent-workspace.js.map +1 -0
- package/dist/apply-job.d.ts +5 -0
- package/dist/apply-job.js +10 -3
- package/dist/apply-job.js.map +1 -1
- package/dist/auth-api.d.ts +81 -1
- package/dist/auth-api.js +365 -14
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/company-join.d.ts +16 -0
- package/dist/authority/company-join.js +37 -0
- package/dist/authority/company-join.js.map +1 -0
- package/dist/authority/hub-initialization.d.ts +13 -0
- package/dist/authority/hub-initialization.js +30 -0
- package/dist/authority/hub-initialization.js.map +1 -0
- package/dist/authority/session-authorizations.d.ts +2 -0
- package/dist/authority/session-authorizations.js +7 -1
- package/dist/authority/session-authorizations.js.map +1 -1
- package/dist/authority/settings-role.d.ts +56 -0
- package/dist/authority/settings-role.js +48 -0
- package/dist/authority/settings-role.js.map +1 -0
- package/dist/authority/web-authority.d.ts +25 -2
- package/dist/authority/web-authority.js +37 -4
- package/dist/authority/web-authority.js.map +1 -1
- package/dist/backend/claude-code.d.ts +18 -12
- package/dist/backend/claude-code.js +228 -145
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/cli-env-probe.js +6 -2
- package/dist/backend/cli-env-probe.js.map +1 -1
- package/dist/backend/codex-footer-hints.d.ts +3 -0
- package/dist/backend/codex-footer-hints.js +14 -0
- package/dist/backend/codex-footer-hints.js.map +1 -1
- package/dist/backend/codex-package.d.ts +5 -2
- package/dist/backend/codex-package.js +1 -5
- package/dist/backend/codex-package.js.map +1 -1
- package/dist/backend/codex-quota-history.d.ts +7 -0
- package/dist/backend/codex-quota-history.js +57 -0
- package/dist/backend/codex-quota-history.js.map +1 -0
- package/dist/backend/codex-session-lookup.d.ts +6 -0
- package/dist/backend/codex-session-lookup.js +1 -1
- package/dist/backend/codex-session-lookup.js.map +1 -1
- package/dist/backend/codex.d.ts +148 -116
- package/dist/backend/codex.js +1355 -1225
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/credential-profile.d.ts +2 -0
- package/dist/backend/credential-profile.js +4 -1
- package/dist/backend/credential-profile.js.map +1 -1
- package/dist/backend/grok-model-cache.d.ts +7 -0
- package/dist/backend/grok-model-cache.js +65 -0
- package/dist/backend/grok-model-cache.js.map +1 -0
- package/dist/backend/grok-weekly-reset.d.ts +24 -0
- package/dist/backend/grok-weekly-reset.js +95 -0
- package/dist/backend/grok-weekly-reset.js.map +1 -0
- package/dist/backend/grok.d.ts +32 -1
- package/dist/backend/grok.js +323 -54
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/kiro.js +1 -1
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/native-pane.d.ts +11 -0
- package/dist/backend/native-pane.js +59 -0
- package/dist/backend/native-pane.js.map +1 -0
- package/dist/backend/types.d.ts +25 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-availability.d.ts +15 -0
- package/dist/backend-availability.js +37 -1
- package/dist/backend-availability.js.map +1 -1
- package/dist/backend-signin-pending.d.ts +8 -2
- package/dist/backend-signin-pending.js +6 -2
- package/dist/backend-signin-pending.js.map +1 -1
- package/dist/browser-backend-signins.d.ts +2 -1
- package/dist/browser-backend-signins.js +1 -1
- package/dist/browser-backend-signins.js.map +1 -1
- package/dist/build-provenance-cli.d.ts +3 -0
- package/dist/build-provenance-cli.js +11 -0
- package/dist/build-provenance-cli.js.map +1 -0
- package/dist/build-provenance.d.ts +20 -0
- package/dist/build-provenance.js +67 -0
- package/dist/build-provenance.js.map +1 -0
- package/dist/build-provenance.json +1 -0
- package/dist/bundled-tmux-guard.d.ts +23 -0
- package/dist/bundled-tmux-guard.js +90 -0
- package/dist/bundled-tmux-guard.js.map +1 -0
- package/dist/cache-service.d.ts +6 -0
- package/dist/cache-service.js +105 -0
- package/dist/cache-service.js.map +1 -1
- package/dist/channel/access-manager.d.ts +1 -6
- package/dist/channel/access-manager.js +4 -94
- package/dist/channel/access-manager.js.map +1 -1
- package/dist/channel/adapters/discord.d.ts +0 -2
- package/dist/channel/adapters/discord.js +0 -8
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.d.ts +0 -3
- package/dist/channel/adapters/telegram.js +1 -30
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/ipc-bridge.d.ts +2 -0
- package/dist/channel/mcp-tools.js +7 -7
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/types.d.ts +0 -2
- package/dist/classic-bindings.d.ts +13 -0
- package/dist/classic-bindings.js +28 -2
- package/dist/classic-bindings.js.map +1 -1
- package/dist/classic-channel-manager.d.ts +2 -0
- package/dist/classic-channel-manager.js +5 -1
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/claude-auth-status.d.ts +60 -0
- package/dist/claude-auth-status.js +165 -0
- package/dist/claude-auth-status.js.map +1 -0
- package/dist/claude-model-minimum.d.ts +7 -0
- package/dist/claude-model-minimum.js +16 -0
- package/dist/claude-model-minimum.js.map +1 -0
- package/dist/cli-audited.d.ts +60 -0
- package/dist/cli-audited.js +84 -0
- package/dist/cli-audited.js.map +1 -0
- package/dist/cli-capability.d.ts +217 -0
- package/dist/cli-capability.js +55 -0
- package/dist/cli-capability.js.map +1 -0
- package/dist/cli-caps-module.d.ts +33 -0
- package/dist/cli-caps-module.js +45 -0
- package/dist/cli-caps-module.js.map +1 -0
- package/dist/cli-registry-check.d.ts +28 -0
- package/dist/cli-registry-check.js +237 -0
- package/dist/cli-registry-check.js.map +1 -0
- package/dist/cli-registry.d.ts +578 -0
- package/dist/cli-registry.js +83 -0
- package/dist/cli-registry.js.map +1 -0
- package/dist/cli-spec-antigravity.d.ts +71 -0
- package/dist/cli-spec-antigravity.js +47 -0
- package/dist/cli-spec-antigravity.js.map +1 -0
- package/dist/cli-spec-claude-code.d.ts +93 -0
- package/dist/cli-spec-claude-code.js +37 -0
- package/dist/cli-spec-claude-code.js.map +1 -0
- package/dist/cli-spec-codex.d.ts +87 -0
- package/dist/cli-spec-codex.js +40 -0
- package/dist/cli-spec-codex.js.map +1 -0
- package/dist/cli-spec-grok.d.ts +64 -0
- package/dist/cli-spec-grok.js +40 -0
- package/dist/cli-spec-grok.js.map +1 -0
- package/dist/cli-spec-kiro-cli.d.ts +79 -0
- package/dist/cli-spec-kiro-cli.js +40 -0
- package/dist/cli-spec-kiro-cli.js.map +1 -0
- package/dist/cli-spec-muse.d.ts +54 -0
- package/dist/cli-spec-muse.js +40 -0
- package/dist/cli-spec-muse.js.map +1 -0
- package/dist/cli-spec-opencode.d.ts +60 -0
- package/dist/cli-spec-opencode.js +42 -0
- package/dist/cli-spec-opencode.js.map +1 -0
- package/dist/cli.js +286 -68
- package/dist/cli.js.map +1 -1
- package/dist/config-validator.js +99 -2
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +19 -1
- package/dist/config.js.map +1 -1
- package/dist/daemon.d.ts +165 -7
- package/dist/daemon.js +1307 -307
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard-permissions.d.ts +8 -0
- package/dist/dashboard-permissions.js +16 -0
- package/dist/dashboard-permissions.js.map +1 -1
- package/dist/decision-list.d.ts +2 -0
- package/dist/decision-list.js +1 -1
- package/dist/decision-list.js.map +1 -1
- package/dist/delivery-consumed-watch.d.ts +15 -3
- package/dist/delivery-consumed-watch.js +23 -1
- package/dist/delivery-consumed-watch.js.map +1 -1
- package/dist/delivery-outbox.d.ts +5 -0
- package/dist/delivery-outbox.js +32 -4
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/delivery-reconciliation.d.ts +2 -42
- package/dist/delivery-reconciliation.js +2 -164
- package/dist/delivery-reconciliation.js.map +1 -1
- package/dist/doctor.js +19 -9
- package/dist/doctor.js.map +1 -1
- package/dist/e2e-isolation.js +5 -2
- package/dist/e2e-isolation.js.map +1 -1
- package/dist/fleet-context.d.ts +7 -3
- package/dist/fleet-control-audit.d.ts +1 -1
- package/dist/fleet-level-config.d.ts +1 -1
- package/dist/fleet-level-config.js +2 -0
- package/dist/fleet-level-config.js.map +1 -1
- package/dist/fleet-manager.d.ts +1108 -27
- package/dist/fleet-manager.js +5735 -462
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-process-handlers.d.ts +1 -1
- package/dist/fleet-process-handlers.js +3 -2
- package/dist/fleet-process-handlers.js.map +1 -1
- package/dist/fleet-windows-runtime.d.ts +98 -0
- package/dist/fleet-windows-runtime.js +467 -0
- package/dist/fleet-windows-runtime.js.map +1 -0
- package/dist/general-binding.d.ts +85 -0
- package/dist/general-binding.js +298 -0
- package/dist/general-binding.js.map +1 -0
- package/dist/general-host-owner.d.ts +8 -0
- package/dist/general-host-owner.js +26 -0
- package/dist/general-host-owner.js.map +1 -0
- package/dist/general-instance.d.ts +7 -0
- package/dist/general-instance.js +20 -3
- package/dist/general-instance.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +101 -39
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +23 -9
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +9 -1
- package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +4 -1
- package/dist/general-knowledge/skills/fleet-config/SKILL.md +12 -0
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +3 -3
- package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +4 -0
- package/dist/general-knowledge/skills/session-management/SKILL.md +1 -1
- package/dist/general-knowledge/skills/tui-effort/SKILL.md +10 -10
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +51 -33
- package/dist/general-knowledge/steering/core-rules.md +7 -5
- package/dist/general-role.d.ts +5 -0
- package/dist/general-role.js +27 -0
- package/dist/general-role.js.map +1 -0
- package/dist/hub/admission.d.ts +28 -0
- package/dist/hub/admission.js +62 -0
- package/dist/hub/admission.js.map +1 -0
- package/dist/hub/attachments/limits.d.ts +20 -0
- package/dist/hub/attachments/limits.js +48 -0
- package/dist/hub/attachments/limits.js.map +1 -0
- package/dist/hub/attachments/store.d.ts +116 -0
- package/dist/hub/attachments/store.js +246 -0
- package/dist/hub/attachments/store.js.map +1 -0
- package/dist/hub/audit/index.d.ts +62 -0
- package/dist/hub/audit/index.js +344 -0
- package/dist/hub/audit/index.js.map +1 -0
- package/dist/hub/browser-certificate.d.ts +38 -0
- package/dist/hub/browser-certificate.js +247 -0
- package/dist/hub/browser-certificate.js.map +1 -0
- package/dist/hub/buttons-model.d.ts +9 -0
- package/dist/hub/buttons-model.js +42 -0
- package/dist/hub/buttons-model.js.map +1 -0
- package/dist/hub/buttons.d.ts +54 -0
- package/dist/hub/buttons.js +348 -0
- package/dist/hub/buttons.js.map +1 -0
- package/dist/hub/catalog.d.ts +74 -0
- package/dist/hub/catalog.js +380 -0
- package/dist/hub/catalog.js.map +1 -0
- package/dist/hub/client.d.ts +69 -0
- package/dist/hub/client.js +304 -0
- package/dist/hub/client.js.map +1 -0
- package/dist/hub/compose/member.d.ts +145 -0
- package/dist/hub/compose/member.js +458 -0
- package/dist/hub/compose/member.js.map +1 -0
- package/dist/hub/compose/server.d.ts +167 -0
- package/dist/hub/compose/server.js +477 -0
- package/dist/hub/compose/server.js.map +1 -0
- package/dist/hub/compose/storage.d.ts +5 -0
- package/dist/hub/compose/storage.js +28 -0
- package/dist/hub/compose/storage.js.map +1 -0
- package/dist/hub/compose/views.d.ts +12 -0
- package/dist/hub/compose/views.js +4 -0
- package/dist/hub/compose/views.js.map +1 -0
- package/dist/hub/db.d.ts +58 -0
- package/dist/hub/db.js +215 -0
- package/dist/hub/db.js.map +1 -0
- package/dist/hub/directory/config.d.ts +39 -0
- package/dist/hub/directory/config.js +108 -0
- package/dist/hub/directory/config.js.map +1 -0
- package/dist/hub/directory/directory.d.ts +25 -0
- package/dist/hub/directory/directory.js +526 -0
- package/dist/hub/directory/directory.js.map +1 -0
- package/dist/hub/directory/groups.d.ts +41 -0
- package/dist/hub/directory/groups.js +30 -0
- package/dist/hub/directory/groups.js.map +1 -0
- package/dist/hub/directory/index.d.ts +8 -0
- package/dist/hub/directory/index.js +4 -0
- package/dist/hub/directory/index.js.map +1 -0
- package/dist/hub/directory/profiles.d.ts +41 -0
- package/dist/hub/directory/profiles.js +90 -0
- package/dist/hub/directory/profiles.js.map +1 -0
- package/dist/hub/directory/types.d.ts +83 -0
- package/dist/hub/directory/types.js +14 -0
- package/dist/hub/directory/types.js.map +1 -0
- package/dist/hub/directory-response-owner.d.ts +38 -0
- package/dist/hub/directory-response-owner.js +191 -0
- package/dist/hub/directory-response-owner.js.map +1 -0
- package/dist/hub/enrollment-budget.d.ts +6 -0
- package/dist/hub/enrollment-budget.js +24 -0
- package/dist/hub/enrollment-budget.js.map +1 -0
- package/dist/hub/execution/cli-provider.d.ts +23 -0
- package/dist/hub/execution/cli-provider.js +341 -0
- package/dist/hub/execution/cli-provider.js.map +1 -0
- package/dist/hub/execution/index.d.ts +13 -0
- package/dist/hub/execution/index.js +8 -0
- package/dist/hub/execution/index.js.map +1 -0
- package/dist/hub/execution/model-broker.d.ts +24 -0
- package/dist/hub/execution/model-broker.js +208 -0
- package/dist/hub/execution/model-broker.js.map +1 -0
- package/dist/hub/execution/provider-setup.d.ts +11 -0
- package/dist/hub/execution/provider-setup.js +21 -0
- package/dist/hub/execution/provider-setup.js.map +1 -0
- package/dist/hub/execution/sandbox-runner.d.ts +1 -0
- package/dist/hub/execution/sandbox-runner.js +221 -0
- package/dist/hub/execution/sandbox-runner.js.map +1 -0
- package/dist/hub/execution/service.d.ts +136 -0
- package/dist/hub/execution/service.js +459 -0
- package/dist/hub/execution/service.js.map +1 -0
- package/dist/hub/execution/store.d.ts +61 -0
- package/dist/hub/execution/store.js +182 -0
- package/dist/hub/execution/store.js.map +1 -0
- package/dist/hub/execution/views.d.ts +20 -0
- package/dist/hub/execution/views.js +48 -0
- package/dist/hub/execution/views.js.map +1 -0
- package/dist/hub/group-policy/admin-api.d.ts +30 -0
- package/dist/hub/group-policy/admin-api.js +83 -0
- package/dist/hub/group-policy/admin-api.js.map +1 -0
- package/dist/hub/group-policy/admin-context.d.ts +23 -0
- package/dist/hub/group-policy/admin-context.js +52 -0
- package/dist/hub/group-policy/admin-context.js.map +1 -0
- package/dist/hub/group-policy/admin-control.d.ts +34 -0
- package/dist/hub/group-policy/admin-control.js +258 -0
- package/dist/hub/group-policy/admin-control.js.map +1 -0
- package/dist/hub/group-policy/admin-dto.d.ts +249 -0
- package/dist/hub/group-policy/admin-dto.js +55 -0
- package/dist/hub/group-policy/admin-dto.js.map +1 -0
- package/dist/hub/group-policy/admin-facts.d.ts +17 -0
- package/dist/hub/group-policy/admin-facts.js +33 -0
- package/dist/hub/group-policy/admin-facts.js.map +1 -0
- package/dist/hub/group-policy/admin-impact.d.ts +51 -0
- package/dist/hub/group-policy/admin-impact.js +88 -0
- package/dist/hub/group-policy/admin-impact.js.map +1 -0
- package/dist/hub/group-policy/admin-inventory.d.ts +24 -0
- package/dist/hub/group-policy/admin-inventory.js +72 -0
- package/dist/hub/group-policy/admin-inventory.js.map +1 -0
- package/dist/hub/group-policy/admin-read.d.ts +21 -0
- package/dist/hub/group-policy/admin-read.js +95 -0
- package/dist/hub/group-policy/admin-read.js.map +1 -0
- package/dist/hub/group-policy/authorization.d.ts +65 -0
- package/dist/hub/group-policy/authorization.js +315 -0
- package/dist/hub/group-policy/authorization.js.map +1 -0
- package/dist/hub/group-policy/impact-inventory.d.ts +21 -0
- package/dist/hub/group-policy/impact-inventory.js +75 -0
- package/dist/hub/group-policy/impact-inventory.js.map +1 -0
- package/dist/hub/group-policy/model.d.ts +56 -0
- package/dist/hub/group-policy/model.js +46 -0
- package/dist/hub/group-policy/model.js.map +1 -0
- package/dist/hub/group-policy/resources.d.ts +72 -0
- package/dist/hub/group-policy/resources.js +260 -0
- package/dist/hub/group-policy/resources.js.map +1 -0
- package/dist/hub/group-policy/store.d.ts +69 -0
- package/dist/hub/group-policy/store.js +210 -0
- package/dist/hub/group-policy/store.js.map +1 -0
- package/dist/hub/group-policy/welcome.d.ts +36 -0
- package/dist/hub/group-policy/welcome.js +55 -0
- package/dist/hub/group-policy/welcome.js.map +1 -0
- package/dist/hub/http/compose.d.ts +24 -0
- package/dist/hub/http/compose.js +739 -0
- package/dist/hub/http/compose.js.map +1 -0
- package/dist/hub/http/core.d.ts +71 -0
- package/dist/hub/http/core.js +266 -0
- package/dist/hub/http/core.js.map +1 -0
- package/dist/hub/http/deps.d.ts +79 -0
- package/dist/hub/http/deps.js +2 -0
- package/dist/hub/http/deps.js.map +1 -0
- package/dist/hub/http/schema.d.ts +14 -0
- package/dist/hub/http/schema.js +84 -0
- package/dist/hub/http/schema.js.map +1 -0
- package/dist/hub/identity.d.ts +32 -0
- package/dist/hub/identity.js +80 -0
- package/dist/hub/identity.js.map +1 -0
- package/dist/hub/init/browser-certificate.d.ts +14 -0
- package/dist/hub/init/browser-certificate.js +99 -0
- package/dist/hub/init/browser-certificate.js.map +1 -0
- package/dist/hub/init/browser-tls.d.ts +18 -0
- package/dist/hub/init/browser-tls.js +62 -0
- package/dist/hub/init/browser-tls.js.map +1 -0
- package/dist/hub/init/cli.d.ts +3 -0
- package/dist/hub/init/cli.js +83 -0
- package/dist/hub/init/cli.js.map +1 -0
- package/dist/hub/init/directory-certificate.d.ts +24 -0
- package/dist/hub/init/directory-certificate.js +229 -0
- package/dist/hub/init/directory-certificate.js.map +1 -0
- package/dist/hub/init/existing-fleet.d.ts +6 -0
- package/dist/hub/init/existing-fleet.js +58 -0
- package/dist/hub/init/existing-fleet.js.map +1 -0
- package/dist/hub/init/handoff.d.ts +8 -0
- package/dist/hub/init/handoff.js +36 -0
- package/dist/hub/init/handoff.js.map +1 -0
- package/dist/hub/init/identity.d.ts +5 -0
- package/dist/hub/init/identity.js +24 -0
- package/dist/hub/init/identity.js.map +1 -0
- package/dist/hub/init/initializer.d.ts +34 -0
- package/dist/hub/init/initializer.js +504 -0
- package/dist/hub/init/initializer.js.map +1 -0
- package/dist/hub/init/inventory.d.ts +17 -0
- package/dist/hub/init/inventory.js +33 -0
- package/dist/hub/init/inventory.js.map +1 -0
- package/dist/hub/init/layout.d.ts +32 -0
- package/dist/hub/init/layout.js +53 -0
- package/dist/hub/init/layout.js.map +1 -0
- package/dist/hub/init/network.d.ts +18 -0
- package/dist/hub/init/network.js +104 -0
- package/dist/hub/init/network.js.map +1 -0
- package/dist/hub/init/plan-digest.d.ts +5 -0
- package/dist/hub/init/plan-digest.js +47 -0
- package/dist/hub/init/plan-digest.js.map +1 -0
- package/dist/hub/init/prompt.d.ts +26 -0
- package/dist/hub/init/prompt.js +110 -0
- package/dist/hub/init/prompt.js.map +1 -0
- package/dist/hub/init/secret-file.d.ts +1 -0
- package/dist/hub/init/secret-file.js +59 -0
- package/dist/hub/init/secret-file.js.map +1 -0
- package/dist/hub/init/text.d.ts +127 -0
- package/dist/hub/init/text.js +247 -0
- package/dist/hub/init/text.js.map +1 -0
- package/dist/hub/init/types.d.ts +142 -0
- package/dist/hub/init/types.js +9 -0
- package/dist/hub/init/types.js.map +1 -0
- package/dist/hub/init/web-audit-import.d.ts +12 -0
- package/dist/hub/init/web-audit-import.js +39 -0
- package/dist/hub/init/web-audit-import.js.map +1 -0
- package/dist/hub/init/web-audit.d.ts +30 -0
- package/dist/hub/init/web-audit.js +42 -0
- package/dist/hub/init/web-audit.js.map +1 -0
- package/dist/hub/init/web-error.d.ts +6 -0
- package/dist/hub/init/web-error.js +8 -0
- package/dist/hub/init/web-error.js.map +1 -0
- package/dist/hub/init/web-http.d.ts +9 -0
- package/dist/hub/init/web-http.js +103 -0
- package/dist/hub/init/web-http.js.map +1 -0
- package/dist/hub/init/web.d.ts +118 -0
- package/dist/hub/init/web.js +428 -0
- package/dist/hub/init/web.js.map +1 -0
- package/dist/hub/init/wizard.d.ts +34 -0
- package/dist/hub/init/wizard.js +552 -0
- package/dist/hub/init/wizard.js.map +1 -0
- package/dist/hub/initialization.d.ts +23 -0
- package/dist/hub/initialization.js +28 -0
- package/dist/hub/initialization.js.map +1 -0
- package/dist/hub/join/client.d.ts +35 -0
- package/dist/hub/join/client.js +112 -0
- package/dist/hub/join/client.js.map +1 -0
- package/dist/hub/join/descriptor.d.ts +45 -0
- package/dist/hub/join/descriptor.js +52 -0
- package/dist/hub/join/descriptor.js.map +1 -0
- package/dist/hub/join/fleet-authority.d.ts +2 -0
- package/dist/hub/join/fleet-authority.js +3 -0
- package/dist/hub/join/fleet-authority.js.map +1 -0
- package/dist/hub/join/http.d.ts +8 -0
- package/dist/hub/join/http.js +112 -0
- package/dist/hub/join/http.js.map +1 -0
- package/dist/hub/join/invitation.d.ts +28 -0
- package/dist/hub/join/invitation.js +28 -0
- package/dist/hub/join/invitation.js.map +1 -0
- package/dist/hub/join/local-journal.d.ts +84 -0
- package/dist/hub/join/local-journal.js +65 -0
- package/dist/hub/join/local-journal.js.map +1 -0
- package/dist/hub/join/local.d.ts +116 -0
- package/dist/hub/join/local.js +419 -0
- package/dist/hub/join/local.js.map +1 -0
- package/dist/hub/join/private.d.ts +3 -0
- package/dist/hub/join/private.js +46 -0
- package/dist/hub/join/private.js.map +1 -0
- package/dist/hub/join/protocol.d.ts +69 -0
- package/dist/hub/join/protocol.js +96 -0
- package/dist/hub/join/protocol.js.map +1 -0
- package/dist/hub/join/receipt.d.ts +42 -0
- package/dist/hub/join/receipt.js +75 -0
- package/dist/hub/join/receipt.js.map +1 -0
- package/dist/hub/join/service.d.ts +177 -0
- package/dist/hub/join/service.js +564 -0
- package/dist/hub/join/service.js.map +1 -0
- package/dist/hub/join/store.d.ts +97 -0
- package/dist/hub/join/store.js +87 -0
- package/dist/hub/join/store.js.map +1 -0
- package/dist/hub/join/trust.d.ts +13 -0
- package/dist/hub/join/trust.js +68 -0
- package/dist/hub/join/trust.js.map +1 -0
- package/dist/hub/member/agent-mode.d.ts +6 -0
- package/dist/hub/member/agent-mode.js +23 -0
- package/dist/hub/member/agent-mode.js.map +1 -0
- package/dist/hub/member/attachments.d.ts +29 -0
- package/dist/hub/member/attachments.js +107 -0
- package/dist/hub/member/attachments.js.map +1 -0
- package/dist/hub/member/exposure-api.d.ts +87 -0
- package/dist/hub/member/exposure-api.js +64 -0
- package/dist/hub/member/exposure-api.js.map +1 -0
- package/dist/hub/member/exposures.d.ts +123 -0
- package/dist/hub/member/exposures.js +282 -0
- package/dist/hub/member/exposures.js.map +1 -0
- package/dist/hub/member/pairing-api.d.ts +87 -0
- package/dist/hub/member/pairing-api.js +391 -0
- package/dist/hub/member/pairing-api.js.map +1 -0
- package/dist/hub/member/pairing-notices.d.ts +18 -0
- package/dist/hub/member/pairing-notices.js +60 -0
- package/dist/hub/member/pairing-notices.js.map +1 -0
- package/dist/hub/member/quota.d.ts +20 -0
- package/dist/hub/member/quota.js +98 -0
- package/dist/hub/member/quota.js.map +1 -0
- package/dist/hub/member-journal.d.ts +104 -0
- package/dist/hub/member-journal.js +336 -0
- package/dist/hub/member-journal.js.map +1 -0
- package/dist/hub/member-reconciliation.d.ts +14 -0
- package/dist/hub/member-reconciliation.js +97 -0
- package/dist/hub/member-reconciliation.js.map +1 -0
- package/dist/hub/mount.d.ts +48 -0
- package/dist/hub/mount.js +146 -0
- package/dist/hub/mount.js.map +1 -0
- package/dist/hub/pairing-client.d.ts +17 -0
- package/dist/hub/pairing-client.js +108 -0
- package/dist/hub/pairing-client.js.map +1 -0
- package/dist/hub/pairing-notices.d.ts +47 -0
- package/dist/hub/pairing-notices.js +246 -0
- package/dist/hub/pairing-notices.js.map +1 -0
- package/dist/hub/pairing.d.ts +105 -0
- package/dist/hub/pairing.js +514 -0
- package/dist/hub/pairing.js.map +1 -0
- package/dist/hub/policy.d.ts +65 -0
- package/dist/hub/policy.js +154 -0
- package/dist/hub/policy.js.map +1 -0
- package/dist/hub/preview.d.ts +32 -0
- package/dist/hub/preview.js +64 -0
- package/dist/hub/preview.js.map +1 -0
- package/dist/hub/private-files.d.ts +5 -0
- package/dist/hub/private-files.js +44 -0
- package/dist/hub/private-files.js.map +1 -0
- package/dist/hub/profile.d.ts +59 -0
- package/dist/hub/profile.js +73 -0
- package/dist/hub/profile.js.map +1 -0
- package/dist/hub/protocol.d.ts +840 -0
- package/dist/hub/protocol.js +100 -0
- package/dist/hub/protocol.js.map +1 -0
- package/dist/hub/quota.d.ts +24 -0
- package/dist/hub/quota.js +112 -0
- package/dist/hub/quota.js.map +1 -0
- package/dist/hub/representative.d.ts +141 -0
- package/dist/hub/representative.js +528 -0
- package/dist/hub/representative.js.map +1 -0
- package/dist/hub/retention.d.ts +17 -0
- package/dist/hub/retention.js +45 -0
- package/dist/hub/retention.js.map +1 -0
- package/dist/hub/room-read-pacer.d.ts +14 -0
- package/dist/hub/room-read-pacer.js +51 -0
- package/dist/hub/room-read-pacer.js.map +1 -0
- package/dist/hub/rooms.d.ts +127 -0
- package/dist/hub/rooms.js +597 -0
- package/dist/hub/rooms.js.map +1 -0
- package/dist/hub/runtime.d.ts +155 -0
- package/dist/hub/runtime.js +651 -0
- package/dist/hub/runtime.js.map +1 -0
- package/dist/hub/server.d.ts +61 -0
- package/dist/hub/server.js +235 -0
- package/dist/hub/server.js.map +1 -0
- package/dist/hub/service-start.d.ts +17 -0
- package/dist/hub/service-start.js +109 -0
- package/dist/hub/service-start.js.map +1 -0
- package/dist/hub/session-directory-transition.d.ts +48 -0
- package/dist/hub/session-directory-transition.js +118 -0
- package/dist/hub/session-directory-transition.js.map +1 -0
- package/dist/hub/session-epoch.d.ts +16 -0
- package/dist/hub/session-epoch.js +50 -0
- package/dist/hub/session-epoch.js.map +1 -0
- package/dist/hub/sessions.d.ts +66 -0
- package/dist/hub/sessions.js +217 -0
- package/dist/hub/sessions.js.map +1 -0
- package/dist/hub/settings-api.d.ts +50 -0
- package/dist/hub/settings-api.js +92 -0
- package/dist/hub/settings-api.js.map +1 -0
- package/dist/hub/settings-commit.d.ts +102 -0
- package/dist/hub/settings-commit.js +522 -0
- package/dist/hub/settings-commit.js.map +1 -0
- package/dist/hub/settings-directory-ca.d.ts +31 -0
- package/dist/hub/settings-directory-ca.js +115 -0
- package/dist/hub/settings-directory-ca.js.map +1 -0
- package/dist/hub/settings-directory-control.d.ts +58 -0
- package/dist/hub/settings-directory-control.js +117 -0
- package/dist/hub/settings-directory-control.js.map +1 -0
- package/dist/hub/settings-directory-decision.d.ts +465 -0
- package/dist/hub/settings-directory-decision.js +322 -0
- package/dist/hub/settings-directory-decision.js.map +1 -0
- package/dist/hub/settings-directory-host-http.d.ts +9 -0
- package/dist/hub/settings-directory-host-http.js +75 -0
- package/dist/hub/settings-directory-host-http.js.map +1 -0
- package/dist/hub/settings-directory-host-notice-http.d.ts +9 -0
- package/dist/hub/settings-directory-host-notice-http.js +78 -0
- package/dist/hub/settings-directory-host-notice-http.js.map +1 -0
- package/dist/hub/settings-directory-host-notices.d.ts +11 -0
- package/dist/hub/settings-directory-host-notices.js +39 -0
- package/dist/hub/settings-directory-host-notices.js.map +1 -0
- package/dist/hub/settings-directory-http.d.ts +33 -0
- package/dist/hub/settings-directory-http.js +109 -0
- package/dist/hub/settings-directory-http.js.map +1 -0
- package/dist/hub/settings-directory-mount.d.ts +24 -0
- package/dist/hub/settings-directory-mount.js +77 -0
- package/dist/hub/settings-directory-mount.js.map +1 -0
- package/dist/hub/settings-directory-notices.d.ts +61 -0
- package/dist/hub/settings-directory-notices.js +132 -0
- package/dist/hub/settings-directory-notices.js.map +1 -0
- package/dist/hub/settings-directory-proof.d.ts +77 -0
- package/dist/hub/settings-directory-proof.js +313 -0
- package/dist/hub/settings-directory-proof.js.map +1 -0
- package/dist/hub/settings-directory-recovery-intent.d.ts +13 -0
- package/dist/hub/settings-directory-recovery-intent.js +29 -0
- package/dist/hub/settings-directory-recovery-intent.js.map +1 -0
- package/dist/hub/settings-directory-recovery.d.ts +37 -0
- package/dist/hub/settings-directory-recovery.js +173 -0
- package/dist/hub/settings-directory-recovery.js.map +1 -0
- package/dist/hub/settings-directory-runtime.d.ts +17 -0
- package/dist/hub/settings-directory-runtime.js +2 -0
- package/dist/hub/settings-directory-runtime.js.map +1 -0
- package/dist/hub/settings-directory-save.d.ts +37 -0
- package/dist/hub/settings-directory-save.js +175 -0
- package/dist/hub/settings-directory-save.js.map +1 -0
- package/dist/hub/socket.d.ts +24 -0
- package/dist/hub/socket.js +79 -0
- package/dist/hub/socket.js.map +1 -0
- package/dist/hub/store.d.ts +87 -0
- package/dist/hub/store.js +92 -0
- package/dist/hub/store.js.map +1 -0
- package/dist/hub/tls.d.ts +31 -0
- package/dist/hub/tls.js +135 -0
- package/dist/hub/tls.js.map +1 -0
- package/dist/hub/types.d.ts +416 -0
- package/dist/hub/types.js +2 -0
- package/dist/hub/types.js.map +1 -0
- package/dist/hub/validation.d.ts +33 -0
- package/dist/hub/validation.js +136 -0
- package/dist/hub/validation.js.map +1 -0
- package/dist/hub/version-floor.d.ts +10 -0
- package/dist/hub/version-floor.js +45 -0
- package/dist/hub/version-floor.js.map +1 -0
- package/dist/hub-browser-certificate-policy.d.ts +31 -0
- package/dist/hub-browser-certificate-policy.js +25 -0
- package/dist/hub-browser-certificate-policy.js.map +1 -0
- package/dist/hub-host-settings.d.ts +48 -0
- package/dist/hub-host-settings.js +85 -0
- package/dist/hub-host-settings.js.map +1 -0
- package/dist/hub-membership-settings.d.ts +6 -0
- package/dist/hub-membership-settings.js +21 -0
- package/dist/hub-membership-settings.js.map +1 -0
- package/dist/hub-mode.d.ts +15 -0
- package/dist/hub-mode.js +17 -0
- package/dist/hub-mode.js.map +1 -0
- package/dist/hub-pairing-summary.d.ts +48 -0
- package/dist/hub-pairing-summary.js +36 -0
- package/dist/hub-pairing-summary.js.map +1 -0
- package/dist/hub-report-target.d.ts +32 -0
- package/dist/hub-report-target.js +33 -0
- package/dist/hub-report-target.js.map +1 -0
- package/dist/hub-retention-policy.d.ts +14 -0
- package/dist/hub-retention-policy.js +15 -0
- package/dist/hub-retention-policy.js.map +1 -0
- package/dist/instance-config-impact.js +9 -3
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +52 -5
- package/dist/instance-lifecycle.js +493 -200
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.d.ts +2 -0
- package/dist/instructions.js +35 -6
- package/dist/instructions.js.map +1 -1
- package/dist/kiro-history-scan.d.ts +26 -0
- package/dist/kiro-history-scan.js +141 -0
- package/dist/kiro-history-scan.js.map +1 -0
- package/dist/kiro-history-worker.d.ts +1 -0
- package/dist/kiro-history-worker.js +9 -0
- package/dist/kiro-history-worker.js.map +1 -0
- package/dist/kiro-history.d.ts +20 -0
- package/dist/kiro-history.js +96 -0
- package/dist/kiro-history.js.map +1 -0
- package/dist/kiro-usage-run.d.ts +2 -0
- package/dist/kiro-usage-run.js +4 -1
- package/dist/kiro-usage-run.js.map +1 -1
- package/dist/launchd-service-domain.d.ts +5 -0
- package/dist/launchd-service-domain.js +21 -0
- package/dist/launchd-service-domain.js.map +1 -0
- package/dist/local-pane-endpoint.d.ts +46 -0
- package/dist/local-pane-endpoint.js +189 -0
- package/dist/local-pane-endpoint.js.map +1 -0
- package/dist/local-pane-launcher.d.ts +2 -0
- package/dist/local-pane-launcher.js +38 -0
- package/dist/local-pane-launcher.js.map +1 -0
- package/dist/local-pane-stage.ps1 +101 -0
- package/dist/locale.js +345 -99
- package/dist/locale.js.map +1 -1
- package/dist/logger.d.ts +5 -3
- package/dist/logger.js +323 -85
- package/dist/logger.js.map +1 -1
- package/dist/login-controller.d.ts +14 -1
- package/dist/login-controller.js +31 -1
- package/dist/login-controller.js.map +1 -1
- package/dist/login-flows.d.ts +21 -8
- package/dist/login-flows.js +40 -18
- package/dist/login-flows.js.map +1 -1
- package/dist/login-manager.d.ts +2 -2
- package/dist/login-manager.js +28 -6
- package/dist/login-manager.js.map +1 -1
- package/dist/login-window-lock.d.ts +2 -1
- package/dist/login-window-lock.js.map +1 -1
- package/dist/ls-rows.d.ts +1 -1
- package/dist/ls-rows.js +3 -4
- package/dist/ls-rows.js.map +1 -1
- package/dist/machine-accounts.d.ts +110 -0
- package/dist/machine-accounts.js +229 -0
- package/dist/machine-accounts.js.map +1 -0
- package/dist/machine-signins.d.ts +89 -0
- package/dist/machine-signins.js +182 -0
- package/dist/machine-signins.js.map +1 -0
- package/dist/model-catalog-defaults.d.ts +14 -0
- package/dist/model-catalog-defaults.js +20 -0
- package/dist/model-catalog-defaults.js.map +1 -0
- package/dist/muse-usage-relay.d.ts +2 -0
- package/dist/muse-usage-relay.js +5 -3
- package/dist/muse-usage-relay.js.map +1 -1
- package/dist/native-agent-admission.d.ts +7 -0
- package/dist/native-agent-admission.js +26 -0
- package/dist/native-agent-admission.js.map +1 -0
- package/dist/native-daemon-client.d.ts +13 -0
- package/dist/native-daemon-client.js +28 -0
- package/dist/native-daemon-client.js.map +1 -0
- package/dist/native-instance-api.d.ts +13 -0
- package/dist/native-instance-api.js +217 -0
- package/dist/native-instance-api.js.map +1 -0
- package/dist/native-instance-input.d.ts +87 -0
- package/dist/native-instance-input.js +59 -0
- package/dist/native-instance-input.js.map +1 -0
- package/dist/native-instance-registry.d.ts +38 -0
- package/dist/native-instance-registry.js +129 -0
- package/dist/native-instance-registry.js.map +1 -0
- package/dist/native-mcp.d.ts +43 -0
- package/dist/native-mcp.js +291 -0
- package/dist/native-mcp.js.map +1 -0
- package/dist/native-model-catalog.d.ts +25 -0
- package/dist/native-model-catalog.js +181 -0
- package/dist/native-model-catalog.js.map +1 -0
- package/dist/native-pane-crash-budget.d.ts +20 -0
- package/dist/native-pane-crash-budget.js +60 -0
- package/dist/native-pane-crash-budget.js.map +1 -0
- package/dist/native-pane-create.d.ts +26 -0
- package/dist/native-pane-create.js +53 -0
- package/dist/native-pane-create.js.map +1 -0
- package/dist/native-pane-lifecycle.d.ts +73 -0
- package/dist/native-pane-lifecycle.js +239 -0
- package/dist/native-pane-lifecycle.js.map +1 -0
- package/dist/native-pane-manager.d.ts +59 -0
- package/dist/native-pane-manager.js +592 -0
- package/dist/native-pane-manager.js.map +1 -0
- package/dist/native-pane-output-log.d.ts +15 -0
- package/dist/native-pane-output-log.js +108 -0
- package/dist/native-pane-output-log.js.map +1 -0
- package/dist/native-pane-reconciliation.d.ts +4 -0
- package/dist/native-pane-reconciliation.js +40 -0
- package/dist/native-pane-reconciliation.js.map +1 -0
- package/dist/native-pane-recovery.d.ts +12 -0
- package/dist/native-pane-recovery.js +10 -0
- package/dist/native-pane-recovery.js.map +1 -0
- package/dist/native-pane-tools.d.ts +2 -0
- package/dist/native-pane-tools.js +14 -0
- package/dist/native-pane-tools.js.map +1 -0
- package/dist/needs-you-hub.d.ts +8 -0
- package/dist/needs-you-hub.js +29 -3
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +78 -2
- package/dist/needs-you.js +45 -2
- package/dist/needs-you.js.map +1 -1
- package/dist/office-levels.d.ts +4 -3
- package/dist/office-levels.js +3 -3
- package/dist/office-levels.js.map +1 -1
- package/dist/office-share-page.js +3 -3
- package/dist/office-share-page.js.map +1 -1
- package/dist/office-share.d.ts +11 -0
- package/dist/office-share.js +14 -0
- package/dist/office-share.js.map +1 -1
- package/dist/office-talk.d.ts +26 -0
- package/dist/office-talk.js +50 -0
- package/dist/office-talk.js.map +1 -0
- package/dist/outbound-handlers.d.ts +30 -2
- package/dist/outbound-handlers.js +156 -18
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +94 -1
- package/dist/outbound-schemas.js +44 -16
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/pane-port.d.ts +118 -0
- package/dist/pane-port.js +2 -0
- package/dist/pane-port.js.map +1 -0
- package/dist/pane-quota-history.d.ts +9 -0
- package/dist/pane-quota-history.js +67 -0
- package/dist/pane-quota-history.js.map +1 -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/platform-general.d.ts +46 -0
- package/dist/platform-general.js +91 -0
- package/dist/platform-general.js.map +1 -0
- package/dist/profile-signins.d.ts +107 -0
- package/dist/profile-signins.js +249 -0
- package/dist/profile-signins.js.map +1 -0
- package/dist/public-web-gateway.js +17 -1
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +11 -0
- package/dist/public-web-link.js +13 -0
- package/dist/public-web-link.js.map +1 -1
- package/dist/quickstart-api.js +11 -7
- package/dist/quickstart-api.js.map +1 -1
- package/dist/quickstart.d.ts +14 -0
- package/dist/quickstart.js +72 -4
- package/dist/quickstart.js.map +1 -1
- package/dist/quiet-run.d.ts +31 -0
- package/dist/quiet-run.js +50 -0
- package/dist/quiet-run.js.map +1 -0
- package/dist/quota-notice-config.d.ts +22 -0
- package/dist/quota-notice-config.js +41 -0
- package/dist/quota-notice-config.js.map +1 -0
- package/dist/quota-notice.d.ts +7 -0
- package/dist/quota-notice.js +40 -0
- package/dist/quota-notice.js.map +1 -1
- package/dist/reply-buttons-controller.d.ts +5 -1
- package/dist/reply-buttons-controller.js +18 -10
- package/dist/reply-buttons-controller.js.map +1 -1
- package/dist/reply-buttons.d.ts +6 -2
- package/dist/reply-buttons.js +7 -3
- package/dist/reply-buttons.js.map +1 -1
- package/dist/reply-polls.d.ts +2 -2
- package/dist/reply-polls.js +3 -3
- package/dist/reply-polls.js.map +1 -1
- package/dist/runtime-api.d.ts +23 -0
- package/dist/runtime-api.js +413 -0
- package/dist/runtime-api.js.map +1 -0
- package/dist/runtime-assets/@xterm/addon-serialize/LICENSE +21 -0
- package/dist/runtime-assets/@xterm/addon-serialize/lib/addon-serialize.js +2 -0
- package/dist/runtime-assets/@xterm/addon-serialize/lib/addon-serialize.mjs +19 -0
- package/dist/runtime-assets/@xterm/addon-serialize/package.json +29 -0
- package/dist/runtime-assets/@xterm/headless/LICENSE +21 -0
- package/dist/runtime-assets/@xterm/headless/lib-headless/xterm-headless.js +2 -0
- package/dist/runtime-assets/@xterm/headless/lib-headless/xterm-headless.mjs +46 -0
- package/dist/runtime-assets/@xterm/headless/package.json +29 -0
- package/dist/runtime-assets/node-pty/CONPTY-LICENSE +21 -0
- package/dist/runtime-assets/node-pty/CONPTY-NOTICE.md +503 -0
- package/dist/runtime-assets/node-pty/LICENSE +69 -0
- package/dist/runtime-assets/node-pty/lib/conpty_console_list_agent.js +16 -0
- package/dist/runtime-assets/node-pty/lib/eventEmitter2.js +47 -0
- package/dist/runtime-assets/node-pty/lib/index.js +52 -0
- package/dist/runtime-assets/node-pty/lib/interfaces.js +7 -0
- package/dist/runtime-assets/node-pty/lib/shared/conout.js +11 -0
- package/dist/runtime-assets/node-pty/lib/terminal.js +190 -0
- package/dist/runtime-assets/node-pty/lib/types.js +7 -0
- package/dist/runtime-assets/node-pty/lib/unixTerminal.js +346 -0
- package/dist/runtime-assets/node-pty/lib/utils.js +39 -0
- package/dist/runtime-assets/node-pty/lib/windowsConoutConnection.js +125 -0
- package/dist/runtime-assets/node-pty/lib/windowsPtyAgent.js +320 -0
- package/dist/runtime-assets/node-pty/lib/windowsTerminal.js +199 -0
- package/dist/runtime-assets/node-pty/lib/worker/conoutSocketWorker.js +22 -0
- package/dist/runtime-assets/node-pty/package.json +64 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty.node +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
- package/dist/runtime-autostart.d.ts +61 -0
- package/dist/runtime-autostart.js +161 -0
- package/dist/runtime-autostart.js.map +1 -0
- package/dist/runtime-background.d.ts +200 -0
- package/dist/runtime-background.js +480 -0
- package/dist/runtime-background.js.map +1 -0
- package/dist/runtime-build-info.d.ts +10 -0
- package/dist/runtime-build-info.js +64 -0
- package/dist/runtime-build-info.js.map +1 -0
- package/dist/runtime-bundle.d.ts +22 -0
- package/dist/runtime-bundle.js +158 -0
- package/dist/runtime-bundle.js.map +1 -0
- package/dist/runtime-cli-background.d.ts +92 -0
- package/dist/runtime-cli-background.js +336 -0
- package/dist/runtime-cli-background.js.map +1 -0
- package/dist/runtime-cli-install.d.ts +295 -0
- package/dist/runtime-cli-install.js +869 -0
- package/dist/runtime-cli-install.js.map +1 -0
- package/dist/runtime-cli.d.ts +21 -0
- package/dist/runtime-cli.js +578 -0
- package/dist/runtime-cli.js.map +1 -0
- package/dist/runtime-client-store.d.ts +86 -0
- package/dist/runtime-client-store.js +387 -0
- package/dist/runtime-client-store.js.map +1 -0
- package/dist/runtime-client.d.ts +258 -0
- package/dist/runtime-client.js +1353 -0
- package/dist/runtime-client.js.map +1 -0
- package/dist/runtime-connection.d.ts +22 -0
- package/dist/runtime-connection.js +93 -0
- package/dist/runtime-connection.js.map +1 -0
- package/dist/runtime-coordinator.d.ts +201 -0
- package/dist/runtime-coordinator.js +1514 -0
- package/dist/runtime-coordinator.js.map +1 -0
- package/dist/runtime-credential-profiles.d.ts +89 -0
- package/dist/runtime-credential-profiles.js +304 -0
- package/dist/runtime-credential-profiles.js.map +1 -0
- package/dist/runtime-enroll-notice.d.ts +4 -0
- package/dist/runtime-enroll-notice.js +21 -0
- package/dist/runtime-enroll-notice.js.map +1 -0
- package/dist/runtime-enrollment.d.ts +21 -0
- package/dist/runtime-enrollment.js +52 -0
- package/dist/runtime-enrollment.js.map +1 -0
- package/dist/runtime-general-protocol.d.ts +22 -0
- package/dist/runtime-general-protocol.js +57 -0
- package/dist/runtime-general-protocol.js.map +1 -0
- package/dist/runtime-general-workspace.d.ts +17 -0
- package/dist/runtime-general-workspace.js +213 -0
- package/dist/runtime-general-workspace.js.map +1 -0
- package/dist/runtime-install.d.ts +50 -0
- package/dist/runtime-install.js +189 -0
- package/dist/runtime-install.js.map +1 -0
- package/dist/runtime-pane-assets.d.ts +17 -0
- package/dist/runtime-pane-assets.js +23 -0
- package/dist/runtime-pane-assets.js.map +1 -0
- package/dist/runtime-pane-boot.d.ts +9 -0
- package/dist/runtime-pane-boot.js +47 -0
- package/dist/runtime-pane-boot.js.map +1 -0
- package/dist/runtime-pane-codex-index.d.ts +10 -0
- package/dist/runtime-pane-codex-index.js +151 -0
- package/dist/runtime-pane-codex-index.js.map +1 -0
- package/dist/runtime-pane-config.d.ts +16 -0
- package/dist/runtime-pane-config.js +54 -0
- package/dist/runtime-pane-config.js.map +1 -0
- package/dist/runtime-pane-host.d.ts +63 -0
- package/dist/runtime-pane-host.js +467 -0
- package/dist/runtime-pane-host.js.map +1 -0
- package/dist/runtime-pane-job-owner.d.ts +1 -0
- package/dist/runtime-pane-job-owner.js +29 -0
- package/dist/runtime-pane-job-owner.js.map +1 -0
- package/dist/runtime-pane-job.ps1 +116 -0
- package/dist/runtime-pane-link.d.ts +47 -0
- package/dist/runtime-pane-link.js +338 -0
- package/dist/runtime-pane-link.js.map +1 -0
- package/dist/runtime-pane-mcp-protocol.d.ts +32 -0
- package/dist/runtime-pane-mcp-protocol.js +39 -0
- package/dist/runtime-pane-mcp-protocol.js.map +1 -0
- package/dist/runtime-pane-mcp-relay.d.ts +18 -0
- package/dist/runtime-pane-mcp-relay.js +80 -0
- package/dist/runtime-pane-mcp-relay.js.map +1 -0
- package/dist/runtime-pane-mcp.d.ts +55 -0
- package/dist/runtime-pane-mcp.js +153 -0
- package/dist/runtime-pane-mcp.js.map +1 -0
- package/dist/runtime-pane-native.d.ts +75 -0
- package/dist/runtime-pane-native.js +114 -0
- package/dist/runtime-pane-native.js.map +1 -0
- package/dist/runtime-pane-output.d.ts +19 -0
- package/dist/runtime-pane-output.js +53 -0
- package/dist/runtime-pane-output.js.map +1 -0
- package/dist/runtime-pane-port.d.ts +144 -0
- package/dist/runtime-pane-port.js +574 -0
- package/dist/runtime-pane-port.js.map +1 -0
- package/dist/runtime-pane-private.d.ts +14 -0
- package/dist/runtime-pane-private.js +51 -0
- package/dist/runtime-pane-private.js.map +1 -0
- package/dist/runtime-pane-private.ps1 +14 -0
- package/dist/runtime-pane-process.d.ts +4 -0
- package/dist/runtime-pane-process.js +117 -0
- package/dist/runtime-pane-process.js.map +1 -0
- package/dist/runtime-pane-protocol.d.ts +182 -0
- package/dist/runtime-pane-protocol.js +217 -0
- package/dist/runtime-pane-protocol.js.map +1 -0
- package/dist/runtime-pane-quota-history.d.ts +6 -0
- package/dist/runtime-pane-quota-history.js +44 -0
- package/dist/runtime-pane-quota-history.js.map +1 -0
- package/dist/runtime-pane-screen.d.ts +19 -0
- package/dist/runtime-pane-screen.js +76 -0
- package/dist/runtime-pane-screen.js.map +1 -0
- package/dist/runtime-pane-service.d.ts +16 -0
- package/dist/runtime-pane-service.js +256 -0
- package/dist/runtime-pane-service.js.map +1 -0
- package/dist/runtime-pane-stdio-protocol.d.ts +54 -0
- package/dist/runtime-pane-stdio-protocol.js +94 -0
- package/dist/runtime-pane-stdio-protocol.js.map +1 -0
- package/dist/runtime-pane-stdio.d.ts +3 -0
- package/dist/runtime-pane-stdio.js +123 -0
- package/dist/runtime-pane-stdio.js.map +1 -0
- package/dist/runtime-pane-store.d.ts +43 -0
- package/dist/runtime-pane-store.js +176 -0
- package/dist/runtime-pane-store.js.map +1 -0
- package/dist/runtime-pane-transcript-protocol.d.ts +43 -0
- package/dist/runtime-pane-transcript-protocol.js +58 -0
- package/dist/runtime-pane-transcript-protocol.js.map +1 -0
- package/dist/runtime-pane-transcript.d.ts +50 -0
- package/dist/runtime-pane-transcript.js +666 -0
- package/dist/runtime-pane-transcript.js.map +1 -0
- package/dist/runtime-pane-worker.d.ts +1 -0
- package/dist/runtime-pane-worker.js +167 -0
- package/dist/runtime-pane-worker.js.map +1 -0
- package/dist/runtime-profile-ownership.d.ts +66 -0
- package/dist/runtime-profile-ownership.js +391 -0
- package/dist/runtime-profile-ownership.js.map +1 -0
- package/dist/runtime-protocol.d.ts +340 -0
- package/dist/runtime-protocol.js +179 -0
- package/dist/runtime-protocol.js.map +1 -0
- package/dist/runtime-remote-accounts.d.ts +209 -0
- package/dist/runtime-remote-accounts.js +714 -0
- package/dist/runtime-remote-accounts.js.map +1 -0
- package/dist/runtime-remote-setup.d.ts +108 -0
- package/dist/runtime-remote-setup.js +532 -0
- package/dist/runtime-remote-setup.js.map +1 -0
- package/dist/runtime-signin-transport.d.ts +39 -0
- package/dist/runtime-signin-transport.js +111 -0
- package/dist/runtime-signin-transport.js.map +1 -0
- package/dist/runtime-signin.d.ts +132 -0
- package/dist/runtime-signin.js +290 -0
- package/dist/runtime-signin.js.map +1 -0
- package/dist/runtime-switches.d.ts +79 -0
- package/dist/runtime-switches.js +90 -0
- package/dist/runtime-switches.js.map +1 -0
- package/dist/runtime-transcript-delta-reader.d.ts +23 -0
- package/dist/runtime-transcript-delta-reader.js +74 -0
- package/dist/runtime-transcript-delta-reader.js.map +1 -0
- package/dist/runtime-transcript-source.d.ts +36 -0
- package/dist/runtime-transcript-source.js +189 -0
- package/dist/runtime-transcript-source.js.map +1 -0
- package/dist/runtime-update-activity.d.ts +21 -0
- package/dist/runtime-update-activity.js +51 -0
- package/dist/runtime-update-activity.js.map +1 -0
- package/dist/runtime-update-artifact.d.ts +31 -0
- package/dist/runtime-update-artifact.js +252 -0
- package/dist/runtime-update-artifact.js.map +1 -0
- package/dist/runtime-update-attention.d.ts +4 -0
- package/dist/runtime-update-attention.js +11 -0
- package/dist/runtime-update-attention.js.map +1 -0
- package/dist/runtime-update-controller.d.ts +86 -0
- package/dist/runtime-update-controller.js +743 -0
- package/dist/runtime-update-controller.js.map +1 -0
- package/dist/runtime-update-install.d.ts +31 -0
- package/dist/runtime-update-install.js +205 -0
- package/dist/runtime-update-install.js.map +1 -0
- package/dist/runtime-update-ipc.d.ts +42 -0
- package/dist/runtime-update-ipc.js +144 -0
- package/dist/runtime-update-ipc.js.map +1 -0
- package/dist/runtime-update-journal.d.ts +49 -0
- package/dist/runtime-update-journal.js +128 -0
- package/dist/runtime-update-journal.js.map +1 -0
- package/dist/runtime-update-lock.d.ts +48 -0
- package/dist/runtime-update-lock.js +232 -0
- package/dist/runtime-update-lock.js.map +1 -0
- package/dist/runtime-update-owners.d.ts +29 -0
- package/dist/runtime-update-owners.js +240 -0
- package/dist/runtime-update-owners.js.map +1 -0
- package/dist/runtime-update-protocol.d.ts +15 -0
- package/dist/runtime-update-protocol.js +13 -0
- package/dist/runtime-update-protocol.js.map +1 -0
- package/dist/runtime-update-status.d.ts +30 -0
- package/dist/runtime-update-status.js +31 -0
- package/dist/runtime-update-status.js.map +1 -0
- package/dist/runtime-windows-bridge.d.ts +42 -0
- package/dist/runtime-windows-bridge.js +167 -0
- package/dist/runtime-windows-bridge.js.map +1 -0
- package/dist/scheduler/db.d.ts +10 -0
- package/dist/scheduler/db.js +38 -11
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/task-board-text.js +1 -1
- package/dist/scheduler/task-board-text.js.map +1 -1
- package/dist/scheduler/task-board.d.ts +13 -0
- package/dist/scheduler/task-board.js +28 -3
- package/dist/scheduler/task-board.js.map +1 -1
- package/dist/scheduler/types.d.ts +6 -1
- package/dist/service-drain.d.ts +19 -0
- package/dist/service-drain.js +64 -0
- package/dist/service-drain.js.map +1 -0
- package/dist/service-installer.d.ts +7 -2
- package/dist/service-installer.js +13 -10
- package/dist/service-installer.js.map +1 -1
- package/dist/settings-api.d.ts +36 -2
- package/dist/settings-api.js +734 -9
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +7 -0
- package/dist/settings-baseline.js +3 -1
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-change.d.ts +5 -3
- package/dist/settings-change.js +61 -1
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-confirmation.d.ts +44 -7
- package/dist/settings-confirmation.js +56 -14
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.d.ts +22 -0
- package/dist/settings-effect.js +294 -4
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +35 -0
- package/dist/settings-http-confirmation.js +153 -13
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-instance-patch.js +1 -1
- package/dist/settings-instance-patch.js.map +1 -1
- package/dist/settings-request-capability.d.ts +14 -0
- package/dist/settings-request-capability.js +12 -1
- package/dist/settings-request-capability.js.map +1 -1
- package/dist/settings-route-lifetime.d.ts +14 -0
- package/dist/settings-route-lifetime.js +48 -0
- package/dist/settings-route-lifetime.js.map +1 -0
- package/dist/settings-transaction.d.ts +4 -0
- package/dist/settings-transaction.js +9 -0
- package/dist/settings-transaction.js.map +1 -1
- package/dist/setup-form.js +6 -3
- package/dist/setup-form.js.map +1 -1
- package/dist/setup-host.js +1 -1
- package/dist/setup-host.js.map +1 -1
- package/dist/setup-i18n.js +7 -4
- package/dist/setup-i18n.js.map +1 -1
- package/dist/setup-wizard.js +4 -2
- package/dist/setup-wizard.js.map +1 -1
- package/dist/signin-keepalive.d.ts +207 -0
- package/dist/signin-keepalive.js +682 -0
- package/dist/signin-keepalive.js.map +1 -0
- package/dist/structured-signin-transport.d.ts +20 -2
- package/dist/structured-signin-transport.js +57 -2
- package/dist/structured-signin-transport.js.map +1 -1
- package/dist/structured-signin.d.ts +11 -2
- package/dist/structured-signin.js +8 -8
- package/dist/structured-signin.js.map +1 -1
- package/dist/subagent-records.d.ts +45 -0
- package/dist/subagent-records.js +214 -0
- package/dist/subagent-records.js.map +1 -0
- package/dist/subagent-service.d.ts +27 -0
- package/dist/subagent-service.js +199 -0
- package/dist/subagent-service.js.map +1 -0
- package/dist/task-board-tool.d.ts +13 -1
- package/dist/task-board-tool.js +104 -4
- package/dist/task-board-tool.js.map +1 -1
- package/dist/task-board-waker.d.ts +6 -0
- package/dist/task-board-waker.js +4 -0
- package/dist/task-board-waker.js.map +1 -1
- package/dist/team-membership.d.ts +7 -0
- package/dist/team-membership.js +10 -0
- package/dist/team-membership.js.map +1 -0
- package/dist/tips.js +4 -4
- package/dist/tips.js.map +1 -1
- package/dist/tmux-binary.d.ts +59 -0
- package/dist/tmux-binary.js +189 -0
- package/dist/tmux-binary.js.map +1 -0
- package/dist/tmux-control.d.ts +2 -1
- package/dist/tmux-control.js +4 -4
- package/dist/tmux-control.js.map +1 -1
- package/dist/tmux-exec-helper.js +32 -1
- package/dist/tmux-exec-helper.js.map +1 -1
- package/dist/tmux-legacy.d.ts +94 -0
- package/dist/tmux-legacy.js +309 -0
- package/dist/tmux-legacy.js.map +1 -0
- package/dist/tmux-manager.d.ts +11 -4
- package/dist/tmux-manager.js +64 -40
- package/dist/tmux-manager.js.map +1 -1
- package/dist/tmux-pane-host.d.ts +26 -0
- package/dist/tmux-pane-host.js +25 -0
- package/dist/tmux-pane-host.js.map +1 -0
- package/dist/tmux-read.js +4 -3
- package/dist/tmux-read.js.map +1 -1
- package/dist/tmux-rollback.d.ts +31 -0
- package/dist/tmux-rollback.js +72 -0
- package/dist/tmux-rollback.js.map +1 -0
- package/dist/tmux-server.d.ts +102 -0
- package/dist/tmux-server.js +248 -0
- package/dist/tmux-server.js.map +1 -0
- package/dist/tool-permissions.d.ts +2 -3
- package/dist/tool-permissions.js +5 -4
- package/dist/tool-permissions.js.map +1 -1
- package/dist/topic-commands.js +10 -6
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-delta-reader.d.ts +1 -1
- package/dist/transcript-delta-reader.js +1 -1
- package/dist/transcript-delta-reader.js.map +1 -1
- package/dist/transcript-monitor.d.ts +23 -0
- package/dist/transcript-monitor.js +107 -49
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-needles.d.ts +42 -0
- package/dist/transcript-needles.js +166 -0
- package/dist/transcript-needles.js.map +1 -0
- package/dist/transcript-records.d.ts +22 -0
- package/dist/transcript-records.js +144 -0
- package/dist/transcript-records.js.map +1 -0
- package/dist/transcript-sources.d.ts +5 -0
- package/dist/transcript-sources.js +11 -79
- package/dist/transcript-sources.js.map +1 -1
- package/dist/types.d.ts +34 -0
- package/dist/types.js.map +1 -1
- package/dist/ui/account-identity.js +29 -0
- package/dist/ui/accounts-keepalive.js +118 -0
- package/dist/ui/accounts-manage.js +256 -0
- package/dist/ui/accounts-view.js +460 -0
- package/dist/ui/agent-proposals.js +90 -0
- package/dist/ui/agent-runtime-settings.js +69 -0
- package/dist/ui/agent-runtime.js +124 -0
- package/dist/ui/app.html +8 -1
- package/dist/ui/backend-signin.js +169 -97
- package/dist/ui/chat-ambient.js +1 -1
- package/dist/ui/chat-commands.js +7 -0
- package/dist/ui/chat-md-strings.js +3 -9
- package/dist/ui/chat-msg-actions.js +50 -4
- package/dist/ui/chat-quote.js +256 -0
- package/dist/ui/chat-render.js +3 -670
- package/dist/ui/chat-store.js +23 -7
- package/dist/ui/chat-strings.js +3 -285
- package/dist/ui/chat-thread.js +3 -969
- package/dist/ui/chat-time.js +3 -80
- package/dist/ui/chat-tour.js +1 -1
- package/dist/ui/cli-caps.js +15 -0
- package/dist/ui/cli-picker.js +42 -0
- package/dist/ui/credential-profile-select.js +54 -0
- package/dist/ui/fleet-cache.js +3 -3
- package/dist/ui/fleet-canvas.js +2 -2
- package/dist/ui/fleet-office-dialogue.d.ts +30 -0
- package/dist/ui/fleet-office-dialogue.js +382 -0
- package/dist/ui/fleet-office-editor.js +1 -1
- package/dist/ui/fleet-office-pack.d.ts +9 -0
- package/dist/ui/fleet-office-pack.js +76 -4
- package/dist/ui/fleet-office-skin.js +23 -5
- package/dist/ui/fleet-office-store.js +5 -0
- package/dist/ui/fleet-office.js +174 -7
- package/dist/ui/fleet-org.js +2 -2
- package/dist/ui/fleet-task-card.js +11 -7
- package/dist/ui/fleet-task-common.js +18 -8
- package/dist/ui/fleet-task-menu.js +188 -0
- package/dist/ui/fleet-task-stats.js +124 -0
- package/dist/ui/fleet-task-view.js +340 -0
- package/dist/ui/fleet-tasks.js +131 -43
- package/dist/ui/general-location.js +85 -0
- package/dist/ui/host-install.js +290 -0
- package/dist/ui/html-attachment.js +3 -40
- package/dist/ui/hub-agent-copy.js +23 -0
- package/dist/ui/hub-attachments.js +90 -0
- package/dist/ui/hub-button-actions.js +65 -0
- package/dist/ui/hub-chat-store.js +168 -0
- package/dist/ui/hub-chat-strings.js +79 -0
- package/dist/ui/hub-client.js +410 -0
- package/dist/ui/hub-company-join-strings.js +77 -0
- package/dist/ui/hub-company-join.js +137 -0
- package/dist/ui/hub-directory-editor-strings.js +56 -0
- package/dist/ui/hub-directory-editor.js +163 -0
- package/dist/ui/hub-directory-notice-strings.js +28 -0
- package/dist/ui/hub-directory-notices.js +66 -0
- package/dist/ui/hub-grant-strings.js +13 -0
- package/dist/ui/hub-group-policy.js +183 -0
- package/dist/ui/hub-group-strings.js +110 -0
- package/dist/ui/hub-host-security-notices.js +28 -0
- package/dist/ui/hub-owner-strings.js +56 -0
- package/dist/ui/hub-pairing-progress-strings.js +15 -0
- package/dist/ui/hub-preview.js +101 -0
- package/dist/ui/hub-provider-guidance.js +31 -0
- package/dist/ui/hub-quick-pairing.js +209 -0
- package/dist/ui/hub-quick-strings.js +43 -0
- package/dist/ui/hub-quota.js +85 -0
- package/dist/ui/hub-read-strings.js +7 -0
- package/dist/ui/hub-strings.js +164 -0
- package/dist/ui/hub-switcher.js +27 -0
- package/dist/ui/hub-this-hub.js +113 -0
- package/dist/ui/hub-welcome.js +102 -0
- package/dist/ui/machine-signin.js +56 -0
- package/dist/ui/model-picker.js +68 -0
- package/dist/ui/native-instance-settings.js +44 -0
- package/dist/ui/native-pane-recovery.js +45 -0
- package/dist/ui/office-share-page.js +4 -2
- package/dist/ui/panel-chat.js +167 -87
- package/dist/ui/panel-details.js +3 -2
- package/dist/ui/panel-fleet.js +183 -32
- package/dist/ui/panel-hub.js +974 -0
- package/dist/ui/panel-log.js +4 -4
- package/dist/ui/panel-needs.js +179 -13
- package/dist/ui/panel-notices.js +4 -3
- package/dist/ui/panel-runtimes.js +645 -0
- package/dist/ui/panel-settings.js +292 -201
- package/dist/ui/panel-windows-agent.js +87 -0
- package/dist/ui/panel-windows-cli.js +189 -0
- package/dist/ui/preview-pages.js +3 -41
- package/dist/ui/preview-panel-actions.js +3 -161
- package/dist/ui/preview-panel.js +11 -548
- package/dist/ui/preview-versions.js +3 -155
- package/dist/ui/preview.js +3 -476
- package/dist/ui/provider-marks.js +83 -0
- package/dist/ui/runtime-catalog.js +55 -0
- package/dist/ui/runtime-cli-install.js +214 -0
- package/dist/ui/runtime-commands.d.ts +6 -0
- package/dist/ui/runtime-commands.js +92 -0
- package/dist/ui/runtime-update-commands.d.ts +2 -0
- package/dist/ui/runtime-update-commands.js +11 -0
- package/dist/ui/runtime-update-status.js +53 -0
- package/dist/ui/search-dialog.js +6 -2
- package/dist/ui/settings-access-strings.js +42 -0
- package/dist/ui/settings-agent-filters.js +94 -0
- package/dist/ui/settings-appearance.js +122 -23
- package/dist/ui/settings-apply.js +12 -5
- package/dist/ui/settings-build-version.js +35 -0
- package/dist/ui/settings-catalog.js +57 -13
- package/dist/ui/settings-confirm.js +108 -10
- package/dist/ui/settings-devices.js +283 -0
- package/dist/ui/settings-dialogs.js +72 -28
- package/dist/ui/settings-guests.js +29 -14
- package/dist/ui/settings-hub-browser-certificate.js +76 -0
- package/dist/ui/settings-hub-company-join.js +165 -0
- package/dist/ui/settings-hub-connection.js +121 -0
- package/dist/ui/settings-hub-directory.js +29 -0
- package/dist/ui/settings-hub-membership.js +93 -0
- package/dist/ui/settings-hub-preview.js +74 -0
- package/dist/ui/settings-hub-retention.js +54 -0
- package/dist/ui/settings-hub-run.js +61 -0
- package/dist/ui/settings-hub-section.js +63 -0
- package/dist/ui/settings-hub-setup-strings.js +70 -0
- package/dist/ui/settings-hub-setup.js +195 -0
- package/dist/ui/settings-hub.js +266 -0
- package/dist/ui/settings-layout.js +246 -0
- package/dist/ui/settings-model.js +10 -1
- package/dist/ui/settings-named-test.js +2 -2
- package/dist/ui/settings-outside.js +310 -0
- package/dist/ui/settings-quota-notice.js +102 -0
- package/dist/ui/settings-registry.js +26 -6
- package/dist/ui/settings-restart-strings.js +17 -0
- package/dist/ui/settings-revoke-strings.js +28 -0
- package/dist/ui/settings-shared-strings.js +143 -0
- package/dist/ui/settings-shared.js +345 -0
- package/dist/ui/settings-shortcuts.js +65 -0
- package/dist/ui/settings-strings.js +146 -71
- package/dist/ui/settings-update.js +69 -0
- package/dist/ui/settings-web-authority.js +29 -15
- package/dist/ui/shared/accounts-keepalive.css +12 -0
- package/dist/ui/shared/accounts.css +88 -0
- package/dist/ui/shared/agend-auth.js +8 -1
- package/dist/ui/shared/app-i18n.js +25 -18
- package/dist/ui/shared/app-route.js +12 -3
- package/dist/ui/shared/app-session.js +13 -12
- package/dist/ui/shared/app-shell.js +320 -48
- package/dist/ui/shared/app-store.js +3 -2
- package/dist/ui/shared/app-stream.js +3 -1
- package/dist/ui/shared/app-update.js +215 -0
- package/dist/ui/shared/app.css +1542 -8
- package/dist/ui/shared/app.js +18 -4
- package/dist/ui/shared/chat-composer.js +68 -0
- package/dist/ui/shared/chat-md-strings.js +9 -0
- package/dist/ui/shared/chat-render.js +682 -0
- package/dist/ui/shared/chat-strings.js +333 -0
- package/dist/ui/shared/chat-thread.js +969 -0
- package/dist/ui/shared/chat-time.js +80 -0
- package/dist/ui/shared/device-roles.js +27 -0
- package/dist/ui/shared/header-tools.js +9 -9
- package/dist/ui/shared/host-install.css +10 -0
- package/dist/ui/shared/html-attachment.js +42 -0
- package/dist/ui/shared/hub-chat.css +98 -0
- package/dist/ui/shared/hub-groups.css +28 -0
- package/dist/ui/shared/hub-owner.css +57 -0
- package/dist/ui/shared/hub-quota.css +8 -0
- package/dist/ui/shared/hub-signin.css +24 -0
- package/dist/ui/shared/hub.css +78 -0
- package/dist/ui/shared/instance-nav.js +35 -8
- package/dist/ui/shared/instance-switch.js +4 -3
- package/dist/ui/shared/loading.css +37 -0
- package/dist/ui/shared/machine-name.js +13 -0
- package/dist/ui/shared/model-picker.css +21 -0
- package/dist/ui/shared/page-head.js +8 -0
- package/dist/ui/shared/preview-pages.js +41 -0
- package/dist/ui/shared/preview-panel-actions.js +168 -0
- package/dist/ui/shared/preview-panel.js +565 -0
- package/dist/ui/shared/preview-versions.js +155 -0
- package/dist/ui/shared/preview.js +476 -0
- package/dist/ui/shared/qrcode.module.js +2237 -0
- package/dist/ui/shared/runtime-install.css +55 -0
- package/dist/ui/shared/settings-width.js +31 -0
- package/dist/ui/shared/setup-host-text.js +8 -5
- package/dist/ui/shared/side-rail.js +15 -0
- package/dist/ui/shared/signin-authenticator.js +60 -0
- package/dist/ui/shared/signin.js +315 -25
- package/dist/ui/shared/subagent-row.css +15 -0
- package/dist/ui/shared/task-board.css +95 -0
- package/dist/ui/shared/tokens.css +1 -0
- package/dist/ui/shared/ui-dialog.js +2 -2
- package/dist/ui/shared/ui-menu.js +30 -10
- package/dist/ui/shared/ui-states.js +14 -3
- package/dist/ui/shared/usage-dialog.js +4 -73
- package/dist/ui/shared/usage-meter.js +84 -0
- package/dist/ui/shared/vendor/qrcode-generator.LICENSE +27 -0
- package/dist/ui/shared/vendor/vendor.json +19 -2
- package/dist/ui/shared/view-strings.js +26 -18
- package/dist/ui/shared/web-authorize.js +55 -5
- package/dist/ui/shared/workspace-follow.css +19 -0
- package/dist/ui/shared/workspace.css +20 -0
- package/dist/ui/signin-authenticator.html +60 -0
- package/dist/ui/signin.html +27 -2
- package/dist/ui/structured-signin.js +89 -39
- package/dist/ui/subagent-row.js +72 -0
- package/dist/ui/web-terminal/terminal.js +9 -9
- package/dist/ui/windows-agents-nav.js +2 -0
- package/dist/ui/windows-cli-catalog.js +108 -0
- package/dist/ui/workspace-follow-strings.js +28 -0
- package/dist/ui/workspace-panel.js +378 -0
- package/dist/ui/workspace-strings.js +35 -0
- package/dist/unattended-install.d.ts +11 -2
- package/dist/unattended-install.js +41 -6
- package/dist/unattended-install.js.map +1 -1
- package/dist/update-dispatch.d.ts +32 -4
- package/dist/update-dispatch.js +146 -16
- package/dist/update-dispatch.js.map +1 -1
- package/dist/update-install.d.ts +7 -0
- package/dist/update-install.js +23 -0
- package/dist/update-install.js.map +1 -1
- package/dist/update-launch.d.ts +1 -1
- package/dist/update-launch.js +6 -3
- package/dist/update-launch.js.map +1 -1
- package/dist/update-marker.d.ts +4 -2
- package/dist/update-marker.js +4 -3
- package/dist/update-marker.js.map +1 -1
- package/dist/update-npm-env.d.ts +70 -0
- package/dist/update-npm-env.js +128 -0
- package/dist/update-npm-env.js.map +1 -0
- package/dist/usage/providers.d.ts +8 -0
- package/dist/usage/providers.js +36 -26
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/quota-notices.d.ts +38 -0
- package/dist/usage/quota-notices.js +160 -0
- package/dist/usage/quota-notices.js.map +1 -0
- package/dist/usage/usage-api.d.ts +2 -1
- package/dist/usage/usage-api.js +19 -10
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/usage-rollup.d.ts +3 -0
- package/dist/usage-rollup.js +2 -0
- package/dist/usage-rollup.js.map +1 -1
- package/dist/view-api.d.ts +2 -8
- package/dist/view-api.js +8 -16
- package/dist/view-api.js.map +1 -1
- package/dist/web-api.d.ts +163 -3
- package/dist/web-api.js +1391 -32
- package/dist/web-api.js.map +1 -1
- package/dist/web-auth.js +2 -1
- package/dist/web-auth.js.map +1 -1
- package/dist/web-backend-login.d.ts +39 -3
- package/dist/web-backend-login.js +25 -17
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-channel-echo.js +3 -1
- package/dist/web-channel-echo.js.map +1 -1
- package/dist/web-chat-history.d.ts +19 -2
- package/dist/web-chat-history.js +72 -3
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-commands.d.ts +9 -1
- package/dist/web-commands.js +7 -1
- package/dist/web-commands.js.map +1 -1
- package/dist/web-device-login.d.ts +153 -0
- package/dist/web-device-login.js +278 -0
- package/dist/web-device-login.js.map +1 -0
- package/dist/web-host-install.d.ts +127 -0
- package/dist/web-host-install.js +165 -0
- package/dist/web-host-install.js.map +1 -0
- package/dist/web-login.d.ts +35 -1
- package/dist/web-login.js +51 -5
- package/dist/web-login.js.map +1 -1
- package/dist/web-notices.d.ts +9 -0
- package/dist/web-notices.js +19 -0
- package/dist/web-notices.js.map +1 -1
- package/dist/web-office-skins.d.ts +9 -0
- package/dist/web-office-skins.js +16 -1
- package/dist/web-office-skins.js.map +1 -1
- package/dist/web-only-fleet.d.ts +20 -0
- package/dist/web-only-fleet.js +21 -0
- package/dist/web-only-fleet.js.map +1 -1
- package/dist/web-remote-access.d.ts +273 -0
- package/dist/web-remote-access.js +610 -0
- package/dist/web-remote-access.js.map +1 -0
- package/dist/web-session.d.ts +61 -0
- package/dist/web-session.js +47 -1
- package/dist/web-session.js.map +1 -1
- package/dist/web-settings-patch.d.ts +3 -1
- package/dist/web-settings-patch.js +4 -1
- package/dist/web-settings-patch.js.map +1 -1
- package/dist/web-shell-routes.d.ts +10 -1
- package/dist/web-shell-routes.js +14 -2
- package/dist/web-shell-routes.js.map +1 -1
- package/dist/web-signin-device.d.ts +16 -0
- package/dist/web-signin-device.js +81 -0
- package/dist/web-signin-device.js.map +1 -0
- package/dist/web-signin-link.d.ts +42 -0
- package/dist/web-signin-link.js +110 -0
- package/dist/web-signin-link.js.map +1 -0
- package/dist/web-terminal.d.ts +11 -30
- package/dist/web-terminal.js +23 -8
- package/dist/web-terminal.js.map +1 -1
- package/dist/web-update.d.ts +78 -0
- package/dist/web-update.js +106 -0
- package/dist/web-update.js.map +1 -0
- package/dist/windows-agents.d.ts +127 -0
- package/dist/windows-agents.js +491 -0
- package/dist/windows-agents.js.map +1 -0
- package/dist/windows-cli-api.d.ts +48 -0
- package/dist/windows-cli-api.js +207 -0
- package/dist/windows-cli-api.js.map +1 -0
- package/dist/windows-cli-providers.d.ts +109 -0
- package/dist/windows-cli-providers.js +396 -0
- package/dist/windows-cli-providers.js.map +1 -0
- package/dist/windows-cli-worker.d.ts +99 -0
- package/dist/windows-cli-worker.js +729 -0
- package/dist/windows-cli-worker.js.map +1 -0
- package/dist/windows-cli.d.ts +130 -0
- package/dist/windows-cli.js +424 -0
- package/dist/windows-cli.js.map +1 -0
- package/dist/windows-native-mcp.d.ts +19 -0
- package/dist/windows-native-mcp.js +143 -0
- package/dist/windows-native-mcp.js.map +1 -0
- package/dist/windows-pane-mcp.d.ts +26 -0
- package/dist/windows-pane-mcp.js +187 -0
- package/dist/windows-pane-mcp.js.map +1 -0
- package/dist/workspace-follow-parse.d.ts +36 -0
- package/dist/workspace-follow-parse.js +208 -0
- package/dist/workspace-follow-parse.js.map +1 -0
- package/dist/workspace-follow-records.d.ts +17 -0
- package/dist/workspace-follow-records.js +88 -0
- package/dist/workspace-follow-records.js.map +1 -0
- package/dist/workspace-follow.d.ts +41 -0
- package/dist/workspace-follow.js +143 -0
- package/dist/workspace-follow.js.map +1 -0
- package/dist/wsl-detect.d.ts +1 -0
- package/dist/wsl-detect.js +20 -0
- package/dist/wsl-detect.js.map +1 -0
- package/dist/yaml-shared-nodes.js +8 -3
- package/dist/yaml-shared-nodes.js.map +1 -1
- package/launcher/agend-install.cjs +24 -4
- package/launcher/launchd-session-type.cjs +14 -0
- package/launcher/postinstall.cjs +27 -2
- package/launcher/tmux-bundle.cjs +263 -0
- package/package.json +16 -4
- package/templates/launchd.plist.ejs +3 -1
- package/templates/runtime-assets/conpty-LICENSE +21 -0
- package/templates/runtime-assets/conpty-NOTICE.md +503 -0
- package/templates/runtime-assets/local-pane-stage.ps1 +101 -0
- package/templates/runtime-assets/runtime-pane-job.ps1 +116 -0
- package/templates/runtime-assets/runtime-pane-private.ps1 +14 -0
- package/templates/runtime-assets/xterm-LICENSE +21 -0
- package/templates/runtime-install/install.ps1 +618 -0
|
@@ -0,0 +1,1514 @@
|
|
|
1
|
+
/** Durable machine registration and outbound-client transport; never starts a remote shell. */
|
|
2
|
+
import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
3
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { WebSocket, WebSocketServer } from "ws";
|
|
6
|
+
import { readBoundedWebBody } from "./web-body.js";
|
|
7
|
+
import { atomicWriteFileSync } from "./atomic-write.js";
|
|
8
|
+
import { validateNativeTask } from "./windows-cli-worker.js";
|
|
9
|
+
import { inventoryProbed } from "./windows-cli.js";
|
|
10
|
+
import { isNativeProviderId } from "./windows-cli-providers.js";
|
|
11
|
+
import { assertCredentialProfileCli, assertCredentialProfileName, parseCredentialProfileReport } from "./runtime-credential-profiles.js";
|
|
12
|
+
import { parseAccountIdentity } from "./claude-auth-status.js";
|
|
13
|
+
import { RuntimeUpdateActivity } from "./runtime-update-activity.js";
|
|
14
|
+
import { parseRuntimeUpdateControl, RUNTIME_MANAGED_UPDATE_CAPABILITY, validRuntimeUpdateId } from "./runtime-update-protocol.js";
|
|
15
|
+
import { parseRuntimeUpdateReport, parseRuntimeUpdateStatusFrame, RUNTIME_UPDATE_STATUS_CAPABILITY } from "./runtime-update-status.js";
|
|
16
|
+
import { validatePaneMcpBody } from "./runtime-pane-mcp-protocol.js";
|
|
17
|
+
import { validateRuntimePaneRequest, validateRuntimePaneSnapshot, validateRuntimePaneShutdown } from "./runtime-pane-protocol.js";
|
|
18
|
+
import { withNativePaneVerification } from "./runtime-pane-native.js";
|
|
19
|
+
import { ENROLL_TTL_MS, enrollTokenMatches, generateEnrollToken, hashEnrollToken, isEnrollToken, loadRuntimeServerIdentity } from "./runtime-enrollment.js";
|
|
20
|
+
import { RUNTIME_CLAIM_PATH, RUNTIME_CONNECT_PATH, RUNTIME_MAX_FRAME_BYTES, RUNTIME_PAIR_PATH, RUNTIME_ROTATE_PATH, RUNTIME_ENROLL_PATH, RUNTIME_ENROLL_HELLO_PATH, RUNTIME_SERVER_FINGERPRINT_PATTERN, RUNTIME_ENROLL_TID_PATTERN, RUNTIME_ENROLL_REFUSALS, runtimeEnrollHelloMessage, newRuntimeEnrollEphemeral, runtimeEnrollChannel, sealRuntimeEnroll, openRuntimeEnroll, runtimeEnrollTokenId, runtimeFingerprintFromHash, parseRuntimeInfo, runtimeInfoCompatible, RUNTIME_REINSTALL_CLOSE_REASON, isRuntimeRemoteOperation, parseRuntimeRemotePayload } from "./runtime-protocol.js";
|
|
21
|
+
const PAIR_TTL = 10 * 60_000;
|
|
22
|
+
const MAX_STORE_BYTES = 64 * 1024 * 1024;
|
|
23
|
+
const UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
24
|
+
const secret = () => randomBytes(32).toString("hex");
|
|
25
|
+
const hash = (value) => createHash("sha256").update(value).digest("hex");
|
|
26
|
+
const equal = (value, digest) => /^[a-f0-9]{64}$/i.test(digest) && timingSafeEqual(Buffer.from(hash(value), "hex"), Buffer.from(digest, "hex"));
|
|
27
|
+
const record = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
28
|
+
/** A deliberate validation failure whose static message is safe to show the runtime; every other error (I/O, internal) is not. */
|
|
29
|
+
class RuntimeProtocolError extends Error {
|
|
30
|
+
}
|
|
31
|
+
/** An enrollment the server refused. `reason` is a closed word the Runtime turns into a sentence; the message never contains the token. */
|
|
32
|
+
class RuntimeEnrollError extends RuntimeProtocolError {
|
|
33
|
+
reason;
|
|
34
|
+
constructor(reason, message) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.reason = reason;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const text = (v, max) => typeof v === "string" && v.length > 0 && v.length <= max && !/[\0\r\n]/.test(v);
|
|
40
|
+
const terminal = (task) => !!task.finishedAt && ["completed", "failed", "cancelled"].includes(task.status);
|
|
41
|
+
const loopback = (address) => address === "127.0.0.1" || address === "::1" || address === "::ffff:127.0.0.1";
|
|
42
|
+
function privateTransport(req) {
|
|
43
|
+
return req.headers.origin === undefined && req.headers.cookie === undefined
|
|
44
|
+
&& (loopback(req.socket.remoteAddress) || req.socket.encrypted === true);
|
|
45
|
+
}
|
|
46
|
+
function stable(value, depth = 0) {
|
|
47
|
+
if (depth > 64)
|
|
48
|
+
throw Error("Runtime request is too deeply nested");
|
|
49
|
+
if (Array.isArray(value))
|
|
50
|
+
return `[${value.map(value => stable(value, depth + 1)).join(",")}]`;
|
|
51
|
+
if (record(value))
|
|
52
|
+
return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${stable(value[key], depth + 1)}`).join(",")}}`;
|
|
53
|
+
return JSON.stringify(value) ?? "null";
|
|
54
|
+
}
|
|
55
|
+
/** The CLI rows' `supports` flags AgEnD knows; any other key a Runtime adds is not kept. */
|
|
56
|
+
const SUPPORT_KEYS = ["execution", "resume", "model", "mcp"];
|
|
57
|
+
const MODEL_SOURCES = ["cli-cache", "official-catalog", "cli-list", "unavailable"];
|
|
58
|
+
/**
|
|
59
|
+
* A Runtime's inventory, copied field by field from an allowlist: a field AgEnD does not know is not kept (so it can never be stored or served back
|
|
60
|
+
* by /ui/runtimes), every text field has a length limit, and the account identity and the credential profile report are accepted in their
|
|
61
|
+
* closed, masked form only. A refusal names the field and the reason, never the rejected value: an unmasked e-mail must not reach a log, a close
|
|
62
|
+
* reason or an error message from here.
|
|
63
|
+
*/
|
|
64
|
+
function inventory(value) {
|
|
65
|
+
if (!record(value) || typeof value.home !== "string" || value.home.length > 1024 || !Array.isArray(value.clis) || value.clis.length > 16)
|
|
66
|
+
throw new RuntimeProtocolError("Invalid runtime inventory");
|
|
67
|
+
const seen = new Set(), clis = [];
|
|
68
|
+
for (const row of value.clis) {
|
|
69
|
+
if (!record(row) || !isNativeProviderId(row.id) || seen.has(row.id) || !record(row.supports)
|
|
70
|
+
|| typeof row.runnable !== "boolean" || typeof row.readOnlySupport !== "boolean"
|
|
71
|
+
|| ![true, false, null].includes(row.authenticated)
|
|
72
|
+
|| !(row.path === null || text(row.path, 2048)) || !(row.version === null || text(row.version, 256))
|
|
73
|
+
|| typeof row.permissionNote !== "string" || row.permissionNote.length > 2048
|
|
74
|
+
|| !Array.isArray(row.models) || row.models.length > 256)
|
|
75
|
+
throw new RuntimeProtocolError("Invalid runtime CLI inventory");
|
|
76
|
+
const models = row.models.map(model => {
|
|
77
|
+
if (!record(model) || !text(model.id, 256) || model.name !== undefined && !text(model.name, 256)
|
|
78
|
+
|| model.description !== undefined && (typeof model.description !== "string" || model.description.length > 2048))
|
|
79
|
+
throw new RuntimeProtocolError("Invalid runtime model inventory");
|
|
80
|
+
return { id: model.id, ...(model.name !== undefined ? { name: model.name } : {}), ...(model.description !== undefined ? { description: model.description } : {}) };
|
|
81
|
+
});
|
|
82
|
+
if (Object.values(row.supports).some(v => typeof v !== "boolean"))
|
|
83
|
+
throw new RuntimeProtocolError("Invalid runtime capabilities");
|
|
84
|
+
if (row.reason !== undefined && (typeof row.reason !== "string" || row.reason.length > 1024))
|
|
85
|
+
throw new RuntimeProtocolError("Invalid runtime CLI inventory");
|
|
86
|
+
const supports = Object.fromEntries(SUPPORT_KEYS.filter(key => Object.hasOwn(row.supports, key)).map(key => [key, row.supports[key]]));
|
|
87
|
+
const entry = { id: row.id, path: row.path, version: row.version, authenticated: row.authenticated, runnable: row.runnable, supports: supports,
|
|
88
|
+
readOnlySupport: row.readOnlySupport, permissionNote: row.permissionNote, models,
|
|
89
|
+
...(row.reason !== undefined ? { reason: row.reason } : {}),
|
|
90
|
+
...(MODEL_SOURCES.includes(row.modelsSource) ? { modelsSource: row.modelsSource } : {}) };
|
|
91
|
+
seen.add(row.id);
|
|
92
|
+
clis.push(entry);
|
|
93
|
+
}
|
|
94
|
+
if (Buffer.byteLength(JSON.stringify(value)) > RUNTIME_MAX_FRAME_BYTES / 2)
|
|
95
|
+
throw new RuntimeProtocolError("Runtime inventory is too large");
|
|
96
|
+
if (value.probedAt !== undefined && value.probedAt !== null && (typeof value.probedAt !== "number" || !Number.isFinite(value.probedAt)))
|
|
97
|
+
throw new RuntimeProtocolError("Invalid runtime inventory");
|
|
98
|
+
const probe = { clis, home: value.home, ...(value.probedAt !== undefined ? { probedAt: value.probedAt } : {}),
|
|
99
|
+
...(typeof value.hostname === "string" && value.hostname.trim() && value.hostname.length <= 255 && !/[\x00-\x1f\x7f]/.test(value.hostname) ? { hostname: value.hostname.trim() } : {}) };
|
|
100
|
+
const field = (error) => /^Invalid (?:credential profile report|account identity): [A-Za-z ,.]{1,48}$/.test(String(error?.message)) ? String(error.message).replace(/^Invalid (?:credential profile report|account identity): /, "") : "invalid";
|
|
101
|
+
if (value.credentialProfiles !== undefined) {
|
|
102
|
+
try {
|
|
103
|
+
probe.credentialProfiles = parseCredentialProfileReport(value.credentialProfiles);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw new RuntimeProtocolError(`Invalid runtime credential profiles (${field(error)})`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const identities = new Map(value.clis.map(row => [row.id, row.identity]));
|
|
110
|
+
for (const row of probe.clis) {
|
|
111
|
+
const identity = identities.get(row.id);
|
|
112
|
+
if (identity === undefined)
|
|
113
|
+
continue;
|
|
114
|
+
if (row.id !== "claude-code" || row.authenticated !== true)
|
|
115
|
+
throw new RuntimeProtocolError("Invalid runtime CLI identity (only a signed-in Claude Code has one)");
|
|
116
|
+
try {
|
|
117
|
+
row.identity = parseAccountIdentity(identity);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw new RuntimeProtocolError(`Invalid runtime CLI identity (${field(error)})`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return probe;
|
|
124
|
+
}
|
|
125
|
+
function machineView(machine, claimExpiresAt, now = Date.now()) {
|
|
126
|
+
return { ...structuredClone(machine), ...(machine.status === "pending" && claimExpiresAt !== undefined && claimExpiresAt <= now ? { pairingExpired: true } : {}), ...(machine.inventory ? { inventory: withNativePaneVerification(machine.inventory) } : {}), runtimeCompatibility: machine.runtimeInfo
|
|
127
|
+
? runtimeInfoCompatible(machine.runtimeInfo) ? "compatible" : "incompatible"
|
|
128
|
+
: machine.bootId ? "legacy" : "unknown" };
|
|
129
|
+
}
|
|
130
|
+
/** `reject` of a computer that is not waiting for approval any more. */
|
|
131
|
+
export class RuntimeNotPendingError extends Error {
|
|
132
|
+
constructor() { super("This computer was already handled"); this.name = "RuntimeNotPendingError"; }
|
|
133
|
+
}
|
|
134
|
+
/** Every event is kept in the journal's bounded trail; a refusal on a known token and a throttling summary are kept too. */
|
|
135
|
+
const PERSISTED_AUDIT_EVENTS = ["issued", "used", "revoked", "superseded", "rejected", "throttled"];
|
|
136
|
+
const SOURCE_PATTERN = /^[0-9a-fx.:]{1,45}$/;
|
|
137
|
+
/** The eight groups of an IPv6 address with its `::` written out (so `fe80::abcd:1` is fe80:0:0:0:0:0:abcd:1), or undefined when it is not one. */
|
|
138
|
+
function ipv6Groups(address) {
|
|
139
|
+
const text = address.split("%")[0].toLowerCase();
|
|
140
|
+
if (!/^[0-9a-f:]+$/.test(text) || text.includes(":::"))
|
|
141
|
+
return undefined;
|
|
142
|
+
const halves = text.split("::");
|
|
143
|
+
if (halves.length > 2)
|
|
144
|
+
return undefined;
|
|
145
|
+
const head = halves[0] ? halves[0].split(":") : [], tail = halves.length === 2 && halves[1] ? halves[1].split(":") : [];
|
|
146
|
+
const fill = 8 - head.length - tail.length;
|
|
147
|
+
if (halves.length === 2 ? fill < 1 : fill !== 0)
|
|
148
|
+
return undefined;
|
|
149
|
+
const groups = [...head, ...new Array(halves.length === 2 ? fill : 0).fill("0"), ...tail];
|
|
150
|
+
return groups.length === 8 && groups.every(group => /^[0-9a-f]{1,4}$/.test(group)) ? groups.map(group => group.replace(/^0+(?=.)/, "")) : undefined;
|
|
151
|
+
}
|
|
152
|
+
/** An address for the trail with its host part hidden (IPv4 keeps two octets, IPv6 the first two of its eight groups); nothing for loopback or an unknown address. */
|
|
153
|
+
export function maskedSource(address) {
|
|
154
|
+
if (!address || loopback(address))
|
|
155
|
+
return undefined;
|
|
156
|
+
const v4 = /^(?:::ffff:)?(\d{1,3})\.(\d{1,3})\.\d{1,3}\.\d{1,3}$/i.exec(address);
|
|
157
|
+
if (v4)
|
|
158
|
+
return `${v4[1]}.${v4[2]}.x.x`;
|
|
159
|
+
const groups = ipv6Groups(address);
|
|
160
|
+
return groups && groups.some(group => group !== "0") ? `${groups[0]}:${groups[1]}:x:x` : undefined;
|
|
161
|
+
}
|
|
162
|
+
const HELLO_TTL_MS = 2 * 60_000, HELLO_CAP = 512, THROTTLE_SUMMARY_MS = 60_000;
|
|
163
|
+
const ENROLLMENT_CAP = 64, ENROLLMENT_AUDIT_CAP = 512, ENROLLMENT_KEEP_MS = 7 * 24 * 3_600_000;
|
|
164
|
+
/**
|
|
165
|
+
* M-2239 P2-1 (#2936 review): the journal is compacted, never just capped. A settled command (failed, or accepted with a
|
|
166
|
+
* terminal, process-confirmed outcome) older than COMMAND_KEEP_MS, or the oldest settled ones beyond COMMAND_SOFT_CAP,
|
|
167
|
+
* become tombstones; pending and uncertain commands are never compacted. Tombstones are evicted only beyond
|
|
168
|
+
* TOMBSTONE_CAP and only when older than TOMBSTONE_KEEP_MS — a replayed id is refused for at least that long.
|
|
169
|
+
*/
|
|
170
|
+
const COMMAND_HARD_CAP = 4096, COMMAND_SOFT_CAP = 2048, COMMAND_KEEP_MS = 7 * 24 * 3_600_000;
|
|
171
|
+
const TOMBSTONE_CAP = 65_536, TOMBSTONE_KEEP_MS = 30 * 24 * 3_600_000;
|
|
172
|
+
/**
|
|
173
|
+
* alpha.2 polish: what an interrupted command becomes. A probe only reads the runner's CLI inventory — nothing to reconcile
|
|
174
|
+
* if its answer was lost — so it settles as failed (compacted like any settled command); every other operation stays
|
|
175
|
+
* uncertain (never compacted, never sent again). The automatic probe on connect must not leave a trail in the journal.
|
|
176
|
+
*/
|
|
177
|
+
const interrupted = (command) => command.operation === "probe" ? "failed" : "uncertain";
|
|
178
|
+
export class RuntimeCoordinator {
|
|
179
|
+
home;
|
|
180
|
+
options;
|
|
181
|
+
paneEpoch = randomUUID();
|
|
182
|
+
path;
|
|
183
|
+
state;
|
|
184
|
+
server = new WebSocketServer({ noServer: true, maxPayload: RUNTIME_MAX_FRAME_BYTES, perMessageDeflate: false });
|
|
185
|
+
connections = new Map();
|
|
186
|
+
pending = new Map();
|
|
187
|
+
paneToolPending = new Set();
|
|
188
|
+
panePending = new Map();
|
|
189
|
+
/** #3190 Part 3: remote account / CLI-install calls. Memory only, never the journal (see callAccount). */
|
|
190
|
+
accountPending = new Map();
|
|
191
|
+
/** Physical handler ownership survives socket replacement and transport deadlines. */
|
|
192
|
+
machineActivity = new Map();
|
|
193
|
+
listeners = new Set();
|
|
194
|
+
limits = new Map();
|
|
195
|
+
heartbeat;
|
|
196
|
+
closed = false;
|
|
197
|
+
identityValue;
|
|
198
|
+
/** `enroll-hello` sessions: the fresh private key made for one request, kept in memory only for two minutes and spent by its one `enroll` (or dropped). Keyed by the caller's nonce. */
|
|
199
|
+
hellos = new Map();
|
|
200
|
+
throttledAt = new Map();
|
|
201
|
+
constructor(home, options = {}) {
|
|
202
|
+
this.home = home;
|
|
203
|
+
this.options = options;
|
|
204
|
+
mkdirSync(home, { recursive: true, mode: 0o700 });
|
|
205
|
+
this.path = join(home, "runtime-machines.json");
|
|
206
|
+
if (existsSync(this.path)) {
|
|
207
|
+
const stat = lstatSync(this.path);
|
|
208
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > MAX_STORE_BYTES)
|
|
209
|
+
throw Error("Invalid runtime machine store file");
|
|
210
|
+
}
|
|
211
|
+
this.state = existsSync(this.path) ? JSON.parse(readFileSync(this.path, "utf8")) : { version: 1, machines: [], pairings: [], commands: [] };
|
|
212
|
+
if (this.state.version !== 1 || !Array.isArray(this.state.machines) || !Array.isArray(this.state.pairings) || !Array.isArray(this.state.commands)
|
|
213
|
+
|| this.state.tombstones !== undefined && !Array.isArray(this.state.tombstones)
|
|
214
|
+
|| this.state.enrollments !== undefined && !Array.isArray(this.state.enrollments)
|
|
215
|
+
|| this.state.enrollmentAudit !== undefined && !Array.isArray(this.state.enrollmentAudit))
|
|
216
|
+
throw Error("Invalid runtime machine store");
|
|
217
|
+
this.state.tombstones ??= [];
|
|
218
|
+
this.state.enrollments ??= [];
|
|
219
|
+
this.state.enrollmentAudit ??= [];
|
|
220
|
+
// A trail longer than its cap is cut to the newest entries (never a reason to refuse to start).
|
|
221
|
+
if (this.state.enrollmentAudit.length > ENROLLMENT_AUDIT_CAP)
|
|
222
|
+
this.state.enrollmentAudit = this.state.enrollmentAudit.slice(-ENROLLMENT_AUDIT_CAP);
|
|
223
|
+
if (this.state.machines.length > 256 || this.state.pairings.length > 16 || this.state.commands.length > COMMAND_HARD_CAP || this.state.tombstones.length > TOMBSTONE_CAP
|
|
224
|
+
|| this.state.tombstones.some(row => !record(row) || !text(row.id, 128) || !UUID.test(String(row.machineId)) || !/^[a-f0-9]{64}$/.test(row.digest) || !Number.isFinite(row.at))
|
|
225
|
+
|| this.state.machines.some(row => !record(row) || !record(row.machine) || !UUID.test(String(row.machine.id)) || !text(row.machine.name, 100)
|
|
226
|
+
|| row.machine.platform !== "win32" || !["pending", "offline", "online", "revoked"].includes(String(row.machine.status))
|
|
227
|
+
|| !Number.isSafeInteger(row.machine.generation) || row.machine.generation < 0
|
|
228
|
+
|| row.machine.pairingFingerprint !== undefined && (typeof row.machine.pairingFingerprint !== "string" || !/^[A-F0-9]{4}(?:-[A-F0-9]{4}){2}$/.test(row.machine.pairingFingerprint))
|
|
229
|
+
|| row.credentialHash !== undefined && !/^[a-f0-9]{64}$/.test(row.credentialHash)
|
|
230
|
+
|| row.claimHash !== undefined && !/^[a-f0-9]{64}$/.test(row.claimHash))
|
|
231
|
+
|| new Set(this.state.machines.map(row => row.machine.id)).size !== this.state.machines.length
|
|
232
|
+
|| this.state.machines.some(row => row.machine.enrolledVia !== undefined && (row.machine.enrolledVia !== "install-command" || row.machine.enrollmentId !== undefined && !UUID.test(String(row.machine.enrollmentId))))
|
|
233
|
+
|| this.state.enrollments.length > ENROLLMENT_CAP
|
|
234
|
+
|| this.state.enrollments.some(row => !record(row) || !UUID.test(String(row.id)) || !/^[a-f0-9]{64}$/.test(String(row.tokenHash)) || !/^[a-f0-9]{64}$/.test(String(row.fingerprint))
|
|
235
|
+
|| !Number.isFinite(row.createdAt) || !Number.isFinite(row.expiresAt) || !text(row.createdBy, 64)
|
|
236
|
+
|| row.usedAt !== undefined && !Number.isFinite(row.usedAt) || row.revokedAt !== undefined && !Number.isFinite(row.revokedAt) || row.machineId !== undefined && !UUID.test(String(row.machineId)))
|
|
237
|
+
|| new Set(this.state.enrollments.map(row => row.id)).size !== this.state.enrollments.length
|
|
238
|
+
|| this.state.enrollmentAudit.some(row => !record(row) || !Number.isFinite(row.at) || !PERSISTED_AUDIT_EVENTS.includes(String(row.event))
|
|
239
|
+
|| (row.event === "throttled" ? row.enrollmentId !== undefined : !UUID.test(String(row.enrollmentId)))
|
|
240
|
+
|| row.actor !== undefined && !text(row.actor, 64) || row.machineId !== undefined && !UUID.test(String(row.machineId))
|
|
241
|
+
|| row.reason !== undefined && !RUNTIME_ENROLL_REFUSALS.includes(row.reason) || row.source !== undefined && !SOURCE_PATTERN.test(String(row.source))
|
|
242
|
+
|| row.scope !== undefined && row.scope !== "enroll" && row.scope !== "hello")
|
|
243
|
+
|| this.state.pairings.some(row => !record(row) || !UUID.test(String(row.id)) || !/^[a-f0-9]{64}$/.test(row.codeHash) || !Number.isFinite(row.expiresAt))
|
|
244
|
+
|| this.state.commands.some(row => !record(row) || !text(row.id, 128) || !UUID.test(String(row.machineId)) || !/^[a-f0-9]{64}$/.test(row.digest)
|
|
245
|
+
|| !["probe", "workspace", "run", "cancel", "reconcile", "recover"].includes(row.operation)
|
|
246
|
+
|| !["pending", "accepted", "failed", "uncertain"].includes(row.state) || !Number.isSafeInteger(row.seq) || row.seq < 0))
|
|
247
|
+
throw Error("Malformed runtime machine store");
|
|
248
|
+
// A coordinator restart never grants execution authority or redelivers an in-flight command.
|
|
249
|
+
for (const row of this.state.machines) {
|
|
250
|
+
if (row.machine.status === "online")
|
|
251
|
+
row.machine.status = "offline";
|
|
252
|
+
if (row.claimHash)
|
|
253
|
+
row.machine.pairingFingerprint = runtimeFingerprintFromHash(row.claimHash);
|
|
254
|
+
}
|
|
255
|
+
for (const command of this.state.commands)
|
|
256
|
+
if (command.state === "pending")
|
|
257
|
+
command.state = interrupted(command);
|
|
258
|
+
for (const row of this.state.machines)
|
|
259
|
+
if (row.machine.runtimeInfo !== undefined)
|
|
260
|
+
row.machine.runtimeInfo = parseRuntimeInfo(row.machine.runtimeInfo);
|
|
261
|
+
for (const row of this.state.machines)
|
|
262
|
+
if (row.machine.updateReport !== undefined) {
|
|
263
|
+
try {
|
|
264
|
+
row.machine.updateReport = parseRuntimeUpdateReport(row.machine.updateReport);
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
delete row.machine.updateReport;
|
|
268
|
+
} // A damaged diagnostic never prevents normal Runtime admission.
|
|
269
|
+
}
|
|
270
|
+
this.save();
|
|
271
|
+
this.heartbeat = setInterval(() => {
|
|
272
|
+
for (const connection of this.connections.values()) {
|
|
273
|
+
if (!connection.alive) {
|
|
274
|
+
connection.ws.terminate();
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
connection.alive = false;
|
|
278
|
+
connection.ws.ping();
|
|
279
|
+
}
|
|
280
|
+
}, 15_000);
|
|
281
|
+
this.heartbeat.unref();
|
|
282
|
+
}
|
|
283
|
+
now() { return this.options.now?.() ?? Date.now(); }
|
|
284
|
+
save() {
|
|
285
|
+
const value = JSON.stringify(this.state);
|
|
286
|
+
if (Buffer.byteLength(value) > MAX_STORE_BYTES)
|
|
287
|
+
throw Error("Runtime machine journal limit reached");
|
|
288
|
+
for (let attempt = 0;; attempt++) {
|
|
289
|
+
try {
|
|
290
|
+
atomicWriteFileSync(this.path, value, { mode: 0o600 });
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
// Windows scanners can briefly hold a destination open; retain atomic replacement and a bounded retry.
|
|
295
|
+
if (process.platform !== "win32" || attempt >= 4 || !["EPERM", "EACCES", "EBUSY"].includes(error.code ?? ""))
|
|
296
|
+
throw error;
|
|
297
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10 * (attempt + 1));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
emit(event) {
|
|
302
|
+
try {
|
|
303
|
+
this.options.changed?.(event);
|
|
304
|
+
}
|
|
305
|
+
catch { /* UI observers cannot change the durable verdict. */ }
|
|
306
|
+
for (const listener of this.listeners) {
|
|
307
|
+
try {
|
|
308
|
+
listener(structuredClone(event));
|
|
309
|
+
}
|
|
310
|
+
catch { /* Observer isolation. */ }
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
entry(id) { const row = this.state.machines.find(v => v.machine.id === id); if (!row)
|
|
314
|
+
throw Error("Runtime machine not found"); return row; }
|
|
315
|
+
listMachines() { const now = this.now(); return this.state.machines.map(row => machineView(row.machine, row.claimExpiresAt, now)); }
|
|
316
|
+
machine(id) { const row = this.state.machines.find(v => v.machine.id === id); return row ? machineView(row.machine, row.claimExpiresAt, this.now()) : null; }
|
|
317
|
+
subscribe(listener) { this.listeners.add(listener); return () => this.listeners.delete(listener); }
|
|
318
|
+
createPairing() {
|
|
319
|
+
this.state.pairings = this.state.pairings.filter(row => row.expiresAt > this.now());
|
|
320
|
+
if (this.state.pairings.length >= 16)
|
|
321
|
+
throw Error("Too many pending runtime pairing codes");
|
|
322
|
+
const code = randomBytes(6).toString("hex").toUpperCase(), pairingId = randomUUID(), expiresAt = this.now() + PAIR_TTL;
|
|
323
|
+
this.state.pairings.push({ id: pairingId, codeHash: hash(code), expiresAt });
|
|
324
|
+
this.save();
|
|
325
|
+
return { pairingId, code: code.match(/.{4}/g).join("-"), expiresAt };
|
|
326
|
+
}
|
|
327
|
+
/** The key a command pins. Created on first use and kept for the life of this AgEnD data folder. */
|
|
328
|
+
identity() { return this.identityValue ??= loadRuntimeServerIdentity(this.home); }
|
|
329
|
+
/** SHA-256 fingerprint of this AgEnD's enrollment key: the "who the server is" value an install command carries. */
|
|
330
|
+
serverFingerprint() { return this.identity().fingerprint; }
|
|
331
|
+
enrollmentStatus(row) {
|
|
332
|
+
return row.usedAt !== undefined ? "used" : row.revokedAt !== undefined ? "revoked" : row.expiresAt <= this.now() ? "expired" : "unused";
|
|
333
|
+
}
|
|
334
|
+
/** Appends to the persisted trail, keeping it within its cap. Returns how to take the entries back out if the journal then cannot be saved. */
|
|
335
|
+
trail(...entries) {
|
|
336
|
+
const log = this.state.enrollmentAudit, before = log.slice();
|
|
337
|
+
log.push(...entries);
|
|
338
|
+
while (log.length > ENROLLMENT_AUDIT_CAP)
|
|
339
|
+
log.shift();
|
|
340
|
+
return () => { this.state.enrollmentAudit = before; };
|
|
341
|
+
}
|
|
342
|
+
/** Reports an entry to the log hook (after it is saved, or for an entry that is only logged). */
|
|
343
|
+
audit(entry) {
|
|
344
|
+
try {
|
|
345
|
+
this.options.audit?.({ ...entry });
|
|
346
|
+
}
|
|
347
|
+
catch { /* a logging hook never changes the verdict */ }
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* issues a one-time install-command token. The same people who may create a pairing code may issue one (the caller checked
|
|
351
|
+
* for an administrator session on the dashboard, never the bare header token, #3327); `actor` is only the opaque handle recorded for them. A new token ends every earlier unused one. The token is returned
|
|
352
|
+
* here and nowhere else: the journal keeps its SHA-256 only.
|
|
353
|
+
*/
|
|
354
|
+
createEnrollment(actor) {
|
|
355
|
+
if (this.closed)
|
|
356
|
+
throw Error("Runtime coordinator is closed");
|
|
357
|
+
if (!text(actor, 64))
|
|
358
|
+
throw Error("Invalid enrollment actor");
|
|
359
|
+
const now = this.now(), identity = this.identity(), previousRows = structuredClone(this.state.enrollments);
|
|
360
|
+
const events = [];
|
|
361
|
+
// A week after it ended, a token leaves the list (the audit keeps the history); a full list drops its oldest ended token first.
|
|
362
|
+
let rows = this.state.enrollments.filter(row => (row.usedAt ?? row.revokedAt ?? row.expiresAt) + ENROLLMENT_KEEP_MS > now);
|
|
363
|
+
while (rows.length >= ENROLLMENT_CAP) {
|
|
364
|
+
const ended = rows.findIndex(row => this.enrollmentStatus(row) !== "unused");
|
|
365
|
+
if (ended < 0)
|
|
366
|
+
throw Error("Too many install-command tokens");
|
|
367
|
+
rows = rows.filter((_, index) => index !== ended);
|
|
368
|
+
}
|
|
369
|
+
this.state.enrollments = rows;
|
|
370
|
+
for (const row of rows)
|
|
371
|
+
if (this.enrollmentStatus(row) === "unused") {
|
|
372
|
+
row.revokedAt = now;
|
|
373
|
+
events.push({ at: now, event: "superseded", enrollmentId: row.id, actor });
|
|
374
|
+
}
|
|
375
|
+
const token = generateEnrollToken(), id = randomUUID(), expiresAt = now + ENROLL_TTL_MS;
|
|
376
|
+
rows.push({ id, tokenHash: hashEnrollToken(token), fingerprint: identity.fingerprint, createdAt: now, expiresAt, createdBy: actor });
|
|
377
|
+
events.push({ at: now, event: "issued", enrollmentId: id, actor });
|
|
378
|
+
const undo = this.trail(...events);
|
|
379
|
+
try {
|
|
380
|
+
this.save();
|
|
381
|
+
}
|
|
382
|
+
catch (error) {
|
|
383
|
+
this.state.enrollments = previousRows;
|
|
384
|
+
undo();
|
|
385
|
+
throw error;
|
|
386
|
+
}
|
|
387
|
+
for (const entry of events)
|
|
388
|
+
this.audit(entry);
|
|
389
|
+
return { id, token, fingerprint: identity.fingerprint, createdAt: now, expiresAt };
|
|
390
|
+
}
|
|
391
|
+
/** Newest first, at most the last few: what the page shows next to the token it just issued. Never a token or a hash. */
|
|
392
|
+
listEnrollments() {
|
|
393
|
+
return [...this.state.enrollments].reverse().slice(0, 8).map(row => ({ id: row.id, status: this.enrollmentStatus(row), createdAt: row.createdAt, expiresAt: row.expiresAt,
|
|
394
|
+
...(row.usedAt !== undefined ? { usedAt: row.usedAt } : {}), ...(row.revokedAt !== undefined ? { revokedAt: row.revokedAt } : {}), ...(row.machineId ? { machineId: row.machineId } : {}) }));
|
|
395
|
+
}
|
|
396
|
+
/** Ends a token that has not been used. A used token cannot be revoked (revoke the computer that used it); an ended one needs nothing. */
|
|
397
|
+
revokeEnrollment(id, actor) {
|
|
398
|
+
if (this.closed)
|
|
399
|
+
throw Error("Runtime coordinator is closed");
|
|
400
|
+
if (!text(actor, 64))
|
|
401
|
+
throw Error("Invalid enrollment actor");
|
|
402
|
+
const row = this.state.enrollments.find(row => row.id === id);
|
|
403
|
+
if (!row)
|
|
404
|
+
throw Error("Install-command token not found");
|
|
405
|
+
if (this.enrollmentStatus(row) !== "unused")
|
|
406
|
+
throw Error("Only an unused install-command token can be revoked");
|
|
407
|
+
const now = this.now(), entry = { at: now, event: "revoked", enrollmentId: row.id, actor };
|
|
408
|
+
row.revokedAt = now;
|
|
409
|
+
const undo = this.trail(entry);
|
|
410
|
+
try {
|
|
411
|
+
this.save();
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
delete row.revokedAt;
|
|
415
|
+
undo();
|
|
416
|
+
throw error;
|
|
417
|
+
}
|
|
418
|
+
this.audit(entry);
|
|
419
|
+
return this.listEnrollments().find(view => view.id === id);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Step 1 of joining with a token. The server makes a fresh X25519 key for this request and signs the caller's nonce together with it, using its enrollment key. The
|
|
423
|
+
* Runtime checks that key against the fingerprint in its command and, if it matches, seals the token to the fresh key. Anyone can ask; the answer is public by
|
|
424
|
+
* design and spends nothing, but the private half of the fresh key never leaves this process, so only this server can read what is sent next. A relay that
|
|
425
|
+
* forwards this call to the real server gets the real server's valid answer and still cannot read the token or the credential that follow.
|
|
426
|
+
*/
|
|
427
|
+
enrollHello(input) {
|
|
428
|
+
const invalid = () => { throw new RuntimeEnrollError("invalid", "Invalid runtime enrollment request"); };
|
|
429
|
+
if (!record(input) || Object.keys(input).some(key => key !== "nonce" && key !== "tid") || typeof input.nonce !== "string" || input.tid !== undefined && (typeof input.tid !== "string" || !RUNTIME_ENROLL_TID_PATTERN.test(input.tid)))
|
|
430
|
+
return invalid();
|
|
431
|
+
const now = this.now();
|
|
432
|
+
for (const [nonce, entry] of this.hellos)
|
|
433
|
+
if (entry.expiresAt <= now)
|
|
434
|
+
this.hellos.delete(nonce);
|
|
435
|
+
if (this.hellos.has(input.nonce))
|
|
436
|
+
return invalid(); // a nonce is used once: it cannot be re-asked to get a second key for the same exchange
|
|
437
|
+
const ephemeral = newRuntimeEnrollEphemeral();
|
|
438
|
+
let message;
|
|
439
|
+
try {
|
|
440
|
+
message = runtimeEnrollHelloMessage(input.nonce, ephemeral.publicKey);
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
return invalid();
|
|
444
|
+
}
|
|
445
|
+
while (this.hellos.size >= HELLO_CAP)
|
|
446
|
+
this.hellos.delete(this.hellos.keys().next().value);
|
|
447
|
+
this.hellos.set(input.nonce, { privateKey: ephemeral.privateKey, ephemeral: ephemeral.publicKey, tid: input.tid ?? "", expiresAt: now + HELLO_TTL_MS });
|
|
448
|
+
const identity = this.identity();
|
|
449
|
+
return { publicKey: identity.publicKey, ephemeral: ephemeral.publicKey, signature: identity.signature(message) };
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Step 2 as the Runtime sends it: the request is sealed to the fresh key that `enrollHello` made for this nonce (X25519, HKDF-SHA256, AES-256-GCM). The key is
|
|
453
|
+
* spent by this call, whatever happens, so a request cannot be replayed. A box that does not open, a nonce that was never asked for or has aged out are all "invalid".
|
|
454
|
+
* The answer is sealed under the other direction's key: nobody between the Runtime and this server can read the credential or forge the answer.
|
|
455
|
+
*/
|
|
456
|
+
enrollSealed(input, context = {}) {
|
|
457
|
+
const invalid = () => { throw new RuntimeEnrollError("invalid", "Invalid runtime enrollment request"); };
|
|
458
|
+
if (!record(input) || Object.keys(input).some(key => !["nonce", "tid", "clientKey", "iv", "ciphertext"].includes(key)) || typeof input.nonce !== "string" || typeof input.tid !== "string" || !RUNTIME_ENROLL_TID_PATTERN.test(input.tid)
|
|
459
|
+
|| typeof input.clientKey !== "string")
|
|
460
|
+
return invalid();
|
|
461
|
+
const entry = this.hellos.get(input.nonce);
|
|
462
|
+
this.hellos.delete(input.nonce);
|
|
463
|
+
if (!entry || entry.expiresAt <= this.now() || entry.tid !== "" && entry.tid !== input.tid)
|
|
464
|
+
return invalid();
|
|
465
|
+
let channel;
|
|
466
|
+
try {
|
|
467
|
+
channel = runtimeEnrollChannel(entry.privateKey, input.clientKey, input.nonce, input.tid, entry.ephemeral, input.clientKey);
|
|
468
|
+
}
|
|
469
|
+
catch {
|
|
470
|
+
return invalid();
|
|
471
|
+
}
|
|
472
|
+
const plain = openRuntimeEnroll(channel.requestKey, channel.context, "request", { iv: input.iv, ciphertext: input.ciphertext });
|
|
473
|
+
if (!plain)
|
|
474
|
+
return invalid();
|
|
475
|
+
let fields;
|
|
476
|
+
try {
|
|
477
|
+
fields = JSON.parse(plain.toString("utf8"));
|
|
478
|
+
}
|
|
479
|
+
catch {
|
|
480
|
+
return invalid();
|
|
481
|
+
}
|
|
482
|
+
if (record(fields) && typeof fields.token === "string" && isEnrollToken(fields.token) && runtimeEnrollTokenId(fields.token) !== input.tid)
|
|
483
|
+
return invalid();
|
|
484
|
+
const grant = this.enroll(fields, context);
|
|
485
|
+
return { box: sealRuntimeEnroll(channel.replyKey, channel.context, "reply", Buffer.from(JSON.stringify(grant), "utf8")) };
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Spends the token. The computer is created already approved (the token IS the approval: it could only come from an authorised administrator's page) and gets its
|
|
489
|
+
* credential in the grant. Every refusal says why in one closed word; a token that is unknown to the server says only "invalid". Called with the opened request.
|
|
490
|
+
*/
|
|
491
|
+
enroll(input, context = {}) {
|
|
492
|
+
if (!record(input) || Object.keys(input).some(key => !["token", "fingerprint", "name", "platform", "hostname"].includes(key)) || !isEnrollToken(input.token)
|
|
493
|
+
|| typeof input.fingerprint !== "string" || !RUNTIME_SERVER_FINGERPRINT_PATTERN.test(input.fingerprint)
|
|
494
|
+
|| !text(input.name, 100) || !input.name.trim() || input.platform !== "win32" || input.hostname !== undefined && !text(input.hostname, 255))
|
|
495
|
+
throw new RuntimeEnrollError("invalid", "Invalid runtime enrollment request");
|
|
496
|
+
const token = input.token, now = this.now(), identity = this.identity(), source = maskedSource(context.remote);
|
|
497
|
+
const row = this.state.enrollments.find(candidate => enrollTokenMatches(token, candidate.tokenHash));
|
|
498
|
+
if (!row)
|
|
499
|
+
throw new RuntimeEnrollError("invalid", "Install-command token is not valid");
|
|
500
|
+
const refuse = (reason, message) => {
|
|
501
|
+
// A refusal on a KNOWN token goes in the trail (a token that is not known is only counted, by the throttling summary). Not being able to save it never changes the answer.
|
|
502
|
+
const entry = { at: now, event: "rejected", enrollmentId: row.id, reason, ...(source ? { source } : {}) }, undo = this.trail(entry);
|
|
503
|
+
try {
|
|
504
|
+
this.save();
|
|
505
|
+
}
|
|
506
|
+
catch {
|
|
507
|
+
undo();
|
|
508
|
+
}
|
|
509
|
+
this.audit(entry);
|
|
510
|
+
throw new RuntimeEnrollError(reason, message);
|
|
511
|
+
};
|
|
512
|
+
if (row.usedAt !== undefined)
|
|
513
|
+
refuse("used", "Install-command token was already used");
|
|
514
|
+
if (row.revokedAt !== undefined)
|
|
515
|
+
refuse("revoked", "Install-command token was revoked");
|
|
516
|
+
if (row.expiresAt <= now)
|
|
517
|
+
refuse("expired", "Install-command token expired");
|
|
518
|
+
if (input.fingerprint !== identity.fingerprint || row.fingerprint !== identity.fingerprint)
|
|
519
|
+
refuse("mismatch", "Install-command token is for a different AgEnD");
|
|
520
|
+
if (this.state.machines.length >= 256 || this.state.machines.filter(machine => machine.machine.status !== "revoked").length >= 64)
|
|
521
|
+
refuse("limit", "Runtime machine limit reached");
|
|
522
|
+
const machineId = randomUUID(), credential = secret(), entry = { at: now, event: "used", enrollmentId: row.id, machineId, ...(source ? { source } : {}) };
|
|
523
|
+
const machine = { machine: { id: machineId, name: input.name.trim(), platform: "win32", ...(input.hostname ? { hostname: input.hostname } : {}), status: "offline", createdAt: now, approvedAt: now,
|
|
524
|
+
generation: 0, enrolledVia: "install-command", enrollmentId: row.id }, credentialHash: hash(credential) };
|
|
525
|
+
row.usedAt = now;
|
|
526
|
+
row.machineId = machineId;
|
|
527
|
+
this.state.machines.push(machine);
|
|
528
|
+
const undo = this.trail(entry);
|
|
529
|
+
try {
|
|
530
|
+
this.save();
|
|
531
|
+
}
|
|
532
|
+
catch (error) {
|
|
533
|
+
delete row.usedAt;
|
|
534
|
+
delete row.machineId;
|
|
535
|
+
this.state.machines.pop();
|
|
536
|
+
undo();
|
|
537
|
+
throw error;
|
|
538
|
+
}
|
|
539
|
+
this.audit(entry);
|
|
540
|
+
this.emit({ type: "machine", machineId });
|
|
541
|
+
return { status: "enrolled", machineId, credential };
|
|
542
|
+
}
|
|
543
|
+
/** One summary in the trail per bucket and minute when an enrollment-related bucket starts refusing: what is throttled names no known token, so it is counted, not listed. */
|
|
544
|
+
noteThrottled(key, scope, remote) {
|
|
545
|
+
const now = this.now(), last = this.throttledAt.get(key);
|
|
546
|
+
if (last !== undefined && now - last < THROTTLE_SUMMARY_MS)
|
|
547
|
+
return;
|
|
548
|
+
this.throttledAt.set(key, now);
|
|
549
|
+
while (this.throttledAt.size > 256)
|
|
550
|
+
this.throttledAt.delete(this.throttledAt.keys().next().value);
|
|
551
|
+
const source = maskedSource(remote), entry = { at: now, event: "throttled", scope, ...(source ? { source } : {}) }, undo = this.trail(entry);
|
|
552
|
+
try {
|
|
553
|
+
this.save();
|
|
554
|
+
}
|
|
555
|
+
catch {
|
|
556
|
+
undo();
|
|
557
|
+
}
|
|
558
|
+
this.audit(entry);
|
|
559
|
+
}
|
|
560
|
+
pair(input) {
|
|
561
|
+
if (!record(input) || Object.keys(input).some(k => !["code", "name", "platform", "hostname"].includes(k))
|
|
562
|
+
|| !text(input.code, 32) || !text(input.name, 100) || !input.name.trim() || input.platform !== "win32"
|
|
563
|
+
|| input.hostname !== undefined && !text(input.hostname, 255))
|
|
564
|
+
throw Error("Invalid runtime pairing request");
|
|
565
|
+
if (this.state.machines.length >= 256 || this.state.machines.filter(row => row.machine.status !== "revoked").length >= 64)
|
|
566
|
+
throw Error("Runtime machine limit reached");
|
|
567
|
+
const code = input.code.replaceAll("-", "").toUpperCase();
|
|
568
|
+
const pairing = this.state.pairings.find(row => row.expiresAt > this.now() && equal(code, row.codeHash));
|
|
569
|
+
if (!pairing)
|
|
570
|
+
throw Error("Pairing code is invalid, used or expired");
|
|
571
|
+
const machineId = randomUUID(), claimSecret = secret();
|
|
572
|
+
this.state.pairings = this.state.pairings.filter(row => row !== pairing);
|
|
573
|
+
this.state.machines.push({ machine: { id: machineId, name: input.name.trim(), platform: "win32", ...(input.hostname ? { hostname: input.hostname } : {}), status: "pending", createdAt: this.now(), generation: 0, pairingFingerprint: runtimeFingerprintFromHash(hash(claimSecret)) }, claimHash: hash(claimSecret), claimExpiresAt: pairing.expiresAt });
|
|
574
|
+
this.save();
|
|
575
|
+
this.emit({ type: "machine", machineId });
|
|
576
|
+
return { machineId, claimSecret, status: "pending", expiresAt: pairing.expiresAt };
|
|
577
|
+
}
|
|
578
|
+
claim(input) {
|
|
579
|
+
if (!record(input) || Object.keys(input).some(k => !["machineId", "claimSecret"].includes(k)) || !text(input.machineId, 64) || !text(input.claimSecret, 128))
|
|
580
|
+
throw Error("Invalid runtime claim");
|
|
581
|
+
const row = this.state.machines.find(row => row.machine.id === input.machineId);
|
|
582
|
+
if (!row?.claimHash || !row.claimExpiresAt || row.claimExpiresAt <= this.now() || !equal(input.claimSecret, row.claimHash) || row.machine.status === "revoked")
|
|
583
|
+
throw Error("Runtime claim is invalid or expired");
|
|
584
|
+
if (!row.machine.approvedAt)
|
|
585
|
+
return { status: "pending" };
|
|
586
|
+
const credential = secret();
|
|
587
|
+
row.credentialHash = hash(credential);
|
|
588
|
+
delete row.claimHash;
|
|
589
|
+
delete row.claimExpiresAt;
|
|
590
|
+
this.save();
|
|
591
|
+
return { machineId: row.machine.id, credential, status: "approved" };
|
|
592
|
+
}
|
|
593
|
+
approve(id, fingerprint) {
|
|
594
|
+
const row = this.entry(id);
|
|
595
|
+
if (row.machine.status !== "pending" || !row.claimExpiresAt || row.claimExpiresAt <= this.now())
|
|
596
|
+
throw Error("Runtime pairing is no longer pending");
|
|
597
|
+
if (!fingerprint || fingerprint !== row.machine.pairingFingerprint)
|
|
598
|
+
throw Error("Compare the pairing fingerprint shown by this Runtime before approving");
|
|
599
|
+
row.machine.approvedAt = this.now();
|
|
600
|
+
row.machine.status = "offline";
|
|
601
|
+
this.save();
|
|
602
|
+
this.emit({ type: "machine", machineId: id });
|
|
603
|
+
return structuredClone(row.machine);
|
|
604
|
+
}
|
|
605
|
+
rename(id, name) {
|
|
606
|
+
if (!text(name, 100) || !name.trim())
|
|
607
|
+
throw Error("Invalid runtime machine name");
|
|
608
|
+
const row = this.entry(id);
|
|
609
|
+
row.machine.name = name.trim();
|
|
610
|
+
this.save();
|
|
611
|
+
this.emit({ type: "machine", machineId: id });
|
|
612
|
+
return structuredClone(row.machine);
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Drops a computer's request to pair while it is still waiting (an expired request too: that is how it is cleared). A computer that is no longer waiting, because it was approved
|
|
616
|
+
* meanwhile (another tab, another administrator) or was revoked, is left exactly as it is and the call says so: rejecting is never a way to revoke a computer that was approved.
|
|
617
|
+
*/
|
|
618
|
+
reject(id) {
|
|
619
|
+
const row = this.entry(id);
|
|
620
|
+
if (row.machine.status !== "pending")
|
|
621
|
+
throw new RuntimeNotPendingError();
|
|
622
|
+
return this.revoke(id);
|
|
623
|
+
}
|
|
624
|
+
revoke(id) {
|
|
625
|
+
const row = this.entry(id);
|
|
626
|
+
row.machine.status = "revoked";
|
|
627
|
+
delete row.credentialHash;
|
|
628
|
+
delete row.claimHash;
|
|
629
|
+
delete row.claimExpiresAt;
|
|
630
|
+
this.save();
|
|
631
|
+
const connection = this.connections.get(id);
|
|
632
|
+
if (connection) {
|
|
633
|
+
this.connections.delete(id);
|
|
634
|
+
this.rejectPending(connection, "Runtime machine was revoked");
|
|
635
|
+
this.options.warn?.({ machineId: id, code: 1008, reason: "Machine revoked" }, "Runtime connection closed because the machine was revoked");
|
|
636
|
+
connection.ws.close(1008, "Machine revoked");
|
|
637
|
+
}
|
|
638
|
+
this.emit({ type: "machine", machineId: id });
|
|
639
|
+
return structuredClone(row.machine);
|
|
640
|
+
}
|
|
641
|
+
credentialOwner(auth) {
|
|
642
|
+
if (typeof auth !== "string" || !/^Bearer [a-f0-9]{64}$/i.test(auth))
|
|
643
|
+
return;
|
|
644
|
+
return this.state.machines.find(row => row.credentialHash && row.machine.status !== "revoked" && row.machine.approvedAt && equal(auth.slice(7), row.credentialHash));
|
|
645
|
+
}
|
|
646
|
+
/** Valid capabilities never share the invalid-traffic bucket of a loopback proxy. Forwarding headers are untrusted. */
|
|
647
|
+
rate(key, limit) {
|
|
648
|
+
const now = this.now();
|
|
649
|
+
for (const [id, value] of this.limits)
|
|
650
|
+
if (value.until <= now)
|
|
651
|
+
this.limits.delete(id);
|
|
652
|
+
if (!this.limits.has(key) && this.limits.size >= 512) {
|
|
653
|
+
const invalid = [...this.limits.keys()].find(id => id.startsWith("invalid:"));
|
|
654
|
+
if (!invalid || key.startsWith("invalid:"))
|
|
655
|
+
return false;
|
|
656
|
+
this.limits.delete(invalid);
|
|
657
|
+
}
|
|
658
|
+
const old = this.limits.get(key), row = old && old.until > now ? old : { count: 0, until: now + 60_000 };
|
|
659
|
+
this.limits.set(key, row);
|
|
660
|
+
return ++row.count <= limit;
|
|
661
|
+
}
|
|
662
|
+
requestRateKey(path, input, req) {
|
|
663
|
+
if (path === RUNTIME_ROTATE_PATH) {
|
|
664
|
+
const row = this.credentialOwner(req.headers.authorization);
|
|
665
|
+
if (row)
|
|
666
|
+
return `rotate:${row.machine.id}`;
|
|
667
|
+
}
|
|
668
|
+
else if (record(input)) {
|
|
669
|
+
// A request that names an existing token by its non-secret id (the first 64 bits of its SHA-256) is that token's own traffic: it gets that token's bucket, so
|
|
670
|
+
// nobody who floods the address bucket (every client behind a local proxy shares one address) can keep a real installer out. The id reveals nothing of the token.
|
|
671
|
+
if ((path === RUNTIME_ENROLL_PATH || path === RUNTIME_ENROLL_HELLO_PATH) && typeof input.tid === "string" && RUNTIME_ENROLL_TID_PATTERN.test(input.tid)) {
|
|
672
|
+
const row = this.state.enrollments.find(row => row.tokenHash.startsWith(input.tid));
|
|
673
|
+
if (row)
|
|
674
|
+
return `${path === RUNTIME_ENROLL_PATH ? "enroll" : "hello-id"}:${row.id}`;
|
|
675
|
+
}
|
|
676
|
+
if (path === RUNTIME_ENROLL_HELLO_PATH)
|
|
677
|
+
return `enroll-hello:${req.socket.remoteAddress ?? "unknown"}`;
|
|
678
|
+
if (path === RUNTIME_PAIR_PATH && text(input.code, 32)) {
|
|
679
|
+
const code = input.code.replaceAll("-", "").toUpperCase();
|
|
680
|
+
const row = this.state.pairings.find(row => row.expiresAt > this.now() && equal(code, row.codeHash));
|
|
681
|
+
if (row)
|
|
682
|
+
return `pair:${row.id}`;
|
|
683
|
+
}
|
|
684
|
+
if (path === RUNTIME_CLAIM_PATH && text(input.claimSecret, 128)) {
|
|
685
|
+
const row = this.state.machines.find(row => row.machine.id === input.machineId && row.claimHash && row.claimExpiresAt > this.now()
|
|
686
|
+
&& row.machine.status !== "revoked" && equal(input.claimSecret, row.claimHash));
|
|
687
|
+
if (row)
|
|
688
|
+
return `claim:${row.machine.id}`;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return `invalid:${req.socket.remoteAddress ?? "unknown"}`;
|
|
692
|
+
}
|
|
693
|
+
rotateCredential(auth, input) {
|
|
694
|
+
const row = this.credentialOwner(auth);
|
|
695
|
+
if (!row || !record(input) || Object.keys(input).some(key => !["machineId", "credential"].includes(key))
|
|
696
|
+
|| input.machineId !== row.machine.id || typeof input.credential !== "string" || !/^[a-f0-9]{64}$/.test(input.credential))
|
|
697
|
+
throw Error("Invalid runtime credential rotation");
|
|
698
|
+
if (!equal(input.credential, row.credentialHash)) {
|
|
699
|
+
const before = { credentialHash: row.credentialHash, status: row.machine.status };
|
|
700
|
+
row.credentialHash = hash(input.credential);
|
|
701
|
+
row.machine.status = "offline";
|
|
702
|
+
try {
|
|
703
|
+
this.save();
|
|
704
|
+
}
|
|
705
|
+
catch (error) {
|
|
706
|
+
row.credentialHash = before.credentialHash;
|
|
707
|
+
row.machine.status = before.status;
|
|
708
|
+
throw error;
|
|
709
|
+
}
|
|
710
|
+
const connection = this.connections.get(row.machine.id);
|
|
711
|
+
if (connection) {
|
|
712
|
+
this.connections.delete(row.machine.id);
|
|
713
|
+
this.rejectPending(connection, "Runtime credential rotated; reconnect to reconcile");
|
|
714
|
+
connection.ws.close(1012, "Credential rotated");
|
|
715
|
+
}
|
|
716
|
+
this.emit({ type: "machine", machineId: row.machine.id });
|
|
717
|
+
}
|
|
718
|
+
return { machineId: row.machine.id, status: "rotated" };
|
|
719
|
+
}
|
|
720
|
+
handlePublicRequest(req, res, url) {
|
|
721
|
+
if (![RUNTIME_PAIR_PATH, RUNTIME_CLAIM_PATH, RUNTIME_ROTATE_PATH, RUNTIME_ENROLL_HELLO_PATH, RUNTIME_ENROLL_PATH].includes(url.pathname))
|
|
722
|
+
return false;
|
|
723
|
+
const answer = (status, body) => { if (!res.destroyed && !res.writableEnded) {
|
|
724
|
+
res.writeHead(status, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
725
|
+
res.end(JSON.stringify(body));
|
|
726
|
+
} };
|
|
727
|
+
if (this.closed || req.method !== "POST" || url.search || !privateTransport(req)) {
|
|
728
|
+
answer(403, { error: "Runtime pairing requires a protected non-browser connection" });
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
let charged = false;
|
|
732
|
+
void readBoundedWebBody(req, 4096).then(bytes => {
|
|
733
|
+
const value = JSON.parse(bytes.toString("utf8"));
|
|
734
|
+
if (this.closed) {
|
|
735
|
+
answer(403, { error: "Runtime coordinator is closed" });
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
const key = this.requestRateKey(url.pathname, value, req);
|
|
739
|
+
charged = true;
|
|
740
|
+
if (!this.rate(key, key.startsWith("claim:") || key.startsWith("enroll-hello:") ? 120 : 30)) {
|
|
741
|
+
if (url.pathname === RUNTIME_ENROLL_PATH || url.pathname === RUNTIME_ENROLL_HELLO_PATH)
|
|
742
|
+
this.noteThrottled(key, url.pathname === RUNTIME_ENROLL_PATH ? "enroll" : "hello", req.socket.remoteAddress);
|
|
743
|
+
answer(429, { error: "Too many runtime pairing requests" });
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
if (url.pathname === RUNTIME_ROTATE_PATH) {
|
|
747
|
+
if (!this.credentialOwner(req.headers.authorization)) {
|
|
748
|
+
answer(401, { error: "Runtime credential was refused" });
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
answer(200, this.rotateCredential(req.headers.authorization, value));
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
if (url.pathname === RUNTIME_ENROLL_HELLO_PATH) {
|
|
755
|
+
answer(200, this.enrollHello(value));
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
if (url.pathname === RUNTIME_ENROLL_PATH) {
|
|
759
|
+
answer(201, this.enrollSealed(value, { remote: req.socket.remoteAddress }));
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
if (url.pathname === RUNTIME_PAIR_PATH)
|
|
763
|
+
answer(201, this.pair(value));
|
|
764
|
+
else {
|
|
765
|
+
const result = this.claim(value);
|
|
766
|
+
answer(result.status === "pending" ? 202 : 200, result);
|
|
767
|
+
}
|
|
768
|
+
}).catch((error) => {
|
|
769
|
+
const allowed = charged || this.rate(`invalid:${req.socket.remoteAddress ?? "unknown"}`, 30);
|
|
770
|
+
// A refused enrollment says why (a closed word and a fixed sentence, never the token); every other failure keeps the one generic answer.
|
|
771
|
+
if (allowed && error instanceof RuntimeEnrollError) {
|
|
772
|
+
answer(error.reason === "invalid" ? 400 : error.reason === "limit" ? 409 : 403, { error: error.message, reason: error.reason });
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
answer(allowed ? 400 : 429, { error: "Runtime pairing request is invalid, expired or already used" });
|
|
776
|
+
});
|
|
777
|
+
return true;
|
|
778
|
+
}
|
|
779
|
+
handleUpgrade(req, socket, head) {
|
|
780
|
+
let url;
|
|
781
|
+
try {
|
|
782
|
+
url = new URL(req.url ?? "", "http://localhost");
|
|
783
|
+
}
|
|
784
|
+
catch {
|
|
785
|
+
return false;
|
|
786
|
+
}
|
|
787
|
+
if (url.pathname !== RUNTIME_CONNECT_PATH)
|
|
788
|
+
return false;
|
|
789
|
+
const refuse = () => { socket.end("HTTP/1.1 401 Unauthorized\r\nConnection: close\r\nContent-Length: 0\r\n\r\n"); };
|
|
790
|
+
const auth = req.headers.authorization;
|
|
791
|
+
if (this.closed || req.method !== "GET" || url.search || !privateTransport(req) || typeof auth !== "string" || !/^Bearer [a-f0-9]{64}$/i.test(auth)) {
|
|
792
|
+
refuse();
|
|
793
|
+
return true;
|
|
794
|
+
}
|
|
795
|
+
const row = this.credentialOwner(auth);
|
|
796
|
+
if (!row) {
|
|
797
|
+
refuse();
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
800
|
+
this.server.handleUpgrade(req, socket, head, ws => this.attach(ws, row));
|
|
801
|
+
return true;
|
|
802
|
+
}
|
|
803
|
+
current(connection) { return !this.closed && this.connections.get(connection.machineId) === connection && this.entry(connection.machineId).machine.status !== "revoked"; }
|
|
804
|
+
attach(ws, row) {
|
|
805
|
+
const old = this.connections.get(row.machine.id);
|
|
806
|
+
if (old) {
|
|
807
|
+
this.rejectPending(old, "Runtime connection was replaced; execution must be reconciled");
|
|
808
|
+
this.options.warn?.({ machineId: row.machine.id, code: 1008, reason: "Connection replaced" }, "Runtime connection closed because the same machine credential connected again");
|
|
809
|
+
old.ws.close(1008, "Connection replaced");
|
|
810
|
+
}
|
|
811
|
+
row.machine.generation++;
|
|
812
|
+
row.machine.status = "offline";
|
|
813
|
+
this.save();
|
|
814
|
+
const activity = this.machineActivity.get(row.machine.id) ?? new RuntimeUpdateActivity();
|
|
815
|
+
this.machineActivity.set(row.machine.id, activity);
|
|
816
|
+
const connection = { ws, machineId: row.machine.id, generation: row.machine.generation, ready: false, alive: true, activity, helloTimer: setTimeout(() => ws.close(1008, "Runtime hello required"), 10_000) };
|
|
817
|
+
connection.helloTimer.unref();
|
|
818
|
+
this.connections.set(row.machine.id, connection);
|
|
819
|
+
ws.on("pong", () => { connection.alive = true; if (this.current(connection))
|
|
820
|
+
row.machine.lastSeenAt = this.now(); });
|
|
821
|
+
ws.on("message", (data, binary) => {
|
|
822
|
+
if (binary) {
|
|
823
|
+
ws.close(1008, "Runtime requires JSON text frames");
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
void this.message(connection, data).catch(error => {
|
|
827
|
+
// The cause (a static validation message) goes to the log and, trimmed, to the runtime so its terminal can show it.
|
|
828
|
+
const reason = error instanceof RuntimeProtocolError ? `Invalid runtime message: ${error.message}`.replace(/[^ -~]/g, "?").slice(0, 120) : "Invalid runtime message";
|
|
829
|
+
this.options.warn?.({ machineId: connection.machineId, code: 1008, reason, detail: error instanceof Error ? error.message : String(error) }, "Runtime connection closed because of an invalid runtime message");
|
|
830
|
+
ws.close(1008, reason);
|
|
831
|
+
});
|
|
832
|
+
});
|
|
833
|
+
ws.on("error", () => { });
|
|
834
|
+
ws.on("close", () => {
|
|
835
|
+
clearTimeout(connection.helloTimer);
|
|
836
|
+
if (this.connections.get(row.machine.id) !== connection)
|
|
837
|
+
return;
|
|
838
|
+
this.connections.delete(row.machine.id);
|
|
839
|
+
this.rejectPending(connection, "Runtime disconnected; reconcile before retrying");
|
|
840
|
+
if (row.machine.status !== "revoked")
|
|
841
|
+
row.machine.status = "offline";
|
|
842
|
+
this.save();
|
|
843
|
+
this.emit({ type: "machine", machineId: row.machine.id });
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
send(connection, value) {
|
|
847
|
+
if (!this.current(connection) || connection.ws.readyState !== WebSocket.OPEN)
|
|
848
|
+
throw Error("Runtime machine is offline");
|
|
849
|
+
const frame = JSON.stringify(value);
|
|
850
|
+
if (Buffer.byteLength(frame) > RUNTIME_MAX_FRAME_BYTES)
|
|
851
|
+
throw Error("Runtime response exceeds the frame limit");
|
|
852
|
+
if (connection.ws.bufferedAmount > RUNTIME_MAX_FRAME_BYTES * 2) {
|
|
853
|
+
connection.ws.close(1013, "Runtime backpressure");
|
|
854
|
+
throw Error("Runtime connection is too slow");
|
|
855
|
+
}
|
|
856
|
+
connection.ws.send(frame);
|
|
857
|
+
}
|
|
858
|
+
rejectPending(connection, reason) {
|
|
859
|
+
connection.update?.fence.release();
|
|
860
|
+
connection.update = undefined;
|
|
861
|
+
for (const [id, pending] of this.panePending)
|
|
862
|
+
if (pending.machineId === connection.machineId && pending.generation === connection.generation) {
|
|
863
|
+
this.panePending.delete(id);
|
|
864
|
+
clearTimeout(pending.timer);
|
|
865
|
+
pending.reject(Error(reason));
|
|
866
|
+
}
|
|
867
|
+
for (const [id, pending] of this.accountPending)
|
|
868
|
+
if (pending.machineId === connection.machineId && pending.generation === connection.generation) {
|
|
869
|
+
this.accountPending.delete(id);
|
|
870
|
+
clearTimeout(pending.timer);
|
|
871
|
+
pending.reject(Error(reason));
|
|
872
|
+
}
|
|
873
|
+
let changed = false;
|
|
874
|
+
for (const [id, pending] of this.pending)
|
|
875
|
+
if (pending.machineId === connection.machineId && pending.generation === connection.generation) {
|
|
876
|
+
this.pending.delete(id);
|
|
877
|
+
clearTimeout(pending.timer);
|
|
878
|
+
const command = this.state.commands.find(row => row.id === id);
|
|
879
|
+
if (command?.state === "pending") {
|
|
880
|
+
command.state = interrupted(command);
|
|
881
|
+
command.error = reason;
|
|
882
|
+
changed = true;
|
|
883
|
+
}
|
|
884
|
+
pending.reject(Error(reason));
|
|
885
|
+
}
|
|
886
|
+
if (changed)
|
|
887
|
+
this.save();
|
|
888
|
+
}
|
|
889
|
+
validateTask(command, value) {
|
|
890
|
+
if (command.operation !== "run" || !record(command.payload) || !record(command.payload.task) || !record(value))
|
|
891
|
+
throw new RuntimeProtocolError("Unexpected runtime task");
|
|
892
|
+
const input = command.payload.task;
|
|
893
|
+
if (value.id !== input.requestId || value.cli !== input.cli || value.cwd !== input.cwd || value.sandbox !== input.sandbox || (value.model ?? "") !== (input.model ?? "")
|
|
894
|
+
|| !["starting", "running", "cancelling", "completed", "failed", "cancelled"].includes(String(value.status))
|
|
895
|
+
|| typeof value.startedAt !== "number" || !Number.isFinite(value.startedAt) || typeof value.output !== "string" || value.output.length > 64 * 1024
|
|
896
|
+
|| value.finishedAt !== undefined && (typeof value.finishedAt !== "number" || !Number.isFinite(value.finishedAt))
|
|
897
|
+
|| ["completed", "failed", "cancelled"].includes(String(value.status)) && (typeof value.finishedAt !== "number" || typeof value.outcomeConfirmed !== "boolean")
|
|
898
|
+
|| value.error !== undefined && (typeof value.error !== "string" || value.error.length > 8192)
|
|
899
|
+
|| value.threadId !== undefined && !text(value.threadId, 256)
|
|
900
|
+
|| value.threadId !== undefined && command.payload.resumeSessionId !== undefined && value.threadId !== command.payload.resumeSessionId
|
|
901
|
+
|| value.outcomeConfirmed !== undefined && typeof value.outcomeConfirmed !== "boolean")
|
|
902
|
+
throw new RuntimeProtocolError("Invalid runtime task snapshot");
|
|
903
|
+
return { id: value.id, cli: value.cli, cwd: value.cwd, sandbox: value.sandbox, ...(value.model ? { model: value.model } : {}),
|
|
904
|
+
status: value.status, startedAt: value.startedAt, output: value.output,
|
|
905
|
+
...(value.finishedAt !== undefined ? { finishedAt: value.finishedAt } : {}), ...(value.error ? { error: value.error } : {}), ...(value.threadId ? { threadId: value.threadId } : {}), ...(value.outcomeConfirmed !== undefined ? { outcomeConfirmed: value.outcomeConfirmed } : {}) };
|
|
906
|
+
}
|
|
907
|
+
admitting(connection) {
|
|
908
|
+
return connection.ready && !connection.update && connection.activity.accepting && this.current(connection)
|
|
909
|
+
&& this.entry(connection.machineId).machine.status === "online" && connection.ws.readyState === WebSocket.OPEN;
|
|
910
|
+
}
|
|
911
|
+
updateIdle(connection) {
|
|
912
|
+
const machine = connection.machineId;
|
|
913
|
+
return connection.activity.pending === 0 && !this.hasActiveTask(machine) && connection.ws.bufferedAmount === 0
|
|
914
|
+
&& ![...this.pending.values(), ...this.panePending.values()].some(pending => pending.machineId === machine)
|
|
915
|
+
&& ![...this.paneToolPending].some(key => key.startsWith(`${machine}:`));
|
|
916
|
+
}
|
|
917
|
+
/** Trial metadata is staged until activation: no online event or probe can admit work early. */
|
|
918
|
+
promoteRuntime(connection) {
|
|
919
|
+
const row = this.entry(connection.machineId), hello = connection.hello;
|
|
920
|
+
row.machine.bootId = connection.bootId;
|
|
921
|
+
row.machine.status = "online";
|
|
922
|
+
row.machine.lastSeenAt = this.now();
|
|
923
|
+
// A new boot has not yet reported status. Never carry an old boot's "current" label into it.
|
|
924
|
+
delete row.machine.updateReport;
|
|
925
|
+
if (hello.runtimeInfo)
|
|
926
|
+
row.machine.runtimeInfo = hello.runtimeInfo;
|
|
927
|
+
else
|
|
928
|
+
delete row.machine.runtimeInfo;
|
|
929
|
+
if (hello.paneProtocol === 1)
|
|
930
|
+
row.machine.paneProtocol = 1;
|
|
931
|
+
else
|
|
932
|
+
delete row.machine.paneProtocol;
|
|
933
|
+
if (hello.inventory !== undefined) {
|
|
934
|
+
row.machine.inventory = hello.inventory;
|
|
935
|
+
row.machine.inventoryUpdatedAt = this.now();
|
|
936
|
+
}
|
|
937
|
+
this.save();
|
|
938
|
+
}
|
|
939
|
+
updateControl(connection, value) {
|
|
940
|
+
if (!connection.ready || !connection.managedUpdate)
|
|
941
|
+
throw new RuntimeProtocolError("Runtime update was not negotiated");
|
|
942
|
+
const control = parseRuntimeUpdateControl(value, "client");
|
|
943
|
+
const reply = (phase) => this.send(connection, { v: 1, type: "update.control", id: control.id, bootId: connection.bootId, generation: connection.generation, phase });
|
|
944
|
+
if (control.bootId !== connection.bootId || control.generation !== connection.generation) {
|
|
945
|
+
reply("cancelled");
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
const owned = connection.update;
|
|
949
|
+
if (owned?.phase === "trial") {
|
|
950
|
+
if (control.phase !== "activate" || owned.id !== control.id) {
|
|
951
|
+
reply("busy");
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
if (!owned.fence.current() || !this.updateIdle(connection)) {
|
|
955
|
+
reply("busy");
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
// The supervisor has persisted its activation intent. Lost acknowledgement is uncertain, never rollback permission.
|
|
959
|
+
owned.fence.release();
|
|
960
|
+
connection.update = undefined;
|
|
961
|
+
connection.activatedUpdateId = control.id;
|
|
962
|
+
this.promoteRuntime(connection);
|
|
963
|
+
reply("activated");
|
|
964
|
+
this.emit({ type: "machine", machineId: connection.machineId });
|
|
965
|
+
if (!inventoryProbed(this.entry(connection.machineId).machine.inventory))
|
|
966
|
+
void this.call(connection.machineId, "probe", { force: true }).catch(() => { });
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
if (control.phase === "activate" && connection.activatedUpdateId === control.id) {
|
|
970
|
+
reply("activated");
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
if (control.phase === "prepare") {
|
|
974
|
+
if (owned) {
|
|
975
|
+
reply(owned.id === control.id ? owned.phase === "committed" ? "commit" : "prepared" : "busy");
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
const fence = connection.activity.tryFence(control.id, () => this.current(connection) && connection.ready && connection.ws.readyState === WebSocket.OPEN, () => this.updateIdle(connection));
|
|
979
|
+
if (!fence) {
|
|
980
|
+
reply("busy");
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
connection.update = { id: control.id, phase: "prepared", fence };
|
|
984
|
+
reply("prepared");
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
if (!owned || owned.id !== control.id) {
|
|
988
|
+
reply("cancelled");
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
if (owned.phase === "committed") {
|
|
992
|
+
reply("commit");
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
if (control.phase === "ready" && owned.fence.current() && this.updateIdle(connection)) {
|
|
996
|
+
owned.phase = "committed";
|
|
997
|
+
reply("commit");
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
// A cancellation/busy reply is queued before admitting any later request on this ordered connection.
|
|
1001
|
+
reply(control.phase === "ready" ? "busy" : "cancelled");
|
|
1002
|
+
owned.fence.release();
|
|
1003
|
+
connection.update = undefined;
|
|
1004
|
+
}
|
|
1005
|
+
async message(connection, raw) {
|
|
1006
|
+
if (!this.current(connection))
|
|
1007
|
+
return;
|
|
1008
|
+
const value = JSON.parse(raw.toString());
|
|
1009
|
+
if (!record(value) || value.v !== 1 || !text(value.type, 32))
|
|
1010
|
+
throw new RuntimeProtocolError("Invalid runtime frame");
|
|
1011
|
+
const row = this.entry(connection.machineId);
|
|
1012
|
+
connection.alive = true;
|
|
1013
|
+
if (value.type === "update.control") {
|
|
1014
|
+
this.updateControl(connection, value);
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
if (!connection.ready) {
|
|
1018
|
+
if (value.type !== "hello" || !text(value.bootId, 128))
|
|
1019
|
+
throw new RuntimeProtocolError("Runtime hello required");
|
|
1020
|
+
const runtimeInfo = parseRuntimeInfo(value.runtimeInfo);
|
|
1021
|
+
if (runtimeInfo && !runtimeInfoCompatible(runtimeInfo)) {
|
|
1022
|
+
// Version skew fails clearly: no welcome, no work, and the Runtime is told to run the install command again. Its report is
|
|
1023
|
+
// kept (it stays offline) so Settings can show which version needs reinstalling; the pairing itself is untouched.
|
|
1024
|
+
row.machine.runtimeInfo = runtimeInfo;
|
|
1025
|
+
row.machine.lastSeenAt = this.now();
|
|
1026
|
+
this.save();
|
|
1027
|
+
this.emit({ type: "machine", machineId: connection.machineId });
|
|
1028
|
+
this.options.warn?.({ machineId: connection.machineId, code: 1008, reason: "Runtime incompatible", detail: `version ${runtimeInfo.version ?? "unknown"}, protocols ${runtimeInfo.protocolVersions.join(",")}, capabilities ${runtimeInfo.capabilities.join(",")}` }, "Runtime connection refused: its version is not compatible with this AgEnD");
|
|
1029
|
+
connection.ws.close(1008, RUNTIME_REINSTALL_CLOSE_REASON);
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
const managed = runtimeInfo?.capabilities.includes(RUNTIME_MANAGED_UPDATE_CAPABILITY) === true;
|
|
1033
|
+
if (managed && !validRuntimeUpdateId(value.bootId) || value.updateTrialId !== undefined && (!managed || !validRuntimeUpdateId(value.updateTrialId)))
|
|
1034
|
+
throw new RuntimeProtocolError("Invalid Runtime update handshake");
|
|
1035
|
+
const reportedInventory = value.inventory === undefined ? undefined : inventory(value.inventory);
|
|
1036
|
+
connection.bootId = value.bootId;
|
|
1037
|
+
connection.managedUpdate = managed;
|
|
1038
|
+
connection.updateStatusProtocol = runtimeInfo?.capabilities.includes(RUNTIME_UPDATE_STATUS_CAPABILITY) === true;
|
|
1039
|
+
if (connection.updateStatusProtocol && !validRuntimeUpdateId(value.bootId))
|
|
1040
|
+
throw new RuntimeProtocolError("Invalid Runtime status handshake");
|
|
1041
|
+
connection.hello = { runtimeInfo, ...(value.paneProtocol === 1 ? { paneProtocol: 1 } : {}), inventory: reportedInventory };
|
|
1042
|
+
if (value.updateTrialId !== undefined) {
|
|
1043
|
+
const fence = connection.activity.tryFence(value.updateTrialId, () => this.current(connection), () => this.updateIdle(connection));
|
|
1044
|
+
if (!fence)
|
|
1045
|
+
throw new RuntimeProtocolError("Runtime update trial is busy");
|
|
1046
|
+
connection.update = { id: value.updateTrialId, phase: "trial", fence };
|
|
1047
|
+
}
|
|
1048
|
+
connection.ready = true;
|
|
1049
|
+
clearTimeout(connection.helloTimer);
|
|
1050
|
+
if (!connection.update)
|
|
1051
|
+
this.promoteRuntime(connection);
|
|
1052
|
+
this.send(connection, { v: 1, type: "welcome", machineId: connection.machineId, generation: connection.generation, ...(managed ? { updateProtocol: 1 } : {}), ...(connection.updateStatusProtocol ? { updateStatusProtocol: 1 } : {}) });
|
|
1053
|
+
if (connection.update)
|
|
1054
|
+
return; // A trial has authenticated, but cannot receive tasks or an automatic CLI probe.
|
|
1055
|
+
this.emit({ type: "machine", machineId: connection.machineId });
|
|
1056
|
+
// alpha.2 polish (dev-claude's no-chat e2e): a runner that brings no CLI inventory (just paired, nothing detected
|
|
1057
|
+
// yet) is asked for its own report now — its detection runs on that PC, never on this fleet's loop — so the first
|
|
1058
|
+
// approval of an agent's request there is not refused for "no available CLI" until someone presses Refresh.
|
|
1059
|
+
// (#3004 rig: the runner's hello may carry a placeholder — `probedAt: null`, no CLIs — which is no report either.)
|
|
1060
|
+
// (#3005 rig recheck: `force` — without it the runner answers with its cached inventory, on a fresh profile the same
|
|
1061
|
+
// placeholder; Refresh sends force, and so does this: detection runs on that PC.)
|
|
1062
|
+
if (!inventoryProbed(row.machine.inventory))
|
|
1063
|
+
void this.call(connection.machineId, "probe", { force: true }).catch(() => { });
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
row.machine.lastSeenAt = this.now();
|
|
1067
|
+
if (connection.update?.phase === "trial")
|
|
1068
|
+
throw new RuntimeProtocolError("Runtime update trial has not activated");
|
|
1069
|
+
if (value.type === "update.status") {
|
|
1070
|
+
const report = parseRuntimeUpdateStatusFrame(value);
|
|
1071
|
+
if (!connection.updateStatusProtocol || report.bootId !== connection.bootId || report.generation !== connection.generation)
|
|
1072
|
+
throw new RuntimeProtocolError("Runtime status belongs to another connection");
|
|
1073
|
+
if (JSON.stringify(row.machine.updateReport?.status) === JSON.stringify(report.status))
|
|
1074
|
+
return;
|
|
1075
|
+
const now = this.now(), allowance = connection.statusAllowance;
|
|
1076
|
+
const tokens = allowance ? Math.min(8, allowance.tokens + Math.max(0, now - allowance.at) / 5000) : 8;
|
|
1077
|
+
if (tokens < 1)
|
|
1078
|
+
return; // Diagnostic churn cannot force unbounded writes or hold task admission.
|
|
1079
|
+
connection.statusAllowance = { at: now, tokens: tokens - 1 };
|
|
1080
|
+
row.machine.updateReport = { bootId: report.bootId, generation: report.generation, reportedAt: now, status: report.status };
|
|
1081
|
+
this.save();
|
|
1082
|
+
this.emit({ type: "machine", machineId: connection.machineId });
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
if (value.type === "pane.tool.request") {
|
|
1086
|
+
if (row.machine.paneProtocol !== 1 || Object.keys(value).some(key => !["v", "type", "id", "body"].includes(key)) || !UUID.test(String(value.id)))
|
|
1087
|
+
throw new RuntimeProtocolError("Invalid pane MCP transport request");
|
|
1088
|
+
const body = validatePaneMcpBody(value.body), id = value.id;
|
|
1089
|
+
const key = `${connection.machineId}:${connection.generation}:${id}`;
|
|
1090
|
+
if (this.paneToolPending.size >= 128 || this.paneToolPending.has(key))
|
|
1091
|
+
throw new RuntimeProtocolError("Pane MCP transport backlog or duplicate request");
|
|
1092
|
+
let active = true;
|
|
1093
|
+
const current = () => active && !this.closed && this.current(connection) && connection.ready && connection.ws.readyState === WebSocket.OPEN;
|
|
1094
|
+
this.paneToolPending.add(key);
|
|
1095
|
+
let timer;
|
|
1096
|
+
try {
|
|
1097
|
+
if (!current() || !this.options.handlePaneMcp || !connection.activity.accepting || connection.activity.pending >= 128)
|
|
1098
|
+
throw new RuntimeProtocolError("Pane MCP scope unavailable");
|
|
1099
|
+
// The activity token belongs to the underlying handler, not the deadline race that may finish first.
|
|
1100
|
+
const physical = connection.activity.run(() => this.options.handlePaneMcp(connection.machineId, body, current));
|
|
1101
|
+
const result = await Promise.race([physical, new Promise((_resolve, reject) => {
|
|
1102
|
+
timer = setTimeout(() => { active = false; reject(Error("Pane MCP deadline")); }, 80_000);
|
|
1103
|
+
timer.unref();
|
|
1104
|
+
})]);
|
|
1105
|
+
if (current())
|
|
1106
|
+
this.send(connection, { v: 1, type: "pane.tool.result", id, ok: true, result });
|
|
1107
|
+
}
|
|
1108
|
+
catch {
|
|
1109
|
+
if (current())
|
|
1110
|
+
this.send(connection, { v: 1, type: "pane.tool.result", id, ok: false });
|
|
1111
|
+
}
|
|
1112
|
+
finally {
|
|
1113
|
+
active = false;
|
|
1114
|
+
clearTimeout(timer);
|
|
1115
|
+
this.paneToolPending.delete(key);
|
|
1116
|
+
}
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
if (value.type === "pane.output") {
|
|
1120
|
+
if (row.machine.paneProtocol !== 1)
|
|
1121
|
+
throw new RuntimeProtocolError("Pane protocol was not negotiated");
|
|
1122
|
+
const snapshot = validateRuntimePaneSnapshot(value.snapshot);
|
|
1123
|
+
this.emit({ type: "pane", machineId: connection.machineId, pane: snapshot });
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
if (value.type === "pane.response") {
|
|
1127
|
+
if (row.machine.paneProtocol !== 1 || !UUID.test(String(value.id)) || typeof value.ok !== "boolean")
|
|
1128
|
+
throw new RuntimeProtocolError("Invalid pane transport response");
|
|
1129
|
+
const pending = this.panePending.get(value.id);
|
|
1130
|
+
if (!pending)
|
|
1131
|
+
return; // A late reply proves nothing and never replays a command.
|
|
1132
|
+
if (pending.machineId !== connection.machineId || pending.generation !== connection.generation)
|
|
1133
|
+
throw new RuntimeProtocolError("Pane response belongs to another connection");
|
|
1134
|
+
this.panePending.delete(value.id);
|
|
1135
|
+
clearTimeout(pending.timer);
|
|
1136
|
+
if (value.ok)
|
|
1137
|
+
pending.resolve(value.result);
|
|
1138
|
+
else
|
|
1139
|
+
pending.reject(Error(typeof value.error === "string" ? value.error.slice(0, 1000) : "Pane operation failed"));
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
if (value.type === "account.response") {
|
|
1143
|
+
if (!UUID.test(String(value.id)) || typeof value.ok !== "boolean")
|
|
1144
|
+
throw new RuntimeProtocolError("Invalid account transport response");
|
|
1145
|
+
const pending = this.accountPending.get(value.id);
|
|
1146
|
+
if (!pending)
|
|
1147
|
+
return; // A late reply proves nothing and is never replayed.
|
|
1148
|
+
if (pending.machineId !== connection.machineId || pending.generation !== connection.generation)
|
|
1149
|
+
throw new RuntimeProtocolError("Account response belongs to another connection");
|
|
1150
|
+
this.accountPending.delete(value.id);
|
|
1151
|
+
clearTimeout(pending.timer);
|
|
1152
|
+
// Nothing of the result or the error is logged or stored here; the error is shown to the administrator who asked, in a fixed length and without control characters.
|
|
1153
|
+
if (value.ok)
|
|
1154
|
+
pending.resolve(value.result);
|
|
1155
|
+
else
|
|
1156
|
+
pending.reject(Error(typeof value.error === "string" ? value.error.replace(/[\u0000-\u001f\u007f]/g, " ").slice(0, 400) : "The operation failed on that computer"));
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
if (value.type === "inventory") {
|
|
1160
|
+
row.machine.inventory = inventory(value.inventory);
|
|
1161
|
+
row.machine.inventoryUpdatedAt = this.now();
|
|
1162
|
+
this.save();
|
|
1163
|
+
this.emit({ type: "machine", machineId: connection.machineId });
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
if (value.type === "task") {
|
|
1167
|
+
if (!record(value.task) || !Number.isSafeInteger(value.seq) || value.seq < 1)
|
|
1168
|
+
throw new RuntimeProtocolError("Invalid runtime task event");
|
|
1169
|
+
const taskValue = value.task;
|
|
1170
|
+
const command = this.state.commands.find(command => command.id === taskValue.id && command.machineId === connection.machineId && command.operation === "run");
|
|
1171
|
+
if (!command) {
|
|
1172
|
+
// #2945 review: a reconnecting runtime republishes what it retained; a run already settled and compacted here
|
|
1173
|
+
// is acknowledged by its tombstone and changes nothing. An unknown id, or another machine's, still closes.
|
|
1174
|
+
if (this.tombstoned(connection.machineId, taskValue.id))
|
|
1175
|
+
return;
|
|
1176
|
+
throw new RuntimeProtocolError("Runtime task does not belong to this machine");
|
|
1177
|
+
}
|
|
1178
|
+
const task = this.validateTask(command, value.task);
|
|
1179
|
+
if (value.seq <= command.seq)
|
|
1180
|
+
return;
|
|
1181
|
+
if (command.task && terminal(command.task) && !terminal(task))
|
|
1182
|
+
throw new RuntimeProtocolError("Runtime task cannot restart");
|
|
1183
|
+
command.seq = value.seq;
|
|
1184
|
+
command.task = task;
|
|
1185
|
+
command.state = "accepted";
|
|
1186
|
+
this.save();
|
|
1187
|
+
this.emit({ type: "task", machineId: connection.machineId, task });
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
if (value.type === "response") {
|
|
1191
|
+
if (!text(value.id, 128) || typeof value.ok !== "boolean")
|
|
1192
|
+
throw new RuntimeProtocolError("Invalid runtime response");
|
|
1193
|
+
const pending = this.pending.get(value.id), command = this.state.commands.find(command => command.id === value.id);
|
|
1194
|
+
if (!command || command.machineId !== connection.machineId) {
|
|
1195
|
+
if (!command && this.tombstoned(connection.machineId, value.id))
|
|
1196
|
+
return;
|
|
1197
|
+
throw new RuntimeProtocolError("Runtime response does not belong to this machine");
|
|
1198
|
+
}
|
|
1199
|
+
if (!pending || pending.generation !== connection.generation)
|
|
1200
|
+
return;
|
|
1201
|
+
this.pending.delete(value.id);
|
|
1202
|
+
clearTimeout(pending.timer);
|
|
1203
|
+
try {
|
|
1204
|
+
if (!value.ok) {
|
|
1205
|
+
command.state = "failed";
|
|
1206
|
+
command.error = typeof value.error === "string" ? value.error.slice(0, 1024) : "Runtime request failed";
|
|
1207
|
+
this.save();
|
|
1208
|
+
pending.reject(Error(command.error));
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
let result = value.result;
|
|
1212
|
+
if (command.operation === "probe") {
|
|
1213
|
+
result = inventory(result);
|
|
1214
|
+
row.machine.inventory = result;
|
|
1215
|
+
row.machine.inventoryUpdatedAt = this.now();
|
|
1216
|
+
}
|
|
1217
|
+
if (command.operation === "run") {
|
|
1218
|
+
const task = this.validateTask(command, result);
|
|
1219
|
+
if (!command.task || !terminal(command.task))
|
|
1220
|
+
command.task = task;
|
|
1221
|
+
result = command.task;
|
|
1222
|
+
}
|
|
1223
|
+
command.state = "accepted";
|
|
1224
|
+
command.result = result;
|
|
1225
|
+
this.save();
|
|
1226
|
+
if (command.task)
|
|
1227
|
+
this.emit({ type: "task", machineId: connection.machineId, task: command.task });
|
|
1228
|
+
else if (command.operation === "probe")
|
|
1229
|
+
this.emit({ type: "machine", machineId: connection.machineId });
|
|
1230
|
+
pending.resolve(structuredClone(result));
|
|
1231
|
+
}
|
|
1232
|
+
catch (error) {
|
|
1233
|
+
command.state = "uncertain";
|
|
1234
|
+
this.save();
|
|
1235
|
+
pending.reject(error instanceof Error ? error : Error("Invalid runtime response"));
|
|
1236
|
+
throw error;
|
|
1237
|
+
}
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
if (value.type === "tool.call") {
|
|
1241
|
+
if (!text(value.id, 128) || !text(value.runId, 128))
|
|
1242
|
+
throw new RuntimeProtocolError("Invalid runtime tool call");
|
|
1243
|
+
const command = this.state.commands.find(command => command.id === value.runId && command.machineId === connection.machineId && command.operation === "run");
|
|
1244
|
+
try {
|
|
1245
|
+
if (!connection.activity.accepting || connection.activity.pending >= 128 || !command || !record(command.payload) || !record(command.payload.mcp) || command.task && terminal(command.task) || !this.options.handleMcp)
|
|
1246
|
+
throw new RuntimeProtocolError("Runtime tool call has no active turn");
|
|
1247
|
+
const body = value.body;
|
|
1248
|
+
if (!record(body) || Object.keys(body).some(key => !["op", "method", "params", "callId"].includes(key))
|
|
1249
|
+
|| body.op !== "native-mcp" || !record(body.params) || Buffer.byteLength(JSON.stringify(body)) > 64 * 1024)
|
|
1250
|
+
throw new RuntimeProtocolError("Invalid runtime MCP request");
|
|
1251
|
+
if (body.method === "tools/list") {
|
|
1252
|
+
if (Object.keys(body.params).length || body.callId !== undefined)
|
|
1253
|
+
throw new RuntimeProtocolError("Invalid runtime MCP listing");
|
|
1254
|
+
}
|
|
1255
|
+
else if (body.method === "tools/call") {
|
|
1256
|
+
if (!text(body.callId, 128) || !/^[A-Za-z0-9._:-]+$/.test(body.callId)
|
|
1257
|
+
|| Object.keys(body.params).some(key => !["name", "arguments"].includes(key)) || typeof body.params.name !== "string"
|
|
1258
|
+
|| !Array.isArray(command.payload.mcp.tools) || !command.payload.mcp.tools.includes(body.params.name)
|
|
1259
|
+
|| body.params.arguments !== undefined && !record(body.params.arguments))
|
|
1260
|
+
throw new RuntimeProtocolError("Runtime MCP tool is outside this turn");
|
|
1261
|
+
stable(body.params);
|
|
1262
|
+
}
|
|
1263
|
+
else
|
|
1264
|
+
throw new RuntimeProtocolError("Invalid runtime MCP operation");
|
|
1265
|
+
const result = await connection.activity.run(() => this.options.handleMcp(connection.machineId, value.runId, body));
|
|
1266
|
+
if (!this.current(connection))
|
|
1267
|
+
return;
|
|
1268
|
+
this.send(connection, { v: 1, type: "tool.result", id: value.id, ok: true, result });
|
|
1269
|
+
}
|
|
1270
|
+
catch {
|
|
1271
|
+
if (this.current(connection))
|
|
1272
|
+
this.send(connection, { v: 1, type: "tool.result", id: value.id, ok: false, error: "Runtime tool call was refused or its turn expired" });
|
|
1273
|
+
}
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
throw new RuntimeProtocolError("Unknown runtime message");
|
|
1277
|
+
}
|
|
1278
|
+
tombstoned(machineId, id) {
|
|
1279
|
+
return typeof id === "string" && this.state.tombstones.some(row => row.id === id && row.machineId === machineId);
|
|
1280
|
+
}
|
|
1281
|
+
/** M-2239 P2-1: settled commands to tombstones (see COMMAND_KEEP_MS); never a pending, uncertain or unconfirmed one. */
|
|
1282
|
+
compact() {
|
|
1283
|
+
const now = this.now();
|
|
1284
|
+
const settled = (command) => !this.pending.has(command.id) && (command.state === "failed"
|
|
1285
|
+
|| command.state === "accepted" && (command.operation !== "run" || !!command.task && terminal(command.task) && command.task.outcomeConfirmed === true));
|
|
1286
|
+
const drop = new Set(this.state.commands.filter(command => settled(command) && now - command.createdAt > COMMAND_KEEP_MS));
|
|
1287
|
+
const excess = this.state.commands.length - drop.size - COMMAND_SOFT_CAP;
|
|
1288
|
+
if (excess > 0)
|
|
1289
|
+
for (const command of this.state.commands.filter(command => settled(command) && !drop.has(command)).sort((a, b) => a.createdAt - b.createdAt).slice(0, excess))
|
|
1290
|
+
drop.add(command);
|
|
1291
|
+
if (!drop.size)
|
|
1292
|
+
return;
|
|
1293
|
+
// Room for new tombstones without passing TOMBSTONE_CAP (what the constructor reads back, #2945 review): old ones
|
|
1294
|
+
// past TOMBSTONE_KEEP_MS give way, oldest first; a younger one never does. Commands beyond that room stay as they
|
|
1295
|
+
// are — still refused by id from the journal — until room frees up.
|
|
1296
|
+
const tombstones = this.state.tombstones;
|
|
1297
|
+
const evictable = tombstones.filter(row => now - row.at > TOMBSTONE_KEEP_MS).sort((a, b) => a.at - b.at);
|
|
1298
|
+
const room = TOMBSTONE_CAP - tombstones.length + evictable.length;
|
|
1299
|
+
const moved = [...drop].sort((a, b) => a.createdAt - b.createdAt).slice(0, Math.max(0, room));
|
|
1300
|
+
if (!moved.length)
|
|
1301
|
+
return;
|
|
1302
|
+
const gone = new Set(evictable.slice(0, Math.max(0, tombstones.length + moved.length - TOMBSTONE_CAP)));
|
|
1303
|
+
const movedSet = new Set(moved);
|
|
1304
|
+
this.state.tombstones = [...tombstones.filter(row => !gone.has(row)),
|
|
1305
|
+
...moved.map(command => ({ id: command.id, machineId: command.machineId, digest: command.digest, at: now }))];
|
|
1306
|
+
this.state.commands = this.state.commands.filter(command => !movedSet.has(command));
|
|
1307
|
+
this.save();
|
|
1308
|
+
}
|
|
1309
|
+
task(id) { const task = this.state.commands.find(command => command.id === id && command.operation === "run")?.task; return task ? structuredClone(task) : null; }
|
|
1310
|
+
tasks() { return this.state.commands.flatMap(command => command.operation === "run" && command.task ? [{ machineId: command.machineId, task: structuredClone(command.task) }] : []); }
|
|
1311
|
+
/** Include journaled sends whose acknowledgement is still missing, so reopening diagnostics cannot hide an uncertain run. */
|
|
1312
|
+
diagnosticTasks(machineId) {
|
|
1313
|
+
return this.state.commands.flatMap(command => {
|
|
1314
|
+
if (command.operation !== "run" || command.machineId !== machineId)
|
|
1315
|
+
return [];
|
|
1316
|
+
if (command.task)
|
|
1317
|
+
return [structuredClone(command.task)];
|
|
1318
|
+
let input;
|
|
1319
|
+
try {
|
|
1320
|
+
input = validateNativeTask(command.payload.task);
|
|
1321
|
+
}
|
|
1322
|
+
catch {
|
|
1323
|
+
return [];
|
|
1324
|
+
}
|
|
1325
|
+
const uncertain = command.state === "uncertain", rejected = command.state === "failed";
|
|
1326
|
+
return [{ id: command.id, cli: input.cli, cwd: input.cwd, sandbox: input.sandbox, ...(input.model ? { model: input.model } : {}),
|
|
1327
|
+
startedAt: command.createdAt, status: uncertain || rejected ? "failed" : "starting", output: "",
|
|
1328
|
+
...(rejected ? { outcomeConfirmed: true, error: command.error || "Runtime request failed" } : {}),
|
|
1329
|
+
...(uncertain ? { outcomeConfirmed: false, error: "Remote execution outcome is unconfirmed. Reconnect this runtime to reconcile before sending another task." } : {}) }];
|
|
1330
|
+
}).sort((a, b) => b.startedAt - a.startedAt).slice(0, 20);
|
|
1331
|
+
}
|
|
1332
|
+
hasActiveTask(machineId) { return this.state.commands.some(command => command.machineId === machineId && command.operation === "run" && command.state !== "failed" && (!command.task || !terminal(command.task) || command.task.outcomeConfirmed === false)); }
|
|
1333
|
+
paneTransportEpoch(machineId) {
|
|
1334
|
+
const connection = this.connections.get(machineId);
|
|
1335
|
+
return connection && this.admitting(connection) ? `${this.paneEpoch}:${machineId}:${connection.generation}` : null;
|
|
1336
|
+
}
|
|
1337
|
+
/** Pane input replay/sequence authority lives in its pane ledger; reads never fill the exec-task journal. */
|
|
1338
|
+
async callPane(machineId, raw, maxAgents = 4) {
|
|
1339
|
+
const request = validateRuntimePaneRequest(raw);
|
|
1340
|
+
if (!Number.isInteger(maxAgents) || maxAgents < 1 || maxAgents > 16)
|
|
1341
|
+
throw Error("Invalid machine pane limit");
|
|
1342
|
+
const machine = this.entry(machineId).machine, connection = this.connections.get(machineId);
|
|
1343
|
+
if (this.closed || machine.status !== "online" || machine.paneProtocol !== 1 || !connection || !this.admitting(connection))
|
|
1344
|
+
throw Error("Pane runtime is offline, updating or unsupported");
|
|
1345
|
+
if (this.panePending.size >= 64)
|
|
1346
|
+
throw Error("Pane transport capacity reached");
|
|
1347
|
+
const id = randomUUID();
|
|
1348
|
+
return new Promise((resolve, reject) => {
|
|
1349
|
+
const timer = setTimeout(() => { this.panePending.delete(id); reject(Error("Pane response timed out; reconcile before another input")); }, this.options.requestTimeoutMs ?? 30_000);
|
|
1350
|
+
timer.unref();
|
|
1351
|
+
this.panePending.set(id, { machineId, generation: connection.generation, resolve, reject, timer });
|
|
1352
|
+
try {
|
|
1353
|
+
this.send(connection, { v: 1, type: "pane.request", id, maxAgents, request });
|
|
1354
|
+
}
|
|
1355
|
+
catch (error) {
|
|
1356
|
+
this.panePending.delete(id);
|
|
1357
|
+
clearTimeout(timer);
|
|
1358
|
+
reject(error);
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* #3190 Part 3: one request to a paired computer's account / CLI-install operations, in an `account.request` frame answered by an `account.response`.
|
|
1364
|
+
* Deliberately NOT `call`: `call` writes the request and its answer to the journal on disk, and a sign-in link or one-time code must never be there.
|
|
1365
|
+
* This keeps the pending call in memory only, never calls `save()`, never logs the payload or the result, never replays: a lost answer is lost,
|
|
1366
|
+
* and the person asks again. The payload is checked here in its closed form, and the Runtime must have reported the matching capability.
|
|
1367
|
+
*/
|
|
1368
|
+
async callAccount(machineId, operation, payload, timeoutMs = this.options.requestTimeoutMs ?? 30_000) {
|
|
1369
|
+
if (!isRuntimeRemoteOperation(operation))
|
|
1370
|
+
throw Error("Unsupported runtime operation");
|
|
1371
|
+
const input = parseRuntimeRemotePayload(operation, payload);
|
|
1372
|
+
const machine = this.entry(machineId).machine, connection = this.connections.get(machineId);
|
|
1373
|
+
if (this.closed || machine.status !== "online" || !connection?.ready || !this.current(connection))
|
|
1374
|
+
throw Error("Runtime machine is offline");
|
|
1375
|
+
const needed = operation === "models.refresh" ? "model-catalog-refresh" : operation === "cli.install" ? "cli-install" : operation === "cli.update" ? "cli-update" : "remote-signin";
|
|
1376
|
+
if (!machine.runtimeInfo?.capabilities.includes(needed))
|
|
1377
|
+
throw Error("Update the Runtime on that computer to use this; it does not offer it yet");
|
|
1378
|
+
if (this.accountPending.size >= 16)
|
|
1379
|
+
throw Error("Too many account operations are waiting; try again shortly");
|
|
1380
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < 1000 || timeoutMs > 15 * 60_000)
|
|
1381
|
+
throw Error("Invalid account operation timeout");
|
|
1382
|
+
const id = randomUUID();
|
|
1383
|
+
return new Promise((resolve, reject) => {
|
|
1384
|
+
const timer = setTimeout(() => { this.accountPending.delete(id); reject(Error("That computer did not answer in time")); }, timeoutMs);
|
|
1385
|
+
timer.unref();
|
|
1386
|
+
this.accountPending.set(id, { machineId, generation: connection.generation, resolve, reject, timer });
|
|
1387
|
+
try {
|
|
1388
|
+
this.send(connection, { v: 1, type: "account.request", id, operation, payload: input });
|
|
1389
|
+
}
|
|
1390
|
+
catch (error) {
|
|
1391
|
+
this.accountPending.delete(id);
|
|
1392
|
+
clearTimeout(timer);
|
|
1393
|
+
reject(error);
|
|
1394
|
+
}
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
/** Explicit switch-off only, after owned pane closes. A normal hub close/restart never shuts its hosts down. */
|
|
1398
|
+
async shutdownPaneHosts() {
|
|
1399
|
+
const machines = this.listMachines().filter(machine => machine.status === "online" && machine.paneProtocol === 1);
|
|
1400
|
+
const outcomes = await Promise.allSettled(machines.map(async (machine) => {
|
|
1401
|
+
const raw = await this.callPane(machine.id, { action: "list" });
|
|
1402
|
+
if (!raw || typeof raw.hostBootId !== "string" || !/^[a-f0-9-]{36}$/i.test(raw.hostBootId) || !Array.isArray(raw.panes) || raw.panes.length > 4096)
|
|
1403
|
+
throw Error("Pane shutdown inventory is unconfirmed");
|
|
1404
|
+
if (raw.panes.map(validateRuntimePaneSnapshot).some(pane => pane.state !== "exited"))
|
|
1405
|
+
throw Error("Pane shutdown still has live or unconfirmed work");
|
|
1406
|
+
validateRuntimePaneShutdown(await this.callPane(machine.id, { action: "shutdown", hostBootId: raw.hostBootId }), raw.hostBootId);
|
|
1407
|
+
}));
|
|
1408
|
+
if (outcomes.some(result => result.status === "rejected"))
|
|
1409
|
+
throw Error("One or more pane hosts could not confirm empty shutdown; retained work stays reserved");
|
|
1410
|
+
}
|
|
1411
|
+
async call(machineId, operation, payload) {
|
|
1412
|
+
if (this.closed || !["probe", "workspace", "run", "cancel", "reconcile", "recover"].includes(operation))
|
|
1413
|
+
throw Error("Unsupported runtime operation");
|
|
1414
|
+
const machine = this.entry(machineId).machine;
|
|
1415
|
+
const connection = this.connections.get(machineId);
|
|
1416
|
+
if (machine.status !== "online" || !connection || !this.admitting(connection))
|
|
1417
|
+
throw Error("Runtime machine is offline or updating");
|
|
1418
|
+
let id = randomUUID(), normalized = payload;
|
|
1419
|
+
if (operation === "run") {
|
|
1420
|
+
if (!record(payload) || Object.keys(payload).some(k => !["task", "resumeSessionId", "context", "mcp", "credentialProfile"].includes(k)))
|
|
1421
|
+
throw Error("Invalid runtime run payload");
|
|
1422
|
+
const task = validateNativeTask(payload.task);
|
|
1423
|
+
if (payload.credentialProfile !== undefined) {
|
|
1424
|
+
assertCredentialProfileName(payload.credentialProfile);
|
|
1425
|
+
assertCredentialProfileCli(task.cli);
|
|
1426
|
+
}
|
|
1427
|
+
if (payload.resumeSessionId !== undefined && !text(payload.resumeSessionId, 256) || payload.context !== undefined && (typeof payload.context !== "string" || payload.context.length > 2000 || payload.context.includes("\0")))
|
|
1428
|
+
throw Error("Invalid runtime turn context");
|
|
1429
|
+
if (payload.mcp !== undefined && (!record(payload.mcp) || Object.keys(payload.mcp).some(k => k !== "tools") || !Array.isArray(payload.mcp.tools) || !payload.mcp.tools.length || payload.mcp.tools.length > 128 || payload.mcp.tools.some(v => typeof v !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(v))))
|
|
1430
|
+
throw Error("Invalid runtime tool scope");
|
|
1431
|
+
normalized = { ...payload, task };
|
|
1432
|
+
id = task.requestId;
|
|
1433
|
+
}
|
|
1434
|
+
if (operation === "recover") {
|
|
1435
|
+
if (!record(payload) || Object.keys(payload).some(key => !["runId", "confirmedStopped"].includes(key))
|
|
1436
|
+
|| !text(payload.runId, 80) || payload.confirmedStopped !== true)
|
|
1437
|
+
throw Error("Runtime recovery requires explicit stopped-process confirmation");
|
|
1438
|
+
const original = this.state.commands.find(command => command.id === payload.runId && command.machineId === machineId && command.operation === "run");
|
|
1439
|
+
if (!original)
|
|
1440
|
+
throw Error("Runtime recovery does not belong to this machine");
|
|
1441
|
+
// A runtime that never received the original request can still save a no-execution tombstone after manual
|
|
1442
|
+
// confirmation. The original is server-owned; callers cannot replace it with another task or tool scope.
|
|
1443
|
+
normalized = { runId: payload.runId, confirmedStopped: true, original: structuredClone(original.payload) };
|
|
1444
|
+
}
|
|
1445
|
+
const digest = hash(stable({ operation, payload: normalized }));
|
|
1446
|
+
if (Buffer.byteLength(JSON.stringify(normalized)) > RUNTIME_MAX_FRAME_BYTES / 2)
|
|
1447
|
+
throw Error("Runtime command payload is too large");
|
|
1448
|
+
const existing = this.state.commands.find(command => command.id === id);
|
|
1449
|
+
if (existing) {
|
|
1450
|
+
if (existing.machineId !== machineId || existing.digest !== digest)
|
|
1451
|
+
throw Error("Runtime task ID belongs to a different request or machine");
|
|
1452
|
+
if (existing.task)
|
|
1453
|
+
return structuredClone(existing.task);
|
|
1454
|
+
throw Error("Runtime command is already recorded; reconcile it before retrying");
|
|
1455
|
+
}
|
|
1456
|
+
const tombstone = this.state.tombstones.find(row => row.id === id);
|
|
1457
|
+
if (tombstone) {
|
|
1458
|
+
if (tombstone.machineId !== machineId || tombstone.digest !== digest)
|
|
1459
|
+
throw Error("Runtime task ID belongs to a different request or machine");
|
|
1460
|
+
throw Error("Runtime command already ran and its record was compacted; do not retry it");
|
|
1461
|
+
}
|
|
1462
|
+
if (operation === "run" && this.hasActiveTask(machineId))
|
|
1463
|
+
throw Error("Runtime machine is busy or has an unconfirmed task");
|
|
1464
|
+
this.compact();
|
|
1465
|
+
if (this.state.commands.length >= COMMAND_HARD_CAP)
|
|
1466
|
+
throw Error("Runtime command journal limit reached: too many unsettled commands; reconcile them");
|
|
1467
|
+
const command = { id, machineId, operation, digest, payload: normalized, createdAt: this.now(), state: "pending", seq: 0 };
|
|
1468
|
+
// Journal is committed before the first byte reaches the execution computer. Never auto-send it again.
|
|
1469
|
+
this.state.commands.push(command);
|
|
1470
|
+
this.save();
|
|
1471
|
+
return new Promise((resolve, reject) => {
|
|
1472
|
+
const timer = setTimeout(() => {
|
|
1473
|
+
this.pending.delete(id);
|
|
1474
|
+
command.state = interrupted(command);
|
|
1475
|
+
command.error = command.state === "failed" ? "Runtime inventory request timed out" : "Runtime acknowledgment timed out; reconcile before retrying";
|
|
1476
|
+
this.save();
|
|
1477
|
+
reject(Error(command.error));
|
|
1478
|
+
}, this.options.requestTimeoutMs ?? (operation === "probe" ? 90_000 : 30_000));
|
|
1479
|
+
timer.unref();
|
|
1480
|
+
this.pending.set(id, { machineId, generation: connection.generation, resolve, reject, timer });
|
|
1481
|
+
try {
|
|
1482
|
+
this.send(connection, { v: 1, type: "request", id, operation, payload: normalized });
|
|
1483
|
+
}
|
|
1484
|
+
catch (error) {
|
|
1485
|
+
this.pending.delete(id);
|
|
1486
|
+
clearTimeout(timer);
|
|
1487
|
+
command.state = interrupted(command);
|
|
1488
|
+
this.save();
|
|
1489
|
+
reject(error);
|
|
1490
|
+
}
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
close() {
|
|
1494
|
+
if (this.closed)
|
|
1495
|
+
return;
|
|
1496
|
+
this.closed = true;
|
|
1497
|
+
clearInterval(this.heartbeat);
|
|
1498
|
+
for (const activity of this.machineActivity.values())
|
|
1499
|
+
activity.close();
|
|
1500
|
+
for (const connection of this.connections.values()) {
|
|
1501
|
+
clearTimeout(connection.helloTimer);
|
|
1502
|
+
this.rejectPending(connection, "Runtime coordinator stopped; reconcile before retrying");
|
|
1503
|
+
connection.ws.terminate();
|
|
1504
|
+
}
|
|
1505
|
+
this.connections.clear();
|
|
1506
|
+
for (const row of this.state.machines)
|
|
1507
|
+
if (row.machine.status === "online")
|
|
1508
|
+
row.machine.status = "offline";
|
|
1509
|
+
this.save();
|
|
1510
|
+
this.server.close();
|
|
1511
|
+
this.listeners.clear();
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
//# sourceMappingURL=runtime-coordinator.js.map
|