@apralabs/apra-fleet 0.3.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -257
- package/dist/agents/backlog-groomer.md +287 -0
- package/dist/agents/deployer.md +52 -11
- package/dist/agents/doer.md +32 -7
- package/dist/agents/integ-test-runner.md +151 -61
- package/dist/agents/plan-reviewer.md +74 -17
- package/dist/agents/planner.md +94 -14
- package/dist/agents/regression-test-runner.md +216 -0
- package/dist/agents/reviewer.md +21 -6
- package/dist/agents/schemas/backlog-groomer-input.json +35 -0
- package/dist/agents/schemas/backlog-groomer-output.json +164 -0
- package/dist/agents/schemas/integ-test-runner-output.json +34 -0
- package/dist/agents/schemas/regression-test-runner-input.json +15 -0
- package/dist/agents/schemas/regression-test-runner-output.json +50 -0
- package/dist/agents/schemas/reviewer-output.json +4 -0
- package/dist/cli/agent-transform.d.ts +1 -0
- package/dist/cli/agent-transform.d.ts.map +1 -1
- package/dist/cli/agent-transform.js +77 -0
- package/dist/cli/agent-transform.js.map +1 -1
- package/dist/cli/auth.d.ts +3 -0
- package/dist/cli/auth.d.ts.map +1 -1
- package/dist/cli/auth.js +181 -5
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/config.d.ts +5 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +7 -1
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/dolt-install.d.ts +91 -0
- package/dist/cli/dolt-install.d.ts.map +1 -0
- package/dist/cli/dolt-install.js +334 -0
- package/dist/cli/dolt-install.js.map +1 -0
- package/dist/cli/install-guard.d.ts +29 -0
- package/dist/cli/install-guard.d.ts.map +1 -0
- package/dist/cli/install-guard.js +153 -0
- package/dist/cli/install-guard.js.map +1 -0
- package/dist/cli/install.d.ts +44 -3
- package/dist/cli/install.d.ts.map +1 -1
- package/dist/cli/install.js +604 -108
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/join.d.ts +12 -0
- package/dist/cli/join.d.ts.map +1 -0
- package/dist/cli/join.js +87 -0
- package/dist/cli/join.js.map +1 -0
- package/dist/cli/register-member.d.ts +2 -0
- package/dist/cli/register-member.d.ts.map +1 -0
- package/dist/cli/register-member.js +193 -0
- package/dist/cli/register-member.js.map +1 -0
- package/dist/cli/restart.d.ts +2 -0
- package/dist/cli/restart.d.ts.map +1 -0
- package/dist/cli/restart.js +7 -0
- package/dist/cli/restart.js.map +1 -0
- package/dist/cli/secret.js +8 -2
- package/dist/cli/secret.js.map +1 -1
- package/dist/cli/spoke.d.ts +35 -0
- package/dist/cli/spoke.d.ts.map +1 -0
- package/dist/cli/spoke.js +212 -0
- package/dist/cli/spoke.js.map +1 -0
- package/dist/cli/start.d.ts +2 -0
- package/dist/cli/start.d.ts.map +1 -0
- package/dist/cli/start.js +92 -0
- package/dist/cli/start.js.map +1 -0
- package/dist/cli/status.d.ts +2 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +83 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/cli/stop.d.ts +2 -0
- package/dist/cli/stop.d.ts.map +1 -0
- package/dist/cli/stop.js +51 -0
- package/dist/cli/stop.js.map +1 -0
- package/dist/cli/uninstall.d.ts.map +1 -1
- package/dist/cli/uninstall.js +109 -9
- package/dist/cli/uninstall.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +10 -1
- package/dist/cli/update.js.map +1 -1
- package/dist/cli/workflow-assets.d.ts +37 -0
- package/dist/cli/workflow-assets.d.ts.map +1 -0
- package/dist/cli/workflow-assets.js +144 -0
- package/dist/cli/workflow-assets.js.map +1 -0
- package/dist/cli/workflow.d.ts +75 -0
- package/dist/cli/workflow.d.ts.map +1 -0
- package/dist/cli/workflow.js +397 -0
- package/dist/cli/workflow.js.map +1 -0
- package/dist/hub-service/activity.d.ts +30 -0
- package/dist/hub-service/activity.d.ts.map +1 -0
- package/dist/hub-service/activity.js +20 -0
- package/dist/hub-service/activity.js.map +1 -0
- package/dist/hub-service/audit-log.d.ts +19 -0
- package/dist/hub-service/audit-log.d.ts.map +1 -0
- package/dist/hub-service/audit-log.js +13 -0
- package/dist/hub-service/audit-log.js.map +1 -0
- package/dist/hub-service/db/pool.d.ts +19 -0
- package/dist/hub-service/db/pool.d.ts.map +1 -0
- package/dist/hub-service/db/pool.js +53 -0
- package/dist/hub-service/db/pool.js.map +1 -0
- package/dist/hub-service/enrollment.d.ts +29 -0
- package/dist/hub-service/enrollment.d.ts.map +1 -0
- package/dist/hub-service/enrollment.js +48 -0
- package/dist/hub-service/enrollment.js.map +1 -0
- package/dist/hub-service/envelope-routes.d.ts +46 -0
- package/dist/hub-service/envelope-routes.d.ts.map +1 -0
- package/dist/hub-service/envelope-routes.js +94 -0
- package/dist/hub-service/envelope-routes.js.map +1 -0
- package/dist/hub-service/handlers/installers.d.ts +14 -0
- package/dist/hub-service/handlers/installers.d.ts.map +1 -0
- package/dist/hub-service/handlers/installers.js +8 -0
- package/dist/hub-service/handlers/installers.js.map +1 -0
- package/dist/hub-service/http-server.d.ts +31 -0
- package/dist/hub-service/http-server.d.ts.map +1 -0
- package/dist/hub-service/http-server.js +711 -0
- package/dist/hub-service/http-server.js.map +1 -0
- package/dist/hub-service/hub-jwt.d.ts +30 -0
- package/dist/hub-service/hub-jwt.d.ts.map +1 -0
- package/dist/hub-service/hub-jwt.js +105 -0
- package/dist/hub-service/hub-jwt.js.map +1 -0
- package/dist/hub-service/jwt-revocation.d.ts +20 -0
- package/dist/hub-service/jwt-revocation.d.ts.map +1 -0
- package/dist/hub-service/jwt-revocation.js +18 -0
- package/dist/hub-service/jwt-revocation.js.map +1 -0
- package/dist/hub-service/machines.d.ts +16 -0
- package/dist/hub-service/machines.d.ts.map +1 -0
- package/dist/hub-service/machines.js +14 -0
- package/dist/hub-service/machines.js.map +1 -0
- package/dist/hub-service/main.d.ts +3 -0
- package/dist/hub-service/main.d.ts.map +1 -0
- package/dist/hub-service/main.js +64 -0
- package/dist/hub-service/main.js.map +1 -0
- package/dist/hub-service/member-tokens.d.ts +11 -0
- package/dist/hub-service/member-tokens.d.ts.map +1 -0
- package/dist/hub-service/member-tokens.js +49 -0
- package/dist/hub-service/member-tokens.js.map +1 -0
- package/dist/hub-service/member-view.d.ts +20 -0
- package/dist/hub-service/member-view.d.ts.map +1 -0
- package/dist/hub-service/member-view.js +76 -0
- package/dist/hub-service/member-view.js.map +1 -0
- package/dist/hub-service/members.d.ts +44 -0
- package/dist/hub-service/members.d.ts.map +1 -0
- package/dist/hub-service/members.js +25 -0
- package/dist/hub-service/members.js.map +1 -0
- package/dist/hub-service/presence.d.ts +40 -0
- package/dist/hub-service/presence.d.ts.map +1 -0
- package/dist/hub-service/presence.js +44 -0
- package/dist/hub-service/presence.js.map +1 -0
- package/dist/hub-service/project-view.d.ts +12 -0
- package/dist/hub-service/project-view.d.ts.map +1 -0
- package/dist/hub-service/project-view.js +34 -0
- package/dist/hub-service/project-view.js.map +1 -0
- package/dist/hub-service/projects.d.ts +48 -0
- package/dist/hub-service/projects.d.ts.map +1 -0
- package/dist/hub-service/projects.js +80 -0
- package/dist/hub-service/projects.js.map +1 -0
- package/dist/hub-service/relay-queue.d.ts +115 -0
- package/dist/hub-service/relay-queue.d.ts.map +1 -0
- package/dist/hub-service/relay-queue.js +148 -0
- package/dist/hub-service/relay-queue.js.map +1 -0
- package/dist/hub-service/session-jwt.d.ts +10 -0
- package/dist/hub-service/session-jwt.d.ts.map +1 -0
- package/dist/hub-service/session-jwt.js +69 -0
- package/dist/hub-service/session-jwt.js.map +1 -0
- package/dist/hub-service/usage.d.ts +40 -0
- package/dist/hub-service/usage.d.ts.map +1 -0
- package/dist/hub-service/usage.js +25 -0
- package/dist/hub-service/usage.js.map +1 -0
- package/dist/hub-service/users.d.ts +56 -0
- package/dist/hub-service/users.d.ts.map +1 -0
- package/dist/hub-service/users.js +72 -0
- package/dist/hub-service/users.js.map +1 -0
- package/dist/hub-service/workspaces.d.ts +20 -0
- package/dist/hub-service/workspaces.d.ts.map +1 -0
- package/dist/hub-service/workspaces.js +10 -0
- package/dist/hub-service/workspaces.js.map +1 -0
- package/dist/index.js +179 -132
- package/dist/index.js.map +1 -1
- package/dist/os/linux.d.ts +13 -0
- package/dist/os/linux.d.ts.map +1 -1
- package/dist/os/linux.js +62 -3
- package/dist/os/linux.js.map +1 -1
- package/dist/os/os-commands.d.ts +10 -0
- package/dist/os/os-commands.d.ts.map +1 -1
- package/dist/os/windows.d.ts +1 -0
- package/dist/os/windows.d.ts.map +1 -1
- package/dist/os/windows.js +21 -1
- package/dist/os/windows.js.map +1 -1
- package/dist/paths.d.ts +23 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +29 -0
- package/dist/paths.js.map +1 -1
- package/dist/providers/agy.d.ts +9 -2
- package/dist/providers/agy.d.ts.map +1 -1
- package/dist/providers/agy.js +127 -14
- package/dist/providers/agy.js.map +1 -1
- package/dist/providers/claude.d.ts +6 -2
- package/dist/providers/claude.d.ts.map +1 -1
- package/dist/providers/claude.js +248 -9
- package/dist/providers/claude.js.map +1 -1
- package/dist/providers/codex.d.ts +3 -2
- package/dist/providers/codex.d.ts.map +1 -1
- package/dist/providers/codex.js +7 -0
- package/dist/providers/codex.js.map +1 -1
- package/dist/providers/copilot.d.ts +3 -2
- package/dist/providers/copilot.d.ts.map +1 -1
- package/dist/providers/copilot.js +8 -1
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/gemini.d.ts +3 -2
- package/dist/providers/gemini.d.ts.map +1 -1
- package/dist/providers/gemini.js +11 -1
- package/dist/providers/gemini.js.map +1 -1
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +3 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/none.d.ts +51 -0
- package/dist/providers/none.d.ts.map +1 -0
- package/dist/providers/none.js +103 -0
- package/dist/providers/none.js.map +1 -0
- package/dist/providers/opencode.d.ts +4 -2
- package/dist/providers/opencode.d.ts.map +1 -1
- package/dist/providers/opencode.js +49 -0
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/provider.d.ts +79 -1
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/provider.js +10 -0
- package/dist/providers/provider.js.map +1 -1
- package/dist/services/agent-provisioner.d.ts +3 -3
- package/dist/services/agent-provisioner.d.ts.map +1 -1
- package/dist/services/agent-provisioner.js +12 -5
- package/dist/services/agent-provisioner.js.map +1 -1
- package/dist/services/auth-socket.d.ts.map +1 -1
- package/dist/services/auth-socket.js +2 -0
- package/dist/services/auth-socket.js.map +1 -1
- package/dist/services/budget-awareness.d.ts +130 -0
- package/dist/services/budget-awareness.d.ts.map +1 -0
- package/dist/services/budget-awareness.js +129 -0
- package/dist/services/budget-awareness.js.map +1 -0
- package/dist/services/cloud-sync.d.ts +35 -0
- package/dist/services/cloud-sync.d.ts.map +1 -0
- package/dist/services/cloud-sync.js +90 -0
- package/dist/services/cloud-sync.js.map +1 -0
- package/dist/services/context-admission.d.ts +82 -0
- package/dist/services/context-admission.d.ts.map +1 -0
- package/dist/services/context-admission.js +136 -0
- package/dist/services/context-admission.js.map +1 -0
- package/dist/services/event-bus.d.ts +27 -0
- package/dist/services/event-bus.d.ts.map +1 -0
- package/dist/services/event-bus.js +20 -0
- package/dist/services/event-bus.js.map +1 -0
- package/dist/services/file-chunker.d.ts +38 -0
- package/dist/services/file-chunker.d.ts.map +1 -0
- package/dist/services/file-chunker.js +63 -0
- package/dist/services/file-chunker.js.map +1 -0
- package/dist/services/file-transfer-relay.d.ts +55 -0
- package/dist/services/file-transfer-relay.d.ts.map +1 -0
- package/dist/services/file-transfer-relay.js +115 -0
- package/dist/services/file-transfer-relay.js.map +1 -0
- package/dist/services/github-app.d.ts.map +1 -1
- package/dist/services/github-app.js +1 -0
- package/dist/services/github-app.js.map +1 -1
- package/dist/services/http-transport.d.ts +25 -0
- package/dist/services/http-transport.d.ts.map +1 -0
- package/dist/services/http-transport.js +371 -0
- package/dist/services/http-transport.js.map +1 -0
- package/dist/services/hub-client.d.ts +69 -0
- package/dist/services/hub-client.d.ts.map +1 -0
- package/dist/services/hub-client.js +217 -0
- package/dist/services/hub-client.js.map +1 -0
- package/dist/services/jwt.d.ts +17 -0
- package/dist/services/jwt.d.ts.map +1 -0
- package/dist/services/jwt.js +70 -0
- package/dist/services/jwt.js.map +1 -0
- package/dist/services/known-sessions.d.ts +8 -0
- package/dist/services/known-sessions.d.ts.map +1 -0
- package/dist/services/known-sessions.js +40 -0
- package/dist/services/known-sessions.js.map +1 -0
- package/dist/services/model-pricing.d.ts +36 -0
- package/dist/services/model-pricing.d.ts.map +1 -0
- package/dist/services/model-pricing.js +108 -0
- package/dist/services/model-pricing.js.map +1 -0
- package/dist/services/orphan-recovery.d.ts +56 -0
- package/dist/services/orphan-recovery.d.ts.map +1 -0
- package/dist/services/orphan-recovery.js +111 -0
- package/dist/services/orphan-recovery.js.map +1 -0
- package/dist/services/pending-responses.d.ts +23 -0
- package/dist/services/pending-responses.d.ts.map +1 -0
- package/dist/services/pending-responses.js +52 -0
- package/dist/services/pending-responses.js.map +1 -0
- package/dist/services/registry.d.ts +4 -1
- package/dist/services/registry.d.ts.map +1 -1
- package/dist/services/registry.js +3 -0
- package/dist/services/registry.js.map +1 -1
- package/dist/services/relay-context.d.ts +23 -0
- package/dist/services/relay-context.d.ts.map +1 -0
- package/dist/services/relay-context.js +8 -0
- package/dist/services/relay-context.js.map +1 -0
- package/dist/services/relay-executor.d.ts +68 -0
- package/dist/services/relay-executor.d.ts.map +1 -0
- package/dist/services/relay-executor.js +70 -0
- package/dist/services/relay-executor.js.map +1 -0
- package/dist/services/relay-request.d.ts +65 -0
- package/dist/services/relay-request.d.ts.map +1 -0
- package/dist/services/relay-request.js +129 -0
- package/dist/services/relay-request.js.map +1 -0
- package/dist/services/relay-strategy.d.ts +19 -0
- package/dist/services/relay-strategy.d.ts.map +1 -0
- package/dist/services/relay-strategy.js +111 -0
- package/dist/services/relay-strategy.js.map +1 -0
- package/dist/services/service-manager/index.d.ts +5 -0
- package/dist/services/service-manager/index.d.ts.map +1 -0
- package/dist/services/service-manager/index.js +66 -0
- package/dist/services/service-manager/index.js.map +1 -0
- package/dist/services/service-manager/linux.d.ts +10 -0
- package/dist/services/service-manager/linux.d.ts.map +1 -0
- package/dist/services/service-manager/linux.js +97 -0
- package/dist/services/service-manager/linux.js.map +1 -0
- package/dist/services/service-manager/macos.d.ts +10 -0
- package/dist/services/service-manager/macos.d.ts.map +1 -0
- package/dist/services/service-manager/macos.js +94 -0
- package/dist/services/service-manager/macos.js.map +1 -0
- package/dist/services/service-manager/types.d.ts +18 -0
- package/dist/services/service-manager/types.d.ts.map +1 -0
- package/dist/services/service-manager/types.js +5 -0
- package/dist/services/service-manager/types.js.map +1 -0
- package/dist/services/service-manager/windows.d.ts +10 -0
- package/dist/services/service-manager/windows.d.ts.map +1 -0
- package/dist/services/service-manager/windows.js +73 -0
- package/dist/services/service-manager/windows.js.map +1 -0
- package/dist/services/session-registry.d.ts +70 -0
- package/dist/services/session-registry.d.ts.map +1 -0
- package/dist/services/session-registry.js +91 -0
- package/dist/services/session-registry.js.map +1 -0
- package/dist/services/singleton.d.ts +15 -0
- package/dist/services/singleton.d.ts.map +1 -0
- package/dist/services/singleton.js +98 -0
- package/dist/services/singleton.js.map +1 -0
- package/dist/services/sprint-coordination.d.ts +168 -0
- package/dist/services/sprint-coordination.d.ts.map +1 -0
- package/dist/services/sprint-coordination.js +564 -0
- package/dist/services/sprint-coordination.js.map +1 -0
- package/dist/services/ssh.d.ts.map +1 -1
- package/dist/services/ssh.js +70 -3
- package/dist/services/ssh.js.map +1 -1
- package/dist/services/stall/log-path-resolver.d.ts.map +1 -1
- package/dist/services/stall/log-path-resolver.js +8 -1
- package/dist/services/stall/log-path-resolver.js.map +1 -1
- package/dist/services/stall/stall-detector.d.ts.map +1 -1
- package/dist/services/stall/stall-detector.js +39 -7
- package/dist/services/stall/stall-detector.js.map +1 -1
- package/dist/services/stall/stall-poller.d.ts +16 -0
- package/dist/services/stall/stall-poller.d.ts.map +1 -1
- package/dist/services/stall/stall-poller.js +136 -18
- package/dist/services/stall/stall-poller.js.map +1 -1
- package/dist/services/strategy.d.ts.map +1 -1
- package/dist/services/strategy.js +55 -5
- package/dist/services/strategy.js.map +1 -1
- package/dist/services/substitution-engine.d.ts +20 -0
- package/dist/services/substitution-engine.d.ts.map +1 -0
- package/dist/services/substitution-engine.js +92 -0
- package/dist/services/substitution-engine.js.map +1 -0
- package/dist/services/task-cleanup.d.ts.map +1 -1
- package/dist/services/task-cleanup.js +1 -9
- package/dist/services/task-cleanup.js.map +1 -1
- package/dist/services/token-issuer.d.ts +47 -0
- package/dist/services/token-issuer.d.ts.map +1 -0
- package/dist/services/token-issuer.js +63 -0
- package/dist/services/token-issuer.js.map +1 -0
- package/dist/services/tool-registry.d.ts +3 -0
- package/dist/services/tool-registry.d.ts.map +1 -0
- package/dist/services/tool-registry.js +139 -0
- package/dist/services/tool-registry.js.map +1 -0
- package/dist/services/user-config.d.ts +14 -0
- package/dist/services/user-config.d.ts.map +1 -1
- package/dist/services/user-config.js +55 -0
- package/dist/services/user-config.js.map +1 -1
- package/dist/services/vcs/types.d.ts +44 -0
- package/dist/services/vcs/types.d.ts.map +1 -1
- package/dist/skills/fleet-sprint-cli/SKILL.md +103 -0
- package/dist/skills/pm/cost.md +3 -0
- package/dist/skills/pm/doer-reviewer-loop.md +3 -0
- package/dist/tools/check-status.d.ts.map +1 -1
- package/dist/tools/check-status.js +8 -2
- package/dist/tools/check-status.js.map +1 -1
- package/dist/tools/child-id-allocator.d.ts +45 -0
- package/dist/tools/child-id-allocator.d.ts.map +1 -0
- package/dist/tools/child-id-allocator.js +62 -0
- package/dist/tools/child-id-allocator.js.map +1 -0
- package/dist/tools/cloud-control.d.ts +2 -2
- package/dist/tools/compose-permissions.d.ts +12 -4
- package/dist/tools/compose-permissions.d.ts.map +1 -1
- package/dist/tools/compose-permissions.js +55 -4
- package/dist/tools/compose-permissions.js.map +1 -1
- package/dist/tools/dolt-push-mutex.d.ts +44 -0
- package/dist/tools/dolt-push-mutex.d.ts.map +1 -0
- package/dist/tools/dolt-push-mutex.js +83 -0
- package/dist/tools/dolt-push-mutex.js.map +1 -0
- package/dist/tools/execute-command.d.ts +11 -1
- package/dist/tools/execute-command.d.ts.map +1 -1
- package/dist/tools/execute-command.js +22 -5
- package/dist/tools/execute-command.js.map +1 -1
- package/dist/tools/execute-prompt.d.ts +72 -12
- package/dist/tools/execute-prompt.d.ts.map +1 -1
- package/dist/tools/execute-prompt.js +962 -71
- package/dist/tools/execute-prompt.js.map +1 -1
- package/dist/tools/get-member-model-pricing.d.ts +21 -0
- package/dist/tools/get-member-model-pricing.d.ts.map +1 -0
- package/dist/tools/get-member-model-pricing.js +29 -0
- package/dist/tools/get-member-model-pricing.js.map +1 -0
- package/dist/tools/list-members.d.ts.map +1 -1
- package/dist/tools/list-members.js +39 -7
- package/dist/tools/list-members.js.map +1 -1
- package/dist/tools/member-detail.d.ts +1 -1
- package/dist/tools/member-detail.d.ts.map +1 -1
- package/dist/tools/member-detail.js +8 -2
- package/dist/tools/member-detail.js.map +1 -1
- package/dist/tools/member-reservation.d.ts +29 -0
- package/dist/tools/member-reservation.d.ts.map +1 -0
- package/dist/tools/member-reservation.js +71 -0
- package/dist/tools/member-reservation.js.map +1 -0
- package/dist/tools/provision-vcs-auth.d.ts +7 -7
- package/dist/tools/provision-vcs-auth.js +1 -1
- package/dist/tools/provision-vcs-auth.js.map +1 -1
- package/dist/tools/register-member.d.ts +17 -5
- package/dist/tools/register-member.d.ts.map +1 -1
- package/dist/tools/register-member.js +144 -5
- package/dist/tools/register-member.js.map +1 -1
- package/dist/tools/remove-member.d.ts +1 -1
- package/dist/tools/report-status.d.ts +33 -0
- package/dist/tools/report-status.d.ts.map +1 -0
- package/dist/tools/report-status.js +44 -0
- package/dist/tools/report-status.js.map +1 -0
- package/dist/tools/respond-to-message.d.ts +21 -0
- package/dist/tools/respond-to-message.d.ts.map +1 -0
- package/dist/tools/respond-to-message.js +23 -0
- package/dist/tools/respond-to-message.js.map +1 -0
- package/dist/tools/send-files.d.ts +3 -0
- package/dist/tools/send-files.d.ts.map +1 -1
- package/dist/tools/send-files.js +88 -8
- package/dist/tools/send-files.js.map +1 -1
- package/dist/tools/send-message.d.ts +27 -0
- package/dist/tools/send-message.d.ts.map +1 -0
- package/dist/tools/send-message.js +46 -0
- package/dist/tools/send-message.js.map +1 -0
- package/dist/tools/shutdown-server.d.ts +2 -0
- package/dist/tools/shutdown-server.d.ts.map +1 -1
- package/dist/tools/shutdown-server.js +19 -0
- package/dist/tools/shutdown-server.js.map +1 -1
- package/dist/tools/update-member.d.ts +8 -8
- package/dist/tools/update-member.d.ts.map +1 -1
- package/dist/tools/update-member.js +11 -1
- package/dist/tools/update-member.js.map +1 -1
- package/dist/types.d.ts +15 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/agent-helpers.d.ts +2 -1
- package/dist/utils/agent-helpers.d.ts.map +1 -1
- package/dist/utils/agent-helpers.js +7 -2
- package/dist/utils/agent-helpers.js.map +1 -1
- package/dist/utils/pid-helpers.d.ts +15 -0
- package/dist/utils/pid-helpers.d.ts.map +1 -1
- package/dist/utils/pid-helpers.js +23 -0
- package/dist/utils/pid-helpers.js.map +1 -1
- package/dist/utils/process-utils.d.ts +3 -0
- package/dist/utils/process-utils.d.ts.map +1 -0
- package/dist/utils/process-utils.js +42 -0
- package/dist/utils/process-utils.js.map +1 -0
- package/dist/utils/prompt-errors.d.ts +2 -1
- package/dist/utils/prompt-errors.d.ts.map +1 -1
- package/dist/utils/prompt-errors.js +13 -3
- package/dist/utils/prompt-errors.js.map +1 -1
- package/dist/utils/workspace-trust.d.ts +24 -0
- package/dist/utils/workspace-trust.d.ts.map +1 -0
- package/dist/utils/workspace-trust.js +35 -0
- package/dist/utils/workspace-trust.js.map +1 -0
- package/dist/workflows/auto-sprint.js +450 -87
- package/package.json +35 -7
- package/packages/apra-fleet-client/package.json +26 -0
- package/packages/apra-fleet-client/src/client/api.mjs +396 -0
- package/packages/apra-fleet-client/src/client/client.mjs +146 -0
- package/packages/apra-fleet-client/src/client/errors.mjs +71 -0
- package/packages/apra-fleet-client/src/client/factory.mjs +65 -0
- package/packages/apra-fleet-client/src/client/server-resolution.mjs +265 -0
- package/packages/apra-fleet-client/src/client/transport.mjs +327 -0
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +287 -0
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +89 -0
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +139 -0
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +225 -0
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +169 -0
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +316 -0
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +188 -0
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +239 -0
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +216 -0
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +174 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-input.json +35 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-output.json +164 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/ci-watcher-input.json +26 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/ci-watcher-output.json +18 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-input.json +19 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +17 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-input.json +25 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +22 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-input.json +31 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-output.json +18 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-input.json +20 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +61 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-input.json +15 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +30 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-input.json +15 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +50 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-input.json +25 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +38 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +402 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/beads.md +142 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +157 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/doer-reviewer-loop.md +300 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +121 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/simple-sprint.md +65 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +327 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/worktrees.md +92 -0
- package/packages/apra-fleet-se/apra-pm/version.json +3 -0
- package/packages/apra-fleet-se/bin/cli.mjs +857 -0
- package/packages/apra-fleet-se/bin/serve.mjs +383 -0
- package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +178 -0
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +914 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +177 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +191 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +151 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-tier2-runbook.md +127 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/fleet-sprint-diagram.md +94 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +1125 -0
- package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +72 -0
- package/packages/apra-fleet-se/fleet-sprint/dolt-recovery-path-b.mjs +339 -0
- package/packages/apra-fleet-se/fleet-sprint/dolt-recovery-tier2.mjs +360 -0
- package/packages/apra-fleet-se/fleet-sprint/dolt-recovery.mjs +363 -0
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +1244 -0
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +572 -0
- package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +118 -0
- package/packages/apra-fleet-se/fleet-sprint/runner.js +9447 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +103 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-lock.mjs +140 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +435 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +68 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +53 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +146 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/generic-git.mjs +176 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +222 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +218 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +882 -0
- package/packages/apra-fleet-se/package.json +28 -0
- package/packages/apra-fleet-se/workflow.json +1 -0
- package/packages/apra-fleet-workflow/package.json +30 -0
- package/packages/apra-fleet-workflow/src/viewer/command-output-cap.mjs +112 -0
- package/packages/apra-fleet-workflow/src/viewer/debounced-writer.mjs +153 -0
- package/packages/apra-fleet-workflow/src/viewer/html-utils.mjs +31 -0
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +1325 -0
- package/packages/apra-fleet-workflow/src/viewer/lean-state.mjs +237 -0
- package/packages/apra-fleet-workflow/src/viewer/run-state-paths.mjs +130 -0
- package/packages/apra-fleet-workflow/src/viewer/sprint-state-paths.mjs +29 -0
- package/packages/apra-fleet-workflow/src/workflow/engine.mjs +200 -0
- package/packages/apra-fleet-workflow/src/workflow/errors.mjs +146 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +1723 -0
- package/packages/apra-fleet-workflow/src/workflow/journal.mjs +291 -0
- package/packages/apra-fleet-workflow/src/workflow/pricing.mjs +99 -0
- package/packages/apra-fleet-workflow/src/workflow/vetting.mjs +111 -0
- package/scripts/agy-transcript-reader.js +1 -0
- package/scripts/fleet-statusline.sh +17 -13
- package/skills/fleet/SKILL.md +37 -2
- package/skills/fleet/beads.md +14 -7
- package/skills/fleet/permissions.md +50 -0
- package/skills/fleet/profiles/base-dev.json +1 -0
- package/skills/fleet/profiles/base-reviewer.json +1 -0
- package/skills/fleet/profiles/node.json +2 -2
- package/version.json +1 -1
- package/scripts/agy-settings-merge.js +0 -27
- /package/{dist → packages/apra-fleet-se/apra-pm}/agents/_shared/GRAPH-SEMANTICS.md +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal typed error shape for the transport/client layer.
|
|
3
|
+
*
|
|
4
|
+
* NOTE (apra-fleet-unw.5): packages/apra-fleet-workflow/src/workflow/errors.mjs
|
|
5
|
+
* already defines a `WorkflowError` taxonomy (MEMBER_NOT_FOUND,
|
|
6
|
+
* AGENT_OUTPUT_INVALID, COMMAND_FAILED, TRANSPORT_ERROR, ...), but
|
|
7
|
+
* apra-fleet-client is a lower-level package that apra-fleet-workflow
|
|
8
|
+
* *depends on* (see packages/apra-fleet-workflow/package.json), so
|
|
9
|
+
* client.mjs cannot import from the workflow package without introducing a
|
|
10
|
+
* circular dependency. This module defines a small, compatible error shape
|
|
11
|
+
* (`message`, `.code`, `.details`, `.cause`) for use at the MCP
|
|
12
|
+
* request/transport layer. When the two taxonomies are reconciled, consider
|
|
13
|
+
* hoisting a shared base error class into a package both can depend on (e.g.
|
|
14
|
+
* a `@apralabs/apra-fleet-errors` package), or having the workflow layer's
|
|
15
|
+
* `FleetTransportError` classifier recognize `.code === 'TIMEOUT'` /
|
|
16
|
+
* `.code === 'ABORTED'` from this module and re-wrap accordingly.
|
|
17
|
+
*/
|
|
18
|
+
export class ClientError extends Error {
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} message
|
|
21
|
+
* @param {{ code: string, details?: object, cause?: unknown }} opts
|
|
22
|
+
*/
|
|
23
|
+
constructor(message, { code, details, cause } = {}) {
|
|
24
|
+
super(message, cause !== undefined ? { cause } : undefined);
|
|
25
|
+
this.name = this.constructor.name;
|
|
26
|
+
this.code = code || 'CLIENT_ERROR';
|
|
27
|
+
this.details = details;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Thrown by McpClient.request() when no JSON-RPC response arrives within the
|
|
33
|
+
* configured (or default) timeout window.
|
|
34
|
+
*/
|
|
35
|
+
export class TimeoutError extends ClientError {
|
|
36
|
+
constructor(message, opts = {}) {
|
|
37
|
+
super(message, { code: 'TIMEOUT', ...opts });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Thrown by McpClient.request() when the caller-supplied AbortSignal fires
|
|
43
|
+
* before a response arrives.
|
|
44
|
+
*/
|
|
45
|
+
export class AbortError extends ClientError {
|
|
46
|
+
constructor(message, opts = {}) {
|
|
47
|
+
super(message, { code: 'ABORTED', ...opts });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Thrown (as the rejection for every in-flight request) when the underlying
|
|
53
|
+
* transport closes -- deliberate stop(), or the persistent SSE stream dying
|
|
54
|
+
* past its reconnect budget. Previously a bare `new Error('Transport
|
|
55
|
+
* closed')`, indistinguishable downstream from any other failure; typed so
|
|
56
|
+
* callers can classify it as a connectivity event (retryable at their
|
|
57
|
+
* discretion) rather than a request-level failure.
|
|
58
|
+
*
|
|
59
|
+
* CONVENTION (2026-07-19 stabilization): when execute_prompt /
|
|
60
|
+
* execute_command surface a NEW kind of failure that downstream code needs
|
|
61
|
+
* to branch on, add a typed error class HERE (transport/request-level
|
|
62
|
+
* failures) or a `reason` code on the workflow layer's AgentDispatchError
|
|
63
|
+
* (dispatch-level failures reported via structuredContent.isError, e.g.
|
|
64
|
+
* 'busy', 'empty_response', 'max_turns_exhausted') -- never a bare Error
|
|
65
|
+
* with only a message string to sniff.
|
|
66
|
+
*/
|
|
67
|
+
export class TransportClosedError extends ClientError {
|
|
68
|
+
constructor(message, opts = {}) {
|
|
69
|
+
super(message, { code: 'TRANSPORT_CLOSED', ...opts });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { StdioTransport, StreamableHttpTransport } from './transport.mjs';
|
|
2
|
+
import { McpClient } from './client.mjs';
|
|
3
|
+
import { ApraFleet } from './api.mjs';
|
|
4
|
+
import { FleetWorkflow } from '../workflow/index.mjs';
|
|
5
|
+
import { WorkflowEngine } from '../workflow/engine.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates and initializes a WorkflowEngine along with its underlying transport and API layers.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} config
|
|
11
|
+
* @param {'stdio'|'http'} config.transport
|
|
12
|
+
* @param {string} [config.command] - Required if transport is 'stdio'
|
|
13
|
+
* @param {string[]} [config.args] - Optional args if transport is 'stdio'
|
|
14
|
+
* @param {string} [config.url] - Required if transport is 'http'
|
|
15
|
+
* @param {Object} [config.options] - Transport options
|
|
16
|
+
* @param {Object} [config.workflowArgs] - Arguments for the workflow context
|
|
17
|
+
* @returns {Promise<{transport: any, mcpClient: McpClient, apraFleet: ApraFleet, fleetWorkflow: FleetWorkflow, engine: WorkflowEngine}>}
|
|
18
|
+
*/
|
|
19
|
+
export async function createWorkflowEngine(config) {
|
|
20
|
+
let transport;
|
|
21
|
+
|
|
22
|
+
if (config.transport === 'stdio') {
|
|
23
|
+
if (!config.command) {
|
|
24
|
+
throw new Error("StdioTransport requires a 'command' property in config.");
|
|
25
|
+
}
|
|
26
|
+
transport = new StdioTransport(config.command, config.args || [], config.options || {});
|
|
27
|
+
} else if (config.transport === 'http') {
|
|
28
|
+
if (!config.url) {
|
|
29
|
+
throw new Error("StreamableHttpTransport requires a 'url' property in config.");
|
|
30
|
+
}
|
|
31
|
+
transport = new StreamableHttpTransport(config.url, config.options || {});
|
|
32
|
+
} else {
|
|
33
|
+
throw new Error(`Unsupported transport type: ${config.transport}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
await transport.start();
|
|
37
|
+
|
|
38
|
+
const mcpClient = new McpClient(transport);
|
|
39
|
+
|
|
40
|
+
// Standard MCP requires the client to initialize the connection
|
|
41
|
+
if (config.transport === 'stdio') {
|
|
42
|
+
await mcpClient.request('initialize', {
|
|
43
|
+
protocolVersion: '2024-11-05',
|
|
44
|
+
capabilities: {},
|
|
45
|
+
clientInfo: { name: 'fleet-client', version: '1.0.0' }
|
|
46
|
+
});
|
|
47
|
+
await transport.send({
|
|
48
|
+
jsonrpc: '2.0',
|
|
49
|
+
method: 'notifications/initialized',
|
|
50
|
+
params: {}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const apraFleet = new ApraFleet(mcpClient);
|
|
55
|
+
const fleetWorkflow = new FleetWorkflow(apraFleet, config.workflowArgs || {});
|
|
56
|
+
const engine = new WorkflowEngine(fleetWorkflow);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
transport,
|
|
60
|
+
mcpClient,
|
|
61
|
+
apraFleet,
|
|
62
|
+
fleetWorkflow,
|
|
63
|
+
engine
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared fleet-server resolution -- the ONE implementation of "how does a client
|
|
3
|
+
* process reach the apra-fleet MCP server".
|
|
4
|
+
*
|
|
5
|
+
* Binding design doc: docs/adr-workflow-server-resolution.md (apra-fleet-7pm.6).
|
|
6
|
+
* Consumers: src/cli/workflow.ts (the `apra-fleet workflow` launcher) and
|
|
7
|
+
* packages/apra-fleet-se/bin/cli.mjs (auto-sprint). Neither duplicates this logic.
|
|
8
|
+
*
|
|
9
|
+
* Resolution order (ADR Decision 1):
|
|
10
|
+
* 1. APRA_FLEET_TRANSPORT override ('http' | 'stdio').
|
|
11
|
+
* - 'stdio' -> stdio self-spawn, no probe.
|
|
12
|
+
* - APRA_FLEET_SERVER_CMD/_BIN set (and transport is not forced 'http')
|
|
13
|
+
* -> explicit stdio request, no probe.
|
|
14
|
+
* - 'http' -> probe only; NEVER falls back to stdio.
|
|
15
|
+
* - unset -> http is the product default: probe, then fall back.
|
|
16
|
+
* 2. HTTP singleton probe -- checkRunningInstance(): ~/.apra-fleet/data/server.json
|
|
17
|
+
* {pid, url}, pid-alive check + GET <url with /mcp -> /health> (2s timeout),
|
|
18
|
+
* self-healing (deletes a stale server.json). On success: attach over
|
|
19
|
+
* StreamableHttpTransport, spawn nothing.
|
|
20
|
+
* 3. stdio self-spawn fallback -- the existing four command tiers
|
|
21
|
+
* (APRA_FLEET_SERVER_CMD, APRA_FLEET_SERVER_BIN, bundled sibling index.js,
|
|
22
|
+
* dev-monorepo dist/index.js), fed to StdioTransport.
|
|
23
|
+
*
|
|
24
|
+
* Scope guard (ADR): the launcher/auto-sprint client and the MCP server are ALWAYS
|
|
25
|
+
* separate processes. This module decides only the transport, never merges them.
|
|
26
|
+
*
|
|
27
|
+
* Every branch is unit-testable: all filesystem/env/network access goes through the
|
|
28
|
+
* injectable `deps` bag.
|
|
29
|
+
*/
|
|
30
|
+
import fs from 'node:fs';
|
|
31
|
+
import http from 'node:http';
|
|
32
|
+
import path from 'node:path';
|
|
33
|
+
import os from 'node:os';
|
|
34
|
+
import { fileURLToPath } from 'node:url';
|
|
35
|
+
import { StdioTransport, StreamableHttpTransport } from './transport.mjs';
|
|
36
|
+
import { McpClient } from './client.mjs';
|
|
37
|
+
import { ApraFleet } from './api.mjs';
|
|
38
|
+
|
|
39
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
40
|
+
|
|
41
|
+
/** @returns {string} ~/.apra-fleet/data (honors APRA_FLEET_DATA_DIR, like src/paths.ts) */
|
|
42
|
+
export function getFleetDataDir(env = process.env) {
|
|
43
|
+
return env.APRA_FLEET_DATA_DIR ?? path.join(os.homedir(), '.apra-fleet', 'data');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** @returns {string} path to the running server's server.json */
|
|
47
|
+
export function getServerInfoPath(env = process.env) {
|
|
48
|
+
return path.join(getFleetDataDir(env), 'server.json');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* pid-liveness check. Mirrors src/utils/process-utils.ts isPidAlive().
|
|
53
|
+
* @param {number} pid
|
|
54
|
+
* @returns {boolean}
|
|
55
|
+
*/
|
|
56
|
+
function isPidAlive(pid) {
|
|
57
|
+
try {
|
|
58
|
+
process.kill(pid, 0);
|
|
59
|
+
return true;
|
|
60
|
+
} catch (err) {
|
|
61
|
+
// EPERM means the process exists but is owned by another user -- alive.
|
|
62
|
+
return err && err.code === 'EPERM';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* GET <url with a trailing /mcp replaced by /health>, 2s timeout.
|
|
68
|
+
* @param {string} url
|
|
69
|
+
* @returns {Promise<boolean>}
|
|
70
|
+
*/
|
|
71
|
+
function checkHealthEndpoint(url) {
|
|
72
|
+
const healthUrl = url.replace(/\/mcp$/, '/health');
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
const req = http.get(healthUrl, { timeout: 2000 }, (res) => {
|
|
75
|
+
res.resume();
|
|
76
|
+
resolve(res.statusCode === 200);
|
|
77
|
+
});
|
|
78
|
+
req.on('error', () => resolve(false));
|
|
79
|
+
req.on('timeout', () => { req.destroy(); resolve(false); });
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The HTTP-singleton probe. Same semantics as src/services/singleton.ts's
|
|
85
|
+
* checkRunningInstance() (pid + /health + self-heal), so the launcher's probe and
|
|
86
|
+
* the server's own startup-dedup can never disagree.
|
|
87
|
+
*
|
|
88
|
+
* @param {{ env?: Record<string, string|undefined>, readFile?: (p: string) => string,
|
|
89
|
+
* unlink?: (p: string) => void, pidAlive?: (pid: number) => boolean,
|
|
90
|
+
* health?: (url: string) => Promise<boolean> }} [deps]
|
|
91
|
+
* @returns {Promise<{running: true, url: string, pid: number} | {running: false}>}
|
|
92
|
+
*/
|
|
93
|
+
export async function checkRunningInstance(deps = {}) {
|
|
94
|
+
const env = deps.env || process.env;
|
|
95
|
+
const readFile = deps.readFile || ((p) => fs.readFileSync(p, 'utf8'));
|
|
96
|
+
const unlink = deps.unlink || ((p) => { try { fs.unlinkSync(p); } catch { /* already gone */ } });
|
|
97
|
+
const pidAlive = deps.pidAlive || isPidAlive;
|
|
98
|
+
const health = deps.health || checkHealthEndpoint;
|
|
99
|
+
|
|
100
|
+
const serverInfoPath = getServerInfoPath(env);
|
|
101
|
+
|
|
102
|
+
let info;
|
|
103
|
+
try {
|
|
104
|
+
info = JSON.parse(readFile(serverInfoPath));
|
|
105
|
+
} catch {
|
|
106
|
+
return { running: false };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!info || !info.pid || !info.url) return { running: false };
|
|
110
|
+
|
|
111
|
+
if (!pidAlive(info.pid)) {
|
|
112
|
+
unlink(serverInfoPath);
|
|
113
|
+
return { running: false };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!(await health(info.url))) {
|
|
117
|
+
unlink(serverInfoPath);
|
|
118
|
+
return { running: false };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return { running: true, url: info.url, pid: info.pid };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Tier 3 of the ADR: the stdio self-spawn command, four resolution tiers.
|
|
126
|
+
* This is the single implementation; packages/apra-fleet-se/bin/cli.mjs re-exports it
|
|
127
|
+
* under its historical name with identical behavior.
|
|
128
|
+
*
|
|
129
|
+
* @param {{ env?: Record<string, string|undefined>, dirname?: string,
|
|
130
|
+
* exists?: (candidate: string) => boolean }} [deps]
|
|
131
|
+
* @returns {{ command: string, args: string[] }}
|
|
132
|
+
*/
|
|
133
|
+
export function resolveFleetServerCommand(deps = {}) {
|
|
134
|
+
const env = deps.env || process.env;
|
|
135
|
+
// Default dirname: the *consumer's* location matters, so callers that care
|
|
136
|
+
// (cli.mjs) pass their own __dirname. Falling back to this module's dirname
|
|
137
|
+
// keeps the dev-monorepo tier working for direct callers.
|
|
138
|
+
const dirname = deps.dirname || __dirname;
|
|
139
|
+
const exists = deps.exists || fs.existsSync;
|
|
140
|
+
|
|
141
|
+
if (env.APRA_FLEET_SERVER_CMD) {
|
|
142
|
+
const parts = env.APRA_FLEET_SERVER_CMD.split(' ').filter(Boolean);
|
|
143
|
+
if (parts.length === 0) {
|
|
144
|
+
throw new Error('APRA_FLEET_SERVER_CMD is set but empty.');
|
|
145
|
+
}
|
|
146
|
+
return { command: parts[0], args: parts.slice(1) };
|
|
147
|
+
}
|
|
148
|
+
if (env.APRA_FLEET_SERVER_BIN) {
|
|
149
|
+
return { command: env.APRA_FLEET_SERVER_BIN, args: ['run', '--transport', 'stdio'] };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const bundledSiblingEntry = path.join(dirname, 'index.js');
|
|
153
|
+
const devMonorepoEntry = path.resolve(dirname, '..', '..', '..', 'dist', 'index.js');
|
|
154
|
+
|
|
155
|
+
for (const entry of [bundledSiblingEntry, devMonorepoEntry]) {
|
|
156
|
+
if (exists(entry)) {
|
|
157
|
+
return { command: 'node', args: [entry, 'run', '--transport', 'stdio'] };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
throw new Error(
|
|
162
|
+
'[apra-fleet-se] Could not locate the apra-fleet MCP server entry point. Tried:\n' +
|
|
163
|
+
` - ${bundledSiblingEntry} (bundled layout)\n` +
|
|
164
|
+
` - ${devMonorepoEntry} (dev-monorepo layout)\n` +
|
|
165
|
+
'Set APRA_FLEET_SERVER_CMD (a full "<command> <args...>" string) or ' +
|
|
166
|
+
'APRA_FLEET_SERVER_BIN (a server executable resolved via PATH) to point at your ' +
|
|
167
|
+
'apra-fleet server explicitly.',
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The ADR's resolution order, as a pure descriptor (nothing is spawned or connected).
|
|
173
|
+
*
|
|
174
|
+
* @param {{ env?: Record<string, string|undefined>, dirname?: string,
|
|
175
|
+
* exists?: (candidate: string) => boolean,
|
|
176
|
+
* checkRunningInstance?: (deps?: object) => Promise<object> }} [deps]
|
|
177
|
+
* @returns {Promise<{mode: 'http', url: string, pid: number, reason: string}
|
|
178
|
+
* | {mode: 'stdio', command: string, args: string[], reason: string}>}
|
|
179
|
+
*/
|
|
180
|
+
export async function resolveFleetServerConnection(deps = {}) {
|
|
181
|
+
const env = deps.env || process.env;
|
|
182
|
+
const probe = deps.checkRunningInstance || checkRunningInstance;
|
|
183
|
+
|
|
184
|
+
const forced = (env.APRA_FLEET_TRANSPORT || '').trim().toLowerCase();
|
|
185
|
+
if (forced && forced !== 'http' && forced !== 'stdio') {
|
|
186
|
+
throw new Error(
|
|
187
|
+
`APRA_FLEET_TRANSPORT is set to '${env.APRA_FLEET_TRANSPORT}'. Valid values are 'http' or 'stdio'.`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Step 1 -- forced-transport / explicit stdio escape hatches.
|
|
192
|
+
const explicitStdioCmd = Boolean(env.APRA_FLEET_SERVER_CMD || env.APRA_FLEET_SERVER_BIN);
|
|
193
|
+
if (forced === 'stdio' || (forced !== 'http' && explicitStdioCmd)) {
|
|
194
|
+
const cmd = resolveFleetServerCommand(deps);
|
|
195
|
+
return {
|
|
196
|
+
mode: 'stdio',
|
|
197
|
+
...cmd,
|
|
198
|
+
reason: forced === 'stdio'
|
|
199
|
+
? 'APRA_FLEET_TRANSPORT=stdio forced'
|
|
200
|
+
: 'APRA_FLEET_SERVER_CMD/APRA_FLEET_SERVER_BIN set (explicit stdio request)',
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Step 2 -- HTTP singleton probe (the default path).
|
|
205
|
+
const instance = await probe({ env });
|
|
206
|
+
if (instance && instance.running) {
|
|
207
|
+
return {
|
|
208
|
+
mode: 'http',
|
|
209
|
+
url: instance.url,
|
|
210
|
+
pid: instance.pid,
|
|
211
|
+
reason: `attached to HTTP singleton at ${instance.url} (pid ${instance.pid})`,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// An explicit APRA_FLEET_TRANSPORT=http must never silently become a private
|
|
216
|
+
// stdio server (ADR Decision 1, step 1).
|
|
217
|
+
if (forced === 'http') {
|
|
218
|
+
throw new Error(
|
|
219
|
+
'APRA_FLEET_TRANSPORT=http was requested, but no healthy apra-fleet HTTP singleton was found.\n' +
|
|
220
|
+
` Checked: ${getServerInfoPath(env)} (pid alive + GET /health)\n` +
|
|
221
|
+
" Start one with 'apra-fleet start' (or 'apra-fleet install'), or unset " +
|
|
222
|
+
'APRA_FLEET_TRANSPORT to allow the stdio self-spawn fallback.',
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Step 3 -- stdio self-spawn fallback.
|
|
227
|
+
const cmd = resolveFleetServerCommand(deps);
|
|
228
|
+
return {
|
|
229
|
+
mode: 'stdio',
|
|
230
|
+
...cmd,
|
|
231
|
+
reason: `no healthy fleet singleton found; self-spawning stdio server via ${cmd.command} ${cmd.args.join(' ')}`,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Resolve + connect, returning a live MCP client bound to whichever transport the
|
|
237
|
+
* ADR order selected.
|
|
238
|
+
*
|
|
239
|
+
* @param {object} [deps] same bag as resolveFleetServerConnection, plus `options`
|
|
240
|
+
* forwarded to the transport.
|
|
241
|
+
* @returns {Promise<{transport: object, mcpClient: McpClient, fleetApi: ApraFleet, mode: 'http'|'stdio'}>}
|
|
242
|
+
*/
|
|
243
|
+
export async function connectFleet(deps = {}) {
|
|
244
|
+
const resolution = await resolveFleetServerConnection(deps);
|
|
245
|
+
const options = deps.options || {};
|
|
246
|
+
|
|
247
|
+
const transport = resolution.mode === 'http'
|
|
248
|
+
? new StreamableHttpTransport(resolution.url, options)
|
|
249
|
+
: new StdioTransport(resolution.command, resolution.args, options);
|
|
250
|
+
|
|
251
|
+
await transport.start();
|
|
252
|
+
|
|
253
|
+
const mcpClient = new McpClient(transport);
|
|
254
|
+
|
|
255
|
+
if (resolution.mode === 'stdio') {
|
|
256
|
+
await mcpClient.request('initialize', {
|
|
257
|
+
protocolVersion: '2024-11-05',
|
|
258
|
+
capabilities: {},
|
|
259
|
+
clientInfo: { name: 'fleet-client', version: '1.0.0' },
|
|
260
|
+
});
|
|
261
|
+
await transport.send({ jsonrpc: '2.0', method: 'notifications/initialized', params: {} });
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return { transport, mcpClient, fleetApi: new ApraFleet(mcpClient), mode: resolution.mode };
|
|
265
|
+
}
|