@alan-ai-hq/agent-manager 0.1.113 → 0.1.115
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/LICENSE +88 -0
- package/dist/__tests__/binding-switch-git.test.d.ts +2 -0
- package/dist/__tests__/binding-switch-git.test.d.ts.map +1 -0
- package/dist/__tests__/binding-switch-git.test.js +555 -0
- package/dist/__tests__/binding-switch-git.test.js.map +1 -0
- package/dist/__tests__/cli-ensure-install.test.d.ts +2 -0
- package/dist/__tests__/cli-ensure-install.test.d.ts.map +1 -0
- package/dist/__tests__/cli-ensure-install.test.js +177 -0
- package/dist/__tests__/cli-ensure-install.test.js.map +1 -0
- package/dist/__tests__/cli-executable.test.d.ts +2 -0
- package/dist/__tests__/cli-executable.test.d.ts.map +1 -0
- package/dist/__tests__/cli-executable.test.js +155 -0
- package/dist/__tests__/cli-executable.test.js.map +1 -0
- package/dist/__tests__/cli-executable.windows.test.d.ts +2 -0
- package/dist/__tests__/cli-executable.windows.test.d.ts.map +1 -0
- package/dist/__tests__/cli-executable.windows.test.js +123 -0
- package/dist/__tests__/cli-executable.windows.test.js.map +1 -0
- package/dist/__tests__/cli-help.test.d.ts +2 -0
- package/dist/__tests__/cli-help.test.d.ts.map +1 -0
- package/dist/__tests__/cli-help.test.js +47 -0
- package/dist/__tests__/cli-help.test.js.map +1 -0
- package/dist/__tests__/computer-readiness.test.d.ts +2 -0
- package/dist/__tests__/computer-readiness.test.d.ts.map +1 -0
- package/dist/__tests__/computer-readiness.test.js +63 -0
- package/dist/__tests__/computer-readiness.test.js.map +1 -0
- package/dist/__tests__/core-agent-provider-auth-env.test.d.ts +2 -0
- package/dist/__tests__/core-agent-provider-auth-env.test.d.ts.map +1 -0
- package/dist/__tests__/core-agent-provider-auth-env.test.js +93 -0
- package/dist/__tests__/core-agent-provider-auth-env.test.js.map +1 -0
- package/dist/__tests__/core-agent-workflow-context.test.d.ts +2 -0
- package/dist/__tests__/core-agent-workflow-context.test.d.ts.map +1 -0
- package/dist/__tests__/core-agent-workflow-context.test.js +139 -0
- package/dist/__tests__/core-agent-workflow-context.test.js.map +1 -0
- package/dist/__tests__/daemon-native-hooks.test.d.ts +2 -0
- package/dist/__tests__/daemon-native-hooks.test.d.ts.map +1 -0
- package/dist/__tests__/daemon-native-hooks.test.js +94 -0
- package/dist/__tests__/daemon-native-hooks.test.js.map +1 -0
- package/dist/__tests__/daemon-reconcile-ask.test.d.ts +2 -0
- package/dist/__tests__/daemon-reconcile-ask.test.d.ts.map +1 -0
- package/dist/__tests__/daemon-reconcile-ask.test.js +100 -0
- package/dist/__tests__/daemon-reconcile-ask.test.js.map +1 -0
- package/dist/__tests__/daemon-runner-status.test.d.ts +2 -0
- package/dist/__tests__/daemon-runner-status.test.d.ts.map +1 -0
- package/dist/__tests__/daemon-runner-status.test.js +102 -0
- package/dist/__tests__/daemon-runner-status.test.js.map +1 -0
- package/dist/__tests__/daemon-socket.integration.test.d.ts +2 -0
- package/dist/__tests__/daemon-socket.integration.test.d.ts.map +1 -0
- package/dist/__tests__/daemon-socket.integration.test.js +435 -0
- package/dist/__tests__/daemon-socket.integration.test.js.map +1 -0
- package/dist/__tests__/daemon.test.d.ts +2 -0
- package/dist/__tests__/daemon.test.d.ts.map +1 -0
- package/dist/__tests__/daemon.test.js +4884 -0
- package/dist/__tests__/daemon.test.js.map +1 -0
- package/dist/__tests__/ensure-shared-checkout-branch.test.d.ts +2 -0
- package/dist/__tests__/ensure-shared-checkout-branch.test.d.ts.map +1 -0
- package/dist/__tests__/ensure-shared-checkout-branch.test.js +129 -0
- package/dist/__tests__/ensure-shared-checkout-branch.test.js.map +1 -0
- package/dist/__tests__/event-journal-stress.test.d.ts +2 -0
- package/dist/__tests__/event-journal-stress.test.d.ts.map +1 -0
- package/dist/__tests__/event-journal-stress.test.js +124 -0
- package/dist/__tests__/event-journal-stress.test.js.map +1 -0
- package/dist/__tests__/event-journal.test.d.ts +2 -0
- package/dist/__tests__/event-journal.test.d.ts.map +1 -0
- package/dist/__tests__/event-journal.test.js +264 -0
- package/dist/__tests__/event-journal.test.js.map +1 -0
- package/dist/__tests__/event-outbox-persist-failure.test.d.ts +2 -0
- package/dist/__tests__/event-outbox-persist-failure.test.d.ts.map +1 -0
- package/dist/__tests__/event-outbox-persist-failure.test.js +143 -0
- package/dist/__tests__/event-outbox-persist-failure.test.js.map +1 -0
- package/dist/__tests__/event-outbox.test.d.ts +2 -0
- package/dist/__tests__/event-outbox.test.d.ts.map +1 -0
- package/dist/__tests__/event-outbox.test.js +602 -0
- package/dist/__tests__/event-outbox.test.js.map +1 -0
- package/dist/__tests__/execution-activity-tracker.test.d.ts +2 -0
- package/dist/__tests__/execution-activity-tracker.test.d.ts.map +1 -0
- package/dist/__tests__/execution-activity-tracker.test.js +64 -0
- package/dist/__tests__/execution-activity-tracker.test.js.map +1 -0
- package/dist/__tests__/execution-lease-client.test.d.ts +2 -0
- package/dist/__tests__/execution-lease-client.test.d.ts.map +1 -0
- package/dist/__tests__/execution-lease-client.test.js +274 -0
- package/dist/__tests__/execution-lease-client.test.js.map +1 -0
- package/dist/__tests__/fake-provider-cli.test.d.ts +2 -0
- package/dist/__tests__/fake-provider-cli.test.d.ts.map +1 -0
- package/dist/__tests__/fake-provider-cli.test.js +46 -0
- package/dist/__tests__/fake-provider-cli.test.js.map +1 -0
- package/dist/__tests__/generated-images.test.d.ts +2 -0
- package/dist/__tests__/generated-images.test.d.ts.map +1 -0
- package/dist/__tests__/generated-images.test.js +132 -0
- package/dist/__tests__/generated-images.test.js.map +1 -0
- package/dist/__tests__/helpers/sandbox-outbox.d.ts +3 -0
- package/dist/__tests__/helpers/sandbox-outbox.d.ts.map +1 -0
- package/dist/__tests__/helpers/sandbox-outbox.js +23 -0
- package/dist/__tests__/helpers/sandbox-outbox.js.map +1 -0
- package/dist/__tests__/install-command.test.d.ts +2 -0
- package/dist/__tests__/install-command.test.d.ts.map +1 -0
- package/dist/__tests__/install-command.test.js +185 -0
- package/dist/__tests__/install-command.test.js.map +1 -0
- package/dist/__tests__/integration-cli.test.d.ts +2 -0
- package/dist/__tests__/integration-cli.test.d.ts.map +1 -0
- package/dist/__tests__/integration-cli.test.js +150 -0
- package/dist/__tests__/integration-cli.test.js.map +1 -0
- package/dist/__tests__/lifecycle-contracts.test.d.ts +2 -0
- package/dist/__tests__/lifecycle-contracts.test.d.ts.map +1 -0
- package/dist/__tests__/lifecycle-contracts.test.js +66 -0
- package/dist/__tests__/lifecycle-contracts.test.js.map +1 -0
- package/dist/__tests__/lifecycle-logger.test.d.ts +2 -0
- package/dist/__tests__/lifecycle-logger.test.d.ts.map +1 -0
- package/dist/__tests__/lifecycle-logger.test.js +49 -0
- package/dist/__tests__/lifecycle-logger.test.js.map +1 -0
- package/dist/__tests__/local-daemon-lifecycle.test.d.ts +2 -0
- package/dist/__tests__/local-daemon-lifecycle.test.d.ts.map +1 -0
- package/dist/__tests__/local-daemon-lifecycle.test.js +594 -0
- package/dist/__tests__/local-daemon-lifecycle.test.js.map +1 -0
- package/dist/__tests__/local-git-status.test.d.ts +2 -0
- package/dist/__tests__/local-git-status.test.d.ts.map +1 -0
- package/dist/__tests__/local-git-status.test.js +31 -0
- package/dist/__tests__/local-git-status.test.js.map +1 -0
- package/dist/__tests__/mcp-config-adapters-files.test.d.ts +2 -0
- package/dist/__tests__/mcp-config-adapters-files.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-config-adapters-files.test.js +486 -0
- package/dist/__tests__/mcp-config-adapters-files.test.js.map +1 -0
- package/dist/__tests__/mcp-config-adapters.test.d.ts +2 -0
- package/dist/__tests__/mcp-config-adapters.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-config-adapters.test.js +492 -0
- package/dist/__tests__/mcp-config-adapters.test.js.map +1 -0
- package/dist/__tests__/mcp-sync.test.d.ts +2 -0
- package/dist/__tests__/mcp-sync.test.d.ts.map +1 -0
- package/dist/__tests__/mcp-sync.test.js +21 -0
- package/dist/__tests__/mcp-sync.test.js.map +1 -0
- package/dist/__tests__/model-scan-runner.test.d.ts +2 -0
- package/dist/__tests__/model-scan-runner.test.d.ts.map +1 -0
- package/dist/__tests__/model-scan-runner.test.js +80 -0
- package/dist/__tests__/model-scan-runner.test.js.map +1 -0
- package/dist/__tests__/native-hook-command.test.d.ts +2 -0
- package/dist/__tests__/native-hook-command.test.d.ts.map +1 -0
- package/dist/__tests__/native-hook-command.test.js +386 -0
- package/dist/__tests__/native-hook-command.test.js.map +1 -0
- package/dist/__tests__/native-hook-config.test.d.ts +2 -0
- package/dist/__tests__/native-hook-config.test.d.ts.map +1 -0
- package/dist/__tests__/native-hook-config.test.js +374 -0
- package/dist/__tests__/native-hook-config.test.js.map +1 -0
- package/dist/__tests__/native-hook-drain.test.d.ts +2 -0
- package/dist/__tests__/native-hook-drain.test.d.ts.map +1 -0
- package/dist/__tests__/native-hook-drain.test.js +197 -0
- package/dist/__tests__/native-hook-drain.test.js.map +1 -0
- package/dist/__tests__/native-hook-inbox.test.d.ts +2 -0
- package/dist/__tests__/native-hook-inbox.test.d.ts.map +1 -0
- package/dist/__tests__/native-hook-inbox.test.js +139 -0
- package/dist/__tests__/native-hook-inbox.test.js.map +1 -0
- package/dist/__tests__/native-session.test.d.ts +2 -0
- package/dist/__tests__/native-session.test.d.ts.map +1 -0
- package/dist/__tests__/native-session.test.js +41 -0
- package/dist/__tests__/native-session.test.js.map +1 -0
- package/dist/__tests__/native-stream-outbox.test.d.ts +2 -0
- package/dist/__tests__/native-stream-outbox.test.d.ts.map +1 -0
- package/dist/__tests__/native-stream-outbox.test.js +231 -0
- package/dist/__tests__/native-stream-outbox.test.js.map +1 -0
- package/dist/__tests__/native-stream-platform.test.d.ts +2 -0
- package/dist/__tests__/native-stream-platform.test.d.ts.map +1 -0
- package/dist/__tests__/native-stream-platform.test.js +20 -0
- package/dist/__tests__/native-stream-platform.test.js.map +1 -0
- package/dist/__tests__/native-transcript-cursor.test.d.ts +2 -0
- package/dist/__tests__/native-transcript-cursor.test.d.ts.map +1 -0
- package/dist/__tests__/native-transcript-cursor.test.js +60 -0
- package/dist/__tests__/native-transcript-cursor.test.js.map +1 -0
- package/dist/__tests__/native-transcript-stream.test.d.ts +2 -0
- package/dist/__tests__/native-transcript-stream.test.d.ts.map +1 -0
- package/dist/__tests__/native-transcript-stream.test.js +378 -0
- package/dist/__tests__/native-transcript-stream.test.js.map +1 -0
- package/dist/__tests__/network-diagnostics.test.d.ts +2 -0
- package/dist/__tests__/network-diagnostics.test.d.ts.map +1 -0
- package/dist/__tests__/network-diagnostics.test.js +26 -0
- package/dist/__tests__/network-diagnostics.test.js.map +1 -0
- package/dist/__tests__/observable-map.test.d.ts +2 -0
- package/dist/__tests__/observable-map.test.d.ts.map +1 -0
- package/dist/__tests__/observable-map.test.js +54 -0
- package/dist/__tests__/observable-map.test.js.map +1 -0
- package/dist/__tests__/outbox-baseline.bench.test.d.ts +2 -0
- package/dist/__tests__/outbox-baseline.bench.test.d.ts.map +1 -0
- package/dist/__tests__/outbox-baseline.bench.test.js +108 -0
- package/dist/__tests__/outbox-baseline.bench.test.js.map +1 -0
- package/dist/__tests__/provider-auth-preflight.test.d.ts +2 -0
- package/dist/__tests__/provider-auth-preflight.test.d.ts.map +1 -0
- package/dist/__tests__/provider-auth-preflight.test.js +123 -0
- package/dist/__tests__/provider-auth-preflight.test.js.map +1 -0
- package/dist/__tests__/provider-model-discovery.test.d.ts +2 -0
- package/dist/__tests__/provider-model-discovery.test.d.ts.map +1 -0
- package/dist/__tests__/provider-model-discovery.test.js +1071 -0
- package/dist/__tests__/provider-model-discovery.test.js.map +1 -0
- package/dist/__tests__/resource-diagnostics.test.d.ts +2 -0
- package/dist/__tests__/resource-diagnostics.test.d.ts.map +1 -0
- package/dist/__tests__/resource-diagnostics.test.js +138 -0
- package/dist/__tests__/resource-diagnostics.test.js.map +1 -0
- package/dist/__tests__/resume-fallback-env.test.d.ts +2 -0
- package/dist/__tests__/resume-fallback-env.test.d.ts.map +1 -0
- package/dist/__tests__/resume-fallback-env.test.js +28 -0
- package/dist/__tests__/resume-fallback-env.test.js.map +1 -0
- package/dist/__tests__/run-journal.test.d.ts +2 -0
- package/dist/__tests__/run-journal.test.d.ts.map +1 -0
- package/dist/__tests__/run-journal.test.js +121 -0
- package/dist/__tests__/run-journal.test.js.map +1 -0
- package/dist/__tests__/run-start-gate.test.d.ts +2 -0
- package/dist/__tests__/run-start-gate.test.d.ts.map +1 -0
- package/dist/__tests__/run-start-gate.test.js +18 -0
- package/dist/__tests__/run-start-gate.test.js.map +1 -0
- package/dist/__tests__/runtime-capabilities-sync.test.d.ts +2 -0
- package/dist/__tests__/runtime-capabilities-sync.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-capabilities-sync.test.js +66 -0
- package/dist/__tests__/runtime-capabilities-sync.test.js.map +1 -0
- package/dist/__tests__/runtime-config.test.d.ts +2 -0
- package/dist/__tests__/runtime-config.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-config.test.js +137 -0
- package/dist/__tests__/runtime-config.test.js.map +1 -0
- package/dist/__tests__/runtime-presenter-heartbeat.test.d.ts +2 -0
- package/dist/__tests__/runtime-presenter-heartbeat.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-presenter-heartbeat.test.js +253 -0
- package/dist/__tests__/runtime-presenter-heartbeat.test.js.map +1 -0
- package/dist/__tests__/runtime-registration.test.d.ts +2 -0
- package/dist/__tests__/runtime-registration.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-registration.test.js +109 -0
- package/dist/__tests__/runtime-registration.test.js.map +1 -0
- package/dist/__tests__/sandbox-outbox-storage.test.d.ts +2 -0
- package/dist/__tests__/sandbox-outbox-storage.test.d.ts.map +1 -0
- package/dist/__tests__/sandbox-outbox-storage.test.js +81 -0
- package/dist/__tests__/sandbox-outbox-storage.test.js.map +1 -0
- package/dist/__tests__/sandbox-outbox.test.d.ts +2 -0
- package/dist/__tests__/sandbox-outbox.test.d.ts.map +1 -0
- package/dist/__tests__/sandbox-outbox.test.js +300 -0
- package/dist/__tests__/sandbox-outbox.test.js.map +1 -0
- package/dist/__tests__/sandbox-workflow-context.test.d.ts +2 -0
- package/dist/__tests__/sandbox-workflow-context.test.d.ts.map +1 -0
- package/dist/__tests__/sandbox-workflow-context.test.js +600 -0
- package/dist/__tests__/sandbox-workflow-context.test.js.map +1 -0
- package/dist/__tests__/service-manager-deadline.test.d.ts +2 -0
- package/dist/__tests__/service-manager-deadline.test.d.ts.map +1 -0
- package/dist/__tests__/service-manager-deadline.test.js +36 -0
- package/dist/__tests__/service-manager-deadline.test.js.map +1 -0
- package/dist/__tests__/service-manager.test.d.ts +2 -0
- package/dist/__tests__/service-manager.test.d.ts.map +1 -0
- package/dist/__tests__/service-manager.test.js +769 -0
- package/dist/__tests__/service-manager.test.js.map +1 -0
- package/dist/__tests__/service-stop-ownership.test.d.ts +2 -0
- package/dist/__tests__/service-stop-ownership.test.d.ts.map +1 -0
- package/dist/__tests__/service-stop-ownership.test.js +89 -0
- package/dist/__tests__/service-stop-ownership.test.js.map +1 -0
- package/dist/__tests__/skill-invocation.test.d.ts +2 -0
- package/dist/__tests__/skill-invocation.test.d.ts.map +1 -0
- package/dist/__tests__/skill-invocation.test.js +40 -0
- package/dist/__tests__/skill-invocation.test.js.map +1 -0
- package/dist/__tests__/sleep-inhibitor-real.test.d.ts +2 -0
- package/dist/__tests__/sleep-inhibitor-real.test.d.ts.map +1 -0
- package/dist/__tests__/sleep-inhibitor-real.test.js +68 -0
- package/dist/__tests__/sleep-inhibitor-real.test.js.map +1 -0
- package/dist/__tests__/sleep-inhibitor.test.d.ts +2 -0
- package/dist/__tests__/sleep-inhibitor.test.d.ts.map +1 -0
- package/dist/__tests__/sleep-inhibitor.test.js +236 -0
- package/dist/__tests__/sleep-inhibitor.test.js.map +1 -0
- package/dist/__tests__/status-local-workspace.test.d.ts +2 -0
- package/dist/__tests__/status-local-workspace.test.d.ts.map +1 -0
- package/dist/__tests__/status-local-workspace.test.js +121 -0
- package/dist/__tests__/status-local-workspace.test.js.map +1 -0
- package/dist/__tests__/suspension-detector.test.d.ts +2 -0
- package/dist/__tests__/suspension-detector.test.d.ts.map +1 -0
- package/dist/__tests__/suspension-detector.test.js +112 -0
- package/dist/__tests__/suspension-detector.test.js.map +1 -0
- package/dist/__tests__/web-presenter-parent-events.test.d.ts +2 -0
- package/dist/__tests__/web-presenter-parent-events.test.d.ts.map +1 -0
- package/dist/__tests__/web-presenter-parent-events.test.js +168 -0
- package/dist/__tests__/web-presenter-parent-events.test.js.map +1 -0
- package/dist/__tests__/workspace-probe-concurrency.test.d.ts +2 -0
- package/dist/__tests__/workspace-probe-concurrency.test.d.ts.map +1 -0
- package/dist/__tests__/workspace-probe-concurrency.test.js +54 -0
- package/dist/__tests__/workspace-probe-concurrency.test.js.map +1 -0
- package/dist/__tests__/workspace-relocation.test.d.ts +2 -0
- package/dist/__tests__/workspace-relocation.test.d.ts.map +1 -0
- package/dist/__tests__/workspace-relocation.test.js +66 -0
- package/dist/__tests__/workspace-relocation.test.js.map +1 -0
- package/dist/__tests__/workspace-rpc.test.d.ts +2 -0
- package/dist/__tests__/workspace-rpc.test.d.ts.map +1 -0
- package/dist/__tests__/workspace-rpc.test.js +90 -0
- package/dist/__tests__/workspace-rpc.test.js.map +1 -0
- package/dist/__tests__/workspace-run-lease.test.d.ts +2 -0
- package/dist/__tests__/workspace-run-lease.test.d.ts.map +1 -0
- package/dist/__tests__/workspace-run-lease.test.js +331 -0
- package/dist/__tests__/workspace-run-lease.test.js.map +1 -0
- package/dist/__tests__/ws-client-connection.test.d.ts +2 -0
- package/dist/__tests__/ws-client-connection.test.d.ts.map +1 -0
- package/dist/__tests__/ws-client-connection.test.js +295 -0
- package/dist/__tests__/ws-client-connection.test.js.map +1 -0
- package/dist/__tests__/ws-client-heartbeat-volatile.test.d.ts +2 -0
- package/dist/__tests__/ws-client-heartbeat-volatile.test.d.ts.map +1 -0
- package/dist/__tests__/ws-client-heartbeat-volatile.test.js +63 -0
- package/dist/__tests__/ws-client-heartbeat-volatile.test.js.map +1 -0
- package/dist/__tests__/ws-client-heartbeat.integration.test.d.ts +2 -0
- package/dist/__tests__/ws-client-heartbeat.integration.test.d.ts.map +1 -0
- package/dist/__tests__/ws-client-heartbeat.integration.test.js +236 -0
- package/dist/__tests__/ws-client-heartbeat.integration.test.js.map +1 -0
- package/dist/__tests__/ws-client-user-message-ack.integration.test.d.ts +2 -0
- package/dist/__tests__/ws-client-user-message-ack.integration.test.d.ts.map +1 -0
- package/dist/__tests__/ws-client-user-message-ack.integration.test.js +211 -0
- package/dist/__tests__/ws-client-user-message-ack.integration.test.js.map +1 -0
- package/dist/antigravity-api-key-config.d.ts +2 -0
- package/dist/antigravity-api-key-config.d.ts.map +1 -0
- package/dist/antigravity-api-key-config.js +79 -0
- package/dist/antigravity-api-key-config.js.map +1 -0
- package/dist/binding-switch-git.d.ts +26 -0
- package/dist/binding-switch-git.d.ts.map +1 -0
- package/dist/binding-switch-git.js +871 -0
- package/dist/binding-switch-git.js.map +1 -0
- package/dist/cli-ensure-install.d.ts +34 -0
- package/dist/cli-ensure-install.d.ts.map +1 -0
- package/dist/cli-ensure-install.js +154 -0
- package/dist/cli-ensure-install.js.map +1 -0
- package/dist/cli-executable.d.ts +44 -0
- package/dist/cli-executable.d.ts.map +1 -0
- package/dist/cli-executable.js +435 -0
- package/dist/cli-executable.js.map +1 -0
- package/dist/cli-help.d.ts +11 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +65 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/computer-readiness.d.ts +41 -0
- package/dist/computer-readiness.d.ts.map +1 -0
- package/dist/computer-readiness.js +191 -0
- package/dist/computer-readiness.js.map +1 -0
- package/dist/core-agent.d.ts +32 -0
- package/dist/core-agent.d.ts.map +1 -0
- package/dist/core-agent.js +331 -0
- package/dist/core-agent.js.map +1 -0
- package/dist/daemon-execute.d.ts +42 -0
- package/dist/daemon-execute.d.ts.map +1 -0
- package/dist/daemon-execute.js +666 -0
- package/dist/daemon-execute.js.map +1 -0
- package/dist/daemon-helpers.d.ts +150 -0
- package/dist/daemon-helpers.d.ts.map +1 -0
- package/dist/daemon-helpers.js +157 -0
- package/dist/daemon-helpers.js.map +1 -0
- package/dist/daemon-local-control.d.ts +208 -0
- package/dist/daemon-local-control.d.ts.map +1 -0
- package/dist/daemon-local-control.js +826 -0
- package/dist/daemon-local-control.js.map +1 -0
- package/dist/daemon-local-http.d.ts +57 -0
- package/dist/daemon-local-http.d.ts.map +1 -0
- package/dist/daemon-local-http.js +375 -0
- package/dist/daemon-local-http.js.map +1 -0
- package/dist/daemon-native-hooks.d.ts +17 -0
- package/dist/daemon-native-hooks.d.ts.map +1 -0
- package/dist/daemon-native-hooks.js +54 -0
- package/dist/daemon-native-hooks.js.map +1 -0
- package/dist/daemon-provider-scan.d.ts +33 -0
- package/dist/daemon-provider-scan.d.ts.map +1 -0
- package/dist/daemon-provider-scan.js +187 -0
- package/dist/daemon-provider-scan.js.map +1 -0
- package/dist/daemon-runner-status.d.ts +164 -0
- package/dist/daemon-runner-status.d.ts.map +1 -0
- package/dist/daemon-runner-status.js +424 -0
- package/dist/daemon-runner-status.js.map +1 -0
- package/dist/daemon-start.d.ts +5 -0
- package/dist/daemon-start.d.ts.map +1 -0
- package/dist/daemon-start.js +1313 -0
- package/dist/daemon-start.js.map +1 -0
- package/dist/daemon-workspace.d.ts +36 -0
- package/dist/daemon-workspace.d.ts.map +1 -0
- package/dist/daemon-workspace.js +154 -0
- package/dist/daemon-workspace.js.map +1 -0
- package/dist/daemon.d.ts +59 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +681 -0
- package/dist/daemon.js.map +1 -0
- package/dist/event-journal-crypto.d.ts +14 -0
- package/dist/event-journal-crypto.d.ts.map +1 -0
- package/dist/event-journal-crypto.js +89 -0
- package/dist/event-journal-crypto.js.map +1 -0
- package/dist/event-journal-paths.d.ts +10 -0
- package/dist/event-journal-paths.d.ts.map +1 -0
- package/dist/event-journal-paths.js +29 -0
- package/dist/event-journal-paths.js.map +1 -0
- package/dist/event-journal-recovery.d.ts +83 -0
- package/dist/event-journal-recovery.d.ts.map +1 -0
- package/dist/event-journal-recovery.js +333 -0
- package/dist/event-journal-recovery.js.map +1 -0
- package/dist/event-journal-types.d.ts +54 -0
- package/dist/event-journal-types.d.ts.map +1 -0
- package/dist/event-journal-types.js +10 -0
- package/dist/event-journal-types.js.map +1 -0
- package/dist/event-journal-writer.d.ts +44 -0
- package/dist/event-journal-writer.d.ts.map +1 -0
- package/dist/event-journal-writer.js +182 -0
- package/dist/event-journal-writer.js.map +1 -0
- package/dist/event-outbox.d.ts +113 -0
- package/dist/event-outbox.d.ts.map +1 -0
- package/dist/event-outbox.js +707 -0
- package/dist/event-outbox.js.map +1 -0
- package/dist/execution-activity-tracker.d.ts +43 -0
- package/dist/execution-activity-tracker.d.ts.map +1 -0
- package/dist/execution-activity-tracker.js +116 -0
- package/dist/execution-activity-tracker.js.map +1 -0
- package/dist/execution-lease-client.d.ts +62 -0
- package/dist/execution-lease-client.d.ts.map +1 -0
- package/dist/execution-lease-client.js +271 -0
- package/dist/execution-lease-client.js.map +1 -0
- package/dist/fake-provider-cli.d.ts +13 -0
- package/dist/fake-provider-cli.d.ts.map +1 -0
- package/dist/fake-provider-cli.js +53 -0
- package/dist/fake-provider-cli.js.map +1 -0
- package/dist/generated-images.d.ts +2 -0
- package/dist/generated-images.d.ts.map +1 -0
- package/dist/generated-images.js +2 -0
- package/dist/generated-images.js.map +1 -0
- package/dist/index.cjs +47033 -45514
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +224 -0
- package/dist/index.js.map +1 -0
- package/dist/install-command.d.ts +2 -0
- package/dist/install-command.d.ts.map +1 -0
- package/dist/install-command.js +96 -0
- package/dist/install-command.js.map +1 -0
- package/dist/integration-cli.d.ts +14 -0
- package/dist/integration-cli.d.ts.map +1 -0
- package/dist/integration-cli.js +80 -0
- package/dist/integration-cli.js.map +1 -0
- package/dist/lifecycle-logger.d.ts +25 -0
- package/dist/lifecycle-logger.d.ts.map +1 -0
- package/dist/lifecycle-logger.js +73 -0
- package/dist/lifecycle-logger.js.map +1 -0
- package/dist/local-daemon-lifecycle.d.ts +112 -0
- package/dist/local-daemon-lifecycle.d.ts.map +1 -0
- package/dist/local-daemon-lifecycle.js +433 -0
- package/dist/local-daemon-lifecycle.js.map +1 -0
- package/dist/local-git-status.d.ts +14 -0
- package/dist/local-git-status.d.ts.map +1 -0
- package/dist/local-git-status.js +43 -0
- package/dist/local-git-status.js.map +1 -0
- package/dist/managed-mcp.d.ts +7 -0
- package/dist/managed-mcp.d.ts.map +1 -0
- package/dist/managed-mcp.js +16 -0
- package/dist/managed-mcp.js.map +1 -0
- package/dist/mcp-config-adapters.d.ts +57 -0
- package/dist/mcp-config-adapters.d.ts.map +1 -0
- package/dist/mcp-config-adapters.js +929 -0
- package/dist/mcp-config-adapters.js.map +1 -0
- package/dist/mcp-sync.d.ts +44 -0
- package/dist/mcp-sync.d.ts.map +1 -0
- package/dist/mcp-sync.js +68 -0
- package/dist/mcp-sync.js.map +1 -0
- package/dist/model-scan-runner.d.ts +15 -0
- package/dist/model-scan-runner.d.ts.map +1 -0
- package/dist/model-scan-runner.js +56 -0
- package/dist/model-scan-runner.js.map +1 -0
- package/dist/native-hook-command.d.ts +31 -0
- package/dist/native-hook-command.d.ts.map +1 -0
- package/dist/native-hook-command.js +289 -0
- package/dist/native-hook-command.js.map +1 -0
- package/dist/native-hook-config.d.ts +43 -0
- package/dist/native-hook-config.d.ts.map +1 -0
- package/dist/native-hook-config.js +601 -0
- package/dist/native-hook-config.js.map +1 -0
- package/dist/native-hook-drain.d.ts +34 -0
- package/dist/native-hook-drain.d.ts.map +1 -0
- package/dist/native-hook-drain.js +83 -0
- package/dist/native-hook-drain.js.map +1 -0
- package/dist/native-hook-inbox.d.ts +40 -0
- package/dist/native-hook-inbox.d.ts.map +1 -0
- package/dist/native-hook-inbox.js +217 -0
- package/dist/native-hook-inbox.js.map +1 -0
- package/dist/native-project-config.d.ts +11 -0
- package/dist/native-project-config.d.ts.map +1 -0
- package/dist/native-project-config.js +49 -0
- package/dist/native-project-config.js.map +1 -0
- package/dist/native-session.d.ts +20 -0
- package/dist/native-session.d.ts.map +1 -0
- package/dist/native-session.js +213 -0
- package/dist/native-session.js.map +1 -0
- package/dist/native-stream-journal.d.ts +22 -0
- package/dist/native-stream-journal.d.ts.map +1 -0
- package/dist/native-stream-journal.js +98 -0
- package/dist/native-stream-journal.js.map +1 -0
- package/dist/native-stream-outbox.d.ts +40 -0
- package/dist/native-stream-outbox.d.ts.map +1 -0
- package/dist/native-stream-outbox.js +358 -0
- package/dist/native-stream-outbox.js.map +1 -0
- package/dist/native-stream-platform.d.ts +4 -0
- package/dist/native-stream-platform.d.ts.map +1 -0
- package/dist/native-stream-platform.js +11 -0
- package/dist/native-stream-platform.js.map +1 -0
- package/dist/native-transcript-cursor.d.ts +33 -0
- package/dist/native-transcript-cursor.d.ts.map +1 -0
- package/dist/native-transcript-cursor.js +108 -0
- package/dist/native-transcript-cursor.js.map +1 -0
- package/dist/native-transcript-stream.d.ts +20 -0
- package/dist/native-transcript-stream.d.ts.map +1 -0
- package/dist/native-transcript-stream.js +438 -0
- package/dist/native-transcript-stream.js.map +1 -0
- package/dist/network-diagnostics.d.ts +8 -0
- package/dist/network-diagnostics.d.ts.map +1 -0
- package/dist/network-diagnostics.js +56 -0
- package/dist/network-diagnostics.js.map +1 -0
- package/dist/observable-map.d.ts +13 -0
- package/dist/observable-map.d.ts.map +1 -0
- package/dist/observable-map.js +30 -0
- package/dist/observable-map.js.map +1 -0
- package/dist/provider-auth-preflight.d.ts +19 -0
- package/dist/provider-auth-preflight.d.ts.map +1 -0
- package/dist/provider-auth-preflight.js +107 -0
- package/dist/provider-auth-preflight.js.map +1 -0
- package/dist/provider-model-discovery.d.ts +33 -0
- package/dist/provider-model-discovery.d.ts.map +1 -0
- package/dist/provider-model-discovery.js +731 -0
- package/dist/provider-model-discovery.js.map +1 -0
- package/dist/resource-diagnostics.d.ts +21 -0
- package/dist/resource-diagnostics.d.ts.map +1 -0
- package/dist/resource-diagnostics.js +161 -0
- package/dist/resource-diagnostics.js.map +1 -0
- package/dist/resume-fallback-env.d.ts +3 -0
- package/dist/resume-fallback-env.d.ts.map +1 -0
- package/dist/resume-fallback-env.js +14 -0
- package/dist/resume-fallback-env.js.map +1 -0
- package/dist/run-journal.d.ts +51 -0
- package/dist/run-journal.d.ts.map +1 -0
- package/dist/run-journal.js +193 -0
- package/dist/run-journal.js.map +1 -0
- package/dist/runtime-backends.d.ts +2 -0
- package/dist/runtime-backends.d.ts.map +1 -0
- package/dist/runtime-backends.js +2 -0
- package/dist/runtime-backends.js.map +1 -0
- package/dist/runtime-capabilities-sync.d.ts +40 -0
- package/dist/runtime-capabilities-sync.d.ts.map +1 -0
- package/dist/runtime-capabilities-sync.js +56 -0
- package/dist/runtime-capabilities-sync.js.map +1 -0
- package/dist/runtime-config.d.ts +26 -0
- package/dist/runtime-config.d.ts.map +1 -0
- package/dist/runtime-config.js +170 -0
- package/dist/runtime-config.js.map +1 -0
- package/dist/runtime-presenter.d.ts +81 -0
- package/dist/runtime-presenter.d.ts.map +1 -0
- package/dist/runtime-presenter.js +422 -0
- package/dist/runtime-presenter.js.map +1 -0
- package/dist/runtime-registration.d.ts +40 -0
- package/dist/runtime-registration.d.ts.map +1 -0
- package/dist/runtime-registration.js +143 -0
- package/dist/runtime-registration.js.map +1 -0
- package/dist/sandbox-outbox-storage.d.ts +13 -0
- package/dist/sandbox-outbox-storage.d.ts.map +1 -0
- package/dist/sandbox-outbox-storage.js +98 -0
- package/dist/sandbox-outbox-storage.js.map +1 -0
- package/dist/sandbox-outbox.d.ts +115 -0
- package/dist/sandbox-outbox.d.ts.map +1 -0
- package/dist/sandbox-outbox.js +213 -0
- package/dist/sandbox-outbox.js.map +1 -0
- package/dist/sandbox.d.ts +34 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +469 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/service-manager.d.ts +113 -0
- package/dist/service-manager.d.ts.map +1 -0
- package/dist/service-manager.js +1065 -0
- package/dist/service-manager.js.map +1 -0
- package/dist/skills/__tests__/local-skill-source.test.d.ts +2 -0
- package/dist/skills/__tests__/local-skill-source.test.d.ts.map +1 -0
- package/dist/skills/__tests__/local-skill-source.test.js +373 -0
- package/dist/skills/__tests__/local-skill-source.test.js.map +1 -0
- package/dist/skills/__tests__/managed-skill-store.test.d.ts +2 -0
- package/dist/skills/__tests__/managed-skill-store.test.d.ts.map +1 -0
- package/dist/skills/__tests__/managed-skill-store.test.js +114 -0
- package/dist/skills/__tests__/managed-skill-store.test.js.map +1 -0
- package/dist/skills/__tests__/runtime-skill-coordinator.test.d.ts +2 -0
- package/dist/skills/__tests__/runtime-skill-coordinator.test.d.ts.map +1 -0
- package/dist/skills/__tests__/runtime-skill-coordinator.test.js +251 -0
- package/dist/skills/__tests__/runtime-skill-coordinator.test.js.map +1 -0
- package/dist/skills/__tests__/runtime-skill-manager.test.d.ts +2 -0
- package/dist/skills/__tests__/runtime-skill-manager.test.d.ts.map +1 -0
- package/dist/skills/__tests__/runtime-skill-manager.test.js +664 -0
- package/dist/skills/__tests__/runtime-skill-manager.test.js.map +1 -0
- package/dist/skills/__tests__/skill-bundle.test.d.ts +2 -0
- package/dist/skills/__tests__/skill-bundle.test.d.ts.map +1 -0
- package/dist/skills/__tests__/skill-bundle.test.js +42 -0
- package/dist/skills/__tests__/skill-bundle.test.js.map +1 -0
- package/dist/skills/__tests__/skill-control-client.test.d.ts +2 -0
- package/dist/skills/__tests__/skill-control-client.test.d.ts.map +1 -0
- package/dist/skills/__tests__/skill-control-client.test.js +49 -0
- package/dist/skills/__tests__/skill-control-client.test.js.map +1 -0
- package/dist/skills/__tests__/skill-source-config.test.d.ts +2 -0
- package/dist/skills/__tests__/skill-source-config.test.d.ts.map +1 -0
- package/dist/skills/__tests__/skill-source-config.test.js +295 -0
- package/dist/skills/__tests__/skill-source-config.test.js.map +1 -0
- package/dist/skills/local-skill-source.d.ts +77 -0
- package/dist/skills/local-skill-source.d.ts.map +1 -0
- package/dist/skills/local-skill-source.js +660 -0
- package/dist/skills/local-skill-source.js.map +1 -0
- package/dist/skills/managed-skill-store.d.ts +44 -0
- package/dist/skills/managed-skill-store.d.ts.map +1 -0
- package/dist/skills/managed-skill-store.js +160 -0
- package/dist/skills/managed-skill-store.js.map +1 -0
- package/dist/skills/runtime-skill-coordinator.d.ts +35 -0
- package/dist/skills/runtime-skill-coordinator.d.ts.map +1 -0
- package/dist/skills/runtime-skill-coordinator.js +166 -0
- package/dist/skills/runtime-skill-coordinator.js.map +1 -0
- package/dist/skills/runtime-skill-manager.d.ts +89 -0
- package/dist/skills/runtime-skill-manager.d.ts.map +1 -0
- package/dist/skills/runtime-skill-manager.js +934 -0
- package/dist/skills/runtime-skill-manager.js.map +1 -0
- package/dist/skills/skill-bundle.d.ts +2 -0
- package/dist/skills/skill-bundle.d.ts.map +1 -0
- package/dist/skills/skill-bundle.js +2 -0
- package/dist/skills/skill-bundle.js.map +1 -0
- package/dist/skills/skill-cli.d.ts +2 -0
- package/dist/skills/skill-cli.d.ts.map +1 -0
- package/dist/skills/skill-cli.js +81 -0
- package/dist/skills/skill-cli.js.map +1 -0
- package/dist/skills/skill-control-client.d.ts +20 -0
- package/dist/skills/skill-control-client.d.ts.map +1 -0
- package/dist/skills/skill-control-client.js +56 -0
- package/dist/skills/skill-control-client.js.map +1 -0
- package/dist/skills/skill-invocation.d.ts +10 -0
- package/dist/skills/skill-invocation.d.ts.map +1 -0
- package/dist/skills/skill-invocation.js +24 -0
- package/dist/skills/skill-invocation.js.map +1 -0
- package/dist/sleep-inhibitor.d.ts +32 -0
- package/dist/sleep-inhibitor.d.ts.map +1 -0
- package/dist/sleep-inhibitor.js +297 -0
- package/dist/sleep-inhibitor.js.map +1 -0
- package/dist/suspension-detector.d.ts +24 -0
- package/dist/suspension-detector.d.ts.map +1 -0
- package/dist/suspension-detector.js +59 -0
- package/dist/suspension-detector.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/web-presenter.d.ts +52 -0
- package/dist/web-presenter.d.ts.map +1 -0
- package/dist/web-presenter.js +264 -0
- package/dist/web-presenter.js.map +1 -0
- package/dist/workspace-relocation.d.ts +22 -0
- package/dist/workspace-relocation.d.ts.map +1 -0
- package/dist/workspace-relocation.js +90 -0
- package/dist/workspace-relocation.js.map +1 -0
- package/dist/workspace-rpc.d.ts +2 -0
- package/dist/workspace-rpc.d.ts.map +1 -0
- package/dist/workspace-rpc.js +15 -0
- package/dist/workspace-rpc.js.map +1 -0
- package/dist/workspace-run-lease.d.ts +116 -0
- package/dist/workspace-run-lease.d.ts.map +1 -0
- package/dist/workspace-run-lease.js +320 -0
- package/dist/workspace-run-lease.js.map +1 -0
- package/dist/ws-client.d.ts +168 -0
- package/dist/ws-client.d.ts.map +1 -0
- package/dist/ws-client.js +440 -0
- package/dist/ws-client.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
// AL-2472: agent.execute dispatch handler.
|
|
2
|
+
import { mkdirSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { isAlanDefaultWorkspace } from "@alan-ai/shared/constants";
|
|
5
|
+
import { pickPrimaryReadinessIssue } from "@alan-ai/shared/runtime-runner-status";
|
|
6
|
+
import { canInstallProviderCli, ensureProviderCliInstalled } from "./cli-ensure-install.js";
|
|
7
|
+
import { getDaemonCliEnvironment, resolveBackendRuntimeCommand, revalidateBackendRuntimeCommand, } from "./cli-executable.js";
|
|
8
|
+
import { inspectWorkspaceReadiness } from "./computer-readiness.js";
|
|
9
|
+
import { CoreAgent } from "./core-agent.js";
|
|
10
|
+
import { correlationLogFields, resolveWorkspaceRunLeaseTargets, } from "./daemon-helpers.js";
|
|
11
|
+
import { readLocalDaemonMaintenanceLease } from "./daemon-local-control.js";
|
|
12
|
+
import { normalizeBackendKind } from "./daemon-provider-scan.js";
|
|
13
|
+
import { isProviderProcessAlive, summarizeRunnerStatus, } from "./daemon-runner-status.js";
|
|
14
|
+
import { ensureSharedCheckoutBranch, resolveRuntimeCwd, resolveSharedCheckoutTargets, } from "./daemon-workspace.js";
|
|
15
|
+
import { buildManagedAlanMcp } from "./managed-mcp.js";
|
|
16
|
+
import { invalidateProviderAuthPreflight, looksLikeProviderAuthFailure, preflightProviderAuth, } from "./provider-auth-preflight.js";
|
|
17
|
+
import { buildApplicationRunFailure, RuntimePresenter } from "./runtime-presenter.js";
|
|
18
|
+
import { prepareSkillInvocationTask } from "./skills/skill-invocation.js";
|
|
19
|
+
import { AGENT_VERSION } from "./version.js";
|
|
20
|
+
import { discoverRelocatedWorkspace, workspaceMatchesExpectedRepositories, } from "./workspace-relocation.js";
|
|
21
|
+
import { applicationCodeForWorkspaceLeaseFailure, hasGitWorkspaceMarker, WorkspaceRunLease, } from "./workspace-run-lease.js";
|
|
22
|
+
export async function handleAgentExecute(ctx, payload) {
|
|
23
|
+
const { activeAgents, pendingRunStarts, pushLog, socket, runJournal, publishCapacityChange, runtimeId, runtimeSkillManager, getRuntimeToken, ensureRuntimeTokenForLaunch, eventOutbox, daemonSessionId, daemonEpoch, getHeartbeatSeq, endpointProfile, apiUrl, configPath, endpointMismatch, workspaceAccessTracker, getDisconnectedSinceMs, workspaceRelocations, persistWorkspaceRelocations, flushWorkspaceRelocations, recheckWorkspaceIssue, maintenanceReason, verifyActiveWorkspaceLease, } = ctx;
|
|
24
|
+
if (ctx.shutdownSignal.aborted)
|
|
25
|
+
return;
|
|
26
|
+
const heartbeatSeq = getHeartbeatSeq();
|
|
27
|
+
const disconnectedSinceMs = getDisconnectedSinceMs();
|
|
28
|
+
if (!payload?.runId || !payload.conversationId || typeof payload.content !== "string") {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const tokenReadiness = ensureRuntimeTokenForLaunch();
|
|
32
|
+
const tokenReady = typeof tokenReadiness === "boolean" ? tokenReadiness : await tokenReadiness;
|
|
33
|
+
if (!tokenReady) {
|
|
34
|
+
socket.emit("agent.rejected", {
|
|
35
|
+
runId: payload.runId,
|
|
36
|
+
message: "This Computer could not renew its expired Alan credential. Run setup again.",
|
|
37
|
+
code: "runtime_token_expired",
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const runtimeToken = getRuntimeToken();
|
|
42
|
+
const isTaskWorkspacePayload = Boolean(payload.worktreeInfo?.worktreePath || payload.worktreeInfo?.allWorktrees?.length);
|
|
43
|
+
if ((payload.worktreeInfo?.allWorktrees?.length ?? 0) > 1 ||
|
|
44
|
+
(isTaskWorkspacePayload && (payload.repoLocalPaths?.length ?? 0) > 1)) {
|
|
45
|
+
socket.emit("agent.rejected", {
|
|
46
|
+
runId: payload.runId,
|
|
47
|
+
message: "A task worktree requires exactly one Git repository.",
|
|
48
|
+
code: "single_repository_worktree_required",
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const existingRun = activeAgents.get(payload.runId);
|
|
53
|
+
if (existingRun) {
|
|
54
|
+
if (existingRun.conversationId !== payload.conversationId) {
|
|
55
|
+
socket.emit("agent.rejected", {
|
|
56
|
+
runId: payload.runId,
|
|
57
|
+
message: "Run ID is already bound to another conversation",
|
|
58
|
+
code: "run_id_conflict",
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
// The backend may redeliver after the original acceptance ACK is lost.
|
|
63
|
+
// Re-acknowledge the existing execution without spawning a second agent.
|
|
64
|
+
pushLog(`duplicate dispatch re-acknowledged run=${payload.runId}`);
|
|
65
|
+
socket.emit("agent.accepted", { runId: payload.runId });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const preflightingConversationId = pendingRunStarts.get(payload.runId);
|
|
69
|
+
if (preflightingConversationId) {
|
|
70
|
+
if (preflightingConversationId !== payload.conversationId) {
|
|
71
|
+
socket.emit("agent.rejected", {
|
|
72
|
+
runId: payload.runId,
|
|
73
|
+
message: "Run ID is already bound to another conversation",
|
|
74
|
+
code: "run_id_conflict",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const recoveredRun = runJournal.get(payload.runId);
|
|
80
|
+
if (recoveredRun) {
|
|
81
|
+
if (recoveredRun.conversationId !== payload.conversationId) {
|
|
82
|
+
socket.emit("agent.rejected", {
|
|
83
|
+
runId: payload.runId,
|
|
84
|
+
message: "Run ID is already bound to another conversation",
|
|
85
|
+
code: "run_id_conflict",
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const recovery = runJournal.assessRecovery(payload.runId, (pid) => isProviderProcessAlive(pid));
|
|
90
|
+
pushLog(`recovered dispatch fenced run=${payload.runId} recovery=${recovery?.reason ?? "unknown"}${recovery && "providerPid" in recovery ? ` pid=${recovery.providerPid}` : ""}`);
|
|
91
|
+
socket.emit("agent.rejected", {
|
|
92
|
+
runId: payload.runId,
|
|
93
|
+
message: "This run was interrupted by a daemon restart and will not be executed twice.",
|
|
94
|
+
code: "run_interrupted_by_restart",
|
|
95
|
+
});
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const maintenanceLease = readLocalDaemonMaintenanceLease(configPath);
|
|
99
|
+
if (maintenanceLease) {
|
|
100
|
+
socket.emit("agent.rejected", {
|
|
101
|
+
runId: payload.runId,
|
|
102
|
+
message: maintenanceLease.reason === "credential_cleanup"
|
|
103
|
+
? "This computer is finishing logout and cannot start another run."
|
|
104
|
+
: "This computer is under short-lived maintenance; retry shortly.",
|
|
105
|
+
code: maintenanceLease.reason === "credential_cleanup"
|
|
106
|
+
? "runtime_logout_pending"
|
|
107
|
+
: "runtime_maintenance_pending",
|
|
108
|
+
});
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const backendKind = normalizeBackendKind(payload.backendKind);
|
|
112
|
+
let runtimeCommand = resolveBackendRuntimeCommand(backendKind ?? payload.backendKind);
|
|
113
|
+
if (ctx.shutdownSignal.aborted)
|
|
114
|
+
return;
|
|
115
|
+
if (!runtimeCommand && backendKind) {
|
|
116
|
+
// A cached negative resolution is never authoritative for a run: startup
|
|
117
|
+
// provider discovery can probe a CLI before the sandbox's deferred
|
|
118
|
+
// installer drops the binary, and that miss must not reject runs after
|
|
119
|
+
// the binary lands. Drop the cache entry and re-resolve from disk.
|
|
120
|
+
runtimeCommand = revalidateBackendRuntimeCommand(backendKind);
|
|
121
|
+
}
|
|
122
|
+
if (!runtimeCommand && backendKind && canInstallProviderCli(backendKind)) {
|
|
123
|
+
// Fresh sandboxes install provider CLIs DEFERRED (~40-90s after agents can
|
|
124
|
+
// start), so an early run can race the installer and hit a missing binary.
|
|
125
|
+
// Install the policy-bounded CLI on demand (at most once per daemon lifetime) and
|
|
126
|
+
// re-resolve before rejecting the run. No presenter exists pre-accept, so
|
|
127
|
+
// installation progress surfaces through the daemon log only. Fence the
|
|
128
|
+
// runId while awaiting so a backend redelivery of the same dispatch does
|
|
129
|
+
// not start a second execution once the install completes.
|
|
130
|
+
try {
|
|
131
|
+
pendingRunStarts.set(payload.runId, payload.conversationId);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
socket.emit("agent.rejected", {
|
|
135
|
+
runId: payload.runId,
|
|
136
|
+
message: `Unable to reserve local runtime capacity: ${error instanceof Error ? error.message : String(error)}`,
|
|
137
|
+
code: "runner_reservation_failed",
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const installed = await ensureProviderCliInstalled(backendKind, {
|
|
143
|
+
notify: (message) => {
|
|
144
|
+
pushLog(message);
|
|
145
|
+
console.info(`[alan-agent] ${message}`);
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
if (installed) {
|
|
149
|
+
runtimeCommand = revalidateBackendRuntimeCommand(backendKind);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
if (!ctx.shutdownSignal.aborted)
|
|
154
|
+
pendingRunStarts.delete(payload.runId);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (ctx.shutdownSignal.aborted)
|
|
158
|
+
return;
|
|
159
|
+
if (!runtimeCommand && backendKind) {
|
|
160
|
+
socket.emit("agent.rejected", {
|
|
161
|
+
runId: payload.runId,
|
|
162
|
+
message: `CLI command not found for ${backendKind}. Install the provider CLI and restart the daemon.`,
|
|
163
|
+
code: "provider_unavailable",
|
|
164
|
+
});
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
let cwd = resolveRuntimeCwd(payload);
|
|
168
|
+
const explicitWorkspacePath = payload.worktreeInfo?.worktreePath ??
|
|
169
|
+
payload.worktreeInfo?.allWorktrees?.[0]?.worktreePath ??
|
|
170
|
+
payload.projectPath;
|
|
171
|
+
const workspaceRequired = Boolean(explicitWorkspacePath);
|
|
172
|
+
const workspacePathPinned = payload.workspacePathPinned === true || Boolean(payload.worktreeInfo);
|
|
173
|
+
if (isAlanDefaultWorkspace(payload.projectPath) && !workspacePathPinned) {
|
|
174
|
+
try {
|
|
175
|
+
mkdirSync(cwd, { recursive: true });
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
// inspectWorkspaceReadiness below preserves the filesystem cause.
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
let workspaceReadiness = inspectWorkspaceReadiness(workspaceRequired ? cwd : undefined);
|
|
182
|
+
const expectedRepoUrls = [
|
|
183
|
+
...(payload.repoLocalPaths ?? [])
|
|
184
|
+
.filter((repo) => explicitWorkspacePath ? resolve(repo.localPath) === resolve(explicitWorkspacePath) : false)
|
|
185
|
+
.map((repo) => repo.repoUrl),
|
|
186
|
+
...(payload.localRepoUrls ?? []),
|
|
187
|
+
];
|
|
188
|
+
if (workspaceReadiness.code === "workspace_missing" &&
|
|
189
|
+
explicitWorkspacePath &&
|
|
190
|
+
!workspacePathPinned) {
|
|
191
|
+
const previousPath = resolve(explicitWorkspacePath);
|
|
192
|
+
const remembered = workspaceRelocations.get(previousPath);
|
|
193
|
+
const rememberedPath = remembered?.canonicalPath;
|
|
194
|
+
const relocated = rememberedPath &&
|
|
195
|
+
workspaceMatchesExpectedRepositories({
|
|
196
|
+
workspacePath: rememberedPath,
|
|
197
|
+
expectedRepoUrls,
|
|
198
|
+
})
|
|
199
|
+
? resolve(rememberedPath)
|
|
200
|
+
: discoverRelocatedWorkspace({
|
|
201
|
+
missingPath: explicitWorkspacePath,
|
|
202
|
+
approvedWorkspacePaths: payload.approvedWorkspacePaths,
|
|
203
|
+
expectedRepoUrls,
|
|
204
|
+
});
|
|
205
|
+
if (relocated) {
|
|
206
|
+
if (!remembered || resolve(remembered.canonicalPath) !== relocated) {
|
|
207
|
+
workspaceRelocations.set(previousPath, {
|
|
208
|
+
conversationId: payload.conversationId,
|
|
209
|
+
runId: payload.runId,
|
|
210
|
+
previousPath,
|
|
211
|
+
canonicalPath: relocated,
|
|
212
|
+
});
|
|
213
|
+
try {
|
|
214
|
+
persistWorkspaceRelocations();
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
workspaceRelocations.delete(previousPath);
|
|
218
|
+
socket.emit("agent.rejected", {
|
|
219
|
+
runId: payload.runId,
|
|
220
|
+
message: `Recovered project path could not be saved safely: ${error.message}`,
|
|
221
|
+
code: "workspace_relocation_persist_failed",
|
|
222
|
+
});
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
cwd = relocated;
|
|
227
|
+
workspaceReadiness = inspectWorkspaceReadiness(cwd);
|
|
228
|
+
pushLog(`workspace-relocated run=${payload.runId} path=${relocated}`);
|
|
229
|
+
flushWorkspaceRelocations();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (workspaceReadiness.ready && expectedRepoUrls.length > 0 && !isAlanDefaultWorkspace(cwd)) {
|
|
233
|
+
// For multi-worktree tasks the cwd is the non-git parent CONTAINER of the
|
|
234
|
+
// per-repo worktrees (resolveRuntimeCwd → dirname(allWorktrees[0])), so a
|
|
235
|
+
// git-identity check on the cwd itself always fails. Verify each worktree
|
|
236
|
+
// path instead — every one must resolve to an expected repository. Single
|
|
237
|
+
// (or no) worktree tasks fall back to checking the cwd directly.
|
|
238
|
+
const worktreePaths = payload.worktreeInfo?.allWorktrees
|
|
239
|
+
?.map((worktree) => worktree.worktreePath)
|
|
240
|
+
.filter((worktreePath) => Boolean(worktreePath));
|
|
241
|
+
const repositoryMismatch = worktreePaths && worktreePaths.length > 0
|
|
242
|
+
? worktreePaths.some((worktreePath) => !workspaceMatchesExpectedRepositories({
|
|
243
|
+
workspacePath: worktreePath,
|
|
244
|
+
expectedRepoUrls,
|
|
245
|
+
}))
|
|
246
|
+
: !workspaceMatchesExpectedRepositories({ workspacePath: cwd, expectedRepoUrls });
|
|
247
|
+
if (repositoryMismatch) {
|
|
248
|
+
socket.emit("agent.rejected", {
|
|
249
|
+
runId: payload.runId,
|
|
250
|
+
message: "This folder belongs to a different repository. Choose the correct project folder and try again.",
|
|
251
|
+
code: "workspace_repository_mismatch",
|
|
252
|
+
});
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (workspaceRequired)
|
|
257
|
+
workspaceAccessTracker.track(cwd, workspaceReadiness);
|
|
258
|
+
const runnerSummary = summarizeRunnerStatus({
|
|
259
|
+
connected: socket.connected,
|
|
260
|
+
activeAgents,
|
|
261
|
+
disconnectedSinceMs,
|
|
262
|
+
daemonSessionId,
|
|
263
|
+
daemonEpoch,
|
|
264
|
+
heartbeatSeq,
|
|
265
|
+
interruptedRunIds: runJournal.recoveredRunIds(),
|
|
266
|
+
endpointProfile,
|
|
267
|
+
configPath,
|
|
268
|
+
runtimeId,
|
|
269
|
+
runtimeAuthValid: Boolean(runtimeToken),
|
|
270
|
+
endpointMismatchDetail: endpointMismatch?.detail ?? null,
|
|
271
|
+
workspacePath: recheckWorkspaceIssue(),
|
|
272
|
+
maintenanceReason: maintenanceReason(),
|
|
273
|
+
reservedStartCount: pendingRunStarts.size,
|
|
274
|
+
nowMs: Date.now(),
|
|
275
|
+
});
|
|
276
|
+
if (!socket.connected) {
|
|
277
|
+
socket.emit("agent.rejected", {
|
|
278
|
+
runId: payload.runId,
|
|
279
|
+
message: "Daemon is disconnected from backend",
|
|
280
|
+
code: "ws_disconnected",
|
|
281
|
+
});
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (!runnerSummary.acceptingRuns) {
|
|
285
|
+
const capacityExhausted = typeof runnerSummary.runnerStatus.availableSlots === "number" &&
|
|
286
|
+
runnerSummary.runnerStatus.availableSlots <= 0 &&
|
|
287
|
+
!maintenanceReason();
|
|
288
|
+
const primaryIssue = pickPrimaryReadinessIssue(runnerSummary.runnerStatus.computerReadiness ?? []);
|
|
289
|
+
socket.emit("agent.rejected", {
|
|
290
|
+
runId: payload.runId,
|
|
291
|
+
message: runnerSummary.runnerStatus.overloadReason ??
|
|
292
|
+
primaryIssue?.message ??
|
|
293
|
+
(capacityExhausted
|
|
294
|
+
? "Local runtime has no available run slots"
|
|
295
|
+
: runnerSummary.activeRunCount > 0
|
|
296
|
+
? "Daemon is busy with an active run"
|
|
297
|
+
: "Daemon is not ready to accept runs"),
|
|
298
|
+
code: capacityExhausted
|
|
299
|
+
? "runner_capacity"
|
|
300
|
+
: (primaryIssue?.code ??
|
|
301
|
+
(runnerSummary.activeRunCount > 0 ? "runner_busy" : "runner_not_ready")),
|
|
302
|
+
});
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (!workspaceReadiness.ready) {
|
|
306
|
+
socket.emit("agent.rejected", {
|
|
307
|
+
runId: payload.runId,
|
|
308
|
+
message: workspaceReadiness.message,
|
|
309
|
+
code: workspaceReadiness.code ?? "workspace_missing",
|
|
310
|
+
});
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
// Reserve capacity before any async preflight. JS is single-threaded, so the
|
|
314
|
+
// check+set without an await between them is race-safe against other executes.
|
|
315
|
+
try {
|
|
316
|
+
pendingRunStarts.set(payload.runId, payload.conversationId);
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
socket.emit("agent.rejected", {
|
|
320
|
+
runId: payload.runId,
|
|
321
|
+
message: `Unable to reserve local runtime capacity: ${error instanceof Error ? error.message : String(error)}`,
|
|
322
|
+
code: "runner_reservation_failed",
|
|
323
|
+
});
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
publishCapacityChange();
|
|
327
|
+
const releaseCapacity = () => {
|
|
328
|
+
if (ctx.shutdownSignal.aborted)
|
|
329
|
+
return;
|
|
330
|
+
if (!pendingRunStarts.delete(payload.runId))
|
|
331
|
+
return;
|
|
332
|
+
publishCapacityChange();
|
|
333
|
+
};
|
|
334
|
+
const alanMcp = buildManagedAlanMcp({
|
|
335
|
+
apiUrl,
|
|
336
|
+
runtimeToken,
|
|
337
|
+
runId: payload.runId,
|
|
338
|
+
});
|
|
339
|
+
if (!socket.connected) {
|
|
340
|
+
releaseCapacity();
|
|
341
|
+
socket.emit("agent.rejected", {
|
|
342
|
+
runId: payload.runId,
|
|
343
|
+
message: "Daemon disconnected while preparing the provider",
|
|
344
|
+
code: "ws_disconnected",
|
|
345
|
+
});
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const correlation = correlationLogFields({
|
|
349
|
+
taskId: payload.taskId ?? payload.taskMeta?.id,
|
|
350
|
+
conversationId: payload.conversationId,
|
|
351
|
+
runId: payload.runId,
|
|
352
|
+
messageId: payload.messageId,
|
|
353
|
+
cloudEnvironmentId: payload.cloudEnvironmentId,
|
|
354
|
+
backendKind,
|
|
355
|
+
agentVersion: AGENT_VERSION,
|
|
356
|
+
});
|
|
357
|
+
const authPromise = backendKind && runtimeCommand && !payload.providerApiKey
|
|
358
|
+
? preflightProviderAuth({
|
|
359
|
+
backendKind,
|
|
360
|
+
executable: runtimeCommand,
|
|
361
|
+
env: getDaemonCliEnvironment(),
|
|
362
|
+
}).catch(() => ({ status: "unknown" }))
|
|
363
|
+
: Promise.resolve({ status: "unknown" });
|
|
364
|
+
const skillTaskPromise = prepareSkillInvocationTask({
|
|
365
|
+
manager: runtimeSkillManager,
|
|
366
|
+
runtimeId,
|
|
367
|
+
invocations: payload.skillInvocations,
|
|
368
|
+
invocation: payload.skillInvocation,
|
|
369
|
+
userRequest: payload.content,
|
|
370
|
+
});
|
|
371
|
+
let providerAuth;
|
|
372
|
+
let preparedTask;
|
|
373
|
+
try {
|
|
374
|
+
[providerAuth, preparedTask] = await Promise.all([authPromise, skillTaskPromise]);
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
releaseCapacity();
|
|
378
|
+
socket.emit("agent.rejected", {
|
|
379
|
+
runId: payload.runId,
|
|
380
|
+
message: error instanceof Error ? error.message : "Selected Skill could not be resolved",
|
|
381
|
+
code: "skill_invocation_unavailable",
|
|
382
|
+
});
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
if (ctx.shutdownSignal.aborted) {
|
|
386
|
+
releaseCapacity();
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (providerAuth.status === "auth_required") {
|
|
390
|
+
releaseCapacity();
|
|
391
|
+
socket.emit("agent.rejected", {
|
|
392
|
+
runId: payload.runId,
|
|
393
|
+
message: providerAuth.message ?? "The selected provider requires sign-in.",
|
|
394
|
+
code: "provider_auth_required",
|
|
395
|
+
});
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
// Close the TOCTOU window for a dispatch that began preflight just before
|
|
399
|
+
// an external watchdog acquired maintenance. No journal/provider side
|
|
400
|
+
// effects have started yet, so it is safe to reject here.
|
|
401
|
+
const maintenanceLeaseBeforeJournal = readLocalDaemonMaintenanceLease(configPath);
|
|
402
|
+
if (maintenanceLeaseBeforeJournal) {
|
|
403
|
+
releaseCapacity();
|
|
404
|
+
socket.emit("agent.rejected", {
|
|
405
|
+
runId: payload.runId,
|
|
406
|
+
message: maintenanceLeaseBeforeJournal.reason === "credential_cleanup"
|
|
407
|
+
? "This computer is finishing logout and cannot start another run."
|
|
408
|
+
: "This computer is under short-lived maintenance; retry shortly.",
|
|
409
|
+
code: maintenanceLeaseBeforeJournal.reason === "credential_cleanup"
|
|
410
|
+
? "runtime_logout_pending"
|
|
411
|
+
: "runtime_maintenance_pending",
|
|
412
|
+
});
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
try {
|
|
416
|
+
runJournal.record({
|
|
417
|
+
runId: payload.runId,
|
|
418
|
+
conversationId: payload.conversationId,
|
|
419
|
+
acceptedAtMs: Date.now(),
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
catch {
|
|
423
|
+
releaseCapacity();
|
|
424
|
+
pushLog(`run-journal-write-failed run=${payload.runId}`);
|
|
425
|
+
socket.emit("agent.rejected", {
|
|
426
|
+
runId: payload.runId,
|
|
427
|
+
message: "Alan could not safely record this run before starting it. Check disk access.",
|
|
428
|
+
code: "run_journal_unavailable",
|
|
429
|
+
});
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
socket.emit("agent.accepted", { runId: payload.runId });
|
|
433
|
+
pushLog(`accepted run=${payload.runId}`);
|
|
434
|
+
console.info("[alan-agent] Agent run accepted", correlation);
|
|
435
|
+
// Shared-checkout runs (no worktree): put the checkout(s) onto the task's
|
|
436
|
+
// working branch cut from base, so the agent never commits onto the base
|
|
437
|
+
// branch directly. Best-effort — a dirty tree is left untouched.
|
|
438
|
+
if (!payload.worktreeInfo?.worktreePath && payload.sharedCheckout?.branchName) {
|
|
439
|
+
const repoTargets = resolveSharedCheckoutTargets({
|
|
440
|
+
cwd,
|
|
441
|
+
sharedCheckout: payload.sharedCheckout,
|
|
442
|
+
});
|
|
443
|
+
for (const { repoPath, baseBranch } of repoTargets) {
|
|
444
|
+
try {
|
|
445
|
+
const result = ensureSharedCheckoutBranch({
|
|
446
|
+
repoPath,
|
|
447
|
+
branchName: payload.sharedCheckout.branchName,
|
|
448
|
+
baseBranch,
|
|
449
|
+
});
|
|
450
|
+
if (!result.checkedOut) {
|
|
451
|
+
pushLog(`shared-branch skipped run=${payload.runId} ${repoPath}: ${result.reason}`);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
catch (error) {
|
|
455
|
+
pushLog(`shared-branch error run=${payload.runId} ${repoPath} ${error.message}`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
// Preserved/imported folders may have no server-side repository URL metadata.
|
|
460
|
+
// Their Git identity still needs the same lease as an ordinary Project checkout.
|
|
461
|
+
const hasRepository = expectedRepoUrls.length > 0 ||
|
|
462
|
+
(workspaceRequired && !isAlanDefaultWorkspace(cwd) && (await hasGitWorkspaceMarker(cwd)));
|
|
463
|
+
const workspaceLeaseCapture = await WorkspaceRunLease.capture(resolveWorkspaceRunLeaseTargets(payload, cwd, hasRepository));
|
|
464
|
+
if (ctx.shutdownSignal.aborted) {
|
|
465
|
+
releaseCapacity();
|
|
466
|
+
// Keep the accepted journal binding: recovery must fence redelivery.
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (workspaceLeaseCapture.failure) {
|
|
470
|
+
const failure = workspaceLeaseCapture.failure;
|
|
471
|
+
const runFailure = buildApplicationRunFailure({
|
|
472
|
+
conversationId: payload.conversationId,
|
|
473
|
+
runId: payload.runId,
|
|
474
|
+
// A run dispatched onto the wrong branch is also not a missing workspace.
|
|
475
|
+
code: applicationCodeForWorkspaceLeaseFailure(failure.code),
|
|
476
|
+
detail: failure.message,
|
|
477
|
+
component: "agent-manager-workspace-lease",
|
|
478
|
+
phase: "dispatch",
|
|
479
|
+
});
|
|
480
|
+
for (const event of runFailure.events) {
|
|
481
|
+
eventOutbox.enqueue(payload.conversationId, payload.runId, event);
|
|
482
|
+
}
|
|
483
|
+
eventOutbox.flush(socket);
|
|
484
|
+
releaseCapacity();
|
|
485
|
+
try {
|
|
486
|
+
runJournal.remove(payload.runId);
|
|
487
|
+
}
|
|
488
|
+
catch {
|
|
489
|
+
pushLog(`run-journal-remove-failed run=${payload.runId}`);
|
|
490
|
+
}
|
|
491
|
+
pushLog(`workspace-lease-unavailable run=${payload.runId} code=${failure.code}`);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
const nowMs = Date.now();
|
|
495
|
+
const touchActivity = () => {
|
|
496
|
+
const entry = activeAgents.get(payload.runId);
|
|
497
|
+
if (entry)
|
|
498
|
+
entry.lastActivityAtMs = Date.now();
|
|
499
|
+
};
|
|
500
|
+
let agent;
|
|
501
|
+
const releaseActiveRun = () => {
|
|
502
|
+
if (activeAgents.get(payload.runId)?.agent !== agent)
|
|
503
|
+
return;
|
|
504
|
+
activeAgents.delete(payload.runId);
|
|
505
|
+
console.info("[alan-agent] Agent run finished", correlation);
|
|
506
|
+
publishCapacityChange();
|
|
507
|
+
};
|
|
508
|
+
let finalization = null;
|
|
509
|
+
const finalizeRun = () => {
|
|
510
|
+
if (finalization)
|
|
511
|
+
return finalization;
|
|
512
|
+
const entry = activeAgents.get(payload.runId);
|
|
513
|
+
if (entry)
|
|
514
|
+
entry.cleanupState = "stopping";
|
|
515
|
+
finalization = (async () => {
|
|
516
|
+
if (!(await agent.cleanup())) {
|
|
517
|
+
const entry = activeAgents.get(payload.runId);
|
|
518
|
+
if (entry)
|
|
519
|
+
entry.cleanupState = "failed";
|
|
520
|
+
pushLog(`provider-cleanup-failed run=${payload.runId}; ownership retained`);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
if (ctx.shutdownSignal.aborted) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
try {
|
|
527
|
+
runJournal.remove(payload.runId);
|
|
528
|
+
}
|
|
529
|
+
catch {
|
|
530
|
+
pushLog(`run-journal-remove-failed run=${payload.runId}`);
|
|
531
|
+
}
|
|
532
|
+
releaseActiveRun();
|
|
533
|
+
})().catch((error) => {
|
|
534
|
+
if (entry)
|
|
535
|
+
entry.cleanupState = "failed";
|
|
536
|
+
pushLog(`provider-finalization-failed run=${payload.runId} ${String(error)}; ownership retained`);
|
|
537
|
+
});
|
|
538
|
+
return finalization;
|
|
539
|
+
};
|
|
540
|
+
const presenter = new RuntimePresenter(socket, payload.conversationId, payload.runId, eventOutbox, cwd, touchActivity, (result) => {
|
|
541
|
+
// Aborts still need the backend's finally path; retaining its accepted
|
|
542
|
+
// journal entry fences redelivery if the daemon exits first.
|
|
543
|
+
if (result?.success)
|
|
544
|
+
void finalizeRun();
|
|
545
|
+
}, () => {
|
|
546
|
+
const entry = activeAgents.get(payload.runId);
|
|
547
|
+
if (entry)
|
|
548
|
+
entry.stage = "running";
|
|
549
|
+
}, async () => {
|
|
550
|
+
const entry = activeAgents.get(payload.runId);
|
|
551
|
+
return entry ? verifyActiveWorkspaceLease(payload.runId, entry, Date.now(), true) : false;
|
|
552
|
+
}, () => {
|
|
553
|
+
if (backendKind && runtimeCommand) {
|
|
554
|
+
invalidateProviderAuthPreflight(backendKind, runtimeCommand);
|
|
555
|
+
}
|
|
556
|
+
}, backendKind);
|
|
557
|
+
try {
|
|
558
|
+
agent = new CoreAgent(presenter, {
|
|
559
|
+
backendKind,
|
|
560
|
+
runtimeCommand,
|
|
561
|
+
runId: payload.runId,
|
|
562
|
+
runtimeToken,
|
|
563
|
+
providerApiKey: payload.providerApiKey,
|
|
564
|
+
onProviderSpawned: (pid) => {
|
|
565
|
+
const entry = activeAgents.get(payload.runId);
|
|
566
|
+
if (!entry)
|
|
567
|
+
return;
|
|
568
|
+
entry.providerPid = pid;
|
|
569
|
+
entry.stage = "provider_started";
|
|
570
|
+
entry.lastActivityAtMs = Date.now();
|
|
571
|
+
try {
|
|
572
|
+
runJournal.recordProviderSpawned(payload.runId, pid, entry.lastActivityAtMs);
|
|
573
|
+
}
|
|
574
|
+
catch {
|
|
575
|
+
// The accepted binding is already durable and continues to fence
|
|
576
|
+
// redelivery. PID evidence is diagnostic only, so never kill or
|
|
577
|
+
// fail a running provider because this optional update failed.
|
|
578
|
+
pushLog(`run-journal-provider-evidence-write-failed run=${payload.runId}`);
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
catch (error) {
|
|
584
|
+
releaseCapacity();
|
|
585
|
+
try {
|
|
586
|
+
runJournal.remove(payload.runId);
|
|
587
|
+
}
|
|
588
|
+
catch {
|
|
589
|
+
pushLog(`run-journal-remove-failed run=${payload.runId}`);
|
|
590
|
+
}
|
|
591
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
592
|
+
socket.emit("agent.rejected", {
|
|
593
|
+
runId: payload.runId,
|
|
594
|
+
message: `Provider startup failed: ${message}`,
|
|
595
|
+
code: "provider_start_failed",
|
|
596
|
+
});
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
activeAgents.set(payload.runId, {
|
|
600
|
+
agent,
|
|
601
|
+
presenter,
|
|
602
|
+
lastActivityAtMs: nowMs,
|
|
603
|
+
acceptedAtMs: nowMs,
|
|
604
|
+
stage: "provider_starting",
|
|
605
|
+
providerPid: null,
|
|
606
|
+
conversationId: payload.conversationId,
|
|
607
|
+
workspaceLease: workspaceLeaseCapture.lease,
|
|
608
|
+
});
|
|
609
|
+
// Slot moves from reserved → active; publish so heartbeats advertise correctly.
|
|
610
|
+
releaseCapacity();
|
|
611
|
+
void agent
|
|
612
|
+
.run({
|
|
613
|
+
task: preparedTask,
|
|
614
|
+
maxIterations: payload.maxIterations ?? 50,
|
|
615
|
+
teamPath: cwd,
|
|
616
|
+
cwd,
|
|
617
|
+
backendKind,
|
|
618
|
+
runtimeCommand,
|
|
619
|
+
agentId: payload.agentId,
|
|
620
|
+
agentPrompt: payload.agentPrompt,
|
|
621
|
+
mode: (payload.mode ?? "agent"),
|
|
622
|
+
selectedModel: payload.model,
|
|
623
|
+
selectedContextWindow: payload.selectedContextWindow ?? null,
|
|
624
|
+
selectedEffortLevel: payload.selectedEffortLevel ?? null,
|
|
625
|
+
providerSessionId: payload.providerSessionId,
|
|
626
|
+
resumeFallbackContext: payload.resumeFallbackContext,
|
|
627
|
+
taskMeta: payload.taskMeta,
|
|
628
|
+
prMeta: payload.prMeta,
|
|
629
|
+
conversationId: payload.conversationId,
|
|
630
|
+
alanMcp,
|
|
631
|
+
externalMcpServers: payload.externalMcpServers,
|
|
632
|
+
taskId: payload.taskId ?? payload.taskMeta?.id,
|
|
633
|
+
teamId: payload.teamId,
|
|
634
|
+
currentUser: payload.currentUser,
|
|
635
|
+
workflowTools: payload.workflowTools,
|
|
636
|
+
workflowId: payload.workflowId,
|
|
637
|
+
workflowExecutionId: payload.workflowExecutionId,
|
|
638
|
+
images: payload.images,
|
|
639
|
+
files: payload.files,
|
|
640
|
+
parsedAttachments: payload.parsedAttachments,
|
|
641
|
+
})
|
|
642
|
+
.catch((error) => {
|
|
643
|
+
if (presenter.isTerminalFenced())
|
|
644
|
+
return;
|
|
645
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
646
|
+
pushLog(`failed run=${payload.runId} ${message}`);
|
|
647
|
+
console.error("[alan-agent] Agent run failed", {
|
|
648
|
+
...correlation,
|
|
649
|
+
error: message,
|
|
650
|
+
});
|
|
651
|
+
// Mid-run sign-out (or expired CLI session) must drop sticky ready so
|
|
652
|
+
// the next send re-probes and surfaces provider_auth_required cleanly
|
|
653
|
+
// instead of accepting again and failing the same way.
|
|
654
|
+
if (backendKind && runtimeCommand && looksLikeProviderAuthFailure(message)) {
|
|
655
|
+
invalidateProviderAuthPreflight(backendKind, runtimeCommand);
|
|
656
|
+
}
|
|
657
|
+
presenter.failApplicationProblem({
|
|
658
|
+
code: "app.internal",
|
|
659
|
+
detail: message,
|
|
660
|
+
component: "agent-manager-daemon",
|
|
661
|
+
phase: "delivery",
|
|
662
|
+
});
|
|
663
|
+
})
|
|
664
|
+
.finally(finalizeRun);
|
|
665
|
+
}
|
|
666
|
+
//# sourceMappingURL=daemon-execute.js.map
|