@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,769 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { buildDaemonServicePlan, ensureDaemonServiceDefinition, forceStopDaemonServiceAndWait, inspectDaemonService, ownerMatchesDaemonIdentity, parseServiceHostState, resolveEnsureDefinitionOutcome, runServiceCommand, stopDaemonServiceAndWait, uninstallDaemonService, } from "../service-manager.js";
|
|
7
|
+
const baseInput = {
|
|
8
|
+
homeDir: "/Users/Test Person",
|
|
9
|
+
nodeExecutable: "/opt/node bin/node",
|
|
10
|
+
cliEntry: "/opt/alan agent/index.cjs",
|
|
11
|
+
profile: "production",
|
|
12
|
+
userId: 501,
|
|
13
|
+
};
|
|
14
|
+
function decodeWindowsLauncher(registerCommand) {
|
|
15
|
+
const encoded = registerCommand.match(/-EncodedCommand ([A-Za-z0-9+/=]+)/u)?.[1];
|
|
16
|
+
expect(encoded).toBeDefined();
|
|
17
|
+
return Buffer.from(encoded, "base64").toString("utf16le");
|
|
18
|
+
}
|
|
19
|
+
describe("buildDaemonServicePlan", () => {
|
|
20
|
+
it("reloads a stopped launchd definition without force-killing a running service", () => {
|
|
21
|
+
const plan = buildDaemonServicePlan({ ...baseInput, platform: "darwin" });
|
|
22
|
+
expect(plan.manifestPath).toBe(join(baseInput.homeDir, "Library", "LaunchAgents", "ai.tryalan.agent.plist"));
|
|
23
|
+
expect(plan.manifest).toContain("<key>KeepAlive</key>");
|
|
24
|
+
expect(plan.manifest).toContain("<key>ThrottleInterval</key>");
|
|
25
|
+
expect(plan.manifest).toContain("/opt/node bin/node");
|
|
26
|
+
expect(plan.startCommands).toEqual([
|
|
27
|
+
{
|
|
28
|
+
command: "launchctl",
|
|
29
|
+
args: ["kickstart", "gui/501/ai.tryalan.agent"],
|
|
30
|
+
tolerateFailure: false,
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
expect(plan.loadDefinitionCommands.some((command) => command.args.includes("bootout"))).toBe(false);
|
|
34
|
+
expect(plan.reloadDefinitionCommands).toEqual([
|
|
35
|
+
{
|
|
36
|
+
command: "launchctl",
|
|
37
|
+
args: [
|
|
38
|
+
"bootout",
|
|
39
|
+
"gui/501",
|
|
40
|
+
join(baseInput.homeDir, "Library", "LaunchAgents", "ai.tryalan.agent.plist"),
|
|
41
|
+
],
|
|
42
|
+
tolerateFailure: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
command: "launchctl",
|
|
46
|
+
args: [
|
|
47
|
+
"bootstrap",
|
|
48
|
+
"gui/501",
|
|
49
|
+
join(baseInput.homeDir, "Library", "LaunchAgents", "ai.tryalan.agent.plist"),
|
|
50
|
+
],
|
|
51
|
+
tolerateFailure: false,
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
expect(plan.startCommands.some((command) => command.args.includes("-k"))).toBe(false);
|
|
55
|
+
expect(plan.forceStopCommands).toEqual([
|
|
56
|
+
{
|
|
57
|
+
command: "launchctl",
|
|
58
|
+
args: [
|
|
59
|
+
"bootout",
|
|
60
|
+
"gui/501",
|
|
61
|
+
join(baseInput.homeDir, "Library", "LaunchAgents", "ai.tryalan.agent.plist"),
|
|
62
|
+
],
|
|
63
|
+
tolerateFailure: true,
|
|
64
|
+
},
|
|
65
|
+
]);
|
|
66
|
+
});
|
|
67
|
+
it("configures Electron as a Node runtime for a desktop-delivered service", () => {
|
|
68
|
+
const runtime = {
|
|
69
|
+
...baseInput,
|
|
70
|
+
platform: "darwin",
|
|
71
|
+
nodeExecutable: "/Applications/Alan.app/Contents/MacOS/Alan",
|
|
72
|
+
cliEntry: "/Applications/Alan.app/Contents/Resources/alan-agent/index.cjs",
|
|
73
|
+
environment: { ELECTRON_RUN_AS_NODE: "1" },
|
|
74
|
+
};
|
|
75
|
+
const launchd = buildDaemonServicePlan(runtime);
|
|
76
|
+
const systemd = buildDaemonServicePlan({ ...runtime, platform: "linux" });
|
|
77
|
+
expect(launchd.manifest).toContain("<key>ELECTRON_RUN_AS_NODE</key>");
|
|
78
|
+
expect(launchd.manifest).toContain("<string>1</string>");
|
|
79
|
+
expect(systemd.manifest).toContain('Environment="ELECTRON_RUN_AS_NODE=1"');
|
|
80
|
+
});
|
|
81
|
+
it("enables systemd without starting it", () => {
|
|
82
|
+
const plan = buildDaemonServicePlan({ ...baseInput, platform: "linux" });
|
|
83
|
+
expect(plan.manifestPath).toBe(join(baseInput.homeDir, ".config", "systemd", "user", "alan-agent.service"));
|
|
84
|
+
expect(plan.manifest).toContain("Restart=on-failure");
|
|
85
|
+
expect(plan.manifest).toContain("RestartSec=5");
|
|
86
|
+
expect(plan.manifest).toContain('ExecStart="/opt/node bin/node" "/opt/alan agent/index.cjs" "daemon" "--profile" "production"');
|
|
87
|
+
expect(plan.enableCommands).toContainEqual({
|
|
88
|
+
command: "systemctl",
|
|
89
|
+
args: ["--user", "enable", "alan-agent.service"],
|
|
90
|
+
tolerateFailure: false,
|
|
91
|
+
});
|
|
92
|
+
expect(plan.enableCommands.some((command) => command.args.includes("--now"))).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
it("registers a Windows task without forcing start in loadDefinition", () => {
|
|
95
|
+
const plan = buildDaemonServicePlan({
|
|
96
|
+
...baseInput,
|
|
97
|
+
platform: "win32",
|
|
98
|
+
homeDir: "C:\\Users\\Test Person",
|
|
99
|
+
nodeExecutable: "C:\\Program Files\\nodejs\\node.exe",
|
|
100
|
+
cliEntry: "C:\\Users\\Test Person\\alan-agent\\index.cjs",
|
|
101
|
+
environment: { ELECTRON_RUN_AS_NODE: "1" },
|
|
102
|
+
});
|
|
103
|
+
expect(plan.manifestPath).toBeNull();
|
|
104
|
+
expect(plan.loadDefinitionCommands).toHaveLength(1);
|
|
105
|
+
expect(plan.loadDefinitionCommands[0]?.command).toBe("powershell.exe");
|
|
106
|
+
const registerCommand = plan.loadDefinitionCommands[0]?.args.join(" ") ?? "";
|
|
107
|
+
expect(registerCommand).toContain("RestartCount 3");
|
|
108
|
+
expect(registerCommand).toContain("-AllowStartIfOnBatteries");
|
|
109
|
+
expect(registerCommand).toContain("-DontStopIfGoingOnBatteries");
|
|
110
|
+
expect(registerCommand).toContain("$currentIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()");
|
|
111
|
+
expect(registerCommand).toContain("$currentUser = $currentIdentity.Name");
|
|
112
|
+
expect(registerCommand).toContain("$currentSid = $currentIdentity.User.Value");
|
|
113
|
+
expect(registerCommand).toContain("$taskName = 'Alan Agent' + ' ' + $currentSid");
|
|
114
|
+
expect(registerCommand).toContain("New-ScheduledTaskTrigger -AtLogOn -User $currentUser");
|
|
115
|
+
expect(registerCommand).toContain("New-ScheduledTaskPrincipal -UserId $currentUser -LogonType Interactive -RunLevel Limited");
|
|
116
|
+
expect(registerCommand).toContain("Register-ScheduledTask -TaskName $taskName -Description");
|
|
117
|
+
expect(registerCommand).toContain("-Principal $principal");
|
|
118
|
+
expect(registerCommand).toContain("$legacySid -eq $currentSid");
|
|
119
|
+
expect(registerCommand).toContain("Legacy Alan Agent task is not owned");
|
|
120
|
+
const launcher = decodeWindowsLauncher(registerCommand);
|
|
121
|
+
expect(launcher).toContain("[System.Diagnostics.ProcessStartInfo]::new()");
|
|
122
|
+
expect(launcher).toContain("$startInfo.UseShellExecute = $false");
|
|
123
|
+
expect(launcher).toContain("$startInfo.CreateNoWindow = $true");
|
|
124
|
+
expect(launcher).toContain("$startInfo.RedirectStandardOutput = $true");
|
|
125
|
+
expect(launcher).toContain("$startInfo.RedirectStandardError = $true");
|
|
126
|
+
expect(launcher).toContain("$startInfo.EnvironmentVariables['ELECTRON_RUN_AS_NODE'] = '1'");
|
|
127
|
+
expect(launcher).toContain("$process.StandardOutput.BaseStream.CopyToAsync");
|
|
128
|
+
expect(launcher).toContain("$process.StandardError.BaseStream.CopyToAsync");
|
|
129
|
+
expect(launcher).toContain("$process.WaitForExit()");
|
|
130
|
+
expect(launcher).toContain("exit $exitCode");
|
|
131
|
+
expect(launcher).toContain("C:\\Users\\Test Person\\.alan\\agent\\logs");
|
|
132
|
+
expect(launcher).not.toContain("; & '");
|
|
133
|
+
expect(plan.startCommands[0]?.args.join(" ")).toContain("$taskName = 'Alan Agent' + ' ' + $currentSid; Start-ScheduledTask -TaskName $taskName");
|
|
134
|
+
expect(plan.definitionMarker).toMatch(/^Alan daemon owner v1 [a-f0-9]{64}; definition v3 [a-f0-9]{64}$/u);
|
|
135
|
+
});
|
|
136
|
+
it("uses the hidden supervised launcher for a standalone Node installation", () => {
|
|
137
|
+
const plan = buildDaemonServicePlan({
|
|
138
|
+
...baseInput,
|
|
139
|
+
platform: "win32",
|
|
140
|
+
homeDir: "C:\\Users\\O'Brien",
|
|
141
|
+
nodeExecutable: "C:\\Program Files\\nodejs\\node.exe",
|
|
142
|
+
cliEntry: "C:\\Users\\O'Brien\\alan agent\\index.cjs",
|
|
143
|
+
});
|
|
144
|
+
const registerCommand = plan.loadDefinitionCommands[0]?.args.at(-1) ?? "";
|
|
145
|
+
expect(registerCommand).toContain("New-ScheduledTaskAction -Execute 'powershell.exe'");
|
|
146
|
+
const launcher = decodeWindowsLauncher(registerCommand);
|
|
147
|
+
expect(launcher).toContain("$startInfo.FileName = 'C:\\Program Files\\nodejs\\node.exe'");
|
|
148
|
+
expect(launcher).toContain("\"C:\\Users\\O''Brien\\alan agent\\index.cjs\"");
|
|
149
|
+
expect(launcher).toContain("$startInfo.WorkingDirectory = 'C:\\Users\\O''Brien\\alan agent'");
|
|
150
|
+
expect(launcher).toContain("$startInfo.CreateNoWindow = $true");
|
|
151
|
+
expect(launcher).toContain("exit $exitCode");
|
|
152
|
+
});
|
|
153
|
+
it.runIf(process.platform === "win32")("returns failure when launcher logs cannot be opened", async () => {
|
|
154
|
+
const tempDir = mkdtempSync(join(tmpdir(), "alan-launcher-log-failure-"));
|
|
155
|
+
try {
|
|
156
|
+
const blockedHome = join(tempDir, "blocked-home");
|
|
157
|
+
const fixture = join(tempDir, "fixture.cjs");
|
|
158
|
+
writeFileSync(blockedHome, "not a directory");
|
|
159
|
+
writeFileSync(fixture, "process.exit(37);\n");
|
|
160
|
+
const plan = buildDaemonServicePlan({
|
|
161
|
+
platform: "win32",
|
|
162
|
+
homeDir: blockedHome,
|
|
163
|
+
nodeExecutable: process.execPath,
|
|
164
|
+
cliEntry: fixture,
|
|
165
|
+
profile: "production",
|
|
166
|
+
});
|
|
167
|
+
const registerCommand = plan.loadDefinitionCommands[0]?.args.at(-1) ?? "";
|
|
168
|
+
const launcher = decodeWindowsLauncher(registerCommand);
|
|
169
|
+
const result = spawnSync("powershell.exe", [
|
|
170
|
+
"-NoProfile",
|
|
171
|
+
"-NonInteractive",
|
|
172
|
+
"-WindowStyle",
|
|
173
|
+
"Hidden",
|
|
174
|
+
"-EncodedCommand",
|
|
175
|
+
Buffer.from(launcher, "utf16le").toString("base64"),
|
|
176
|
+
], { encoding: "utf8", windowsHide: true, timeout: 15_000 });
|
|
177
|
+
expect(launcher).toContain("$ErrorActionPreference = 'Stop'");
|
|
178
|
+
expect(result.status).not.toBe(0);
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
it.runIf(process.platform === "win32")("recognizes only exact legacy Windows actions as owned", async () => {
|
|
185
|
+
const nodeExecutable = "C:\\Program Files\\Alan QA\\Alan.exe";
|
|
186
|
+
const cliEntry = "C:\\Users\\O'Brien\\Alan Agent\\index.cjs";
|
|
187
|
+
const plan = buildDaemonServicePlan({
|
|
188
|
+
platform: "win32",
|
|
189
|
+
homeDir: "C:\\Users\\O'Brien",
|
|
190
|
+
nodeExecutable,
|
|
191
|
+
cliEntry,
|
|
192
|
+
profile: "production",
|
|
193
|
+
environment: { ELECTRON_RUN_AS_NODE: "1" },
|
|
194
|
+
});
|
|
195
|
+
const registerCommand = plan.loadDefinitionCommands[0]?.args.at(-1) ?? "";
|
|
196
|
+
const encoded = registerCommand.match(/-EncodedCommand ([A-Za-z0-9+/=]+)/u)?.[1];
|
|
197
|
+
expect(encoded).toBeDefined();
|
|
198
|
+
const currentArguments = `-NoProfile -NonInteractive -WindowStyle Hidden -EncodedCommand ${encoded}`;
|
|
199
|
+
const oldArguments = `-NoProfile -NonInteractive -WindowStyle Hidden -Command "$env:ELECTRON_RUN_AS_NODE = '1'; & '${nodeExecutable}' '${cliEntry.replaceAll("'", "''")}' daemon --profile production"`;
|
|
200
|
+
const cases = [
|
|
201
|
+
{
|
|
202
|
+
name: "old-exact",
|
|
203
|
+
state: "Running",
|
|
204
|
+
execute: "powershell.exe",
|
|
205
|
+
arguments: oldArguments,
|
|
206
|
+
workDir: "",
|
|
207
|
+
owned: true,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: "current-exact",
|
|
211
|
+
state: "Queued",
|
|
212
|
+
execute: "powershell.exe",
|
|
213
|
+
arguments: currentArguments,
|
|
214
|
+
workDir: dirname(cliEntry),
|
|
215
|
+
owned: true,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "wrong-executable",
|
|
219
|
+
execute: "cmd.exe",
|
|
220
|
+
arguments: oldArguments,
|
|
221
|
+
workDir: "",
|
|
222
|
+
owned: false,
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "suffix",
|
|
226
|
+
execute: "powershell.exe",
|
|
227
|
+
arguments: `${oldArguments}-foreign`,
|
|
228
|
+
workDir: "",
|
|
229
|
+
owned: false,
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "extra-command",
|
|
233
|
+
execute: "powershell.exe",
|
|
234
|
+
arguments: `${oldArguments}; calc.exe`,
|
|
235
|
+
workDir: "",
|
|
236
|
+
owned: false,
|
|
237
|
+
},
|
|
238
|
+
];
|
|
239
|
+
const statusScript = plan.isActiveCommand.args.at(-1) ?? "";
|
|
240
|
+
const powershell = `
|
|
241
|
+
$statusSource = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Buffer.from(statusScript).toString("base64")}'))
|
|
242
|
+
$cases = ConvertFrom-Json ([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Buffer.from(JSON.stringify(cases)).toString("base64")}')))
|
|
243
|
+
$results = foreach ($case in $cases) {
|
|
244
|
+
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
|
245
|
+
$script:fakeTask = [pscustomobject]@{
|
|
246
|
+
TaskPath = '\\'; TaskName = 'Alan Agent'; State = $(if ($case.state) { $case.state } else { 'Ready' })
|
|
247
|
+
Principal = [pscustomobject]@{ UserId = $identity.Name }
|
|
248
|
+
Actions = @([pscustomobject]@{ Execute = $case.execute; Arguments = $case.arguments; WorkingDirectory = $case.workDir })
|
|
249
|
+
}
|
|
250
|
+
function Get-ScheduledTask { [CmdletBinding()] param(); return $script:fakeTask }
|
|
251
|
+
$output = @(& ([scriptblock]::Create($statusSource)))
|
|
252
|
+
[pscustomobject]@{ name = $case.name; owned = [bool]($output -contains 'LegacyOwned: True'); output = ($output -join "\`n") }
|
|
253
|
+
}
|
|
254
|
+
$results | ConvertTo-Json -Compress
|
|
255
|
+
`;
|
|
256
|
+
const result = spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", powershell], { encoding: "utf8", windowsHide: true, timeout: 15_000 });
|
|
257
|
+
expect(result.status).toBe(0);
|
|
258
|
+
const results = JSON.parse(result.stdout);
|
|
259
|
+
expect(results.map(({ name, owned }) => ({ name, owned }))).toEqual(cases.map(({ name, owned }) => ({ name, owned })));
|
|
260
|
+
for (const result of results) {
|
|
261
|
+
const inspection = await inspectDaemonService({
|
|
262
|
+
platform: "win32",
|
|
263
|
+
runtime: { executable: nodeExecutable, cliEntry },
|
|
264
|
+
runCommand: () => ({ status: 0, output: result.output }),
|
|
265
|
+
});
|
|
266
|
+
expect(inspection.state).toBe(!result.owned ? "unknown" : result.name === "old-exact" ? "running" : "starting");
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
it("isolates non-production services from production on every host platform", () => {
|
|
270
|
+
const launchd = buildDaemonServicePlan({
|
|
271
|
+
...baseInput,
|
|
272
|
+
profile: "local",
|
|
273
|
+
platform: "darwin",
|
|
274
|
+
});
|
|
275
|
+
const systemd = buildDaemonServicePlan({
|
|
276
|
+
...baseInput,
|
|
277
|
+
profile: "local",
|
|
278
|
+
platform: "linux",
|
|
279
|
+
});
|
|
280
|
+
const windows = buildDaemonServicePlan({
|
|
281
|
+
...baseInput,
|
|
282
|
+
profile: "local",
|
|
283
|
+
platform: "win32",
|
|
284
|
+
});
|
|
285
|
+
expect(launchd.manifestPath).toBe(join(baseInput.homeDir, "Library", "LaunchAgents", "ai.tryalan.agent.local.plist"));
|
|
286
|
+
expect(launchd.manifest).toContain("<string>ai.tryalan.agent.local</string>");
|
|
287
|
+
expect(launchd.manifest).toContain(join(baseInput.homeDir, ".alan-dev", "agent", "logs"));
|
|
288
|
+
expect(launchd.logDirectory).toBe(join(baseInput.homeDir, ".alan-dev", "agent", "logs"));
|
|
289
|
+
expect(systemd.manifestPath).toBe(join(baseInput.homeDir, ".config", "systemd", "user", "alan-agent-local.service"));
|
|
290
|
+
expect(systemd.statusCommand.args).toContain("alan-agent-local.service");
|
|
291
|
+
expect(windows.statusCommand.args.join(" ")).toContain("'Alan Agent Local'");
|
|
292
|
+
});
|
|
293
|
+
it("restarts a failed identity handoff on every supported service host", () => {
|
|
294
|
+
const launchd = buildDaemonServicePlan({ ...baseInput, platform: "darwin" });
|
|
295
|
+
const systemd = buildDaemonServicePlan({ ...baseInput, platform: "linux" });
|
|
296
|
+
const windows = buildDaemonServicePlan({ ...baseInput, platform: "win32" });
|
|
297
|
+
expect(launchd.manifest).toContain("<key>SuccessfulExit</key>\n <false/>");
|
|
298
|
+
expect(systemd.manifest).toContain("Restart=on-failure");
|
|
299
|
+
expect(windows.loadDefinitionCommands[0]?.args.join(" ")).toContain("RestartCount 3");
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
describe("forced macOS daemon stop", () => {
|
|
303
|
+
const identity = {
|
|
304
|
+
pid: 4242,
|
|
305
|
+
daemonSessionId: "session-a",
|
|
306
|
+
serviceId: "svc-1",
|
|
307
|
+
port: 4123,
|
|
308
|
+
startedAtMs: 1_000,
|
|
309
|
+
};
|
|
310
|
+
const owner = {
|
|
311
|
+
version: 1,
|
|
312
|
+
id: "owner-session-a",
|
|
313
|
+
daemonSessionId: "session-a",
|
|
314
|
+
pid: 4242,
|
|
315
|
+
startedAtMs: 1_000,
|
|
316
|
+
runtimeId: "runtime-1",
|
|
317
|
+
localServiceId: "svc-1",
|
|
318
|
+
localApiPort: 4123,
|
|
319
|
+
localApiToken: "token",
|
|
320
|
+
};
|
|
321
|
+
const runtime = {
|
|
322
|
+
executable: "/Applications/Alan.app/Contents/MacOS/Alan",
|
|
323
|
+
cliEntry: "/Applications/Alan.app/Contents/Resources/alan-agent/index.cjs",
|
|
324
|
+
};
|
|
325
|
+
it("matches every available owner-lease identity field", () => {
|
|
326
|
+
expect(ownerMatchesDaemonIdentity(owner, identity)).toBe(true);
|
|
327
|
+
expect(ownerMatchesDaemonIdentity({ ...owner, pid: 5252 }, identity)).toBe(false);
|
|
328
|
+
expect(ownerMatchesDaemonIdentity({ ...owner, daemonSessionId: "session-b" }, identity)).toBe(false);
|
|
329
|
+
expect(ownerMatchesDaemonIdentity({ ...owner, localApiPort: 4999 }, identity)).toBe(false);
|
|
330
|
+
expect(ownerMatchesDaemonIdentity({ ...owner, localServiceId: "svc-2" }, identity)).toBe(false);
|
|
331
|
+
expect(ownerMatchesDaemonIdentity({ ...owner, startedAtMs: 2_000 }, identity)).toBe(false);
|
|
332
|
+
});
|
|
333
|
+
it("boots out the service and proves both the captured PID and launchd job exited", async () => {
|
|
334
|
+
const commands = [];
|
|
335
|
+
const outcome = await forceStopDaemonServiceAndWait(identity, 1_000, {
|
|
336
|
+
platform: "darwin",
|
|
337
|
+
homeDir: "/Users/Test Person",
|
|
338
|
+
userId: 501,
|
|
339
|
+
configPath: "/Users/Test Person/.alan/agent/config.json",
|
|
340
|
+
args: ["--profile", "production"],
|
|
341
|
+
runtime,
|
|
342
|
+
runCommand: (command) => {
|
|
343
|
+
commands.push(command);
|
|
344
|
+
return command.args[0] === "print"
|
|
345
|
+
? { status: 113, output: "Could not find service" }
|
|
346
|
+
: { status: 0, output: "" };
|
|
347
|
+
},
|
|
348
|
+
readOwner: () => owner,
|
|
349
|
+
isProcessAlive: () => false,
|
|
350
|
+
nowMs: () => 0,
|
|
351
|
+
sleep: async () => { },
|
|
352
|
+
});
|
|
353
|
+
expect(outcome).toBe("exited");
|
|
354
|
+
expect(commands[0]?.command).toBe("launchctl");
|
|
355
|
+
expect(commands[0]?.args[0]).toBe("bootout");
|
|
356
|
+
expect(commands[0]?.args.at(-1)).toContain("ai.tryalan.agent.plist");
|
|
357
|
+
expect(commands[1]?.args[0]).toBe("print");
|
|
358
|
+
});
|
|
359
|
+
it("does not boot out anything when the owner identity changed", async () => {
|
|
360
|
+
const commands = [];
|
|
361
|
+
const outcome = await forceStopDaemonServiceAndWait(identity, 1_000, {
|
|
362
|
+
platform: "darwin",
|
|
363
|
+
homeDir: "/Users/Test Person",
|
|
364
|
+
userId: 501,
|
|
365
|
+
configPath: "/Users/Test Person/.alan/agent/config.json",
|
|
366
|
+
args: ["--profile", "production"],
|
|
367
|
+
runtime,
|
|
368
|
+
runCommand: (command) => {
|
|
369
|
+
commands.push(command.command);
|
|
370
|
+
return { status: 0, output: "" };
|
|
371
|
+
},
|
|
372
|
+
readOwner: () => ({ ...owner, daemonSessionId: "session-b" }),
|
|
373
|
+
isProcessAlive: () => false,
|
|
374
|
+
nowMs: () => 0,
|
|
375
|
+
sleep: async () => { },
|
|
376
|
+
});
|
|
377
|
+
expect(outcome).toBe("identity_changed");
|
|
378
|
+
expect(commands).toHaveLength(0);
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
describe("ensure/install admission helpers", () => {
|
|
382
|
+
const windowsRuntime = {
|
|
383
|
+
executable: "C:\\Program Files\\nodejs\\node.exe",
|
|
384
|
+
cliEntry: "C:\\Alan QA\\index.cjs",
|
|
385
|
+
};
|
|
386
|
+
const runWindowsEnsure = (output, commands = [], status = 0) => ensureDaemonServiceDefinition({
|
|
387
|
+
platform: "win32",
|
|
388
|
+
homeDir: "C:\\Users\\QA",
|
|
389
|
+
runtime: windowsRuntime,
|
|
390
|
+
ensureLogDir: () => undefined,
|
|
391
|
+
runCommand: (command) => {
|
|
392
|
+
commands.push(command.args.join(" "));
|
|
393
|
+
return { status, output };
|
|
394
|
+
},
|
|
395
|
+
});
|
|
396
|
+
it("bounds hung service commands while keeping the event loop responsive", async () => {
|
|
397
|
+
let ticks = 0;
|
|
398
|
+
const timer = setInterval(() => {
|
|
399
|
+
ticks++;
|
|
400
|
+
}, 10);
|
|
401
|
+
const started = Date.now();
|
|
402
|
+
try {
|
|
403
|
+
await expect(runServiceCommand({
|
|
404
|
+
command: process.execPath,
|
|
405
|
+
args: ["-e", "setInterval(() => {}, 1000)"],
|
|
406
|
+
tolerateFailure: true,
|
|
407
|
+
}, { commandTimeoutMs: 150 })).rejects.toThrow("Service command failed");
|
|
408
|
+
expect(ticks).toBeGreaterThan(2);
|
|
409
|
+
expect(Date.now() - started).toBeLessThan(2_000);
|
|
410
|
+
}
|
|
411
|
+
finally {
|
|
412
|
+
clearInterval(timer);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
it("reports denied commands and supports cancellation and bounded output", async () => {
|
|
416
|
+
const command = {
|
|
417
|
+
command: process.execPath,
|
|
418
|
+
args: ["-e", "process.exit(5)"],
|
|
419
|
+
tolerateFailure: true,
|
|
420
|
+
};
|
|
421
|
+
expect(await runServiceCommand(command)).toMatchObject({ status: 5 });
|
|
422
|
+
await expect(runServiceCommand({ ...command, tolerateFailure: false })).rejects.toThrow();
|
|
423
|
+
await expect(runServiceCommand({ ...command, args: ["-e", "setInterval(() => {}, 1000)"] }, { signal: AbortSignal.timeout(100) })).rejects.toThrow();
|
|
424
|
+
await expect(runServiceCommand({
|
|
425
|
+
...command,
|
|
426
|
+
tolerateFailure: false,
|
|
427
|
+
args: ["-e", "process.stdout.write('x'.repeat(1024 * 1024))"],
|
|
428
|
+
})).rejects.toThrow();
|
|
429
|
+
});
|
|
430
|
+
it("awaits service status without blocking other daemon work", async () => {
|
|
431
|
+
let heartbeat = false;
|
|
432
|
+
const inspection = inspectDaemonService({
|
|
433
|
+
platform: "linux",
|
|
434
|
+
runCommand: async () => {
|
|
435
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
436
|
+
return { status: 0, output: "active" };
|
|
437
|
+
},
|
|
438
|
+
});
|
|
439
|
+
setTimeout(() => {
|
|
440
|
+
heartbeat = true;
|
|
441
|
+
}, 0);
|
|
442
|
+
expect(await inspection).toMatchObject({ state: "running" });
|
|
443
|
+
expect(heartbeat).toBe(true);
|
|
444
|
+
});
|
|
445
|
+
it("marks definition updates pending while the host is running", () => {
|
|
446
|
+
expect(resolveEnsureDefinitionOutcome({ definitionChanged: true, hostState: "running" })).toEqual({
|
|
447
|
+
changed: true,
|
|
448
|
+
updatePending: true,
|
|
449
|
+
});
|
|
450
|
+
expect(resolveEnsureDefinitionOutcome({ definitionChanged: true, hostState: "stopped" })).toEqual({
|
|
451
|
+
changed: true,
|
|
452
|
+
updatePending: false,
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
it("recognizes systemd inactive and failed output despite the expected nonzero exit", () => {
|
|
456
|
+
expect(parseServiceHostState("linux", { status: 3, output: "inactive" })).toBe("stopped");
|
|
457
|
+
expect(parseServiceHostState("linux", { status: 3, output: "failed" })).toBe("stopped");
|
|
458
|
+
expect(parseServiceHostState("linux", { status: 1, output: "permission denied" })).toBe("unknown");
|
|
459
|
+
});
|
|
460
|
+
it("preserves a queued Windows task as pending startup evidence", () => {
|
|
461
|
+
expect(parseServiceHostState("win32", { status: 0, output: "Queued" })).toBe("starting");
|
|
462
|
+
});
|
|
463
|
+
it("keeps a matching per-user Windows task definition unchanged", async () => {
|
|
464
|
+
const plan = buildDaemonServicePlan({
|
|
465
|
+
platform: "win32",
|
|
466
|
+
homeDir: "C:\\Users\\QA",
|
|
467
|
+
nodeExecutable: windowsRuntime.executable,
|
|
468
|
+
cliEntry: windowsRuntime.cliEntry,
|
|
469
|
+
profile: "production",
|
|
470
|
+
});
|
|
471
|
+
const commands = [];
|
|
472
|
+
const result = await runWindowsEnsure(`TaskName: Alan Agent S-1-5-21-test\nState: Ready\nDefinition: ${plan.definitionMarker}\nDefinitionMatch: True\nCurrentOwned: True\nLegacyTask: False\nLegacyOwned: False\nLegacyState: Missing`, commands);
|
|
473
|
+
expect(result).toEqual({ changed: false, updatePending: false });
|
|
474
|
+
expect(commands).toHaveLength(1);
|
|
475
|
+
expect(commands[0]).not.toContain("Register-ScheduledTask");
|
|
476
|
+
});
|
|
477
|
+
it("migrates a stale queued Windows definition instead of leaving it pending", async () => {
|
|
478
|
+
const commands = [];
|
|
479
|
+
const result = await runWindowsEnsure("TaskName: Alan Agent S-1-5-21-test\nState: Queued\nDefinition: stale\nDefinitionMatch: False\nCurrentOwned: True\nLegacyTask: False\nLegacyOwned: False\nLegacyState: Missing", commands);
|
|
480
|
+
expect(result).toEqual({ changed: true, updatePending: false });
|
|
481
|
+
expect(commands).toHaveLength(2);
|
|
482
|
+
expect(commands[1]).toContain("Register-ScheduledTask");
|
|
483
|
+
});
|
|
484
|
+
it("defers a stale Windows definition while its task is running", async () => {
|
|
485
|
+
const commands = [];
|
|
486
|
+
const result = await runWindowsEnsure("TaskName: Alan Agent S-1-5-21-test\nState: Running\nDefinition: stale\nDefinitionMatch: False\nCurrentOwned: True\nLegacyTask: False\nLegacyOwned: False\nLegacyState: Missing", commands);
|
|
487
|
+
expect(result).toEqual({ changed: true, updatePending: true });
|
|
488
|
+
expect(commands).toHaveLength(1);
|
|
489
|
+
expect(commands[0]).not.toContain("Register-ScheduledTask");
|
|
490
|
+
});
|
|
491
|
+
it("fails closed when Windows task inspection is incomplete", async () => {
|
|
492
|
+
await expect(runWindowsEnsure("Access denied", [], 1)).rejects.toThrow("Cannot inspect Windows daemon task definition");
|
|
493
|
+
});
|
|
494
|
+
it("refuses to replace an unowned per-user Windows task", async () => {
|
|
495
|
+
await expect(runWindowsEnsure("TaskName: Alan Agent S-1-5-21-test\nState: Ready\nDefinition: foreign\nDefinitionMatch: False\nCurrentOwned: False\nLegacyTask: False\nLegacyOwned: False\nLegacyState: Missing")).rejects.toThrow("not owned by this Alan installation");
|
|
496
|
+
});
|
|
497
|
+
it("refuses a foreign legacy task before deferring a running current task", async () => {
|
|
498
|
+
await expect(runWindowsEnsure("TaskName: Alan Agent S-1-5-21-test\nState: Running\nDefinition: current\nDefinitionMatch: True\nCurrentOwned: True\nLegacyTask: True\nLegacyOwned: False\nLegacyState: Ready")).rejects.toThrow("Legacy Windows daemon task is not owned");
|
|
499
|
+
});
|
|
500
|
+
it.each([
|
|
501
|
+
["Running", "running"],
|
|
502
|
+
["Queued", "starting"],
|
|
503
|
+
["Ready", "stopped"],
|
|
504
|
+
["Disabled", "stopped"],
|
|
505
|
+
["Unrecognized", "unknown"],
|
|
506
|
+
])("includes a legacy-only %s task in lifecycle inspection", async (legacyState, expected) => {
|
|
507
|
+
const inspection = await inspectDaemonService({
|
|
508
|
+
platform: "win32",
|
|
509
|
+
runtime: windowsRuntime,
|
|
510
|
+
runCommand: () => ({
|
|
511
|
+
status: 0,
|
|
512
|
+
output: `State: Missing\nDefinitionMatch: False\nCurrentOwned: False\nLegacyTask: True\nLegacyOwned: True\nLegacyState: ${legacyState}`,
|
|
513
|
+
}),
|
|
514
|
+
});
|
|
515
|
+
expect(inspection.state).toBe(expected);
|
|
516
|
+
});
|
|
517
|
+
it("keeps a foreign legacy task blocked during lifecycle inspection", async () => {
|
|
518
|
+
const inspection = await inspectDaemonService({
|
|
519
|
+
platform: "win32",
|
|
520
|
+
runtime: windowsRuntime,
|
|
521
|
+
runCommand: () => ({
|
|
522
|
+
status: 0,
|
|
523
|
+
output: "State: Missing\nDefinitionMatch: False\nCurrentOwned: False\nLegacyTask: True\nLegacyOwned: False\nLegacyState: Running",
|
|
524
|
+
}),
|
|
525
|
+
});
|
|
526
|
+
expect(inspection.state).toBe("unknown");
|
|
527
|
+
});
|
|
528
|
+
it("defers migration while an owned legacy Windows task is running", async () => {
|
|
529
|
+
const commands = [];
|
|
530
|
+
const result = await runWindowsEnsure("State: Missing\nDefinitionMatch: False\nCurrentOwned: False\nLegacyTask: True\nLegacyOwned: True\nLegacyState: Running", commands);
|
|
531
|
+
expect(result).toEqual({ changed: true, updatePending: true });
|
|
532
|
+
expect(commands).toHaveLength(1);
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
describe("Windows stop verification", () => {
|
|
536
|
+
const identity = {
|
|
537
|
+
pid: 4242,
|
|
538
|
+
daemonSessionId: "daemon-session-1",
|
|
539
|
+
serviceId: "service-1",
|
|
540
|
+
port: 48734,
|
|
541
|
+
startedAtMs: 1_000,
|
|
542
|
+
};
|
|
543
|
+
const owner = {
|
|
544
|
+
version: 1,
|
|
545
|
+
id: "owner-1",
|
|
546
|
+
daemonSessionId: identity.daemonSessionId,
|
|
547
|
+
pid: identity.pid,
|
|
548
|
+
startedAtMs: identity.startedAtMs,
|
|
549
|
+
runtimeId: "runtime-1",
|
|
550
|
+
localServiceId: identity.serviceId,
|
|
551
|
+
localApiPort: identity.port,
|
|
552
|
+
localApiToken: "test-local-token",
|
|
553
|
+
};
|
|
554
|
+
const runtime = {
|
|
555
|
+
executable: "C:\\Program Files\\nodejs\\node.exe",
|
|
556
|
+
cliEntry: "C:\\Alan QA\\index.cjs",
|
|
557
|
+
};
|
|
558
|
+
function clock() {
|
|
559
|
+
let now = 0;
|
|
560
|
+
return {
|
|
561
|
+
nowMs: () => now,
|
|
562
|
+
sleep: async (ms) => {
|
|
563
|
+
now += ms;
|
|
564
|
+
},
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
it("does not claim exit from scheduler Ready while the captured process lives", async () => {
|
|
568
|
+
const commands = [];
|
|
569
|
+
const result = await stopDaemonServiceAndWait(identity, 400, {
|
|
570
|
+
...clock(),
|
|
571
|
+
platform: "win32",
|
|
572
|
+
homeDir: "C:\\Users\\QA",
|
|
573
|
+
runtime,
|
|
574
|
+
configPath: "C:\\Alan QA\\config.json",
|
|
575
|
+
readOwner: () => owner,
|
|
576
|
+
isProcessAlive: () => true,
|
|
577
|
+
requestWindowsShutdown: async () => "unreachable",
|
|
578
|
+
probeEndpoint: async () => ({ state: "absent" }),
|
|
579
|
+
runCommand: (command) => {
|
|
580
|
+
commands.push(command.args.join(" "));
|
|
581
|
+
return { status: 0, output: "Ready" };
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
expect(result).toBe("timeout");
|
|
585
|
+
expect(commands.some((command) => command.includes("Stop-ScheduledTask"))).toBe(true);
|
|
586
|
+
});
|
|
587
|
+
it("confirms exit only when the captured process and authenticated endpoint are absent", async () => {
|
|
588
|
+
let reads = 0;
|
|
589
|
+
const result = await stopDaemonServiceAndWait(identity, 400, {
|
|
590
|
+
...clock(),
|
|
591
|
+
platform: "win32",
|
|
592
|
+
homeDir: "C:\\Users\\QA",
|
|
593
|
+
runtime,
|
|
594
|
+
configPath: "C:\\Alan QA\\config.json",
|
|
595
|
+
readOwner: () => (reads++ === 0 ? owner : null),
|
|
596
|
+
isProcessAlive: () => false,
|
|
597
|
+
requestWindowsShutdown: async () => "accepted",
|
|
598
|
+
probeEndpoint: async () => ({ state: "absent" }),
|
|
599
|
+
runCommand: () => ({ status: 0, output: "Ready" }),
|
|
600
|
+
});
|
|
601
|
+
expect(result).toBe("exited");
|
|
602
|
+
});
|
|
603
|
+
it("fails closed when Windows daemon ownership changes during stop", async () => {
|
|
604
|
+
let reads = 0;
|
|
605
|
+
const result = await stopDaemonServiceAndWait(identity, 400, {
|
|
606
|
+
...clock(),
|
|
607
|
+
platform: "win32",
|
|
608
|
+
homeDir: "C:\\Users\\QA",
|
|
609
|
+
runtime,
|
|
610
|
+
configPath: "C:\\Alan QA\\config.json",
|
|
611
|
+
readOwner: () => (reads++ === 0 ? owner : { ...owner, daemonSessionId: "daemon-session-2" }),
|
|
612
|
+
isProcessAlive: () => false,
|
|
613
|
+
requestWindowsShutdown: async () => "accepted",
|
|
614
|
+
probeEndpoint: async () => ({ state: "absent" }),
|
|
615
|
+
runCommand: () => ({ status: 0, output: "Ready" }),
|
|
616
|
+
});
|
|
617
|
+
expect(result).toBe("identity_changed");
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
describe("Windows service uninstall", () => {
|
|
621
|
+
const runtime = {
|
|
622
|
+
executable: "C:\\Program Files\\nodejs\\node.exe",
|
|
623
|
+
cliEntry: "C:\\Alan QA\\index.cjs",
|
|
624
|
+
};
|
|
625
|
+
const owner = {
|
|
626
|
+
version: 1,
|
|
627
|
+
id: "owner-1",
|
|
628
|
+
daemonSessionId: "daemon-session-1",
|
|
629
|
+
pid: 4242,
|
|
630
|
+
startedAtMs: 1_000,
|
|
631
|
+
runtimeId: "runtime-1",
|
|
632
|
+
localServiceId: "service-1",
|
|
633
|
+
localApiPort: 48734,
|
|
634
|
+
localApiToken: "test-local-token",
|
|
635
|
+
};
|
|
636
|
+
const maintenance = {
|
|
637
|
+
acquireMaintenance: () => ({
|
|
638
|
+
acquired: true,
|
|
639
|
+
lease: {
|
|
640
|
+
version: 1,
|
|
641
|
+
id: "maintenance-1",
|
|
642
|
+
reason: "watchdog",
|
|
643
|
+
expiresAtMs: Date.now() + 30_000,
|
|
644
|
+
},
|
|
645
|
+
}),
|
|
646
|
+
releaseMaintenance: () => { },
|
|
647
|
+
};
|
|
648
|
+
const ownedTaskStatus = "TaskName: Alan Agent S-1-5-21-test\nState: Ready\nDefinitionMatch: True\nCurrentOwned: True\nLegacyTask: False\nLegacyOwned: False\nLegacyState: Missing";
|
|
649
|
+
function serviceResult(command) {
|
|
650
|
+
return {
|
|
651
|
+
status: 0,
|
|
652
|
+
output: command.args.join(" ").includes("DefinitionMatch") ? ownedTaskStatus : "Ready",
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
it("refuses to unregister while active work is protected", async () => {
|
|
656
|
+
const commands = [];
|
|
657
|
+
await expect(uninstallDaemonService([], {
|
|
658
|
+
...maintenance,
|
|
659
|
+
platform: "win32",
|
|
660
|
+
homeDir: "C:\\Users\\QA",
|
|
661
|
+
runtime,
|
|
662
|
+
configPath: "C:\\Alan QA\\config.json",
|
|
663
|
+
inspectJournal: () => ({ safeToRestart: false, activeRunCount: 1 }),
|
|
664
|
+
readOwner: () => owner,
|
|
665
|
+
runCommand: (command) => {
|
|
666
|
+
commands.push(command.args.join(" "));
|
|
667
|
+
return serviceResult(command);
|
|
668
|
+
},
|
|
669
|
+
})).rejects.toThrow("active run");
|
|
670
|
+
expect(commands.some((command) => command.includes("Unregister-ScheduledTask"))).toBe(false);
|
|
671
|
+
});
|
|
672
|
+
it("stops the owned daemon before unregistering the Windows task", async () => {
|
|
673
|
+
const events = [];
|
|
674
|
+
await uninstallDaemonService([], {
|
|
675
|
+
...maintenance,
|
|
676
|
+
platform: "win32",
|
|
677
|
+
homeDir: "C:\\Users\\QA",
|
|
678
|
+
runtime,
|
|
679
|
+
configPath: "C:\\Alan QA\\config.json",
|
|
680
|
+
inspectJournal: () => ({ safeToRestart: true, activeRunCount: 0 }),
|
|
681
|
+
readOwner: () => owner,
|
|
682
|
+
isProcessAlive: () => false,
|
|
683
|
+
requestWindowsShutdown: async () => {
|
|
684
|
+
events.push("shutdown");
|
|
685
|
+
return "accepted";
|
|
686
|
+
},
|
|
687
|
+
probeEndpoint: async () => {
|
|
688
|
+
events.push("endpoint-absent");
|
|
689
|
+
return { state: "absent" };
|
|
690
|
+
},
|
|
691
|
+
runCommand: (command) => {
|
|
692
|
+
if (command.args.join(" ").includes("Unregister-ScheduledTask")) {
|
|
693
|
+
events.push("unregister");
|
|
694
|
+
}
|
|
695
|
+
return serviceResult(command);
|
|
696
|
+
},
|
|
697
|
+
});
|
|
698
|
+
expect(events).toEqual(["shutdown", "endpoint-absent", "unregister"]);
|
|
699
|
+
});
|
|
700
|
+
it("surfaces Windows task access denial instead of printing success", async () => {
|
|
701
|
+
await expect(uninstallDaemonService([], {
|
|
702
|
+
...maintenance,
|
|
703
|
+
platform: "win32",
|
|
704
|
+
homeDir: "C:\\Users\\QA",
|
|
705
|
+
runtime,
|
|
706
|
+
configPath: "C:\\Alan QA\\config.json",
|
|
707
|
+
inspectJournal: () => ({ safeToRestart: true, activeRunCount: 0 }),
|
|
708
|
+
readOwner: () => null,
|
|
709
|
+
runCommand: (command) => {
|
|
710
|
+
if (command.args.join(" ").includes("Unregister-ScheduledTask")) {
|
|
711
|
+
throw new Error("Access denied");
|
|
712
|
+
}
|
|
713
|
+
return serviceResult(command);
|
|
714
|
+
},
|
|
715
|
+
})).rejects.toThrow("Access denied");
|
|
716
|
+
});
|
|
717
|
+
it("does not stop a same-user task owned by another Alan installation", async () => {
|
|
718
|
+
const shutdown = vi.fn();
|
|
719
|
+
await expect(uninstallDaemonService([], {
|
|
720
|
+
platform: "win32",
|
|
721
|
+
homeDir: "C:\\Users\\QA",
|
|
722
|
+
runtime,
|
|
723
|
+
configPath: "C:\\Alan QA\\config.json",
|
|
724
|
+
requestWindowsShutdown: shutdown,
|
|
725
|
+
runCommand: () => ({
|
|
726
|
+
status: 0,
|
|
727
|
+
output: "TaskName: Alan Agent S-1-5-21-test\nState: Running\nDefinitionMatch: False\nCurrentOwned: False\nLegacyTask: False\nLegacyOwned: False\nLegacyState: Missing",
|
|
728
|
+
}),
|
|
729
|
+
})).rejects.toThrow("not owned by this Alan installation");
|
|
730
|
+
expect(shutdown).not.toHaveBeenCalled();
|
|
731
|
+
});
|
|
732
|
+
it("treats an already-absent Windows service as successfully removed", async () => {
|
|
733
|
+
const acquireMaintenance = vi.fn();
|
|
734
|
+
await uninstallDaemonService([], {
|
|
735
|
+
platform: "win32",
|
|
736
|
+
homeDir: "C:\\Users\\QA",
|
|
737
|
+
runtime,
|
|
738
|
+
configPath: "C:\\Alan QA\\config.json",
|
|
739
|
+
acquireMaintenance,
|
|
740
|
+
runCommand: () => ({
|
|
741
|
+
status: 0,
|
|
742
|
+
output: "State: Missing\nDefinitionMatch: False\nCurrentOwned: False\nLegacyTask: False\nLegacyOwned: False\nLegacyState: Missing",
|
|
743
|
+
}),
|
|
744
|
+
});
|
|
745
|
+
expect(acquireMaintenance).not.toHaveBeenCalled();
|
|
746
|
+
});
|
|
747
|
+
it("refuses to unregister an ownerless running legacy task", async () => {
|
|
748
|
+
const unregister = vi.fn();
|
|
749
|
+
await expect(uninstallDaemonService([], {
|
|
750
|
+
...maintenance,
|
|
751
|
+
platform: "win32",
|
|
752
|
+
homeDir: "C:\\Users\\QA",
|
|
753
|
+
runtime,
|
|
754
|
+
configPath: "C:\\Alan QA\\config.json",
|
|
755
|
+
inspectJournal: () => ({ safeToRestart: true, activeRunCount: 0 }),
|
|
756
|
+
readOwner: () => null,
|
|
757
|
+
runCommand: (command) => {
|
|
758
|
+
if (command.args.join(" ").includes("Unregister-ScheduledTask"))
|
|
759
|
+
unregister();
|
|
760
|
+
return {
|
|
761
|
+
status: 0,
|
|
762
|
+
output: "State: Missing\nDefinitionMatch: False\nCurrentOwned: False\nLegacyTask: True\nLegacyOwned: True\nLegacyState: Running",
|
|
763
|
+
};
|
|
764
|
+
},
|
|
765
|
+
})).rejects.toThrow("without verified ownership");
|
|
766
|
+
expect(unregister).not.toHaveBeenCalled();
|
|
767
|
+
});
|
|
768
|
+
});
|
|
769
|
+
//# sourceMappingURL=service-manager.test.js.map
|