@songsid/agend 2.3.5-alpha.4 → 2.3.5-alpha.6
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/THIRD_PARTY_NOTICES.md +51 -0
- package/dist/accounts-profiles.d.ts +96 -0
- package/dist/accounts-profiles.js +178 -0
- package/dist/accounts-profiles.js.map +1 -0
- package/dist/accounts-signout.d.ts +59 -0
- package/dist/accounts-signout.js +184 -0
- package/dist/accounts-signout.js.map +1 -0
- package/dist/accounts-view.d.ts +151 -0
- package/dist/accounts-view.js +160 -0
- package/dist/accounts-view.js.map +1 -0
- package/dist/agent-cli-instructions.md +1 -1
- package/dist/agent-credentials.d.ts +24 -0
- package/dist/agent-credentials.js +66 -0
- package/dist/agent-credentials.js.map +1 -0
- package/dist/agent-endpoint.d.ts +3 -1
- package/dist/agent-endpoint.js +13 -0
- 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-change.d.ts +3 -1
- package/dist/agent-runtime-change.js +15 -3
- package/dist/agent-runtime-change.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/auth-api.d.ts +27 -0
- package/dist/auth-api.js +191 -8
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/session-authorizations.d.ts +30 -4
- package/dist/authority/session-authorizations.js +69 -17
- package/dist/authority/session-authorizations.js.map +1 -1
- package/dist/backend/antigravity.js +3 -1
- package/dist/backend/antigravity.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-metadata.d.ts +14 -0
- package/dist/backend/codex-metadata.js +45 -0
- package/dist/backend/codex-metadata.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-speed.d.ts +14 -0
- package/dist/backend/codex-speed.js +35 -0
- package/dist/backend/codex-speed.js.map +1 -0
- package/dist/backend/codex.d.ts +7 -0
- package/dist/backend/codex.js +79 -15
- package/dist/backend/codex.js.map +1 -1
- 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 +30 -1
- package/dist/backend/grok.js +301 -54
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/kiro.d.ts +3 -0
- package/dist/backend/kiro.js +50 -2
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/muse.js +5 -3
- package/dist/backend/muse.js.map +1 -1
- package/dist/backend/native-pane.d.ts +3 -1
- package/dist/backend/native-pane.js +2 -2
- package/dist/backend/native-pane.js.map +1 -1
- package/dist/backend/types.d.ts +15 -1
- package/dist/backend/types.js +3 -0
- package/dist/backend/types.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 +19 -0
- package/dist/bundled-tmux-guard.js +83 -0
- package/dist/bundled-tmux-guard.js.map +1 -0
- package/dist/cache-ledger.d.ts +95 -0
- package/dist/cache-ledger.js +276 -4
- package/dist/cache-ledger.js.map +1 -1
- package/dist/cache-service.d.ts +5 -0
- package/dist/cache-service.js +16 -4
- package/dist/cache-service.js.map +1 -1
- package/dist/channel/adapters/discord.js +11 -3
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.d.ts +51 -0
- package/dist/channel/adapters/telegram.js +235 -17
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/mcp-tools.js +3 -3
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/types.d.ts +2 -0
- 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 +48 -0
- package/dist/claude-auth-status.js +149 -0
- package/dist/claude-auth-status.js.map +1 -0
- package/dist/cli.js +252 -46
- package/dist/cli.js.map +1 -1
- package/dist/config-validator.js +32 -1
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/cross-instance-notice.d.ts +10 -0
- package/dist/cross-instance-notice.js +67 -5
- package/dist/cross-instance-notice.js.map +1 -1
- package/dist/daemon.d.ts +95 -1
- package/dist/daemon.js +652 -29
- 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/delivery-consumed-watch.d.ts +23 -1
- package/dist/delivery-consumed-watch.js +30 -3
- package/dist/delivery-consumed-watch.js.map +1 -1
- package/dist/delivery-reconciliation.d.ts +1 -1
- package/dist/delivery-reconciliation.js +1 -1
- 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/export-import.d.ts +7 -0
- package/dist/export-import.js +44 -10
- package/dist/export-import.js.map +1 -1
- package/dist/fleet-context.d.ts +2 -0
- package/dist/fleet-control-audit.d.ts +1 -1
- package/dist/fleet-manager.d.ts +488 -7
- package/dist/fleet-manager.js +2069 -122
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-windows-runtime.d.ts +2 -1
- package/dist/fleet-windows-runtime.js +25 -7
- package/dist/fleet-windows-runtime.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +425 -0
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +15 -2
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +1 -0
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +2 -2
- package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +3 -1
- package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +41 -4
- 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 +31 -15
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +1 -1
- package/dist/general-role.d.ts +1 -1
- package/dist/general-role.js +1 -0
- package/dist/general-role.js.map +1 -1
- 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 +346 -0
- package/dist/hub/buttons.js.map +1 -0
- package/dist/hub/catalog.d.ts +74 -0
- package/dist/hub/catalog.js +195 -0
- package/dist/hub/catalog.js.map +1 -0
- package/dist/hub/client.d.ts +69 -0
- package/dist/hub/client.js +300 -0
- package/dist/hub/client.js.map +1 -0
- package/dist/hub/compose/member.d.ts +139 -0
- package/dist/hub/compose/member.js +450 -0
- package/dist/hub/compose/member.js.map +1 -0
- package/dist/hub/compose/server.d.ts +77 -0
- package/dist/hub/compose/server.js +350 -0
- package/dist/hub/compose/server.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 +56 -0
- package/dist/hub/db.js +188 -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 +18 -0
- package/dist/hub/directory/directory.js +432 -0
- package/dist/hub/directory/directory.js.map +1 -0
- package/dist/hub/directory/groups.d.ts +29 -0
- package/dist/hub/directory/groups.js +29 -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 +75 -0
- package/dist/hub/directory/types.js +14 -0
- package/dist/hub/directory/types.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/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 +52 -0
- package/dist/hub/group-policy/resources.js +166 -0
- package/dist/hub/group-policy/resources.js.map +1 -0
- package/dist/hub/group-policy/store.d.ts +52 -0
- package/dist/hub/group-policy/store.js +149 -0
- package/dist/hub/group-policy/store.js.map +1 -0
- package/dist/hub/http/compose.d.ts +20 -0
- package/dist/hub/http/compose.js +519 -0
- package/dist/hub/http/compose.js.map +1 -0
- package/dist/hub/http/core.d.ts +49 -0
- package/dist/hub/http/core.js +124 -0
- package/dist/hub/http/core.js.map +1 -0
- package/dist/hub/http/deps.d.ts +61 -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 +80 -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 +9 -0
- package/dist/hub/init/browser-certificate.js +78 -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 +222 -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 +24 -0
- package/dist/hub/init/initializer.js +385 -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 +114 -0
- package/dist/hub/init/types.js +9 -0
- package/dist/hub/init/types.js.map +1 -0
- package/dist/hub/init/wizard.d.ts +34 -0
- package/dist/hub/init/wizard.js +554 -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/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 +85 -0
- package/dist/hub/member/pairing-api.js +385 -0
- package/dist/hub/member/pairing-api.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 +39 -0
- package/dist/hub/mount.js +123 -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.d.ts +67 -0
- package/dist/hub/pairing.js +214 -0
- package/dist/hub/pairing.js.map +1 -0
- package/dist/hub/policy.d.ts +63 -0
- package/dist/hub/policy.js +147 -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 +779 -0
- package/dist/hub/protocol.js +93 -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/rooms.d.ts +120 -0
- package/dist/hub/rooms.js +535 -0
- package/dist/hub/rooms.js.map +1 -0
- package/dist/hub/runtime.d.ts +106 -0
- package/dist/hub/runtime.js +298 -0
- package/dist/hub/runtime.js.map +1 -0
- package/dist/hub/server.d.ts +58 -0
- package/dist/hub/server.js +212 -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/sessions.d.ts +53 -0
- package/dist/hub/sessions.js +196 -0
- package/dist/hub/sessions.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 +77 -0
- package/dist/hub/store.js +88 -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 +401 -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-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 +7 -3
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +34 -2
- package/dist/instance-lifecycle.js +96 -9
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instance-topic-delete.d.ts +77 -0
- package/dist/instance-topic-delete.js +123 -0
- package/dist/instance-topic-delete.js.map +1 -0
- package/dist/instructions.d.ts +1 -1
- package/dist/instructions.js +1 -1
- package/dist/instructions.js.map +1 -1
- package/dist/kiro-engine-status.d.ts +11 -0
- package/dist/kiro-engine-status.js +6 -0
- package/dist/kiro-engine-status.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/locale.js +146 -3
- package/dist/locale.js.map +1 -1
- package/dist/log-service.d.ts +28 -0
- package/dist/log-service.js +29 -0
- package/dist/log-service.js.map +1 -1
- package/dist/log-steps.d.ts +4 -3
- package/dist/log-steps.js +32 -7
- package/dist/log-steps.js.map +1 -1
- package/dist/logger.d.ts +16 -2
- package/dist/logger.js +346 -66
- package/dist/logger.js.map +1 -1
- package/dist/login-controller.d.ts +5 -0
- package/dist/login-controller.js +11 -0
- package/dist/login-controller.js.map +1 -1
- package/dist/login-flows.d.ts +15 -7
- package/dist/login-flows.js +29 -3
- package/dist/login-flows.js.map +1 -1
- package/dist/login-manager.js +25 -4
- 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/missed-offline.d.ts +25 -0
- package/dist/missed-offline.js +79 -0
- package/dist/missed-offline.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-instance-api.d.ts +0 -1
- package/dist/native-instance-api.js +15 -3
- package/dist/native-instance-api.js.map +1 -1
- package/dist/native-instance-input.d.ts +3 -0
- package/dist/native-instance-input.js +6 -1
- package/dist/native-instance-input.js.map +1 -1
- package/dist/native-instance-registry.d.ts +6 -0
- package/dist/native-instance-registry.js +24 -0
- package/dist/native-instance-registry.js.map +1 -1
- package/dist/native-mcp.d.ts +3 -0
- package/dist/native-mcp.js +15 -2
- package/dist/native-mcp.js.map +1 -1
- package/dist/native-pane-lifecycle.d.ts +8 -0
- package/dist/native-pane-lifecycle.js +13 -4
- package/dist/native-pane-lifecycle.js.map +1 -1
- package/dist/native-pane-manager.js +17 -9
- package/dist/native-pane-manager.js.map +1 -1
- package/dist/needs-you-hub.d.ts +12 -1
- package/dist/needs-you-hub.js +57 -9
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +80 -2
- package/dist/needs-you.js +50 -3
- package/dist/needs-you.js.map +1 -1
- package/dist/office-share-page.js +2 -2
- 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 +14 -0
- package/dist/outbound-handlers.js +49 -6
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +33 -1
- package/dist/outbound-schemas.js +29 -16
- package/dist/outbound-schemas.js.map +1 -1
- 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/public-web-gateway.js +7 -0
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/queued-handoffs.d.ts +33 -0
- package/dist/queued-handoffs.js +75 -0
- package/dist/queued-handoffs.js.map +1 -0
- package/dist/quickstart.d.ts +13 -0
- package/dist/quickstart.js +68 -3
- 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.js +10 -6
- package/dist/reply-buttons-controller.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 +15 -0
- package/dist/runtime-api.js +149 -7
- package/dist/runtime-api.js.map +1 -1
- package/dist/runtime-build-info.d.ts +2 -1
- package/dist/runtime-build-info.js +9 -3
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-bundle.d.ts +3 -0
- package/dist/runtime-bundle.js +3 -1
- package/dist/runtime-bundle.js.map +1 -1
- package/dist/runtime-cli-install.d.ts +153 -0
- package/dist/runtime-cli-install.js +675 -0
- package/dist/runtime-cli-install.js.map +1 -0
- package/dist/runtime-cli.d.ts +8 -1
- package/dist/runtime-cli.js +273 -9
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client-store.d.ts +7 -0
- package/dist/runtime-client-store.js +30 -2
- package/dist/runtime-client-store.js.map +1 -1
- package/dist/runtime-client.d.ts +126 -2
- package/dist/runtime-client.js +558 -27
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +17 -1
- package/dist/runtime-coordinator.js +304 -35
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-credential-profiles.d.ts +87 -0
- package/dist/runtime-credential-profiles.js +304 -0
- package/dist/runtime-credential-profiles.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 +1 -1
- package/dist/runtime-pane-assets.js +1 -1
- package/dist/runtime-pane-assets.js.map +1 -1
- package/dist/runtime-pane-codex-index.d.ts +10 -1
- package/dist/runtime-pane-codex-index.js +131 -27
- package/dist/runtime-pane-codex-index.js.map +1 -1
- package/dist/runtime-pane-host.d.ts +19 -0
- package/dist/runtime-pane-host.js +50 -7
- package/dist/runtime-pane-host.js.map +1 -1
- package/dist/runtime-pane-link.d.ts +7 -0
- package/dist/runtime-pane-link.js +95 -3
- package/dist/runtime-pane-link.js.map +1 -1
- package/dist/runtime-pane-mcp-relay.d.ts +1 -0
- package/dist/runtime-pane-mcp-relay.js +10 -0
- package/dist/runtime-pane-mcp-relay.js.map +1 -1
- package/dist/runtime-pane-mcp.d.ts +4 -0
- package/dist/runtime-pane-mcp.js +6 -3
- package/dist/runtime-pane-mcp.js.map +1 -1
- package/dist/runtime-pane-native.d.ts +32 -2
- package/dist/runtime-pane-native.js +55 -6
- package/dist/runtime-pane-native.js.map +1 -1
- package/dist/runtime-pane-port.d.ts +5 -0
- package/dist/runtime-pane-port.js +17 -1
- package/dist/runtime-pane-port.js.map +1 -1
- package/dist/runtime-pane-process.d.ts +1 -1
- package/dist/runtime-pane-process.js +11 -2
- package/dist/runtime-pane-process.js.map +1 -1
- package/dist/runtime-pane-protocol.d.ts +11 -1
- package/dist/runtime-pane-protocol.js +27 -5
- package/dist/runtime-pane-protocol.js.map +1 -1
- 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-service.d.ts +5 -0
- package/dist/runtime-pane-service.js +49 -14
- package/dist/runtime-pane-service.js.map +1 -1
- package/dist/runtime-pane-store.d.ts +10 -0
- package/dist/runtime-pane-store.js +13 -1
- package/dist/runtime-pane-store.js.map +1 -1
- package/dist/runtime-pane-transcript.d.ts +5 -0
- package/dist/runtime-pane-transcript.js +66 -5
- package/dist/runtime-pane-transcript.js.map +1 -1
- package/dist/runtime-pane-worker.js +19 -6
- package/dist/runtime-pane-worker.js.map +1 -1
- 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 +103 -2
- package/dist/runtime-protocol.js +52 -0
- package/dist/runtime-protocol.js.map +1 -1
- package/dist/runtime-remote-accounts.d.ts +197 -0
- package/dist/runtime-remote-accounts.js +663 -0
- package/dist/runtime-remote-accounts.js.map +1 -0
- package/dist/runtime-remote-setup.d.ts +105 -0
- package/dist/runtime-remote-setup.js +529 -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 +110 -0
- package/dist/runtime-signin-transport.js.map +1 -0
- package/dist/runtime-signin.d.ts +132 -0
- package/dist/runtime-signin.js +289 -0
- package/dist/runtime-signin.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 +75 -0
- package/dist/runtime-update-controller.js +691 -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 +2 -1
- package/dist/runtime-windows-bridge.js +11 -1
- package/dist/runtime-windows-bridge.js.map +1 -1
- package/dist/scheduler/db.d.ts +2 -1
- package/dist/scheduler/db.js +23 -9
- 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/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 +20 -0
- package/dist/settings-api.js +417 -4
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +6 -0
- package/dist/settings-baseline.js +3 -1
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-change.js +37 -6
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.d.ts +13 -0
- package/dist/settings-effect.js +97 -0
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.js +13 -1
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-instance-patch.js +28 -1
- package/dist/settings-instance-patch.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 +203 -0
- package/dist/signin-keepalive.js +652 -0
- package/dist/signin-keepalive.js.map +1 -0
- package/dist/structured-signin-transport.js +4 -0
- package/dist/structured-signin-transport.js.map +1 -1
- package/dist/structured-signin.d.ts +7 -0
- package/dist/structured-signin.js +1 -1
- package/dist/structured-signin.js.map +1 -1
- 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/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.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 +7 -1
- package/dist/tmux-manager.js +56 -37
- package/dist/tmux-manager.js.map +1 -1
- 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 +5 -2
- package/dist/tool-permissions.js +6 -5
- package/dist/tool-permissions.js.map +1 -1
- package/dist/tool-progress.d.ts +2 -0
- package/dist/tool-progress.js +19 -3
- package/dist/tool-progress.js.map +1 -1
- package/dist/topic-commands.js +10 -5
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-monitor.d.ts +20 -0
- package/dist/transcript-monitor.js +87 -5
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-needles.d.ts +7 -0
- package/dist/transcript-needles.js +9 -1
- package/dist/transcript-needles.js.map +1 -1
- package/dist/transcript-records.d.ts +2 -1
- package/dist/transcript-records.js +5 -1
- package/dist/transcript-records.js.map +1 -1
- package/dist/transcript-sources.js +3 -0
- package/dist/transcript-sources.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/ui/account-identity.js +27 -0
- package/dist/ui/accounts-keepalive.js +112 -0
- package/dist/ui/accounts-manage.js +237 -0
- package/dist/ui/accounts-view.js +358 -0
- package/dist/ui/agent-runtime-settings.js +11 -9
- package/dist/ui/app.html +8 -1
- package/dist/ui/backend-signin.js +4 -1
- package/dist/ui/chat-ambient.js +1 -1
- package/dist/ui/chat-md-strings.js +3 -0
- package/dist/ui/chat-render.js +3 -670
- package/dist/ui/chat-store.js +1 -1
- package/dist/ui/chat-strings.js +3 -333
- package/dist/ui/chat-thread.js +3 -919
- package/dist/ui/chat-time.js +3 -80
- package/dist/ui/chat-tour.js +1 -1
- package/dist/ui/credential-profile-select.js +54 -0
- package/dist/ui/fleet-office-dialogue.d.ts +30 -0
- package/dist/ui/fleet-office-dialogue.js +382 -0
- 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 +173 -6
- package/dist/ui/fleet-task-card.js +10 -6
- package/dist/ui/fleet-task-common.js +12 -2
- 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/fleet-usage.js +90 -27
- 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 +163 -0
- package/dist/ui/hub-chat-strings.js +77 -0
- package/dist/ui/hub-client.js +348 -0
- package/dist/ui/hub-owner-strings.js +51 -0
- package/dist/ui/hub-preview.js +101 -0
- package/dist/ui/hub-provider-guidance.js +31 -0
- package/dist/ui/hub-quota.js +85 -0
- package/dist/ui/hub-strings.js +162 -0
- package/dist/ui/hub-switcher.js +27 -0
- package/dist/ui/machine-signin.js +56 -0
- package/dist/ui/native-pane-recovery.js +1 -1
- package/dist/ui/office-share-page.js +4 -2
- package/dist/ui/panel-chat.js +34 -48
- package/dist/ui/panel-details.js +1 -1
- package/dist/ui/panel-fleet.js +79 -11
- package/dist/ui/panel-hub.js +714 -0
- package/dist/ui/panel-log.js +2 -2
- package/dist/ui/panel-needs.js +36 -14
- package/dist/ui/panel-notices.js +4 -3
- package/dist/ui/panel-runtimes.js +131 -27
- package/dist/ui/panel-settings.js +81 -86
- package/dist/ui/panel-windows-agent.js +2 -1
- package/dist/ui/panel-windows-cli.js +12 -2
- package/dist/ui/preview-pages.js +3 -41
- package/dist/ui/preview-panel-actions.js +3 -161
- package/dist/ui/preview-panel.js +11 -472
- package/dist/ui/preview-versions.js +3 -155
- package/dist/ui/preview.js +3 -476
- package/dist/ui/runtime-cli-install.js +114 -0
- package/dist/ui/runtime-commands.d.ts +4 -0
- package/dist/ui/runtime-commands.js +59 -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 +5 -2
- package/dist/ui/settings-access-strings.js +42 -0
- package/dist/ui/settings-build-version.js +35 -0
- package/dist/ui/settings-codex-copy.js +19 -0
- package/dist/ui/settings-devices.js +253 -0
- package/dist/ui/settings-dialogs.js +28 -7
- package/dist/ui/settings-guests.js +3 -2
- package/dist/ui/settings-hub-browser-certificate.js +76 -0
- package/dist/ui/settings-hub-membership.js +78 -0
- package/dist/ui/settings-hub-retention.js +54 -0
- package/dist/ui/settings-hub.js +204 -0
- package/dist/ui/settings-layout.js +8 -11
- package/dist/ui/settings-model.js +16 -2
- package/dist/ui/settings-outside.js +104 -38
- package/dist/ui/settings-quota-notice.js +100 -0
- package/dist/ui/settings-registry.js +5 -1
- package/dist/ui/settings-shared-strings.js +143 -0
- package/dist/ui/settings-shared.js +345 -0
- package/dist/ui/settings-strings.js +12 -48
- package/dist/ui/settings-web-authority.js +7 -3
- package/dist/ui/shared/accounts-keepalive.css +7 -0
- package/dist/ui/shared/accounts.css +28 -0
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-needs.js +1 -1
- package/dist/ui/shared/app-route.js +7 -2
- package/dist/ui/shared/app-session.js +6 -2
- package/dist/ui/shared/app-shell.js +73 -11
- package/dist/ui/shared/app-store.js +2 -2
- package/dist/ui/shared/app.css +134 -30
- package/dist/ui/shared/app.js +14 -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/header-tools.js +3 -5
- package/dist/ui/shared/html-attachment.js +42 -0
- package/dist/ui/shared/hub-chat.css +86 -0
- package/dist/ui/shared/hub-owner.css +33 -0
- package/dist/ui/shared/hub-quota.css +8 -0
- package/dist/ui/shared/hub.css +71 -0
- package/dist/ui/shared/loading.css +37 -0
- package/dist/ui/shared/page-head.js +8 -0
- package/dist/ui/shared/panel-view.js +77 -4
- 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/runtime-install.css +30 -0
- package/dist/ui/shared/side-rail.js +15 -0
- package/dist/ui/shared/signin.js +238 -4
- package/dist/ui/shared/task-board.css +95 -0
- package/dist/ui/shared/ui-states.js +14 -3
- package/dist/ui/shared/usage-dialog.js +18 -1
- package/dist/ui/shared/view-history.css +17 -0
- package/dist/ui/shared/view-history.js +438 -0
- package/dist/ui/shared/view-strings.js +16 -0
- package/dist/ui/shared/workspace-follow.css +19 -0
- package/dist/ui/shared/workspace.css +20 -0
- package/dist/ui/signin.html +27 -2
- package/dist/ui/structured-signin.js +31 -7
- 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-install.d.ts +7 -0
- package/dist/update-install.js +23 -0
- package/dist/update-install.js.map +1 -1
- package/dist/usage/capacity.d.ts +69 -0
- package/dist/usage/capacity.js +119 -0
- package/dist/usage/capacity.js.map +1 -0
- package/dist/usage/i18n-keys.d.ts +1 -1
- package/dist/usage/i18n-keys.js +3 -0
- package/dist/usage/i18n-keys.js.map +1 -1
- package/dist/usage/profile-timeline.d.ts +16 -0
- package/dist/usage/profile-timeline.js +58 -0
- package/dist/usage/profile-timeline.js.map +1 -0
- package/dist/usage/providers.d.ts +5 -0
- package/dist/usage/providers.js +7 -1
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/quota-history.d.ts +43 -0
- package/dist/usage/quota-history.js +168 -0
- package/dist/usage/quota-history.js.map +1 -0
- 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 +32 -0
- package/dist/usage/usage-api.js +96 -1
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/usage-report.d.ts +25 -1
- package/dist/usage-report.js +55 -4
- package/dist/usage-report.js.map +1 -1
- package/dist/usage-rollup.d.ts +6 -1
- package/dist/usage-rollup.js +16 -4
- package/dist/usage-rollup.js.map +1 -1
- package/dist/view-api.d.ts +16 -0
- package/dist/view-api.js +105 -23
- package/dist/view-api.js.map +1 -1
- package/dist/view-history.d.ts +84 -0
- package/dist/view-history.js +116 -0
- package/dist/view-history.js.map +1 -0
- package/dist/web-api.d.ts +81 -2
- package/dist/web-api.js +615 -13
- package/dist/web-api.js.map +1 -1
- package/dist/web-backend-login.d.ts +23 -1
- package/dist/web-backend-login.js +11 -17
- package/dist/web-backend-login.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-login.d.ts +35 -1
- package/dist/web-login.js +51 -5
- package/dist/web-login.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-session-authorization.d.ts +13 -2
- package/dist/web-session-authorization.js +10 -3
- package/dist/web-session-authorization.js.map +1 -1
- package/dist/web-session.d.ts +46 -0
- package/dist/web-session.js +45 -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 +7 -1
- package/dist/web-shell-routes.js +8 -1
- package/dist/web-shell-routes.js.map +1 -1
- 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 +4 -30
- package/dist/web-terminal.js +9 -6
- package/dist/web-terminal.js.map +1 -1
- package/dist/windows-agents.d.ts +1 -0
- package/dist/windows-agents.js +1 -0
- package/dist/windows-agents.js.map +1 -1
- package/dist/windows-cli-api.d.ts +18 -1
- package/dist/windows-cli-api.js +38 -1
- package/dist/windows-cli-api.js.map +1 -1
- package/dist/windows-cli-providers.d.ts +0 -9
- package/dist/windows-cli-providers.js +4 -9
- package/dist/windows-cli-providers.js.map +1 -1
- package/dist/windows-cli-worker.d.ts +26 -0
- package/dist/windows-cli-worker.js +113 -7
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/windows-cli.d.ts +10 -0
- package/dist/windows-cli.js +10 -1
- package/dist/windows-cli.js.map +1 -1
- 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 +8 -1
- package/launcher/launchd-session-type.cjs +14 -0
- package/launcher/postinstall.cjs +27 -2
- package/launcher/private-home.cjs +1 -1
- package/launcher/tmux-bundle.cjs +263 -0
- package/package.json +8 -3
- package/templates/launchd.plist.ejs +3 -1
- package/templates/runtime-install/install.ps1 +411 -0
package/dist/fleet-manager.js
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
|
+
import { readInstalledBuild } from "./build-provenance.js";
|
|
1
2
|
import { buildNativeFleetInstructions } from "./instructions.js";
|
|
2
3
|
import { GENERAL_ROLE_INSTRUCTIONS } from "./general-role.js";
|
|
3
4
|
import { NativePaneRecoveryError } from "./native-pane-recovery.js";
|
|
4
5
|
import { nativePaneToolAvailable, nativePaneToolRefusal } from "./native-pane-tools.js";
|
|
5
6
|
import { windowsAgentsFor } from "./windows-agents.js";
|
|
6
7
|
import { AgentRuntimeChanges } from "./agent-runtime-change.js";
|
|
8
|
+
import { QuotaNotices } from "./usage/quota-notices.js";
|
|
9
|
+
import { quotaNoticeRule } from "./quota-notice-config.js";
|
|
10
|
+
import { onUsageSnapshot } from "./usage/usage-api.js";
|
|
7
11
|
import { supportsVerifiedKiroMigration, getCachedKiroCliCompatibility, kiroV1DbPath, kiroV2SessionsDir } from "./backend/kiro.js";
|
|
8
12
|
import { listKiroV1Sessions, readKiroClassicLinks } from "./backend/kiro-identity.js";
|
|
9
13
|
import { readKiroV1SavedModel } from "./backend/kiro-retired-model.js";
|
|
10
14
|
import { sharedKiroV2StoreLane } from "./backend/kiro-v2-store.js";
|
|
11
15
|
import { SEPARATE_FEATURE_KEYS, hasLegacyOffice, normalizeOfficeStorage } from "./dashboard-permissions.js";
|
|
16
|
+
import { maskSecrets } from "./log-steps.js";
|
|
12
17
|
import { loginNoticeMode, normalizeNoticeDelivery, setNoticeMode } from "./notice-delivery.js";
|
|
13
18
|
import { DEFAULT_REPLY_TRIGGERS } from "./reply-triggers.js";
|
|
14
19
|
import { WorkingRecoveryCoordinator, WORKING_RECOVERY_KIND, buildWorkingRecoveryPrompt } from "./working-recovery.js";
|
|
15
20
|
import { PUBLIC_TUNNEL_TOKEN_ENV, PUBLIC_TUNNEL_TOKEN_HINT, normalizePublicTunnelToken } from "./public-tunnel-config.js";
|
|
16
21
|
import { humanOwnerObjectId, webHumanOrigin } from "./human-delivery-receipts.js";
|
|
17
22
|
import { SettingsBaselines } from "./settings-baseline.js";
|
|
23
|
+
import { hubMembershipSettings } from "./hub-membership-settings.js";
|
|
18
24
|
import { prepareSettingsEffect } from "./settings-effect.js";
|
|
19
25
|
import { settingsDisplay } from "./settings-change.js";
|
|
20
26
|
import { SettingsConfirmationError, SettingsConfirmationStore, settingsSourceLabel } from "./settings-confirmation.js";
|
|
@@ -39,11 +45,13 @@ import { clearPublicLinkOwner, readPublicLinkOwner, writePublicLinkOwner } from
|
|
|
39
45
|
import { PUBLIC_PREVIEW_FRAME_SRC, PUBLIC_PREVIEW_TUNNEL_DIR, PublicPreview, publicPreviewWanted } from "./public-preview.js";
|
|
40
46
|
import { CloudflaredProvider } from "./tunnel/cloudflared.js";
|
|
41
47
|
import { ensureCloudflared } from "./tunnel/cloudflared-install.js";
|
|
42
|
-
import { unattendedInstallCommand, loginShell } from "./unattended-install.js";
|
|
48
|
+
import { installExitMarker, unattendedInstallCommand, loginShell } from "./unattended-install.js";
|
|
43
49
|
import { InstallStream } from "./install-stream.js";
|
|
44
50
|
import { namedTestLane, runNamedLinkTest } from "./tunnel/named-link-test.js";
|
|
45
51
|
import { daemonTopicMode, isWebOnlyFleetConfig } from "./web-only-fleet.js";
|
|
46
52
|
import { OFFICE_SHARE_TUNNEL_DIR, OfficeShareService } from "./office-share-service.js";
|
|
53
|
+
import { OfficeTalk } from "./office-talk.js";
|
|
54
|
+
import { pairingSummary } from "./hub-pairing-summary.js";
|
|
47
55
|
import { ALL_OFFICES, WHOLE_FLEET } from "./office-share.js";
|
|
48
56
|
import { TunnelPurposeLane } from "./tunnel/purpose-lane.js";
|
|
49
57
|
import { ManagedTunnel } from "./tunnel/manager.js";
|
|
@@ -63,6 +71,7 @@ import { join, dirname, basename, delimiter, isAbsolute, relative, resolve as re
|
|
|
63
71
|
import { fileURLToPath } from "node:url";
|
|
64
72
|
import { isDeepStrictEqual } from "node:util";
|
|
65
73
|
import { getAgendHome, ensureWorkspaceGit } from "./paths.js";
|
|
74
|
+
import { LegacyWindowHoldError } from "./tmux-legacy.js";
|
|
66
75
|
import { planKiroReconciliation, applyKiroReconciliation, kiroReconciliationPrompt } from "./kiro-reconcile.js";
|
|
67
76
|
import { applyKiroMigration, kiroMigrationPrompt, planKiroMigration } from "./kiro-migrate.js";
|
|
68
77
|
import { fleetLabel } from "./fleet-label.js";
|
|
@@ -80,6 +89,11 @@ import { tmuxExecHelper } from "./tmux-exec-helper.js";
|
|
|
80
89
|
import { kiroLogGate } from "./kiro-log-gate.js";
|
|
81
90
|
const __filename = fileURLToPath(import.meta.url);
|
|
82
91
|
const __dirname = dirname(__filename);
|
|
92
|
+
// Describe this running program, not files an updater may replace later. No reads on dashboard polls.
|
|
93
|
+
const RUNNING_BUILD = readInstalledBuild();
|
|
94
|
+
if (RUNNING_BUILD.source)
|
|
95
|
+
Object.freeze(RUNNING_BUILD.source);
|
|
96
|
+
Object.freeze(RUNNING_BUILD);
|
|
83
97
|
/** Fallback access policy for a channel with no `access:` block — open (no gate). */
|
|
84
98
|
const DEFAULT_OPEN_ACCESS = { mode: "open", allowed_users: [], max_pending_codes: 0, code_expiry_minutes: 0 };
|
|
85
99
|
import { STATUS_EMOJI_CONFIG_KEYS, STATUS_EMOJI_KEYS, STATUS_EMOJI_SUGGESTIONS, TELEGRAM_REACTION_EMOJIS, builtinStatusEmojis, customEmojiValue, emojiImageUrl, normalizeEmoji, previewStatusEmojis, reactionForm, reactionMatchKey, resolveStatusEmojis, statusAvoidList, statusEmojiProblem, statusMatchKey, statusMatchKeys, textForm, } from "./status-emojis.js";
|
|
@@ -87,6 +101,7 @@ import { isProbeableRouteTarget } from "./fleet-context.js";
|
|
|
87
101
|
import { getEffectiveInstanceDefaults, loadFleetConfig, loadRawFleetConfig, loadFleetConfigSource, loadRawFleetConfigSource, DEFAULT_COST_GUARD, DEFAULT_DAILY_SUMMARY, DEFAULT_INSTANCE_CONFIG, autoGeneralInstanceConfig } from "./config.js";
|
|
88
102
|
import { EventLog } from "./event-log.js";
|
|
89
103
|
import { binaryProbe } from "./binary-probe.js";
|
|
104
|
+
import { deletePlannedTopic, planInstanceTopicDelete, topicDestination, topicMustStay } from "./instance-topic-delete.js";
|
|
90
105
|
import { AVAILABILITY_STALE_MS, BackendAvailabilityStore, hostAvailabilityProbes, findExecutableIn, resolveBackendBinary } from "./backend-availability.js";
|
|
91
106
|
import { classifySqliteOpenError } from "./sqlite-open-errors.js";
|
|
92
107
|
import { OutboxOpenError } from "./outbox-open-error.js";
|
|
@@ -103,6 +118,7 @@ import { formatFleetTime } from "./tz-utils.js";
|
|
|
103
118
|
import { createAdapter } from "./channel/factory.js";
|
|
104
119
|
import { isWebChannelEcho, WEB_ECHO_PREFIX } from "./web-channel-echo.js";
|
|
105
120
|
import { TelegramAdapter } from "./channel/adapters/telegram.js";
|
|
121
|
+
import { MissedOfflineStore } from "./missed-offline.js";
|
|
106
122
|
import { createBackend } from "./backend/factory.js";
|
|
107
123
|
import { readEffortMetadata } from "./backend/effort-metadata.js";
|
|
108
124
|
import { codexEffort, flagEffort } from "./backend/launch-effort.js";
|
|
@@ -128,6 +144,7 @@ import { InstanceLifecycle, SupersededStartError, BACKEND_INSTALLATION_INFO, che
|
|
|
128
144
|
import { TopicArchiver } from "./topic-archiver.js";
|
|
129
145
|
import { StatuslineWatcher } from "./statusline-watcher.js";
|
|
130
146
|
import { applyInstanceConfigPatch, outboundHandlers } from "./outbound-handlers.js";
|
|
147
|
+
import { HUB_REPORT_TARGET } from "./hub-report-target.js";
|
|
131
148
|
import { backendArgs, backendStep, joinBackendArgs, modelNameCarried, planDisplay } from "./backend-command.js";
|
|
132
149
|
import { DeliveryOutbox, DEFAULT_REPLY_OBLIGATION_TTL_MS, isSilentScheduleDelivery } from "./delivery-outbox.js";
|
|
133
150
|
// The target Daemon can legitimately wait 30 minutes for a busy pane before
|
|
@@ -154,6 +171,20 @@ export const LIVE_TASK_STATUSES = ["open", "claimed", "blocked", "review"];
|
|
|
154
171
|
* " \t " and [" ", "\t"] both normalize to undefined (not treated as explicit
|
|
155
172
|
* filters). The same result drives the live-only default and the cap decision.
|
|
156
173
|
*/
|
|
174
|
+
/**
|
|
175
|
+
* #3195: the saved value of each plain-update field the call named (assignee, priority, result), read back from the
|
|
176
|
+
* task — so the answer shows what was persisted, not what was asked. Status is always in the ack already.
|
|
177
|
+
*/
|
|
178
|
+
export function savedFields(t, named) {
|
|
179
|
+
const out = {};
|
|
180
|
+
if (named.assignee !== undefined)
|
|
181
|
+
out.assignee = t.assignee;
|
|
182
|
+
if (named.priority !== undefined)
|
|
183
|
+
out.priority = t.priority;
|
|
184
|
+
if (named.result !== undefined)
|
|
185
|
+
out.result = t.result;
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
157
188
|
export function normalizeStatusFilter(v) {
|
|
158
189
|
if (typeof v === "string") {
|
|
159
190
|
const s = v.trim();
|
|
@@ -183,19 +214,24 @@ export function applyTaskListCap(tasks, filterAssignee, filterStatus) {
|
|
|
183
214
|
}
|
|
184
215
|
import { handleWebRequest, webPeerOf, broadcastSseEvent, broadcastToGuests, SSE_HEARTBEAT_MS } from "./web-api.js";
|
|
185
216
|
import { windowsCliEnabled, closeWindowsBridge, inventoryProbed, LOCAL_WINDOWS_CLI_OFF } from "./windows-cli.js";
|
|
217
|
+
import { nativeCliVersionState } from "./runtime-pane-native.js";
|
|
186
218
|
import { localWindowsCliEnabled, remoteRuntimeEnabled, setConfiguredRuntimeSwitches, maxAgentsPerMachine } from "./runtime-switches.js";
|
|
219
|
+
import { RuntimeInstallService } from "./runtime-install.js";
|
|
220
|
+
import { RUNTIME_CREDENTIAL_CAPABILITY, validCredentialProfileName } from "./runtime-credential-profiles.js";
|
|
187
221
|
import { RuntimeCoordinator } from "./runtime-coordinator.js";
|
|
222
|
+
import { runtimeUpdateAttention } from "./runtime-update-attention.js";
|
|
188
223
|
import { RuntimeWindowsBridge } from "./runtime-windows-bridge.js";
|
|
189
224
|
import { FleetWindowsRuntime } from "./fleet-windows-runtime.js";
|
|
190
225
|
import { NativeMcpSessions } from "./native-mcp.js";
|
|
191
226
|
import { nativeProviderMcpSupported } from "./windows-cli-providers.js";
|
|
192
|
-
import { isWindowsInstance, isNativePaneInstance, isNativeExecInstance, WINDOWS_CONFIG_REFUSED } from "./native-instance-registry.js";
|
|
227
|
+
import { isWindowsInstance, isNativePaneInstance, isNativeExecInstance, WINDOWS_CONFIG_REFUSED, nativeCredentialProfile } from "./native-instance-registry.js";
|
|
193
228
|
import { createNativeWindowsInstance, updateNativeWindowsInstance } from "./native-instance-api.js";
|
|
194
229
|
import { NativeInstanceConfigEdit, parseNativeInstanceCreate } from "./native-instance-input.js";
|
|
195
230
|
import { LogService } from "./log-service.js";
|
|
231
|
+
import { viewHistory } from "./view-history.js";
|
|
196
232
|
import { WebChatHistory, WEB_CHAT_TEXT_MAX, isWebMessageId, newWebMessageId, webChatFrom } from "./web-chat-history.js";
|
|
197
233
|
import { WEB_ECHO_COPIES_MAX, WEB_MIRROR_TIMEOUT_MS, webReactionEmoji, webReactionProblem } from "./web-reactions.js";
|
|
198
|
-
import { WebChatDiskStore } from "./web-chat-store.js";
|
|
234
|
+
import { WebChatDiskStore, isSafeInstanceDirName } from "./web-chat-store.js";
|
|
199
235
|
import { SeenUsers, resolveMentions } from "./web-mentions.js";
|
|
200
236
|
import { OPERATOR, WebPrefsStore } from "./web-prefs.js";
|
|
201
237
|
import { agendVersion } from "./agent-whats-new.js";
|
|
@@ -225,8 +261,8 @@ import { envFileKeys } from "./token-env-name.js";
|
|
|
225
261
|
import { discordGeneralChannelId } from "./discord-general.js";
|
|
226
262
|
import { parseEnvText } from "./env-file.js";
|
|
227
263
|
import { isDisallowedIntentsError, isRejectedTokenError } from "./discord-permissions.js";
|
|
228
|
-
import { filterUsageProviders, formatDiscordUsageActivity, getUsageSnapshot, handleUsageRequest, isUsagePath, usageProviderIdForBackend } from "./usage/usage-api.js";
|
|
229
|
-
import { LOGIN_FLOWS, checkAuthStatus, LOGIN_BACKEND_ALIASES } from "./login-flows.js";
|
|
264
|
+
import { filterUsageProviders, formatDiscordUsageActivity, getUsageSnapshot, handleUsageRequest, isUsagePath, setCapacityLookup, usageProviderIdForBackend } from "./usage/usage-api.js";
|
|
265
|
+
import { LOGIN_FLOWS, checkAuthStatus, checkAuthIdentity, authIdentitySupported, LOGIN_BACKEND_ALIASES } from "./login-flows.js";
|
|
230
266
|
import { LoginSession } from "./login-manager.js";
|
|
231
267
|
import { runOnLoginShell } from "./login-shell.js";
|
|
232
268
|
import { tightenInstanceDirs } from "./private-dir.js";
|
|
@@ -256,6 +292,8 @@ import { remoteCardAction, remoteCardChoiceLabel, remoteCardOutcomeText, remoteC
|
|
|
256
292
|
import { recentChatContext } from "./log-tail.js";
|
|
257
293
|
import { describeSignalSource, recordInternalRequest, withOrigin } from "./fleet-control-audit.js";
|
|
258
294
|
import { handleAgentRequest, ToolNotPermittedError } from "./agent-endpoint.js";
|
|
295
|
+
import { AgentCredentials, agentCredentialPolicy } from "./agent-credentials.js";
|
|
296
|
+
import { writeSecretFile } from "./secret-file.js";
|
|
259
297
|
import { ConfigHistory, ConfigSyntaxError, configIssueText } from "./config-history.js";
|
|
260
298
|
import { ClassicChannelManager, classicWebEchoOn, getClassicBackendChoices, inferClassicChannelType, isSelectableClassicBackend, readClassicLastActivityAt, readClassicRoomNames } from "./classic-channel-manager.js";
|
|
261
299
|
import { assertExplicitInstanceRemoval } from "./instance-removal.js";
|
|
@@ -276,6 +314,8 @@ import { isSetupComplete, markSetupComplete } from "./setup-marker.js";
|
|
|
276
314
|
import { manualCleanupMessage, reapStaleTunnel } from "./tunnel/lease.js";
|
|
277
315
|
import { buildToolPermissionsNotice } from "./tool-permissions-notice.js";
|
|
278
316
|
import { NeedsYouHub } from "./needs-you-hub.js";
|
|
317
|
+
import { SignInKeepAlive, isKeepAliveBackend } from "./signin-keepalive.js";
|
|
318
|
+
import { BACKEND_LABELS } from "./interaction-observation.js";
|
|
279
319
|
import { GENERAL_NAME, GENERAL_PAUSE_ERROR, adoptGeneralByName, freeGeneralName, isGeneralInstance } from "./general-instance.js";
|
|
280
320
|
import { buildOrgChart } from "./web-org.js";
|
|
281
321
|
import { topMemoryHogs } from "./memory-hogs.js";
|
|
@@ -286,13 +326,14 @@ import { CompactWatch, launchIdentity } from "./compact-watch.js";
|
|
|
286
326
|
import { agyLegacyAgentsFile, danglingSymlink, migrateAgyAgentsFile } from "./backend/antigravity.js";
|
|
287
327
|
import { claudeConfigDirFor, claudeProjectKey } from "./backend/claude-code.js";
|
|
288
328
|
import { sharedRolloutIndex } from "./rollout-index.js";
|
|
289
|
-
import { TASK_BOARD_ON_NOTICE, dashboardRefusalIn, taskBoardSwitchedOn } from "./dashboard-permissions.js";
|
|
329
|
+
import { TASK_BOARD_ON_NOTICE, dashboardRefusalIn, taskBoardOffIn, taskBoardSwitchedOn } from "./dashboard-permissions.js";
|
|
290
330
|
import { mayUseTool, resolveToolSet, scheduleOpRefusal, toolForIpcType, toolRefusedMessage, } from "./tool-permissions.js";
|
|
291
331
|
import { authorizeSession, decideWebGate, loadOrCreateWebToken, readSessionCookies, readWebToken, sessionCookieUpgrade } from "./web-auth.js";
|
|
292
332
|
import { bypassesWebGate, handleAuthRequest, serveGuestRefusedPage, serveSigninPage } from "./auth-api.js";
|
|
293
333
|
import { isWebPageNavigation } from "./web-shell-routes.js";
|
|
294
|
-
import { guestSessionPolicy, localSessionPolicy, tokenEpoch, WebSessionStore } from "./web-session.js";
|
|
334
|
+
import { guestSessionPolicy, localSessionPolicy, sessionVia, tokenEpoch, WebSessionStore } from "./web-session.js";
|
|
295
335
|
import { WebNotices, WEB_NOTICES_FILE } from "./web-notices.js";
|
|
336
|
+
import { DeviceLoginRequests } from "./web-device-login.js";
|
|
296
337
|
import { isOutsideLinkOwner, OUTSIDE_LINK_OWNER, OUTSIDE_LINK_RETRY_MS, OUTSIDE_OWN_CLOSES, outsideDuration, outsideTimer, TOTP_STEP_SECONDS, WEB_REMOTE_ACCESS_FILE, WebRemoteAccess } from "./web-remote-access.js";
|
|
297
338
|
import { authorityNow, evaluateWebAuthority, HOST_OPERATOR, VERIFIED_SESSION_HOURS, webAuthorityPolicy } from "./authority/web-authority.js";
|
|
298
339
|
import { AuthorityStateStore } from "./authority/authority-state.js";
|
|
@@ -315,9 +356,22 @@ import { PROVIDER_SECRET_SPECS, PUBLIC_TUNNEL_SECRET_SPEC, providerSecretSpec, p
|
|
|
315
356
|
const SELF_RESTART_DEADLINE_MS = 300_000;
|
|
316
357
|
import { APPLY_FLEET_TARGET, ApplyJobStore, viewOf, } from "./apply-job.js";
|
|
317
358
|
import { kiroHome } from "./backend/kiro-kas-store.js";
|
|
318
|
-
import { CHAT_PROFILE_LOGIN_BACKENDS, credentialHomeSpec, credentialProfileHome, credentialProfileLogin, credentialProfileLoginCommand, credentialProfileStoreHome, credentialSwitchCarriesConversation, credentialSwitchStartsFresh, instanceCredentialProfile } from "./backend/credential-profile.js";
|
|
359
|
+
import { CHAT_PROFILE_LOGIN_BACKENDS, credentialHomeSpec, credentialProfileHome, credentialProfileEnv, credentialProfileLogin, credentialProfileLoginCommand, credentialProfileStoreHome, credentialSwitchCarriesConversation, credentialSwitchStartsFresh, instanceCredentialProfile, listConfiguredProfiles, resolveCredentialProfile } from "./backend/credential-profile.js";
|
|
319
360
|
import { carryClaudeConversation } from "./backend/claude-carry.js";
|
|
320
|
-
import { mergeBackendOptions, profileKey, profileName, profileOf } from "./classic-bindings.js";
|
|
361
|
+
import { classicProfile, mergeBackendOptions, profileKey, profileName, profileOf, readClassicBindings, readClassicBindingsStrict } from "./classic-bindings.js";
|
|
362
|
+
import { ACCOUNT_CLIS, PROFILE_CLIS, buildAccountsView, profilesOnDisk, weeklyUsage } from "./accounts-view.js";
|
|
363
|
+
import { addAccountProfile, removeAccountProfile } from "./accounts-profiles.js";
|
|
364
|
+
import { signOutAccount } from "./accounts-signout.js";
|
|
365
|
+
import { MachineAccounts, machineAgents } from "./machine-accounts.js";
|
|
366
|
+
import { MachineSignIns } from "./machine-signins.js";
|
|
367
|
+
import { runQuiet } from "./quiet-run.js";
|
|
368
|
+
const ACCOUNT_SIGN_OUT_DEPS = {
|
|
369
|
+
platform: process.platform,
|
|
370
|
+
run: (binary, args, env) => runQuiet(binary, args, env), // its `gone` is kept by withAccountWriter
|
|
371
|
+
// #3305 review P2-5: a deadline is a failure (runQuiet), for the Keychain query too; it only reads, so its child is not
|
|
372
|
+
// held as a credential writer (its answer is a failure until it exits 0 in time).
|
|
373
|
+
keychainHas: async (service) => (await runQuiet("security", ["find-generic-password", "-s", service], process.env, { timeoutMs: 15_000 })).code === 0,
|
|
374
|
+
};
|
|
321
375
|
import { classifyInstanceChange, CLASSIC_HOT_CONFIG_KEYS, HOT_INSTANCE_CONFIG_KEYS, hotConfigUpdate, } from "./instance-config-impact.js";
|
|
322
376
|
import { cleanupWatchVerdict, formatRestartProgressCompletion, RestartProgress, } from "./restart-progress.js";
|
|
323
377
|
import { FleetStartup } from "./fleet-startup.js";
|
|
@@ -331,6 +385,12 @@ import { BackendOutageTracker } from "./backend-outage.js";
|
|
|
331
385
|
import { canUnlockAdvancedTips, DailyTipScheduler, selectTip, visibleTipLevels, } from "./tips.js";
|
|
332
386
|
import { getTmuxSession } from "./config.js";
|
|
333
387
|
import { OwnStatusMessages, discordMessageKey } from "./chat-log-ids.js";
|
|
388
|
+
import { PROFILE_TIMELINE_FILE, PROFILE_UNRECORDED, recordProfileLaunch } from "./usage/profile-timeline.js";
|
|
389
|
+
import { readQuotaHistory } from "./usage/quota-history.js";
|
|
390
|
+
import { estimateCapacity } from "./usage/capacity.js";
|
|
391
|
+
import { covered, hourSources } from "./usage-rollup.js";
|
|
392
|
+
import { KEEP_DAYS } from "./cache-ledger.js";
|
|
393
|
+
import { ratesFor } from "./cache-prices.js";
|
|
334
394
|
// Closed migration cohort: these 11 names existed immediately before the first
|
|
335
395
|
// managed-skill publisher (a1ac499f; parent e267e684). Never grow this set when
|
|
336
396
|
// adding a bundled skill: its new name is not proof of old AgEnD ownership.
|
|
@@ -482,6 +542,8 @@ const INSTALL_TIMEOUT_MS = 10 * 60 * 1000;
|
|
|
482
542
|
* while anything real shows signs of life well before the old two minutes.
|
|
483
543
|
*/
|
|
484
544
|
const PROGRESS_MIN_ELAPSED_MS = 30_000;
|
|
545
|
+
/** M-2391: the threshold tick fires this long after it, never a millisecond before (timers can fire early). */
|
|
546
|
+
const PROGRESS_THRESHOLD_MARGIN_MS = 50;
|
|
485
547
|
/** How much of a tool summary the progress line will show before eliding. */
|
|
486
548
|
const PROGRESS_ACTIVITY_MAX_CHARS = 48;
|
|
487
549
|
/**
|
|
@@ -768,6 +830,9 @@ export class FleetManager {
|
|
|
768
830
|
localPaneRelay = null;
|
|
769
831
|
openingLocalPane = null;
|
|
770
832
|
runtimeHub = null;
|
|
833
|
+
runtimeInstall;
|
|
834
|
+
/** One service for the public installer routes and the administrator API: the hash the dashboard shows is the hash of what is sent. */
|
|
835
|
+
runtimeInstaller() { return this.runtimeInstall ??= new RuntimeInstallService(); }
|
|
771
836
|
runtimeExecutor = null;
|
|
772
837
|
runtimeStatusScheduled = false;
|
|
773
838
|
reconciledRemoteResults = new Set();
|
|
@@ -780,6 +845,8 @@ export class FleetManager {
|
|
|
780
845
|
handlePaneMcp: async (machineId, body, current) => (await this.nativePanes()).handle(machineId, body, current),
|
|
781
846
|
warn: (fields, message) => this.logger.warn(fields, message),
|
|
782
847
|
changed: event => {
|
|
848
|
+
if (event?.type === "machine")
|
|
849
|
+
this.needsYou?.poke();
|
|
783
850
|
if (event?.type === "machine" && this.runtimeHub?.machine(event.machineId)?.status !== "online") {
|
|
784
851
|
for (const [name, config] of Object.entries(this.fleetConfig?.instances ?? {}))
|
|
785
852
|
if (config.machine_id === event.machineId) {
|
|
@@ -789,7 +856,6 @@ export class FleetManager {
|
|
|
789
856
|
this.holdGeneralOldDeliveries(name);
|
|
790
857
|
}
|
|
791
858
|
}
|
|
792
|
-
this.needsYou?.poke();
|
|
793
859
|
}
|
|
794
860
|
if (this.runtimeStatusScheduled || this.shuttingDown)
|
|
795
861
|
return;
|
|
@@ -819,6 +885,8 @@ export class FleetManager {
|
|
|
819
885
|
nativeMcpSessions() {
|
|
820
886
|
return this.nativeMcpStore ??= new NativeMcpSessions(this);
|
|
821
887
|
}
|
|
888
|
+
/** Retire only existing native capabilities; ordinary lifecycle changes do not instantiate the Windows path. */
|
|
889
|
+
invalidateNativeMcp(name) { this.nativeMcpStore?.closeInstance(name); }
|
|
822
890
|
/** The same instance registry and delivery entry point, with a native Windows execution adapter. */
|
|
823
891
|
nativeInstanceRuntime() {
|
|
824
892
|
return this.fleetWindowsRuntime ??= new FleetWindowsRuntime({
|
|
@@ -831,13 +899,23 @@ export class FleetManager {
|
|
|
831
899
|
machineAvailable: id => remoteRuntimeEnabled() && this.runtimeCoordinator().machine(id)?.status === "online",
|
|
832
900
|
machineGeneration: id => this.runtimeCoordinator().machine(id)?.bootId ?? null,
|
|
833
901
|
paneAvailable: id => this.runtimeCoordinator().machine(id)?.paneProtocol === 1,
|
|
834
|
-
validateMachine: (id, cli, sandbox) => {
|
|
902
|
+
validateMachine: (id, cli, sandbox, credentialProfile) => {
|
|
835
903
|
const machine = this.runtimeCoordinator().machine(id);
|
|
836
904
|
const provider = machine?.inventory?.clis.find(row => row.id === cli && row.runnable && row.supports.resume);
|
|
837
905
|
if (!machine || machine.status !== "online" || machine.platform !== "win32" || !provider)
|
|
838
906
|
throw new Error("Choose an online runtime and an available CLI");
|
|
839
907
|
if (sandbox === "read-only" && !provider.readOnlySupport)
|
|
840
908
|
throw new Error("This runtime CLI cannot enforce read-only execution");
|
|
909
|
+
if (credentialProfile !== undefined) {
|
|
910
|
+
// Fail closed at selection time, not at the first message: an old Runtime would ignore the name and run another account.
|
|
911
|
+
if (!machine.runtimeInfo?.capabilities.includes(RUNTIME_CREDENTIAL_CAPABILITY))
|
|
912
|
+
throw new Error("This computer's Runtime is too old to choose a Claude account. Update the Runtime on that computer, then try again.");
|
|
913
|
+
const row = machine.inventory?.credentialProfiles?.profiles.find(profile => profile.name === credentialProfile);
|
|
914
|
+
if (!row)
|
|
915
|
+
throw new Error(`This computer has not reported a credential profile named "${credentialProfile}". On that computer run: agend-runtime login claude-code ${credentialProfile}, then choose Detect again in that computer's CLI diagnostics (Settings → Runtime).`);
|
|
916
|
+
if (row.loggedIn === false)
|
|
917
|
+
throw new Error(`Credential profile "${credentialProfile}" is not signed in on that computer. Sign in there: agend-runtime login claude-code ${credentialProfile}`);
|
|
918
|
+
}
|
|
841
919
|
},
|
|
842
920
|
emit: (event, data) => {
|
|
843
921
|
this.emitSseEvent(event, event === "status" ? this.getUiStatus() : data);
|
|
@@ -1065,6 +1143,26 @@ export class FleetManager {
|
|
|
1065
1143
|
return result;
|
|
1066
1144
|
});
|
|
1067
1145
|
}
|
|
1146
|
+
/** The local machine's inventory as last used to open its pane relay (status only; never a launch decision). */
|
|
1147
|
+
localPaneInventory = null;
|
|
1148
|
+
nativeCliStatus(cli, machineId, daemon) {
|
|
1149
|
+
if (cli !== "codex" && cli !== "claude-code")
|
|
1150
|
+
return {};
|
|
1151
|
+
// The version the running pane actually launched; only without one, the machine's last inventory.
|
|
1152
|
+
let running;
|
|
1153
|
+
try {
|
|
1154
|
+
running = daemon?.usesNativePane?.() ? daemon.nativePaneCliVersion() : undefined;
|
|
1155
|
+
}
|
|
1156
|
+
catch {
|
|
1157
|
+
running = undefined;
|
|
1158
|
+
}
|
|
1159
|
+
const inventory = machineId ? this.runtimeHub?.machine(machineId)?.inventory : this.localPaneInventory;
|
|
1160
|
+
const version = running ?? inventory?.clis?.find(item => item.id === cli && item.runnable)?.version;
|
|
1161
|
+
if (version === undefined || version === null)
|
|
1162
|
+
return {};
|
|
1163
|
+
const result = nativeCliVersionState(cli, version);
|
|
1164
|
+
return { ...(result.version ? { native_cli_version: result.version } : {}), native_cli_verification: result.state };
|
|
1165
|
+
}
|
|
1068
1166
|
async localNativePaneEndpoint() {
|
|
1069
1167
|
const admit = () => { if (this.shuttingDown || this.localPaneDrain || !localWindowsCliEnabled())
|
|
1070
1168
|
throw Error("Local Windows runtime is switched off or draining"); };
|
|
@@ -1081,6 +1179,7 @@ export class FleetManager {
|
|
|
1081
1179
|
]);
|
|
1082
1180
|
admit();
|
|
1083
1181
|
this.localPaneRelay?.stop();
|
|
1182
|
+
this.localPaneInventory = inventory;
|
|
1084
1183
|
const relay = await LocalPaneEndpoint.open({ scope: localPaneScope(this.dataDir), admit, maxAgents: maxAgentsPerMachine,
|
|
1085
1184
|
diagnostic: text => this.logger.warn({ stderr: text }, "Local Windows pane relay wrote to stderr"),
|
|
1086
1185
|
version: provider => inventory.clis.find(row => row.id === provider && row.runnable)?.version ?? null,
|
|
@@ -1129,8 +1228,12 @@ export class FleetManager {
|
|
|
1129
1228
|
if (this.shuttingDown || !isNativePaneInstance(now) || now?.native_agent_id !== config.native_agent_id
|
|
1130
1229
|
|| now?.machine_id !== config.machine_id || now?.working_directory !== config.working_directory || now?.backend !== config.backend
|
|
1131
1230
|
|| now?.model !== config.model || now?.native_sandbox !== config.native_sandbox || now?.systemPrompt !== config.systemPrompt || now?.workflow !== config.workflow
|
|
1132
|
-
|| now?.general_topic !== config.general_topic || now?.native_general_binding !== config.native_general_binding
|
|
1231
|
+
|| now?.general_topic !== config.general_topic || now?.native_general_binding !== config.native_general_binding
|
|
1232
|
+
|| nativeCredentialProfile(now) !== nativeCredentialProfile(config))
|
|
1133
1233
|
throw Error("Native pane configuration or lifetime changed");
|
|
1234
|
+
// Fail closed: a Runtime that does not report the capability would start the terminal on the computer's own account.
|
|
1235
|
+
if (nativeCredentialProfile(config) && !this.runtimeCoordinator().machine(config.machine_id)?.runtimeInfo?.capabilities.includes(RUNTIME_CREDENTIAL_CAPABILITY))
|
|
1236
|
+
throw Error("This computer's Runtime is too old to choose a Claude account. Update the Runtime on that computer, then try again.");
|
|
1134
1237
|
if (config.machine_id ? this.remotePaneDrain || !remoteRuntimeEnabled() : this.localPaneDrain || !localWindowsCliEnabled())
|
|
1135
1238
|
throw Error("Native runtime is switched off");
|
|
1136
1239
|
},
|
|
@@ -1189,12 +1292,12 @@ export class FleetManager {
|
|
|
1189
1292
|
throw Error("General or its paired runtime is unavailable");
|
|
1190
1293
|
const current = () => authorized() && !this.shuttingDown && remoteRuntimeEnabled() && this.runtimeHub === hub
|
|
1191
1294
|
&& this.fleetConfig?.instances[name] === config && hub.paneTransportEpoch(machineId) === epoch;
|
|
1192
|
-
const [{ loadGeneralKnowledge }, { validateGeneralWorkspaceRequest, validateGeneralWorkspaceReceipt, generalWorkspaceUpgrade }, {
|
|
1295
|
+
const [{ loadGeneralKnowledge }, { validateGeneralWorkspaceRequest, validateGeneralWorkspaceReceipt, generalWorkspaceUpgrade }, { assertRunnableNativePaneVersion }] = await Promise.all([
|
|
1193
1296
|
import("./runtime-general-workspace.js"), import("./runtime-general-protocol.js"), import("./runtime-pane-native.js"),
|
|
1194
1297
|
]);
|
|
1195
1298
|
if (!current())
|
|
1196
1299
|
throw Error("General workspace authority expired");
|
|
1197
|
-
|
|
1300
|
+
assertRunnableNativePaneVersion(cli, hub.machine(machineId)?.inventory?.clis.find(row => row.id === cli && row.runnable)?.version ?? null);
|
|
1198
1301
|
const request = validateGeneralWorkspaceRequest({ action: "general-workspace", bindingId, instance: name, cli, packHash: loadGeneralKnowledge(cli).hash });
|
|
1199
1302
|
const inventory = await hub.callPane(machineId, { action: "list" }, maxAgentsPerMachine());
|
|
1200
1303
|
if (!current())
|
|
@@ -1208,6 +1311,14 @@ export class FleetManager {
|
|
|
1208
1311
|
throw new NativePaneRecoveryError({ kind: "host-upgrade" });
|
|
1209
1312
|
return validateGeneralWorkspaceReceipt(result, request);
|
|
1210
1313
|
}
|
|
1314
|
+
/** S3c (S-55): the member's exposure API, attached by S5's member composition (null: no Hub member here). */
|
|
1315
|
+
hubMemberExposureApi = null;
|
|
1316
|
+
hubMemberExposures() { return this.hubMemberExposureApi; }
|
|
1317
|
+
attachHubMemberExposures(api) { this.hubMemberExposureApi = api; }
|
|
1318
|
+
/** S3c PR B: the member's pairing API, attached by S5's member composition (null: no Hub member here). */
|
|
1319
|
+
hubMemberPairingApi = null;
|
|
1320
|
+
hubMemberPairing() { return this.hubMemberPairingApi; }
|
|
1321
|
+
attachHubMemberPairing(api) { this.hubMemberPairingApi = api; }
|
|
1211
1322
|
generalLocationFlights = new Map();
|
|
1212
1323
|
generalAttentionEpisodes = new Map();
|
|
1213
1324
|
generalBindings() { return new GeneralBindings(this.dataDir); }
|
|
@@ -1663,6 +1774,364 @@ export class FleetManager {
|
|
|
1663
1774
|
* them at once; what the fleet itself holds (paired computers' connections, this PC's Windows process, agents' tool
|
|
1664
1775
|
* sessions) follows just after, outside the save that changed them (applyRuntimeSwitches): no restart is needed.
|
|
1665
1776
|
*/
|
|
1777
|
+
/** S-51: the Hub switches follow the configuration in force (load, save, reload rollback), like the runtime ones. */
|
|
1778
|
+
observeHubSwitches() {
|
|
1779
|
+
this.observeHubAgentIncarnations();
|
|
1780
|
+
if (!this.hubEffectsReady || this.hubEffectsScheduled || this.shuttingDown)
|
|
1781
|
+
return;
|
|
1782
|
+
this.hubEffectsScheduled = true;
|
|
1783
|
+
queueMicrotask(() => { this.hubEffectsScheduled = false; void this.applyHubSwitches(); });
|
|
1784
|
+
}
|
|
1785
|
+
/** Reads the raw configuration at run time (the newest wins); off and never started: returns before any import. */
|
|
1786
|
+
async applyHubSwitches() {
|
|
1787
|
+
if (this.shuttingDown || !this.hubEffectsReady)
|
|
1788
|
+
return;
|
|
1789
|
+
const raw = this.rawFleetConfig;
|
|
1790
|
+
const on = raw?.hub?.enabled === true || raw?.hub_member?.enabled === true;
|
|
1791
|
+
if (!on && !this.hubRuntime && !this.hubRuntimeInit)
|
|
1792
|
+
return;
|
|
1793
|
+
try {
|
|
1794
|
+
const runtime = this.hubRuntime ?? (await this.hubRuntimeCreated());
|
|
1795
|
+
if (this.shuttingDown || !this.hubEffectsReady)
|
|
1796
|
+
return; // Stop owns it now (fenced in stopAll, closed in doStopAll)
|
|
1797
|
+
await this.observeHubMemberPairing(raw?.hub_member?.enabled === true);
|
|
1798
|
+
const current = this.rawFleetConfig;
|
|
1799
|
+
await runtime.apply({ hub: current?.hub, hub_member: current?.hub_member });
|
|
1800
|
+
}
|
|
1801
|
+
catch (err) {
|
|
1802
|
+
this.logger.warn({ err: err?.message ?? String(err) }, "Hub switches could not be applied");
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
/** Single flight: one import, one runtime, assigned once; every caller (and Stop) gets that same runtime. */
|
|
1806
|
+
hubRuntimeCreated() {
|
|
1807
|
+
this.hubRuntimeInit ??= (async () => {
|
|
1808
|
+
const { HubRuntime } = await import("./hub/runtime.js");
|
|
1809
|
+
const runtime = new HubRuntime({
|
|
1810
|
+
home: this.dataDir,
|
|
1811
|
+
log: (level, message, meta) => this.logger[level](meta ?? {}, message),
|
|
1812
|
+
onHoldsChanged: holds => { this.hubHolds = holds; this.needsYou?.poke(); },
|
|
1813
|
+
// S-51 PR 2b: the fleet's side of a Hub membership (pairing binding, local agents, attachment points).
|
|
1814
|
+
member: {
|
|
1815
|
+
// S3c's currentBinding: a fresh, fail-closed read of the pairing state (null unless consistent and connectable).
|
|
1816
|
+
boundHub: () => this.hubMemberBinding?.(this.dataDir)?.hubId ?? null,
|
|
1817
|
+
agents: () => this.hubMemberAgents(),
|
|
1818
|
+
// P1 representative mode (docs/design/hub-representative-agent.md): ordinary delivery + the report_result hook.
|
|
1819
|
+
representative: {
|
|
1820
|
+
quota: agent => this.hubAgentQuota(agent),
|
|
1821
|
+
deliver: input => this.deliverHubQuestion(input),
|
|
1822
|
+
agentToken: agent => this.hubAgentToken(agent),
|
|
1823
|
+
// attachments-v1: a question's files go into the agent's inbox; an answer's come from its own paths.
|
|
1824
|
+
files: { stateDir: this.dataDir,
|
|
1825
|
+
inboxDir: agent => isSafeInstanceDirName(agent) ? join(this.dataDir, "workspaces", agent, "inbox") : null,
|
|
1826
|
+
scratchDir: agent => isSafeInstanceDirName(agent) ? join(this.dataDir, "workspaces", agent, "hub-files") : null },
|
|
1827
|
+
attachReports: (handler, failed) => { this.hubReports = handler; this.hubDeliveryFailed = failed; },
|
|
1828
|
+
},
|
|
1829
|
+
attachExposures: api => this.attachHubMemberExposures(api),
|
|
1830
|
+
attachAttention: read => this.attachHubExecutionAttention(read),
|
|
1831
|
+
pokeAttention: () => this.needsYou?.poke(),
|
|
1832
|
+
linkState: state => { this.hubMemberLink = state; },
|
|
1833
|
+
},
|
|
1834
|
+
});
|
|
1835
|
+
// Stop began during the import: it holds this promise and closes the runtime; do not hand it out again.
|
|
1836
|
+
if (this.shuttingDown || !this.hubEffectsReady)
|
|
1837
|
+
runtime.fence();
|
|
1838
|
+
else
|
|
1839
|
+
this.hubRuntime = runtime;
|
|
1840
|
+
return runtime;
|
|
1841
|
+
})();
|
|
1842
|
+
return this.hubRuntimeInit;
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* S-51 PR 2b: while the member switch is on, the local owner's "Connect to a Hub" backend (S3c's pairing API) is
|
|
1846
|
+
* attached, paired or not; switched off, it is detached. A binding change re-composes the member side.
|
|
1847
|
+
*/
|
|
1848
|
+
async observeHubMemberPairing(on) {
|
|
1849
|
+
if (!on) {
|
|
1850
|
+
this.attachHubMemberPairing(null);
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1853
|
+
if (this.hubMemberPairingApi)
|
|
1854
|
+
return;
|
|
1855
|
+
const { createHubMemberPairingApi, currentBinding } = await import("./hub/member/pairing-api.js");
|
|
1856
|
+
if (this.shuttingDown || !this.hubEffectsReady || this.hubMemberPairingApi)
|
|
1857
|
+
return;
|
|
1858
|
+
this.hubMemberBinding = currentBinding;
|
|
1859
|
+
this.attachHubMemberPairing(createHubMemberPairingApi({
|
|
1860
|
+
home: this.dataDir,
|
|
1861
|
+
enabled: () => this.rawFleetConfig?.hub_member?.enabled === true,
|
|
1862
|
+
link: () => (this.hubMemberLink === "online" ? "online" : "offline"),
|
|
1863
|
+
hold: () => (this.hubMemberLink === "revoked" ? "revoked" : null),
|
|
1864
|
+
// Disconnect: stop the member client now (the runtime re-composes from the saved binding, fencing first).
|
|
1865
|
+
fence: () => { void this.hubRuntime?.refresh(); },
|
|
1866
|
+
// A claim saved, a disconnect tombstone or a cancel: re-compose the member side for the new binding.
|
|
1867
|
+
bindingChanged: () => { void this.hubRuntime?.refresh(); },
|
|
1868
|
+
// Disconnect withdraws every published exposure locally (each saved before this returns).
|
|
1869
|
+
withdrawAll: () => this.hubMemberWithdrawAll(),
|
|
1870
|
+
}));
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Disconnect: every published exposure is withdrawn and saved before the disconnect reports success. Through the
|
|
1874
|
+
* running member's API, or — held or not composed — directly in the member's own store; a failure here makes the
|
|
1875
|
+
* disconnect report "unsaved" (S3c), so consent never outlives the disconnect.
|
|
1876
|
+
*/
|
|
1877
|
+
async hubMemberWithdrawAll() {
|
|
1878
|
+
const api = this.hubMemberExposureApi;
|
|
1879
|
+
if (api) {
|
|
1880
|
+
for (const view of api.list()) {
|
|
1881
|
+
if (view.exposureId && view.state === "published")
|
|
1882
|
+
await api.withdraw(view.exposureId, view.revision);
|
|
1883
|
+
}
|
|
1884
|
+
return;
|
|
1885
|
+
}
|
|
1886
|
+
const hubId = this.hubMemberPairingApi?.boundHub()?.hubId ?? null;
|
|
1887
|
+
if (!hubId)
|
|
1888
|
+
return;
|
|
1889
|
+
const { withdrawMemberExposuresOffline } = await import("./hub/compose/member.js");
|
|
1890
|
+
await withdrawMemberExposuresOffline(this.dataDir, hubId);
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* The Hub exposure picker's agents (docs/design/hub-representative-agent.md): every configured instance normal
|
|
1894
|
+
* delivery addresses, General included, shown by its display name. The dedicated Hub daemon is not a fleet instance.
|
|
1895
|
+
*/
|
|
1896
|
+
hubMemberAgents() {
|
|
1897
|
+
return Object.keys(this.fleetConfig?.instances ?? {}).map(name => ({ name, display: this.shownInstanceName(name) }));
|
|
1898
|
+
}
|
|
1899
|
+
/** Same cached usage source as the owner's rail, scoped to the representative's CLI and credential profile. */
|
|
1900
|
+
async hubAgentQuota(agent) {
|
|
1901
|
+
const binding = () => {
|
|
1902
|
+
const config = this.fleetConfig?.instances[agent];
|
|
1903
|
+
if (!config || isWindowsInstance(config))
|
|
1904
|
+
return null; // runner usage never belongs to a Linux login
|
|
1905
|
+
const backend = this.backendNameForInstance(agent), provider = usageProviderIdForBackend(backend);
|
|
1906
|
+
if (!provider)
|
|
1907
|
+
return null;
|
|
1908
|
+
const profile = this.credentialProfileOf(agent, backend);
|
|
1909
|
+
return profile ? `${provider}:${profile}` : provider;
|
|
1910
|
+
};
|
|
1911
|
+
const id = binding();
|
|
1912
|
+
const { quotaBand } = await import("./hub/member/quota.js");
|
|
1913
|
+
const paused = () => this.daemons.get(agent)?.quotaPaused?.() === true
|
|
1914
|
+
|| this.lifecycle.isPaused(agent) && readPauseReason(this.getInstanceDir(agent)) === "quota";
|
|
1915
|
+
if (!id)
|
|
1916
|
+
return { band: "unknown" };
|
|
1917
|
+
try {
|
|
1918
|
+
const snapshot = await getUsageSnapshot(false, new Set([id]));
|
|
1919
|
+
if (binding() !== id)
|
|
1920
|
+
return { band: "unknown" };
|
|
1921
|
+
return quotaBand(snapshot.providers.find(p => p.id === id), paused());
|
|
1922
|
+
}
|
|
1923
|
+
catch {
|
|
1924
|
+
return quotaBand(undefined, paused());
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
/**
|
|
1928
|
+
* A published representative's lifecycle token (#3145, #3147 review): a DURABLE incarnation id per agent name, rotated
|
|
1929
|
+
* whenever its backend, folder or runtime changes and dropped when the instance is removed. A replacement (remove and
|
|
1930
|
+
* re-add, even with the same name and config, across restarts) or any retarget — including A→B→A — gets a new id, so
|
|
1931
|
+
* earlier consent never matches again without an explicit republish. Stopping or pausing changes nothing.
|
|
1932
|
+
*/
|
|
1933
|
+
hubAgentToken(agent) {
|
|
1934
|
+
const instances = this.fleetConfig?.instances ?? {};
|
|
1935
|
+
if (!Object.prototype.hasOwnProperty.call(instances, agent))
|
|
1936
|
+
return null;
|
|
1937
|
+
if (this.hubIncarnationsBroken)
|
|
1938
|
+
return null;
|
|
1939
|
+
let id;
|
|
1940
|
+
try {
|
|
1941
|
+
this.settleHubIncarnations();
|
|
1942
|
+
id = this.hubIncarnationsBroken ? null : this.hubAgentIncarnation(agent, instances[agent], true);
|
|
1943
|
+
}
|
|
1944
|
+
catch (err) {
|
|
1945
|
+
this.logger.warn({ err: err?.message, agent }, "Hub agent incarnation could not be saved; the agent is not a deliverable representative");
|
|
1946
|
+
return null;
|
|
1947
|
+
}
|
|
1948
|
+
return id ? createHash("sha256").update(JSON.stringify(["agend-hub-agent-v2", agent, id])).digest("hex") : null;
|
|
1949
|
+
}
|
|
1950
|
+
hubIncarnationsPath() { return join(this.dataDir, "hub-member", "agent-incarnations.json"); }
|
|
1951
|
+
/**
|
|
1952
|
+
* M-2451 (#3147 residual): written beside hub-member/, in the data directory itself, when an invalidation could not be
|
|
1953
|
+
* made durable in hub-member/. A later process that finds it invalidates every incarnation before handing out any
|
|
1954
|
+
* token, so a restart never revives consent the earlier process had to withdraw (A→B→A, or a removal, while hub-member/
|
|
1955
|
+
* was unwritable).
|
|
1956
|
+
*/
|
|
1957
|
+
hubIncarnationsMarkerPath() { return join(this.dataDir, "hub-member-invalidate.pending"); }
|
|
1958
|
+
/** Whether this process has settled the incarnations on disk (the marker handled, the file proven writable). */
|
|
1959
|
+
hubIncarnationsSettled = false;
|
|
1960
|
+
/**
|
|
1961
|
+
* Once per process, before the first token: an invalidation an earlier process could not persist (the marker) clears
|
|
1962
|
+
* every incarnation; and an existing file must be rewritable here, else this process is broken (no token at all) —
|
|
1963
|
+
* an incarnation this process could not rotate must never be handed out. Fails closed: any doubt marks it broken.
|
|
1964
|
+
*/
|
|
1965
|
+
settleHubIncarnations() {
|
|
1966
|
+
if (this.hubIncarnationsSettled || this.hubIncarnationsBroken || !this.dataDir)
|
|
1967
|
+
return;
|
|
1968
|
+
const path = this.hubIncarnationsPath(), marker = this.hubIncarnationsMarkerPath();
|
|
1969
|
+
if (existsSync(marker)) {
|
|
1970
|
+
try {
|
|
1971
|
+
unlinkSync(path);
|
|
1972
|
+
}
|
|
1973
|
+
catch (err) {
|
|
1974
|
+
if (err?.code !== "ENOENT") {
|
|
1975
|
+
this.hubIncarnationsBroken = true;
|
|
1976
|
+
this.logger.warn({ err: err?.message }, "An earlier Hub consent invalidation is still pending and cannot be applied; no Hub representative token is handed out");
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
// The clear is durable; a marker that cannot be removed only clears again next time (over-invalidation, never revival).
|
|
1981
|
+
try {
|
|
1982
|
+
unlinkSync(marker);
|
|
1983
|
+
}
|
|
1984
|
+
catch { /* left: harmless */ }
|
|
1985
|
+
this.logger.warn("An earlier Hub consent invalidation was applied: every Hub representative needs a republish");
|
|
1986
|
+
}
|
|
1987
|
+
if (existsSync(path))
|
|
1988
|
+
this.writeHubIncarnations(this.readHubIncarnations()); // throws (broken) when hub-member/ is not writable
|
|
1989
|
+
this.hubIncarnationsSettled = true;
|
|
1990
|
+
} /**
|
|
1991
|
+
* #3147 r2: set when an invalidation could not be made durable in any way (neither the atomic write nor removing the
|
|
1992
|
+
* file worked). From then on this process hands out no representative token at all, and the transitions the fleet
|
|
1993
|
+
* controls (a config save, a removal) are refused instead of applied.
|
|
1994
|
+
*/
|
|
1995
|
+
hubIncarnationsBroken = false;
|
|
1996
|
+
readHubIncarnations() {
|
|
1997
|
+
try {
|
|
1998
|
+
const value = JSON.parse(readFileSync(this.hubIncarnationsPath(), "utf8"));
|
|
1999
|
+
return value && typeof value === "object" && !Array.isArray(value) ? Object.assign(Object.create(null), value) : Object.create(null);
|
|
2000
|
+
}
|
|
2001
|
+
catch {
|
|
2002
|
+
return Object.create(null);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* Persist the incarnation map: "written", or — when the atomic write fails — "cleared": the whole file is removed, which
|
|
2007
|
+
* durably invalidates EVERY earlier incarnation (all consent then needs a republish; never a revival). Throws (and
|
|
2008
|
+
* marks the process broken) only when neither is possible.
|
|
2009
|
+
*/
|
|
2010
|
+
writeHubIncarnations(map) {
|
|
2011
|
+
const path = this.hubIncarnationsPath(), tmp = `${path}.${process.pid}.tmp`;
|
|
2012
|
+
try {
|
|
2013
|
+
mkdirSync(join(this.dataDir, "hub-member"), { recursive: true, mode: 0o700 });
|
|
2014
|
+
writeFileSync(tmp, JSON.stringify(map), { mode: 0o600 });
|
|
2015
|
+
renameSync(tmp, path);
|
|
2016
|
+
return "written";
|
|
2017
|
+
}
|
|
2018
|
+
catch (err) {
|
|
2019
|
+
try {
|
|
2020
|
+
rmSync(tmp, { recursive: false, force: true });
|
|
2021
|
+
}
|
|
2022
|
+
catch { /* a directory planted there: left alone */ }
|
|
2023
|
+
try {
|
|
2024
|
+
unlinkSync(path);
|
|
2025
|
+
}
|
|
2026
|
+
catch (gone) {
|
|
2027
|
+
if (gone?.code !== "ENOENT") {
|
|
2028
|
+
this.hubIncarnationsBroken = true;
|
|
2029
|
+
// M-2451: record the withdrawal outside hub-member/, so a restart does not revive what this process withdrew.
|
|
2030
|
+
try {
|
|
2031
|
+
writeFileSync(this.hubIncarnationsMarkerPath(), "", { mode: 0o600 });
|
|
2032
|
+
}
|
|
2033
|
+
catch { /* the data directory too: nothing durable is left */ }
|
|
2034
|
+
throw err;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
this.logger.warn({ err: err?.message }, "Hub agent incarnations could not be saved; every earlier Hub consent is invalidated (republish needed)");
|
|
2038
|
+
return "cleared";
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
/** The agent's durable incarnation id (create: make one if none; else null). A changed fingerprint rotates it. */
|
|
2042
|
+
hubAgentIncarnation(agent, cfg, create) {
|
|
2043
|
+
const fp = createHash("sha256").update(JSON.stringify([cfg.backend ?? "claude-code", cfg.working_directory, cfg.runtime ?? "", cfg.machine_id ?? ""])).digest("hex");
|
|
2044
|
+
const map = this.readHubIncarnations(), entry = Object.prototype.hasOwnProperty.call(map, agent) ? map[agent] : undefined;
|
|
2045
|
+
if (entry && entry.fp === fp && typeof entry.id === "string")
|
|
2046
|
+
return entry.id;
|
|
2047
|
+
if (!entry && !create)
|
|
2048
|
+
return null;
|
|
2049
|
+
map[agent] = { id: randomUUID(), fp };
|
|
2050
|
+
// A rotation that could only clear the file still invalidated the old id durably; the new one is made next time.
|
|
2051
|
+
return this.writeHubIncarnations(map) === "written" ? map[agent].id : null;
|
|
2052
|
+
}
|
|
2053
|
+
/**
|
|
2054
|
+
* Every configuration in force: rotate a recorded agent's incarnation when its backend/folder/runtime changed; drop
|
|
2055
|
+
* removed ones. strict (a config save the fleet is about to write): a failure to make that durable throws, so the save
|
|
2056
|
+
* is refused instead of applied. Otherwise (a load or reload of a hand-edited file) a failure is logged — the
|
|
2057
|
+
* invalidation then is the cleared file, or, if nothing could be written, this process hands out no token at all.
|
|
2058
|
+
*/
|
|
2059
|
+
observeHubAgentIncarnations(strict = false) {
|
|
2060
|
+
// Only against a loaded configuration: never forget every agent because none is loaded yet.
|
|
2061
|
+
if (!this.dataDir || !this.fleetConfig?.instances)
|
|
2062
|
+
return;
|
|
2063
|
+
try {
|
|
2064
|
+
this.settleHubIncarnations();
|
|
2065
|
+
if (this.hubIncarnationsBroken)
|
|
2066
|
+
throw new Error("Hub agent incarnations cannot be written here");
|
|
2067
|
+
if (!existsSync(this.hubIncarnationsPath()))
|
|
2068
|
+
return;
|
|
2069
|
+
const instances = this.fleetConfig.instances;
|
|
2070
|
+
for (const agent of Object.keys(this.readHubIncarnations())) {
|
|
2071
|
+
// Gone from the configuration in force (removed by hand in fleet.yaml, too): forgotten, never revived by a re-add.
|
|
2072
|
+
if (Object.prototype.hasOwnProperty.call(instances, agent))
|
|
2073
|
+
this.hubAgentIncarnation(agent, instances[agent], false);
|
|
2074
|
+
else
|
|
2075
|
+
this.forgetHubAgentIncarnation(agent, true);
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
catch (err) {
|
|
2079
|
+
this.logger?.warn({ err: err?.message }, "Hub agent incarnations could not be checked");
|
|
2080
|
+
if (strict)
|
|
2081
|
+
throw new Error(`Hub consent for a changed agent could not be invalidated durably; the change is not saved (${err?.message})`);
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
/** A removed instance's incarnation goes with it (a later instance of the same name is a new one). strict: throw if not durable. */
|
|
2085
|
+
forgetHubAgentIncarnation(agent, strict = false) {
|
|
2086
|
+
try {
|
|
2087
|
+
if (!this.dataDir || !existsSync(this.hubIncarnationsPath()))
|
|
2088
|
+
return;
|
|
2089
|
+
const map = this.readHubIncarnations();
|
|
2090
|
+
if (!Object.prototype.hasOwnProperty.call(map, agent))
|
|
2091
|
+
return;
|
|
2092
|
+
delete map[agent];
|
|
2093
|
+
this.writeHubIncarnations(map);
|
|
2094
|
+
}
|
|
2095
|
+
catch (err) {
|
|
2096
|
+
this.logger.warn({ err: err?.message, agent }, "Hub agent incarnation could not be dropped");
|
|
2097
|
+
if (strict)
|
|
2098
|
+
throw new Error(`Hub consent for ${agent} could not be invalidated durably; refusing the change (${err?.message})`);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
/**
|
|
2102
|
+
* A Hub question to its representative agent: ordinary cross-instance delivery (idle gate, wake, retries), from the
|
|
2103
|
+
* reserved Hub sender with the Hub-issued correlation id. beforeInput runs immediately before the IPC hand-off.
|
|
2104
|
+
*/
|
|
2105
|
+
async deliverHubQuestion(input) {
|
|
2106
|
+
const { HUB_REPORT_TARGET } = await import("./hub/representative.js");
|
|
2107
|
+
if (this.shuttingDown || !this.fleetConfig?.instances[input.agent])
|
|
2108
|
+
return false;
|
|
2109
|
+
// Windows agents run through their own runtime, which has no pre-input hook: not a P1 representative.
|
|
2110
|
+
if (isNativeExecInstance(this.fleetConfig.instances[input.agent]))
|
|
2111
|
+
return false;
|
|
2112
|
+
const ipcMeta = {
|
|
2113
|
+
chat_id: "",
|
|
2114
|
+
message_id: `hubmsg-${input.correlationId.slice(4)}`,
|
|
2115
|
+
user: `instance:${HUB_REPORT_TARGET}`,
|
|
2116
|
+
user_id: `instance:${HUB_REPORT_TARGET}`,
|
|
2117
|
+
ts: new Date().toISOString(),
|
|
2118
|
+
thread_id: "",
|
|
2119
|
+
from_instance: HUB_REPORT_TARGET,
|
|
2120
|
+
from_display: "Hub",
|
|
2121
|
+
correlation_id: input.correlationId,
|
|
2122
|
+
request_kind: "query",
|
|
2123
|
+
requires_reply: "true",
|
|
2124
|
+
task_summary: "A question from the Hub",
|
|
2125
|
+
};
|
|
2126
|
+
const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: input.text, meta: ipcMeta }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: input.beforeInput });
|
|
2127
|
+
return result !== false;
|
|
2128
|
+
}
|
|
2129
|
+
/** S-51: why the Hub (or this fleet's Hub membership) is not running, if it is held. Empty while off or running. */
|
|
2130
|
+
getHubHolds() {
|
|
2131
|
+
return this.hubHolds;
|
|
2132
|
+
}
|
|
2133
|
+
hubBrowserCertificate() { return this.hubRuntime?.browserCertificateSettings() ?? null; }
|
|
2134
|
+
hubRetention() { return this.hubRuntime?.retentionSettings() ?? null; }
|
|
1666
2135
|
observeRuntimeSwitches() {
|
|
1667
2136
|
setConfiguredRuntimeSwitches(this.fleetConfig?.runtimes);
|
|
1668
2137
|
if (!this.runtimeEffects || this.runtimeEffectsScheduled)
|
|
@@ -1731,6 +2200,32 @@ export class FleetManager {
|
|
|
1731
2200
|
return this.daemons.get(name)?.bootId ?? null;
|
|
1732
2201
|
}
|
|
1733
2202
|
rawFleetConfig = {};
|
|
2203
|
+
/**
|
|
2204
|
+
* S-51 (#3095, experimental, off by default): the Hub runtime. src/hub/runtime.js is imported only once a Hub switch
|
|
2205
|
+
* (hub.enabled / hub_member.enabled) is on; while both are off nothing Hub-related loads, opens or listens.
|
|
2206
|
+
*/
|
|
2207
|
+
hubRuntime = null;
|
|
2208
|
+
/** S3c's currentBinding reader, loaded with the pairing API (only while the member switch is on). */
|
|
2209
|
+
hubMemberBinding = null;
|
|
2210
|
+
/** The member link as the "Connect to a Hub" view shows it (S5's client lifecycle). */
|
|
2211
|
+
hubMemberLink = "offline";
|
|
2212
|
+
/** OutboundContext: the Hub representative's answer hook (null: no member service running, or not a Hub answer). */
|
|
2213
|
+
hubReport(input) {
|
|
2214
|
+
return this.hubReports?.(input) ?? null;
|
|
2215
|
+
}
|
|
2216
|
+
/** The member side's pane-failure hook for a Hub-issued correlation id (else null). */
|
|
2217
|
+
hubDeliveryFailed = null;
|
|
2218
|
+
/** The member side's report_result hook for HUB_REPORT_TARGET while a representative service runs (else null). */
|
|
2219
|
+
hubReports = null;
|
|
2220
|
+
/** The one in-flight creation (single flight): overlapping first observations share it, Stop waits for it. */
|
|
2221
|
+
hubRuntimeInit = null;
|
|
2222
|
+
hubEffectsReady = false;
|
|
2223
|
+
hubEffectsScheduled = false;
|
|
2224
|
+
hubHolds = [];
|
|
2225
|
+
/** M-2457 §6 rule 2: the fleet is held — an old tmux server is still on the socket and AgEnD can't prove it its own. */
|
|
2226
|
+
tmuxHold = null;
|
|
2227
|
+
/** M-2457 §6 rule 3: instances held by an old 2.3 window AgEnD could not prove its own. */
|
|
2228
|
+
legacyWindowHolds = new Map();
|
|
1734
2229
|
rawFleetDocument = null;
|
|
1735
2230
|
/** #2208: the paths a saveFleetConfig() wrote, for its check that nothing else changed. */
|
|
1736
2231
|
fleetDocumentWrites = null;
|
|
@@ -1880,6 +2375,7 @@ export class FleetManager {
|
|
|
1880
2375
|
startupRetryNotices = new Map();
|
|
1881
2376
|
/** Unsupported-CLI refusals waiting to go out, grouped by reason (#1109). */
|
|
1882
2377
|
unsupportedCliNotices = new Map();
|
|
2378
|
+
kiroCompatibilityHolds = new Map();
|
|
1883
2379
|
kiroIncompatNotices = new Map();
|
|
1884
2380
|
/** Backoff between automatic startup retries; the last step repeats while the backend is down. */
|
|
1885
2381
|
static STARTUP_RETRY_BACKOFF_MS = [60_000, 5 * 60_000, 15 * 60_000];
|
|
@@ -1908,6 +2404,10 @@ export class FleetManager {
|
|
|
1908
2404
|
kiroMigrationRuns = new Map();
|
|
1909
2405
|
/** #1386 "Needs you": the list, its live chat messages and Acknowledge. Started with the fleet (finishStartup). */
|
|
1910
2406
|
needsYou = null;
|
|
2407
|
+
/** #3292: "Keep sign-in alive" (signin-keepalive.ts); built at startup, stopped at shutdown. */
|
|
2408
|
+
signInKeepAlive = null;
|
|
2409
|
+
hubExecutionAttention = null;
|
|
2410
|
+
missedOfflineStore = null;
|
|
1911
2411
|
configHistory = null;
|
|
1912
2412
|
configHistoryTimer = null;
|
|
1913
2413
|
loadedFleetSource = null;
|
|
@@ -2023,6 +2523,9 @@ export class FleetManager {
|
|
|
2023
2523
|
discordPresenceEagerPending = false;
|
|
2024
2524
|
discordPresenceInFlight = null;
|
|
2025
2525
|
static DISCORD_PRESENCE_REFRESH_MS = 15 * 60_000;
|
|
2526
|
+
/** #3066 §1d: how often a fleet with no Discord bot reads the quota for its history (the user's choice: 30 min). */
|
|
2527
|
+
static QUOTA_BACKGROUND_READ_MS = 30 * 60_000;
|
|
2528
|
+
quotaReadTimer = null;
|
|
2026
2529
|
/** Days of event/activity history to keep. */
|
|
2027
2530
|
static EVENT_LOG_RETENTION_DAYS = 30;
|
|
2028
2531
|
watchdogTimer = null;
|
|
@@ -2218,6 +2721,8 @@ export class FleetManager {
|
|
|
2218
2721
|
/** #2855: a trusted guest's searches, per account. */
|
|
2219
2722
|
guestSearches = new OfficeWriteLimiter(undefined, { perWindow: GUEST_SEARCHES.perWindow, windowMs: GUEST_SEARCHES.windowMs });
|
|
2220
2723
|
officeSharesInstance;
|
|
2724
|
+
/** #2861: when each instance was last talked to and answered (no words), for share links' dialogue box. */
|
|
2725
|
+
officeTalk = new OfficeTalk();
|
|
2221
2726
|
/**
|
|
2222
2727
|
* #2636: Office share links — the live Office view for people outside the fleet, read-only, on a quick tunnel of
|
|
2223
2728
|
* their own (a manager and lease of its own: never the fleet's one tunnel lane nor the public link's preview tunnel).
|
|
@@ -2234,6 +2739,7 @@ export class FleetManager {
|
|
|
2234
2739
|
hidden: name => crossInstanceVisibility(this.fleetConfig, name) === "hidden",
|
|
2235
2740
|
skins: this.officeSkins,
|
|
2236
2741
|
levels: () => this.officeLevelsSnapshot(),
|
|
2742
|
+
talk: scope => this.officeTalk.recent(scope),
|
|
2237
2743
|
},
|
|
2238
2744
|
manager: new ManagedTunnel({ dataDir: join(this.dataDir, OFFICE_SHARE_TUNNEL_DIR), log: () => this.logger.warn("Office share tunnel cleanup requires attention") }),
|
|
2239
2745
|
ensure: signal => ensureCloudflared({ dataDir: this.dataDir, pinnedOnly: true, signal }),
|
|
@@ -2590,6 +3096,26 @@ export class FleetManager {
|
|
|
2590
3096
|
const baselines = this.settingsBaselineReader = new SettingsBaselines({ dataDir: this.dataDir, configPath: () => this.configPath,
|
|
2591
3097
|
config: () => this.fleetConfig, current: () => [this.settingsGeneration, this.settingsRuntimeRevision, this.shuttingDown],
|
|
2592
3098
|
generalLocation: input => this.previewGeneralLocation(input),
|
|
3099
|
+
hubMembership: raw => hubMembershipSettings(raw),
|
|
3100
|
+
// S3c (S-55): a Hub exposure publish's confirmation summary, while a member composition is attached.
|
|
3101
|
+
hubBrowserCertificate: (input, binding) => {
|
|
3102
|
+
const control = this.hubBrowserCertificate();
|
|
3103
|
+
if (!control)
|
|
3104
|
+
throw Error("unavailable");
|
|
3105
|
+
return control.preview(input, binding);
|
|
3106
|
+
},
|
|
3107
|
+
hubExposure: (input) => {
|
|
3108
|
+
const api = this.hubMemberExposureApi;
|
|
3109
|
+
if (!api)
|
|
3110
|
+
throw Object.assign(new Error("hub_member_unavailable"), { code: "hub_member_unavailable" });
|
|
3111
|
+
return api.preview(input);
|
|
3112
|
+
},
|
|
3113
|
+
hubPairing: (action, input) => {
|
|
3114
|
+
const api = this.hubMemberPairingApi;
|
|
3115
|
+
if (!api)
|
|
3116
|
+
throw Object.assign(new Error("hub_member_unavailable"), { code: "hub_member_unavailable" });
|
|
3117
|
+
return pairingSummary(action, input, api.view(), api.boundHub());
|
|
3118
|
+
},
|
|
2593
3119
|
proof: (kind, target, id, binding, key) => {
|
|
2594
3120
|
const map = kind === "provider" ? this.providerSecretChallenges : kind === "binding" ? this.connectionBindingChallenges : this.connectionSecretChallenges;
|
|
2595
3121
|
const proof = map.get(id);
|
|
@@ -2739,6 +3265,132 @@ export class FleetManager {
|
|
|
2739
3265
|
// while the request is applied fences it.
|
|
2740
3266
|
return this.liveOwner(req, { hostOnly: false });
|
|
2741
3267
|
}
|
|
3268
|
+
/**
|
|
3269
|
+
* Refs #3061 (P2a): the new-device approval's one authority — the same one that decides an agent's request: this web-only
|
|
3270
|
+
* fleet's owner, asked of the LIVE session each time (a sign-out, an expiry, a revocation, the authority switch or
|
|
3271
|
+
* "Only this computer can authorize" turning a session into a non-owner is seen at once). A LAN session that signed in
|
|
3272
|
+
* with a one-time code, a session a device approval made, a guest, a chat fleet's admin and the CLI's header token are
|
|
3273
|
+
* none of them this: they are told so, and learn nothing about any request.
|
|
3274
|
+
*/
|
|
3275
|
+
deviceApprovalOwner(req) {
|
|
3276
|
+
return this.liveOwner(req, { hostOnly: false });
|
|
3277
|
+
}
|
|
3278
|
+
/**
|
|
3279
|
+
* Refs #3061 (auth-api): device-code sign-in is offered — a web-only fleet with web authorization on. With
|
|
3280
|
+
* `web.verified_authority.enabled: false` no one is an owner (liveOwner → null), so no one could approve: the three
|
|
3281
|
+
* `/auth/device-login*` routes answer 404 and the sign-in page shows no button. "Only this computer can authorize"
|
|
3282
|
+
* does not close it: this computer's own session can still approve.
|
|
3283
|
+
*/
|
|
3284
|
+
deviceLoginAvailable() {
|
|
3285
|
+
return this.isWebOnlyFleet() && this.webAuthorityState().enabled;
|
|
3286
|
+
}
|
|
3287
|
+
/** Refs #3061 (P2b): `web.login_qr` (default off), read per page served — the sign-in page then draws the approve link's QR code. */
|
|
3288
|
+
loginQrEnabled() {
|
|
3289
|
+
return this.fleetConfig?.web?.login_qr === true;
|
|
3290
|
+
}
|
|
3291
|
+
/**
|
|
3292
|
+
* GET /ui/devices: is this a web-only fleet, may THIS session approve a new device and end another (is it the verified
|
|
3293
|
+
* owner), and — to an admin session, never to a guest or the CLI's header token — the signed-in devices (Refs #3061, P2b).
|
|
3294
|
+
* `authority`: web authorization is on. With it off nobody is an owner (liveOwner → null), so nobody may add a device or
|
|
3295
|
+
* sign another out; the page says why and points to `agend web-token rotate` on this computer instead of "use the AgEnD
|
|
3296
|
+
* computer", which would not help.
|
|
3297
|
+
*/
|
|
3298
|
+
webDevicesStatus(req) {
|
|
3299
|
+
const webOnly = this.isWebOnlyFleet();
|
|
3300
|
+
const owner = webOnly && !!this.deviceApprovalOwner(req);
|
|
3301
|
+
return { webOnly, owner, authority: webOnly && this.webAuthorityState().enabled, devices: webOnly ? this.webDeviceRows(req) : [] };
|
|
3302
|
+
}
|
|
3303
|
+
/**
|
|
3304
|
+
* Refs #3061 (P2b): the device list — this fleet's admin sessions, newest activity first (a guest's sessions are the
|
|
3305
|
+
* Guests page's, and a read-only tier has none): how each was approved, whether it carries owner authority, and which
|
|
3306
|
+
* one is the reader's own. The same people may read this as may read `GET /auth/sessions` (any admin session).
|
|
3307
|
+
*
|
|
3308
|
+
* `ownerVerified` is the §3 verdict for the session as it would be used from where it signs in (a host session from
|
|
3309
|
+
* this computer, a session from outside over the link): one that signed in with a one-time code or a device approval is
|
|
3310
|
+
* not an owner until the authenticator vouches for it. Display only — the checks that act on it run again at each use.
|
|
3311
|
+
*/
|
|
3312
|
+
webDeviceRows(req) {
|
|
3313
|
+
const auth = authorizeSession(req, this.webToken, this.webSessions, { touch: false });
|
|
3314
|
+
if (auth.kind !== "ok" || auth.session.tier !== "admin" || !this.webSessions)
|
|
3315
|
+
return [];
|
|
3316
|
+
const authorizations = this.sessionAuthorizationStore();
|
|
3317
|
+
return this.webSessions.list(auth.session.idHash, r => r.tier === "admin").map(summary => {
|
|
3318
|
+
const record = this.webSessions.findByHandle(summary.handle);
|
|
3319
|
+
const gateway = summary.surface === "gateway";
|
|
3320
|
+
const peer = gateway ? authorizations?.get(summary.handle)?.peer ?? "quick_link" : record?.host === true ? "loopback" : "lan";
|
|
3321
|
+
return { handle: summary.handle, label: summary.label, via: summary.via, current: summary.current, surface: summary.surface,
|
|
3322
|
+
created: summary.created, lastSeen: summary.lastSeen, expiresAt: Math.min(summary.absoluteExpiry, summary.idleExpiry),
|
|
3323
|
+
ownerVerified: !!record && !this.webAuthority({ session: record, gateway, peer }).refusal };
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3326
|
+
/**
|
|
3327
|
+
* Refs #3061 (P2b): may this request's session end ANOTHER session — one signed in elsewhere, or all of them (auth-api
|
|
3328
|
+
* `DELETE /auth/sessions…`, which an admin session could always do). On a web-only fleet that is the verified owner's:
|
|
3329
|
+
* a session a code or a device approval made is signed in but not an owner, and could otherwise sign out the owner's
|
|
3330
|
+
* own. A fleet with a chat connection is as it was (its admins are the chat's). Ending one's OWN session is never this.
|
|
3331
|
+
*/
|
|
3332
|
+
mayEndOtherSessions(req) {
|
|
3333
|
+
return !this.isWebOnlyFleet() || !!this.deviceApprovalOwner(req);
|
|
3334
|
+
}
|
|
3335
|
+
/**
|
|
3336
|
+
* Refs #3061 (P2b): POST /ui/devices/signout {handle} — the owner ends another signed-in device (the settings list's
|
|
3337
|
+
* button). Only the verified owner, asked of the LIVE session each time (a non-owner learns nothing about any handle:
|
|
3338
|
+
* 403 before anything is looked up); only an admin session of this fleet (a guest's is the Guests page's; an unknown
|
|
3339
|
+
* handle and a guest's are the same 404); never the owner's own session here (Sign out is /auth/logout). The device's
|
|
3340
|
+
* authorization goes with it, so a copy of its cookie is nobody's.
|
|
3341
|
+
*/
|
|
3342
|
+
webDeviceSignOut(req, handle) {
|
|
3343
|
+
if (!this.isWebOnlyFleet() || !this.webSessions)
|
|
3344
|
+
return { status: 404, body: { error: "not_found" } };
|
|
3345
|
+
const owner = this.deviceApprovalOwner(req);
|
|
3346
|
+
if (!owner)
|
|
3347
|
+
return { status: 403, body: { error: "owner_required" } };
|
|
3348
|
+
if (handle === owner.handle)
|
|
3349
|
+
return { status: 400, body: { error: "this_device" } };
|
|
3350
|
+
const target = this.webSessions.findByHandle(handle);
|
|
3351
|
+
if (!target || target.tier !== "admin")
|
|
3352
|
+
return { status: 404, body: { error: "not_found" } };
|
|
3353
|
+
const { found, durable } = this.webSessions.revokeByHandle(handle, r => r.tier === "admin");
|
|
3354
|
+
if (!found)
|
|
3355
|
+
return { status: 404, body: { error: "not_found" } };
|
|
3356
|
+
this.sessionAuthorizationStore()?.prune(a => a.handle !== handle);
|
|
3357
|
+
this.logger.info({ by: owner.handle.slice(0, 8), handle, label: target.label, via: sessionVia(target), durable }, "Device signed out by the owner");
|
|
3358
|
+
if (!durable)
|
|
3359
|
+
return { status: 500, body: { ok: false, durable: false, error: "not_durable" } };
|
|
3360
|
+
return { status: 200, body: { ok: true } };
|
|
3361
|
+
}
|
|
3362
|
+
/**
|
|
3363
|
+
* Refs #3061 (P2a): look a new device's code up (for the confirm screen), approve it, or deny it — the verified owner's,
|
|
3364
|
+
* on a web-only fleet. The answer is the request as it now stands. Approving only marks the request approved: the new
|
|
3365
|
+
* browser makes its own session when it next asks (auth-api POST /auth/device-login/poll), so no credential passes from
|
|
3366
|
+
* here to there — not in the answer, not through the fleet. A wrong code counts against one fleet-wide breaker; while
|
|
3367
|
+
* it is open every code (a right one too) waits.
|
|
3368
|
+
*/
|
|
3369
|
+
webDeviceLoginAct(req, op, code) {
|
|
3370
|
+
const owner = this.deviceApprovalOwner(req);
|
|
3371
|
+
if (!owner)
|
|
3372
|
+
return { status: 403, body: { error: "owner_required" } };
|
|
3373
|
+
const logins = this.webDeviceLogins, token = this.webToken;
|
|
3374
|
+
if (!logins || !token)
|
|
3375
|
+
return { status: 404, body: { error: "not_found" } };
|
|
3376
|
+
const epoch = tokenEpoch(token);
|
|
3377
|
+
const shown = (v) => ({ code: v.code, label: v.label, peer: v.peer, address: v.address, expiresAt: v.expiresAt, state: v.state });
|
|
3378
|
+
if (op === "lookup") {
|
|
3379
|
+
const r = logins.lookup(code, epoch);
|
|
3380
|
+
if (r.kind === "ok")
|
|
3381
|
+
return { status: 200, body: { request: shown(r.view) } };
|
|
3382
|
+
return r.kind === "paused" ? { status: 429, body: { error: "paused", retryAfterMs: r.retryAfterMs } } : { status: 404, body: { error: "not_found" } };
|
|
3383
|
+
}
|
|
3384
|
+
// (The owner above was asked of the live session just now, after the body was read; nothing is awaited since.)
|
|
3385
|
+
const r = logins.decide(code, op === "approve" ? "approved" : "denied", owner.handle, epoch);
|
|
3386
|
+
if (r.kind === "ok") {
|
|
3387
|
+
this.logger.info({ approvedBy: owner.handle.slice(0, 8), label: r.view.label, peer: r.view.peer, decision: r.view.state }, op === "approve" ? "New device sign-in approved" : "New device sign-in denied");
|
|
3388
|
+
return { status: 200, body: { request: shown(r.view) } };
|
|
3389
|
+
}
|
|
3390
|
+
if (r.kind === "decided")
|
|
3391
|
+
return { status: 409, body: { error: "already_decided", state: r.state } };
|
|
3392
|
+
return r.kind === "paused" ? { status: 429, body: { error: "paused", retryAfterMs: r.retryAfterMs } } : { status: 404, body: { error: "not_found" } };
|
|
3393
|
+
}
|
|
2742
3394
|
/** alpha.2: the agents' requests waiting for this web-only fleet's owner, or null when the reader is not that owner. */
|
|
2743
3395
|
webAgentProposals(req) {
|
|
2744
3396
|
if (!this.agentProposalOwner(req))
|
|
@@ -3296,6 +3948,8 @@ export class FleetManager {
|
|
|
3296
3948
|
sseHeartbeatMs = SSE_HEARTBEAT_MS;
|
|
3297
3949
|
/** The dashboard's login codes. Memory only: a code that outlives the process is a code nobody can prove was not copied. */
|
|
3298
3950
|
webLoginCodes = null;
|
|
3951
|
+
/** Refs #3061 (P2a): device-code sign-in requests (in memory; web-device-login.ts). Read by auth-api as `webDeviceLogins`. */
|
|
3952
|
+
webDeviceLogins = null;
|
|
3299
3953
|
/**
|
|
3300
3954
|
* #1920 step 4: guests' codes, apart from the admins' — one per account, so no guest's `/web` withdraws another's or
|
|
3301
3955
|
* an admin's code (#2093 review), at most 32 at once. Local sign-in only for now (audience "local").
|
|
@@ -3334,6 +3988,22 @@ export class FleetManager {
|
|
|
3334
3988
|
* startup-only key at startup. See checkStartupSignatureConsistency(). */
|
|
3335
3989
|
fleetSignatureMismatch = null;
|
|
3336
3990
|
healthServerListening = false;
|
|
3991
|
+
agentCredentialsCache;
|
|
3992
|
+
get agentCredentials() {
|
|
3993
|
+
return this.agentCredentialsCache ??= new AgentCredentials(name => agentCredentialPolicy(this.fleetConfig, name, this.isClassicInstance(name)), name => {
|
|
3994
|
+
try {
|
|
3995
|
+
const token = randomBytes(32).toString("hex");
|
|
3996
|
+
const result = writeSecretFile(join(this.getInstanceDir(name), "agent.token"), token);
|
|
3997
|
+
if (!result.ok)
|
|
3998
|
+
this.logger.error({ name, mode: result.mode, reason: result.reason }, "Agent token file is not owner-only");
|
|
3999
|
+
return token;
|
|
4000
|
+
}
|
|
4001
|
+
catch {
|
|
4002
|
+
this.logger.error({ name }, "Agent credential renewal failed; prior generation remains retired");
|
|
4003
|
+
return null;
|
|
4004
|
+
}
|
|
4005
|
+
});
|
|
4006
|
+
}
|
|
3337
4007
|
constructor(dataDir) {
|
|
3338
4008
|
this.dataDir = dataDir;
|
|
3339
4009
|
FleetManager.signalTarget = this;
|
|
@@ -3356,6 +4026,7 @@ export class FleetManager {
|
|
|
3356
4026
|
this.topicCommands = new TopicCommands(this);
|
|
3357
4027
|
this.topicArchiver = new TopicArchiver(this);
|
|
3358
4028
|
this.statuslineWatcher = new StatuslineWatcher(this);
|
|
4029
|
+
this.missedOfflineStore = new MissedOfflineStore(this.dataDir);
|
|
3359
4030
|
}
|
|
3360
4031
|
/** #1266: a reply's buttons — the store (reply-buttons.db) and what a click does. Created on first use. */
|
|
3361
4032
|
replyButtonsCtl = null;
|
|
@@ -3736,6 +4407,10 @@ export class FleetManager {
|
|
|
3736
4407
|
}
|
|
3737
4408
|
}
|
|
3738
4409
|
}
|
|
4410
|
+
// #3066 §1d: a Codex launch records the credential profile it runs under, so its usage is told by account.
|
|
4411
|
+
if (daemon?.bootId === daemonBootId && this.backendNameOf(name) === "codex") {
|
|
4412
|
+
void recordProfileLaunch(join(this.getInstanceDir(name), PROFILE_TIMELINE_FILE), this.credentialProfileOf(name, "codex") ?? "default");
|
|
4413
|
+
}
|
|
3739
4414
|
// #2802: no post-restart notices. The outbox still delivers or fails a row accepted before the restart, and an open
|
|
3740
4415
|
// request is reminded by the ordinary turn-ended nudge (sweepReplyObligations) once the owner is idle.
|
|
3741
4416
|
this.scheduleDeliveryOutboxPump();
|
|
@@ -4409,6 +5084,7 @@ export class FleetManager {
|
|
|
4409
5084
|
finishStartup(bootUpdateMarker = null) {
|
|
4410
5085
|
this.startupComplete = true;
|
|
4411
5086
|
this.startNeedsYou();
|
|
5087
|
+
this.startSignInKeepAlive();
|
|
4412
5088
|
// Resolve whatever a previous run — or a setup host that crashed — left
|
|
4413
5089
|
// behind. A tunnel nobody is tracking is a public entrance nobody is
|
|
4414
5090
|
// watching, and the fleet starting is the moment there is finally a process
|
|
@@ -4613,6 +5289,7 @@ export class FleetManager {
|
|
|
4613
5289
|
this.enforceGuestSwitch();
|
|
4614
5290
|
this.observeWebAuthority(); // #2453 review: a reload's web-authority switches are seen at once
|
|
4615
5291
|
this.observeRuntimeSwitches(); // M-2255: so are the Windows runtimes' switches
|
|
5292
|
+
this.observeHubSwitches(); // S-51: and the Hub's (no-op until the fleet has started)
|
|
4616
5293
|
// Child tool/guidance readers must follow this fleet's actual config, including --config.
|
|
4617
5294
|
// Scope the path to its owning data directory so another inherited home's override cannot enable CW.
|
|
4618
5295
|
process.env.AGEND_FLEET_DATA_DIR = resolvePath(this.dataDir);
|
|
@@ -4666,6 +5343,8 @@ export class FleetManager {
|
|
|
4666
5343
|
* guild channel.
|
|
4667
5344
|
*/
|
|
4668
5345
|
reregisterClassicChannels() {
|
|
5346
|
+
this.nativeMcpStore?.observePolicies();
|
|
5347
|
+
this.agentCredentialsCache?.observePolicies();
|
|
4669
5348
|
if (!this.classicChannels)
|
|
4670
5349
|
return;
|
|
4671
5350
|
const channels = this.classicChannels.getAll();
|
|
@@ -4718,13 +5397,9 @@ export class FleetManager {
|
|
|
4718
5397
|
}
|
|
4719
5398
|
/** AgEnD package version (for the Settings "current version" / What's New). */
|
|
4720
5399
|
get currentVersion() {
|
|
4721
|
-
|
|
4722
|
-
return JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8")).version ?? "unknown";
|
|
4723
|
-
}
|
|
4724
|
-
catch {
|
|
4725
|
-
return "unknown";
|
|
4726
|
-
}
|
|
5400
|
+
return RUNNING_BUILD.version;
|
|
4727
5401
|
}
|
|
5402
|
+
get currentBuild() { return RUNNING_BUILD; }
|
|
4728
5403
|
/**
|
|
4729
5404
|
* Resolve a slash-command target in a channel. Classic channels are looked up
|
|
4730
5405
|
* per-bot (same-channel multi-bot); a fleet-topic instance is found via the
|
|
@@ -5397,6 +6072,13 @@ export class FleetManager {
|
|
|
5397
6072
|
changed: () => this.emitSseEvent("status", this.getUiStatus()),
|
|
5398
6073
|
});
|
|
5399
6074
|
}
|
|
6075
|
+
/**
|
|
6076
|
+
* Claude history in the View: an instance's earlier conversation for its View, from the transcript the Log reads —
|
|
6077
|
+
* the View's route applied its own access rules first (view-api.ts); the Log's switch plays no part.
|
|
6078
|
+
*/
|
|
6079
|
+
viewHistory(name, q) {
|
|
6080
|
+
return viewHistory((n, rq) => this.log.readBack(n, rq), name, q);
|
|
6081
|
+
}
|
|
5400
6082
|
/** #1218: GET /ui/steps — an instance's steps, read on demand (null: no such instance). */
|
|
5401
6083
|
logSteps(name, q) { return this.log.steps(name, q); }
|
|
5402
6084
|
/**
|
|
@@ -5663,7 +6345,7 @@ export class FleetManager {
|
|
|
5663
6345
|
finish(false);
|
|
5664
6346
|
});
|
|
5665
6347
|
}
|
|
5666
|
-
async deliverWithIdleGate(instanceName, payload, timeoutMs, deliveryEpoch, noInlineWake = false, stillCurrent, onStartRetryHold) {
|
|
6348
|
+
async deliverWithIdleGate(instanceName, payload, timeoutMs, deliveryEpoch, noInlineWake = false, stillCurrent, onStartRetryHold, beforeInput) {
|
|
5667
6349
|
if (this.shuttingDown || !this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent))
|
|
5668
6350
|
return false;
|
|
5669
6351
|
await this.holdDeliveryForStorm(instanceName, deliveryEpoch);
|
|
@@ -5702,7 +6384,8 @@ export class FleetManager {
|
|
|
5702
6384
|
const log = idleGateTimeoutLog(instanceName, timeoutMs, this.instanceStateCache.get(instanceName), Date.now());
|
|
5703
6385
|
this.logger[log.level](log.fields, log.message);
|
|
5704
6386
|
}
|
|
5705
|
-
|
|
6387
|
+
// The Hub representative's begin lease + input intent run inside the final connected hand-off (sendWhenConnected).
|
|
6388
|
+
const sent = await this.sendWhenConnected(instanceName, payload, deliveryEpoch, stillCurrent, onStartRetryHold, beforeInput);
|
|
5706
6389
|
if (!sent)
|
|
5707
6390
|
return false;
|
|
5708
6391
|
if (this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent)) {
|
|
@@ -5735,21 +6418,25 @@ export class FleetManager {
|
|
|
5735
6418
|
* `onStartRetryHold` (#2484, a person's message): an instance in its own start-retry backoff is waited for until that
|
|
5736
6419
|
* retry brings it up, however long the backoff, and fails only once the retries give up.
|
|
5737
6420
|
*/
|
|
5738
|
-
async sendWhenConnected(instanceName, payload, deliveryEpoch = this.getDeliveryEpoch(instanceName), stillCurrent, onStartRetryHold) {
|
|
6421
|
+
async sendWhenConnected(instanceName, payload, deliveryEpoch = this.getDeliveryEpoch(instanceName), stillCurrent, onStartRetryHold, beforeInput) {
|
|
5739
6422
|
if (!this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent))
|
|
5740
6423
|
return false;
|
|
5741
6424
|
const queued = this.ipcWaitTails.get(instanceName);
|
|
5742
6425
|
if (!queued) {
|
|
5743
6426
|
const ipc = this.instanceIpcClients.get(instanceName);
|
|
5744
|
-
if (ipc?.connected
|
|
5745
|
-
|
|
6427
|
+
if (ipc?.connected) {
|
|
6428
|
+
if (beforeInput)
|
|
6429
|
+
return this.handOffAfterBeforeInput(instanceName, payload, deliveryEpoch, stillCurrent, beforeInput);
|
|
6430
|
+
if (ipc.send(this.bindHumanReceiptPayload(instanceName, payload)))
|
|
6431
|
+
return true;
|
|
6432
|
+
}
|
|
5746
6433
|
}
|
|
5747
6434
|
const attempt = (queued ?? Promise.resolve())
|
|
5748
6435
|
.catch(() => { })
|
|
5749
6436
|
.then(() => {
|
|
5750
6437
|
if (!this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent))
|
|
5751
6438
|
return false;
|
|
5752
|
-
return this.sendAfterIpcReturns(instanceName, payload, deliveryEpoch, stillCurrent, onStartRetryHold);
|
|
6439
|
+
return this.sendAfterIpcReturns(instanceName, payload, deliveryEpoch, stillCurrent, onStartRetryHold, beforeInput);
|
|
5753
6440
|
});
|
|
5754
6441
|
// The chain stores a settled-either-way promise so one failed delivery cannot
|
|
5755
6442
|
// wedge every later one, and so `queued` above is safe to await unguarded.
|
|
@@ -5766,8 +6453,21 @@ export class FleetManager {
|
|
|
5766
6453
|
}
|
|
5767
6454
|
}
|
|
5768
6455
|
}
|
|
6456
|
+
/**
|
|
6457
|
+
* The Hub representative's hand-off (#3145): only once a connected client exists, after every reconnect/order wait,
|
|
6458
|
+
* the begin lease + input intent (beforeInput), then the fence and the LIVE client are checked again and the payload
|
|
6459
|
+
* goes in one attempt. After the intent is spent nothing here retries: false is the caller's uncertain outcome.
|
|
6460
|
+
*/
|
|
6461
|
+
async handOffAfterBeforeInput(instanceName, payload, deliveryEpoch, stillCurrent, beforeInput) {
|
|
6462
|
+
if (!(await beforeInput()))
|
|
6463
|
+
return false;
|
|
6464
|
+
if (this.shuttingDown || !this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent))
|
|
6465
|
+
return false;
|
|
6466
|
+
const ipc = this.instanceIpcClients.get(instanceName);
|
|
6467
|
+
return !!ipc?.connected && ipc.send(this.bindHumanReceiptPayload(instanceName, payload));
|
|
6468
|
+
}
|
|
5769
6469
|
/** Poll for the instance's IPC to come back, then send. Throws if it does not. */
|
|
5770
|
-
async sendAfterIpcReturns(instanceName, payload, deliveryEpoch = this.getDeliveryEpoch(instanceName), stillCurrent, onStartRetryHold) {
|
|
6470
|
+
async sendAfterIpcReturns(instanceName, payload, deliveryEpoch = this.getDeliveryEpoch(instanceName), stillCurrent, onStartRetryHold, beforeInput) {
|
|
5771
6471
|
let deadline = Date.now() + IPC_RECONNECT_GRACE_MS;
|
|
5772
6472
|
let warned = false;
|
|
5773
6473
|
let held = false;
|
|
@@ -5777,6 +6477,8 @@ export class FleetManager {
|
|
|
5777
6477
|
// Re-read every round: a reconnect replaces the IpcClient object entirely,
|
|
5778
6478
|
// so a cached reference would stay dead forever.
|
|
5779
6479
|
const ipc = this.instanceIpcClients.get(instanceName);
|
|
6480
|
+
if (ipc?.connected && beforeInput)
|
|
6481
|
+
return this.handOffAfterBeforeInput(instanceName, payload, deliveryEpoch, stillCurrent, beforeInput);
|
|
5780
6482
|
if (ipc?.connected && ipc.send(this.bindHumanReceiptPayload(instanceName, payload)))
|
|
5781
6483
|
return true;
|
|
5782
6484
|
// #2484: while the instance waits for (or runs) its own start retry, the grace runs from now — so the message is
|
|
@@ -6216,6 +6918,8 @@ export class FleetManager {
|
|
|
6216
6918
|
if (this.generalLocationDeliveryHold(instanceName))
|
|
6217
6919
|
return false;
|
|
6218
6920
|
if (isNativeExecInstance(this.fleetConfig?.instances[instanceName])) {
|
|
6921
|
+
if (options.beforeInput)
|
|
6922
|
+
return false; // no pre-input hook on the Windows runtime
|
|
6219
6923
|
return this.nativeInstanceRuntime().deliver(instanceName, payload, { stillCurrent: options.stillCurrent,
|
|
6220
6924
|
...(options.authorityCurrent ? { authorityCurrent: options.authorityCurrent } : {}) });
|
|
6221
6925
|
}
|
|
@@ -6240,7 +6944,7 @@ export class FleetManager {
|
|
|
6240
6944
|
return false;
|
|
6241
6945
|
this.enforceWarmCap(instanceName); // woke one → evict a different LRU idle if over cap
|
|
6242
6946
|
}
|
|
6243
|
-
const sent = await this.sendWhenConnected(instanceName, deliveryPayload, deliveryEpoch, options.stillCurrent, options.onStartRetryHold);
|
|
6947
|
+
const sent = await this.sendWhenConnected(instanceName, deliveryPayload, deliveryEpoch, options.stillCurrent, options.onStartRetryHold, options.beforeInput);
|
|
6244
6948
|
if (!sent)
|
|
6245
6949
|
return false;
|
|
6246
6950
|
// A cross-instance item arriving before the daemon observes this turn as
|
|
@@ -6251,7 +6955,7 @@ export class FleetManager {
|
|
|
6251
6955
|
return true;
|
|
6252
6956
|
}
|
|
6253
6957
|
const previous = this.idleGatedDeliveryTails.get(instanceName) ?? Promise.resolve();
|
|
6254
|
-
const delivery = previous.catch(() => { }).then(() => this.deliverWithIdleGate(instanceName, deliveryPayload, options.idleTimeoutMs ?? 60_000, deliveryEpoch, options.noInlineWake === true, options.stillCurrent, options.onStartRetryHold));
|
|
6958
|
+
const delivery = previous.catch(() => { }).then(() => this.deliverWithIdleGate(instanceName, deliveryPayload, options.idleTimeoutMs ?? 60_000, deliveryEpoch, options.noInlineWake === true, options.stillCurrent, options.onStartRetryHold, options.beforeInput));
|
|
6255
6959
|
this.idleGatedDeliveryTails.set(instanceName, delivery);
|
|
6256
6960
|
try {
|
|
6257
6961
|
return await delivery;
|
|
@@ -6834,6 +7538,7 @@ export class FleetManager {
|
|
|
6834
7538
|
}
|
|
6835
7539
|
classicBehaviorUpdate(instanceName) {
|
|
6836
7540
|
return {
|
|
7541
|
+
quota_notice: this.classicChannels?.getQuotaNoticeByInstance?.(instanceName) ?? null,
|
|
6837
7542
|
reply_triggers: this.classicChannels?.getReplyTriggersByInstance(instanceName, this.fleetConfig?.defaults?.reply_triggers) ?? DEFAULT_REPLY_TRIGGERS,
|
|
6838
7543
|
tool_progress: this.classicChannels?.getToolProgressByInstance(instanceName, this.fleetConfig?.defaults?.tool_progress) ?? "off",
|
|
6839
7544
|
reply_completion_guard: this.classicChannels?.getReplyCompletionGuardByInstance(instanceName, this.fleetConfig?.defaults?.reply_completion_guard) ?? true,
|
|
@@ -6985,6 +7690,9 @@ export class FleetManager {
|
|
|
6985
7690
|
resumePaused = false,
|
|
6986
7691
|
/** Phase 2a: the caller's transition, for a start made from inside a restart or wake. */
|
|
6987
7692
|
transition, execution, kiroMigration) {
|
|
7693
|
+
// M-2457 §6: no agent starts on a held tmux server (an old one AgEnD could not prove its own may still run it).
|
|
7694
|
+
if (this.tmuxHold)
|
|
7695
|
+
throw new Error(this.tmuxHold.detail);
|
|
6988
7696
|
if (isNativeExecInstance(config)) {
|
|
6989
7697
|
execution?.assert();
|
|
6990
7698
|
if (!windowsCliEnabled())
|
|
@@ -7098,14 +7806,26 @@ export class FleetManager {
|
|
|
7098
7806
|
}
|
|
7099
7807
|
const receipt = execution ? this.classicSettingsOwners.get(execution) : undefined;
|
|
7100
7808
|
const identity = { kind, backend, model: isWindowsInstance(config) ? config.model || "default" : this.resolveInstanceModel(name).display };
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7809
|
+
// M-2457 §6 rule 3: an old 2.3 window AgEnD can't prove its own holds only this instance (Needs-you says why).
|
|
7810
|
+
try {
|
|
7811
|
+
if (receipt) {
|
|
7812
|
+
await this.lifecycle.start(name, config, topicMode, identity, transition, execution, daemon => {
|
|
7813
|
+
// Only this transition's actual publication can acquire its replacement.
|
|
7814
|
+
receipt.daemon = daemon;
|
|
7815
|
+
});
|
|
7816
|
+
}
|
|
7817
|
+
else
|
|
7818
|
+
await this.lifecycle.start(name, config, topicMode, identity, transition, execution);
|
|
7106
7819
|
}
|
|
7107
|
-
|
|
7108
|
-
|
|
7820
|
+
catch (err) {
|
|
7821
|
+
if (err instanceof LegacyWindowHoldError) {
|
|
7822
|
+
this.legacyWindowHolds.set(name, { key: `legacy:${Date.now()}`, detail: err.message, since: Date.now() });
|
|
7823
|
+
this.needsYou?.poke();
|
|
7824
|
+
}
|
|
7825
|
+
throw err;
|
|
7826
|
+
}
|
|
7827
|
+
if (this.legacyWindowHolds.delete(name))
|
|
7828
|
+
this.needsYou?.poke();
|
|
7109
7829
|
execution?.assert();
|
|
7110
7830
|
// Only clear a stale process status after a real start succeeded. Clearing
|
|
7111
7831
|
// it before lifecycle.start() can turn a crash-loop daemon's dead pane into
|
|
@@ -7522,6 +8242,17 @@ export class FleetManager {
|
|
|
7522
8242
|
this.queueKiroIncompatNotice(name, err.message);
|
|
7523
8243
|
return true;
|
|
7524
8244
|
}
|
|
8245
|
+
/** No pane is needed for a compatibility refusal to remain in Needs you. */
|
|
8246
|
+
setKiroCompatibilityHold(name, message) {
|
|
8247
|
+
const holds = this.kiroCompatibilityHolds ??= new Map();
|
|
8248
|
+
if ((message === null && !holds.has(name)) || (message !== null && holds.get(name)?.message === message))
|
|
8249
|
+
return;
|
|
8250
|
+
if (message === null)
|
|
8251
|
+
holds.delete(name);
|
|
8252
|
+
else
|
|
8253
|
+
holds.set(name, { message, since: Date.now() });
|
|
8254
|
+
this.needsYou?.poke();
|
|
8255
|
+
}
|
|
7525
8256
|
/**
|
|
7526
8257
|
* LifecycleContext: a kiro instance the installed kiro-cli cannot run as
|
|
7527
8258
|
* configured (#1109) — at start, or at a respawn after kiro-cli replaced
|
|
@@ -8028,6 +8759,12 @@ export class FleetManager {
|
|
|
8028
8759
|
},
|
|
8029
8760
|
});
|
|
8030
8761
|
}
|
|
8762
|
+
if (!this.webDeviceLogins) {
|
|
8763
|
+
this.webDeviceLogins = new DeviceLoginRequests({
|
|
8764
|
+
onEvent: event => { if (event === "breaker-open")
|
|
8765
|
+
this.logger.warn("Device sign-in approval paused: too many wrong codes"); },
|
|
8766
|
+
});
|
|
8767
|
+
}
|
|
8031
8768
|
if (!this.webGuestLoginCodes) {
|
|
8032
8769
|
this.webGuestLoginCodes = new GuestLoginCodes({
|
|
8033
8770
|
onEvent: event => {
|
|
@@ -8642,6 +9379,7 @@ export class FleetManager {
|
|
|
8642
9379
|
void this.publicWebLink?.close("dashboard revoke");
|
|
8643
9380
|
this.forgetPublicLinkOwner();
|
|
8644
9381
|
this.webLoginCodes.revoke();
|
|
9382
|
+
this.webDeviceLogins?.revokeAll(); // …and every new device still waiting to be approved (#3061)
|
|
8645
9383
|
this.webGuestLoginCodes.revokeAll();
|
|
8646
9384
|
this.guestRevokes++; // and every guest /web still on its way
|
|
8647
9385
|
// #1570: no browser may ask the sign-in page for a code any more.
|
|
@@ -9550,7 +10288,7 @@ export class FleetManager {
|
|
|
9550
10288
|
}
|
|
9551
10289
|
async startAllWithinDeadline(configPath, deadline) {
|
|
9552
10290
|
if (!this.structuredLoginCleanupFailed)
|
|
9553
|
-
this.
|
|
10291
|
+
this.reopenLoginWindow(); // a stopAll → startAll restart must accept login windows again
|
|
9554
10292
|
this.loginController?.reopen();
|
|
9555
10293
|
const startupStartedAt = Date.now();
|
|
9556
10294
|
FleetManager.signalTarget = this;
|
|
@@ -9605,10 +10343,63 @@ export class FleetManager {
|
|
|
9605
10343
|
// #2910: a web-only fleet's agents run in topic mode too (their cross-instance tools work; the dashboard is their place).
|
|
9606
10344
|
const topicMode = daemonTopicMode(fleet);
|
|
9607
10345
|
// Set tmux socket isolation for custom AGEND_HOME
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
10346
|
+
// M-2457: AgEnD's own tmux socket (`agend` for the real home).
|
|
10347
|
+
const { tmuxSocket, resolveTmux } = await import("./tmux-binary.js");
|
|
10348
|
+
TmuxManager.setSocketName(tmuxSocket());
|
|
10349
|
+
// M-2457 §6 rule 3: 2.3's window ids (untagged window-id files) move into the migration journal before anything —
|
|
10350
|
+
// a stop, a pane check, a restart — can read one as a window on AgEnD's own server.
|
|
10351
|
+
try {
|
|
10352
|
+
const { sweepLegacyWindowIds } = await import("./tmux-legacy.js");
|
|
10353
|
+
const moved = sweepLegacyWindowIds(getAgendHome(), Object.keys(fleet.instances ?? {}).map(name => ({ name, dir: this.getInstanceDir(name) })), tmuxSocket());
|
|
10354
|
+
if (moved.length)
|
|
10355
|
+
this.logger.info({ instances: moved }, "2.3 tmux window ids moved to the migration journal");
|
|
10356
|
+
}
|
|
10357
|
+
catch (err) {
|
|
10358
|
+
this.logger.warn({ err }, "Could not move 2.3 tmux window ids to the migration journal; each instance does it as it starts");
|
|
10359
|
+
}
|
|
10360
|
+
// M-2457 §6 rule 2: a server from another pin still on the socket is ended by its own recorded
|
|
10361
|
+
// client, positively, before ours starts; one AgEnD cannot prove its own holds the whole fleet (nothing is killed).
|
|
10362
|
+
const bundled = await (async () => {
|
|
10363
|
+
const srv = await import("./tmux-server.js");
|
|
10364
|
+
const binary = resolveTmux().binary;
|
|
10365
|
+
return { srv, socket: tmuxSocket(), current: { binary, sha256: srv.sha256File(binary) }, previous: srv.readServerRecord(getAgendHome()) };
|
|
10366
|
+
})();
|
|
10367
|
+
// M-2457 §5 (Fable #3312 N3): an upgraded home — agents ran here before (their output or session ids are on disk
|
|
10368
|
+
// from an earlier start) and no AgEnD tmux server was ever recorded — gets the one own-tmux notice. A cleanly stopped
|
|
10369
|
+
// 2.3 fleet leaves no window ids (no migration journal), so this, not the journal, is the evidence. Read before any
|
|
10370
|
+
// agent of this start writes its own.
|
|
10371
|
+
this.ownTmuxUpgradedHome = FleetManager.ownTmuxUpgraded(getAgendHome(), bundled.previous);
|
|
10372
|
+
this.tmuxHold = null;
|
|
10373
|
+
TmuxManager.setHold(null);
|
|
10374
|
+
if (bundled) {
|
|
10375
|
+
const reason = await bundled.srv.reconcileServer({ agendHome: getAgendHome(), socket: bundled.socket, current: bundled.current,
|
|
10376
|
+
log: (msg, data) => this.logger.info(data ?? {}, msg) });
|
|
10377
|
+
if (reason) {
|
|
10378
|
+
this.tmuxHold = { key: `server:${Date.now()}`, detail: reason, since: Date.now() };
|
|
10379
|
+
TmuxManager.setHold(reason); // every other way in (sign-in/install windows, a daemon) is refused too
|
|
10380
|
+
this.logger.error({ reason }, "Fleet held: AgEnD's previous tmux server can't be verified; no agent starts");
|
|
10381
|
+
}
|
|
10382
|
+
}
|
|
10383
|
+
if (!this.tmuxHold) {
|
|
10384
|
+
await TmuxManager.ensureSession(getTmuxSession());
|
|
10385
|
+
this.tmuxSessionEnsured = true;
|
|
10386
|
+
if (bundled) {
|
|
10387
|
+
await bundled.srv.recordServer({ agendHome: getAgendHome(), socket: bundled.socket, current: bundled.current, version: "",
|
|
10388
|
+
log: (msg, data) => this.logger.warn(data ?? {}, msg) });
|
|
10389
|
+
// A server AgEnD starts later (the session re-created after the server crashed) is recorded the same way, so
|
|
10390
|
+
// server.json always names the server that runs (leg M: an unrecorded server made `agend rollback` refuse).
|
|
10391
|
+
TmuxManager.onSessionCreated(async () => {
|
|
10392
|
+
const r = await bundled.srv.recordServer({ agendHome: getAgendHome(), socket: bundled.socket, current: bundled.current, version: "",
|
|
10393
|
+
log: (msg, data) => this.logger.warn(data ?? {}, msg) });
|
|
10394
|
+
if (r)
|
|
10395
|
+
this.logger.info({ serverPid: r.serverPid }, "tmux server recorded (session created)");
|
|
10396
|
+
});
|
|
10397
|
+
// The current copy and the one the previous server ran (kept for a handover/rollback); older ones go.
|
|
10398
|
+
const removed = bundled.srv.pruneCopies(getAgendHome(), [bundled.current.binary, ...(bundled.previous ? [bundled.previous.binary] : [])]);
|
|
10399
|
+
if (removed.length)
|
|
10400
|
+
this.logger.info({ removed }, "Pruned old bundled tmux copies");
|
|
10401
|
+
}
|
|
10402
|
+
}
|
|
9612
10403
|
// #2072: what this host can run — probed in the background, published for every picker.
|
|
9613
10404
|
this.startAvailabilityRefresh();
|
|
9614
10405
|
// Pre-flight (advisory, fire-and-forget): warm the per-backend auth cache
|
|
@@ -9620,7 +10411,7 @@ export class FleetManager {
|
|
|
9620
10411
|
return { backend, profile: credentialHomeSpec(backend) ? instanceCredentialProfile(config, fleet.defaults, backend) : null };
|
|
9621
10412
|
}));
|
|
9622
10413
|
// Start tmux control mode client for idle detection
|
|
9623
|
-
if (!this.controlClient) {
|
|
10414
|
+
if (!this.controlClient && !this.tmuxHold) {
|
|
9624
10415
|
this.controlClient = new TmuxControlClient(getTmuxSession(), 2000, this.logger);
|
|
9625
10416
|
this.controlClient.start();
|
|
9626
10417
|
}
|
|
@@ -9633,25 +10424,26 @@ export class FleetManager {
|
|
|
9633
10424
|
// windows from deleted instances that are no longer in fleet.yaml.
|
|
9634
10425
|
const agendNames = new Set(Object.keys(fleet.instances));
|
|
9635
10426
|
agendNames.add("general");
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
if (isOrphanedInstance)
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
10427
|
+
if (!this.tmuxHold)
|
|
10428
|
+
try {
|
|
10429
|
+
const existingWindows = await TmuxManager.listWindows(getTmuxSession());
|
|
10430
|
+
for (const w of existingWindows) {
|
|
10431
|
+
// Kill known instance windows (will be recreated)
|
|
10432
|
+
// Also kill orphaned windows: any window with a topic ID suffix (name-tNNNNN)
|
|
10433
|
+
// that isn't in the current config — these are leftovers from deleted instances
|
|
10434
|
+
const isKnownInstance = agendNames.has(w.name);
|
|
10435
|
+
const isOrphanedInstance = !isKnownInstance && isOrphanInstanceWindowName(w.name);
|
|
10436
|
+
if (isKnownInstance || isOrphanedInstance) {
|
|
10437
|
+
if (isOrphanedInstance)
|
|
10438
|
+
this.logger.info({ window: w.name }, "Cleaning up orphaned tmux window");
|
|
10439
|
+
const tm = new TmuxManager(getTmuxSession(), w.id);
|
|
10440
|
+
await tm.killWindow();
|
|
10441
|
+
}
|
|
9649
10442
|
}
|
|
9650
10443
|
}
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
}
|
|
10444
|
+
catch (err) {
|
|
10445
|
+
this.logger.debug({ err }, "Startup tmux window cleanup failed (best effort)");
|
|
10446
|
+
}
|
|
9655
10447
|
const pidPath = join(this.dataDir, "fleet.pid");
|
|
9656
10448
|
writeFileSync(pidPath, String(process.pid), "utf-8");
|
|
9657
10449
|
this.eventLog = this.openEventLog();
|
|
@@ -9859,18 +10651,22 @@ export class FleetManager {
|
|
|
9859
10651
|
}
|
|
9860
10652
|
}
|
|
9861
10653
|
// Phase 1: Start general instances first and wait for them
|
|
9862
|
-
|
|
10654
|
+
// M-2457: a held fleet starts no agent (the hold's Needs-you line says why and what to do).
|
|
10655
|
+
const allEntries = this.tmuxHold ? [] : Object.entries(fleet.instances).filter(([, config]) => !isNativeExecInstance(config));
|
|
9863
10656
|
const generals = allEntries.filter(([_, cfg]) => cfg.general_topic);
|
|
9864
10657
|
const others = allEntries.filter(([_, cfg]) => !cfg.general_topic);
|
|
9865
|
-
const startupProgress = new RestartProgress(this.runnableStartupCount(fleet, topicMode), pendingUpdateProgress?.startedAt ?? startupStartedAt, this.logger, { mode: pendingProgressOperation === "full-restart" ? "reload" : pendingUpdateProgress ? "update" : "restart" });
|
|
10658
|
+
const startupProgress = new RestartProgress(this.tmuxHold ? 0 : this.runnableStartupCount(fleet, topicMode), pendingUpdateProgress?.startedAt ?? startupStartedAt, this.logger, { mode: pendingProgressOperation === "full-restart" ? "reload" : pendingUpdateProgress ? "update" : "restart" });
|
|
9866
10659
|
this.startupProgress = startupProgress;
|
|
9867
10660
|
// Auth, restored chat, Classic roster and the task DB are ready. Listening is not service readiness:
|
|
9868
10661
|
// the dashboard observes startup, while /health and READY retain their existing completion boundary.
|
|
9869
|
-
this.startupDashboard = new FleetStartup(this.configuredStartupInstanceNames(fleet, topicMode)
|
|
10662
|
+
this.startupDashboard = new FleetStartup(this.tmuxHold ? [] : this.configuredStartupInstanceNames(fleet, topicMode)
|
|
9870
10663
|
.filter(name => !this.lifecycle.isPaused(name)));
|
|
9871
10664
|
await this.startHealthServer(fleet.health_port ?? 19280);
|
|
9872
10665
|
if (this.shuttingDown)
|
|
9873
10666
|
return;
|
|
10667
|
+
// S-51: from here on the Hub switches apply (an enabled Hub mounts now, beside the fleet; it never blocks startup).
|
|
10668
|
+
this.hubEffectsReady = true;
|
|
10669
|
+
this.observeHubSwitches();
|
|
9874
10670
|
if (generals.length > 0) {
|
|
9875
10671
|
for (const [name, cfg] of generals) {
|
|
9876
10672
|
try {
|
|
@@ -9973,6 +10769,9 @@ export class FleetManager {
|
|
|
9973
10769
|
if (others.length > 0 || classicAtBoot.length > 0) {
|
|
9974
10770
|
await this.startInstancesWithConcurrency(others, topicMode, () => startupProgress.markReady(), classicAtBoot);
|
|
9975
10771
|
}
|
|
10772
|
+
// #3066 §1d (Fable r1): on every fleet — a web-only one (#2910) has no chat connection at all, and is the clearest
|
|
10773
|
+
// case with no Discord bot reading. Each tick decides for itself whether to read (backgroundQuotaRead).
|
|
10774
|
+
this.startQuotaBackgroundReads();
|
|
9976
10775
|
if (topicMode && (fleet.channel || fleet.channels?.length)) {
|
|
9977
10776
|
await adapterStartup;
|
|
9978
10777
|
this.startDiscordUsagePresence();
|
|
@@ -10105,6 +10904,8 @@ export class FleetManager {
|
|
|
10105
10904
|
// #1266: buttons that ended while AgEnD was down (expired, or chosen before a restart) are shown as ended now.
|
|
10106
10905
|
// #1823: and polls: a deadline that passed meanwhile closes now (results once); an open one's countdown is redrawn.
|
|
10107
10906
|
void this.replyButtons()?.sweep().catch(err => this.logger.warn({ err }, "Reply-button sweep failed"));
|
|
10907
|
+
// M-2457 §5: the first start on AgEnD's own tmux says so, once per home: `tmux attach` no longer shows the agents.
|
|
10908
|
+
this.announceOwnTmux();
|
|
10108
10909
|
// Daily update check — first check after 1 hour, then every 24 hours
|
|
10109
10910
|
this.updateCheckTimer = setTimeout(() => {
|
|
10110
10911
|
this.checkForUpdates();
|
|
@@ -10148,6 +10949,218 @@ export class FleetManager {
|
|
|
10148
10949
|
this.logger.warn({ health }, "Fleet started with problems — see /health");
|
|
10149
10950
|
}
|
|
10150
10951
|
}
|
|
10952
|
+
/**
|
|
10953
|
+
* #3066 §1d (the user: yes, every 30 min): the quota history (usage/quota-history.ts) records only the readings AgEnD
|
|
10954
|
+
* makes. A Discord bot's presence refresh reads every 15 min; without one, nothing reads while nobody looks. So, with no
|
|
10955
|
+
* Discord bot and while some account has a running agent, read every 30 min — the same cached read (its 5-minute TTL
|
|
10956
|
+
* still bounds the vendor calls), recorded like any other.
|
|
10957
|
+
*/
|
|
10958
|
+
quotaNotices = null;
|
|
10959
|
+
stopQuotaObserver = null;
|
|
10960
|
+
quotaNoticePolicy() {
|
|
10961
|
+
const defaults = this.fleetConfig?.defaults.quota_notice;
|
|
10962
|
+
const wanted = defaults?.target ?? "general";
|
|
10963
|
+
const instances = this.fleetConfig?.instances ?? {};
|
|
10964
|
+
const target = wanted === "general"
|
|
10965
|
+
? Object.entries(instances).find(([name, c]) => c.general_topic === true || name === "general")?.[0]
|
|
10966
|
+
: Object.hasOwn(instances, wanted) ? wanted : undefined;
|
|
10967
|
+
const webOnly = !!this.webOnlyPromptPlace();
|
|
10968
|
+
const config = target ? instances[target] : undefined;
|
|
10969
|
+
const adapterId = target ? this.getInstanceAdapterId(target) : undefined;
|
|
10970
|
+
const groupId = target ? this.getChannelConfig(adapterId)?.group_id : undefined;
|
|
10971
|
+
const ready = !!target && (webOnly || (config?.topic_id != null && !!groupId && !!(this.getAdapterForInstance(target) ?? this.adapter)));
|
|
10972
|
+
return {
|
|
10973
|
+
target: this.shuttingDown ? "" : ready ? target : !target && wanted === "general" && webOnly ? "/notices" : "",
|
|
10974
|
+
destinationBinding: JSON.stringify([webOnly, adapterId, groupId, config?.topic_id]),
|
|
10975
|
+
locale: this.fleetConfig?.defaults.locale ?? getLocale(),
|
|
10976
|
+
subscriptions: this.shuttingDown ? [] : this.activeBackendBindings().flatMap(([name, backend, profile]) => {
|
|
10977
|
+
// Local WSL usage cannot prove a Windows/paired machine's credential source.
|
|
10978
|
+
const instance = instances[name];
|
|
10979
|
+
if (instance?.runtime === "windows" || instance?.machine_id)
|
|
10980
|
+
return [];
|
|
10981
|
+
const provider = usageProviderIdForBackend(backend);
|
|
10982
|
+
if (!provider)
|
|
10983
|
+
return [];
|
|
10984
|
+
const providerId = profile ? `${provider}:${profile}` : provider;
|
|
10985
|
+
return [{ account: `${backend}:host:${profile ?? ""}`, providerId,
|
|
10986
|
+
rule: quotaNoticeRule(defaults, backend, instances[name]?.quota_notice ?? this.classicChannels?.getQuotaNoticeByInstance?.(name)) }];
|
|
10987
|
+
}),
|
|
10988
|
+
};
|
|
10989
|
+
}
|
|
10990
|
+
startQuotaBackgroundReads() {
|
|
10991
|
+
if (!this.quotaNotices) {
|
|
10992
|
+
this.quotaNotices = new QuotaNotices({
|
|
10993
|
+
file: join(this.dataDir, "quota-notices.json"), policy: () => this.quotaNoticePolicy(),
|
|
10994
|
+
send: (target, text) => target === "/notices" ? this.recordWebNotice("fleet", text) : this.notifyInstanceTopic(target, text),
|
|
10995
|
+
warn: err => this.logger.warn({ err }, "Optional quota reminders held: could not retain dispatch state"),
|
|
10996
|
+
});
|
|
10997
|
+
this.stopQuotaObserver = onUsageSnapshot(payload => { void this.quotaNotices?.observe(payload); });
|
|
10998
|
+
}
|
|
10999
|
+
if (this.quotaReadTimer)
|
|
11000
|
+
clearInterval(this.quotaReadTimer);
|
|
11001
|
+
this.quotaReadTimer = setInterval(() => { void this.backgroundQuotaRead(); }, FleetManager.QUOTA_BACKGROUND_READ_MS);
|
|
11002
|
+
this.quotaReadTimer.unref?.();
|
|
11003
|
+
// #3066 §1: the measured capacity, published for the usage reads (get_usage, the page) — refreshed every 10 min.
|
|
11004
|
+
setCapacityLookup((provider, metric) => this.capacityEstimates.get(`${provider}\u0000${metric}`) ?? null);
|
|
11005
|
+
if (this.capacityTimer)
|
|
11006
|
+
clearInterval(this.capacityTimer);
|
|
11007
|
+
void this.refreshCapacity();
|
|
11008
|
+
this.capacityTimer = setInterval(() => { void this.refreshCapacity(); }, FleetManager.CAPACITY_REFRESH_MS);
|
|
11009
|
+
this.capacityTimer.unref?.();
|
|
11010
|
+
}
|
|
11011
|
+
/** #3066 §1: the latest estimates, by `provider\0metric` (what usage-api's lookup reads, synchronously). */
|
|
11012
|
+
capacityEstimates = new Map();
|
|
11013
|
+
capacityTimer = null;
|
|
11014
|
+
static CAPACITY_REFRESH_MS = 10 * 60_000;
|
|
11015
|
+
/**
|
|
11016
|
+
* #3066 §1: estimate each account's weekly 100% from the quota history (§1d) and the usage ledger's hours — both read
|
|
11017
|
+
* asynchronously, the arithmetic small (usage/capacity.ts). An account is its usage provider id ("claude",
|
|
11018
|
+
* "claude:hsinlin", "codex:yanxianchen"): its hours are the ledger sources of that backend under that credential profile
|
|
11019
|
+
* (Codex's "unrecorded" hours are no account's). A per-model weekly ("Sonnet (weekly)") counts only that model's tokens.
|
|
11020
|
+
*
|
|
11021
|
+
* Prism #3073: no estimate rather than a wrong one —
|
|
11022
|
+
* - a window is measured only where the ledger has its hours: kept (31 days) and scanned (`days.coverage`) for every
|
|
11023
|
+
* instance of the account's backend, and every instance whose hours count for it; the quota history goes back 12 weeks;
|
|
11024
|
+
* - a profile literally named "default", "unknown" or "unrecorded" (configured, on disk, or in the quota history) makes
|
|
11025
|
+
* those hours ambiguous: neither the host
|
|
11026
|
+
* account nor the named one is estimated (each would be credited the other's use, or lose its own);
|
|
11027
|
+
* - only a metric the vendor marks per-model (`scope: "model"`) is filtered by model; another named weekly pool
|
|
11028
|
+
* ("Luna Reserve (weekly)", Antigravity pools) is no model name and is not estimated.
|
|
11029
|
+
*/
|
|
11030
|
+
async refreshCapacity() {
|
|
11031
|
+
try {
|
|
11032
|
+
const readings = await readQuotaHistory();
|
|
11033
|
+
const groups = new Map();
|
|
11034
|
+
for (const r of readings) {
|
|
11035
|
+
const k = `${r.provider}\u0000${r.metric}`;
|
|
11036
|
+
(groups.get(k) ?? groups.set(k, []).get(k)).push(r);
|
|
11037
|
+
}
|
|
11038
|
+
if (!groups.size) {
|
|
11039
|
+
this.capacityEstimates = new Map();
|
|
11040
|
+
return 0;
|
|
11041
|
+
}
|
|
11042
|
+
const data = await this.cacheServiceFor().usageData();
|
|
11043
|
+
const now = Date.now(), DAY = 24 * 3_600_000, HOUR = 3_600_000;
|
|
11044
|
+
const keptFrom = now - KEEP_DAYS * DAY + HOUR; // the oldest hour still in every ledger (an hour of margin)
|
|
11045
|
+
// Profiles whose names are also the ledger's own tags: their hours cannot be told from the host's / unattributed.
|
|
11046
|
+
// Any trace of such a profile counts (Prism #3073 r2), not only today's config — a binding removed or switched
|
|
11047
|
+
// leaves its hours in the ledger: configured now, its directory on this host, or its account in the quota history.
|
|
11048
|
+
const RESERVED = new Set(["default", "unknown", PROFILE_UNRECORDED]);
|
|
11049
|
+
const historyProviders = new Set(readings.map((r) => r.provider));
|
|
11050
|
+
const reservedNamed = new Map();
|
|
11051
|
+
const reservedFor = (backend) => {
|
|
11052
|
+
const known = reservedNamed.get(backend);
|
|
11053
|
+
if (known)
|
|
11054
|
+
return known;
|
|
11055
|
+
const found = new Set(listConfiguredProfiles(this.fleetConfig, backend).filter((n) => RESERVED.has(n)));
|
|
11056
|
+
const base = usageProviderIdForBackend(backend);
|
|
11057
|
+
for (const n of RESERVED) {
|
|
11058
|
+
if (base && historyProviders.has(`${base}:${n}`))
|
|
11059
|
+
found.add(n);
|
|
11060
|
+
if (credentialHomeSpec(backend) && existsSync(credentialProfileHome(this.dataDir, backend, n)))
|
|
11061
|
+
found.add(n);
|
|
11062
|
+
}
|
|
11063
|
+
return reservedNamed.set(backend, found).get(backend);
|
|
11064
|
+
};
|
|
11065
|
+
// Every instance of a backend may have used any of its accounts (bindings change): an account is measured only
|
|
11066
|
+
// where all of them were scanned (Prism #3073 r2) — one still waiting for its first scan has no hours yet, not none.
|
|
11067
|
+
const daysOfBase = new Map();
|
|
11068
|
+
for (const inst of data.instances) {
|
|
11069
|
+
const base = usageProviderIdForBackend(inst.inst.backend);
|
|
11070
|
+
if (base)
|
|
11071
|
+
(daysOfBase.get(base) ?? daysOfBase.set(base, []).get(base)).push(inst.days);
|
|
11072
|
+
}
|
|
11073
|
+
// provider id → hour → model key → totals; and the instances whose hours count for it (their scan coverage).
|
|
11074
|
+
const byProvider = new Map();
|
|
11075
|
+
const daysOf = new Map();
|
|
11076
|
+
for (const inst of data.instances) {
|
|
11077
|
+
for (const [hk, hour] of Object.entries(inst.ledger.hours)) {
|
|
11078
|
+
for (const src of hourSources(hour)) {
|
|
11079
|
+
const base = usageProviderIdForBackend(src.backend);
|
|
11080
|
+
if (!base)
|
|
11081
|
+
continue;
|
|
11082
|
+
// Ambiguous (a named profile with the tag's name), or no account's: counted for no one, so an account whose
|
|
11083
|
+
// hours these may be has none — and gets no estimate, never a low one.
|
|
11084
|
+
if (reservedFor(src.backend).has(src.profile) || src.profile === "unknown" || src.profile === PROFILE_UNRECORDED)
|
|
11085
|
+
continue;
|
|
11086
|
+
const provider = src.profile === "default" ? base : `${base}:${src.profile}`;
|
|
11087
|
+
const list = daysOf.get(provider) ?? daysOf.set(provider, []).get(provider);
|
|
11088
|
+
if (!list.includes(inst.days))
|
|
11089
|
+
list.push(inst.days);
|
|
11090
|
+
const hours = byProvider.get(provider) ?? byProvider.set(provider, new Map()).get(provider);
|
|
11091
|
+
const into = hours.get(Number(hk)) ?? hours.set(Number(hk), Object.create(null)).get(Number(hk));
|
|
11092
|
+
for (const [mk, tot] of Object.entries(src.m)) {
|
|
11093
|
+
const cur = into[mk] ??= [0, 0, 0, 0, 0, 0, 0];
|
|
11094
|
+
for (let i = 0; i < 7; i++)
|
|
11095
|
+
cur[i] = (cur[i] ?? 0) + (tot[i] ?? 0);
|
|
11096
|
+
}
|
|
11097
|
+
}
|
|
11098
|
+
}
|
|
11099
|
+
}
|
|
11100
|
+
const next = new Map();
|
|
11101
|
+
for (const [key, list] of groups) {
|
|
11102
|
+
const [provider, metric] = key.split("\u0000");
|
|
11103
|
+
// A per-model weekly ("Sonnet (weekly)", the vendor's scope "model"): that model's tokens only. Another named
|
|
11104
|
+
// pool is not a model: no estimate. "Weekly", "Weekly limit": everything.
|
|
11105
|
+
const named = /^(.+) \((?:weekly|monthly|\d+d)\)$/i.exec(metric)?.[1]?.toLowerCase() ?? null;
|
|
11106
|
+
const perModel = list.some((r) => r.scope === "model");
|
|
11107
|
+
if (named && !perModel)
|
|
11108
|
+
continue;
|
|
11109
|
+
const hours = [];
|
|
11110
|
+
for (const [hour, models] of byProvider.get(provider) ?? []) {
|
|
11111
|
+
let api = 0, output = 0, all = 0;
|
|
11112
|
+
for (const [mk, tot] of Object.entries(models)) {
|
|
11113
|
+
const bar = mk.lastIndexOf("|"), model = mk.slice(0, bar), long = mk.slice(bar + 1) === "1";
|
|
11114
|
+
if (named && !model.toLowerCase().includes(named))
|
|
11115
|
+
continue;
|
|
11116
|
+
const [, uncached, read, w5, w1h, w, out] = tot;
|
|
11117
|
+
const r = ratesFor(model, long ? Number.MAX_SAFE_INTEGER : 0);
|
|
11118
|
+
api = api === null || !r ? null : api + (uncached * r.input + read * r.read + w5 * r.write5m + w1h * r.write1h + w * r.write + out * r.output) / 1_000_000;
|
|
11119
|
+
output += out;
|
|
11120
|
+
all += uncached + read + w5 + w1h + w + out;
|
|
11121
|
+
}
|
|
11122
|
+
if (all > 0)
|
|
11123
|
+
hours.push({ hour, api, output, all });
|
|
11124
|
+
}
|
|
11125
|
+
const base = provider.split(":")[0];
|
|
11126
|
+
const scanned = [...new Set([...(daysOf.get(provider) ?? []), ...(daysOfBase.get(base) ?? [])])];
|
|
11127
|
+
const available = (from, to) => {
|
|
11128
|
+
if (from < keptFrom || !scanned.length)
|
|
11129
|
+
return false;
|
|
11130
|
+
for (let h = from; h <= to; h += HOUR)
|
|
11131
|
+
if (!scanned.every((d) => covered(d, h)))
|
|
11132
|
+
return false;
|
|
11133
|
+
return true;
|
|
11134
|
+
};
|
|
11135
|
+
const est = estimateCapacity(list, hours, available);
|
|
11136
|
+
if (est)
|
|
11137
|
+
next.set(key, est);
|
|
11138
|
+
}
|
|
11139
|
+
this.capacityEstimates = next;
|
|
11140
|
+
return next.size;
|
|
11141
|
+
}
|
|
11142
|
+
catch (err) {
|
|
11143
|
+
this.logger.debug({ err }, "capacity estimate refresh failed");
|
|
11144
|
+
return -1;
|
|
11145
|
+
}
|
|
11146
|
+
}
|
|
11147
|
+
/** One background quota read, when nothing else reads (no Discord bot) and an account has a running agent. */
|
|
11148
|
+
async backgroundQuotaRead() {
|
|
11149
|
+
if (this.shuttingDown)
|
|
11150
|
+
return false;
|
|
11151
|
+
if ([...this.adapters.values()].some(a => a.type === "discord" && typeof a.setActivity === "function"))
|
|
11152
|
+
return false;
|
|
11153
|
+
const active = this.getActiveUsageProviderIds();
|
|
11154
|
+
if (active.size === 0)
|
|
11155
|
+
return false;
|
|
11156
|
+
try {
|
|
11157
|
+
await getUsageSnapshot(false, active);
|
|
11158
|
+
return true;
|
|
11159
|
+
}
|
|
11160
|
+
catch {
|
|
11161
|
+
return false;
|
|
11162
|
+
}
|
|
11163
|
+
}
|
|
10151
11164
|
/** Keep Discord profile activity aligned with the same cached usage source as /usage. */
|
|
10152
11165
|
startDiscordUsagePresence() {
|
|
10153
11166
|
if (this.discordPresenceTimer)
|
|
@@ -10485,8 +11498,8 @@ export class FleetManager {
|
|
|
10485
11498
|
* that should be running is running
|
|
10486
11499
|
* - `degraded` — reachable, but something the operator should look at (an
|
|
10487
11500
|
* adapter retrying, an instance crashed or stopped)
|
|
10488
|
-
* - `down` —
|
|
10489
|
-
*
|
|
11501
|
+
* - `down` — no configured adapter is connected, or a dedicated Hub's
|
|
11502
|
+
* server mount is unavailable
|
|
10490
11503
|
*
|
|
10491
11504
|
* Deliberately does NOT gate the systemd watchdog — see the comment at the
|
|
10492
11505
|
* WATCHDOG timer for why.
|
|
@@ -10519,10 +11532,20 @@ export class FleetManager {
|
|
|
10519
11532
|
if (effectiveStatus === "connected")
|
|
10520
11533
|
connected++;
|
|
10521
11534
|
}
|
|
10522
|
-
const problems = [];
|
|
11535
|
+
const problems = [], warnings = [];
|
|
11536
|
+
const rawHub = this.rawFleetConfig?.hub;
|
|
11537
|
+
const hub = rawHub?.enabled === true ? { server: this.shuttingDown ? "stopped"
|
|
11538
|
+
: this.hubRuntime?.serverHealth?.(rawHub) ?? "unavailable" } : undefined;
|
|
11539
|
+
const hubOnly = !!hub && names.length === 0 && this.adapterState.size === 0;
|
|
11540
|
+
if (hub && hub.server !== "ready")
|
|
11541
|
+
problems.push(`Hub server is ${hub.server}`);
|
|
10523
11542
|
const hostMemory = this.memoryPressure.snapshot();
|
|
10524
|
-
if (
|
|
10525
|
-
|
|
11543
|
+
if (hostMemory.level === "critical" || hostMemory.level === "elevated") {
|
|
11544
|
+
const pressure = `host memory pressure is ${hostMemory.level}`;
|
|
11545
|
+
if (hubOnly)
|
|
11546
|
+
warnings.push(pressure);
|
|
11547
|
+
else if (!this.memoryPressure.advisoryOnly())
|
|
11548
|
+
problems.push(pressure);
|
|
10526
11549
|
}
|
|
10527
11550
|
if (this.adapterState.size > 0 && connected === 0)
|
|
10528
11551
|
problems.push("no channel adapter is connected");
|
|
@@ -10534,9 +11557,8 @@ export class FleetManager {
|
|
|
10534
11557
|
}
|
|
10535
11558
|
if (!this.startupComplete)
|
|
10536
11559
|
problems.push("startup has not completed");
|
|
10537
|
-
//
|
|
10538
|
-
|
|
10539
|
-
const status = this.adapterState.size > 0 && connected === 0
|
|
11560
|
+
// Preserve adapter scoring. A dedicated Hub also cannot serve its workload before its server mount is ready.
|
|
11561
|
+
const status = (this.adapterState.size > 0 && connected === 0) || (hubOnly && hub?.server !== "ready")
|
|
10540
11562
|
? "down"
|
|
10541
11563
|
: problems.length > 0 ? "degraded" : "ok";
|
|
10542
11564
|
return {
|
|
@@ -10548,7 +11570,7 @@ export class FleetManager {
|
|
|
10548
11570
|
memory: readFleetMemory(),
|
|
10549
11571
|
hostMemory: this.memoryTop && (hostMemory.level === "elevated" || hostMemory.level === "critical")
|
|
10550
11572
|
? { ...hostMemory, topProcesses: this.memoryTop.processes, topProcessesAt: this.memoryTop.at } : hostMemory,
|
|
10551
|
-
problems,
|
|
11573
|
+
problems, warnings, ...(hub ? { hub } : {}),
|
|
10552
11574
|
};
|
|
10553
11575
|
}
|
|
10554
11576
|
/** Start the primary adapter (backward-compatible, sets this.adapter) */
|
|
@@ -10623,6 +11645,11 @@ export class FleetManager {
|
|
|
10623
11645
|
adapter.on("callback_query", safeHandler(async (data) => {
|
|
10624
11646
|
await this.receiveAdapterCallback(data, adapterId, adapter, isCurrentAdapter);
|
|
10625
11647
|
}, this.logger, "adapter.callback_query"));
|
|
11648
|
+
adapter.on("missed_offline", (ev) => {
|
|
11649
|
+
if (!isCurrentAdapter())
|
|
11650
|
+
return;
|
|
11651
|
+
this.recordMissedOffline(ev);
|
|
11652
|
+
});
|
|
10626
11653
|
this.bindTopicClosedHandler(adapter, adapterId, "adapter.topic_closed");
|
|
10627
11654
|
// Handle classic bot slash commands (/start, /stop, /chat, /compact, /save, /load)
|
|
10628
11655
|
adapter.on("slash_command", safeHandler(async (data) => {
|
|
@@ -10776,6 +11803,11 @@ export class FleetManager {
|
|
|
10776
11803
|
adapter.on("callback_query", safeHandler(async (data) => {
|
|
10777
11804
|
await this.receiveAdapterCallback(data, adapterId, adapter, isCurrentAdapter);
|
|
10778
11805
|
}, this.logger, `adapter[${adapterId}].callback_query`));
|
|
11806
|
+
adapter.on("missed_offline", (ev) => {
|
|
11807
|
+
if (!isCurrentAdapter())
|
|
11808
|
+
return;
|
|
11809
|
+
this.recordMissedOffline(ev);
|
|
11810
|
+
});
|
|
10779
11811
|
this.bindTopicClosedHandler(adapter, adapterId, `adapter[${adapterId}].topic_closed`);
|
|
10780
11812
|
// Slash commands: classic bot + admin commands
|
|
10781
11813
|
adapter.on("slash_command", safeHandler(async (data) => {
|
|
@@ -10935,6 +11967,9 @@ export class FleetManager {
|
|
|
10935
11967
|
this.eventLog?.insert(targetInstance, "cross_instance_delivery_failed", {
|
|
10936
11968
|
from: senderSession, correlation_id: correlationId, error,
|
|
10937
11969
|
});
|
|
11970
|
+
// A Hub question the pane never took: the representative holds it uncertain (never resent).
|
|
11971
|
+
if (senderSession === HUB_REPORT_TARGET && !senderInstance)
|
|
11972
|
+
this.hubDeliveryFailed?.(correlationId, targetInstance);
|
|
10938
11973
|
if (senderInstance) {
|
|
10939
11974
|
this.notifyInstanceTopic(senderInstance, t("cross_instance.delivery_failed_notice", targetInstance, displayError, correlationId));
|
|
10940
11975
|
void this.deliverToInstance(senderInstance, {
|
|
@@ -11053,13 +12088,12 @@ export class FleetManager {
|
|
|
11053
12088
|
try {
|
|
11054
12089
|
const { execFile } = await import("./child-process.js");
|
|
11055
12090
|
const { promisify } = await import("node:util");
|
|
11056
|
-
const {
|
|
12091
|
+
const { tmuxArgs, tmuxBinary, tmuxEnvOption } = await import("./tmux-binary.js");
|
|
11057
12092
|
// Honour socket isolation: without -L this queried the user's default
|
|
11058
12093
|
// tmux server instead of the fleet's, so under a custom AGEND_HOME the
|
|
11059
12094
|
// check was meaningless (it reported every pane dead).
|
|
11060
|
-
const
|
|
11061
|
-
|
|
11062
|
-
await promisify(execFile)("tmux", args, { timeout: 5_000 });
|
|
12095
|
+
const args = tmuxArgs(["list-panes", "-t", windowId]);
|
|
12096
|
+
await promisify(execFile)(tmuxBinary(), args, { timeout: 5_000, ...tmuxEnvOption() });
|
|
11063
12097
|
}
|
|
11064
12098
|
catch {
|
|
11065
12099
|
// Pane dead — respawn
|
|
@@ -11516,6 +12550,34 @@ export class FleetManager {
|
|
|
11516
12550
|
}
|
|
11517
12551
|
return true;
|
|
11518
12552
|
}
|
|
12553
|
+
/** File a Telegram update that was too old to inject; Needs you lists it until Acknowledge. */
|
|
12554
|
+
recordMissedOffline(ev) {
|
|
12555
|
+
if (!this.missedOfflineStore)
|
|
12556
|
+
this.missedOfflineStore = new MissedOfflineStore(this.dataDir);
|
|
12557
|
+
const stub = {
|
|
12558
|
+
source: "telegram", adapterId: ev.adapterId, chatId: ev.chatId, threadId: ev.threadId,
|
|
12559
|
+
messageId: ev.messageId, userId: ev.userId, username: ev.username, text: ev.preview,
|
|
12560
|
+
timestamp: ev.timestamp, isBotMessage: false,
|
|
12561
|
+
};
|
|
12562
|
+
const threadId = this.inboundRouteThreadId(stub);
|
|
12563
|
+
const target = threadId ? this.resolveInboundTarget(stub, threadId) : undefined;
|
|
12564
|
+
let instance = target?.name ?? "";
|
|
12565
|
+
if (!instance) {
|
|
12566
|
+
instance = Object.entries(this.fleetConfig?.instances ?? {}).find(([name, cfg]) => cfg.general_topic && this.getInstanceAdapterId(name) === ev.adapterId)?.[0] ?? "";
|
|
12567
|
+
}
|
|
12568
|
+
const place = [ev.chatTitle, ev.threadId ? `#${ev.threadId}` : ""].filter(Boolean).join(" · ") || ev.chatId;
|
|
12569
|
+
this.missedOfflineStore.add({
|
|
12570
|
+
id: `missed:${ev.adapterId}:${ev.updateId}`,
|
|
12571
|
+
adapterId: ev.adapterId,
|
|
12572
|
+
instance,
|
|
12573
|
+
username: ev.username,
|
|
12574
|
+
place,
|
|
12575
|
+
preview: ev.preview,
|
|
12576
|
+
since: ev.timestamp.getTime(),
|
|
12577
|
+
});
|
|
12578
|
+
this.logger.info({ adapterId: ev.adapterId, updateId: ev.updateId, instance, chatId: ev.chatId, threadId: ev.threadId }, "Telegram message missed while AgEnD was offline — filed for Needs you");
|
|
12579
|
+
this.needsYou?.poke();
|
|
12580
|
+
}
|
|
11519
12581
|
/**
|
|
11520
12582
|
* #1085: coincident topic numbers must not route across Telegram groups.
|
|
11521
12583
|
*/
|
|
@@ -13152,6 +14214,11 @@ export class FleetManager {
|
|
|
13152
14214
|
let result;
|
|
13153
14215
|
switch (msg.type) {
|
|
13154
14216
|
case "fleet_decision_create": {
|
|
14217
|
+
const supersedes = this.decisionSupersedes("ipc-typed", instanceName, payload.supersedes);
|
|
14218
|
+
if ("error" in supersedes) {
|
|
14219
|
+
ipc.send({ type: "fleet_decision_response", fleetRequestId, error: supersedes.error });
|
|
14220
|
+
return;
|
|
14221
|
+
}
|
|
13155
14222
|
// Prune expired decisions on create
|
|
13156
14223
|
db.pruneExpiredDecisions();
|
|
13157
14224
|
result = db.createDecision({
|
|
@@ -13162,7 +14229,7 @@ export class FleetManager {
|
|
|
13162
14229
|
tags: payload.tags,
|
|
13163
14230
|
ttl_days: payload.ttl_days,
|
|
13164
14231
|
created_by: instanceName,
|
|
13165
|
-
supersedes:
|
|
14232
|
+
supersedes: supersedes.id,
|
|
13166
14233
|
});
|
|
13167
14234
|
break;
|
|
13168
14235
|
}
|
|
@@ -13339,6 +14406,21 @@ export class FleetManager {
|
|
|
13339
14406
|
return "ok";
|
|
13340
14407
|
}
|
|
13341
14408
|
}
|
|
14409
|
+
/**
|
|
14410
|
+
* `post_decision` with `supersedes` changes a decision someone else may have recorded (it stops being active): the
|
|
14411
|
+
* same permission as `update_decision`, asked through the same live check (tool set + dashboard switches), on both
|
|
14412
|
+
* create paths. An empty or absent value supersedes nothing and needs nothing; anything else must be an id.
|
|
14413
|
+
*/
|
|
14414
|
+
decisionSupersedes(sink, instanceName, value) {
|
|
14415
|
+
if (value === undefined || value === null || value === "")
|
|
14416
|
+
return { id: undefined };
|
|
14417
|
+
if (typeof value !== "string")
|
|
14418
|
+
return { error: "supersedes must be a decision id" };
|
|
14419
|
+
const permitted = this.checkToolPermission(sink, instanceName, "update_decision");
|
|
14420
|
+
if (!permitted.allowed)
|
|
14421
|
+
return { error: `Superseding a decision needs update_decision. ${permitted.message}` };
|
|
14422
|
+
return { id: value };
|
|
14423
|
+
}
|
|
13342
14424
|
async handleDecisionCrudHttp(instance, op, args) {
|
|
13343
14425
|
if (!this.scheduler)
|
|
13344
14426
|
return { error: "Scheduler not available" };
|
|
@@ -13354,16 +14436,24 @@ export class FleetManager {
|
|
|
13354
14436
|
if (!title || !content)
|
|
13355
14437
|
return { error: "title and content are required" };
|
|
13356
14438
|
const scope = args.scope === "fleet" ? "fleet" : "project";
|
|
13357
|
-
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
14439
|
+
const supersedes = this.decisionSupersedes("agent-endpoint", instance, args.supersedes);
|
|
14440
|
+
if ("error" in supersedes)
|
|
14441
|
+
return { error: supersedes.error };
|
|
14442
|
+
try {
|
|
14443
|
+
return db.createDecision({
|
|
14444
|
+
project_root: projectRoot,
|
|
14445
|
+
scope,
|
|
14446
|
+
title,
|
|
14447
|
+
content,
|
|
14448
|
+
tags: asStrArr(args.tags),
|
|
14449
|
+
ttl_days: asNum(args.ttl_days),
|
|
14450
|
+
supersedes: supersedes.id,
|
|
14451
|
+
created_by: instance,
|
|
14452
|
+
});
|
|
14453
|
+
}
|
|
14454
|
+
catch (err) {
|
|
14455
|
+
return { error: err.message }; // a refused predecessor: nothing was inserted
|
|
14456
|
+
}
|
|
13367
14457
|
}
|
|
13368
14458
|
// #2152: titles by default (agend-agent decision-list); one decision's full text by id (decision-get <id>).
|
|
13369
14459
|
// The CLI sends include_archived (snake case, as the MCP tool): both spellings are read.
|
|
@@ -13406,6 +14496,8 @@ export class FleetManager {
|
|
|
13406
14496
|
const asStatusFilter = normalizeStatusFilter;
|
|
13407
14497
|
// #1336: small write ack — identifying fields only.
|
|
13408
14498
|
const ack = (t) => ({ id: t.id, status: t.status, updated_at: t.updated_at });
|
|
14499
|
+
// #3195: an update's ack also carries what was SAVED for each field it named, read back from the task.
|
|
14500
|
+
const updatedAck = (t, named) => ({ ...ack(t), ...savedFields(t, named) });
|
|
13409
14501
|
// The board's notes for the write (a send-back reason, a comment the assignee had not seen): with the ack when any.
|
|
13410
14502
|
const noted = (a) => { const notes = db.board.takeNotes(); return notes.length ? { ...a, notes } : a; };
|
|
13411
14503
|
try {
|
|
@@ -13463,12 +14555,12 @@ export class FleetManager {
|
|
|
13463
14555
|
const id = asStr(args.id);
|
|
13464
14556
|
if (!id)
|
|
13465
14557
|
return { error: "id is required" };
|
|
13466
|
-
return noted(
|
|
14558
|
+
return noted(updatedAck(db.updateTask(db.getTaskByPrefix(id).id, {
|
|
13467
14559
|
status: asStatus(args.status),
|
|
13468
14560
|
assignee: asStr(args.assignee),
|
|
13469
14561
|
result: asStr(args.result),
|
|
13470
14562
|
priority: asPriority(args.priority),
|
|
13471
|
-
}, { kind: "instance", name: instance })));
|
|
14563
|
+
}, { kind: "instance", name: instance }), args));
|
|
13472
14564
|
}
|
|
13473
14565
|
default: return { error: `Unknown task action: ${action}` };
|
|
13474
14566
|
}
|
|
@@ -13622,7 +14714,8 @@ export class FleetManager {
|
|
|
13622
14714
|
result: payload.result,
|
|
13623
14715
|
priority: payload.priority,
|
|
13624
14716
|
}, { kind: "instance", name: meta.instance_name || instanceName });
|
|
13625
|
-
|
|
14717
|
+
// #3195: with what was SAVED for each field the update named, read back from the task.
|
|
14718
|
+
result = noted({ ...ack(logTask), ...savedFields(logTask, payload) });
|
|
13626
14719
|
break;
|
|
13627
14720
|
default:
|
|
13628
14721
|
throw new Error(`Unknown task action: ${action}`);
|
|
@@ -13652,16 +14745,101 @@ export class FleetManager {
|
|
|
13652
14745
|
}
|
|
13653
14746
|
return adapter.createTopic(topicName);
|
|
13654
14747
|
}
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
this.
|
|
13664
|
-
|
|
14748
|
+
/**
|
|
14749
|
+
* Delete an agent and, unless asked not to, its own chat topic (user decision: by default). The topic is planned
|
|
14750
|
+
* before the removal (its id and bot go with the fleet.yaml entry) and deleted through the agent's OWN bot after it;
|
|
14751
|
+
* the outcome is the platform's answer (instance-topic-delete.ts). A topic that cannot go never fails the removal.
|
|
14752
|
+
*/
|
|
14753
|
+
async removeInstanceAndTopic(name, authorization, opts) {
|
|
14754
|
+
const plan = opts.deleteTopic ? this.planInstanceTopicDelete(name) : null;
|
|
14755
|
+
if (opts.execution)
|
|
14756
|
+
await this.removeInstance(name, authorization, opts.execution);
|
|
14757
|
+
else
|
|
14758
|
+
await this.removeInstance(name, authorization);
|
|
14759
|
+
// #3055 review (Prism P1): asked again right before the platform call — the fleet as it is NOW, not as planned
|
|
14760
|
+
// before the removal was awaited (a new owner of the topic, or the bot rebuilt).
|
|
14761
|
+
return deletePlannedTopic(plan, this.logger, (p) => {
|
|
14762
|
+
if (this.instanceTopicAdapter(p.adapterId) !== p.adapter)
|
|
14763
|
+
return "the agent's bot changed while it was being deleted, so its topic was left";
|
|
14764
|
+
return topicMustStay(p.destination, this.topicOwnership(), null); // the original is gone: every owner now counts
|
|
14765
|
+
}, { begin: (d) => this.topicDeletionsInFlight.add(d), end: (d) => this.topicDeletionsInFlight.delete(d) });
|
|
14766
|
+
}
|
|
14767
|
+
/** #3055: destinations whose platform deletion is running now; a binding to one waits until it is over. */
|
|
14768
|
+
topicDeletionsInFlight = new Set();
|
|
14769
|
+
/** True while a topic with this id is being deleted on any connection (a new binding of it is refused meanwhile). */
|
|
14770
|
+
isTopicDeletionInFlight(topicId) {
|
|
14771
|
+
const tail = `:${topicId}`;
|
|
14772
|
+
return [...this.topicDeletionsInFlight].some(d => d.endsWith(tail));
|
|
14773
|
+
}
|
|
14774
|
+
/**
|
|
14775
|
+
* #3055 review r2 (Prism P1-3): would this instance config bind a topic whose deletion is running now? Compared by
|
|
14776
|
+
* physical destination, so the same thread number in another Telegram group is not held. Settings asks it at commit.
|
|
14777
|
+
*/
|
|
14778
|
+
topicBindingInFlight(inst) {
|
|
14779
|
+
if (this.topicDeletionsInFlight.size === 0 || inst.topic_id == null || inst.topic_id === "")
|
|
14780
|
+
return false;
|
|
14781
|
+
const adapterId = typeof inst.channel_id === "string" && inst.channel_id ? inst.channel_id : this.getPrimaryAdapterId();
|
|
14782
|
+
return this.topicDeletionsInFlight.has(this.destinationFor(adapterId, inst.topic_id));
|
|
14783
|
+
}
|
|
14784
|
+
/** Any topic deletion running now (a connection's group or General may not be re-pointed meanwhile). */
|
|
14785
|
+
topicDeletionPending() { return this.topicDeletionsInFlight.size > 0; }
|
|
14786
|
+
/** The physical destination of `topicId` on the bot `adapterId`. */
|
|
14787
|
+
destinationFor(adapterId, topicId) {
|
|
14788
|
+
const world = adapterId ? this.worlds.get(adapterId) : undefined;
|
|
14789
|
+
const platform = world?.adapter?.type ?? this.getChannelConfig(adapterId)?.type;
|
|
14790
|
+
const groupId = world?.groupId ?? String(this.getChannelConfig(adapterId)?.group_id ?? "");
|
|
14791
|
+
return topicDestination(platform, groupId, adapterId, topicId);
|
|
14792
|
+
}
|
|
14793
|
+
/** The adapter of the bot `adapterId` names — never a substitute for a bot that is not there. */
|
|
14794
|
+
instanceTopicAdapter(adapterId) {
|
|
14795
|
+
return (adapterId ? this.worlds.get(adapterId)?.adapter : this.worlds.size === 0 ? this.adapter ?? undefined : undefined) ?? undefined;
|
|
14796
|
+
}
|
|
14797
|
+
/**
|
|
14798
|
+
* Topic ownership by physical destination (#3055 review, Prism P1): an instance's topic is where its bot's platform
|
|
14799
|
+
* puts it (a Telegram group + thread, a Discord channel), so two bots in one group, or two instances on one
|
|
14800
|
+
* channel, are seen to share it; and every connection's own General is protected, with or without a General agent.
|
|
14801
|
+
*/
|
|
14802
|
+
topicOwnership() {
|
|
14803
|
+
const channels = this.fleetConfig?.channels ?? (this.fleetConfig?.channel ? [this.fleetConfig.channel] : []);
|
|
14804
|
+
const destinationOf = (n) => {
|
|
14805
|
+
const cfg = this.fleetConfig?.instances?.[n];
|
|
14806
|
+
if (!cfg || cfg.topic_id == null || cfg.topic_id === "")
|
|
14807
|
+
return null;
|
|
14808
|
+
return this.destinationFor(this.topicAdapterIdOf(n), cfg.topic_id);
|
|
14809
|
+
};
|
|
14810
|
+
const generalDestinations = () => {
|
|
14811
|
+
const out = new Set();
|
|
14812
|
+
for (const ch of channels) {
|
|
14813
|
+
const id = ch.id ?? ch.type;
|
|
14814
|
+
const groupId = this.worlds.get(id)?.groupId ?? (ch.group_id != null ? String(ch.group_id) : undefined);
|
|
14815
|
+
if (ch.type === "telegram")
|
|
14816
|
+
out.add(topicDestination("telegram", groupId, id, 1));
|
|
14817
|
+
if (ch.type === "discord") {
|
|
14818
|
+
const gcid = discordGeneralChannelId(ch);
|
|
14819
|
+
if (gcid)
|
|
14820
|
+
out.add(topicDestination("discord", groupId, id, gcid));
|
|
14821
|
+
}
|
|
14822
|
+
}
|
|
14823
|
+
return out;
|
|
14824
|
+
};
|
|
14825
|
+
return { instances: this.fleetConfig?.instances, destinationOf, generalDestinations };
|
|
14826
|
+
}
|
|
14827
|
+
/**
|
|
14828
|
+
* The bot an agent's configured topic is on (#3105 review, Prism P1): a fleet.yaml agent's `channel_id` (else the
|
|
14829
|
+
* primary connection) whatever its runtime — a per-turn Windows agent has no execution adapter
|
|
14830
|
+
* (getInstanceAdapterId), yet its topic is still on that bot, and must be counted as an owner and deleted through it.
|
|
14831
|
+
* Topic planning and ownership only; execution routing is getInstanceAdapterId's and unchanged.
|
|
14832
|
+
*/
|
|
14833
|
+
topicAdapterIdOf(name) {
|
|
14834
|
+
const cfg = this.fleetConfig?.instances?.[name];
|
|
14835
|
+
if (cfg)
|
|
14836
|
+
return cfg.channel_id ?? this.getPrimaryAdapterId();
|
|
14837
|
+
return this.getInstanceAdapterId(name);
|
|
14838
|
+
}
|
|
14839
|
+
/** What deleting `name`'s topic would act on: its own bot only — a bot that is not there is never substituted. */
|
|
14840
|
+
planInstanceTopicDelete(name) {
|
|
14841
|
+
const adapterId = this.topicAdapterIdOf(name);
|
|
14842
|
+
return planInstanceTopicDelete({ name, adapterId, adapter: this.instanceTopicAdapter(adapterId), ...this.topicOwnership() });
|
|
13665
14843
|
}
|
|
13666
14844
|
getForumTopicDeleter(adapterId) {
|
|
13667
14845
|
const adapter = (adapterId ? this.worlds.get(adapterId)?.adapter : undefined) ?? this.adapter;
|
|
@@ -13940,6 +15118,8 @@ export class FleetManager {
|
|
|
13940
15118
|
this.observeWebAuthority(); // #2453 review: so is a web-authority switch (off is always seen)
|
|
13941
15119
|
if (!this.fleetConfig || !this.configPath)
|
|
13942
15120
|
return;
|
|
15121
|
+
// #3147 r2: a changed or removed Hub representative's consent is invalidated durably BEFORE the change is written.
|
|
15122
|
+
this.observeHubAgentIncarnations(true);
|
|
13943
15123
|
if (!this.savedFleetConfigSnapshot)
|
|
13944
15124
|
this.savedFleetConfigSnapshot = structuredClone(this.fleetConfig);
|
|
13945
15125
|
normalizeNoticeDelivery(this.fleetConfig);
|
|
@@ -14062,9 +15242,12 @@ export class FleetManager {
|
|
|
14062
15242
|
Object.assign(current, resolved);
|
|
14063
15243
|
}
|
|
14064
15244
|
this.savedFleetConfigSnapshot = structuredClone(this.fleetConfig);
|
|
15245
|
+
this.nativeMcpStore?.observePolicies();
|
|
15246
|
+
this.agentCredentialsCache?.observePolicies();
|
|
14065
15247
|
this.refreshSavedDashboardPermissions();
|
|
14066
15248
|
this.logger.info({ path: this.configPath, strippedDefaults: redundantPaths.length }, "Saved fleet config (lossless patch)");
|
|
14067
15249
|
this.observeRuntimeSwitches(); // M-2255: a saved Windows runtime switch applies now
|
|
15250
|
+
this.observeHubSwitches(); // S-51: so does a saved Hub switch
|
|
14068
15251
|
}
|
|
14069
15252
|
/** A permission tightening is effective when its save returns, independently of the later apply job or IPC. */
|
|
14070
15253
|
refreshSavedDashboardPermissions() {
|
|
@@ -14374,6 +15557,7 @@ export class FleetManager {
|
|
|
14374
15557
|
const instanceDirToClean = this.getInstanceDir(name);
|
|
14375
15558
|
// #1774: replies sent from here on are a later instance's (a replacement registered while this one goes); the ones
|
|
14376
15559
|
// sent before wait for the outcome before they are shown.
|
|
15560
|
+
this.forgetHubAgentIncarnation(name, true); // #3147: a re-added instance never inherits Hub consent; not durable → refused
|
|
14377
15561
|
const removedBelow = this.webChatGeneration(name) + 1, removedDaemon = this.daemons.get(name);
|
|
14378
15562
|
this.webChatGenerations.set(name, removedBelow);
|
|
14379
15563
|
let settleRemoval;
|
|
@@ -15784,6 +16968,46 @@ export class FleetManager {
|
|
|
15784
16968
|
}
|
|
15785
16969
|
return { chatId, opts: {} };
|
|
15786
16970
|
}
|
|
16971
|
+
/**
|
|
16972
|
+
* M-2457 §5: one fleet notice, the first time an upgraded home's fleet runs on AgEnD's own tmux. Marked done only once it
|
|
16973
|
+
* was dispatched (General, the channel's notice target, or a web-only fleet's Notices), so a start with nowhere to
|
|
16974
|
+
* post it tries again next start.
|
|
16975
|
+
*/
|
|
16976
|
+
/** Set at fleet start (before any agent starts): this home ran agents on an earlier AgEnD's system tmux. */
|
|
16977
|
+
ownTmuxUpgradedHome = false;
|
|
16978
|
+
/** An upgraded home: agent state from an earlier start, and no AgEnD tmux server ever recorded (`previous`). */
|
|
16979
|
+
static ownTmuxUpgraded(agendHome, previous) {
|
|
16980
|
+
return previous === null && FleetManager.priorAgentState(join(agendHome, "instances"));
|
|
16981
|
+
}
|
|
16982
|
+
/** Whether any instance directory holds state from an earlier start (its output log or a session id). */
|
|
16983
|
+
static priorAgentState(instancesDir) {
|
|
16984
|
+
let names = [];
|
|
16985
|
+
try {
|
|
16986
|
+
names = readdirSync(instancesDir);
|
|
16987
|
+
}
|
|
16988
|
+
catch {
|
|
16989
|
+
return false;
|
|
16990
|
+
}
|
|
16991
|
+
return names.some(n => ["output.log", "session-id"].some(f => existsSync(join(instancesDir, n, f))));
|
|
16992
|
+
}
|
|
16993
|
+
announceOwnTmux() {
|
|
16994
|
+
const marker = join(getAgendHome(), "tmux", "own-server-announced");
|
|
16995
|
+
if (existsSync(marker))
|
|
16996
|
+
return;
|
|
16997
|
+
// Only a home an earlier AgEnD ran its agents in (on the system tmux) has something to be told (Fable #3312 N3):
|
|
16998
|
+
// agent state from before this start and no recorded AgEnD tmux server (set at fleet start), or a migration journal
|
|
16999
|
+
// (2.3 window ids found). A fresh home is marked without a notice.
|
|
17000
|
+
const upgraded = this.ownTmuxUpgradedHome || existsSync(join(getAgendHome(), "tmux-migration.json"));
|
|
17001
|
+
if (upgraded && !this.notifyFleetError(t("tmux.own_server_notice"), { throttle: false }))
|
|
17002
|
+
return;
|
|
17003
|
+
try {
|
|
17004
|
+
mkdirSync(dirname(marker), { recursive: true });
|
|
17005
|
+
writeFileSync(marker, `${new Date().toISOString()}\n`);
|
|
17006
|
+
}
|
|
17007
|
+
catch (err) {
|
|
17008
|
+
this.logger.warn({ err }, "Could not record that the own-tmux notice was posted");
|
|
17009
|
+
}
|
|
17010
|
+
}
|
|
15787
17011
|
/**
|
|
15788
17012
|
* Post the daily summary where fleet-wide notices go.
|
|
15789
17013
|
*
|
|
@@ -16358,6 +17582,11 @@ export class FleetManager {
|
|
|
16358
17582
|
needsYouItems() {
|
|
16359
17583
|
return this.needsYou?.webItems() ?? [];
|
|
16360
17584
|
}
|
|
17585
|
+
/** Enabled member composition supplies only a local attention reader, never an approval/execution callback. */
|
|
17586
|
+
attachHubExecutionAttention(read) {
|
|
17587
|
+
this.hubExecutionAttention = read;
|
|
17588
|
+
this.needsYou?.poke();
|
|
17589
|
+
}
|
|
16361
17590
|
/**
|
|
16362
17591
|
* #1389: the org chart's structure for the web — the instances the dashboard lists (getUiStatus's names), General,
|
|
16363
17592
|
* fleet.yaml's teams, each instance's description and thread link. Read on demand; the live state rides the stream.
|
|
@@ -16421,6 +17650,7 @@ export class FleetManager {
|
|
|
16421
17650
|
const fleet = Object.entries(this.fleetConfig?.instances ?? {}).filter(([, cfg]) => !isWindowsInstance(cfg)).map(([name, cfg]) => ({
|
|
16422
17651
|
name, backend: this.backendNameOf(name), workingDirectory: cfg.working_directory, ledgerPath: join(this.getInstanceDir(name), "cache-ledger.json"),
|
|
16423
17652
|
claudeConfigDir: this.claudeConfigDirOf(name), profile: this.usageProfileOf(name, this.backendNameOf(name)),
|
|
17653
|
+
...(this.backendNameOf(name) === "codex" ? { profileTimelinePath: join(this.getInstanceDir(name), PROFILE_TIMELINE_FILE) } : {}),
|
|
16424
17654
|
kiroDbPath: this.kiroDbPathOf(name, this.backendNameOf(name)),
|
|
16425
17655
|
}));
|
|
16426
17656
|
const taken = new Set(fleet.map(i => i.name));
|
|
@@ -16432,6 +17662,9 @@ export class FleetManager {
|
|
|
16432
17662
|
claudeConfigDir: this.claudeConfigDirOf(ch.instanceName),
|
|
16433
17663
|
profile: this.usageProfileOf(ch.instanceName, this.classicChannels?.getBackendByInstance(ch.instanceName, this.fleetConfig?.defaults?.backend) ?? this.fleetConfig?.defaults?.backend ?? "claude-code"),
|
|
16434
17664
|
kiroDbPath: this.kiroDbPathOf(ch.instanceName, this.classicChannels?.getBackendByInstance(ch.instanceName, this.fleetConfig?.defaults?.backend) ?? this.fleetConfig?.defaults?.backend ?? "claude-code"),
|
|
17665
|
+
// #3066 §1d (Fable r1 #2): a ClassicBot Codex room records its launches too (onDaemonReady) — read them the same way.
|
|
17666
|
+
...((this.classicChannels?.getBackendByInstance(ch.instanceName, this.fleetConfig?.defaults?.backend) ?? this.fleetConfig?.defaults?.backend) === "codex"
|
|
17667
|
+
? { profileTimelinePath: join(this.getInstanceDir(ch.instanceName), PROFILE_TIMELINE_FILE) } : {}),
|
|
16435
17668
|
}));
|
|
16436
17669
|
return [...fleet, ...new Map(classic.map(c => [c.name, c])).values()];
|
|
16437
17670
|
}
|
|
@@ -16592,7 +17825,8 @@ export class FleetManager {
|
|
|
16592
17825
|
out.push({
|
|
16593
17826
|
name, state: p.state ?? undefined,
|
|
16594
17827
|
interaction: p.interaction ? { kind: p.interaction.kind, owner: wait?.owner ?? null, episode: p.interaction.episode, since: p.interaction.since } : null,
|
|
16595
|
-
interactionSummary: p.interaction_summary ?? null,
|
|
17828
|
+
interactionSummary: p.interaction?.kind === "kiro_choice" ? t("kiro3.running") : p.interaction_summary ?? null,
|
|
17829
|
+
kiroCompatibility: this.kiroCompatibilityHolds?.get(name),
|
|
16596
17830
|
pauseReason, pausedAt,
|
|
16597
17831
|
crashedAt: crashed ? (this.needsCrashedAt.get(name) ?? null) : null,
|
|
16598
17832
|
signIn: pauseReason === "auth" ? this.signInFor(name) : null,
|
|
@@ -16684,8 +17918,22 @@ export class FleetManager {
|
|
|
16684
17918
|
throw new Error("the delivery outbox is not open");
|
|
16685
17919
|
return this.deliveryOutbox.acknowledge(deliveryId, by);
|
|
16686
17920
|
},
|
|
17921
|
+
missedOffline: () => (this.missedOfflineStore?.list(Date.now()) ?? []).map(m => ({
|
|
17922
|
+
id: m.id, instance: m.instance, owner: m.adapterId, username: m.username, place: m.place, preview: m.preview, since: m.since,
|
|
17923
|
+
})),
|
|
17924
|
+
acknowledgeMissed: (id, by) => this.missedOfflineStore?.acknowledge(id, by) ?? false,
|
|
16687
17925
|
tasks: () => this.needsYouTaskItems(),
|
|
16688
17926
|
backendSignIns: () => this.needsYouBackendSignIns(),
|
|
17927
|
+
signInKeepAlive: () => this.keepAliveAttention(),
|
|
17928
|
+
hubExecution: () => this.hubExecutionAttention?.() ?? [],
|
|
17929
|
+
runtimeUpdates: () => remoteRuntimeEnabled() ? runtimeUpdateAttention(this.runtimeHub?.listMachines() ?? [], t, this.worlds.keys().next().value) : [],
|
|
17930
|
+
hubHolds: () => this.hubHolds.map(h => {
|
|
17931
|
+
// A provider hold carries a bounded setup reason; its guidance (S4b's copy) when present, else the code's text.
|
|
17932
|
+
const guidance = h.reason ? t(`hub.provider.${h.reason}`) : "";
|
|
17933
|
+
return { side: h.side, code: h.code, since: h.since, detail: guidance && guidance !== `hub.provider.${h.reason}` ? guidance : t(`hub.hold.${h.code}`) };
|
|
17934
|
+
}),
|
|
17935
|
+
tmuxHolds: () => [...(this.tmuxHold ? [{ instance: null, ...this.tmuxHold }] : []),
|
|
17936
|
+
...[...this.legacyWindowHolds].map(([instance, h]) => ({ instance, ...h }))],
|
|
16689
17937
|
configIssues: () => (this.configHistory?.currentIssues() ?? []).map(issue => ({
|
|
16690
17938
|
...issue, detail: configIssueText(issue, t), owner: this.worlds.keys().next().value,
|
|
16691
17939
|
})),
|
|
@@ -17602,7 +18850,7 @@ export class FleetManager {
|
|
|
17602
18850
|
// Over a link: the temporary one (§0.3), else the named one (a record from before §0.3 has no peer).
|
|
17603
18851
|
...(sessions.get(a.handle).surface === "gateway" ? (a.peer === "quick_link" ? { quick: true } : { named: true }) : {}) })) : [];
|
|
17604
18852
|
const host = this.fleetConfig?.web?.public_link?.hostname;
|
|
17605
|
-
return { state, configured, hours: VERIFIED_SESSION_HOURS, lanHosts, authorized, namedHost: typeof host === "string" && host ? host : null };
|
|
18853
|
+
return { state, configured, hours: VERIFIED_SESSION_HOURS, lanHosts, authorized, namedHost: typeof host === "string" && host ? host : null, webOnly: this.isWebOnlyFleet() };
|
|
17606
18854
|
}
|
|
17607
18855
|
authorizationRequests = null;
|
|
17608
18856
|
/**
|
|
@@ -17665,8 +18913,9 @@ export class FleetManager {
|
|
|
17665
18913
|
return r.ok ? { ok: true, until: Math.min(r.authorization.until, record.absoluteExpiry) } : { ok: false, refusal: r.refusal };
|
|
17666
18914
|
},
|
|
17667
18915
|
signOut: (handle) => {
|
|
17668
|
-
this.webSessions?.revokeByHandle(handle);
|
|
17669
|
-
this.sessionAuthorizationStore()?.prune(a => a.handle !== handle);
|
|
18916
|
+
const session = this.webSessions?.revokeByHandle(handle) ?? { found: false, durable: true };
|
|
18917
|
+
const authorization = this.sessionAuthorizationStore()?.prune(a => a.handle !== handle) ?? { dropped: 0, durable: true };
|
|
18918
|
+
return { durable: session.durable, authorizationDurable: authorization.durable };
|
|
17670
18919
|
},
|
|
17671
18920
|
event: (type, payload) => { try {
|
|
17672
18921
|
this.eventLog?.insert("web", type, payload);
|
|
@@ -17679,6 +18928,7 @@ export class FleetManager {
|
|
|
17679
18928
|
expired: (c) => t("web_auth.card_expired", c.label),
|
|
17680
18929
|
refused: (c) => t("web_auth.card_refused", c.label, t(`web_auth.refusal_${c.refusal}`)),
|
|
17681
18930
|
revoked: (c) => t("web_auth.card_revoked", c.label),
|
|
18931
|
+
notSaved: (c) => t("web_auth.card_not_saved", c.label),
|
|
17682
18932
|
ended: (c) => t("web_auth.card_ended", c.label),
|
|
17683
18933
|
generalHint: () => t("web_auth.general_hint"),
|
|
17684
18934
|
confirmLabel: () => t("web_auth.confirm"),
|
|
@@ -18601,7 +19851,14 @@ export class FleetManager {
|
|
|
18601
19851
|
return;
|
|
18602
19852
|
}
|
|
18603
19853
|
const publication = this.beginCancelButtonPublication(instanceName, correlationId);
|
|
18604
|
-
|
|
19854
|
+
// M-2391: a re-post below a reply (preserveProgress) continues the same turn — its elapsed time continues from
|
|
19855
|
+
// the live bubble's start, as its tool list does. Restarting it at 0 meant an agent replying more often than the
|
|
19856
|
+
// threshold never showed elapsed time at all. A fresh turn (no preserve) starts at 0 as before.
|
|
19857
|
+
const carriedStart = preserveProgress ? this.liveButtonStart(instanceName) : undefined;
|
|
19858
|
+
const carriedMs = carriedStart !== undefined ? Math.max(0, Date.now() - carriedStart) : 0;
|
|
19859
|
+
const initialProgressText = carriedStart !== undefined && carriedMs >= this.progressMinElapsedMs()
|
|
19860
|
+
? FleetManager.progressText(carriedMs, null, this.progressMinElapsedMs(), this.progressPrefixFor(instanceName, carriedMs))
|
|
19861
|
+
: FleetManager.progressText(0, null, 1, this.progressPrefixFor(instanceName, 0, 1));
|
|
18605
19862
|
try {
|
|
18606
19863
|
const sent = await adapter.notifyAlert(chatId, {
|
|
18607
19864
|
type: "cancel",
|
|
@@ -18624,7 +19881,7 @@ export class FleetManager {
|
|
|
18624
19881
|
// Elapsed time is measured from when this button was posted — i.e. from
|
|
18625
19882
|
// when the work was handed over — not from the pane's working transition,
|
|
18626
19883
|
// which resets if the CLI blips idle mid-turn.
|
|
18627
|
-
startedAt: Date.now(),
|
|
19884
|
+
startedAt: carriedStart ?? Date.now(),
|
|
18628
19885
|
// Matches the text notifyAlert just posted, so the first 60s tick does
|
|
18629
19886
|
// not re-edit identical text — which put a "(edited)" mark on Discord
|
|
18630
19887
|
// with nothing visibly changed.
|
|
@@ -18747,14 +20004,16 @@ export class FleetManager {
|
|
|
18747
20004
|
* Make a tool summary safe to paste into a channel message.
|
|
18748
20005
|
*
|
|
18749
20006
|
* The text is agent-controlled (it is built from tool inputs — file paths,
|
|
18750
|
-
* shell commands), so it gets flattened to one line, capped,
|
|
18751
|
-
* the two Discord mass-mention triggers.
|
|
18752
|
-
*
|
|
20007
|
+
* shell commands), so it gets flattened to one line, secrets masked, capped,
|
|
20008
|
+
* and stripped of the two Discord mass-mention triggers. Masking comes BEFORE
|
|
20009
|
+
* the cap: a cap can cut a mask's context but must never be what hides (or
|
|
20010
|
+
* fails to hide) a secret. Neither channel renders it with a parse mode, so no
|
|
20011
|
+
* markup escaping is needed beyond that.
|
|
18753
20012
|
*/
|
|
18754
20013
|
static sanitizeActivity(activity) {
|
|
18755
20014
|
if (!activity)
|
|
18756
20015
|
return null;
|
|
18757
|
-
const flat = activity.replace(/\s+/g, " ").replace(/@(everyone|here)/g, "@$1").trim();
|
|
20016
|
+
const flat = maskSecrets(activity.replace(/\s+/g, " ")).replace(/@(everyone|here)/g, "@$1").trim();
|
|
18758
20017
|
if (!flat)
|
|
18759
20018
|
return null;
|
|
18760
20019
|
return flat.length > PROGRESS_ACTIVITY_MAX_CHARS
|
|
@@ -18873,6 +20132,12 @@ export class FleetManager {
|
|
|
18873
20132
|
}
|
|
18874
20133
|
return PROGRESS_MIN_ELAPSED_MS;
|
|
18875
20134
|
}
|
|
20135
|
+
/** M-2391: when the instance's live (not retiring) bubble started — the current turn's start — or undefined. */
|
|
20136
|
+
liveButtonStart(instanceName) {
|
|
20137
|
+
const starts = [...this.cancelButtons.values()].filter((e) => e.instanceName === instanceName && !e.retiring && typeof e.startedAt === "number")
|
|
20138
|
+
.map((e) => e.startedAt);
|
|
20139
|
+
return starts.length ? Math.min(...starts) : undefined;
|
|
20140
|
+
}
|
|
18876
20141
|
startProgressTicker(entry) {
|
|
18877
20142
|
const tick = () => this.refreshBubble(entry);
|
|
18878
20143
|
entry.progressTimer = setInterval(tick, PROGRESS_UPDATE_INTERVAL_MS);
|
|
@@ -18882,7 +20147,9 @@ export class FleetManager {
|
|
|
18882
20147
|
// one additional edit per turn that lives past the threshold.
|
|
18883
20148
|
const firstAt = this.progressMinElapsedMs() - (Date.now() - (entry.startedAt ?? Date.now()));
|
|
18884
20149
|
if (firstAt > 0 && firstAt < PROGRESS_UPDATE_INTERVAL_MS) {
|
|
18885
|
-
|
|
20150
|
+
// M-2391: a little past the threshold — a timer can fire a millisecond before Date.now() reaches it, which
|
|
20151
|
+
// rendered the unchanged "處理中…" text and skipped the edit until the next 60 s interval.
|
|
20152
|
+
const firstTick = setTimeout(tick, firstAt + PROGRESS_THRESHOLD_MARGIN_MS);
|
|
18886
20153
|
firstTick.unref?.();
|
|
18887
20154
|
}
|
|
18888
20155
|
}
|
|
@@ -19195,6 +20462,43 @@ export class FleetManager {
|
|
|
19195
20462
|
}
|
|
19196
20463
|
return this.loginController;
|
|
19197
20464
|
}
|
|
20465
|
+
/**
|
|
20466
|
+
* #3190 Part 3c: dashboard sign-ins on a paired computer (machine-signins.ts): #3212's StructuredSignIn over a RuntimeSignInTransport, one computer and one
|
|
20467
|
+
* credential profile at a time. Its own coordinator, not the host's: it never touches the host's sign-in checklist or login window.
|
|
20468
|
+
*/
|
|
20469
|
+
machineSignInsInstance = null;
|
|
20470
|
+
get machineSignIns() {
|
|
20471
|
+
return this.machineSignInsInstance ??= new MachineSignIns({
|
|
20472
|
+
call: (id, operation, payload, timeoutMs) => this.runtimeCoordinator().callAccount(id, operation, payload, timeoutMs),
|
|
20473
|
+
current: owner => this.browserSignInOwnerCurrent(owner),
|
|
20474
|
+
reported: (id, profile) => this.machineAccounts.profileState(id, profile),
|
|
20475
|
+
readiness: id => this.machineAccounts.readiness(id),
|
|
20476
|
+
actor: owner => { const handle = owner.handle; return typeof handle === "string" && /^[a-f0-9]{16}$/.test(handle) ? `admin:${handle}` : null; },
|
|
20477
|
+
changed: (event, owner) => {
|
|
20478
|
+
// Safe fields only: the computer, the profile name, a phase and a fixed reason. Never a URL, a code, output or an e-mail address.
|
|
20479
|
+
this.logger.info({ machine: event.machine, profile: event.profile, phase: event.phase, ...(event.reason ? { reason: event.reason } : {}), by: owner.label }, "Computer account sign-in from Settings → Accounts");
|
|
20480
|
+
broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
|
|
20481
|
+
this.needsYou?.poke();
|
|
20482
|
+
},
|
|
20483
|
+
});
|
|
20484
|
+
}
|
|
20485
|
+
machineAccountsInstance = null;
|
|
20486
|
+
/** #3190 Part 3c: a paired computer's accounts in Settings → Accounts (machine-accounts.ts). */
|
|
20487
|
+
get machineAccounts() {
|
|
20488
|
+
return this.machineAccountsInstance ??= new MachineAccounts({
|
|
20489
|
+
call: (id, operation, payload, timeoutMs) => this.runtimeCoordinator().callAccount(id, operation, payload, timeoutMs),
|
|
20490
|
+
machine: id => remoteRuntimeEnabled() ? this.runtimeCoordinator().machine(id) ?? undefined : undefined,
|
|
20491
|
+
machines: () => remoteRuntimeEnabled() ? this.runtimeCoordinator().listMachines() : [],
|
|
20492
|
+
agents: id => machineAgents(this.fleetConfig?.instances, id, name => { try {
|
|
20493
|
+
return nativeCredentialProfile(this.fleetConfig?.instances[name]) ?? null;
|
|
20494
|
+
}
|
|
20495
|
+
catch {
|
|
20496
|
+
return null;
|
|
20497
|
+
} }, this.fleetConfig?.defaults?.backend ?? "claude-code"),
|
|
20498
|
+
signingIn: (id, profile) => this.machineSignInsInstance?.signingIn(id, profile) ?? false,
|
|
20499
|
+
log: entry => this.logger.info(entry, entry.outcome === "ok" ? "Computer account changed from Settings → Accounts" : "Computer account change refused"),
|
|
20500
|
+
});
|
|
20501
|
+
}
|
|
19198
20502
|
browserBackendSignInsInstance = null;
|
|
19199
20503
|
structuredLoginCleanupFailed = false;
|
|
19200
20504
|
pendingBackendSince = new Map();
|
|
@@ -19221,6 +20525,8 @@ export class FleetManager {
|
|
|
19221
20525
|
}
|
|
19222
20526
|
catch { /* safe metadata only */ }
|
|
19223
20527
|
broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
|
|
20528
|
+
if (event.phase === "done")
|
|
20529
|
+
this.forgetSignInIdentities(); // a sign-in may be a different account now
|
|
19224
20530
|
this.needsYou?.poke();
|
|
19225
20531
|
if (!this.browserSignInOwnerCurrent(owner))
|
|
19226
20532
|
return;
|
|
@@ -19259,7 +20565,10 @@ export class FleetManager {
|
|
|
19259
20565
|
cancel: () => this.cancelLoginSession(),
|
|
19260
20566
|
notice: ({ shown, label, handle }) => this.notifyFleetError(t("login.web_dashboard_notice", shown, label, handle.slice(0, 8))),
|
|
19261
20567
|
// No details in the event: each page reads its own view (GET /ui/backend-login), as its session may see it.
|
|
19262
|
-
|
|
20568
|
+
// The accounts are forgotten when ANY sign-in ends, even one a later one replaced (it may be a different account now), and not at every step of a
|
|
20569
|
+
// running one: `changed` only tells the pages to read again.
|
|
20570
|
+
changed: () => { broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed")); },
|
|
20571
|
+
loginEnded: () => this.forgetSignInIdentities(),
|
|
19263
20572
|
});
|
|
19264
20573
|
return this.webBackendLoginsInstance;
|
|
19265
20574
|
}
|
|
@@ -19273,6 +20582,551 @@ export class FleetManager {
|
|
|
19273
20582
|
* #2233: Settings → Agents' sign-in list — every backend's default login as the availability snapshot has it, then
|
|
19274
20583
|
* each credential profile an agent uses (its own login state, read offline).
|
|
19275
20584
|
*/
|
|
20585
|
+
/** Which account each sign-in is, as the host's own `claude auth status` said (masked; see checkAuthIdentity). Keys are `backend\0profile` in a Map: a name is data, never a property. */
|
|
20586
|
+
signInIdentities = new Map();
|
|
20587
|
+
/** Reads in flight, by the same key: a second request for a sign-in that is already being read joins it instead of starting another process. */
|
|
20588
|
+
signInIdentityReads = new Map();
|
|
20589
|
+
/** Raised each time the accounts are forgotten: a read that began before is never allowed to write what it found. */
|
|
20590
|
+
signInIdentityGeneration = 0;
|
|
20591
|
+
signInIdentitySlots = 0;
|
|
20592
|
+
signInIdentityWaiters = [];
|
|
20593
|
+
signInIdentity(backend, profile) { return this.signInIdentities.get(`${backend}\0${profile ?? ""}`)?.identity ?? undefined; }
|
|
20594
|
+
/** A sign-in finished (or changed): forget what was read and let no read that was already running put its answer back. */
|
|
20595
|
+
forgetSignInIdentities() { this.signInIdentityGeneration++; this.signInIdentities.clear(); this.signInIdentityReads.clear(); }
|
|
20596
|
+
/** At most three `claude auth status` at once across the whole host, however many requests ask. */
|
|
20597
|
+
async withSignInIdentitySlot(task) {
|
|
20598
|
+
while (this.signInIdentitySlots >= 3)
|
|
20599
|
+
await new Promise(resolve => this.signInIdentityWaiters.push(resolve));
|
|
20600
|
+
this.signInIdentitySlots++;
|
|
20601
|
+
try {
|
|
20602
|
+
return await task();
|
|
20603
|
+
}
|
|
20604
|
+
finally {
|
|
20605
|
+
this.signInIdentitySlots--;
|
|
20606
|
+
this.signInIdentityWaiters.shift()?.();
|
|
20607
|
+
}
|
|
20608
|
+
}
|
|
20609
|
+
/** One `claude auth status` for a sign-in (the default one, or a credential profile's folder). */
|
|
20610
|
+
async readSignInIdentity(target) {
|
|
20611
|
+
let env;
|
|
20612
|
+
if (target.profile)
|
|
20613
|
+
env = credentialProfileEnv(this.dataDir, target.backend, target.profile) ?? undefined;
|
|
20614
|
+
return checkAuthIdentity(target.backend, env);
|
|
20615
|
+
}
|
|
20616
|
+
/**
|
|
20617
|
+
* Start reading, in the background, the account of each Claude Code sign-in that is signed in (the default and every profile an agent uses) and
|
|
20618
|
+
* not read in the last five minutes. It never waits and never blocks a request: the list shows what is already known, and the pages are told to
|
|
20619
|
+
* read it again when something new was learned. A sign-in already being read is not read twice, and a read that began before the accounts were
|
|
20620
|
+
* forgotten (a sign-in finished meanwhile) is dropped. No login, no network request of ours, nothing logged.
|
|
20621
|
+
*/
|
|
20622
|
+
refreshSignInIdentities() {
|
|
20623
|
+
const now = Date.now(), fresh = (target) => { const entry = this.signInIdentities.get(`${target.backend}\0${target.profile ?? ""}`); return !!entry && now - entry.at < 5 * 60_000; };
|
|
20624
|
+
const started = [];
|
|
20625
|
+
for (const target of this.backendSignInTargets()) {
|
|
20626
|
+
const key = `${target.backend}\0${target.profile ?? ""}`;
|
|
20627
|
+
if (target.state !== "usable" || !authIdentitySupported(target.backend) || fresh(target) || this.signInIdentityReads.has(key))
|
|
20628
|
+
continue;
|
|
20629
|
+
const generation = this.signInIdentityGeneration;
|
|
20630
|
+
const read = this.withSignInIdentitySlot(() => this.readSignInIdentity(target)).then(identity => {
|
|
20631
|
+
if (generation !== this.signInIdentityGeneration)
|
|
20632
|
+
return false; // forgotten while it ran: its answer may be the old account
|
|
20633
|
+
this.signInIdentities.set(key, { identity: identity ?? null, at: Date.now() });
|
|
20634
|
+
return true;
|
|
20635
|
+
}).catch(() => {
|
|
20636
|
+
// A read that threw is an answer too: remembered as "no account" for the same five minutes, so every GET does not try again.
|
|
20637
|
+
if (generation === this.signInIdentityGeneration)
|
|
20638
|
+
this.signInIdentities.set(key, { identity: null, at: Date.now() });
|
|
20639
|
+
return false;
|
|
20640
|
+
}).finally(() => { if (this.signInIdentityReads.get(key) === read)
|
|
20641
|
+
this.signInIdentityReads.delete(key); });
|
|
20642
|
+
this.signInIdentityReads.set(key, read);
|
|
20643
|
+
started.push(read);
|
|
20644
|
+
}
|
|
20645
|
+
if (started.length)
|
|
20646
|
+
void Promise.all(started).then(results => {
|
|
20647
|
+
if (results.some(Boolean))
|
|
20648
|
+
broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed")); // read the list again: it knows more now
|
|
20649
|
+
});
|
|
20650
|
+
}
|
|
20651
|
+
/**
|
|
20652
|
+
* #3212 PR 1: the Accounts view (accounts-view.ts) — every CLI's default sign-in and named profiles (used or only on
|
|
20653
|
+
* disk), who uses each and its weekly usage. Host rows only; a paired computer's rows come with #3190 Part 3c. Its
|
|
20654
|
+
* usage is the usage panel's cached read (never forced), given at most `usageWaitMs` before the view is sent without it.
|
|
20655
|
+
*/
|
|
20656
|
+
async accountsView(usageWaitMs = 1500) {
|
|
20657
|
+
this.refreshSignInIdentities();
|
|
20658
|
+
const targets = this.backendSignInTargets();
|
|
20659
|
+
const diskProfiles = new Map();
|
|
20660
|
+
for (const backend of PROFILE_CLIS) {
|
|
20661
|
+
const rows = [];
|
|
20662
|
+
for (const profile of profilesOnDisk(this.dataDir, backend)) {
|
|
20663
|
+
let login = "unknown";
|
|
20664
|
+
try {
|
|
20665
|
+
login = credentialProfileLogin(this.dataDir, backend, profile).state;
|
|
20666
|
+
}
|
|
20667
|
+
catch { /* unknown */ }
|
|
20668
|
+
const signIn = dashboardSignInSupported(backend, profile);
|
|
20669
|
+
const hostCommand = signIn ? null : credentialProfileLoginCommand(this.dataDir, backend, profile);
|
|
20670
|
+
const identity = this.signInIdentity(backend, profile);
|
|
20671
|
+
rows.push({ profile, state: (login === "logged-in" ? "usable" : login === "signed-out" ? "not_signed_in" : "unknown"), signIn,
|
|
20672
|
+
...(hostCommand ? { hostCommand } : {}), ...(identity ? { identity } : {}) });
|
|
20673
|
+
}
|
|
20674
|
+
diskProfiles.set(backend, rows);
|
|
20675
|
+
}
|
|
20676
|
+
const { agents, classic, fleetDefaults } = this.accountUses();
|
|
20677
|
+
// Weekly usage, from the usage panel's own (cached, never forced) read.
|
|
20678
|
+
const usage = new Map();
|
|
20679
|
+
const ids = new Map(); // provider id → backend\0profile
|
|
20680
|
+
for (const backend of ACCOUNT_CLIS) {
|
|
20681
|
+
const pid = usageProviderIdForBackend(backend);
|
|
20682
|
+
if (!pid)
|
|
20683
|
+
continue;
|
|
20684
|
+
ids.set(pid, `${backend}\0`);
|
|
20685
|
+
for (const p of new Set([...(diskProfiles.get(backend) ?? []).map(d => d.profile), ...targets.filter(t => t.backend === backend && t.profile).map(t => t.profile)]))
|
|
20686
|
+
ids.set(`${pid}:${p}`, `${backend}\0${p}`);
|
|
20687
|
+
}
|
|
20688
|
+
try {
|
|
20689
|
+
const payload = await Promise.race([getUsageSnapshot(false, undefined, { allowStale: true }), new Promise(r => { const tm = setTimeout(() => r(null), usageWaitMs); tm.unref?.(); })]);
|
|
20690
|
+
for (const provider of payload?.providers ?? []) {
|
|
20691
|
+
const at = ids.get(provider.id);
|
|
20692
|
+
const w = at ? weeklyUsage(provider) : undefined;
|
|
20693
|
+
if (at && w)
|
|
20694
|
+
usage.set(at, w);
|
|
20695
|
+
}
|
|
20696
|
+
}
|
|
20697
|
+
catch { /* the view without usage */ }
|
|
20698
|
+
// #3292: each Claude Code / Codex row's "Keep sign-in alive" part (the setting, its last run, the dates its file says).
|
|
20699
|
+
const keepAlive = new Map();
|
|
20700
|
+
const ka = this.keepAliveService();
|
|
20701
|
+
for (const backend of ACCOUNT_CLIS) {
|
|
20702
|
+
if (!isKeepAliveBackend(backend))
|
|
20703
|
+
continue;
|
|
20704
|
+
for (const profile of [null, ...new Set([...(diskProfiles.get(backend) ?? []).map(d => d.profile), ...targets.filter(t => t.backend === backend && t.profile).map(t => t.profile)])]) {
|
|
20705
|
+
const v = ka.view(backend, profile);
|
|
20706
|
+
if (v)
|
|
20707
|
+
keepAlive.set(`${backend}\0${profile ?? ""}`, v);
|
|
20708
|
+
}
|
|
20709
|
+
}
|
|
20710
|
+
// #3190 Part 3c: each paired computer's accounts, as rows under the `machine` scope. Read from what the computers reported; the view never waits long for one.
|
|
20711
|
+
// (Keep-alive is the host's: it is built from the host's profiles above and never given to a computer's rows.)
|
|
20712
|
+
let machines = [];
|
|
20713
|
+
if (remoteRuntimeEnabled()) {
|
|
20714
|
+
try {
|
|
20715
|
+
machines = await this.machineAccounts.list();
|
|
20716
|
+
}
|
|
20717
|
+
catch (err) {
|
|
20718
|
+
this.logger.debug({ err: err.message }, "Computer accounts not read");
|
|
20719
|
+
}
|
|
20720
|
+
}
|
|
20721
|
+
return buildAccountsView({ targets, diskProfiles, agents, classic, fleetDefaults, usage, keepAlive, machines });
|
|
20722
|
+
}
|
|
20723
|
+
/** #3292: the keep-alive service (built on first use, so the Accounts view can read settings before startup finishes). */
|
|
20724
|
+
keepAliveService() {
|
|
20725
|
+
return this.signInKeepAlive ??= new SignInKeepAlive({
|
|
20726
|
+
dataDir: this.dataDir,
|
|
20727
|
+
log: (level, msg, fields) => this.logger[level](fields, msg),
|
|
20728
|
+
homeOf: (backend, profile) => profile ? credentialProfileHome(this.dataDir, backend, profile) : credentialHomeSpec(backend)?.sharedRoot() ?? null,
|
|
20729
|
+
acquire: (backend, profile) => this.acquireKeepAliveRun(backend, profile),
|
|
20730
|
+
changed: () => {
|
|
20731
|
+
this.needsYou?.poke();
|
|
20732
|
+
// #3313 review P2-7: the Accounts view reads itself again on `backend_login` (no details: each page reads its own
|
|
20733
|
+
// view). That event, not a new one: a tab whose cached shell predates this still passes it on.
|
|
20734
|
+
broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
|
|
20735
|
+
},
|
|
20736
|
+
claudeKeychain: process.platform === "darwin",
|
|
20737
|
+
});
|
|
20738
|
+
}
|
|
20739
|
+
startSignInKeepAlive() { this.keepAliveService().start(); }
|
|
20740
|
+
/**
|
|
20741
|
+
* #3292 review: which sign-in each host agent is starting or running on, recorded at its start (InstanceLifecycle
|
|
20742
|
+
* admitCredentialUse) from the configuration it launched with — never re-resolved against today's defaults. An entry
|
|
20743
|
+
* whose start ended without a daemon, or whose daemon is gone, is dropped when next read.
|
|
20744
|
+
*/
|
|
20745
|
+
credentialLeases = new Map();
|
|
20746
|
+
/** #3292 review: Keep sign-in alive runs in flight, by sign-in: a start on that sign-in waits for its end. */
|
|
20747
|
+
keepAliveRenewing = new Map();
|
|
20748
|
+
credentialKey(backend, profile) { return `${backend}\0${(profile ?? "").toLowerCase()}`; }
|
|
20749
|
+
/**
|
|
20750
|
+
* The sign-in a start launches on, from the instance's own (defaults-expanded at load) options — exactly what the
|
|
20751
|
+
* Daemon's clone of that config hands its CLI. Never today's defaults: an older config object keeps its own.
|
|
20752
|
+
*/
|
|
20753
|
+
launchCredentialKey(config, backend) {
|
|
20754
|
+
let profile = null;
|
|
20755
|
+
try {
|
|
20756
|
+
profile = resolveCredentialProfile(config.backend_options?.[backend]);
|
|
20757
|
+
}
|
|
20758
|
+
catch {
|
|
20759
|
+
profile = null;
|
|
20760
|
+
}
|
|
20761
|
+
return this.credentialKey(backend, profile);
|
|
20762
|
+
}
|
|
20763
|
+
/**
|
|
20764
|
+
* #3313 review r2: failed starts whose CLI was not proven gone keep holding their sign-in (across a retry of the same
|
|
20765
|
+
* agent too) until a check finds it ended.
|
|
20766
|
+
*/
|
|
20767
|
+
credentialOrphans = new Map();
|
|
20768
|
+
orphanCheck = null;
|
|
20769
|
+
recheckCredentialOrphans() {
|
|
20770
|
+
if (this.orphanCheck || !this.credentialOrphans.size)
|
|
20771
|
+
return;
|
|
20772
|
+
this.orphanCheck = (async () => {
|
|
20773
|
+
for (const [id, o] of [...this.credentialOrphans]) {
|
|
20774
|
+
let gone = false;
|
|
20775
|
+
try {
|
|
20776
|
+
gone = await o.ended();
|
|
20777
|
+
}
|
|
20778
|
+
catch {
|
|
20779
|
+
gone = false;
|
|
20780
|
+
}
|
|
20781
|
+
if (gone)
|
|
20782
|
+
this.credentialOrphans.delete(id);
|
|
20783
|
+
}
|
|
20784
|
+
})().finally(() => { this.orphanCheck = null; });
|
|
20785
|
+
}
|
|
20786
|
+
/**
|
|
20787
|
+
* LifecycleContext: hold the sign-in a start will launch on (waits while Keep sign-in alive renews it). The key is
|
|
20788
|
+
* read again after every wait; `current(config)` lets the start check, with no await before it builds its Daemon,
|
|
20789
|
+
* that the config still names that sign-in (a save may have changed it meanwhile: then it asks again).
|
|
20790
|
+
*/
|
|
20791
|
+
async admitCredentialUse(name, config, backend, assertCurrent) {
|
|
20792
|
+
if (!isKeepAliveBackend(backend) || isWindowsInstance(config))
|
|
20793
|
+
return null;
|
|
20794
|
+
let key = this.launchCredentialKey(config, backend);
|
|
20795
|
+
for (let renewing = this.keepAliveRenewing.get(key); renewing; renewing = this.keepAliveRenewing.get(key)) {
|
|
20796
|
+
await renewing;
|
|
20797
|
+
assertCurrent();
|
|
20798
|
+
key = this.launchCredentialKey(config, backend);
|
|
20799
|
+
}
|
|
20800
|
+
const lease = { key, starting: true };
|
|
20801
|
+
this.credentialLeases.set(name, lease);
|
|
20802
|
+
const drop = () => { if (this.credentialLeases.get(name) === lease)
|
|
20803
|
+
this.credentialLeases.delete(name); };
|
|
20804
|
+
return {
|
|
20805
|
+
published: () => { lease.starting = false; },
|
|
20806
|
+
release: drop,
|
|
20807
|
+
current: c => this.launchCredentialKey(c, backend) === key,
|
|
20808
|
+
// A failed start whose CLI may still run: the sign-in stays held (by itself, not by the agent's name) until it is seen gone.
|
|
20809
|
+
unknownEnd: ended => { drop(); this.credentialOrphans.set(Symbol(name), { key, ended }); this.recheckCredentialOrphans(); },
|
|
20810
|
+
};
|
|
20811
|
+
}
|
|
20812
|
+
/**
|
|
20813
|
+
* #3292: a sign-in is in use when a host agent is starting or running on it (as launched), a ClassicBot room is bound
|
|
20814
|
+
* to it (or the rooms cannot be read — none when there is no classicBot.yaml), or a sign-in for it is running. Codex
|
|
20815
|
+
* refresh tokens are single-use: a refresh beside a live user could spend the one it holds; and use keeps it alive.
|
|
20816
|
+
*/
|
|
20817
|
+
keepAliveInUse(backend, profile) {
|
|
20818
|
+
const key = this.credentialKey(backend, profile);
|
|
20819
|
+
for (const o of this.credentialOrphans.values())
|
|
20820
|
+
if (o.key === key) {
|
|
20821
|
+
this.recheckCredentialOrphans();
|
|
20822
|
+
return true;
|
|
20823
|
+
}
|
|
20824
|
+
for (const [name, lease] of [...this.credentialLeases]) {
|
|
20825
|
+
if (!lease.starting && !this.daemons?.has(name)) {
|
|
20826
|
+
this.credentialLeases.delete(name);
|
|
20827
|
+
continue;
|
|
20828
|
+
}
|
|
20829
|
+
if (lease.key === key)
|
|
20830
|
+
return true;
|
|
20831
|
+
}
|
|
20832
|
+
const same = (p) => profile === null ? !p : !!p && p.toLowerCase() === profile.toLowerCase();
|
|
20833
|
+
const defaults = this.fleetConfig?.defaults, defaultBackend = defaults?.backend ?? "claude-code";
|
|
20834
|
+
// A running agent with no record (started some other way): only its own setting is trusted; none names an account, so it may be on any.
|
|
20835
|
+
for (const [name, daemon] of this.daemons ?? []) {
|
|
20836
|
+
if (this.credentialLeases.has(name))
|
|
20837
|
+
continue;
|
|
20838
|
+
let snap;
|
|
20839
|
+
try {
|
|
20840
|
+
snap = daemon.getConfigSnapshot?.();
|
|
20841
|
+
}
|
|
20842
|
+
catch {
|
|
20843
|
+
snap = undefined;
|
|
20844
|
+
}
|
|
20845
|
+
if (snap && isWindowsInstance(snap))
|
|
20846
|
+
continue;
|
|
20847
|
+
if (!snap)
|
|
20848
|
+
return true;
|
|
20849
|
+
if ((snap.backend ?? defaultBackend) !== backend)
|
|
20850
|
+
continue;
|
|
20851
|
+
let own = null;
|
|
20852
|
+
try {
|
|
20853
|
+
own = resolveCredentialProfile(snap.backend_options?.[backend]);
|
|
20854
|
+
}
|
|
20855
|
+
catch {
|
|
20856
|
+
return true;
|
|
20857
|
+
}
|
|
20858
|
+
if (!own || same(own))
|
|
20859
|
+
return true;
|
|
20860
|
+
}
|
|
20861
|
+
const rooms = readClassicBindingsStrict(this.dataDir);
|
|
20862
|
+
if (rooms.kind === "unknown")
|
|
20863
|
+
return true;
|
|
20864
|
+
for (const b of rooms.kind === "ok" ? rooms.bindings : []) {
|
|
20865
|
+
const cli = b.backend ?? defaultBackend;
|
|
20866
|
+
if (cli === backend && same(profileName(classicProfile(b.backend_options, defaults?.backend_options, cli))))
|
|
20867
|
+
return true;
|
|
20868
|
+
}
|
|
20869
|
+
return this.loginController?.signingIn(backend, profile) ?? false;
|
|
20870
|
+
}
|
|
20871
|
+
/**
|
|
20872
|
+
* #3292 review: one keep-alive run's admission, decided synchronously: not in use, the shared login window taken, and the
|
|
20873
|
+
* sign-in marked as renewing (a start on it waits). The run's life is an account writer: a stop waits for it, and
|
|
20874
|
+
* sign-in admission reopens after a restart only once it has ended. `release()` only after its CLI has exited.
|
|
20875
|
+
*/
|
|
20876
|
+
acquireKeepAliveRun(backend, profile) {
|
|
20877
|
+
if (this.keepAliveInUse(backend, profile))
|
|
20878
|
+
return "in_use";
|
|
20879
|
+
const claim = this.loginWindow.tryClaim("keepalive", backend);
|
|
20880
|
+
if (!claim)
|
|
20881
|
+
return "busy";
|
|
20882
|
+
const key = this.credentialKey(backend, profile);
|
|
20883
|
+
let finished;
|
|
20884
|
+
const life = new Promise(r => { finished = r; });
|
|
20885
|
+
this.keepAliveRenewing.set(key, life);
|
|
20886
|
+
this.accountWriters.add(life);
|
|
20887
|
+
let released = false;
|
|
20888
|
+
return {
|
|
20889
|
+
release: () => {
|
|
20890
|
+
if (released)
|
|
20891
|
+
return;
|
|
20892
|
+
released = true;
|
|
20893
|
+
this.loginWindow.release(claim);
|
|
20894
|
+
if (this.keepAliveRenewing.get(key) === life)
|
|
20895
|
+
this.keepAliveRenewing.delete(key);
|
|
20896
|
+
this.accountWriters.delete(life);
|
|
20897
|
+
finished();
|
|
20898
|
+
},
|
|
20899
|
+
};
|
|
20900
|
+
}
|
|
20901
|
+
/** #3292: Needs you's lines for kept sign-ins, in the fleet's language (posted in General's world, like config issues). */
|
|
20902
|
+
keepAliveAttention() {
|
|
20903
|
+
const ka = this.signInKeepAlive;
|
|
20904
|
+
if (!ka)
|
|
20905
|
+
return [];
|
|
20906
|
+
const day = (ms) => ms === undefined ? "?" : new Date(ms).toISOString().slice(0, 10);
|
|
20907
|
+
const owner = this.worlds.keys().next().value;
|
|
20908
|
+
return ka.attention().map(a => ({
|
|
20909
|
+
backend: a.backend, profile: a.profile, kind: a.kind, since: a.since, signIn: dashboardSignInSupported(a.backend, a.profile),
|
|
20910
|
+
...(owner ? { owner } : {}),
|
|
20911
|
+
detail: t(`keepalive.${a.kind}`, BACKEND_LABELS[a.backend] ?? a.backend, a.profile ?? t("keepalive.default_name"), day(a.kind === "transient" ? a.failedSince ?? a.since : a.endsAt)),
|
|
20912
|
+
}));
|
|
20913
|
+
}
|
|
20914
|
+
/** #3292: Settings → Accounts → Keep sign-in alive (POST /ui/accounts/keep-alive). `by`: the session's label, for the fleet log. */
|
|
20915
|
+
setAccountKeepAlive(backend, profile, enabled, fallback, by) {
|
|
20916
|
+
const r = this.keepAliveService().set(backend, profile, enabled, fallback);
|
|
20917
|
+
if (r.ok)
|
|
20918
|
+
this.logger.info({ backend, profile: profile ?? "(default)", enabled, by }, "Keep sign-in alive changed from Settings → Accounts");
|
|
20919
|
+
return r;
|
|
20920
|
+
}
|
|
20921
|
+
/**
|
|
20922
|
+
* Who uses which account: host agents (an agent on a paired Windows computer runs on that computer's accounts — its
|
|
20923
|
+
* own scope), ClassicBot rooms and the fleet default per CLI, each with its effective profile (null: the default sign-in).
|
|
20924
|
+
*/
|
|
20925
|
+
accountUses() {
|
|
20926
|
+
const fleet = this.fleetConfig;
|
|
20927
|
+
const defaultBackend = fleet?.defaults?.backend ?? "claude-code";
|
|
20928
|
+
const agents = Object.keys(fleet?.instances ?? {}).filter(name => !isWindowsInstance(fleet.instances[name])).sort()
|
|
20929
|
+
.map(name => { const backend = this.backendNameForInstance(name); return { name, backend, profile: this.credentialProfileOf(name, backend) }; });
|
|
20930
|
+
const classic = readClassicBindings(this.dataDir).map(b => {
|
|
20931
|
+
const backend = b.backend ?? defaultBackend;
|
|
20932
|
+
return { key: b.key, backend, profile: profileName(classicProfile(b.backend_options, fleet?.defaults?.backend_options, backend)) };
|
|
20933
|
+
});
|
|
20934
|
+
const fleetDefaults = new Map();
|
|
20935
|
+
for (const backend of PROFILE_CLIS) {
|
|
20936
|
+
const p = profileName(profileOf(fleet?.defaults?.backend_options, backend));
|
|
20937
|
+
if (p)
|
|
20938
|
+
fleetDefaults.set(backend, p);
|
|
20939
|
+
}
|
|
20940
|
+
return { agents, classic, fleetDefaults };
|
|
20941
|
+
}
|
|
20942
|
+
/** #3212 PR 2: Settings → Accounts → + Add account (accounts-profiles.ts). `by`: the session's label, for the fleet log. */
|
|
20943
|
+
addAccountProfile(backend, name, by, machine) {
|
|
20944
|
+
// #3190 Part 3c: on a paired computer the profile's folder is made by its Runtime when the first sign-in starts; this only checks what can be checked first.
|
|
20945
|
+
if (machine)
|
|
20946
|
+
return this.machineAccounts.add(backend, name, machine.id, by);
|
|
20947
|
+
const { agents, classic, fleetDefaults } = this.accountUses();
|
|
20948
|
+
const configured = new Set();
|
|
20949
|
+
for (const x of [...agents, ...classic])
|
|
20950
|
+
if (x.backend === backend && x.profile)
|
|
20951
|
+
configured.add(x.profile);
|
|
20952
|
+
const fd = fleetDefaults.get(backend);
|
|
20953
|
+
if (fd)
|
|
20954
|
+
configured.add(fd);
|
|
20955
|
+
const result = addAccountProfile(this.dataDir, backend, name, configured);
|
|
20956
|
+
if (result.ok)
|
|
20957
|
+
this.logger.info({ backend, profile: name, by }, "Credential profile added from Settings → Accounts");
|
|
20958
|
+
return result;
|
|
20959
|
+
}
|
|
20960
|
+
/**
|
|
20961
|
+
* #3212 PR 2: Settings → Accounts → Remove. Refused while anything uses it or a sign-in for it runs (the login controller,
|
|
20962
|
+
* or the login window held for this backend by a sign-in whose profile is not known yet); see accounts-profiles.ts.
|
|
20963
|
+
* The fleet log records who removed which backend's profile — never what was in it.
|
|
20964
|
+
*/
|
|
20965
|
+
async removeAccountProfile(backend, name, confirm, by, machine) {
|
|
20966
|
+
if (machine)
|
|
20967
|
+
return this.machineAccounts.remove(backend, name, confirm, machine.id, machine, by); // #3190 Part 3c: that computer's Runtime deletes its own folder
|
|
20968
|
+
const profile = typeof name === "string" ? name : "";
|
|
20969
|
+
const shown = validCredentialProfileName(name) ? name : "(invalid)";
|
|
20970
|
+
const refused = (r) => { if (!r.ok)
|
|
20971
|
+
this.logger.info({ backend, profile: shown, by, refused: r.error }, "Credential profile removal refused"); return r; };
|
|
20972
|
+
// #3212 PR 3: on macOS, Claude Code keeps the account's token in the Keychain, outside the folder — its own logout
|
|
20973
|
+
// (run with the folder, once every Remove check has passed) removes that item first. AgEnD never deletes it itself.
|
|
20974
|
+
// #3305 review: the logout holds the shared login window (no sign-in or other logout starts meanwhile), and after it
|
|
20975
|
+
// every check is made again — who uses it, sign-ins, ClassicBot's settings — on the same folder (its identity).
|
|
20976
|
+
const signOutDeps = this.accountSignOutDeps ?? ACCOUNT_SIGN_OUT_DEPS;
|
|
20977
|
+
let keychainLeft = false;
|
|
20978
|
+
let removed;
|
|
20979
|
+
if (backend === "claude-code" && signOutDeps.platform === "darwin") {
|
|
20980
|
+
const dry = removeAccountProfile(this.dataDir, this.removalRequest(backend, name, confirm, null), undefined, { dryRun: true });
|
|
20981
|
+
if (!dry.ok)
|
|
20982
|
+
return refused(dry);
|
|
20983
|
+
const claim = this.loginWindow.tryClaim("web", backend);
|
|
20984
|
+
if (!claim)
|
|
20985
|
+
return refused({ ok: false, error: "signing_in" });
|
|
20986
|
+
const step = await this.withAccountWriter(claim, async (deps) => {
|
|
20987
|
+
const out = await signOutAccount(this.dataDir, { backend, profile, confirm: true, signingIn: false }, deps);
|
|
20988
|
+
if (!out.ok)
|
|
20989
|
+
return { ok: false, error: out.error === "unsafe" ? "unsafe" : "failed" };
|
|
20990
|
+
if (!this.loginWindow.isCurrent(claim))
|
|
20991
|
+
return { ok: false, error: "failed" }; // the fleet is stopping
|
|
20992
|
+
keychainLeft = out.keychainLeft === true;
|
|
20993
|
+
return removeAccountProfile(this.dataDir, this.removalRequest(backend, name, confirm, claim), undefined, { expect: dry.identity });
|
|
20994
|
+
});
|
|
20995
|
+
if (!step.ok)
|
|
20996
|
+
return refused(step);
|
|
20997
|
+
removed = step;
|
|
20998
|
+
}
|
|
20999
|
+
else
|
|
21000
|
+
removed = removeAccountProfile(this.dataDir, this.removalRequest(backend, name, confirm, null));
|
|
21001
|
+
if (!removed.ok)
|
|
21002
|
+
return refused(removed);
|
|
21003
|
+
this.logger.info({ backend, profile, by, ...(keychainLeft ? { keychainLeft } : {}) }, "Credential profile removed from Settings → Accounts");
|
|
21004
|
+
return keychainLeft ? { ok: true, keychainLeft: true } : { ok: true };
|
|
21005
|
+
}
|
|
21006
|
+
/**
|
|
21007
|
+
* Remove's whole safety proof, read now (#3291 review): who uses the account — configured agents and live daemons, the
|
|
21008
|
+
* fleet default, ClassicBot rooms read strictly — and whether a sign-in for it runs. `ownClaim`: the login window this
|
|
21009
|
+
* removal holds itself, which is not someone else's sign-in.
|
|
21010
|
+
*/
|
|
21011
|
+
removalRequest(backend, name, confirm, ownClaim) {
|
|
21012
|
+
const profile = typeof name === "string" ? name : "";
|
|
21013
|
+
// #3291 review (Prism P2-3): one folder on a case-insensitive disk (Windows, default macOS) — `Work` and `work` are the
|
|
21014
|
+
// same account for every safety check here.
|
|
21015
|
+
const same = (p) => !!p && p.toLowerCase() === profile.toLowerCase();
|
|
21016
|
+
const { agents, fleetDefaults } = this.accountUses();
|
|
21017
|
+
const defaultBackend = this.fleetConfig?.defaults?.backend ?? "claude-code";
|
|
21018
|
+
// #3291 review (Prism P2-2): ClassicBot rooms read strictly — an unreadable or malformed classicBot.yaml is not "no rooms".
|
|
21019
|
+
const rooms = readClassicBindingsStrict(this.dataDir);
|
|
21020
|
+
const classic = rooms.kind === "ok" ? rooms.bindings.map(b => {
|
|
21021
|
+
const cli = b.backend ?? defaultBackend;
|
|
21022
|
+
return { key: b.key, backend: cli, profile: profileName(classicProfile(b.backend_options, this.fleetConfig?.defaults?.backend_options, cli)) };
|
|
21023
|
+
}) : [];
|
|
21024
|
+
// #3291 review (Prism P2-1): what a running CLI was launched with. An agent or room moved off this account keeps
|
|
21025
|
+
// running on it until its process stops (the configuration changes first): it is still a user until then.
|
|
21026
|
+
const live = [];
|
|
21027
|
+
for (const [instance, daemon] of this.daemons ?? []) {
|
|
21028
|
+
let snap;
|
|
21029
|
+
try {
|
|
21030
|
+
snap = daemon.getConfigSnapshot?.();
|
|
21031
|
+
}
|
|
21032
|
+
catch {
|
|
21033
|
+
snap = undefined;
|
|
21034
|
+
}
|
|
21035
|
+
if (!snap || isWindowsInstance(snap))
|
|
21036
|
+
continue;
|
|
21037
|
+
const cli = snap.backend ?? defaultBackend;
|
|
21038
|
+
if (cli !== backend)
|
|
21039
|
+
continue;
|
|
21040
|
+
let launched = null;
|
|
21041
|
+
try {
|
|
21042
|
+
launched = resolveCredentialProfile(snap.backend_options?.[cli]);
|
|
21043
|
+
}
|
|
21044
|
+
catch {
|
|
21045
|
+
launched = null;
|
|
21046
|
+
}
|
|
21047
|
+
if (same(launched))
|
|
21048
|
+
live.push(instance);
|
|
21049
|
+
}
|
|
21050
|
+
const users = {
|
|
21051
|
+
agents: [...new Set([...agents.filter(a => a.backend === backend && same(a.profile)).map(a => a.name), ...live])].sort(),
|
|
21052
|
+
classic: classic.filter(c => c.backend === backend && same(c.profile)).map(c => c.key),
|
|
21053
|
+
fleetDefault: same(fleetDefaults.get(backend)),
|
|
21054
|
+
};
|
|
21055
|
+
const held = this.loginWindow.current;
|
|
21056
|
+
const signingIn = (this.loginController?.signingIn(backend, profile) ?? false)
|
|
21057
|
+
|| (!!held && held !== ownClaim && held.backend === backend && !this.loginController?.activeBackend);
|
|
21058
|
+
return { backend, name, confirm, users, signingIn, usersUnknown: rooms.kind === "unknown" };
|
|
21059
|
+
}
|
|
21060
|
+
/**
|
|
21061
|
+
* #3212 PR 3: Settings → Accounts → Sign out (accounts-signout.ts): the CLI's own logout for the default sign-in
|
|
21062
|
+
* (`profile` null) or a named account. Refused while a sign-in for it runs (case-insensitive, as Remove). The fleet
|
|
21063
|
+
* log records who signed out which backend's account; then every page reads the sign-ins again.
|
|
21064
|
+
*/
|
|
21065
|
+
/** How a CLI's logout is run and the Keychain asked (a test's stand-in; the platform with it). */
|
|
21066
|
+
accountSignOutDeps = ACCOUNT_SIGN_OUT_DEPS;
|
|
21067
|
+
/** #3305 review: every account logout's whole life — its CLI children until positively gone (shutdown drains them). */
|
|
21068
|
+
accountWriters = new Set();
|
|
21069
|
+
/**
|
|
21070
|
+
* #3305 review P2-3/P2-5: run `work` as the owner of the credential writer (`claim`). Its CLIs run through a runner
|
|
21071
|
+
* that records each child's positive end; the work is told whether it still owns the writer (`stillOwner`) before it
|
|
21072
|
+
* cleans anything; and the claim is released only once every child it started is positively gone — a child whose end
|
|
21073
|
+
* is unknown keeps sign-in admission closed (logged). Shutdown waits for these (shutdownLoginWindows), and a restart
|
|
21074
|
+
* reopens admission only after they are gone.
|
|
21075
|
+
*/
|
|
21076
|
+
async withAccountWriter(claim, work) {
|
|
21077
|
+
const base = this.accountSignOutDeps ?? ACCOUNT_SIGN_OUT_DEPS;
|
|
21078
|
+
const children = [];
|
|
21079
|
+
const watch = async (r) => { if (r.gone)
|
|
21080
|
+
children.push(r.gone); return r; };
|
|
21081
|
+
const deps = {
|
|
21082
|
+
platform: base.platform,
|
|
21083
|
+
run: async (b, a, e) => watch(await base.run(b, a, e)),
|
|
21084
|
+
keychainHas: base.keychainHas,
|
|
21085
|
+
stillOwner: () => this.loginWindow.isCurrent(claim),
|
|
21086
|
+
};
|
|
21087
|
+
let finished;
|
|
21088
|
+
const life = new Promise(r => { finished = r; });
|
|
21089
|
+
this.accountWriters.add(life);
|
|
21090
|
+
try {
|
|
21091
|
+
return await work(deps);
|
|
21092
|
+
}
|
|
21093
|
+
finally {
|
|
21094
|
+
const settle = () => { this.loginWindow.release(claim); this.accountWriters.delete(life); finished(); };
|
|
21095
|
+
if (!children.length)
|
|
21096
|
+
settle();
|
|
21097
|
+
else {
|
|
21098
|
+
let warned = false;
|
|
21099
|
+
const t = setTimeout(() => { warned = true; this.logger.error("An account logout's CLI has not ended: sign-in stays closed until it does"); }, 30_000);
|
|
21100
|
+
t.unref?.();
|
|
21101
|
+
void Promise.all(children).then(() => { clearTimeout(t); if (warned)
|
|
21102
|
+
this.logger.info("The account logout's CLI ended: sign-in is open again"); settle(); });
|
|
21103
|
+
}
|
|
21104
|
+
}
|
|
21105
|
+
}
|
|
21106
|
+
async signOutAccount(backend, profile, confirm, by, machine) {
|
|
21107
|
+
if (machine)
|
|
21108
|
+
return this.machineAccounts.signOut(backend, profile, confirm, machine.id, machine, by); // #3190 Part 3c: that computer's Runtime runs the CLI's own logout
|
|
21109
|
+
const named = typeof profile === "string" ? profile : null;
|
|
21110
|
+
const shown = named === null ? "(default)" : validCredentialProfileName(named) ? named : "(invalid)";
|
|
21111
|
+
// #3305 review P2-3: the logout holds the shared login window from before it runs until its cleanup is done — no
|
|
21112
|
+
// sign-in (chat, dashboard, install) and no other logout starts meanwhile; one already running refuses this.
|
|
21113
|
+
const signingIn = this.loginController?.signingIn(backend, named) ?? false;
|
|
21114
|
+
const claim = signingIn ? null : this.loginWindow.tryClaim("web", backend);
|
|
21115
|
+
let result;
|
|
21116
|
+
if (!claim)
|
|
21117
|
+
result = { ok: false, error: "signing_in" };
|
|
21118
|
+
else
|
|
21119
|
+
result = await this.withAccountWriter(claim, deps => signOutAccount(this.dataDir, { backend, profile: profile ?? null, confirm, signingIn: false }, deps));
|
|
21120
|
+
if (result.ok) {
|
|
21121
|
+
this.logger.info({ backend, profile: shown, by, ...(result.keychainLeft ? { keychainLeft: true } : {}) }, "Account signed out from Settings → Accounts");
|
|
21122
|
+
this.forgetSignInIdentities();
|
|
21123
|
+
void this.backendAvailability.refresh([backend], { force: true }).catch(() => { });
|
|
21124
|
+
broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
|
|
21125
|
+
}
|
|
21126
|
+
else
|
|
21127
|
+
this.logger.info({ backend, profile: shown, by, refused: result.error }, "Account sign-out refused");
|
|
21128
|
+
return result;
|
|
21129
|
+
}
|
|
19276
21130
|
backendSignInTargets() {
|
|
19277
21131
|
const out = [];
|
|
19278
21132
|
for (const row of this.backendAvailabilityRows()) {
|
|
@@ -19284,6 +21138,7 @@ export class FleetManager {
|
|
|
19284
21138
|
...(flow?.remoteLogin === "unsupported" ? { hostCommand: flow.command } : {}),
|
|
19285
21139
|
...(row.state === "not_installed" && install ? { install } : {}),
|
|
19286
21140
|
...(row.state === "too_old" && install ? { update: install } : {}),
|
|
21141
|
+
...(this.signInIdentity(row.backend) ? { identity: this.signInIdentity(row.backend) } : {}),
|
|
19287
21142
|
});
|
|
19288
21143
|
}
|
|
19289
21144
|
const seen = new Set();
|
|
@@ -19301,7 +21156,7 @@ export class FleetManager {
|
|
|
19301
21156
|
const signIn = dashboardSignInSupported(backend, profile);
|
|
19302
21157
|
const hostCommand = signIn ? null : credentialProfileLoginCommand(this.dataDir, backend, profile);
|
|
19303
21158
|
out.push({ backend, profile, state: login === "logged-in" ? "usable" : login === "signed-out" ? "not_signed_in" : "unknown", signIn,
|
|
19304
|
-
...(hostCommand ? { hostCommand } : {}) });
|
|
21159
|
+
...(hostCommand ? { hostCommand } : {}), ...(this.signInIdentity(backend, profile) ? { identity: this.signInIdentity(backend, profile) } : {}) });
|
|
19305
21160
|
}
|
|
19306
21161
|
return out;
|
|
19307
21162
|
}
|
|
@@ -19576,11 +21431,32 @@ export class FleetManager {
|
|
|
19576
21431
|
return this.webLogin.start(backendArg, chat, opts);
|
|
19577
21432
|
}
|
|
19578
21433
|
/** Fleet shutdown: end any web login or install window and wait for its confirmed teardown. */
|
|
21434
|
+
/**
|
|
21435
|
+
* #3305 review P2-3: reopen sign-in admission after a restart — only once no account logout's CLI from before is still
|
|
21436
|
+
* alive (a fresh sign-in must never overlap it). Each reopen supersedes a deferred one.
|
|
21437
|
+
*/
|
|
21438
|
+
loginReopenGen = 0;
|
|
21439
|
+
reopenLoginWindow() {
|
|
21440
|
+
const gen = ++this.loginReopenGen;
|
|
21441
|
+
const pending = [...this.accountWriters];
|
|
21442
|
+
if (!pending.length) {
|
|
21443
|
+
this.loginWindow.reopen();
|
|
21444
|
+
return;
|
|
21445
|
+
}
|
|
21446
|
+
this.logger.warn({ pending: pending.length }, "Sign-in admission reopens once an account logout from before the restart has ended");
|
|
21447
|
+
void Promise.all(pending).then(() => { if (gen === this.loginReopenGen && !this.structuredLoginCleanupFailed)
|
|
21448
|
+
this.loginWindow.reopen(); });
|
|
21449
|
+
}
|
|
19579
21450
|
async shutdownLoginWindows() {
|
|
21451
|
+
// #3305 review: a newer stop supersedes a reopen still waiting for an old account logout's CLI.
|
|
21452
|
+
this.loginReopenGen++;
|
|
19580
21453
|
// Close the lock FIRST: in-flight starts parked in a pre-check or
|
|
19581
21454
|
// ensureSession observe !isCurrent when they resume and stop; no new
|
|
19582
21455
|
// window can be claimed while we stop.
|
|
19583
21456
|
this.loginWindow.close();
|
|
21457
|
+
// #3292 review: Keep sign-in alive stops asking for runs and stops its CLI; its run's life is an account writer,
|
|
21458
|
+
// waited for below like an account logout.
|
|
21459
|
+
void this.signInKeepAlive?.stop();
|
|
19584
21460
|
// Completion semantics live INSIDE the sessions: each awaits its own
|
|
19585
21461
|
// confirmed cleanup, every tmux op on that path has a hard per-op bound
|
|
19586
21462
|
// (web: abort ≤10 s + kill ≤31 s; legacy: create/list/kill ≤10 s each,
|
|
@@ -19617,8 +21493,17 @@ export class FleetManager {
|
|
|
19617
21493
|
this.logger.error("Structured login cleanup failed; sign-in admission remains closed until the host is restarted.");
|
|
19618
21494
|
}
|
|
19619
21495
|
}), "browser-controls"),
|
|
21496
|
+
// #3190 Part 3c: a sign-in running on a paired computer is ended (its Runtime also ends it when the connection goes). One that could not be shown gone is logged.
|
|
21497
|
+
bounded(this.machineSignInsInstance?.close().then(confirmed => {
|
|
21498
|
+
if (confirmed)
|
|
21499
|
+
this.machineSignInsInstance = null;
|
|
21500
|
+
else
|
|
21501
|
+
this.logger.error("A computer's account sign-in could not be confirmed ended; check that computer's Runtime window.");
|
|
21502
|
+
}), "machine-signins"),
|
|
19620
21503
|
bounded(this.loginController?.shutdown(), "web-login"),
|
|
19621
21504
|
bounded(this.activeInstall?.session.cancel("cancelled"), "install"),
|
|
21505
|
+
// #3305 review P2-3: an account logout in flight (its CLI) — the closed window fences its cleanup; this waits for it.
|
|
21506
|
+
bounded(this.accountWriters.size ? Promise.all([...this.accountWriters]).then(() => undefined) : undefined, "account-logout"),
|
|
19622
21507
|
]);
|
|
19623
21508
|
}
|
|
19624
21509
|
/** `/login cancel` — abort the active session and remove its window. */
|
|
@@ -19820,9 +21705,12 @@ export class FleetManager {
|
|
|
19820
21705
|
this.loginWindow.release(claim);
|
|
19821
21706
|
return t("login.web_shutting_down");
|
|
19822
21707
|
}
|
|
21708
|
+
// The wrapper says its own exit code after this marker: tmux may never record it (unattended-install.ts).
|
|
21709
|
+
const exitMarker = installExitMarker();
|
|
19823
21710
|
const flow = {
|
|
19824
21711
|
backend,
|
|
19825
|
-
command: unattendedInstallCommand(info.unattended ?? info.install, shell),
|
|
21712
|
+
command: unattendedInstallCommand(info.unattended ?? info.install, shell, exitMarker),
|
|
21713
|
+
exitMarker,
|
|
19826
21714
|
successPattern: /$^/,
|
|
19827
21715
|
timeoutMs: this.installTimeoutMs,
|
|
19828
21716
|
};
|
|
@@ -20123,6 +22011,8 @@ export class FleetManager {
|
|
|
20123
22011
|
this.needsYou?.poke();
|
|
20124
22012
|
const onError = (err) => this.logger.debug({ err }, "SSE client write failed; evicting");
|
|
20125
22013
|
if (event === "message" && data && typeof data === "object") {
|
|
22014
|
+
// #2861: an Office share's dialogue box hears that someone talked to an instance (never what was said).
|
|
22015
|
+
this.officeTalk.noteMessage(data);
|
|
20126
22016
|
// A chat message: record it, and send it WITH its id so a reconnecting stream can ask for what it missed.
|
|
20127
22017
|
const m = data;
|
|
20128
22018
|
const recorded = this.webChatHistory.record({
|
|
@@ -20167,9 +22057,12 @@ export class FleetManager {
|
|
|
20167
22057
|
this.taskBoardWaker?.stop();
|
|
20168
22058
|
// #2303: each instance's cards at once, read at every claim (a fleet.yaml edit applies to the next one).
|
|
20169
22059
|
db.board.setCardLimit((name) => boardCardLimit(this.fleetConfig, name));
|
|
22060
|
+
// An instance with the task board switched off is handed no cards and sent no notices (read at each write and wake).
|
|
22061
|
+
db.board.setBoardOff((name) => taskBoardOffIn(this.fleetConfig, name));
|
|
20170
22062
|
const waker = this.taskBoardWaker = new TaskBoardWaker({
|
|
20171
22063
|
deliver: (instance, message, key) => this.admitTaskBoardNotice(instance, message, key),
|
|
20172
22064
|
isInstance: (name) => this.fleetConfig?.instances?.[name] != null,
|
|
22065
|
+
boardOff: (name) => taskBoardOffIn(this.fleetConfig, name),
|
|
20173
22066
|
// #2785 (c), #2801: the maker's own message already told it; the board's line would repeat it.
|
|
20174
22067
|
messagedAbout: (from, to, codes, sinceMs) => {
|
|
20175
22068
|
const outbox = this.deliveryOutbox;
|
|
@@ -23129,6 +25022,7 @@ export class FleetManager {
|
|
|
23129
25022
|
...this.fleetConfig?.defaults,
|
|
23130
25023
|
working_directory: workDir,
|
|
23131
25024
|
lightweight: true,
|
|
25025
|
+
quota_notice: classicIdentity?.quotaNotice,
|
|
23132
25026
|
tool_progress: toolProgress ?? "off",
|
|
23133
25027
|
reply_completion_guard: replyCompletionGuard ?? true,
|
|
23134
25028
|
...(backend ? { backend } : {}),
|
|
@@ -23233,6 +25127,9 @@ export class FleetManager {
|
|
|
23233
25127
|
* settles, so a later genuine stop (after a restart) still does the work.
|
|
23234
25128
|
*/
|
|
23235
25129
|
stopAll() {
|
|
25130
|
+
// S-51: no new Hub admission, dispatch or listener work from this tick on; doStopAll awaits the close.
|
|
25131
|
+
this.hubEffectsReady = false;
|
|
25132
|
+
this.hubRuntime?.fence();
|
|
23236
25133
|
this.lifecycle.cancelNativeRecovery?.();
|
|
23237
25134
|
this.nativeMcpStore?.closeAll();
|
|
23238
25135
|
this.runtimeExecutor?.close();
|
|
@@ -23305,6 +25202,25 @@ export class FleetManager {
|
|
|
23305
25202
|
// because we asked it to. Set synchronously — doStopAll runs to its first
|
|
23306
25203
|
// await in the same tick as the signal handler, so no event can slip in.
|
|
23307
25204
|
this.shuttingDown = true;
|
|
25205
|
+
this.stopQuotaObserver?.();
|
|
25206
|
+
this.stopQuotaObserver = null;
|
|
25207
|
+
const quotaNoticesStopped = this.quotaNotices?.stop();
|
|
25208
|
+
// Stop receive admission before the first await or any instance shutdown; outbound
|
|
25209
|
+
// adapters remain available below to retire notices and pending prompts.
|
|
25210
|
+
for (const state of this.adapterState.values()) {
|
|
25211
|
+
if (state.retryTimer) {
|
|
25212
|
+
clearTimeout(state.retryTimer);
|
|
25213
|
+
state.retryTimer = undefined;
|
|
25214
|
+
}
|
|
25215
|
+
}
|
|
25216
|
+
const inboundStopped = Promise.all([...this.adapters.values()].map(async (adapter) => {
|
|
25217
|
+
try {
|
|
25218
|
+
await adapter.stopReceiving?.();
|
|
25219
|
+
}
|
|
25220
|
+
catch (err) {
|
|
25221
|
+
this.logger.warn({ adapterId: adapter.id, err }, "Adapter receive stop failed; inbound remains fenced");
|
|
25222
|
+
}
|
|
25223
|
+
}));
|
|
23308
25224
|
this.workingRecovery?.reset();
|
|
23309
25225
|
if (this.workingRecoveryTimer)
|
|
23310
25226
|
clearInterval(this.workingRecoveryTimer);
|
|
@@ -23335,6 +25251,17 @@ export class FleetManager {
|
|
|
23335
25251
|
// #1565: the web chat's last changes reach the disk (bounded: a slow disk does not hold the shutdown).
|
|
23336
25252
|
const webChatStopped = this.webChatStore ? Promise.race([this.webChatStore.flush().catch(() => { }), new Promise(r => setTimeout(r, 3_000).unref?.())]) : Promise.resolve();
|
|
23337
25253
|
const profileStopped = this.runtimeCpuProfiler?.shutdown("fleet shutdown");
|
|
25254
|
+
// S-51: the Hub closes in the same drain, bounded so an unanswering listener does not hold the shutdown.
|
|
25255
|
+
const hubInit = this.hubRuntimeInit, hubNow = this.hubRuntime;
|
|
25256
|
+
this.hubRuntime = null;
|
|
25257
|
+
this.hubRuntimeInit = null;
|
|
25258
|
+
const hubClose = async () => {
|
|
25259
|
+
const runtime = hubNow ?? (hubInit ? await hubInit.catch(() => null) : null);
|
|
25260
|
+
await runtime?.close();
|
|
25261
|
+
};
|
|
25262
|
+
const hubStopped = hubNow || hubInit
|
|
25263
|
+
? Promise.race([hubClose().catch(err => this.logger.warn({ err: err?.message }, "Hub did not close cleanly")), new Promise(r => setTimeout(r, 10_000).unref?.())])
|
|
25264
|
+
: Promise.resolve();
|
|
23338
25265
|
this.ipcStoppingInstances.add("__fleet_stopping__");
|
|
23339
25266
|
// Release held delivery promises before awaiting daemon shutdown, then
|
|
23340
25267
|
// reject spawn work which has not started. Otherwise a storm backoff could
|
|
@@ -23365,23 +25292,20 @@ export class FleetManager {
|
|
|
23365
25292
|
// A login/install window is a dedicated tmux server with its own TTL
|
|
23366
25293
|
// timer and HTTP listener living in THIS process: without an explicit
|
|
23367
25294
|
// shutdown it would outlive us as an owner-less login CLI (sol B3).
|
|
25295
|
+
await inboundStopped;
|
|
23368
25296
|
await publicStopped;
|
|
23369
25297
|
await sharesStopped?.catch(() => { });
|
|
23370
25298
|
await profileStopped;
|
|
25299
|
+
await hubStopped;
|
|
23371
25300
|
await needsStopped;
|
|
23372
25301
|
await settingsControlStopped;
|
|
23373
25302
|
await cacheStopped;
|
|
25303
|
+
await quotaNoticesStopped;
|
|
25304
|
+
this.quotaNotices = null;
|
|
23374
25305
|
await webChatStopped;
|
|
23375
25306
|
await this.cpuProfileControl?.close();
|
|
23376
25307
|
this.cpuProfileControl = null;
|
|
23377
25308
|
await this.shutdownLoginWindows();
|
|
23378
|
-
// Cancel adapter retry timers
|
|
23379
|
-
for (const state of this.adapterState.values()) {
|
|
23380
|
-
if (state.retryTimer) {
|
|
23381
|
-
clearTimeout(state.retryTimer);
|
|
23382
|
-
state.retryTimer = undefined;
|
|
23383
|
-
}
|
|
23384
|
-
}
|
|
23385
25309
|
this.clearStatuslineWatchers();
|
|
23386
25310
|
this.costGuard?.stop();
|
|
23387
25311
|
this.dailySummary?.stop();
|
|
@@ -23419,6 +25343,15 @@ export class FleetManager {
|
|
|
23419
25343
|
clearInterval(this.discordPresenceTimer);
|
|
23420
25344
|
this.discordPresenceTimer = null;
|
|
23421
25345
|
}
|
|
25346
|
+
if (this.quotaReadTimer) {
|
|
25347
|
+
clearInterval(this.quotaReadTimer);
|
|
25348
|
+
this.quotaReadTimer = null;
|
|
25349
|
+
}
|
|
25350
|
+
if (this.capacityTimer) {
|
|
25351
|
+
clearInterval(this.capacityTimer);
|
|
25352
|
+
this.capacityTimer = null;
|
|
25353
|
+
}
|
|
25354
|
+
setCapacityLookup(null);
|
|
23422
25355
|
if (this.discordPresenceEagerTimer) {
|
|
23423
25356
|
clearTimeout(this.discordPresenceEagerTimer);
|
|
23424
25357
|
this.discordPresenceEagerTimer = null;
|
|
@@ -23705,6 +25638,7 @@ export class FleetManager {
|
|
|
23705
25638
|
this.loadedFleetSource = previousSource;
|
|
23706
25639
|
this.observeWebAuthority(); // #2453 review: the configuration back in force is the one seen
|
|
23707
25640
|
this.observeRuntimeSwitches(); // M-2255: and the Windows runtimes' switches
|
|
25641
|
+
this.observeHubSwitches(); // S-51: and the Hub's
|
|
23708
25642
|
this.logger.error({
|
|
23709
25643
|
oldCount,
|
|
23710
25644
|
newCount,
|
|
@@ -23724,6 +25658,8 @@ export class FleetManager {
|
|
|
23724
25658
|
// mark every row done and tell the user "changes applied".
|
|
23725
25659
|
return { rejected: why };
|
|
23726
25660
|
}
|
|
25661
|
+
this.nativeMcpStore?.observePolicies();
|
|
25662
|
+
this.agentCredentialsCache?.observePolicies();
|
|
23727
25663
|
if (this.loadedFleetSource)
|
|
23728
25664
|
this.getConfigHistory().accepted("fleet.yaml", this.configPath, this.loadedFleetSource);
|
|
23729
25665
|
this.migrateOfficeStorage();
|
|
@@ -24624,6 +26560,9 @@ export class FleetManager {
|
|
|
24624
26560
|
}
|
|
24625
26561
|
async runConnectionBindingApply(job, binding, execution) {
|
|
24626
26562
|
try {
|
|
26563
|
+
// #3055 review r2: a connection is not re-pointed while one of its topics is being deleted (nothing is changed).
|
|
26564
|
+
if (this.topicDeletionPending())
|
|
26565
|
+
throw new Error("a topic deletion is running; try again in a moment");
|
|
24627
26566
|
await this.rebuildAdapterForBinding(job.connectionId, binding, execution);
|
|
24628
26567
|
job.result = "applied";
|
|
24629
26568
|
}
|
|
@@ -25794,8 +27733,13 @@ export class FleetManager {
|
|
|
25794
27733
|
return;
|
|
25795
27734
|
}
|
|
25796
27735
|
const requestPath = new URL(req.url ?? "/", `http://localhost:${port}`).pathname;
|
|
27736
|
+
const publicUrl = new URL(req.url ?? "/", `http://localhost:${port}`);
|
|
25797
27737
|
if (remoteRuntimeEnabled() && !gatewayRequestContext(req)
|
|
25798
|
-
&& this.runtimeCoordinator().handlePublicRequest(req, res,
|
|
27738
|
+
&& this.runtimeCoordinator().handlePublicRequest(req, res, publicUrl))
|
|
27739
|
+
return;
|
|
27740
|
+
// The read-only installer files (/runtime/install.ps1 and the bundle ZIP) grant nothing. They answer 404 while remote runtimes
|
|
27741
|
+
// are off or on a public gateway link, and touch no other path.
|
|
27742
|
+
if (this.runtimeInstaller().handle(req, res, publicUrl))
|
|
25799
27743
|
return;
|
|
25800
27744
|
// Branding is public, after Host admission: automatic favicon requests
|
|
25801
27745
|
// must not become noisy web-token 401s in the browser console.
|
|
@@ -25824,7 +27768,7 @@ export class FleetManager {
|
|
|
25824
27768
|
&& String(req.headers.accept ?? "").includes("text/html")
|
|
25825
27769
|
&& isWebPageNavigation(requestPath)) {
|
|
25826
27770
|
const link = gatewayRequestContext(req);
|
|
25827
|
-
serveSigninPage(res, 401, { webOnly: this.isWebOnlyFleet(), outside: !!link && this.isOutsideLink(link.exposureId) });
|
|
27771
|
+
serveSigninPage(res, 401, { webOnly: this.isWebOnlyFleet(), outside: !!link && this.isOutsideLink(link.exposureId), deviceLogin: !link && this.deviceLoginAvailable(), loginQr: this.loginQrEnabled() });
|
|
25828
27772
|
return;
|
|
25829
27773
|
}
|
|
25830
27774
|
res.writeHead(decision.status);
|
|
@@ -25996,6 +27940,7 @@ export class FleetManager {
|
|
|
25996
27940
|
res.end(JSON.stringify({
|
|
25997
27941
|
...sysInfo,
|
|
25998
27942
|
version: this.currentVersion,
|
|
27943
|
+
build: gatewayRequestContext(req) ? undefined : this.currentBuild,
|
|
25999
27944
|
instances: enriched,
|
|
26000
27945
|
publicLink: this.getPublicWebStatus(),
|
|
26001
27946
|
}));
|
|
@@ -26493,6 +28438,8 @@ export class FleetManager {
|
|
|
26493
28438
|
})(),
|
|
26494
28439
|
capabilities: { chat: true, settings: true, pause: true, cancel: true, teams: true, schedules: true, delegation: true, mcp: true,
|
|
26495
28440
|
commands: true, effort: false, log: true, details: true, channels: false, terminal: false, attachments: false, usage: false, send_while_busy: true },
|
|
28441
|
+
// cc3ce4fe: the version this machine's inventory reports for the agent's CLI, and whether AgEnD has audited it.
|
|
28442
|
+
...this.nativeCliStatus(nativeConfig.backend, nativeConfig.machine_id, this.daemons.get(name)),
|
|
26496
28443
|
...(nativeConfig.machine_id ? { machine_id: nativeConfig.machine_id, machine_name: this.runtimeHub?.machine(nativeConfig.machine_id)?.name,
|
|
26497
28444
|
machine_status: this.runtimeHub?.machine(nativeConfig.machine_id)?.status ?? "offline" } : {}) } : {}),
|
|
26498
28445
|
display_name: identity.display_name || undefined,
|