@songsid/agend 2.3.5-alpha.4 → 2.3.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/README.zh-TW.md +0 -2
- package/THIRD_PARTY_NOTICES.md +12 -28
- 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 +4 -6
- package/dist/agent-endpoint.js +15 -12
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/auth-api.d.ts +0 -21
- package/dist/auth-api.js +8 -93
- 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/authority/web-authority.d.ts +2 -12
- package/dist/authority/web-authority.js +4 -25
- package/dist/authority/web-authority.js.map +1 -1
- package/dist/backend/antigravity.js +3 -1
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/claude-code.d.ts +12 -15
- package/dist/backend/claude-code.js +133 -152
- package/dist/backend/claude-code.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-package.d.ts +2 -5
- package/dist/backend/codex-package.js +5 -1
- package/dist/backend/codex-package.js.map +1 -1
- package/dist/backend/codex-quota-history.d.ts +7 -0
- package/dist/backend/codex-quota-history.js +72 -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 +116 -136
- package/dist/backend/codex.js +912 -942
- 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 -3
- package/dist/backend/grok.js +301 -76
- 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/types.d.ts +15 -8
- package/dist/backend/types.js +3 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/bundled-tmux-guard.d.ts +21 -0
- package/dist/bundled-tmux-guard.js +96 -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/ipc-bridge.d.ts +0 -2
- 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-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/cli.js +14 -10
- package/dist/cli.js.map +1 -1
- package/dist/config-validator.js +30 -71
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +3 -17
- 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 +70 -68
- package/dist/daemon.js +774 -846
- 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 +26 -16
- package/dist/delivery-consumed-watch.js +31 -26
- package/dist/delivery-consumed-watch.js.map +1 -1
- package/dist/delivery-outbox.d.ts +0 -5
- package/dist/delivery-outbox.js +4 -32
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/delivery-reconciliation.d.ts +42 -2
- package/dist/delivery-reconciliation.js +164 -2
- package/dist/delivery-reconciliation.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 +4 -2
- package/dist/fleet-level-config.d.ts +1 -1
- package/dist/fleet-level-config.js +0 -2
- package/dist/fleet-level-config.js.map +1 -1
- package/dist/fleet-manager.d.ts +108 -245
- package/dist/fleet-manager.js +656 -2028
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-instance.d.ts +0 -7
- package/dist/general-instance.js +3 -20
- package/dist/general-instance.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +393 -0
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +1 -0
- 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/web-dashboard/SKILL.md +9 -3
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +1 -1
- package/dist/instance-config-impact.js +6 -7
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +19 -23
- package/dist/instance-lifecycle.js +216 -383
- 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 -3
- package/dist/instructions.js +1 -7
- 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/locale.js +63 -86
- 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-flows.d.ts +7 -0
- package/dist/login-flows.js +5 -2
- 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/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/needs-you-hub.d.ts +6 -3
- package/dist/needs-you-hub.js +31 -9
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +20 -18
- package/dist/needs-you.js +18 -14
- package/dist/needs-you.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/outbound-handlers.d.ts +2 -16
- package/dist/outbound-handlers.js +10 -72
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +0 -38
- package/dist/outbound-schemas.js +5 -14
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/pane-quota-history.d.ts +7 -0
- package/dist/pane-quota-history.js +47 -0
- package/dist/pane-quota-history.js.map +1 -0
- 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 +0 -9
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +0 -11
- package/dist/public-web-link.js +0 -13
- package/dist/public-web-link.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-api.js +5 -9
- package/dist/quickstart-api.js.map +1 -1
- package/dist/quickstart.d.ts +8 -1
- package/dist/quickstart.js +42 -4
- package/dist/quickstart.js.map +1 -1
- 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/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.d.ts +9 -0
- package/dist/scheduler/task-board.js +19 -0
- package/dist/scheduler/task-board.js.map +1 -1
- package/dist/settings-api.d.ts +13 -5
- package/dist/settings-api.js +26 -96
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +0 -1
- package/dist/settings-baseline.js +1 -1
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-change.js +23 -28
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-confirmation.d.ts +1 -16
- package/dist/settings-confirmation.js +9 -47
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.d.ts +0 -4
- package/dist/settings-effect.js +1 -58
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +0 -4
- package/dist/settings-http-confirmation.js +3 -31
- 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/settings-request-capability.d.ts +0 -2
- package/dist/settings-request-capability.js +0 -4
- package/dist/settings-request-capability.js.map +1 -1
- package/dist/settings-transaction.d.ts +0 -4
- package/dist/settings-transaction.js +0 -9
- package/dist/settings-transaction.js.map +1 -1
- package/dist/setup-form.js +3 -6
- package/dist/setup-form.js.map +1 -1
- package/dist/setup-i18n.js +0 -3
- package/dist/setup-i18n.js.map +1 -1
- package/dist/task-board-tool.d.ts +11 -0
- package/dist/task-board-tool.js +44 -0
- 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-control.d.ts +1 -2
- package/dist/tmux-control.js.map +1 -1
- package/dist/tmux-manager.d.ts +1 -2
- package/dist/tmux-manager.js.map +1 -1
- package/dist/tool-permissions.d.ts +5 -2
- package/dist/tool-permissions.js +7 -7
- 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 +4 -3
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-delta-reader.d.ts +1 -1
- package/dist/transcript-delta-reader.js +1 -1
- package/dist/transcript-delta-reader.js.map +1 -1
- package/dist/transcript-monitor.d.ts +20 -3
- package/dist/transcript-monitor.js +92 -24
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-sources.d.ts +0 -5
- package/dist/transcript-sources.js +79 -8
- package/dist/transcript-sources.js.map +1 -1
- package/dist/types.d.ts +3 -23
- package/dist/ui/app.html +8 -1
- package/dist/ui/backend-signin.js +21 -36
- package/dist/ui/chat-md-strings.js +9 -0
- package/dist/ui/chat-store.js +2 -13
- package/dist/ui/chat-strings.js +2 -50
- package/dist/ui/chat-thread.js +53 -3
- package/dist/ui/fleet-task-card.js +3 -3
- package/dist/ui/fleet-task-common.js +10 -0
- package/dist/ui/fleet-tasks.js +7 -5
- package/dist/ui/fleet-usage.js +90 -27
- package/dist/ui/panel-chat.js +37 -66
- package/dist/ui/panel-details.js +1 -2
- package/dist/ui/panel-fleet.js +88 -107
- package/dist/ui/panel-needs.js +21 -163
- package/dist/ui/panel-notices.js +4 -3
- package/dist/ui/panel-settings.js +149 -239
- package/dist/ui/preview-panel.js +84 -6
- package/dist/ui/search-dialog.js +3 -2
- package/dist/ui/settings-appearance.js +23 -122
- package/dist/ui/settings-catalog.js +10 -37
- package/dist/ui/settings-codex-copy.js +19 -0
- package/dist/ui/settings-confirm.js +1 -3
- package/dist/ui/settings-dialogs.js +20 -27
- package/dist/ui/settings-guests.js +14 -27
- package/dist/ui/settings-model.js +17 -12
- package/dist/ui/settings-quota-notice.js +100 -0
- package/dist/ui/settings-registry.js +4 -11
- package/dist/ui/settings-strings.js +4 -113
- package/dist/ui/settings-web-authority.js +13 -15
- 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 +2 -6
- package/dist/ui/shared/app-shell.js +18 -23
- package/dist/ui/shared/app-store.js +2 -3
- package/dist/ui/shared/app-stream.js +1 -3
- package/dist/ui/shared/app.css +40 -1312
- package/dist/ui/shared/app.js +2 -5
- package/dist/ui/shared/header-tools.js +4 -6
- package/dist/ui/shared/instance-nav.js +7 -34
- package/dist/ui/shared/instance-switch.js +3 -4
- package/dist/ui/shared/loading.css +37 -0
- package/dist/ui/shared/panel-view.js +77 -4
- package/dist/ui/shared/signin.js +6 -39
- package/dist/ui/shared/tokens.css +0 -1
- package/dist/ui/shared/ui-dialog.js +2 -2
- package/dist/ui/shared/ui-menu.js +10 -30
- package/dist/ui/shared/ui-states.js +14 -3
- package/dist/ui/shared/usage-dialog.js +18 -1
- package/dist/ui/shared/vendor/vendor.json +2 -19
- 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 -8
- package/dist/ui/signin.html +5 -2
- package/dist/unattended-install.d.ts +11 -2
- package/dist/unattended-install.js +39 -5
- package/dist/unattended-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 +5 -0
- 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 +100 -16
- 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 +6 -38
- package/dist/web-api.js +20 -255
- package/dist/web-api.js.map +1 -1
- package/dist/web-chat-history.d.ts +2 -19
- package/dist/web-chat-history.js +3 -72
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-only-fleet.d.ts +0 -20
- package/dist/web-only-fleet.js +0 -21
- package/dist/web-only-fleet.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 +0 -7
- package/dist/web-session.js +0 -2
- package/dist/web-session.js.map +1 -1
- package/dist/web-shell-routes.d.ts +1 -4
- package/dist/web-shell-routes.js +2 -7
- package/dist/web-shell-routes.js.map +1 -1
- package/launcher/private-home.cjs +1 -1
- package/package.json +3 -9
- package/dist/agent-runtime-api.d.ts +0 -4
- package/dist/agent-runtime-api.js +0 -59
- package/dist/agent-runtime-api.js.map +0 -1
- package/dist/agent-runtime-change.d.ts +0 -74
- package/dist/agent-runtime-change.js +0 -102
- package/dist/agent-runtime-change.js.map +0 -1
- package/dist/backend/grok-model-cache.d.ts +0 -7
- package/dist/backend/grok-model-cache.js +0 -65
- package/dist/backend/grok-model-cache.js.map +0 -1
- package/dist/backend/native-pane.d.ts +0 -9
- package/dist/backend/native-pane.js +0 -59
- package/dist/backend/native-pane.js.map +0 -1
- package/dist/fleet-windows-runtime.d.ts +0 -97
- package/dist/fleet-windows-runtime.js +0 -449
- package/dist/fleet-windows-runtime.js.map +0 -1
- package/dist/general-binding.d.ts +0 -85
- package/dist/general-binding.js +0 -298
- package/dist/general-binding.js.map +0 -1
- package/dist/general-host-owner.d.ts +0 -8
- package/dist/general-host-owner.js +0 -26
- package/dist/general-host-owner.js.map +0 -1
- package/dist/general-role.d.ts +0 -5
- package/dist/general-role.js +0 -26
- package/dist/general-role.js.map +0 -1
- package/dist/local-pane-endpoint.d.ts +0 -46
- package/dist/local-pane-endpoint.js +0 -189
- package/dist/local-pane-endpoint.js.map +0 -1
- package/dist/local-pane-launcher.d.ts +0 -2
- package/dist/local-pane-launcher.js +0 -38
- package/dist/local-pane-launcher.js.map +0 -1
- package/dist/local-pane-stage.ps1 +0 -101
- package/dist/model-catalog-defaults.d.ts +0 -14
- package/dist/model-catalog-defaults.js +0 -20
- package/dist/model-catalog-defaults.js.map +0 -1
- package/dist/native-agent-admission.d.ts +0 -7
- package/dist/native-agent-admission.js +0 -26
- package/dist/native-agent-admission.js.map +0 -1
- package/dist/native-daemon-client.d.ts +0 -13
- package/dist/native-daemon-client.js +0 -28
- package/dist/native-daemon-client.js.map +0 -1
- package/dist/native-instance-api.d.ts +0 -14
- package/dist/native-instance-api.js +0 -205
- package/dist/native-instance-api.js.map +0 -1
- package/dist/native-instance-input.d.ts +0 -84
- package/dist/native-instance-input.js +0 -54
- package/dist/native-instance-input.js.map +0 -1
- package/dist/native-instance-registry.d.ts +0 -32
- package/dist/native-instance-registry.js +0 -105
- package/dist/native-instance-registry.js.map +0 -1
- package/dist/native-mcp.d.ts +0 -40
- package/dist/native-mcp.js +0 -278
- package/dist/native-mcp.js.map +0 -1
- package/dist/native-model-catalog.d.ts +0 -5
- package/dist/native-model-catalog.js +0 -76
- package/dist/native-model-catalog.js.map +0 -1
- package/dist/native-pane-crash-budget.d.ts +0 -20
- package/dist/native-pane-crash-budget.js +0 -60
- package/dist/native-pane-crash-budget.js.map +0 -1
- package/dist/native-pane-create.d.ts +0 -26
- package/dist/native-pane-create.js +0 -53
- package/dist/native-pane-create.js.map +0 -1
- package/dist/native-pane-lifecycle.d.ts +0 -65
- package/dist/native-pane-lifecycle.js +0 -230
- package/dist/native-pane-lifecycle.js.map +0 -1
- package/dist/native-pane-manager.d.ts +0 -59
- package/dist/native-pane-manager.js +0 -584
- package/dist/native-pane-manager.js.map +0 -1
- package/dist/native-pane-output-log.d.ts +0 -15
- package/dist/native-pane-output-log.js +0 -108
- package/dist/native-pane-output-log.js.map +0 -1
- package/dist/native-pane-reconciliation.d.ts +0 -4
- package/dist/native-pane-reconciliation.js +0 -40
- package/dist/native-pane-reconciliation.js.map +0 -1
- package/dist/native-pane-recovery.d.ts +0 -12
- package/dist/native-pane-recovery.js +0 -10
- package/dist/native-pane-recovery.js.map +0 -1
- package/dist/native-pane-tools.d.ts +0 -2
- package/dist/native-pane-tools.js +0 -14
- package/dist/native-pane-tools.js.map +0 -1
- package/dist/pane-port.d.ts +0 -118
- package/dist/pane-port.js +0 -2
- package/dist/pane-port.js.map +0 -1
- package/dist/runtime-api.d.ts +0 -8
- package/dist/runtime-api.js +0 -171
- package/dist/runtime-api.js.map +0 -1
- package/dist/runtime-assets/@xterm/addon-serialize/LICENSE +0 -21
- package/dist/runtime-assets/@xterm/addon-serialize/lib/addon-serialize.js +0 -2
- package/dist/runtime-assets/@xterm/addon-serialize/lib/addon-serialize.mjs +0 -19
- package/dist/runtime-assets/@xterm/addon-serialize/package.json +0 -29
- package/dist/runtime-assets/@xterm/headless/LICENSE +0 -21
- package/dist/runtime-assets/@xterm/headless/lib-headless/xterm-headless.js +0 -2
- package/dist/runtime-assets/@xterm/headless/lib-headless/xterm-headless.mjs +0 -46
- package/dist/runtime-assets/@xterm/headless/package.json +0 -29
- package/dist/runtime-assets/node-pty/CONPTY-LICENSE +0 -21
- package/dist/runtime-assets/node-pty/CONPTY-NOTICE.md +0 -503
- package/dist/runtime-assets/node-pty/LICENSE +0 -69
- package/dist/runtime-assets/node-pty/lib/conpty_console_list_agent.js +0 -16
- package/dist/runtime-assets/node-pty/lib/eventEmitter2.js +0 -47
- package/dist/runtime-assets/node-pty/lib/index.js +0 -52
- package/dist/runtime-assets/node-pty/lib/interfaces.js +0 -7
- package/dist/runtime-assets/node-pty/lib/shared/conout.js +0 -11
- package/dist/runtime-assets/node-pty/lib/terminal.js +0 -190
- package/dist/runtime-assets/node-pty/lib/types.js +0 -7
- package/dist/runtime-assets/node-pty/lib/unixTerminal.js +0 -346
- package/dist/runtime-assets/node-pty/lib/utils.js +0 -39
- package/dist/runtime-assets/node-pty/lib/windowsConoutConnection.js +0 -125
- package/dist/runtime-assets/node-pty/lib/windowsPtyAgent.js +0 -320
- package/dist/runtime-assets/node-pty/lib/windowsTerminal.js +0 -199
- package/dist/runtime-assets/node-pty/lib/worker/conoutSocketWorker.js +0 -22
- package/dist/runtime-assets/node-pty/package.json +0 -64
- package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty.node +0 -0
- package/dist/runtime-assets/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
- package/dist/runtime-build-info.d.ts +0 -9
- package/dist/runtime-build-info.js +0 -57
- package/dist/runtime-build-info.js.map +0 -1
- package/dist/runtime-bundle.d.ts +0 -19
- package/dist/runtime-bundle.js +0 -156
- package/dist/runtime-bundle.js.map +0 -1
- package/dist/runtime-cli.d.ts +0 -7
- package/dist/runtime-cli.js +0 -152
- package/dist/runtime-cli.js.map +0 -1
- package/dist/runtime-client-store.d.ts +0 -68
- package/dist/runtime-client-store.js +0 -344
- package/dist/runtime-client-store.js.map +0 -1
- package/dist/runtime-client.d.ts +0 -112
- package/dist/runtime-client.js +0 -736
- package/dist/runtime-client.js.map +0 -1
- package/dist/runtime-connection.d.ts +0 -22
- package/dist/runtime-connection.js +0 -93
- package/dist/runtime-connection.js.map +0 -1
- package/dist/runtime-coordinator.d.ts +0 -91
- package/dist/runtime-coordinator.js +0 -911
- package/dist/runtime-coordinator.js.map +0 -1
- package/dist/runtime-general-protocol.d.ts +0 -22
- package/dist/runtime-general-protocol.js +0 -57
- package/dist/runtime-general-protocol.js.map +0 -1
- package/dist/runtime-general-workspace.d.ts +0 -17
- package/dist/runtime-general-workspace.js +0 -213
- package/dist/runtime-general-workspace.js.map +0 -1
- package/dist/runtime-pane-assets.d.ts +0 -17
- package/dist/runtime-pane-assets.js +0 -23
- package/dist/runtime-pane-assets.js.map +0 -1
- package/dist/runtime-pane-boot.d.ts +0 -9
- package/dist/runtime-pane-boot.js +0 -47
- package/dist/runtime-pane-boot.js.map +0 -1
- package/dist/runtime-pane-codex-index.d.ts +0 -1
- package/dist/runtime-pane-codex-index.js +0 -47
- package/dist/runtime-pane-codex-index.js.map +0 -1
- package/dist/runtime-pane-config.d.ts +0 -16
- package/dist/runtime-pane-config.js +0 -54
- package/dist/runtime-pane-config.js.map +0 -1
- package/dist/runtime-pane-host.d.ts +0 -44
- package/dist/runtime-pane-host.js +0 -424
- package/dist/runtime-pane-host.js.map +0 -1
- package/dist/runtime-pane-job-owner.d.ts +0 -1
- package/dist/runtime-pane-job-owner.js +0 -29
- package/dist/runtime-pane-job-owner.js.map +0 -1
- package/dist/runtime-pane-job.ps1 +0 -116
- package/dist/runtime-pane-link.d.ts +0 -40
- package/dist/runtime-pane-link.js +0 -246
- package/dist/runtime-pane-link.js.map +0 -1
- package/dist/runtime-pane-mcp-protocol.d.ts +0 -32
- package/dist/runtime-pane-mcp-protocol.js +0 -39
- package/dist/runtime-pane-mcp-protocol.js.map +0 -1
- package/dist/runtime-pane-mcp-relay.d.ts +0 -17
- package/dist/runtime-pane-mcp-relay.js +0 -70
- package/dist/runtime-pane-mcp-relay.js.map +0 -1
- package/dist/runtime-pane-mcp.d.ts +0 -51
- package/dist/runtime-pane-mcp.js +0 -150
- package/dist/runtime-pane-mcp.js.map +0 -1
- package/dist/runtime-pane-native.d.ts +0 -45
- package/dist/runtime-pane-native.js +0 -65
- package/dist/runtime-pane-native.js.map +0 -1
- package/dist/runtime-pane-output.d.ts +0 -19
- package/dist/runtime-pane-output.js +0 -53
- package/dist/runtime-pane-output.js.map +0 -1
- package/dist/runtime-pane-port.d.ts +0 -139
- package/dist/runtime-pane-port.js +0 -558
- package/dist/runtime-pane-port.js.map +0 -1
- package/dist/runtime-pane-private.d.ts +0 -14
- package/dist/runtime-pane-private.js +0 -51
- package/dist/runtime-pane-private.js.map +0 -1
- package/dist/runtime-pane-private.ps1 +0 -14
- package/dist/runtime-pane-process.d.ts +0 -4
- package/dist/runtime-pane-process.js +0 -108
- package/dist/runtime-pane-process.js.map +0 -1
- package/dist/runtime-pane-protocol.d.ts +0 -172
- package/dist/runtime-pane-protocol.js +0 -195
- package/dist/runtime-pane-protocol.js.map +0 -1
- package/dist/runtime-pane-screen.d.ts +0 -19
- package/dist/runtime-pane-screen.js +0 -76
- package/dist/runtime-pane-screen.js.map +0 -1
- package/dist/runtime-pane-service.d.ts +0 -11
- package/dist/runtime-pane-service.js +0 -221
- package/dist/runtime-pane-service.js.map +0 -1
- package/dist/runtime-pane-stdio-protocol.d.ts +0 -54
- package/dist/runtime-pane-stdio-protocol.js +0 -94
- package/dist/runtime-pane-stdio-protocol.js.map +0 -1
- package/dist/runtime-pane-stdio.d.ts +0 -3
- package/dist/runtime-pane-stdio.js +0 -123
- package/dist/runtime-pane-stdio.js.map +0 -1
- package/dist/runtime-pane-store.d.ts +0 -33
- package/dist/runtime-pane-store.js +0 -164
- package/dist/runtime-pane-store.js.map +0 -1
- package/dist/runtime-pane-transcript-protocol.d.ts +0 -43
- package/dist/runtime-pane-transcript-protocol.js +0 -58
- package/dist/runtime-pane-transcript-protocol.js.map +0 -1
- package/dist/runtime-pane-transcript.d.ts +0 -45
- package/dist/runtime-pane-transcript.js +0 -605
- package/dist/runtime-pane-transcript.js.map +0 -1
- package/dist/runtime-pane-worker.d.ts +0 -1
- package/dist/runtime-pane-worker.js +0 -154
- package/dist/runtime-pane-worker.js.map +0 -1
- package/dist/runtime-protocol.d.ts +0 -162
- package/dist/runtime-protocol.js +0 -37
- package/dist/runtime-protocol.js.map +0 -1
- package/dist/runtime-switches.d.ts +0 -79
- package/dist/runtime-switches.js +0 -90
- package/dist/runtime-switches.js.map +0 -1
- package/dist/runtime-transcript-delta-reader.d.ts +0 -23
- package/dist/runtime-transcript-delta-reader.js +0 -74
- package/dist/runtime-transcript-delta-reader.js.map +0 -1
- package/dist/runtime-transcript-source.d.ts +0 -36
- package/dist/runtime-transcript-source.js +0 -189
- package/dist/runtime-transcript-source.js.map +0 -1
- package/dist/runtime-windows-bridge.d.ts +0 -41
- package/dist/runtime-windows-bridge.js +0 -157
- package/dist/runtime-windows-bridge.js.map +0 -1
- package/dist/settings-route-lifetime.d.ts +0 -14
- package/dist/settings-route-lifetime.js +0 -48
- package/dist/settings-route-lifetime.js.map +0 -1
- package/dist/tmux-pane-host.d.ts +0 -26
- package/dist/tmux-pane-host.js +0 -25
- package/dist/tmux-pane-host.js.map +0 -1
- package/dist/transcript-needles.d.ts +0 -35
- package/dist/transcript-needles.js +0 -158
- package/dist/transcript-needles.js.map +0 -1
- package/dist/transcript-records.d.ts +0 -21
- package/dist/transcript-records.js +0 -140
- package/dist/transcript-records.js.map +0 -1
- package/dist/ui/agent-proposals.js +0 -90
- package/dist/ui/agent-runtime-settings.js +0 -67
- package/dist/ui/agent-runtime.js +0 -124
- package/dist/ui/cli-picker.js +0 -42
- package/dist/ui/general-location.js +0 -71
- package/dist/ui/native-instance-settings.js +0 -44
- package/dist/ui/native-pane-recovery.js +0 -45
- package/dist/ui/panel-runtimes.js +0 -334
- package/dist/ui/panel-windows-agent.js +0 -86
- package/dist/ui/panel-windows-cli.js +0 -179
- package/dist/ui/provider-marks.js +0 -83
- package/dist/ui/runtime-catalog.js +0 -55
- package/dist/ui/settings-agent-filters.js +0 -94
- package/dist/ui/settings-layout.js +0 -245
- package/dist/ui/settings-outside.js +0 -176
- package/dist/ui/settings-shortcuts.js +0 -65
- package/dist/ui/shared/machine-name.js +0 -13
- package/dist/ui/shared/qrcode.module.js +0 -2237
- package/dist/ui/shared/settings-width.js +0 -31
- package/dist/ui/shared/vendor/qrcode-generator.LICENSE +0 -27
- package/dist/ui/windows-agents-nav.js +0 -2
- package/dist/ui/windows-cli-catalog.js +0 -108
- package/dist/web-remote-access.d.ts +0 -152
- package/dist/web-remote-access.js +0 -368
- package/dist/web-remote-access.js.map +0 -1
- package/dist/windows-agents.d.ts +0 -126
- package/dist/windows-agents.js +0 -490
- package/dist/windows-agents.js.map +0 -1
- package/dist/windows-cli-api.d.ts +0 -23
- package/dist/windows-cli-api.js +0 -159
- package/dist/windows-cli-api.js.map +0 -1
- package/dist/windows-cli-providers.d.ts +0 -115
- package/dist/windows-cli-providers.js +0 -429
- package/dist/windows-cli-providers.js.map +0 -1
- package/dist/windows-cli-worker.d.ts +0 -59
- package/dist/windows-cli-worker.js +0 -479
- package/dist/windows-cli-worker.js.map +0 -1
- package/dist/windows-cli.d.ts +0 -116
- package/dist/windows-cli.js +0 -407
- package/dist/windows-cli.js.map +0 -1
- package/dist/windows-native-mcp.d.ts +0 -19
- package/dist/windows-native-mcp.js +0 -143
- package/dist/windows-native-mcp.js.map +0 -1
- package/dist/windows-pane-mcp.d.ts +0 -26
- package/dist/windows-pane-mcp.js +0 -187
- package/dist/windows-pane-mcp.js.map +0 -1
- package/templates/runtime-assets/conpty-LICENSE +0 -21
- package/templates/runtime-assets/conpty-NOTICE.md +0 -503
- package/templates/runtime-assets/local-pane-stage.ps1 +0 -101
- package/templates/runtime-assets/runtime-pane-job.ps1 +0 -116
- package/templates/runtime-assets/runtime-pane-private.ps1 +0 -14
- package/templates/runtime-assets/xterm-LICENSE +0 -21
package/dist/runtime-client.js
DELETED
|
@@ -1,736 +0,0 @@
|
|
|
1
|
-
/** Standalone, outbound-only native runtime. Imports no Fleet, database, bot or Linux native dependency. */
|
|
2
|
-
import WebSocket from "ws";
|
|
3
|
-
import { readPaneSystemBootId, reusedRuntimeLockPid } from "./runtime-pane-boot.js";
|
|
4
|
-
import { createServer } from "node:http";
|
|
5
|
-
import { hostname } from "node:os";
|
|
6
|
-
import { randomBytes, randomUUID } from "node:crypto";
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
import { WindowsCliBridge, nativeWindowsTransport, WINDOWS_CLI_INVENTORY_FILE } from "./windows-cli.js";
|
|
9
|
-
import { validateNativeTask, validWindowsAgentId } from "./windows-cli-worker.js";
|
|
10
|
-
import { validNativeSessionId } from "./windows-cli-providers.js";
|
|
11
|
-
import { runtimeJobDigest, validateRuntimeServer } from "./runtime-client-store.js";
|
|
12
|
-
import { RUNTIME_ROTATE_PATH, runtimeClaimFingerprint } from "./runtime-protocol.js";
|
|
13
|
-
import { readRuntimeInfo } from "./runtime-build-info.js";
|
|
14
|
-
import { validatePaneMcpBody } from "./runtime-pane-mcp-protocol.js";
|
|
15
|
-
import { validateRuntimePaneRequest, validateRuntimePaneShutdown } from "./runtime-pane-protocol.js";
|
|
16
|
-
export { RUNTIME_PANE_MODULES } from "./runtime-pane-assets.js";
|
|
17
|
-
const REPAIR = "run .\\agend-runtime.cmd disconnect in this folder (add the same --profile if you used one), then double-click connect-agend.bat and enter a new pairing code.";
|
|
18
|
-
/** Plain-language cause and next step for a stop AgEnD caused. AgEnD answers an unknown and a revoked credential with the same bare 401, so "refused" covers both. */
|
|
19
|
-
export function describeRuntimeStop(reason) {
|
|
20
|
-
switch (reason.kind) {
|
|
21
|
-
case "refused": return `${reason.detail === "HTTP 403" ? "The connection was refused with HTTP 403. If AgEnD's address goes through a proxy, check the proxy's settings too. " : ""}AgEnD did not accept this computer's saved connection, so the Runtime stopped. Open AgEnD Settings -> Runtime: if this computer is missing or revoked, or AgEnD's data was reset, it must be paired again; ${REPAIR} If the pairing was made against a different AgEnD address than this folder's, use the download that matches it.`;
|
|
22
|
-
case "revoked": return `This computer was revoked in AgEnD Settings -> Runtime, so the Runtime stopped. To connect it again, ${REPAIR}`;
|
|
23
|
-
case "replaced": return "This computer connected to AgEnD again from somewhere else, so AgEnD closed this connection. A pairing allows one live connection. Close the other Runtime window (or the other computer that uses a copy of this profile), then double-click connect-agend.bat again. Each computer needs its own pairing code.";
|
|
24
|
-
case "incompatible": return "This Runtime could not understand a message from AgEnD, so it stopped. This usually means the Runtime and AgEnD are different versions, or the address points at something that is not this AgEnD. Download the Windows Runtime again from AgEnD Settings -> Runtime, extract it, and double-click connect-agend.bat.";
|
|
25
|
-
case "rejected": return `AgEnD rejected a message from this Runtime${reason.detail ? ` (${reason.detail})` : ""}. Usual causes: leftover data from pairing this profile with a different AgEnD server, or a Runtime/AgEnD version mismatch. If this profile was used with another AgEnD server, ${REPAIR} If pairing reports an unfinished job from another pairing, follow that message: check that no CLI it started is still running, delete jobs.json in the profile folder, then pair again. Otherwise download the Windows Runtime again from AgEnD Settings -> Runtime, extract it, and double-click connect-agend.bat.`;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const MAX_FRAME = 256 * 1024;
|
|
29
|
-
const MAX_TOOL = 64 * 1024;
|
|
30
|
-
function object(value) { return !!value && typeof value === "object" && !Array.isArray(value); }
|
|
31
|
-
function message(error) { return error instanceof Error ? error.message.slice(0, 1000) : "Runtime operation failed"; }
|
|
32
|
-
function checkedRun(value) {
|
|
33
|
-
if (!object(value) || Object.keys(value).some(key => !["task", "resumeSessionId", "context", "mcp"].includes(key)))
|
|
34
|
-
throw new Error("Invalid runtime run payload");
|
|
35
|
-
const task = validateNativeTask(value.task);
|
|
36
|
-
if (value.resumeSessionId !== undefined && !validNativeSessionId(task.cli, value.resumeSessionId))
|
|
37
|
-
throw new Error("Invalid native conversation ID");
|
|
38
|
-
if (value.context !== undefined && (typeof value.context !== "string" || value.context.length > 2000 || value.context.includes("\0")))
|
|
39
|
-
throw new Error("Invalid native context");
|
|
40
|
-
if (value.mcp !== undefined && (!object(value.mcp) || Object.keys(value.mcp).some(key => key !== "tools")
|
|
41
|
-
|| !Array.isArray(value.mcp.tools) || !value.mcp.tools.length || value.mcp.tools.length > 64
|
|
42
|
-
|| value.mcp.tools.some(tool => typeof tool !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(tool))))
|
|
43
|
-
throw new Error("Invalid scoped MCP request");
|
|
44
|
-
return { task, resumeSessionId: value.resumeSessionId, context: value.context,
|
|
45
|
-
mcp: value.mcp };
|
|
46
|
-
}
|
|
47
|
-
function jsonBody(req) {
|
|
48
|
-
return new Promise((accept, reject) => {
|
|
49
|
-
let text = "", bytes = 0;
|
|
50
|
-
req.setTimeout(10_000, () => { reject(new Error("MCP request timed out")); req.destroy(); });
|
|
51
|
-
req.setEncoding("utf8");
|
|
52
|
-
req.on("data", (part) => { bytes += Buffer.byteLength(part); if (bytes > MAX_TOOL) {
|
|
53
|
-
reject(new Error("MCP request is too large"));
|
|
54
|
-
req.destroy();
|
|
55
|
-
}
|
|
56
|
-
else
|
|
57
|
-
text += part; });
|
|
58
|
-
req.on("error", reject);
|
|
59
|
-
req.on("end", () => { try {
|
|
60
|
-
accept(JSON.parse(text));
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
reject(new Error("Invalid MCP JSON"));
|
|
64
|
-
} });
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
export class RuntimeClient {
|
|
68
|
-
options;
|
|
69
|
-
bootId = randomUUID();
|
|
70
|
-
runtimeInfo;
|
|
71
|
-
bridge;
|
|
72
|
-
socket = null;
|
|
73
|
-
welcomed = false;
|
|
74
|
-
stopped = true;
|
|
75
|
-
closed = false;
|
|
76
|
-
unlock = null;
|
|
77
|
-
reconnectTimer = null;
|
|
78
|
-
reconnectAttempt = 0;
|
|
79
|
-
graceTimer = null;
|
|
80
|
-
pollTimer = null;
|
|
81
|
-
credentials = null;
|
|
82
|
-
startupRotation = null;
|
|
83
|
-
paneHost = null;
|
|
84
|
-
paneOpening = null;
|
|
85
|
-
machinePaneLimit = 4;
|
|
86
|
-
paneEpoch = randomUUID();
|
|
87
|
-
active = new Set();
|
|
88
|
-
snapshots = new Map();
|
|
89
|
-
pendingPaneTools = new Map();
|
|
90
|
-
pendingTools = new Map();
|
|
91
|
-
mcpTokens = new Map();
|
|
92
|
-
mcpServer = null;
|
|
93
|
-
mcpOpening = null;
|
|
94
|
-
mcpPort = 0;
|
|
95
|
-
inventory = null;
|
|
96
|
-
stoppedListeners = new Set();
|
|
97
|
-
/** Set only when AgEnD ended the connection and the person must act; a local stop (Ctrl+C) leaves it undefined. */
|
|
98
|
-
stopReason;
|
|
99
|
-
/** The socket this Runtime itself closed with 1008 because it could not read AgEnD's frame; that is not AgEnD refusing us. */
|
|
100
|
-
selfClosed = null;
|
|
101
|
-
constructor(options) {
|
|
102
|
-
this.options = options;
|
|
103
|
-
this.runtimeInfo = readRuntimeInfo({ panes: process.platform === "win32" || !!options.createPaneHost || !!options.openPaneLink });
|
|
104
|
-
this.bridge = options.bridge ?? new WindowsCliBridge(nativeWindowsTransport, join(options.store.directory, WINDOWS_CLI_INVENTORY_FILE));
|
|
105
|
-
}
|
|
106
|
-
report(text) { this.options.report?.(text); }
|
|
107
|
-
online() { return this.welcomed && this.socket?.readyState === WebSocket.OPEN; }
|
|
108
|
-
waitUntilStopped() { return this.stopped && this.closed ? Promise.resolve() : new Promise(done => this.stoppedListeners.add(done)); }
|
|
109
|
-
async start() {
|
|
110
|
-
if (!this.stopped)
|
|
111
|
-
return;
|
|
112
|
-
let credentials = this.options.store.credentials();
|
|
113
|
-
if (!credentials)
|
|
114
|
-
throw new Error("Pair this runtime before connecting");
|
|
115
|
-
validateRuntimeServer(credentials.server);
|
|
116
|
-
this.stopped = false;
|
|
117
|
-
this.closed = false;
|
|
118
|
-
this.stopReason = undefined;
|
|
119
|
-
try {
|
|
120
|
-
const systemBootId = process.platform === "win32" ? await readPaneSystemBootId() : undefined;
|
|
121
|
-
if (this.stopped)
|
|
122
|
-
throw Error("Runtime start was cancelled");
|
|
123
|
-
const reused = process.platform === "win32" ? await reusedRuntimeLockPid(this.options.store.lockHolder()) : undefined;
|
|
124
|
-
if (this.stopped)
|
|
125
|
-
throw Error("Runtime start was cancelled");
|
|
126
|
-
this.unlock = this.options.store.lock(this.bootId, systemBootId, reused);
|
|
127
|
-
if (credentials.pendingCredential) {
|
|
128
|
-
const rotating = this.startupRotation = rotateRuntimeCredentials({ store: this.options.store });
|
|
129
|
-
try {
|
|
130
|
-
credentials = await rotating;
|
|
131
|
-
}
|
|
132
|
-
finally {
|
|
133
|
-
if (this.startupRotation === rotating)
|
|
134
|
-
this.startupRotation = null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (this.stopped)
|
|
138
|
-
throw Error("Runtime start was cancelled");
|
|
139
|
-
this.options.store.adoptMachine(credentials.machineId);
|
|
140
|
-
this.options.store.recoverInterrupted();
|
|
141
|
-
this.credentials = credentials;
|
|
142
|
-
// Connect immediately, then publish the last administrator detection from the private profile.
|
|
143
|
-
// A cached read starts no CLI. Only an explicit probe command with force:true performs detection.
|
|
144
|
-
this.connect();
|
|
145
|
-
// A foreground runtime must remain alive while an idle connection is down. Promises and unref'ed retry
|
|
146
|
-
// timers do not keep Node running after the last socket closes; stop() owns and clears this liveness ref.
|
|
147
|
-
this.pollTimer = setInterval(() => this.poll(), this.options.pollMs ?? 250);
|
|
148
|
-
void this.refreshInventory().catch(() => this.report("CLI discovery failed; refresh it from AgEnD after checking the local installation."));
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
this.stopped = true;
|
|
152
|
-
this.unlock?.();
|
|
153
|
-
this.unlock = null;
|
|
154
|
-
throw error;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
connect() {
|
|
158
|
-
if (this.stopped || !this.credentials)
|
|
159
|
-
return;
|
|
160
|
-
const url = validateRuntimeServer(this.credentials.server);
|
|
161
|
-
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
162
|
-
url.pathname = "/runtime/v1/connect";
|
|
163
|
-
const socket = this.socket = this.options.socketFactory?.(url.href, this.credentials.credential)
|
|
164
|
-
?? new WebSocket(url.href, { headers: { Authorization: `Bearer ${this.credentials.credential}` }, followRedirects: false,
|
|
165
|
-
maxPayload: MAX_FRAME, handshakeTimeout: 15_000, perMessageDeflate: false });
|
|
166
|
-
this.welcomed = false;
|
|
167
|
-
this.paneEpoch = randomUUID();
|
|
168
|
-
socket.on("open", () => {
|
|
169
|
-
if (this.stopped || this.socket !== socket) {
|
|
170
|
-
socket.close();
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
this.send({ v: 1, type: "hello", bootId: this.bootId, name: this.credentials.name, platform: process.platform, runtimeInfo: this.runtimeInfo,
|
|
174
|
-
...(process.platform === "win32" || this.options.createPaneHost || this.options.openPaneLink ? { paneProtocol: 1 } : {}),
|
|
175
|
-
...(this.inventory ? { inventory: this.inventory } : {}) });
|
|
176
|
-
});
|
|
177
|
-
socket.on("message", (bytes, binary) => {
|
|
178
|
-
const size = Array.isArray(bytes) ? bytes.reduce((sum, part) => sum + part.byteLength, 0) : bytes.byteLength;
|
|
179
|
-
if (binary || size > MAX_FRAME || this.socket !== socket) {
|
|
180
|
-
this.selfClosed = socket;
|
|
181
|
-
socket.close(1008, "Invalid runtime frame");
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
void this.receive(bytes.toString()).catch(() => { this.selfClosed = socket; socket.close(1008, "Invalid runtime protocol"); });
|
|
185
|
-
});
|
|
186
|
-
socket.on("error", () => { });
|
|
187
|
-
socket.on("unexpected-response", (_req, response) => {
|
|
188
|
-
response.resume();
|
|
189
|
-
if (response.statusCode === 401 || response.statusCode === 403) {
|
|
190
|
-
this.report("Runtime credential was refused. Re-pair after the machine is authorized.");
|
|
191
|
-
this.stopReason = { kind: "refused", ...(response.statusCode === 403 ? { detail: "HTTP 403" } : {}) };
|
|
192
|
-
void this.stop();
|
|
193
|
-
}
|
|
194
|
-
else
|
|
195
|
-
socket.terminate();
|
|
196
|
-
});
|
|
197
|
-
socket.on("close", (code, reason) => {
|
|
198
|
-
if (this.socket !== socket)
|
|
199
|
-
return;
|
|
200
|
-
this.socket = null;
|
|
201
|
-
this.welcomed = false;
|
|
202
|
-
this.paneEpoch = randomUUID();
|
|
203
|
-
if (this.paneHost && "connectionChanged" in this.paneHost)
|
|
204
|
-
this.paneHost.connectionChanged();
|
|
205
|
-
this.rejectTools();
|
|
206
|
-
if (this.stopped)
|
|
207
|
-
return;
|
|
208
|
-
if (code === 1008) {
|
|
209
|
-
const why = reason.toString().replace(/[^ -~]/g, "?").slice(0, 120);
|
|
210
|
-
this.report(this.selfClosed === socket ? "This Runtime could not read a message from AgEnD and closed the connection." : `AgEnD closed the connection (code 1008${why ? `: ${why}` : ""}).`);
|
|
211
|
-
this.stopReason = this.selfClosed === socket ? { kind: "incompatible" } : { kind: why === "Machine revoked" ? "revoked" : why === "Connection replaced" ? "replaced" : "rejected", ...(why ? { detail: why } : {}) };
|
|
212
|
-
void this.stop({ retirePanes: why === "Machine revoked" });
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
this.report("Disconnected. Existing execution is not replayed; reconnecting…");
|
|
216
|
-
if (!this.graceTimer)
|
|
217
|
-
this.graceTimer = setTimeout(() => {
|
|
218
|
-
this.graceTimer = null;
|
|
219
|
-
for (const id of this.active) {
|
|
220
|
-
try {
|
|
221
|
-
this.bridge.cancel(id);
|
|
222
|
-
}
|
|
223
|
-
catch { /* state reconciles in poll */ }
|
|
224
|
-
}
|
|
225
|
-
this.report("The coordinator remained disconnected; cancellation was requested for the active execution.");
|
|
226
|
-
}, this.options.disconnectGraceMs ?? 45_000);
|
|
227
|
-
this.graceTimer.unref?.();
|
|
228
|
-
const base = Math.min(30_000, 2000 * 2 ** Math.min(this.reconnectAttempt++, 4));
|
|
229
|
-
const delay = this.options.reconnectMs ?? Math.min(30_000, Math.round(base * (0.75 + Math.random() * 0.5)));
|
|
230
|
-
this.reconnectTimer = setTimeout(() => { this.reconnectTimer = null; this.connect(); }, delay);
|
|
231
|
-
this.reconnectTimer.unref?.();
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
send(value) {
|
|
235
|
-
if (this.socket?.readyState !== WebSocket.OPEN)
|
|
236
|
-
return;
|
|
237
|
-
const frame = JSON.stringify(value);
|
|
238
|
-
if (Buffer.byteLength(frame) > MAX_FRAME)
|
|
239
|
-
throw new Error("Runtime frame limit exceeded");
|
|
240
|
-
if (this.socket.bufferedAmount > 2 * MAX_FRAME) {
|
|
241
|
-
this.socket.close(1013, "Runtime backpressure");
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
this.socket.send(frame);
|
|
245
|
-
}
|
|
246
|
-
async receive(text) {
|
|
247
|
-
const value = JSON.parse(text);
|
|
248
|
-
if (!object(value) || value.v !== 1 || typeof value.type !== "string")
|
|
249
|
-
throw new Error("Unsupported runtime protocol");
|
|
250
|
-
if (value.type === "welcome") {
|
|
251
|
-
if (value.machineId !== this.credentials?.machineId || !Number.isSafeInteger(value.generation))
|
|
252
|
-
throw new Error("Runtime machine identity mismatch");
|
|
253
|
-
this.welcomed = true;
|
|
254
|
-
this.reconnectAttempt = 0;
|
|
255
|
-
if (this.graceTimer) {
|
|
256
|
-
clearTimeout(this.graceTimer);
|
|
257
|
-
this.graceTimer = null;
|
|
258
|
-
}
|
|
259
|
-
this.report("Connected to AgEnD.");
|
|
260
|
-
for (const job of this.options.store.list())
|
|
261
|
-
this.publish(job);
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
if (value.type === "revoked") {
|
|
265
|
-
this.report("This machine was revoked by AgEnD.");
|
|
266
|
-
this.stopReason = { kind: "revoked" };
|
|
267
|
-
await this.stop({ retirePanes: true });
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
if (!this.welcomed)
|
|
271
|
-
throw new Error("Runtime handshake is incomplete");
|
|
272
|
-
if (value.type === "ping") {
|
|
273
|
-
this.send({ v: 1, type: "pong" });
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
if (value.type === "tool.result") {
|
|
277
|
-
if (typeof value.id !== "string")
|
|
278
|
-
throw new Error("Invalid tool reply");
|
|
279
|
-
const pending = this.pendingTools.get(value.id);
|
|
280
|
-
if (!pending)
|
|
281
|
-
return;
|
|
282
|
-
clearTimeout(pending.timer);
|
|
283
|
-
this.pendingTools.delete(value.id);
|
|
284
|
-
if (value.ok === true)
|
|
285
|
-
pending.accept(value.result);
|
|
286
|
-
else
|
|
287
|
-
pending.reject(new Error("AgEnD MCP request was refused"));
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
if (value.type === "pane.tool.result") {
|
|
291
|
-
if (Object.keys(value).some(key => !["v", "type", "id", "ok", "result"].includes(key)) || !validWindowsAgentId(value.id) || typeof value.ok !== "boolean")
|
|
292
|
-
throw Error("Invalid pane MCP reply");
|
|
293
|
-
const pending = this.pendingPaneTools.get(value.id);
|
|
294
|
-
if (!pending)
|
|
295
|
-
return;
|
|
296
|
-
this.pendingPaneTools.delete(value.id);
|
|
297
|
-
clearTimeout(pending.timer);
|
|
298
|
-
if (value.ok)
|
|
299
|
-
pending.accept(value.result);
|
|
300
|
-
else
|
|
301
|
-
pending.reject(Error("Pane MCP request was refused"));
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
if (value.type === "pane.request") {
|
|
305
|
-
if (Object.keys(value).some(key => !["v", "type", "id", "maxAgents", "request"].includes(key))
|
|
306
|
-
|| typeof value.id !== "string" || !validWindowsAgentId(value.id) || !Number.isInteger(value.maxAgents)
|
|
307
|
-
|| value.maxAgents < 1 || value.maxAgents > 16)
|
|
308
|
-
throw Error("Invalid pane transport envelope");
|
|
309
|
-
const request = validateRuntimePaneRequest(value.request);
|
|
310
|
-
this.machinePaneLimit = value.maxAgents;
|
|
311
|
-
const epoch = this.paneEpoch;
|
|
312
|
-
try {
|
|
313
|
-
const host = await this.panes();
|
|
314
|
-
const result = await host.request(request, () => epoch === this.paneEpoch && this.online());
|
|
315
|
-
if (request.action === "shutdown") {
|
|
316
|
-
validateRuntimePaneShutdown(result, request.hostBootId);
|
|
317
|
-
// Explicit coordinator disable, not a disconnect: the next enabled request discovers a new host boot.
|
|
318
|
-
// Retire this cache before sending the reply, including when that reply is lost under backpressure.
|
|
319
|
-
if (this.paneHost === host) {
|
|
320
|
-
this.paneHost = null;
|
|
321
|
-
this.paneOpening = null;
|
|
322
|
-
}
|
|
323
|
-
await host.stop();
|
|
324
|
-
}
|
|
325
|
-
this.send({ v: 1, type: "pane.response", id: value.id, ok: true, result });
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
this.send({ v: 1, type: "pane.response", id: value.id, ok: false, error: message(error) });
|
|
329
|
-
}
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
if (value.type !== "request" || typeof value.id !== "string" || !/^[A-Za-z0-9._:-]{1,128}$/.test(value.id)
|
|
333
|
-
|| typeof value.operation !== "string" || !object(value.payload))
|
|
334
|
-
throw new Error("Invalid runtime request");
|
|
335
|
-
const command = value;
|
|
336
|
-
try {
|
|
337
|
-
this.send({ v: 1, type: "response", id: command.id, ok: true, result: await this.operation(command.operation, command.payload) });
|
|
338
|
-
}
|
|
339
|
-
catch (error) {
|
|
340
|
-
this.send({ v: 1, type: "response", id: command.id, ok: false, error: message(error) });
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
publish(job) { if (this.online())
|
|
344
|
-
this.send({ v: 1, type: "task", seq: job.seq, task: job.task }); }
|
|
345
|
-
panes() {
|
|
346
|
-
// A detached host link is not a live cache. Rediscover on the next independent request; never replay this RPC.
|
|
347
|
-
if (this.paneHost && "connected" in this.paneHost && !this.paneHost.connected()) {
|
|
348
|
-
this.paneHost = null;
|
|
349
|
-
this.paneOpening = null;
|
|
350
|
-
}
|
|
351
|
-
if (!this.paneOpening) {
|
|
352
|
-
const output = snapshot => { if (this.online())
|
|
353
|
-
this.send({ v: 1, type: "pane.output", snapshot }); };
|
|
354
|
-
if (this.options.createPaneHost)
|
|
355
|
-
this.paneOpening = import("./runtime-pane-store.js").then(({ RuntimePaneStore }) => {
|
|
356
|
-
const store = new RuntimePaneStore(join(this.options.store.directory, "panes"));
|
|
357
|
-
store.recoverInterrupted();
|
|
358
|
-
return this.paneHost = this.options.createPaneHost({ store, bootId: this.bootId, online: () => !this.stopped && this.online(), maxAgents: () => this.machinePaneLimit, output });
|
|
359
|
-
});
|
|
360
|
-
else
|
|
361
|
-
this.paneOpening = import("./runtime-pane-link.js").then(({ RuntimePaneLink }) => (this.options.openPaneLink ?? RuntimePaneLink.open.bind(RuntimePaneLink))({
|
|
362
|
-
directory: this.options.store.directory, server: this.credentials.server, machineId: this.credentials.machineId,
|
|
363
|
-
online: () => !this.stopped && this.online(), maxAgents: () => this.machinePaneLimit, epoch: () => this.paneEpoch, output, mcp: (body, current) => this.paneMcp(body, current),
|
|
364
|
-
})).then(host => this.paneHost = host);
|
|
365
|
-
const opening = this.paneOpening;
|
|
366
|
-
void opening.catch(() => { if (this.paneOpening === opening)
|
|
367
|
-
this.paneOpening = null; });
|
|
368
|
-
}
|
|
369
|
-
return this.paneOpening;
|
|
370
|
-
}
|
|
371
|
-
paneMcp(raw, current) {
|
|
372
|
-
const body = validatePaneMcpBody(raw), epoch = this.paneEpoch;
|
|
373
|
-
if (!current() || !this.online() || this.pendingPaneTools.size >= 32)
|
|
374
|
-
return Promise.reject(Error("Pane MCP transport is unavailable"));
|
|
375
|
-
const id = randomUUID();
|
|
376
|
-
return new Promise((accept, reject) => {
|
|
377
|
-
const timer = setTimeout(() => { this.pendingPaneTools.delete(id); reject(Error("Pane MCP response is unconfirmed")); }, 85_000);
|
|
378
|
-
timer.unref();
|
|
379
|
-
this.pendingPaneTools.set(id, { timer, reject, accept: value => current() && this.online() && this.paneEpoch === epoch ? accept(value) : reject(Error("Pane MCP lease expired")) });
|
|
380
|
-
try {
|
|
381
|
-
this.send({ v: 1, type: "pane.tool.request", id, body });
|
|
382
|
-
}
|
|
383
|
-
catch {
|
|
384
|
-
this.pendingPaneTools.delete(id);
|
|
385
|
-
clearTimeout(timer);
|
|
386
|
-
reject(Error("Pane MCP response is unconfirmed"));
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
update(task) {
|
|
391
|
-
if (this.closed)
|
|
392
|
-
return;
|
|
393
|
-
const serialized = JSON.stringify(task);
|
|
394
|
-
if (this.snapshots.get(task.id) === serialized)
|
|
395
|
-
return;
|
|
396
|
-
try {
|
|
397
|
-
const job = this.options.store.update(task);
|
|
398
|
-
this.snapshots.set(task.id, serialized);
|
|
399
|
-
this.publish(job);
|
|
400
|
-
if (task.finishedAt) {
|
|
401
|
-
this.active.delete(task.id);
|
|
402
|
-
this.closeMcp(task.id);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
catch {
|
|
406
|
-
// A process whose state could not be committed must not continue accepting commands.
|
|
407
|
-
this.report("Runtime execution state could not be saved. Stop and inspect the private runtime profile.");
|
|
408
|
-
try {
|
|
409
|
-
this.bridge.cancel(task.id);
|
|
410
|
-
}
|
|
411
|
-
catch { /* leave durable accepted state blocked */ }
|
|
412
|
-
this.socket?.close(1011, "Runtime storage failed");
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
poll() { for (const id of this.active) {
|
|
416
|
-
const task = this.bridge.get(id);
|
|
417
|
-
if (task)
|
|
418
|
-
this.update(task);
|
|
419
|
-
} }
|
|
420
|
-
async refreshInventory(force = false) {
|
|
421
|
-
const inventory = await this.bridge.probe({ force });
|
|
422
|
-
this.inventory = inventory;
|
|
423
|
-
if (this.online())
|
|
424
|
-
this.send({ v: 1, type: "inventory", inventory });
|
|
425
|
-
return inventory;
|
|
426
|
-
}
|
|
427
|
-
/** Testable command surface. Mutation identity is committed before calling the native bridge. */
|
|
428
|
-
async operation(operation, payload) {
|
|
429
|
-
if (operation === "probe") {
|
|
430
|
-
if (Object.keys(payload).some(key => key !== "force") || (payload.force !== undefined && typeof payload.force !== "boolean"))
|
|
431
|
-
throw new Error("Invalid discovery request");
|
|
432
|
-
return this.refreshInventory(payload.force === true);
|
|
433
|
-
}
|
|
434
|
-
if (operation === "workspace") {
|
|
435
|
-
if (Object.keys(payload).some(key => key !== "agentId") || !validWindowsAgentId(payload.agentId))
|
|
436
|
-
throw new Error("Invalid workspace request");
|
|
437
|
-
return { agentId: payload.agentId, cwd: await this.bridge.prepareWorkspace(payload.agentId) };
|
|
438
|
-
}
|
|
439
|
-
if (operation === "reconcile") {
|
|
440
|
-
if (Object.keys(payload).length)
|
|
441
|
-
throw new Error("Invalid reconciliation request");
|
|
442
|
-
return { jobs: this.options.store.list().map(row => ({ seq: row.seq, task: row.task })) };
|
|
443
|
-
}
|
|
444
|
-
if (operation === "cancel" || operation === "recover") {
|
|
445
|
-
if (typeof payload.runId !== "string" || Object.keys(payload).some(key => !["runId", ...(operation === "recover" ? ["confirmedStopped", "original"] : [])].includes(key)))
|
|
446
|
-
throw new Error("Invalid execution operation");
|
|
447
|
-
const stored = this.options.store.get(payload.runId);
|
|
448
|
-
if (operation === "recover") {
|
|
449
|
-
if (this.active.has(payload.runId))
|
|
450
|
-
throw new Error("The native execution is still connected; wait for cancellation");
|
|
451
|
-
if (payload.confirmedStopped !== true)
|
|
452
|
-
throw new Error("Confirm the execution stopped before recovery");
|
|
453
|
-
const original = payload.original === undefined ? null : checkedRun(payload.original);
|
|
454
|
-
if (original && original.task.requestId !== payload.runId)
|
|
455
|
-
throw new Error("Recovery execution identity does not match the original run");
|
|
456
|
-
const digest = original ? runtimeJobDigest(original) : null;
|
|
457
|
-
if (stored && digest && stored.digest !== digest)
|
|
458
|
-
throw new Error("Recovery arguments do not match the accepted execution");
|
|
459
|
-
if (!stored) {
|
|
460
|
-
if (!original || !digest)
|
|
461
|
-
throw new Error("Unknown execution recovery needs its trusted original run");
|
|
462
|
-
if (this.active.size)
|
|
463
|
-
throw new Error("Wait for the active native execution before recovery");
|
|
464
|
-
const task = original.task;
|
|
465
|
-
// The coordinator may have durably submitted a run that never reached this client. Explicit manual
|
|
466
|
-
// confirmation creates a terminal tombstone, never an execution, so a delayed retry cannot launch it.
|
|
467
|
-
const accepted = this.options.store.accept({ id: task.requestId, cli: task.cli, cwd: task.cwd, sandbox: task.sandbox,
|
|
468
|
-
...(task.model ? { model: task.model } : {}), status: "failed", startedAt: Date.now(), finishedAt: Date.now(),
|
|
469
|
-
outcomeConfirmed: true, output: "", error: "The unconfirmed execution was manually confirmed stopped before local acceptance; it will not be replayed." }, digest);
|
|
470
|
-
this.publish(accepted.job);
|
|
471
|
-
return accepted.job.task;
|
|
472
|
-
}
|
|
473
|
-
if (stored.task.finishedAt && stored.task.outcomeConfirmed === true)
|
|
474
|
-
return stored.task;
|
|
475
|
-
this.bridge.releaseUnknown(payload.runId);
|
|
476
|
-
const job = this.options.store.recover(payload.runId, true);
|
|
477
|
-
this.publish(job);
|
|
478
|
-
return job.task;
|
|
479
|
-
}
|
|
480
|
-
if (!stored)
|
|
481
|
-
throw new Error("Runtime execution not found");
|
|
482
|
-
if (!this.active.has(payload.runId))
|
|
483
|
-
return stored.task;
|
|
484
|
-
const task = this.bridge.cancel(payload.runId);
|
|
485
|
-
this.update(task);
|
|
486
|
-
return task;
|
|
487
|
-
}
|
|
488
|
-
if (operation !== "run")
|
|
489
|
-
throw new Error("Unknown runtime operation");
|
|
490
|
-
const run = checkedRun(payload), task = run.task;
|
|
491
|
-
const digest = runtimeJobDigest(run);
|
|
492
|
-
const accepted = this.options.store.accept({ id: task.requestId, cli: task.cli, cwd: task.cwd, sandbox: task.sandbox,
|
|
493
|
-
...(task.model ? { model: task.model } : {}), status: "starting", startedAt: Date.now(), output: "" }, digest);
|
|
494
|
-
if (accepted.duplicate)
|
|
495
|
-
return accepted.job.task;
|
|
496
|
-
this.publish(accepted.job);
|
|
497
|
-
try {
|
|
498
|
-
const mcp = payload.mcp ? await this.openMcp(task.requestId, payload.mcp.tools) : undefined;
|
|
499
|
-
if (this.stopped || !this.online())
|
|
500
|
-
throw new Error("Runtime disconnected before native execution started");
|
|
501
|
-
this.active.add(task.requestId);
|
|
502
|
-
const initial = this.bridge.start(task, () => !this.stopped && this.online(), {
|
|
503
|
-
...(payload.resumeSessionId ? { resumeSessionId: payload.resumeSessionId } : {}),
|
|
504
|
-
...(payload.context ? { context: payload.context } : {}), ...(mcp ? { mcp } : {}),
|
|
505
|
-
onSettled: settled => this.update(settled),
|
|
506
|
-
});
|
|
507
|
-
this.update(initial);
|
|
508
|
-
return this.options.store.get(task.requestId).task;
|
|
509
|
-
}
|
|
510
|
-
catch (error) {
|
|
511
|
-
this.active.delete(task.requestId);
|
|
512
|
-
this.closeMcp(task.requestId);
|
|
513
|
-
const failed = { ...accepted.job.task, status: "failed", error: message(error), finishedAt: Date.now(), outcomeConfirmed: true };
|
|
514
|
-
this.update(failed);
|
|
515
|
-
return failed;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
async openMcp(runId, tools) {
|
|
519
|
-
if (!this.mcpOpening)
|
|
520
|
-
this.mcpOpening = new Promise((accept, reject) => {
|
|
521
|
-
const server = this.mcpServer = createServer((req, res) => {
|
|
522
|
-
const reply = (status, value) => { if (!res.writableEnded && !res.destroyed) {
|
|
523
|
-
res.writeHead(status, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
524
|
-
res.end(JSON.stringify(value));
|
|
525
|
-
} };
|
|
526
|
-
const header = req.headers["x-agend-native-token"];
|
|
527
|
-
const entry = typeof header === "string" && /^[a-f0-9]{64}$/.test(header) ? this.mcpTokens.get(header) : undefined;
|
|
528
|
-
if (req.method !== "POST" || req.url !== "/agent" || req.headers.origin !== undefined || req.headers.cookie !== undefined
|
|
529
|
-
|| !["127.0.0.1", "::1", "::ffff:127.0.0.1"].includes(req.socket.remoteAddress ?? "") || !entry
|
|
530
|
-
|| !this.active.has(entry.runId) || !this.online()) {
|
|
531
|
-
req.resume();
|
|
532
|
-
reply(403, { error: "Runtime MCP capability is unavailable" });
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
void jsonBody(req).then(async (body) => {
|
|
536
|
-
if (!object(body) || body.op !== "native-mcp" || !["tools/list", "tools/call"].includes(String(body.method))
|
|
537
|
-
|| !object(body.params) || Object.keys(body).some(key => !["op", "method", "params", "callId"].includes(key)))
|
|
538
|
-
throw new Error("Invalid runtime MCP request");
|
|
539
|
-
if (body.method === "tools/call" && (!entry.tools.includes(String(body.params.name)) || !object(body.params.arguments)
|
|
540
|
-
|| typeof body.callId !== "string" || !/^[A-Za-z0-9._:-]{1,128}$/.test(body.callId)))
|
|
541
|
-
throw new Error("Runtime MCP tool is unavailable");
|
|
542
|
-
const result = await this.toolCall(entry.runId, body);
|
|
543
|
-
if (!this.active.has(entry.runId) || !this.online()) {
|
|
544
|
-
reply(401, { error: "Runtime MCP capability expired" });
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
if (Buffer.byteLength(JSON.stringify(result) ?? "") > MAX_TOOL)
|
|
548
|
-
throw new Error("Runtime MCP result is too large");
|
|
549
|
-
reply(200, result);
|
|
550
|
-
}).catch(() => reply(403, { error: "Runtime MCP request was refused or its execution expired" }));
|
|
551
|
-
});
|
|
552
|
-
server.on("error", reject);
|
|
553
|
-
server.listen(0, "127.0.0.1", () => { const address = server.address(); if (!address || typeof address === "string") {
|
|
554
|
-
reject(new Error("Runtime MCP could not bind"));
|
|
555
|
-
return;
|
|
556
|
-
} this.mcpPort = address.port; accept(address.port); });
|
|
557
|
-
});
|
|
558
|
-
await this.mcpOpening;
|
|
559
|
-
const token = randomBytes(32).toString("hex");
|
|
560
|
-
this.mcpTokens.set(token, { runId, tools: [...tools] });
|
|
561
|
-
return { endpoint: `http://127.0.0.1:${this.mcpPort}/agent`, token, tools: [...tools] };
|
|
562
|
-
}
|
|
563
|
-
closeMcp(runId) { for (const [token, entry] of this.mcpTokens)
|
|
564
|
-
if (entry.runId === runId)
|
|
565
|
-
this.mcpTokens.delete(token); }
|
|
566
|
-
toolCall(runId, body) {
|
|
567
|
-
if (!this.online())
|
|
568
|
-
return Promise.reject(new Error("Runtime is disconnected"));
|
|
569
|
-
if (this.pendingTools.size >= 64)
|
|
570
|
-
return Promise.reject(new Error("Runtime MCP call capacity reached"));
|
|
571
|
-
const id = randomUUID();
|
|
572
|
-
return new Promise((accept, reject) => {
|
|
573
|
-
const timer = setTimeout(() => { this.pendingTools.delete(id); reject(new Error("AgEnD MCP request timed out")); }, 90_000);
|
|
574
|
-
timer.unref?.();
|
|
575
|
-
this.pendingTools.set(id, { accept, reject, timer });
|
|
576
|
-
this.send({ v: 1, type: "tool.call", id, runId, body });
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
rejectTools() {
|
|
580
|
-
for (const pending of this.pendingPaneTools.values()) {
|
|
581
|
-
clearTimeout(pending.timer);
|
|
582
|
-
pending.reject(Error("Pane MCP disconnected; no call was replayed"));
|
|
583
|
-
}
|
|
584
|
-
this.pendingPaneTools.clear();
|
|
585
|
-
for (const pending of this.pendingTools.values()) {
|
|
586
|
-
clearTimeout(pending.timer);
|
|
587
|
-
pending.reject(new Error("Runtime disconnected"));
|
|
588
|
-
}
|
|
589
|
-
this.pendingTools.clear();
|
|
590
|
-
}
|
|
591
|
-
async stop(options = {}) {
|
|
592
|
-
if (this.stopped)
|
|
593
|
-
return;
|
|
594
|
-
this.stopped = true;
|
|
595
|
-
this.welcomed = false;
|
|
596
|
-
if (this.reconnectTimer)
|
|
597
|
-
clearTimeout(this.reconnectTimer);
|
|
598
|
-
if (this.graceTimer)
|
|
599
|
-
clearTimeout(this.graceTimer);
|
|
600
|
-
if (this.pollTimer)
|
|
601
|
-
clearInterval(this.pollTimer);
|
|
602
|
-
this.reconnectTimer = null;
|
|
603
|
-
this.graceTimer = null;
|
|
604
|
-
this.pollTimer = null;
|
|
605
|
-
this.rejectTools();
|
|
606
|
-
this.mcpTokens.clear();
|
|
607
|
-
this.bridge.close();
|
|
608
|
-
const socket = this.socket;
|
|
609
|
-
this.socket = null;
|
|
610
|
-
if (socket) {
|
|
611
|
-
socket.close();
|
|
612
|
-
if (socket.readyState !== WebSocket.CLOSED)
|
|
613
|
-
socket.terminate();
|
|
614
|
-
}
|
|
615
|
-
// A cancelled start may still finish its durable credential write. Do not release the profile to another writer.
|
|
616
|
-
await this.startupRotation?.catch(() => { });
|
|
617
|
-
await this.paneOpening?.then(async (host) => {
|
|
618
|
-
try {
|
|
619
|
-
if (options.retirePanes && "retireOwned" in host)
|
|
620
|
-
await host.retireOwned();
|
|
621
|
-
}
|
|
622
|
-
finally {
|
|
623
|
-
await host.stop();
|
|
624
|
-
}
|
|
625
|
-
}).catch(() => this.report("Pane cleanup is unconfirmed; its durable reservations remain held."));
|
|
626
|
-
// Keep the profile lock until cancellation is confirmed or the journal is explicitly marked uncertain.
|
|
627
|
-
const deadline = Date.now() + 5000;
|
|
628
|
-
while (this.active.size && Date.now() < deadline) {
|
|
629
|
-
this.poll();
|
|
630
|
-
if (!this.active.size)
|
|
631
|
-
break;
|
|
632
|
-
await new Promise(done => setTimeout(done, 50));
|
|
633
|
-
}
|
|
634
|
-
for (const id of this.active) {
|
|
635
|
-
const old = this.options.store.get(id);
|
|
636
|
-
if (old)
|
|
637
|
-
this.update({ ...old.task, status: "failed", finishedAt: Date.now(), outcomeConfirmed: false,
|
|
638
|
-
error: "Runtime stopped before native process shutdown was confirmed. Inspect processes before recovery." });
|
|
639
|
-
}
|
|
640
|
-
this.closed = true;
|
|
641
|
-
if (this.mcpServer) {
|
|
642
|
-
const server = this.mcpServer;
|
|
643
|
-
this.mcpServer = null;
|
|
644
|
-
server.closeAllConnections();
|
|
645
|
-
await new Promise(done => server.close(() => done()));
|
|
646
|
-
}
|
|
647
|
-
this.unlock?.();
|
|
648
|
-
this.unlock = null;
|
|
649
|
-
for (const done of this.stoppedListeners)
|
|
650
|
-
done();
|
|
651
|
-
this.stoppedListeners.clear();
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
async function post(server, path, body, signal, credential) {
|
|
655
|
-
const response = await fetch(new URL(path, server), { method: "POST", redirect: "error", headers: { "Content-Type": "application/json", ...(credential ? { Authorization: `Bearer ${credential}` } : {}) },
|
|
656
|
-
body: JSON.stringify(body), signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(15_000)]) : AbortSignal.timeout(15_000) });
|
|
657
|
-
let text = "", bytes = 0;
|
|
658
|
-
if (response.body)
|
|
659
|
-
for await (const part of response.body) {
|
|
660
|
-
bytes += part.byteLength;
|
|
661
|
-
if (bytes > MAX_TOOL)
|
|
662
|
-
throw new Error("Runtime pairing response is too large");
|
|
663
|
-
text += new TextDecoder().decode(part);
|
|
664
|
-
}
|
|
665
|
-
let data;
|
|
666
|
-
try {
|
|
667
|
-
data = JSON.parse(text);
|
|
668
|
-
}
|
|
669
|
-
catch {
|
|
670
|
-
throw new Error("Invalid runtime pairing response");
|
|
671
|
-
}
|
|
672
|
-
if (!object(data))
|
|
673
|
-
throw new Error("Invalid runtime pairing response");
|
|
674
|
-
return { status: response.status, data };
|
|
675
|
-
}
|
|
676
|
-
/** Caller holds the profile lock. Persist the candidate before wire; either credential can recover a lost response. */
|
|
677
|
-
export async function rotateRuntimeCredentials(input) {
|
|
678
|
-
let saved = input.store.credentials();
|
|
679
|
-
if (!saved)
|
|
680
|
-
throw Error("Pair this runtime before rotating its credential");
|
|
681
|
-
if (!saved.pendingCredential) {
|
|
682
|
-
saved = { ...saved, pendingCredential: randomBytes(32).toString("hex") };
|
|
683
|
-
input.store.saveCredentials(saved);
|
|
684
|
-
}
|
|
685
|
-
const server = validateRuntimeServer(saved.server), candidate = saved.pendingCredential;
|
|
686
|
-
for (const credential of [saved.credential, candidate]) {
|
|
687
|
-
const response = await post(server, RUNTIME_ROTATE_PATH, { machineId: saved.machineId, credential: candidate }, input.signal, credential);
|
|
688
|
-
if (response.status === 200 && response.data.status === "rotated" && response.data.machineId === saved.machineId) {
|
|
689
|
-
const { pendingCredential: _, ...current } = saved;
|
|
690
|
-
const completed = { ...current, credential: candidate };
|
|
691
|
-
input.store.saveCredentials(completed);
|
|
692
|
-
return completed;
|
|
693
|
-
}
|
|
694
|
-
if (response.status !== 401 && response.status !== 429)
|
|
695
|
-
break;
|
|
696
|
-
}
|
|
697
|
-
throw Error("Runtime credential rotation was not confirmed. The saved candidate is retained; retry rotate before connecting.");
|
|
698
|
-
}
|
|
699
|
-
export async function pairRuntime(input) {
|
|
700
|
-
const server = validateRuntimeServer(input.server);
|
|
701
|
-
if (!input.code.trim() || input.code.length > 256 || /[\x00-\x1f]/.test(input.code) || !input.name.trim() || input.name.length > 100)
|
|
702
|
-
throw new Error("Enter a valid pairing code and machine name");
|
|
703
|
-
input.store.assertCanPair();
|
|
704
|
-
const paired = await post(server, "/runtime/v1/pair", { code: input.code.trim(), name: input.name.trim(), platform: process.platform, hostname: hostname() }, input.signal);
|
|
705
|
-
if (paired.status !== 201 || paired.data.status !== "pending" || typeof paired.data.machineId !== "string" || typeof paired.data.claimSecret !== "string")
|
|
706
|
-
throw new Error(`Runtime pairing was refused (HTTP ${paired.status})`);
|
|
707
|
-
const deadline = Math.min(Date.now() + 10 * 60_000, typeof paired.data.expiresAt === "number" ? paired.data.expiresAt : Infinity);
|
|
708
|
-
const fingerprint = runtimeClaimFingerprint(paired.data.claimSecret);
|
|
709
|
-
input.report?.(`Pairing fingerprint: ${fingerprint}. Compare it with AgEnD Settings → Runtime before approving this machine; waiting for approval…`);
|
|
710
|
-
while (!input.signal?.aborted && Date.now() < deadline) {
|
|
711
|
-
const claimed = await post(server, "/runtime/v1/claim", { machineId: paired.data.machineId, claimSecret: paired.data.claimSecret }, input.signal);
|
|
712
|
-
if (claimed.status === 200 && claimed.data.status === "approved" && claimed.data.machineId === paired.data.machineId
|
|
713
|
-
&& typeof claimed.data.credential === "string" && /^[A-Za-z0-9._-]{16,256}$/.test(claimed.data.credential)) {
|
|
714
|
-
const credentials = { server: server.origin, machineId: paired.data.machineId, credential: claimed.data.credential, name: input.name.trim() };
|
|
715
|
-
// Save first: the one-time credential cannot be issued again. A ledger that changed since the check above is reported after it is safe.
|
|
716
|
-
input.store.saveCredentials(credentials);
|
|
717
|
-
try {
|
|
718
|
-
input.store.adoptMachine(credentials.machineId, true);
|
|
719
|
-
}
|
|
720
|
-
catch (error) {
|
|
721
|
-
throw new Error(`The computer was paired and its credential is saved. ${error instanceof Error ? error.message : "Its job ledger could not be updated."}`);
|
|
722
|
-
}
|
|
723
|
-
input.report?.("Runtime paired. Its machine credential was saved in the private local profile.");
|
|
724
|
-
return credentials;
|
|
725
|
-
}
|
|
726
|
-
if (claimed.status !== 202 || claimed.data.status !== "pending")
|
|
727
|
-
throw new Error(`Runtime approval was refused or expired (HTTP ${claimed.status})`);
|
|
728
|
-
await new Promise((accept, reject) => {
|
|
729
|
-
const timer = setTimeout(() => { input.signal?.removeEventListener("abort", abort); accept(); }, input.pollMs ?? 1500);
|
|
730
|
-
const abort = () => { clearTimeout(timer); reject(new Error("Runtime pairing cancelled")); };
|
|
731
|
-
input.signal?.addEventListener("abort", abort, { once: true });
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
throw new Error(input.signal?.aborted ? "Runtime pairing was cancelled" : "Runtime pairing expired before the computer was approved. Open AgEnD Settings -> Runtime, then double-click connect-agend.bat again and enter a new pairing code.");
|
|
735
|
-
}
|
|
736
|
-
//# sourceMappingURL=runtime-client.js.map
|