@apralabs/apra-fleet 0.4.0 → 0.4.2
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 +159 -13
- package/dist/agents/backlog-groomer.md +31 -19
- package/dist/agents/ci-watcher.md +16 -1
- package/dist/agents/deployer.md +37 -47
- package/dist/agents/doer.md +147 -114
- package/dist/agents/harvester.md +41 -34
- package/dist/agents/integ-test-runner.md +98 -114
- package/dist/agents/kb-reconciler.md +205 -0
- package/dist/agents/plan-reviewer.md +45 -44
- package/dist/agents/planner.md +121 -50
- package/dist/agents/regression-test-runner.md +84 -81
- package/dist/agents/reviewer.md +118 -44
- package/dist/agents/schemas/doer-output.json +63 -3
- package/dist/agents/schemas/harvester-output.json +59 -2
- package/dist/agents/schemas/integ-test-runner-output.json +3 -3
- package/dist/agents/schemas/kb-reconciler-output.json +87 -0
- package/dist/agents/schemas/planner-output.json +65 -0
- package/dist/agents/schemas/regression-test-runner-output.json +4 -17
- package/dist/agents/schemas/reviewer-output.json +105 -8
- package/dist/cli/auth.d.ts.map +1 -1
- package/dist/cli/auth.js +1 -2
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/config.d.ts +3 -3
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +4 -13
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/install.d.ts +1 -0
- package/dist/cli/install.d.ts.map +1 -1
- package/dist/cli/install.js +141 -44
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/join.js +1 -1
- package/dist/cli/join.js.map +1 -1
- package/dist/cli/kb-commit.d.ts +12 -0
- package/dist/cli/kb-commit.d.ts.map +1 -0
- package/dist/cli/kb-commit.js +53 -0
- package/dist/cli/kb-commit.js.map +1 -0
- package/dist/cli/kb-directives.d.ts +17 -0
- package/dist/cli/kb-directives.d.ts.map +1 -0
- package/dist/cli/kb-directives.js +146 -0
- package/dist/cli/kb-directives.js.map +1 -0
- package/dist/cli/kb-import.d.ts +13 -0
- package/dist/cli/kb-import.d.ts.map +1 -0
- package/dist/cli/kb-import.js +56 -0
- package/dist/cli/kb-import.js.map +1 -0
- package/dist/cli/register-member.js +1 -1
- package/dist/cli/start.d.ts.map +1 -1
- package/dist/cli/start.js +7 -0
- package/dist/cli/start.js.map +1 -1
- package/dist/cli/uninstall.d.ts.map +1 -1
- package/dist/cli/uninstall.js +16 -3
- package/dist/cli/uninstall.js.map +1 -1
- package/dist/cli/watch.d.ts +76 -4
- package/dist/cli/watch.d.ts.map +1 -1
- package/dist/cli/watch.js +150 -17
- package/dist/cli/watch.js.map +1 -1
- package/dist/commands/kb-server.d.ts +8 -0
- package/dist/commands/kb-server.d.ts.map +1 -0
- package/dist/commands/kb-server.js +221 -0
- package/dist/commands/kb-server.js.map +1 -0
- package/dist/index.js +77 -2
- package/dist/index.js.map +1 -1
- package/dist/os/git-bash-candidates.d.ts +35 -0
- package/dist/os/git-bash-candidates.d.ts.map +1 -0
- package/dist/os/git-bash-candidates.js +46 -0
- package/dist/os/git-bash-candidates.js.map +1 -0
- package/dist/os/index.d.ts +13 -4
- package/dist/os/index.d.ts.map +1 -1
- package/dist/os/index.js +17 -2
- package/dist/os/index.js.map +1 -1
- package/dist/os/linux.d.ts +1 -0
- package/dist/os/linux.d.ts.map +1 -1
- package/dist/os/linux.js +19 -2
- package/dist/os/linux.js.map +1 -1
- package/dist/os/os-commands.d.ts +12 -0
- package/dist/os/os-commands.d.ts.map +1 -1
- package/dist/os/os-commands.js.map +1 -1
- package/dist/os/windows-gitbash.d.ts +93 -0
- package/dist/os/windows-gitbash.d.ts.map +1 -0
- package/dist/os/windows-gitbash.js +244 -0
- package/dist/os/windows-gitbash.js.map +1 -0
- package/dist/os/windows.d.ts +35 -0
- package/dist/os/windows.d.ts.map +1 -1
- package/dist/os/windows.js +93 -35
- package/dist/os/windows.js.map +1 -1
- package/dist/providers/agy.d.ts +15 -3
- package/dist/providers/agy.d.ts.map +1 -1
- package/dist/providers/agy.js +145 -11
- package/dist/providers/agy.js.map +1 -1
- package/dist/providers/claude.d.ts +14 -3
- package/dist/providers/claude.d.ts.map +1 -1
- package/dist/providers/claude.js +69 -22
- package/dist/providers/claude.js.map +1 -1
- package/dist/providers/codex.d.ts +14 -3
- package/dist/providers/codex.d.ts.map +1 -1
- package/dist/providers/codex.js +34 -8
- package/dist/providers/codex.js.map +1 -1
- package/dist/providers/copilot.d.ts +14 -3
- package/dist/providers/copilot.d.ts.map +1 -1
- package/dist/providers/copilot.js +33 -8
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/email/headers.d.ts +15 -0
- package/dist/providers/email/headers.d.ts.map +1 -0
- package/dist/providers/email/headers.js +42 -0
- package/dist/providers/email/headers.js.map +1 -0
- package/dist/providers/email/index.d.ts +18 -0
- package/dist/providers/email/index.d.ts.map +1 -0
- package/dist/providers/email/index.js +60 -0
- package/dist/providers/email/index.js.map +1 -0
- package/dist/providers/email/provider.d.ts +49 -0
- package/dist/providers/email/provider.d.ts.map +1 -0
- package/dist/providers/email/provider.js +2 -0
- package/dist/providers/email/provider.js.map +1 -0
- package/dist/providers/email/sendgrid.d.ts +12 -0
- package/dist/providers/email/sendgrid.d.ts.map +1 -0
- package/dist/providers/email/sendgrid.js +67 -0
- package/dist/providers/email/sendgrid.js.map +1 -0
- package/dist/providers/email/smtp.d.ts +65 -0
- package/dist/providers/email/smtp.d.ts.map +1 -0
- package/dist/providers/email/smtp.js +373 -0
- package/dist/providers/email/smtp.js.map +1 -0
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +0 -3
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/none.d.ts +14 -3
- package/dist/providers/none.d.ts.map +1 -1
- package/dist/providers/none.js +26 -2
- package/dist/providers/none.js.map +1 -1
- package/dist/providers/opencode.d.ts +14 -3
- package/dist/providers/opencode.d.ts.map +1 -1
- package/dist/providers/opencode.js +60 -6
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/provider.d.ts +91 -5
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/provider.js +45 -1
- package/dist/providers/provider.js.map +1 -1
- package/dist/services/agent-provisioner.d.ts.map +1 -1
- package/dist/services/agent-provisioner.js +5 -8
- package/dist/services/agent-provisioner.js.map +1 -1
- package/dist/services/cloud/activity.js +2 -2
- package/dist/services/cloud/activity.js.map +1 -1
- package/dist/services/cloud/lifecycle.d.ts.map +1 -1
- package/dist/services/cloud/lifecycle.js +3 -0
- package/dist/services/cloud/lifecycle.js.map +1 -1
- package/dist/services/cloud/task-wrapper.d.ts +18 -0
- package/dist/services/cloud/task-wrapper.d.ts.map +1 -1
- package/dist/services/cloud/task-wrapper.js +157 -0
- package/dist/services/cloud/task-wrapper.js.map +1 -1
- package/dist/services/context-admission.d.ts.map +1 -1
- package/dist/services/context-admission.js +9 -7
- package/dist/services/context-admission.js.map +1 -1
- package/dist/services/credential-cleanup.d.ts.map +1 -1
- package/dist/services/credential-cleanup.js +22 -3
- package/dist/services/credential-cleanup.js.map +1 -1
- package/dist/services/github-app.d.ts.map +1 -1
- package/dist/services/github-app.js +11 -2
- package/dist/services/github-app.js.map +1 -1
- package/dist/services/knowledge/audn.d.ts +37 -0
- package/dist/services/knowledge/audn.d.ts.map +1 -0
- package/dist/services/knowledge/audn.js +219 -0
- package/dist/services/knowledge/audn.js.map +1 -0
- package/dist/services/knowledge/file-hash.d.ts +11 -0
- package/dist/services/knowledge/file-hash.d.ts.map +1 -0
- package/dist/services/knowledge/file-hash.js +123 -0
- package/dist/services/knowledge/file-hash.js.map +1 -0
- package/dist/services/knowledge/http-provider.d.ts +46 -0
- package/dist/services/knowledge/http-provider.d.ts.map +1 -0
- package/dist/services/knowledge/http-provider.js +254 -0
- package/dist/services/knowledge/http-provider.js.map +1 -0
- package/dist/services/knowledge/kb-providers.d.ts +15 -0
- package/dist/services/knowledge/kb-providers.d.ts.map +1 -0
- package/dist/services/knowledge/kb-providers.js +92 -0
- package/dist/services/knowledge/kb-providers.js.map +1 -0
- package/dist/services/knowledge/kb-scope-input.d.ts +5 -0
- package/dist/services/knowledge/kb-scope-input.d.ts.map +1 -0
- package/dist/services/knowledge/kb-scope-input.js +11 -0
- package/dist/services/knowledge/kb-scope-input.js.map +1 -0
- package/dist/services/knowledge/kb-service.d.ts +3 -0
- package/dist/services/knowledge/kb-service.d.ts.map +1 -0
- package/dist/services/knowledge/kb-service.js +2 -0
- package/dist/services/knowledge/kb-service.js.map +1 -0
- package/dist/services/knowledge/path-validation.d.ts +2 -0
- package/dist/services/knowledge/path-validation.d.ts.map +1 -0
- package/dist/services/knowledge/path-validation.js +13 -0
- package/dist/services/knowledge/path-validation.js.map +1 -0
- package/dist/services/knowledge/pre-init.d.ts +14 -0
- package/dist/services/knowledge/pre-init.d.ts.map +1 -0
- package/dist/services/knowledge/pre-init.js +147 -0
- package/dist/services/knowledge/pre-init.js.map +1 -0
- package/dist/services/knowledge/project-slug.d.ts +2 -0
- package/dist/services/knowledge/project-slug.d.ts.map +1 -0
- package/dist/services/knowledge/project-slug.js +49 -0
- package/dist/services/knowledge/project-slug.js.map +1 -0
- package/dist/services/knowledge/sqlite-provider.d.ts +147 -0
- package/dist/services/knowledge/sqlite-provider.d.ts.map +1 -0
- package/dist/services/knowledge/sqlite-provider.js +1646 -0
- package/dist/services/knowledge/sqlite-provider.js.map +1 -0
- package/dist/services/knowledge/types.d.ts +163 -0
- package/dist/services/knowledge/types.d.ts.map +1 -0
- package/dist/services/knowledge/types.js +9 -0
- package/dist/services/knowledge/types.js.map +1 -0
- package/dist/services/member-home.d.ts +89 -0
- package/dist/services/member-home.d.ts.map +1 -0
- package/dist/services/member-home.js +259 -0
- package/dist/services/member-home.js.map +1 -0
- package/dist/services/member-remote-url.d.ts +34 -0
- package/dist/services/member-remote-url.d.ts.map +1 -0
- package/dist/services/member-remote-url.js +39 -0
- package/dist/services/member-remote-url.js.map +1 -0
- package/dist/services/model-pricing.d.ts.map +1 -1
- package/dist/services/model-pricing.js +0 -5
- package/dist/services/model-pricing.js.map +1 -1
- package/dist/services/orphan-recovery.d.ts +9 -3
- package/dist/services/orphan-recovery.d.ts.map +1 -1
- package/dist/services/orphan-recovery.js +22 -8
- package/dist/services/orphan-recovery.js.map +1 -1
- package/dist/services/preflight-check.d.ts +56 -0
- package/dist/services/preflight-check.d.ts.map +1 -0
- package/dist/services/preflight-check.js +277 -0
- package/dist/services/preflight-check.js.map +1 -0
- package/dist/services/shell-probe.d.ts +131 -0
- package/dist/services/shell-probe.d.ts.map +1 -0
- package/dist/services/shell-probe.js +210 -0
- package/dist/services/shell-probe.js.map +1 -0
- package/dist/services/singleton.d.ts +2 -0
- package/dist/services/singleton.d.ts.map +1 -1
- package/dist/services/singleton.js +1 -1
- package/dist/services/singleton.js.map +1 -1
- package/dist/services/ssh.js +2 -2
- package/dist/services/ssh.js.map +1 -1
- package/dist/services/stall/find-log-file.d.ts.map +1 -1
- package/dist/services/stall/find-log-file.js +22 -16
- package/dist/services/stall/find-log-file.js.map +1 -1
- package/dist/services/stall/log-path-resolver.d.ts +11 -8
- package/dist/services/stall/log-path-resolver.d.ts.map +1 -1
- package/dist/services/stall/log-path-resolver.js +17 -40
- package/dist/services/stall/log-path-resolver.js.map +1 -1
- package/dist/services/stall/read-log-tail.d.ts.map +1 -1
- package/dist/services/stall/read-log-tail.js +6 -5
- package/dist/services/stall/read-log-tail.js.map +1 -1
- package/dist/services/stall/stall-detector.d.ts +32 -0
- package/dist/services/stall/stall-detector.d.ts.map +1 -1
- package/dist/services/stall/stall-detector.js +149 -6
- package/dist/services/stall/stall-detector.js.map +1 -1
- package/dist/services/stall/stall-poller.d.ts +34 -0
- package/dist/services/stall/stall-poller.d.ts.map +1 -1
- package/dist/services/stall/stall-poller.js +160 -35
- package/dist/services/stall/stall-poller.js.map +1 -1
- package/dist/services/strategy.d.ts +9 -0
- package/dist/services/strategy.d.ts.map +1 -1
- package/dist/services/strategy.js +41 -7
- package/dist/services/strategy.js.map +1 -1
- package/dist/services/tool-registry.d.ts.map +1 -1
- package/dist/services/tool-registry.js +87 -1
- package/dist/services/tool-registry.js.map +1 -1
- package/dist/services/user-config.js +1 -1
- package/dist/services/user-config.js.map +1 -1
- package/dist/services/vcs/azure-devops.d.ts +1 -1
- package/dist/services/vcs/azure-devops.d.ts.map +1 -1
- package/dist/services/vcs/azure-devops.js +105 -10
- package/dist/services/vcs/azure-devops.js.map +1 -1
- package/dist/services/vcs/bitbucket.d.ts.map +1 -1
- package/dist/services/vcs/bitbucket.js +16 -0
- package/dist/services/vcs/bitbucket.js.map +1 -1
- package/dist/services/vcs/github.d.ts.map +1 -1
- package/dist/services/vcs/github.js +56 -1
- package/dist/services/vcs/github.js.map +1 -1
- package/dist/services/vcs/types.d.ts +123 -2
- package/dist/services/vcs/types.d.ts.map +1 -1
- package/dist/services/version-check.d.ts +22 -0
- package/dist/services/version-check.d.ts.map +1 -0
- package/dist/services/version-check.js +103 -0
- package/dist/services/version-check.js.map +1 -0
- package/dist/skills/fleet-sprint-cli/SKILL.md +15 -3
- package/dist/skills/pm/SKILL.md +0 -1
- package/dist/skills/pm/beads.md +6 -0
- package/dist/skills/pm/cost.md +0 -1
- package/dist/skills/pm/fleet-addendum.md +6 -1
- package/dist/skills/pm/index.md +56 -0
- package/dist/skills/pm/kb-reconcile.md +132 -0
- package/dist/skills/pm/kb-review.md +109 -0
- package/dist/tools/check-status.d.ts +47 -0
- package/dist/tools/check-status.d.ts.map +1 -1
- package/dist/tools/check-status.js +245 -3
- package/dist/tools/check-status.js.map +1 -1
- package/dist/tools/child-id-allocator.d.ts +2 -2
- package/dist/tools/cloud-control.js +2 -2
- package/dist/tools/cloud-control.js.map +1 -1
- package/dist/tools/code-intelligence-codebase-memory.d.ts +11 -0
- package/dist/tools/code-intelligence-codebase-memory.d.ts.map +1 -0
- package/dist/tools/code-intelligence-codebase-memory.js +270 -0
- package/dist/tools/code-intelligence-codebase-memory.js.map +1 -0
- package/dist/tools/code-intelligence-freshness.d.ts +2 -0
- package/dist/tools/code-intelligence-freshness.d.ts.map +1 -0
- package/dist/tools/code-intelligence-freshness.js +26 -0
- package/dist/tools/code-intelligence-freshness.js.map +1 -0
- package/dist/tools/code-intelligence-gitnexus.d.ts +14 -0
- package/dist/tools/code-intelligence-gitnexus.d.ts.map +1 -0
- package/dist/tools/code-intelligence-gitnexus.js +475 -0
- package/dist/tools/code-intelligence-gitnexus.js.map +1 -0
- package/dist/tools/code-intelligence-kb-enrich.d.ts +2 -0
- package/dist/tools/code-intelligence-kb-enrich.d.ts.map +1 -0
- package/dist/tools/code-intelligence-kb-enrich.js +65 -0
- package/dist/tools/code-intelligence-kb-enrich.js.map +1 -0
- package/dist/tools/code-intelligence-reindex.d.ts +7 -0
- package/dist/tools/code-intelligence-reindex.d.ts.map +1 -0
- package/dist/tools/code-intelligence-reindex.js +106 -0
- package/dist/tools/code-intelligence-reindex.js.map +1 -0
- package/dist/tools/code-intelligence-telemetry.d.ts +5 -0
- package/dist/tools/code-intelligence-telemetry.d.ts.map +1 -0
- package/dist/tools/code-intelligence-telemetry.js +52 -0
- package/dist/tools/code-intelligence-telemetry.js.map +1 -0
- package/dist/tools/code-intelligence-tests.d.ts +2 -0
- package/dist/tools/code-intelligence-tests.d.ts.map +1 -0
- package/dist/tools/code-intelligence-tests.js +24 -0
- package/dist/tools/code-intelligence-tests.js.map +1 -0
- package/dist/tools/code-intelligence.d.ts +114 -0
- package/dist/tools/code-intelligence.d.ts.map +1 -0
- package/dist/tools/code-intelligence.js +124 -0
- package/dist/tools/code-intelligence.js.map +1 -0
- package/dist/tools/compose-permissions.d.ts +26 -0
- package/dist/tools/compose-permissions.d.ts.map +1 -1
- package/dist/tools/compose-permissions.js +257 -33
- package/dist/tools/compose-permissions.js.map +1 -1
- package/dist/tools/execute-command.d.ts +2 -0
- package/dist/tools/execute-command.d.ts.map +1 -1
- package/dist/tools/execute-command.js +114 -28
- package/dist/tools/execute-command.js.map +1 -1
- package/dist/tools/execute-prompt.d.ts +13 -1
- package/dist/tools/execute-prompt.d.ts.map +1 -1
- package/dist/tools/execute-prompt.js +310 -61
- package/dist/tools/execute-prompt.js.map +1 -1
- package/dist/tools/kb-capture.d.ts +53 -0
- package/dist/tools/kb-capture.d.ts.map +1 -0
- package/dist/tools/kb-capture.js +130 -0
- package/dist/tools/kb-capture.js.map +1 -0
- package/dist/tools/kb-context.d.ts +17 -0
- package/dist/tools/kb-context.d.ts.map +1 -0
- package/dist/tools/kb-context.js +29 -0
- package/dist/tools/kb-context.js.map +1 -0
- package/dist/tools/kb-export.d.ts +19 -0
- package/dist/tools/kb-export.d.ts.map +1 -0
- package/dist/tools/kb-export.js +344 -0
- package/dist/tools/kb-export.js.map +1 -0
- package/dist/tools/kb-feedback.d.ts +23 -0
- package/dist/tools/kb-feedback.d.ts.map +1 -0
- package/dist/tools/kb-feedback.js +43 -0
- package/dist/tools/kb-feedback.js.map +1 -0
- package/dist/tools/kb-freshness-sweep.d.ts +14 -0
- package/dist/tools/kb-freshness-sweep.d.ts.map +1 -0
- package/dist/tools/kb-freshness-sweep.js +29 -0
- package/dist/tools/kb-freshness-sweep.js.map +1 -0
- package/dist/tools/kb-harvest.d.ts +20 -0
- package/dist/tools/kb-harvest.d.ts.map +1 -0
- package/dist/tools/kb-harvest.js +143 -0
- package/dist/tools/kb-harvest.js.map +1 -0
- package/dist/tools/kb-import.d.ts +44 -0
- package/dist/tools/kb-import.d.ts.map +1 -0
- package/dist/tools/kb-import.js +239 -0
- package/dist/tools/kb-import.js.map +1 -0
- package/dist/tools/kb-invalidate.d.ts +19 -0
- package/dist/tools/kb-invalidate.d.ts.map +1 -0
- package/dist/tools/kb-invalidate.js +34 -0
- package/dist/tools/kb-invalidate.js.map +1 -0
- package/dist/tools/kb-list.d.ts +32 -0
- package/dist/tools/kb-list.d.ts.map +1 -0
- package/dist/tools/kb-list.js +43 -0
- package/dist/tools/kb-list.js.map +1 -0
- package/dist/tools/kb-promote.d.ts +20 -0
- package/dist/tools/kb-promote.d.ts.map +1 -0
- package/dist/tools/kb-promote.js +20 -0
- package/dist/tools/kb-promote.js.map +1 -0
- package/dist/tools/kb-query.d.ts +35 -0
- package/dist/tools/kb-query.d.ts.map +1 -0
- package/dist/tools/kb-query.js +111 -0
- package/dist/tools/kb-query.js.map +1 -0
- package/dist/tools/kb-reconcile-prefilter.d.ts +14 -0
- package/dist/tools/kb-reconcile-prefilter.d.ts.map +1 -0
- package/dist/tools/kb-reconcile-prefilter.js +26 -0
- package/dist/tools/kb-reconcile-prefilter.js.map +1 -0
- package/dist/tools/kb-resolve-contradiction.d.ts +23 -0
- package/dist/tools/kb-resolve-contradiction.d.ts.map +1 -0
- package/dist/tools/kb-resolve-contradiction.js +37 -0
- package/dist/tools/kb-resolve-contradiction.js.map +1 -0
- package/dist/tools/kb-session-prime.d.ts +26 -0
- package/dist/tools/kb-session-prime.d.ts.map +1 -0
- package/dist/tools/kb-session-prime.js +392 -0
- package/dist/tools/kb-session-prime.js.map +1 -0
- package/dist/tools/kb-setup.d.ts +20 -0
- package/dist/tools/kb-setup.d.ts.map +1 -0
- package/dist/tools/kb-setup.js +49 -0
- package/dist/tools/kb-setup.js.map +1 -0
- package/dist/tools/kb-stats.d.ts +20 -0
- package/dist/tools/kb-stats.d.ts.map +1 -0
- package/dist/tools/kb-stats.js +115 -0
- package/dist/tools/kb-stats.js.map +1 -0
- package/dist/tools/list-members.d.ts.map +1 -1
- package/dist/tools/list-members.js +6 -2
- package/dist/tools/list-members.js.map +1 -1
- package/dist/tools/member-detail.d.ts.map +1 -1
- package/dist/tools/member-detail.js +13 -3
- package/dist/tools/member-detail.js.map +1 -1
- package/dist/tools/member-reservation.d.ts.map +1 -1
- package/dist/tools/member-reservation.js +13 -1
- package/dist/tools/member-reservation.js.map +1 -1
- package/dist/tools/monitor-task.d.ts.map +1 -1
- package/dist/tools/monitor-task.js +38 -5
- package/dist/tools/monitor-task.js.map +1 -1
- package/dist/tools/provision-auth.d.ts.map +1 -1
- package/dist/tools/provision-auth.js +15 -8
- package/dist/tools/provision-auth.js.map +1 -1
- package/dist/tools/provision-vcs-auth.d.ts +5 -2
- package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
- package/dist/tools/provision-vcs-auth.js +58 -52
- package/dist/tools/provision-vcs-auth.js.map +1 -1
- package/dist/tools/register-member.d.ts +21 -12
- package/dist/tools/register-member.d.ts.map +1 -1
- package/dist/tools/register-member.js +70 -3
- package/dist/tools/register-member.js.map +1 -1
- package/dist/tools/remove-member.d.ts.map +1 -1
- package/dist/tools/remove-member.js +19 -5
- package/dist/tools/remove-member.js.map +1 -1
- package/dist/tools/report-status.d.ts.map +1 -1
- package/dist/tools/report-status.js +2 -1
- package/dist/tools/report-status.js.map +1 -1
- package/dist/tools/revoke-vcs-auth.js +2 -2
- package/dist/tools/revoke-vcs-auth.js.map +1 -1
- package/dist/tools/send-email.d.ts +69 -0
- package/dist/tools/send-email.d.ts.map +1 -0
- package/dist/tools/send-email.js +177 -0
- package/dist/tools/send-email.js.map +1 -0
- package/dist/tools/setup-ssh-key.d.ts.map +1 -1
- package/dist/tools/setup-ssh-key.js +4 -1
- package/dist/tools/setup-ssh-key.js.map +1 -1
- package/dist/tools/stop-prompt.js +2 -2
- package/dist/tools/stop-prompt.js.map +1 -1
- package/dist/tools/update-agent-cli.js +2 -2
- package/dist/tools/update-agent-cli.js.map +1 -1
- package/dist/tools/update-member.d.ts +21 -12
- package/dist/tools/update-member.d.ts.map +1 -1
- package/dist/tools/update-member.js +43 -2
- package/dist/tools/update-member.js.map +1 -1
- package/dist/types.d.ts +12 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/agent-helpers.d.ts +36 -0
- package/dist/utils/agent-helpers.d.ts.map +1 -1
- package/dist/utils/agent-helpers.js +39 -1
- package/dist/utils/agent-helpers.js.map +1 -1
- package/dist/utils/platform.d.ts +7 -0
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js +11 -1
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/prompt-errors.js +1 -1
- package/dist/utils/prompt-errors.js.map +1 -1
- package/dist/utils/session-caller.d.ts +28 -0
- package/dist/utils/session-caller.d.ts.map +1 -0
- package/dist/utils/session-caller.js +24 -0
- package/dist/utils/session-caller.js.map +1 -0
- package/dist/utils/work-folder-validation.d.ts +39 -0
- package/dist/utils/work-folder-validation.d.ts.map +1 -0
- package/dist/utils/work-folder-validation.js +60 -0
- package/dist/utils/work-folder-validation.js.map +1 -0
- package/dist/utils/workspace-trust.d.ts.map +1 -1
- package/dist/utils/workspace-trust.js +5 -1
- package/dist/utils/workspace-trust.js.map +1 -1
- package/dist/workflows/auto-sprint.js +550 -23
- package/package.json +7 -4
- package/packages/apra-fleet-client/src/client/api.mjs +210 -7
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +31 -19
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +16 -1
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +37 -47
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +147 -114
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +41 -34
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +98 -114
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +205 -0
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +45 -44
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +121 -50
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +84 -81
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +118 -44
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +63 -3
- package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-output.json +59 -2
- package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +3 -3
- package/packages/apra-fleet-se/apra-pm/agents/schemas/kb-reconciler-output.json +87 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/planner-output.json +65 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +4 -17
- package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +105 -8
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +0 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/beads.md +6 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +6 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +56 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/kb-reconcile.md +132 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/kb-review.md +109 -0
- package/packages/apra-fleet-se/bin/cli.mjs +139 -3
- package/packages/apra-fleet-se/bin/serve.mjs +49 -2
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +182 -38
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +23 -8
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-manual-recovery-verified.md +258 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +1487 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +908 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/shared-orchestrator-reservation-design.md +399 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +14 -4
- package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +1148 -0
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +229 -112
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +91 -6
- package/packages/apra-fleet-se/fleet-sprint/runner.js +2469 -238
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +134 -0
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +154 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows-gitbash.mjs +97 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +143 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +15 -3
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +350 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-progress.mjs +101 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +51 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +657 -12
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +33 -4
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +60 -30
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +205 -2
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +164 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +141 -26
- package/packages/apra-fleet-se/package.json +1 -0
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +294 -14
- package/packages/apra-fleet-workflow/src/viewer/run-title.mjs +60 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +443 -35
- package/skills/fleet/SKILL.md +20 -9
- package/skills/fleet/auth-azdevops.md +44 -5
- package/skills/fleet/auth-bitbucket.md +3 -3
- package/skills/fleet/auth-github.md +2 -2
- package/skills/fleet/beads-conflict-resolution.md +141 -0
- package/skills/fleet/beads.md +16 -12
- package/skills/fleet/knowledge-agent.md +66 -0
- package/skills/fleet/onboarding.md +4 -4
- package/skills/fleet/permissions.md +32 -8
- package/skills/fleet/profiles/base-dev.json +10 -1
- package/skills/fleet/profiles/base-reviewer.json +8 -1
- package/skills/fleet/profiles/tag-kb-reconciler.json +20 -0
- package/skills/fleet/skill-matrix.md +1 -1
- package/skills/fleet/troubleshooting.md +2 -1
- package/version.json +1 -1
- package/dist/providers/gemini.d.ts +0 -42
- package/dist/providers/gemini.d.ts.map +0 -1
- package/dist/providers/gemini.js +0 -202
- package/dist/providers/gemini.js.map +0 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +0 -151
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-tier2-runbook.md +0 -127
- package/packages/apra-fleet-se/fleet-sprint/dolt-recovery-path-b.mjs +0 -339
- package/packages/apra-fleet-se/fleet-sprint/dolt-recovery-tier2.mjs +0 -360
- package/packages/apra-fleet-se/fleet-sprint/dolt-recovery.mjs +0 -363
|
@@ -3,10 +3,11 @@ import os from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { v4 as uuid } from 'uuid';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
+
import { knownRepoRemoteUrl } from '../services/member-remote-url.js';
|
|
6
7
|
import { getStrategy } from '../services/strategy.js';
|
|
7
8
|
import { getOsCommands } from '../os/index.js';
|
|
8
9
|
import { getProvider } from '../providers/index.js';
|
|
9
|
-
import { getAgentOS, touchAgent, getStoredPid } from '../utils/agent-helpers.js';
|
|
10
|
+
import { getAgentOS, getAgentShell, touchAgent, getStoredPid, isPosixShellMember } from '../utils/agent-helpers.js';
|
|
10
11
|
import { updateAgent } from '../services/registry.js';
|
|
11
12
|
import { memberIdentifier, resolveMember } from '../utils/resolve-member.js';
|
|
12
13
|
import { isRetryable, authErrorAdvice, workspaceNotTrustedAdvice } from '../utils/prompt-errors.js';
|
|
@@ -15,6 +16,7 @@ import { writeStatusline } from '../services/statusline.js';
|
|
|
15
16
|
import { getModelOverride } from '../services/user-config.js';
|
|
16
17
|
import { ensureCloudReady } from '../services/cloud/lifecycle.js';
|
|
17
18
|
import { getStallDetector, resolveSessionLogPath } from '../services/stall/index.js';
|
|
19
|
+
import { getCachedMemberPathContext } from '../services/member-home.js';
|
|
18
20
|
import { provisionAgents, remoteAgentsDir, loadCanonicalAgentSet } from '../services/agent-provisioner.js';
|
|
19
21
|
import { escapeWindowsArg, escapeDoubleQuoted } from '../os/os-commands.js';
|
|
20
22
|
import { resolveTilde } from './execute-command.js';
|
|
@@ -23,7 +25,7 @@ import { tryKillPid, isPidAlive } from '../utils/pid-helpers.js';
|
|
|
23
25
|
import { recoverOrphanedDispatch, isRemoteProcessAlive } from '../services/orphan-recovery.js';
|
|
24
26
|
import { seedWorkspaceTrust } from '../utils/workspace-trust.js';
|
|
25
27
|
import { durableOutputPath } from '../os/linux.js';
|
|
26
|
-
import { LogScope, maskSecrets, truncateForLog
|
|
28
|
+
import { LogScope, logLine, logWarn, maskSecrets, truncateForLog } from '../utils/log-helpers.js';
|
|
27
29
|
import { getLogPreviewChars } from '../services/user-config.js';
|
|
28
30
|
import { validateSubstitutionKeys, applySubstitutions } from '../services/substitution-engine.js';
|
|
29
31
|
import { sessionRegistry } from '../services/session-registry.js';
|
|
@@ -34,9 +36,11 @@ import { resolveBudgetScope, evaluateBudget, recordAndEvaluate } from '../servic
|
|
|
34
36
|
import { sendMessage } from './send-message.js';
|
|
35
37
|
import { registerPending } from '../services/pending-responses.js';
|
|
36
38
|
import { isMaxTurnsResponse } from '../providers/provider.js';
|
|
39
|
+
import { preflightCheck } from '../services/preflight-check.js';
|
|
37
40
|
export const executePromptSchema = z.object({
|
|
38
41
|
...memberIdentifier,
|
|
39
42
|
prompt: z.string().describe('The prompt to send to the LLM on the remote member'),
|
|
43
|
+
session_id: z.string().optional().describe('Shorthand for explicit session resume. Equivalent to resume: "<session_id>". If provided, takes precedence over resume.'),
|
|
40
44
|
resume: z.union([z.boolean(), z.string()]).default(true).describe('Session-resume control (default: true). ' +
|
|
41
45
|
'true = best-effort resume of the member\'s stored last session (a stale/unknown stored session transparently falls back to a fresh session). ' +
|
|
42
46
|
'false = always start a fresh session. ' +
|
|
@@ -52,22 +56,21 @@ export const executePromptSchema = z.object({
|
|
|
52
56
|
'Extra keys are silently ignored. Values are never logged.'),
|
|
53
57
|
agent: z.string().optional().describe('Optional agent name to activate. ' +
|
|
54
58
|
'For Claude: invokes claude --agent <name>. ' +
|
|
55
|
-
'For
|
|
56
|
-
'For AGY: prepends @<name> to the prompt on every dispatch (same as Gemini). ' +
|
|
59
|
+
'For AGY: prepends @<name> to the prompt on every dispatch. ' +
|
|
57
60
|
'Substitution runs before the @<name> prepend. ' +
|
|
58
61
|
'Agent file must exist at the provider-specific path on the member: ' +
|
|
59
62
|
'Claude: <workFolder>/.claude/agents/<name>.md or ~/.claude/agents/<name>.md; ' +
|
|
60
|
-
'
|
|
61
|
-
'
|
|
63
|
+
'AGY: <workFolder>/.gemini/antigravity-cli/agents/<name>.md or ~/.gemini/antigravity-cli/agents/<name>.md; ' +
|
|
64
|
+
'OpenCode: <workFolder>/.opencode/agents/<name>.md or ~/.config/opencode/agents/<name>.md -- ' +
|
|
62
65
|
'the call is rejected with a clear error if neither is present.'),
|
|
63
|
-
sprint_id: z.string().optional().describe('Opaque identity of the sprint issuing this dispatch
|
|
66
|
+
sprint_id: z.string().optional().describe('Opaque identity of the sprint issuing this dispatch. ' +
|
|
64
67
|
'When provided, the server-side member-reservation check (see reservedBy below) ' +
|
|
65
68
|
'compares this value directly against the reservation instead of falling back to ' +
|
|
66
69
|
'this server process\'s APRA_FLEET_SPRINT_ID env var -- the same per-call value ' +
|
|
67
70
|
'the caller passed to member_reservation reserve/release. Callers that never set a ' +
|
|
68
71
|
'reservation, or that reserved and dispatch in the same process, should omit this; ' +
|
|
69
72
|
'omitting it preserves the pre-existing env-var-based behavior exactly.'),
|
|
70
|
-
expected_context_tokens: z.number().positive().optional().describe('Optional estimate
|
|
73
|
+
expected_context_tokens: z.number().positive().optional().describe('Optional estimate of how many tokens this dispatch will add ' +
|
|
71
74
|
'to the target session\'s context. When set (or context_size is set), the server ' +
|
|
72
75
|
'compares it against the session\'s remaining context-window headroom BEFORE ' +
|
|
73
76
|
'invoking the LLM: too little headroom rejects the call with ' +
|
|
@@ -75,7 +78,7 @@ export const executePromptSchema = z.object({
|
|
|
75
78
|
'spawn; a fit that lands inside the safety margin still proceeds but attaches a ' +
|
|
76
79
|
'structured contextWarning. Wins over context_size when both are set. Omitting both ' +
|
|
77
80
|
'fields disables the check entirely -- pre-existing behavior is unchanged.'),
|
|
78
|
-
context_size: z.enum(['S', 'M', 'L']).optional().describe('Optional size-bucket shorthand for expected_context_tokens
|
|
81
|
+
context_size: z.enum(['S', 'M', 'L']).optional().describe('Optional size-bucket shorthand for expected_context_tokens: ' +
|
|
79
82
|
'S/M/L map to configured token estimates (fleet defaults, overridable via ' +
|
|
80
83
|
'config.json\'s contextAdmission.sizeBucketTokens). Ignored when expected_context_tokens ' +
|
|
81
84
|
'is also set. The auto-sprint engine supplies this from the dispatched task\'s size ' +
|
|
@@ -124,11 +127,20 @@ async function writePromptFile(agent, strategy, promptFilePath, content) {
|
|
|
124
127
|
fs.writeFileSync(promptFilePath, content, 'utf-8');
|
|
125
128
|
return;
|
|
126
129
|
}
|
|
127
|
-
const agentOs = getAgentOS(agent);
|
|
128
130
|
const promptFileName = path.basename(promptFilePath);
|
|
129
131
|
const remoteDir = path.dirname(promptFilePath);
|
|
130
132
|
const chunks = chunkContent(content);
|
|
131
|
-
|
|
133
|
+
// apra-fleet-7dir.5.4: the PowerShell branch below is shell-INDEPENDENT as a
|
|
134
|
+
// string (a single base64 `powershell -EncodedCommand` invocation, safe to
|
|
135
|
+
// run from bash too), so a gitbash member would survive it. It is routed to
|
|
136
|
+
// the POSIX branch anyway, so that one member class speaks exactly one shell
|
|
137
|
+
// end to end: the sibling deletePromptFile's PowerShell branch cannot clean
|
|
138
|
+
// up the durable stdout mirror (a POSIX /tmp path only bash resolves), and
|
|
139
|
+
// splitting write/delete across two shells for one member would be the
|
|
140
|
+
// harder invariant to keep true. The `cd "<folder>"` this branch emits is
|
|
141
|
+
// the same POSIX form LinuxCommands.buildAgentPromptCommand already uses for
|
|
142
|
+
// every gitbash dispatch, so it adds no new path-quoting exposure.
|
|
143
|
+
if (!isPosixShellMember(agent)) {
|
|
132
144
|
const escapedFolder = escapeWindowsArg(remoteDir);
|
|
133
145
|
for (let i = 0; i < chunks.length; i++) {
|
|
134
146
|
const setup = i === 0 ? `New-Item -Path '${escapedFolder}' -ItemType Directory -Force | Out-Null; ` : '';
|
|
@@ -164,10 +176,13 @@ async function deletePromptFile(agent, strategy, promptFilePath, extraPaths = []
|
|
|
164
176
|
}
|
|
165
177
|
return;
|
|
166
178
|
}
|
|
167
|
-
const agentOs = getAgentOS(agent);
|
|
168
179
|
const promptFileName = path.basename(promptFilePath);
|
|
169
180
|
const remoteDir = path.dirname(promptFilePath);
|
|
170
|
-
|
|
181
|
+
// apra-fleet-7dir.5.4: gitbash members take the POSIX branch, matching
|
|
182
|
+
// writePromptFile above -- and only that branch deletes `extraPaths` (the
|
|
183
|
+
// durable stdout mirror), which lives at a POSIX /tmp path PowerShell would
|
|
184
|
+
// resolve to a different directory entirely.
|
|
185
|
+
if (!isPosixShellMember(agent)) {
|
|
171
186
|
const escapedFolder = escapeWindowsArg(remoteDir);
|
|
172
187
|
const psScript = `Set-Location "${escapedFolder}"; Remove-Item "${promptFileName}" -Force -ErrorAction SilentlyContinue`;
|
|
173
188
|
const encoded = Buffer.from(psScript, 'utf16le').toString('base64');
|
|
@@ -189,6 +204,14 @@ export function resolveModelForTier(agent, tier, provider) {
|
|
|
189
204
|
}
|
|
190
205
|
return provider.modelForTier(tier);
|
|
191
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* apra-fleet-b4g.6: the auto-harvest dispatch (below) is a server-internal
|
|
209
|
+
* kb_harvest call, not an LLM-supplied repo_remote_url like the other kb_*
|
|
210
|
+
* tools' hot paths (apra-fleet-b4g.1). Re-exported from
|
|
211
|
+
* services/member-remote-url.ts, which documents the no-guessing rule and is
|
|
212
|
+
* shared with member_detail (the fleet-sprint engine's only source for it).
|
|
213
|
+
*/
|
|
214
|
+
export { knownRepoRemoteUrl };
|
|
192
215
|
const SECURE_TOKEN_RE = /\{\{secure\.[a-zA-Z0-9_-]{1,64}\}\}/;
|
|
193
216
|
/**
|
|
194
217
|
* The sprint id this server process dispatches on behalf of, or undefined when
|
|
@@ -246,7 +269,15 @@ async function ensureAgentFilesProvisioned(agent) {
|
|
|
246
269
|
// (d) AbortSignal/MCP client cancellation -> abortHandler kills PID, execCommand resolves, finally clears
|
|
247
270
|
// (e) stale session retry -> retried without session ID; finally clears on success or failure
|
|
248
271
|
// (f) server overload retry -> retried after delay; finally clears on success or failure
|
|
249
|
-
// (g) early returns before inFlightAgents.add
|
|
272
|
+
// (g) early returns before inFlightAgents.add (busy-rejection, reservation
|
|
273
|
+
// conflict, no-LLM member): busy state never entered
|
|
274
|
+
// (h) preflight: the lock is claimed just before the preflight await (moved
|
|
275
|
+
// here from the interactive/subprocess split further below, to close the
|
|
276
|
+
// busy-check-to-lock-claim race window -- that split no longer calls
|
|
277
|
+
// .add() itself, it relies on the claim made here). Both the {ok: false}
|
|
278
|
+
// result path and preflightCheck() itself throwing release the lock
|
|
279
|
+
// explicitly inline, since both return/rethrow before reaching any
|
|
280
|
+
// finally block below
|
|
250
281
|
/**
|
|
251
282
|
* apra-fleet-idb: liveness probe for a busy-locked member's backing process.
|
|
252
283
|
* An inFlightAgents entry can outlive the process it was guarding -- a child
|
|
@@ -290,7 +321,7 @@ async function findDeadLockPid(agent, workspaceId) {
|
|
|
290
321
|
if (subprocessPid !== undefined) {
|
|
291
322
|
const alive = agent.agentType === 'local'
|
|
292
323
|
? isPidAlive(subprocessPid)
|
|
293
|
-
: await isRemoteProcessAlive(getStrategy(agent), subprocessPid);
|
|
324
|
+
: await isRemoteProcessAlive(getStrategy(agent), subprocessPid, getAgentOS(agent), getAgentShell(agent));
|
|
294
325
|
if (!alive)
|
|
295
326
|
return subprocessPid;
|
|
296
327
|
}
|
|
@@ -495,6 +526,67 @@ export async function executePrompt(input, extra) {
|
|
|
495
526
|
if (agent.llmProvider === 'none') {
|
|
496
527
|
return `[FAIL] "${agent.friendlyName}" has no LLM provider (llm_provider: "none") -- it is a plain command executor. Use execute_command instead.`;
|
|
497
528
|
}
|
|
529
|
+
// Claim the busy lock BEFORE the preflight await, not after (as it
|
|
530
|
+
// originally was further below at the interactive/subprocess split).
|
|
531
|
+
// preflightCheck can take up to ~30s on a cache miss; leaving the busy-check
|
|
532
|
+
// (line ~546) and the lock claim ~150 lines apart left a window where two
|
|
533
|
+
// near-simultaneous dispatches to the same member could both pass the busy
|
|
534
|
+
// check (neither had claimed the lock yet), both await preflight, and both
|
|
535
|
+
// proceed to double-dispatch. Every return path from here to the
|
|
536
|
+
// interactive/subprocess split below (currently only the preflight-failure
|
|
537
|
+
// return immediately following) must release this lock explicitly, since
|
|
538
|
+
// it now returns AFTER the lock is claimed instead of before.
|
|
539
|
+
inFlightAgents.add(agent.id);
|
|
540
|
+
// Peek at session state early so the preflight check can skip interactive
|
|
541
|
+
// members whose dispatch routes through a live MCP push channel, not SSH.
|
|
542
|
+
const earlyWorkspaceId = getTokenIssuer().workspaceId();
|
|
543
|
+
const earlySession = sessionRegistry.get(earlyWorkspaceId, agent.id);
|
|
544
|
+
const isChannelCapable = !!earlySession?.channelCapable;
|
|
545
|
+
// Pre-dispatch readiness check (apra-fleet preflight-check): verify
|
|
546
|
+
// connectivity and LLM auth BEFORE the expensive prompt dispatch
|
|
547
|
+
// (writePromptFile + CLI invocation). Catches expired OAuth, missing
|
|
548
|
+
// credentials, and offline members in <1s instead of burning a full
|
|
549
|
+
// round trip. Local members and interactive sessions are excluded
|
|
550
|
+
// (local shares this machine's credentials; interactive sessions have
|
|
551
|
+
// their own liveness probes). The check is cached for 60s so
|
|
552
|
+
// back-to-back dispatches do not add latency.
|
|
553
|
+
if (agent.agentType !== 'local' && !isChannelCapable) {
|
|
554
|
+
let preflight;
|
|
555
|
+
try {
|
|
556
|
+
preflight = await preflightCheck(agent);
|
|
557
|
+
}
|
|
558
|
+
catch (err) {
|
|
559
|
+
// preflightCheck's own synchronous prologue (getStrategy/getProvider)
|
|
560
|
+
// and its internal exec calls are not fully guarded -- if it throws
|
|
561
|
+
// instead of resolving {ok: false}, the lock claimed above would
|
|
562
|
+
// otherwise leak forever (no pid captured yet for findDeadLockPid's
|
|
563
|
+
// stale-lock self-heal to recognize). Release and propagate unchanged
|
|
564
|
+
// -- this preserves the exact same exception the caller would have
|
|
565
|
+
// seen before the lock was claimed this early.
|
|
566
|
+
inFlightAgents.delete(agent.id);
|
|
567
|
+
throw err;
|
|
568
|
+
}
|
|
569
|
+
if (!preflight.ok) {
|
|
570
|
+
// R2-F5: use preflight-specific reason codes so fleet-sprint can
|
|
571
|
+
// distinguish pre-dispatch failures from in-dispatch ones and avoid
|
|
572
|
+
// inappropriate self-heal loops (e.g. re-provisioning auth when the
|
|
573
|
+
// member is simply offline).
|
|
574
|
+
const preflightReason = preflight.code === 'offline' ? 'preflight_offline'
|
|
575
|
+
: preflight.code === 'auth_expired' ? 'preflight_auth_expired'
|
|
576
|
+
: preflight.code === 'auth_missing' ? 'preflight_auth_missing'
|
|
577
|
+
: 'dispatch_failed';
|
|
578
|
+
// Release the lock claimed above -- this return happens before the
|
|
579
|
+
// interactive/subprocess split's own add+finally cleanup ever runs.
|
|
580
|
+
inFlightAgents.delete(agent.id);
|
|
581
|
+
return {
|
|
582
|
+
text: `[FAIL] Pre-dispatch check failed for "${agent.friendlyName}": ${preflight.reason}`,
|
|
583
|
+
structuredContent: {
|
|
584
|
+
isError: true,
|
|
585
|
+
reason: preflightReason,
|
|
586
|
+
},
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
}
|
|
498
590
|
// Interactive routing (apra-fleet-2xs.8/us9.8, docs/cloud-fleet-architecture.md
|
|
499
591
|
// section 6): if this member has a live MCP session connected right now,
|
|
500
592
|
// route via send_message + wait-for-response instead of spawning a
|
|
@@ -513,8 +605,8 @@ export async function executePrompt(input, extra) {
|
|
|
513
605
|
// but the routing decision itself must be provider-agnostic: whatever the
|
|
514
606
|
// provider, a session is only an interactive-routing candidate if it
|
|
515
607
|
// actually declared that capability at MCP initialize time (recorded as
|
|
516
|
-
// SessionState.channelCapable below).
|
|
517
|
-
// today (no equivalent push mechanism) and so never
|
|
608
|
+
// SessionState.channelCapable below). Codex is confirmed [FAIL]
|
|
609
|
+
// today (no equivalent push mechanism) and so never ends up channelCapable in
|
|
518
610
|
// practice, but that is a fact about what each provider adapter currently
|
|
519
611
|
// advertises, not a name-based pre-filter here -- any provider that
|
|
520
612
|
// implements the same MCP channel capability is picked up automatically. A
|
|
@@ -522,6 +614,9 @@ export async function executePrompt(input, extra) {
|
|
|
522
614
|
// gives it basic MCP tool access, apra-fleet-fnz.1-3) without that meaning
|
|
523
615
|
// it can receive or act on this push -- routing to it anyway would silently
|
|
524
616
|
// spend the full timeout_s waiting for a response that can never arrive.
|
|
617
|
+
// R2-F3: re-query session registry after the preflight await (10-20s) so
|
|
618
|
+
// interactive routing sees sessions that became channelCapable during that
|
|
619
|
+
// window, rather than using the stale pre-preflight snapshot.
|
|
525
620
|
const workspaceId = getTokenIssuer().workspaceId();
|
|
526
621
|
const rawSession = sessionRegistry.get(workspaceId, agent.id);
|
|
527
622
|
// apra-fleet-eft.74.1: interactive routing requires the EXPLICIT channel
|
|
@@ -587,7 +682,9 @@ export async function executePrompt(input, extra) {
|
|
|
587
682
|
interactiveSession = undefined;
|
|
588
683
|
}
|
|
589
684
|
if (interactiveSession?.server) {
|
|
590
|
-
|
|
685
|
+
// Lock already claimed above, before the preflight await -- do not
|
|
686
|
+
// re-add here (Set.add would be a harmless no-op, but keeping a second
|
|
687
|
+
// add site invites the lock and its release to drift out of sync).
|
|
591
688
|
writeStatusline(new Map([[agent.id, 'busy']]));
|
|
592
689
|
try {
|
|
593
690
|
return await executePromptInteractive(agent, renderedPrompt, input, workspaceId, heuristicWarningSuffix);
|
|
@@ -597,7 +694,7 @@ export async function executePrompt(input, extra) {
|
|
|
597
694
|
writeStatusline(new Map([[agent.id, 'idle']]));
|
|
598
695
|
}
|
|
599
696
|
}
|
|
600
|
-
|
|
697
|
+
// Lock already claimed above, before the preflight await.
|
|
601
698
|
await ensureAgentFilesProvisioned(agent);
|
|
602
699
|
const stallDetector = getStallDetector();
|
|
603
700
|
let clearedByStall = false;
|
|
@@ -650,7 +747,7 @@ export async function executePrompt(input, extra) {
|
|
|
650
747
|
? path.join(resolvedWorkFolder, promptFileName)
|
|
651
748
|
: `${resolvedWorkFolder}/${promptFileName}`;
|
|
652
749
|
const strategy = getStrategy(agent);
|
|
653
|
-
const cmds = getOsCommands(getAgentOS(agent));
|
|
750
|
+
const cmds = getOsCommands(getAgentOS(agent), getAgentShell(agent));
|
|
654
751
|
const provider = getProvider(agent.llmProvider);
|
|
655
752
|
const authPrefix = buildAuthEnvPrefix(agent, getAgentOS(agent));
|
|
656
753
|
const tiers = provider.modelTiers();
|
|
@@ -687,7 +784,9 @@ export async function executePrompt(input, extra) {
|
|
|
687
784
|
// on that session's context, so an unknown/expired id is a
|
|
688
785
|
// TERMINAL session_not_found (handled just below) and NO
|
|
689
786
|
// fresh-session fallback is ever applied (see the retry paths).
|
|
690
|
-
const explicitResumeId = typeof input.
|
|
787
|
+
const explicitResumeId = (typeof input.session_id === 'string' && input.session_id.trim().length > 0)
|
|
788
|
+
? input.session_id.trim()
|
|
789
|
+
: (typeof input.resume === 'string' && input.resume.length > 0 ? input.resume : undefined);
|
|
691
790
|
const resumeRequested = input.resume === true || explicitResumeId !== undefined;
|
|
692
791
|
const resumeTargetId = explicitResumeId ?? agent.sessionId;
|
|
693
792
|
// An explicit-id resume must never silently degrade to a fresh session: that
|
|
@@ -695,7 +794,8 @@ export async function executePrompt(input, extra) {
|
|
|
695
794
|
// resume=false keep their pre-existing transparent recovery.
|
|
696
795
|
const allowFreshSessionFallback = explicitResumeId === undefined;
|
|
697
796
|
const resuming = !!(resumeRequested && resumeTargetId && provider.supportsResume());
|
|
698
|
-
const
|
|
797
|
+
const isCallerMinted = provider.sessionIdStrategy().type === 'caller-minted';
|
|
798
|
+
const mintedId = isCallerMinted
|
|
699
799
|
? (resuming ? resumeTargetId : uuid())
|
|
700
800
|
: (resuming ? resumeTargetId : undefined);
|
|
701
801
|
// Terminal session-not-found gate for explicit-id resumes (apra-fleet-eft.78.1).
|
|
@@ -731,11 +831,59 @@ export async function executePrompt(input, extra) {
|
|
|
731
831
|
inv: scope.getInv(),
|
|
732
832
|
agentName: input.agent,
|
|
733
833
|
};
|
|
834
|
+
// apra-fleet issue #390: session log paths live on the MEMBER's machine, under
|
|
835
|
+
// the MEMBER's home directory, joined with the MEMBER's OS convention. Before
|
|
836
|
+
// this, every remote member got a HUB-home path (os.homedir()) joined with the
|
|
837
|
+
// HUB's path convention -- a path that can never exist on the member, which
|
|
838
|
+
// silently disabled stall detection for Claude and manufactured
|
|
839
|
+
// false-positive stall kills for AGY/OpenCode.
|
|
840
|
+
//
|
|
841
|
+
// This resolution is deliberately SYNCHRONOUS (cached probe result, else the
|
|
842
|
+
// member's known login username's default home): the dispatch path must not
|
|
843
|
+
// add a remote round trip, and a wrong guess here can only cost detection
|
|
844
|
+
// fidelity, never cause a kill. The kill-capable directory poll in
|
|
845
|
+
// stall-poller.ts uses the probe-backed async resolver instead.
|
|
846
|
+
const memberPathCtx = getCachedMemberPathContext(agent);
|
|
847
|
+
const activePreSpawnSid = resuming ? resumeTargetId : (isCallerMinted ? mintedId : undefined);
|
|
848
|
+
let resolvedLogPath = null;
|
|
849
|
+
if (activePreSpawnSid) {
|
|
850
|
+
try {
|
|
851
|
+
resolvedLogPath = resolveSessionLogPath(agent.llmProvider ?? 'claude', activePreSpawnSid, resolvedWorkFolder, memberPathCtx.homeDir, memberPathCtx.targetOs);
|
|
852
|
+
}
|
|
853
|
+
catch {
|
|
854
|
+
resolvedLogPath = null;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
stallDetector.update(agent.id, {
|
|
858
|
+
sessionId: activePreSpawnSid,
|
|
859
|
+
logFilePath: resolvedLogPath,
|
|
860
|
+
provisional: !resolvedLogPath,
|
|
861
|
+
});
|
|
734
862
|
const claudeCmd = authPrefix + cmds.buildAgentPromptCommand(provider, promptOpts);
|
|
735
863
|
// apra-fleet-6z8.1: the per-invocation durable stdout mirror the unix prompt
|
|
736
|
-
// wrapper tees to (see durableOutputPath / buildAgentPromptCommand).
|
|
737
|
-
//
|
|
738
|
-
|
|
864
|
+
// wrapper tees to (see durableOutputPath / buildAgentPromptCommand). A
|
|
865
|
+
// PowerShell Windows member has no such companion tee, so recovery is
|
|
866
|
+
// skipped for it.
|
|
867
|
+
//
|
|
868
|
+
// apra-fleet-7dir.5.4: a Windows member registered as gitbash runs
|
|
869
|
+
// WindowsGitBashCommands, which INHERITS LinuxCommands.buildAgentPromptCommand
|
|
870
|
+
// -- so it has already been teeing its stdout to /tmp/.fleet-out-<inv>.json
|
|
871
|
+
// on every dispatch, with nothing reading it and (because extraPaths was
|
|
872
|
+
// empty) nothing deleting it. Enabling the mirror for gitbash both turns
|
|
873
|
+
// recovery on for that member class and makes the file get cleaned up.
|
|
874
|
+
// This gate and the `unsupported` flag passed to recoverOrphanedDispatch
|
|
875
|
+
// below are ONE decision: recoverOrphanedDispatch short-circuits on
|
|
876
|
+
// `unsupported || !durablePath`, so they must always agree -- hence the
|
|
877
|
+
// single shared predicate.
|
|
878
|
+
//
|
|
879
|
+
// LOCAL agents are deliberately excluded from the flip: orphan recovery
|
|
880
|
+
// exists for a torn-down SSH channel, which a local spawn does not have, and
|
|
881
|
+
// deletePromptFile's local branch would fs.unlinkSync('/tmp/...') through
|
|
882
|
+
// Node on Windows (resolving to C:\tmp), not the MSYS /tmp bash teed to.
|
|
883
|
+
// Non-Windows members (local or remote) keep today's behaviour verbatim.
|
|
884
|
+
const durableMirrorSupported = getAgentOS(agent) !== 'windows'
|
|
885
|
+
|| (getAgentShell(agent) === 'gitbash' && agent.agentType !== 'local');
|
|
886
|
+
const durablePath = durableMirrorSupported ? durableOutputPath(scope.getInv()) : undefined;
|
|
739
887
|
const dispatchStartedAt = Date.now();
|
|
740
888
|
const timeoutMs = (input.timeout_s ?? 300) * 1000;
|
|
741
889
|
const maxTotalMs = input.max_total_s !== undefined ? input.max_total_s * 1000 : undefined;
|
|
@@ -765,13 +913,11 @@ export async function executePrompt(input, extra) {
|
|
|
765
913
|
}
|
|
766
914
|
// Agent file validation -- verify named agent exists before any CLI invocation
|
|
767
915
|
if (input.agent) {
|
|
768
|
-
const
|
|
769
|
-
// AGY uses ~/.gemini/antigravity-cli/ as its config root, not ~/.agy/
|
|
770
|
-
const agentRelDir = provName === 'agy' ? '.gemini/antigravity-cli/agents' : `.${provName}/agents`;
|
|
916
|
+
const dirs = provider.agentDirectories(input.agent);
|
|
771
917
|
let agentFound = false;
|
|
772
918
|
if (agent.agentType === 'local') {
|
|
773
|
-
const projPath = path.join(resolvedWorkFolder,
|
|
774
|
-
const userPath = path.join(os.homedir(),
|
|
919
|
+
const projPath = path.join(resolvedWorkFolder, dirs.project);
|
|
920
|
+
const userPath = path.join(os.homedir(), dirs.home);
|
|
775
921
|
agentFound = fs.existsSync(projPath) || fs.existsSync(userPath);
|
|
776
922
|
if (!agentFound) {
|
|
777
923
|
inFlightAgents.delete(agent.id);
|
|
@@ -782,7 +928,7 @@ export async function executePrompt(input, extra) {
|
|
|
782
928
|
}
|
|
783
929
|
else {
|
|
784
930
|
// Canonical PM role agents (planner/doer/reviewer/plan-reviewer/...) are
|
|
785
|
-
// already guaranteed present in
|
|
931
|
+
// already guaranteed present in ~/dirs.home by
|
|
786
932
|
// ensureAgentFilesProvisioned() above (ln ~576, which ran provisionAgents()
|
|
787
933
|
// for this exact member earlier in this same call) -- trust that instead
|
|
788
934
|
// of re-probing the remote here. This also SIDESTEPS the bug this check
|
|
@@ -794,17 +940,17 @@ export async function executePrompt(input, extra) {
|
|
|
794
940
|
// sprint via a Windows remote member always failed plan-review with
|
|
795
941
|
// "agent 'plan-reviewer' not found").
|
|
796
942
|
const canonicalRelPath = `${input.agent}.md`;
|
|
797
|
-
agentFound = remoteAgentsDir(
|
|
798
|
-
&& loadCanonicalAgentSet(
|
|
943
|
+
agentFound = remoteAgentsDir(provider.name) !== null
|
|
944
|
+
&& loadCanonicalAgentSet(provider.name).some((f) => f.relPath === canonicalRelPath);
|
|
799
945
|
if (!agentFound) {
|
|
800
946
|
// Not part of the canonical PM set (e.g. a project-local custom
|
|
801
947
|
// agent) -- fall back to a REAL existence probe, built platform-aware
|
|
802
948
|
// via this repo's own getOsCommands() abstraction (src/os/*.ts,
|
|
803
949
|
// already used the same way by list-members.ts/member-detail.ts for
|
|
804
950
|
// credential-file checks) instead of a single hardcoded shell dialect.
|
|
805
|
-
const cmds = getOsCommands(getAgentOS(agent));
|
|
806
|
-
const projPath = `${resolvedWorkFolder}/${
|
|
807
|
-
const userPath = `~/${
|
|
951
|
+
const cmds = getOsCommands(getAgentOS(agent), getAgentShell(agent));
|
|
952
|
+
const projPath = `${resolvedWorkFolder}/${dirs.project}`;
|
|
953
|
+
const userPath = `~/${dirs.home}`;
|
|
808
954
|
const [projResult, userResult] = await Promise.all([
|
|
809
955
|
strategy.execCommand(cmds.credentialFileCheck(projPath), 10000),
|
|
810
956
|
strategy.execCommand(cmds.credentialFileCheck(userPath), 10000),
|
|
@@ -815,7 +961,7 @@ export async function executePrompt(input, extra) {
|
|
|
815
961
|
inFlightAgents.delete(agent.id);
|
|
816
962
|
stallDetector.remove(agent.id);
|
|
817
963
|
writeStatusline(new Map([[agent.id, 'idle']]));
|
|
818
|
-
return `execute_prompt: agent "${input.agent}" not found on "${agent.friendlyName}".\n\nExpected at:\n ${resolvedWorkFolder}/${
|
|
964
|
+
return `execute_prompt: agent "${input.agent}" not found on "${agent.friendlyName}".\n\nExpected at:\n ${resolvedWorkFolder}/${dirs.project}\n ~/${dirs.home}`;
|
|
819
965
|
}
|
|
820
966
|
}
|
|
821
967
|
}
|
|
@@ -877,15 +1023,18 @@ export async function executePrompt(input, extra) {
|
|
|
877
1023
|
capturedPid = pid;
|
|
878
1024
|
scope.info(`pid=${pid}`);
|
|
879
1025
|
if (mintedId) {
|
|
1026
|
+
let logPath = null;
|
|
880
1027
|
try {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
provisional: false,
|
|
886
|
-
});
|
|
1028
|
+
logPath = resolveSessionLogPath(agent.llmProvider ?? 'claude', mintedId, resolvedWorkFolder, memberPathCtx.homeDir, memberPathCtx.targetOs);
|
|
1029
|
+
}
|
|
1030
|
+
catch {
|
|
1031
|
+
logPath = null;
|
|
887
1032
|
}
|
|
888
|
-
|
|
1033
|
+
stallDetector.update(agent.id, {
|
|
1034
|
+
sessionId: mintedId,
|
|
1035
|
+
logFilePath: logPath,
|
|
1036
|
+
provisional: !logPath,
|
|
1037
|
+
});
|
|
889
1038
|
}
|
|
890
1039
|
};
|
|
891
1040
|
const abortHandler = () => {
|
|
@@ -950,7 +1099,7 @@ export async function executePrompt(input, extra) {
|
|
|
950
1099
|
throw dispatchErr;
|
|
951
1100
|
scope.info(`[${resolvedModel}] retrying -- dispatch exception: ${dispatchErr.message}`);
|
|
952
1101
|
await tryKillPid(agent, strategy, cmds);
|
|
953
|
-
const freshOpts = { ...promptOpts, sessionId:
|
|
1102
|
+
const freshOpts = { ...promptOpts, sessionId: isCallerMinted ? uuid() : undefined, resuming: false };
|
|
954
1103
|
const retryCmd = authPrefix + cmds.buildAgentPromptCommand(provider, freshOpts);
|
|
955
1104
|
result = await strategy.execCommand(retryCmd, budget.timeoutMs, budget.maxTotalMs, onPidCaptured, dispatchSignal);
|
|
956
1105
|
}
|
|
@@ -982,7 +1131,7 @@ export async function executePrompt(input, extra) {
|
|
|
982
1131
|
if (!staleBudget.exhausted) {
|
|
983
1132
|
scope.info(`[${resolvedModel}] retrying -- stale session`);
|
|
984
1133
|
await tryKillPid(agent, strategy, cmds);
|
|
985
|
-
const freshOpts = { ...promptOpts, sessionId:
|
|
1134
|
+
const freshOpts = { ...promptOpts, sessionId: isCallerMinted ? uuid() : undefined, resuming: false };
|
|
986
1135
|
const retryCmd = authPrefix + cmds.buildAgentPromptCommand(provider, freshOpts);
|
|
987
1136
|
result = await strategy.execCommand(retryCmd, staleBudget.timeoutMs, staleBudget.maxTotalMs, onPidCaptured, dispatchSignal);
|
|
988
1137
|
parsed = provider.parseResponse(result);
|
|
@@ -1001,7 +1150,7 @@ export async function executePrompt(input, extra) {
|
|
|
1001
1150
|
scope.info(`[${resolvedModel}] retrying -- server overloaded`);
|
|
1002
1151
|
await tryKillPid(agent, strategy, cmds);
|
|
1003
1152
|
await new Promise(r => setTimeout(r, SERVER_RETRY_DELAY_MS));
|
|
1004
|
-
const freshOpts = { ...promptOpts, sessionId:
|
|
1153
|
+
const freshOpts = { ...promptOpts, sessionId: isCallerMinted ? uuid() : undefined, resuming: false };
|
|
1005
1154
|
const retryCmd = authPrefix + cmds.buildAgentPromptCommand(provider, freshOpts);
|
|
1006
1155
|
result = await strategy.execCommand(retryCmd, overloadBudget.timeoutMs, overloadBudget.maxTotalMs, onPidCaptured, dispatchSignal);
|
|
1007
1156
|
parsed = provider.parseResponse(result);
|
|
@@ -1075,7 +1224,15 @@ export async function executePrompt(input, extra) {
|
|
|
1075
1224
|
cmds,
|
|
1076
1225
|
pid: capturedPid,
|
|
1077
1226
|
durablePath,
|
|
1078
|
-
|
|
1227
|
+
// apra-fleet-7dir.5.4: the SAME predicate that decides `durablePath`
|
|
1228
|
+
// above -- the mirror and recovery are one decision, and enabling
|
|
1229
|
+
// either alone is inert (no file to read / a file nothing reads).
|
|
1230
|
+
unsupported: !durableMirrorSupported,
|
|
1231
|
+
os: getAgentOS(agent),
|
|
1232
|
+
// Live for gitbash members now that `unsupported` no longer
|
|
1233
|
+
// short-circuits every Windows member: it selects the POSIX
|
|
1234
|
+
// `kill -0` / `cat` probes over the PowerShell ones (apra-fleet-7dir.2.4).
|
|
1235
|
+
shell: getAgentShell(agent),
|
|
1079
1236
|
maxWaitMs: maxTotalMs !== undefined ? Math.max(maxTotalMs - (Date.now() - dispatchStartedAt), 0) : undefined,
|
|
1080
1237
|
scope,
|
|
1081
1238
|
});
|
|
@@ -1110,6 +1267,7 @@ export async function executePrompt(input, extra) {
|
|
|
1110
1267
|
// onAuthFailure shape: a repeat failure after the heal is terminal, not
|
|
1111
1268
|
// looped).
|
|
1112
1269
|
if ((!parsed.result || parsed.result.trim() === '')
|
|
1270
|
+
&& allowFreshSessionFallback
|
|
1113
1271
|
&& provider.classifyError(result.stderr || result.stdout) === 'workspace_not_trusted'
|
|
1114
1272
|
&& !trustHealAttempted) {
|
|
1115
1273
|
trustHealAttempted = true;
|
|
@@ -1118,7 +1276,7 @@ export async function executePrompt(input, extra) {
|
|
|
1118
1276
|
const healBudget = retryBudget();
|
|
1119
1277
|
if (!healBudget.exhausted) {
|
|
1120
1278
|
await tryKillPid(agent, strategy, cmds);
|
|
1121
|
-
const freshOpts = { ...promptOpts, sessionId:
|
|
1279
|
+
const freshOpts = { ...promptOpts, sessionId: isCallerMinted ? uuid() : undefined, resuming: false };
|
|
1122
1280
|
const retryCmd = authPrefix + cmds.buildAgentPromptCommand(provider, freshOpts);
|
|
1123
1281
|
result = await strategy.execCommand(retryCmd, healBudget.timeoutMs, healBudget.maxTotalMs, onPidCaptured, dispatchSignal);
|
|
1124
1282
|
parsed = provider.parseResponse(result);
|
|
@@ -1138,28 +1296,66 @@ export async function executePrompt(input, extra) {
|
|
|
1138
1296
|
}
|
|
1139
1297
|
}
|
|
1140
1298
|
// Session-id assertion: returned id must match the one we minted/resumed
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1299
|
+
const expectedSid = resuming ? resumeTargetId : (isCallerMinted ? mintedId : undefined);
|
|
1300
|
+
const isMismatch = expectedSid && parsed.sessionId && parsed.sessionId !== expectedSid;
|
|
1301
|
+
if (isMismatch) {
|
|
1302
|
+
scope.info(`session-id mismatch: expected=${expectedSid} got=${parsed.sessionId} -- not persisting`);
|
|
1303
|
+
if (!allowFreshSessionFallback && explicitResumeId !== undefined) {
|
|
1304
|
+
inFlightAgents.delete(agent.id);
|
|
1305
|
+
stallDetector.remove(agent.id);
|
|
1306
|
+
writeStatusline(new Map([[agent.id, 'idle']]));
|
|
1307
|
+
clearStoredPid(agent.id);
|
|
1308
|
+
if (parsed.sessionId) {
|
|
1309
|
+
recordKnownSession(agent.id, parsed.sessionId);
|
|
1310
|
+
}
|
|
1311
|
+
if (parsed.usage) {
|
|
1312
|
+
const prev = agent.tokenUsage ?? { input: 0, output: 0 };
|
|
1313
|
+
updateAgent(agent.id, {
|
|
1314
|
+
tokenUsage: {
|
|
1315
|
+
input: prev.input + parsed.usage.input_tokens,
|
|
1316
|
+
output: prev.output + parsed.usage.output_tokens,
|
|
1317
|
+
},
|
|
1318
|
+
});
|
|
1319
|
+
recordSessionUsage(parsed.sessionId ?? expectedSid, parsed.usage);
|
|
1320
|
+
if (budgetScope) {
|
|
1321
|
+
await recordAndEvaluate({ scope: budgetScope, agent, provider, tier: resolvedTier, usage: parsed.usage });
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
return {
|
|
1325
|
+
text: `[FAIL] execute_prompt on "${agent.friendlyName}" failed -- resumed session mismatch. Expected session "${expectedSid}", but provider returned "${parsed.sessionId}".`,
|
|
1326
|
+
structuredContent: {
|
|
1327
|
+
isError: true,
|
|
1328
|
+
reason: 'session_not_found',
|
|
1329
|
+
sessionId: expectedSid,
|
|
1330
|
+
returnedSessionId: parsed.sessionId,
|
|
1331
|
+
...(parsed.usage ? { usage: { ...parsed.usage, total_tokens: parsed.usage.input_tokens + parsed.usage.output_tokens } } : {}),
|
|
1332
|
+
},
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1144
1335
|
touchAgent(agent.id, undefined);
|
|
1145
1336
|
}
|
|
1146
1337
|
else {
|
|
1147
|
-
touchAgent(agent.id, parsed.sessionId ??
|
|
1338
|
+
touchAgent(agent.id, parsed.sessionId ?? expectedSid);
|
|
1148
1339
|
}
|
|
1149
1340
|
// apra-fleet-eft.78.1: mark the session this dispatch actually landed on as
|
|
1150
1341
|
// known/resumable for this member, so a later explicit-id resume of it
|
|
1151
1342
|
// passes the terminal session_not_found gate above instead of being
|
|
1152
1343
|
// rejected as unknown.
|
|
1153
|
-
|
|
1154
|
-
if (
|
|
1344
|
+
const finalSid = parsed.sessionId ?? expectedSid;
|
|
1345
|
+
if (finalSid) {
|
|
1346
|
+
recordKnownSession(agent.id, finalSid);
|
|
1347
|
+
let postLogPath = null;
|
|
1155
1348
|
try {
|
|
1156
|
-
|
|
1157
|
-
sessionId: mintedId,
|
|
1158
|
-
logFilePath: resolveSessionLogPath(agent.llmProvider ?? 'claude', mintedId, agent.workFolder),
|
|
1159
|
-
provisional: false,
|
|
1160
|
-
});
|
|
1349
|
+
postLogPath = resolveSessionLogPath(agent.llmProvider ?? 'claude', finalSid, resolvedWorkFolder, memberPathCtx.homeDir, memberPathCtx.targetOs);
|
|
1161
1350
|
}
|
|
1162
|
-
catch {
|
|
1351
|
+
catch {
|
|
1352
|
+
postLogPath = null;
|
|
1353
|
+
}
|
|
1354
|
+
stallDetector.update(agent.id, {
|
|
1355
|
+
sessionId: finalSid,
|
|
1356
|
+
logFilePath: postLogPath,
|
|
1357
|
+
provisional: !postLogPath,
|
|
1358
|
+
});
|
|
1163
1359
|
}
|
|
1164
1360
|
clearStoredPid(agent.id);
|
|
1165
1361
|
if (parsed.usage) {
|
|
@@ -1197,6 +1393,59 @@ ${parsed.result}`;
|
|
|
1197
1393
|
|
|
1198
1394
|
---
|
|
1199
1395
|
session: ${parsed.sessionId}`;
|
|
1396
|
+
// Auto-harvest learnings from session output (fire-and-forget)
|
|
1397
|
+
if (parsed.result) {
|
|
1398
|
+
// apra-fleet-tm7.2: always pass resolvedWorkFolder, local or remote.
|
|
1399
|
+
// getKbProviders(undefined) falls back to slugFor(process.cwd()) --
|
|
1400
|
+
// the FLEET SERVER's own cwd, not any generic 'default' -- so omitting
|
|
1401
|
+
// repo_path for remote members would silently route their harvested
|
|
1402
|
+
// learnings into the server's own repo KB (the exact defect apra-fleet-tm7
|
|
1403
|
+
// describes).
|
|
1404
|
+
//
|
|
1405
|
+
// apra-fleet-b4g.6: repo_remote_url (apra-fleet-b4g.1) is how a REMOTE
|
|
1406
|
+
// member's call reaches the SAME shared project KB a local clone would --
|
|
1407
|
+
// without it, resolvedWorkFolder is a path on the remote host that will
|
|
1408
|
+
// almost never exist on this (fleet server) machine, resolveProjectSlug's
|
|
1409
|
+
// git calls on it fail with ENOENT, and it falls through to the literal
|
|
1410
|
+
// 'default' slug, pooling every such member's harvest into one shared,
|
|
1411
|
+
// useless bucket (no cross-repo contamination, but no real routing
|
|
1412
|
+
// either). knownRepoRemoteUrl() forwards it whenever the member's own
|
|
1413
|
+
// registration record already carries a genuine URL. It deliberately does
|
|
1414
|
+
// NOT construct one from agent.gitRepos' bare "owner/repo" access-list
|
|
1415
|
+
// entries (see src/services/vcs/github.ts's own
|
|
1416
|
+
// https://github.com/${repo}.git construction for a DIFFERENT, narrower
|
|
1417
|
+
// purpose -- connectivity testing) or shell out to the member host to
|
|
1418
|
+
// discover it: guessing a URL that turns out wrong would route the
|
|
1419
|
+
// harvest into a KB slug that does not match the repo's real local-clone
|
|
1420
|
+
// slug, which is worse than today's honest 'default' degradation. When no
|
|
1421
|
+
// genuine URL is known, behaviour is unchanged from before this fix.
|
|
1422
|
+
// KB-TRUST PHASE 1 (apra-fleet-4wz.8): report the harvest counters. This is
|
|
1423
|
+
// the highest-volume KB writer and its result was previously discarded
|
|
1424
|
+
// entirely, so entries_rejected -- the fail-closed signal -- was invisible
|
|
1425
|
+
// on the one path that produces most of it. Rejections are EXPECTED to
|
|
1426
|
+
// dominate here: harvest's regex extraction frequently yields no file
|
|
1427
|
+
// paths at all, and an entry with no basis is refused by design. A high
|
|
1428
|
+
// rejected count is the invariant working, not a regression to tune away.
|
|
1429
|
+
void import('./kb-harvest.js')
|
|
1430
|
+
.then(({ kbHarvest }) => kbHarvest({
|
|
1431
|
+
repo_path: resolvedWorkFolder,
|
|
1432
|
+
repo_remote_url: knownRepoRemoteUrl(agent),
|
|
1433
|
+
session_transcript: parsed.result,
|
|
1434
|
+
session_id: parsed.sessionId,
|
|
1435
|
+
}))
|
|
1436
|
+
.then((raw) => {
|
|
1437
|
+
try {
|
|
1438
|
+
const r = JSON.parse(raw);
|
|
1439
|
+
if (r.entries_captured || r.entries_updated || r.entries_skipped || r.entries_rejected) {
|
|
1440
|
+
logLine('kb_harvest', `auto-harvest: captured=${r.entries_captured} updated=${r.entries_updated} skipped=${r.entries_skipped} rejected=${r.entries_rejected}`);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
catch {
|
|
1444
|
+
// A non-JSON payload is not worth failing a fire-and-forget harvest over.
|
|
1445
|
+
}
|
|
1446
|
+
})
|
|
1447
|
+
.catch((err) => logWarn('kb_harvest', `auto-harvest failed: ${err.message}`));
|
|
1448
|
+
}
|
|
1200
1449
|
if (heuristicWarningSuffix)
|
|
1201
1450
|
output += heuristicWarningSuffix;
|
|
1202
1451
|
return {
|