@apralabs/apra-fleet 0.4.3 → 0.4.4
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 +66 -30
- package/dist/agents/backlog-groomer.md +75 -27
- package/dist/agents/ci-watcher.md +37 -22
- package/dist/agents/deployer.md +39 -22
- package/dist/agents/doer.md +74 -40
- package/dist/agents/harvester.md +49 -40
- package/dist/agents/integ-test-runner.md +40 -23
- package/dist/agents/kb-reconciler.md +28 -7
- package/dist/agents/plan-reviewer.md +49 -24
- package/dist/agents/planner.md +66 -43
- package/dist/agents/regression-test-runner.md +101 -78
- package/dist/agents/reviewer.md +117 -56
- package/dist/agents/schemas/backlog-groomer-output.json +1 -1
- package/dist/agents/schemas/doer-output.json +32 -0
- package/dist/agents/schemas/harvester-input.json +1 -5
- package/dist/agents/schemas/planner-output.json +1 -1
- package/dist/agents/schemas/regression-test-runner-output.json +41 -7
- package/dist/agents/schemas/reviewer-output.json +62 -3
- package/dist/cli/agent-transform.d.ts +7 -0
- package/dist/cli/agent-transform.js +46 -1
- package/dist/cli/auth.d.ts +1 -0
- package/dist/cli/auth.js +38 -8
- package/dist/cli/beads-install.d.ts +35 -0
- package/dist/cli/beads-install.js +125 -0
- package/dist/cli/beads-pin.d.ts +5 -0
- package/dist/cli/beads-pin.js +27 -0
- package/dist/cli/call.d.ts +27 -0
- package/dist/cli/call.js +177 -0
- package/dist/cli/config.d.ts +24 -1
- package/dist/cli/config.js +69 -2
- package/dist/cli/dolt-install.d.ts +18 -2
- package/dist/cli/dolt-install.js +46 -15
- package/dist/cli/fleet-se-guard.d.ts +51 -0
- package/dist/cli/fleet-se-guard.js +215 -0
- package/dist/cli/install-guard.d.ts +54 -0
- package/dist/cli/install-guard.js +132 -4
- package/dist/cli/install.d.ts +77 -21
- package/dist/cli/install.js +610 -152
- package/dist/cli/kb-commit.d.ts +2 -1
- package/dist/cli/kb-commit.js +1 -1
- package/dist/cli/kb-import.d.ts +2 -1
- package/dist/cli/kb-import.js +1 -1
- package/dist/cli/register-member.js +20 -3
- package/dist/cli/remove-member.d.ts +4 -0
- package/dist/cli/remove-member.js +63 -0
- package/dist/cli/secret.js +9 -0
- package/dist/cli/start.js +59 -4
- package/dist/cli/status.d.ts +3 -0
- package/dist/cli/status.js +45 -12
- package/dist/cli/stop.js +64 -9
- package/dist/cli/uninstall.js +101 -15
- package/dist/cli/update.js +33 -2
- package/dist/cli/watch.js +1 -1
- package/dist/cli/workflow.js +3 -2
- package/dist/commands/kb-server.js +9 -2
- package/dist/hub-service/http-server.d.ts +5 -1
- package/dist/hub-service/http-server.js +55 -5
- package/dist/index.js +155 -8
- package/dist/os/child-env-bound.d.ts +77 -0
- package/dist/os/child-env-bound.js +171 -0
- package/dist/os/linux.d.ts +7 -2
- package/dist/os/linux.js +40 -14
- package/dist/os/macos.d.ts +1 -1
- package/dist/os/macos.js +2 -11
- package/dist/os/os-commands.d.ts +17 -2
- package/dist/os/windows-gitbash.d.ts +1 -0
- package/dist/os/windows-gitbash.js +17 -3
- package/dist/os/windows-wrapper.d.ts +0 -4
- package/dist/os/windows-wrapper.js +2 -1
- package/dist/os/windows.d.ts +5 -2
- package/dist/os/windows.js +75 -29
- package/dist/paths.d.ts +21 -0
- package/dist/paths.js +35 -0
- package/dist/providers/agy.d.ts +6 -2
- package/dist/providers/agy.js +245 -106
- package/dist/providers/claude-permission-denial.d.ts +7 -0
- package/dist/providers/claude-permission-denial.js +137 -0
- package/dist/providers/claude.d.ts +86 -38
- package/dist/providers/claude.js +426 -164
- package/dist/providers/codex.js +5 -1
- package/dist/providers/copilot.js +5 -1
- package/dist/providers/opencode.d.ts +10 -2
- package/dist/providers/opencode.js +114 -53
- package/dist/providers/provider.d.ts +171 -33
- package/dist/providers/provider.js +164 -3
- package/dist/services/agent-provisioner.d.ts +29 -0
- package/dist/services/agent-provisioner.js +107 -0
- package/dist/services/agent-shadow.d.ts +96 -0
- package/dist/services/agent-shadow.js +479 -0
- package/dist/services/agy-project.d.ts +2 -1
- package/dist/services/agy-project.js +15 -17
- package/dist/services/auth-socket.d.ts +25 -0
- package/dist/services/auth-socket.js +68 -23
- package/dist/services/auth-web.js +1 -1
- package/dist/services/budget-awareness.d.ts +11 -11
- package/dist/services/budget-awareness.js +15 -3
- package/dist/services/claude-local-scope-mcp.d.ts +19 -0
- package/dist/services/claude-local-scope-mcp.js +91 -0
- package/dist/services/cloud/aws.js +2 -1
- package/dist/services/cloud/lifecycle.js +19 -2
- package/dist/services/cloud/task-wrapper.d.ts +0 -9
- package/dist/services/cloud/task-wrapper.js +15 -6
- package/dist/services/event-loop-watchdog.d.ts +32 -0
- package/dist/services/event-loop-watchdog.js +140 -0
- package/dist/services/http-transport.d.ts +49 -1
- package/dist/services/http-transport.js +190 -24
- package/dist/services/in-flight-agents.d.ts +2 -0
- package/dist/services/in-flight-agents.js +4 -0
- package/dist/services/knowledge/bible-basis-filter.d.ts +53 -0
- package/dist/services/knowledge/bible-basis-filter.js +134 -0
- package/dist/services/knowledge/bible-blob-id.d.ts +44 -0
- package/dist/services/knowledge/bible-blob-id.js +113 -0
- package/dist/services/knowledge/bible-import.d.ts +65 -0
- package/dist/services/knowledge/bible-import.js +211 -0
- package/dist/services/knowledge/file-hash.d.ts +31 -0
- package/dist/services/knowledge/file-hash.js +153 -23
- package/dist/services/knowledge/http-provider.d.ts +4 -3
- package/dist/services/knowledge/http-provider.js +17 -5
- package/dist/services/knowledge/kb-maintainer-grant.d.ts +15 -0
- package/dist/services/knowledge/kb-maintainer-grant.js +34 -0
- package/dist/services/knowledge/kb-providers.d.ts +4 -0
- package/dist/services/knowledge/kb-providers.js +8 -0
- package/dist/services/knowledge/kb-removed-scope-keys.d.ts +28 -0
- package/dist/services/knowledge/kb-removed-scope-keys.js +59 -0
- package/dist/services/knowledge/kb-scopes.d.ts +14 -0
- package/dist/services/knowledge/kb-scopes.js +47 -0
- package/dist/services/knowledge/kb-self.d.ts +91 -0
- package/dist/services/knowledge/kb-self.js +198 -0
- package/dist/services/knowledge/member-bible-view.d.ts +21 -0
- package/dist/services/knowledge/member-bible-view.js +194 -0
- package/dist/services/knowledge/pre-init.js +1 -0
- package/dist/services/knowledge/project-slug.js +2 -2
- package/dist/services/knowledge/sqlite-provider.d.ts +64 -11
- package/dist/services/knowledge/sqlite-provider.js +303 -41
- package/dist/services/knowledge/types.d.ts +45 -2
- package/dist/services/member-access-secret.d.ts +70 -0
- package/dist/services/member-access-secret.js +195 -0
- package/dist/services/member-call-counts.d.ts +24 -0
- package/dist/services/member-call-counts.js +58 -0
- package/dist/services/member-config-io.d.ts +192 -0
- package/dist/services/member-config-io.js +443 -0
- package/dist/services/member-fleet-install.d.ts +710 -0
- package/dist/services/member-fleet-install.js +1895 -0
- package/dist/services/member-secret-env.d.ts +42 -0
- package/dist/services/member-secret-env.js +68 -0
- package/dist/services/member-tool-allowlist.d.ts +49 -0
- package/dist/services/member-tool-allowlist.js +111 -0
- package/dist/services/model-pricing.d.ts +19 -0
- package/dist/services/model-pricing.js +54 -8
- package/dist/services/port-holder.d.ts +86 -0
- package/dist/services/port-holder.js +351 -0
- package/dist/services/preflight-check.js +2 -0
- package/dist/services/registry.d.ts +13 -2
- package/dist/services/registry.js +27 -1
- package/dist/services/relay-strategy.d.ts +2 -0
- package/dist/services/relay-strategy.js +8 -0
- package/dist/services/server-lifecycle.d.ts +26 -0
- package/dist/services/server-lifecycle.js +85 -0
- package/dist/services/service-manager/index.d.ts +7 -1
- package/dist/services/service-manager/index.js +17 -4
- package/dist/services/service-manager/linux.d.ts +1 -1
- package/dist/services/service-manager/linux.js +15 -7
- package/dist/services/service-manager/macos.d.ts +11 -1
- package/dist/services/service-manager/macos.js +45 -7
- package/dist/services/service-manager/service-path.d.ts +24 -0
- package/dist/services/service-manager/service-path.js +55 -0
- package/dist/services/service-manager/types.d.ts +38 -3
- package/dist/services/service-manager/types.js +29 -0
- package/dist/services/service-manager/windows.d.ts +181 -2
- package/dist/services/service-manager/windows.js +666 -49
- package/dist/services/service-notice.d.ts +14 -0
- package/dist/services/service-notice.js +62 -0
- package/dist/services/service-start-guard.d.ts +20 -0
- package/dist/services/service-start-guard.js +86 -0
- package/dist/services/session-cost.d.ts +24 -0
- package/dist/services/session-cost.js +105 -0
- package/dist/services/session-mcp-config.d.ts +83 -0
- package/dist/services/session-mcp-config.js +211 -0
- package/dist/services/sftp.d.ts +34 -0
- package/dist/services/sftp.js +304 -76
- package/dist/services/shell-probe.d.ts +0 -24
- package/dist/services/shell-probe.js +28 -3
- package/dist/services/singleton.d.ts +68 -2
- package/dist/services/singleton.js +168 -11
- package/dist/services/sprint-coordination.js +9 -3
- package/dist/services/ssh.d.ts +27 -0
- package/dist/services/ssh.js +229 -38
- package/dist/services/stall/find-log-file.js +12 -5
- package/dist/services/stall/index.d.ts +1 -1
- package/dist/services/stall/read-log-tail.d.ts +23 -0
- package/dist/services/stall/read-log-tail.js +33 -2
- package/dist/services/stall/stall-detector.d.ts +25 -1
- package/dist/services/stall/stall-detector.js +85 -6
- package/dist/services/stall/stall-poller.d.ts +16 -0
- package/dist/services/stall/stall-poller.js +50 -6
- package/dist/services/stopped-marker.d.ts +16 -0
- package/dist/services/stopped-marker.js +55 -0
- package/dist/services/strategy.d.ts +33 -1
- package/dist/services/strategy.js +86 -17
- package/dist/services/supervisor-service-cleanup.d.ts +52 -0
- package/dist/services/supervisor-service-cleanup.js +332 -0
- package/dist/services/tool-registry.d.ts +8 -1
- package/dist/services/tool-registry.js +160 -59
- package/dist/services/tool-scope.d.ts +58 -0
- package/dist/services/tool-scope.js +99 -0
- package/dist/services/watch/project-resolver.js +1 -0
- package/dist/skills/auto-sprint-args/SKILL.md +2 -2
- package/dist/skills/fleet-sprint-cli/SKILL.md +39 -15
- package/dist/skills/pm/SKILL.md +3 -3
- package/dist/skills/pm/index.md +4 -2
- package/dist/skills/pm/kb-reconcile.md +29 -14
- package/dist/skills/pm/kb-review.md +1 -0
- package/dist/skills/pm/sprint.md +5 -5
- package/dist/tools/check-status.d.ts +53 -5
- package/dist/tools/check-status.js +210 -53
- package/dist/tools/child-id-allocator.d.ts +2 -2
- package/dist/tools/child-id-allocator.js +1 -1
- package/dist/tools/code-index-heal.d.ts +8 -0
- package/dist/tools/code-index-heal.js +21 -0
- package/dist/tools/code-index-state.d.ts +45 -0
- package/dist/tools/code-index-state.js +115 -0
- package/dist/tools/code-intelligence-codebase-memory.js +6 -33
- package/dist/tools/code-intelligence-freshness.js +1 -1
- package/dist/tools/code-intelligence-gitnexus.d.ts +30 -0
- package/dist/tools/code-intelligence-gitnexus.js +333 -57
- package/dist/tools/code-intelligence-kb-enrich.js +7 -6
- package/dist/tools/code-intelligence-readiness.d.ts +99 -0
- package/dist/tools/code-intelligence-readiness.js +206 -0
- package/dist/tools/code-intelligence-reindex.d.ts +195 -0
- package/dist/tools/code-intelligence-reindex.js +530 -50
- package/dist/tools/code-intelligence-telemetry.d.ts +6 -1
- package/dist/tools/code-intelligence-telemetry.js +12 -3
- package/dist/tools/code-intelligence.d.ts +81 -31
- package/dist/tools/code-intelligence.js +156 -52
- package/dist/tools/compose-permissions.d.ts +57 -2
- package/dist/tools/compose-permissions.js +497 -44
- package/dist/tools/execute-command.d.ts +11 -0
- package/dist/tools/execute-command.js +80 -12
- package/dist/tools/execute-prompt.d.ts +59 -15
- package/dist/tools/execute-prompt.js +544 -133
- package/dist/tools/kb-bible-commit.d.ts +65 -0
- package/dist/tools/kb-bible-commit.js +239 -0
- package/dist/tools/kb-capture.d.ts +13 -9
- package/dist/tools/kb-capture.js +42 -11
- package/dist/tools/kb-context.d.ts +27 -7
- package/dist/tools/kb-context.js +60 -9
- package/dist/tools/kb-export.d.ts +96 -7
- package/dist/tools/kb-export.js +228 -65
- package/dist/tools/kb-feedback.d.ts +13 -9
- package/dist/tools/kb-feedback.js +13 -7
- package/dist/tools/kb-freshness-sweep.d.ts +11 -7
- package/dist/tools/kb-freshness-sweep.js +7 -7
- package/dist/tools/kb-harvest.d.ts +11 -7
- package/dist/tools/kb-harvest.js +7 -7
- package/dist/tools/kb-import.d.ts +26 -10
- package/dist/tools/kb-import.js +169 -159
- package/dist/tools/kb-invalidate.d.ts +17 -10
- package/dist/tools/kb-invalidate.js +41 -8
- package/dist/tools/kb-list.d.ts +14 -10
- package/dist/tools/kb-list.js +30 -10
- package/dist/tools/kb-promote.d.ts +11 -7
- package/dist/tools/kb-promote.js +14 -8
- package/dist/tools/kb-query.d.ts +21 -11
- package/dist/tools/kb-query.js +76 -13
- package/dist/tools/kb-reconcile-prefilter.d.ts +11 -7
- package/dist/tools/kb-reconcile-prefilter.js +10 -8
- package/dist/tools/kb-resolve-contradiction.d.ts +11 -7
- package/dist/tools/kb-resolve-contradiction.js +7 -7
- package/dist/tools/kb-session-prime.d.ts +14 -7
- package/dist/tools/kb-session-prime.js +44 -44
- package/dist/tools/kb-setup.d.ts +11 -4
- package/dist/tools/kb-setup.js +25 -11
- package/dist/tools/kb-stats.d.ts +11 -10
- package/dist/tools/kb-stats.js +22 -41
- package/dist/tools/list-members.js +5 -2
- package/dist/tools/member-detail.d.ts +3 -0
- package/dist/tools/member-detail.js +88 -17
- package/dist/tools/member-reservation.d.ts +2 -2
- package/dist/tools/provision-auth.d.ts +39 -1
- package/dist/tools/provision-auth.js +269 -47
- package/dist/tools/provision-vcs-auth.d.ts +2 -2
- package/dist/tools/receive-files.js +3 -1
- package/dist/tools/register-member.d.ts +34 -8
- package/dist/tools/register-member.js +76 -58
- package/dist/tools/remove-member.js +110 -32
- package/dist/tools/send-email.d.ts +2 -2
- package/dist/tools/send-files.js +6 -4
- package/dist/tools/session-stats.d.ts +17 -0
- package/dist/tools/session-stats.js +27 -0
- package/dist/tools/shutdown-server.js +5 -0
- package/dist/tools/update-agent-cli.d.ts +19 -0
- package/dist/tools/update-agent-cli.js +59 -2
- package/dist/tools/update-member.d.ts +13 -10
- package/dist/tools/update-member.js +138 -7
- package/dist/tools/vcs-credential-exec.js +8 -2
- package/dist/types.d.ts +98 -1
- package/dist/utils/agent-helpers.js +2 -0
- package/dist/utils/auth-env.d.ts +15 -4
- package/dist/utils/auth-env.js +52 -23
- package/dist/utils/find-on-path.d.ts +37 -0
- package/dist/utils/find-on-path.js +85 -0
- package/dist/utils/log-helpers.d.ts +37 -0
- package/dist/utils/log-helpers.js +106 -20
- package/dist/utils/owner-only-fs.d.ts +56 -0
- package/dist/utils/owner-only-fs.js +98 -0
- package/dist/utils/process-utils.d.ts +28 -0
- package/dist/utils/process-utils.js +68 -0
- package/dist/utils/prompt-errors.js +4 -1
- package/dist/utils/session-caller.d.ts +4 -2
- package/dist/utils/session-caller.js +3 -2
- package/dist/utils/shell-escape.d.ts +42 -3
- package/dist/utils/shell-escape.js +70 -4
- package/dist/utils/ssh-error-messages.js +3 -0
- package/dist/utils/workspace-trust.d.ts +24 -1
- package/dist/utils/workspace-trust.js +21 -17
- package/dist/workflows/auto-sprint.js +223 -43
- package/package.json +11 -8
- package/packages/apra-fleet-client/package.json +2 -2
- package/packages/apra-fleet-client/src/client/api.mjs +558 -27
- package/packages/apra-fleet-client/src/client/auto-start.mjs +434 -0
- package/packages/apra-fleet-client/src/client/client.mjs +9 -0
- package/packages/apra-fleet-client/src/client/factory.mjs +23 -4
- package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +137 -0
- package/packages/apra-fleet-client/src/client/server-resolution.mjs +267 -30
- package/packages/apra-fleet-client/src/client/transport.mjs +37 -3
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +75 -27
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +37 -22
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +39 -22
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +74 -40
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +49 -40
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +40 -23
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +28 -7
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +49 -24
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +66 -43
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +101 -78
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +117 -56
- package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-output.json +1 -1
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +32 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-input.json +1 -5
- package/packages/apra-fleet-se/apra-pm/agents/schemas/planner-output.json +1 -1
- package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +41 -7
- package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +62 -3
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +3 -3
- package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +4 -2
- package/packages/apra-fleet-se/apra-pm/skills/pm/kb-reconcile.md +29 -14
- package/packages/apra-fleet-se/apra-pm/skills/pm/kb-review.md +1 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +5 -5
- package/packages/apra-fleet-se/bin/cli.mjs +184 -54
- package/packages/apra-fleet-se/bin/serve.mjs +143 -10
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +56 -20
- package/packages/apra-fleet-se/fleet-sprint/backlog-role.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +208 -53
- package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +576 -33
- package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +9 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-memory-hygiene.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +114 -7
- package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +154 -8
- package/packages/apra-fleet-se/fleet-sprint/ci-gate.mjs +353 -0
- package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +12 -0
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +60 -1
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +25 -2
- package/packages/apra-fleet-se/fleet-sprint/dispatch-accounting.mjs +270 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +22 -2
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +205 -16
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +52 -14
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +6 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/fleet-sprint-diagram.md +3 -3
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +339 -20
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +210 -11
- package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +4 -4
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +200 -9
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +57 -9
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +53 -4
- package/packages/apra-fleet-se/fleet-sprint/kb-hints.mjs +181 -0
- package/packages/apra-fleet-se/fleet-sprint/kb-injection.mjs +64 -0
- package/packages/apra-fleet-se/fleet-sprint/kb-maintainer.mjs +298 -0
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +1257 -301
- package/packages/apra-fleet-se/fleet-sprint/lower-quality.mjs +39 -0
- package/packages/apra-fleet-se/fleet-sprint/member-align.mjs +391 -0
- package/packages/apra-fleet-se/fleet-sprint/member-call.mjs +374 -0
- package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +644 -0
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +447 -0
- package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +250 -29
- package/packages/apra-fleet-se/fleet-sprint/orphan-reclaim.mjs +153 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +82 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +97 -50
- package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +1 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +81 -18
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +43 -11
- package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +6 -6
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +20 -15
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +60 -38
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +42 -10
- package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +16 -11
- package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +36 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +72 -12
- package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +259 -0
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +83 -25
- package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +19 -1
- package/packages/apra-fleet-se/fleet-sprint/runner.js +834 -142
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +24 -0
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +130 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +111 -0
- package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +44 -1
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +39 -15
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +84 -30
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +138 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +111 -11
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +22 -0
- package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +7 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +180 -14
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +134 -7
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +99 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +223 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +49 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +8 -4
- package/packages/apra-fleet-se/fleet-sprint/verify-block.mjs +152 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +235 -21
- package/packages/apra-fleet-se/package.json +2 -2
- package/packages/apra-fleet-se/src/supervisor/api.mjs +919 -0
- package/packages/apra-fleet-se/src/supervisor/backlog-member.mjs +332 -0
- package/packages/apra-fleet-se/src/supervisor/backlog.mjs +982 -0
- package/packages/apra-fleet-se/src/supervisor/beads-identity.mjs +246 -0
- package/packages/apra-fleet-se/src/supervisor/beads-view.mjs +438 -0
- package/packages/apra-fleet-se/src/supervisor/child-port.mjs +36 -0
- package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +1659 -0
- package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +350 -0
- package/packages/apra-fleet-se/src/supervisor/dolt-orphan-sweep.mjs +338 -0
- package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +279 -0
- package/packages/apra-fleet-se/src/supervisor/history-view.mjs +276 -0
- package/packages/apra-fleet-se/src/supervisor/history.mjs +328 -0
- package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +521 -0
- package/packages/apra-fleet-se/src/supervisor/launch-form.mjs +444 -0
- package/packages/apra-fleet-se/src/supervisor/ledger.mjs +629 -0
- package/packages/apra-fleet-se/src/supervisor/lib/exec-bd.mjs +303 -0
- package/packages/apra-fleet-se/src/supervisor/log-timestamp.mjs +51 -0
- package/packages/apra-fleet-se/src/supervisor/log-view.mjs +159 -0
- package/packages/apra-fleet-se/src/supervisor/proxy.mjs +474 -0
- package/packages/apra-fleet-se/src/supervisor/readopt.mjs +136 -0
- package/packages/apra-fleet-se/src/supervisor/reconcile.mjs +263 -0
- package/packages/apra-fleet-se/src/supervisor/rename-with-retry.mjs +87 -0
- package/packages/apra-fleet-se/src/supervisor/scope-overlap.mjs +327 -0
- package/packages/apra-fleet-se/src/supervisor/self-log.mjs +133 -0
- package/packages/apra-fleet-se/src/supervisor/server.mjs +399 -0
- package/packages/apra-fleet-se/src/supervisor/spawner.mjs +542 -0
- package/packages/apra-fleet-se/src/supervisor/sprint-identity.mjs +96 -0
- package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +987 -0
- package/packages/apra-fleet-workflow/package.json +1 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +64 -9
- package/packages/apra-fleet-workflow/src/viewer/run-summary.mjs +127 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +71 -5
- package/packages/apra-fleet-workflow/src/workflow/pricing.mjs +75 -25
- package/skills/fleet/permissions.md +9 -0
- package/skills/fleet/profiles/tag-kb-reconciler.json +2 -6
- package/version.json +1 -1
- package/dist/cli/agent-transform.d.ts.map +0 -1
- package/dist/cli/agent-transform.js.map +0 -1
- package/dist/cli/auth.d.ts.map +0 -1
- package/dist/cli/auth.js.map +0 -1
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/dolt-install.d.ts.map +0 -1
- package/dist/cli/dolt-install.js.map +0 -1
- package/dist/cli/install-guard.d.ts.map +0 -1
- package/dist/cli/install-guard.js.map +0 -1
- package/dist/cli/install.d.ts.map +0 -1
- package/dist/cli/install.js.map +0 -1
- package/dist/cli/join.d.ts.map +0 -1
- package/dist/cli/join.js.map +0 -1
- package/dist/cli/kb-commit.d.ts.map +0 -1
- package/dist/cli/kb-commit.js.map +0 -1
- package/dist/cli/kb-directives.d.ts.map +0 -1
- package/dist/cli/kb-directives.js.map +0 -1
- package/dist/cli/kb-import.d.ts.map +0 -1
- package/dist/cli/kb-import.js.map +0 -1
- package/dist/cli/register-member.d.ts.map +0 -1
- package/dist/cli/register-member.js.map +0 -1
- package/dist/cli/restart.d.ts.map +0 -1
- package/dist/cli/restart.js.map +0 -1
- package/dist/cli/secret.d.ts.map +0 -1
- package/dist/cli/secret.js.map +0 -1
- package/dist/cli/spoke.d.ts.map +0 -1
- package/dist/cli/spoke.js.map +0 -1
- package/dist/cli/start.d.ts.map +0 -1
- package/dist/cli/start.js.map +0 -1
- package/dist/cli/status.d.ts.map +0 -1
- package/dist/cli/status.js.map +0 -1
- package/dist/cli/stop.d.ts.map +0 -1
- package/dist/cli/stop.js.map +0 -1
- package/dist/cli/uninstall.d.ts.map +0 -1
- package/dist/cli/uninstall.js.map +0 -1
- package/dist/cli/update.d.ts.map +0 -1
- package/dist/cli/update.js.map +0 -1
- package/dist/cli/watch.d.ts.map +0 -1
- package/dist/cli/watch.js.map +0 -1
- package/dist/cli/workflow-assets.d.ts.map +0 -1
- package/dist/cli/workflow-assets.js.map +0 -1
- package/dist/cli/workflow.d.ts.map +0 -1
- package/dist/cli/workflow.js.map +0 -1
- package/dist/commands/kb-server.d.ts.map +0 -1
- package/dist/commands/kb-server.js.map +0 -1
- package/dist/delivery-mode.d.ts.map +0 -1
- package/dist/delivery-mode.js.map +0 -1
- package/dist/hub-service/activity.d.ts.map +0 -1
- package/dist/hub-service/activity.js.map +0 -1
- package/dist/hub-service/audit-log.d.ts.map +0 -1
- package/dist/hub-service/audit-log.js.map +0 -1
- package/dist/hub-service/db/pool.d.ts.map +0 -1
- package/dist/hub-service/db/pool.js.map +0 -1
- package/dist/hub-service/enrollment.d.ts.map +0 -1
- package/dist/hub-service/enrollment.js.map +0 -1
- package/dist/hub-service/envelope-routes.d.ts.map +0 -1
- package/dist/hub-service/envelope-routes.js.map +0 -1
- package/dist/hub-service/handlers/installers.d.ts.map +0 -1
- package/dist/hub-service/handlers/installers.js.map +0 -1
- package/dist/hub-service/http-server.d.ts.map +0 -1
- package/dist/hub-service/http-server.js.map +0 -1
- package/dist/hub-service/hub-jwt.d.ts.map +0 -1
- package/dist/hub-service/hub-jwt.js.map +0 -1
- package/dist/hub-service/jwt-revocation.d.ts.map +0 -1
- package/dist/hub-service/jwt-revocation.js.map +0 -1
- package/dist/hub-service/machines.d.ts.map +0 -1
- package/dist/hub-service/machines.js.map +0 -1
- package/dist/hub-service/main.d.ts.map +0 -1
- package/dist/hub-service/main.js.map +0 -1
- package/dist/hub-service/member-tokens.d.ts.map +0 -1
- package/dist/hub-service/member-tokens.js.map +0 -1
- package/dist/hub-service/member-view.d.ts.map +0 -1
- package/dist/hub-service/member-view.js.map +0 -1
- package/dist/hub-service/members.d.ts.map +0 -1
- package/dist/hub-service/members.js.map +0 -1
- package/dist/hub-service/presence.d.ts.map +0 -1
- package/dist/hub-service/presence.js.map +0 -1
- package/dist/hub-service/project-view.d.ts.map +0 -1
- package/dist/hub-service/project-view.js.map +0 -1
- package/dist/hub-service/projects.d.ts.map +0 -1
- package/dist/hub-service/projects.js.map +0 -1
- package/dist/hub-service/relay-queue.d.ts.map +0 -1
- package/dist/hub-service/relay-queue.js.map +0 -1
- package/dist/hub-service/session-jwt.d.ts.map +0 -1
- package/dist/hub-service/session-jwt.js.map +0 -1
- package/dist/hub-service/usage.d.ts.map +0 -1
- package/dist/hub-service/usage.js.map +0 -1
- package/dist/hub-service/users.d.ts.map +0 -1
- package/dist/hub-service/users.js.map +0 -1
- package/dist/hub-service/workspaces.d.ts.map +0 -1
- package/dist/hub-service/workspaces.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/onboarding/text.d.ts.map +0 -1
- package/dist/onboarding/text.js.map +0 -1
- package/dist/os/git-bash-candidates.d.ts.map +0 -1
- package/dist/os/git-bash-candidates.js.map +0 -1
- package/dist/os/index.d.ts.map +0 -1
- package/dist/os/index.js.map +0 -1
- package/dist/os/linux.d.ts.map +0 -1
- package/dist/os/linux.js.map +0 -1
- package/dist/os/macos.d.ts.map +0 -1
- package/dist/os/macos.js.map +0 -1
- package/dist/os/os-commands.d.ts.map +0 -1
- package/dist/os/os-commands.js.map +0 -1
- package/dist/os/windows-gitbash.d.ts.map +0 -1
- package/dist/os/windows-gitbash.js.map +0 -1
- package/dist/os/windows-wrapper.d.ts.map +0 -1
- package/dist/os/windows-wrapper.js.map +0 -1
- package/dist/os/windows.d.ts.map +0 -1
- package/dist/os/windows.js.map +0 -1
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/providers/agy.d.ts.map +0 -1
- package/dist/providers/agy.js.map +0 -1
- package/dist/providers/claude.d.ts.map +0 -1
- package/dist/providers/claude.js.map +0 -1
- package/dist/providers/codex.d.ts.map +0 -1
- package/dist/providers/codex.js.map +0 -1
- package/dist/providers/copilot.d.ts.map +0 -1
- package/dist/providers/copilot.js.map +0 -1
- package/dist/providers/email/headers.d.ts.map +0 -1
- package/dist/providers/email/headers.js.map +0 -1
- package/dist/providers/email/index.d.ts.map +0 -1
- package/dist/providers/email/index.js.map +0 -1
- package/dist/providers/email/provider.d.ts.map +0 -1
- package/dist/providers/email/provider.js.map +0 -1
- package/dist/providers/email/sendgrid.d.ts.map +0 -1
- package/dist/providers/email/sendgrid.js.map +0 -1
- package/dist/providers/email/smtp.d.ts.map +0 -1
- package/dist/providers/email/smtp.js.map +0 -1
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/none.d.ts.map +0 -1
- package/dist/providers/none.js.map +0 -1
- package/dist/providers/opencode.d.ts.map +0 -1
- package/dist/providers/opencode.js.map +0 -1
- package/dist/providers/provider.d.ts.map +0 -1
- package/dist/providers/provider.js.map +0 -1
- package/dist/services/agent-provisioner.d.ts.map +0 -1
- package/dist/services/agent-provisioner.js.map +0 -1
- package/dist/services/agy-project.d.ts.map +0 -1
- package/dist/services/agy-project.js.map +0 -1
- package/dist/services/auth-socket.d.ts.map +0 -1
- package/dist/services/auth-socket.js.map +0 -1
- package/dist/services/auth-web.d.ts.map +0 -1
- package/dist/services/auth-web.js.map +0 -1
- package/dist/services/budget-awareness.d.ts.map +0 -1
- package/dist/services/budget-awareness.js.map +0 -1
- package/dist/services/cloud/activity.d.ts.map +0 -1
- package/dist/services/cloud/activity.js.map +0 -1
- package/dist/services/cloud/aws.d.ts.map +0 -1
- package/dist/services/cloud/aws.js.map +0 -1
- package/dist/services/cloud/cost.d.ts.map +0 -1
- package/dist/services/cloud/cost.js.map +0 -1
- package/dist/services/cloud/idle-manager.d.ts.map +0 -1
- package/dist/services/cloud/idle-manager.js.map +0 -1
- package/dist/services/cloud/lifecycle.d.ts.map +0 -1
- package/dist/services/cloud/lifecycle.js.map +0 -1
- package/dist/services/cloud/task-wrapper.d.ts.map +0 -1
- package/dist/services/cloud/task-wrapper.js.map +0 -1
- package/dist/services/cloud/types.d.ts.map +0 -1
- package/dist/services/cloud/types.js.map +0 -1
- package/dist/services/cloud-sync.d.ts.map +0 -1
- package/dist/services/cloud-sync.js.map +0 -1
- package/dist/services/context-admission.d.ts.map +0 -1
- package/dist/services/context-admission.js.map +0 -1
- package/dist/services/credential-cleanup.d.ts.map +0 -1
- package/dist/services/credential-cleanup.js.map +0 -1
- package/dist/services/credential-store.d.ts.map +0 -1
- package/dist/services/credential-store.js.map +0 -1
- package/dist/services/event-bus.d.ts.map +0 -1
- package/dist/services/event-bus.js.map +0 -1
- package/dist/services/exit-drain.d.ts.map +0 -1
- package/dist/services/exit-drain.js.map +0 -1
- package/dist/services/file-chunker.d.ts.map +0 -1
- package/dist/services/file-chunker.js.map +0 -1
- package/dist/services/file-transfer-relay.d.ts.map +0 -1
- package/dist/services/file-transfer-relay.js.map +0 -1
- package/dist/services/file-transfer.d.ts.map +0 -1
- package/dist/services/file-transfer.js.map +0 -1
- package/dist/services/git-config.d.ts.map +0 -1
- package/dist/services/git-config.js.map +0 -1
- package/dist/services/github-app.d.ts.map +0 -1
- package/dist/services/github-app.js.map +0 -1
- package/dist/services/http-transport.d.ts.map +0 -1
- package/dist/services/http-transport.js.map +0 -1
- package/dist/services/hub-client.d.ts.map +0 -1
- package/dist/services/hub-client.js.map +0 -1
- package/dist/services/icons.d.ts.map +0 -1
- package/dist/services/icons.js.map +0 -1
- package/dist/services/jwt.d.ts.map +0 -1
- package/dist/services/jwt.js.map +0 -1
- package/dist/services/knowledge/audn.d.ts.map +0 -1
- package/dist/services/knowledge/audn.js.map +0 -1
- package/dist/services/knowledge/file-hash.d.ts.map +0 -1
- package/dist/services/knowledge/file-hash.js.map +0 -1
- package/dist/services/knowledge/http-provider.d.ts.map +0 -1
- package/dist/services/knowledge/http-provider.js.map +0 -1
- package/dist/services/knowledge/kb-config.d.ts.map +0 -1
- package/dist/services/knowledge/kb-config.js.map +0 -1
- package/dist/services/knowledge/kb-providers.d.ts.map +0 -1
- package/dist/services/knowledge/kb-providers.js.map +0 -1
- package/dist/services/knowledge/kb-scope-input.d.ts +0 -5
- package/dist/services/knowledge/kb-scope-input.d.ts.map +0 -1
- package/dist/services/knowledge/kb-scope-input.js +0 -11
- package/dist/services/knowledge/kb-scope-input.js.map +0 -1
- package/dist/services/knowledge/kb-service.d.ts.map +0 -1
- package/dist/services/knowledge/kb-service.js.map +0 -1
- package/dist/services/knowledge/path-validation.d.ts.map +0 -1
- package/dist/services/knowledge/path-validation.js.map +0 -1
- package/dist/services/knowledge/pre-init.d.ts.map +0 -1
- package/dist/services/knowledge/pre-init.js.map +0 -1
- package/dist/services/knowledge/project-slug.d.ts.map +0 -1
- package/dist/services/knowledge/project-slug.js.map +0 -1
- package/dist/services/knowledge/require-sqlite-project.d.ts.map +0 -1
- package/dist/services/knowledge/require-sqlite-project.js.map +0 -1
- package/dist/services/knowledge/sqlite-provider.d.ts.map +0 -1
- package/dist/services/knowledge/sqlite-provider.js.map +0 -1
- package/dist/services/knowledge/types.d.ts.map +0 -1
- package/dist/services/knowledge/types.js.map +0 -1
- package/dist/services/known-hosts.d.ts.map +0 -1
- package/dist/services/known-hosts.js.map +0 -1
- package/dist/services/known-sessions.d.ts.map +0 -1
- package/dist/services/known-sessions.js.map +0 -1
- package/dist/services/member-home.d.ts.map +0 -1
- package/dist/services/member-home.js.map +0 -1
- package/dist/services/member-remote-url.d.ts.map +0 -1
- package/dist/services/member-remote-url.js.map +0 -1
- package/dist/services/model-pricing.d.ts.map +0 -1
- package/dist/services/model-pricing.js.map +0 -1
- package/dist/services/onboarding.d.ts.map +0 -1
- package/dist/services/onboarding.js.map +0 -1
- package/dist/services/orphan-recovery.d.ts.map +0 -1
- package/dist/services/orphan-recovery.js.map +0 -1
- package/dist/services/pending-responses.d.ts.map +0 -1
- package/dist/services/pending-responses.js.map +0 -1
- package/dist/services/preflight-check.d.ts.map +0 -1
- package/dist/services/preflight-check.js.map +0 -1
- package/dist/services/registry.d.ts.map +0 -1
- package/dist/services/registry.js.map +0 -1
- package/dist/services/relay-context.d.ts.map +0 -1
- package/dist/services/relay-context.js.map +0 -1
- package/dist/services/relay-executor.d.ts.map +0 -1
- package/dist/services/relay-executor.js.map +0 -1
- package/dist/services/relay-request.d.ts.map +0 -1
- package/dist/services/relay-request.js.map +0 -1
- package/dist/services/relay-strategy.d.ts.map +0 -1
- package/dist/services/relay-strategy.js.map +0 -1
- package/dist/services/secret-token.d.ts.map +0 -1
- package/dist/services/secret-token.js.map +0 -1
- package/dist/services/service-manager/index.d.ts.map +0 -1
- package/dist/services/service-manager/index.js.map +0 -1
- package/dist/services/service-manager/linux.d.ts.map +0 -1
- package/dist/services/service-manager/linux.js.map +0 -1
- package/dist/services/service-manager/macos.d.ts.map +0 -1
- package/dist/services/service-manager/macos.js.map +0 -1
- package/dist/services/service-manager/types.d.ts.map +0 -1
- package/dist/services/service-manager/types.js.map +0 -1
- package/dist/services/service-manager/windows.d.ts.map +0 -1
- package/dist/services/service-manager/windows.js.map +0 -1
- package/dist/services/session-registry.d.ts.map +0 -1
- package/dist/services/session-registry.js.map +0 -1
- package/dist/services/sftp.d.ts.map +0 -1
- package/dist/services/sftp.js.map +0 -1
- package/dist/services/shell-probe.d.ts.map +0 -1
- package/dist/services/shell-probe.js.map +0 -1
- package/dist/services/singleton.d.ts.map +0 -1
- package/dist/services/singleton.js.map +0 -1
- package/dist/services/sprint-coordination.d.ts.map +0 -1
- package/dist/services/sprint-coordination.js.map +0 -1
- package/dist/services/ssh.d.ts.map +0 -1
- package/dist/services/ssh.js.map +0 -1
- package/dist/services/stall/find-log-file.d.ts.map +0 -1
- package/dist/services/stall/find-log-file.js.map +0 -1
- package/dist/services/stall/index.d.ts.map +0 -1
- package/dist/services/stall/index.js.map +0 -1
- package/dist/services/stall/log-path-resolver.d.ts.map +0 -1
- package/dist/services/stall/log-path-resolver.js.map +0 -1
- package/dist/services/stall/read-log-tail.d.ts.map +0 -1
- package/dist/services/stall/read-log-tail.js.map +0 -1
- package/dist/services/stall/stall-detector.d.ts.map +0 -1
- package/dist/services/stall/stall-detector.js.map +0 -1
- package/dist/services/stall/stall-poller.d.ts.map +0 -1
- package/dist/services/stall/stall-poller.js.map +0 -1
- package/dist/services/stall/time-utils.d.ts.map +0 -1
- package/dist/services/stall/time-utils.js.map +0 -1
- package/dist/services/statusline.d.ts.map +0 -1
- package/dist/services/statusline.js.map +0 -1
- package/dist/services/strategy.d.ts.map +0 -1
- package/dist/services/strategy.js.map +0 -1
- package/dist/services/substitution-engine.d.ts.map +0 -1
- package/dist/services/substitution-engine.js.map +0 -1
- package/dist/services/task-cleanup.d.ts.map +0 -1
- package/dist/services/task-cleanup.js.map +0 -1
- package/dist/services/token-issuer.d.ts.map +0 -1
- package/dist/services/token-issuer.js.map +0 -1
- package/dist/services/tool-registry.d.ts.map +0 -1
- package/dist/services/tool-registry.js.map +0 -1
- package/dist/services/update-check.d.ts.map +0 -1
- package/dist/services/update-check.js.map +0 -1
- package/dist/services/user-config.d.ts.map +0 -1
- package/dist/services/user-config.js.map +0 -1
- package/dist/services/vcs/azure-devops.d.ts.map +0 -1
- package/dist/services/vcs/azure-devops.js.map +0 -1
- package/dist/services/vcs/bitbucket.d.ts.map +0 -1
- package/dist/services/vcs/bitbucket.js.map +0 -1
- package/dist/services/vcs/constants.d.ts.map +0 -1
- package/dist/services/vcs/constants.js.map +0 -1
- package/dist/services/vcs/github.d.ts.map +0 -1
- package/dist/services/vcs/github.js.map +0 -1
- package/dist/services/vcs/types.d.ts.map +0 -1
- package/dist/services/vcs/types.js.map +0 -1
- package/dist/services/version-check.d.ts.map +0 -1
- package/dist/services/version-check.js.map +0 -1
- package/dist/services/watch/fleet-log.d.ts.map +0 -1
- package/dist/services/watch/fleet-log.js.map +0 -1
- package/dist/services/watch/project-resolver.d.ts.map +0 -1
- package/dist/services/watch/project-resolver.js.map +0 -1
- package/dist/services/watch/transcript-formatter.d.ts.map +0 -1
- package/dist/services/watch/transcript-formatter.js.map +0 -1
- package/dist/smoke-test.d.ts.map +0 -1
- package/dist/smoke-test.js.map +0 -1
- package/dist/tools/check-status.d.ts.map +0 -1
- package/dist/tools/check-status.js.map +0 -1
- package/dist/tools/child-id-allocator.d.ts.map +0 -1
- package/dist/tools/child-id-allocator.js.map +0 -1
- package/dist/tools/cloud-control.d.ts.map +0 -1
- package/dist/tools/cloud-control.js.map +0 -1
- package/dist/tools/code-intelligence-codebase-memory.d.ts.map +0 -1
- package/dist/tools/code-intelligence-codebase-memory.js.map +0 -1
- package/dist/tools/code-intelligence-freshness.d.ts.map +0 -1
- package/dist/tools/code-intelligence-freshness.js.map +0 -1
- package/dist/tools/code-intelligence-gitnexus.d.ts.map +0 -1
- package/dist/tools/code-intelligence-gitnexus.js.map +0 -1
- package/dist/tools/code-intelligence-kb-enrich.d.ts.map +0 -1
- package/dist/tools/code-intelligence-kb-enrich.js.map +0 -1
- package/dist/tools/code-intelligence-reindex.d.ts.map +0 -1
- package/dist/tools/code-intelligence-reindex.js.map +0 -1
- package/dist/tools/code-intelligence-telemetry.d.ts.map +0 -1
- package/dist/tools/code-intelligence-telemetry.js.map +0 -1
- package/dist/tools/code-intelligence-tests.d.ts.map +0 -1
- package/dist/tools/code-intelligence-tests.js.map +0 -1
- package/dist/tools/code-intelligence.d.ts.map +0 -1
- package/dist/tools/code-intelligence.js.map +0 -1
- package/dist/tools/compose-permissions.d.ts.map +0 -1
- package/dist/tools/compose-permissions.js.map +0 -1
- package/dist/tools/credential-store-delete.d.ts.map +0 -1
- package/dist/tools/credential-store-delete.js.map +0 -1
- package/dist/tools/credential-store-list.d.ts.map +0 -1
- package/dist/tools/credential-store-list.js.map +0 -1
- package/dist/tools/credential-store-set.d.ts.map +0 -1
- package/dist/tools/credential-store-set.js.map +0 -1
- package/dist/tools/credential-store-update.d.ts.map +0 -1
- package/dist/tools/credential-store-update.js.map +0 -1
- package/dist/tools/dolt-push-mutex.d.ts.map +0 -1
- package/dist/tools/dolt-push-mutex.js.map +0 -1
- package/dist/tools/execute-command.d.ts.map +0 -1
- package/dist/tools/execute-command.js.map +0 -1
- package/dist/tools/execute-prompt.d.ts.map +0 -1
- package/dist/tools/execute-prompt.js.map +0 -1
- package/dist/tools/get-member-model-pricing.d.ts.map +0 -1
- package/dist/tools/get-member-model-pricing.js.map +0 -1
- package/dist/tools/kb-capture.d.ts.map +0 -1
- package/dist/tools/kb-capture.js.map +0 -1
- package/dist/tools/kb-context.d.ts.map +0 -1
- package/dist/tools/kb-context.js.map +0 -1
- package/dist/tools/kb-export.d.ts.map +0 -1
- package/dist/tools/kb-export.js.map +0 -1
- package/dist/tools/kb-feedback.d.ts.map +0 -1
- package/dist/tools/kb-feedback.js.map +0 -1
- package/dist/tools/kb-freshness-sweep.d.ts.map +0 -1
- package/dist/tools/kb-freshness-sweep.js.map +0 -1
- package/dist/tools/kb-harvest.d.ts.map +0 -1
- package/dist/tools/kb-harvest.js.map +0 -1
- package/dist/tools/kb-import.d.ts.map +0 -1
- package/dist/tools/kb-import.js.map +0 -1
- package/dist/tools/kb-invalidate.d.ts.map +0 -1
- package/dist/tools/kb-invalidate.js.map +0 -1
- package/dist/tools/kb-list.d.ts.map +0 -1
- package/dist/tools/kb-list.js.map +0 -1
- package/dist/tools/kb-promote.d.ts.map +0 -1
- package/dist/tools/kb-promote.js.map +0 -1
- package/dist/tools/kb-query.d.ts.map +0 -1
- package/dist/tools/kb-query.js.map +0 -1
- package/dist/tools/kb-reconcile-prefilter.d.ts.map +0 -1
- package/dist/tools/kb-reconcile-prefilter.js.map +0 -1
- package/dist/tools/kb-resolve-contradiction.d.ts.map +0 -1
- package/dist/tools/kb-resolve-contradiction.js.map +0 -1
- package/dist/tools/kb-session-prime.d.ts.map +0 -1
- package/dist/tools/kb-session-prime.js.map +0 -1
- package/dist/tools/kb-setup.d.ts.map +0 -1
- package/dist/tools/kb-setup.js.map +0 -1
- package/dist/tools/kb-stats.d.ts.map +0 -1
- package/dist/tools/kb-stats.js.map +0 -1
- package/dist/tools/list-members.d.ts.map +0 -1
- package/dist/tools/list-members.js.map +0 -1
- package/dist/tools/member-detail.d.ts.map +0 -1
- package/dist/tools/member-detail.js.map +0 -1
- package/dist/tools/member-reservation.d.ts.map +0 -1
- package/dist/tools/member-reservation.js.map +0 -1
- package/dist/tools/monitor-task.d.ts.map +0 -1
- package/dist/tools/monitor-task.js.map +0 -1
- package/dist/tools/provision-auth.d.ts.map +0 -1
- package/dist/tools/provision-auth.js.map +0 -1
- package/dist/tools/provision-vcs-auth.d.ts.map +0 -1
- package/dist/tools/provision-vcs-auth.js.map +0 -1
- package/dist/tools/receive-files.d.ts.map +0 -1
- package/dist/tools/receive-files.js.map +0 -1
- package/dist/tools/register-member.d.ts.map +0 -1
- package/dist/tools/register-member.js.map +0 -1
- package/dist/tools/remove-member.d.ts.map +0 -1
- package/dist/tools/remove-member.js.map +0 -1
- package/dist/tools/report-status.d.ts.map +0 -1
- package/dist/tools/report-status.js.map +0 -1
- package/dist/tools/respond-to-message.d.ts.map +0 -1
- package/dist/tools/respond-to-message.js.map +0 -1
- package/dist/tools/revoke-vcs-auth.d.ts.map +0 -1
- package/dist/tools/revoke-vcs-auth.js.map +0 -1
- package/dist/tools/send-email.d.ts.map +0 -1
- package/dist/tools/send-email.js.map +0 -1
- package/dist/tools/send-files.d.ts.map +0 -1
- package/dist/tools/send-files.js.map +0 -1
- package/dist/tools/send-message.d.ts.map +0 -1
- package/dist/tools/send-message.js.map +0 -1
- package/dist/tools/setup-git-app.d.ts.map +0 -1
- package/dist/tools/setup-git-app.js.map +0 -1
- package/dist/tools/setup-ssh-key.d.ts.map +0 -1
- package/dist/tools/setup-ssh-key.js.map +0 -1
- package/dist/tools/shutdown-server.d.ts.map +0 -1
- package/dist/tools/shutdown-server.js.map +0 -1
- package/dist/tools/stop-prompt.d.ts.map +0 -1
- package/dist/tools/stop-prompt.js.map +0 -1
- package/dist/tools/update-agent-cli.d.ts.map +0 -1
- package/dist/tools/update-agent-cli.js.map +0 -1
- package/dist/tools/update-member.d.ts.map +0 -1
- package/dist/tools/update-member.js.map +0 -1
- package/dist/tools/vcs-credential-exec.d.ts.map +0 -1
- package/dist/tools/vcs-credential-exec.js.map +0 -1
- package/dist/tools/version.d.ts.map +0 -1
- package/dist/tools/version.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/agent-helpers.d.ts.map +0 -1
- package/dist/utils/agent-helpers.js.map +0 -1
- package/dist/utils/ansi.d.ts.map +0 -1
- package/dist/utils/ansi.js.map +0 -1
- package/dist/utils/auth-env.d.ts.map +0 -1
- package/dist/utils/auth-env.js.map +0 -1
- package/dist/utils/collect-secret.d.ts.map +0 -1
- package/dist/utils/collect-secret.js.map +0 -1
- package/dist/utils/credential-validation.d.ts.map +0 -1
- package/dist/utils/credential-validation.js.map +0 -1
- package/dist/utils/crypto.d.ts.map +0 -1
- package/dist/utils/crypto.js.map +0 -1
- package/dist/utils/deep-merge.d.ts.map +0 -1
- package/dist/utils/deep-merge.js.map +0 -1
- package/dist/utils/file-permissions.d.ts.map +0 -1
- package/dist/utils/file-permissions.js.map +0 -1
- package/dist/utils/gpu-parser.d.ts.map +0 -1
- package/dist/utils/gpu-parser.js.map +0 -1
- package/dist/utils/log-helpers.d.ts.map +0 -1
- package/dist/utils/log-helpers.js.map +0 -1
- package/dist/utils/oob-timeout.d.ts.map +0 -1
- package/dist/utils/oob-timeout.js.map +0 -1
- package/dist/utils/opencode-model-validation.d.ts.map +0 -1
- package/dist/utils/opencode-model-validation.js.map +0 -1
- package/dist/utils/pid-helpers.d.ts.map +0 -1
- package/dist/utils/pid-helpers.js.map +0 -1
- package/dist/utils/platform.d.ts.map +0 -1
- package/dist/utils/platform.js.map +0 -1
- package/dist/utils/process-utils.d.ts.map +0 -1
- package/dist/utils/process-utils.js.map +0 -1
- package/dist/utils/prompt-errors.d.ts.map +0 -1
- package/dist/utils/prompt-errors.js.map +0 -1
- package/dist/utils/resolve-member.d.ts.map +0 -1
- package/dist/utils/resolve-member.js.map +0 -1
- package/dist/utils/secure-input.d.ts.map +0 -1
- package/dist/utils/secure-input.js.map +0 -1
- package/dist/utils/session-caller.d.ts.map +0 -1
- package/dist/utils/session-caller.js.map +0 -1
- package/dist/utils/shell-escape.d.ts.map +0 -1
- package/dist/utils/shell-escape.js.map +0 -1
- package/dist/utils/skill-matrix.d.ts.map +0 -1
- package/dist/utils/skill-matrix.js.map +0 -1
- package/dist/utils/ssh-error-messages.d.ts.map +0 -1
- package/dist/utils/ssh-error-messages.js.map +0 -1
- package/dist/utils/vcs-provider-detect.d.ts.map +0 -1
- package/dist/utils/vcs-provider-detect.js.map +0 -1
- package/dist/utils/work-folder-validation.d.ts.map +0 -1
- package/dist/utils/work-folder-validation.js.map +0 -1
- package/dist/utils/workspace-trust.d.ts.map +0 -1
- package/dist/utils/workspace-trust.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { escapePowerShellArgInner } from '../utils/shell-escape.js';
|
|
1
2
|
import fs from 'node:fs';
|
|
2
3
|
import os from 'node:os';
|
|
3
4
|
import path from 'node:path';
|
|
@@ -11,13 +12,14 @@ import { getAgentOS, getAgentShell, touchAgent, getStoredPid, isPosixShellMember
|
|
|
11
12
|
import { updateAgent } from '../services/registry.js';
|
|
12
13
|
import { memberIdentifier, resolveMember } from '../utils/resolve-member.js';
|
|
13
14
|
import { isRetryable, authErrorAdvice, workspaceNotTrustedAdvice } from '../utils/prompt-errors.js';
|
|
14
|
-
import {
|
|
15
|
+
import { stageAuthEnv, removeMemberSecretFile, SecretDeliveryError } from '../services/member-secret-env.js';
|
|
15
16
|
import { writeStatusline } from '../services/statusline.js';
|
|
16
17
|
import { getModelOverride } from '../services/user-config.js';
|
|
17
18
|
import { ensureCloudReady } from '../services/cloud/lifecycle.js';
|
|
18
19
|
import { getStallDetector, resolveSessionLogPath } from '../services/stall/index.js';
|
|
19
20
|
import { getCachedMemberPathContext } from '../services/member-home.js';
|
|
20
21
|
import { provisionAgents, remoteAgentsDir, loadCanonicalAgentSet } from '../services/agent-provisioner.js';
|
|
22
|
+
import { ensureNoProjectAgentShadows } from '../services/agent-shadow.js';
|
|
21
23
|
import { escapeWindowsArg, escapeDoubleQuoted } from '../os/os-commands.js';
|
|
22
24
|
import { resolveTilde } from './execute-command.js';
|
|
23
25
|
import { clearStoredPid } from '../utils/agent-helpers.js';
|
|
@@ -34,17 +36,34 @@ import { getTokenIssuer } from '../services/token-issuer.js';
|
|
|
34
36
|
import { resolveExpectedDemand, checkContextAdmission, recordSessionUsage } from '../services/context-admission.js';
|
|
35
37
|
import { recordKnownSession, isKnownSession } from '../services/known-sessions.js';
|
|
36
38
|
import { resolveBudgetScope, evaluateBudget, recordAndEvaluate } from '../services/budget-awareness.js';
|
|
39
|
+
import { dispatchCostFromCumulative } from '../services/session-cost.js';
|
|
37
40
|
import { sendMessage } from './send-message.js';
|
|
41
|
+
import { serverVersion } from '../version.js';
|
|
38
42
|
import { registerPending } from '../services/pending-responses.js';
|
|
43
|
+
import { inFlightAgents } from '../services/in-flight-agents.js';
|
|
39
44
|
import { isMaxTurnsResponse } from '../providers/provider.js';
|
|
40
45
|
import { preflightCheck } from '../services/preflight-check.js';
|
|
41
46
|
import { ensureAgyProject } from '../services/agy-project.js';
|
|
47
|
+
import { sessionMcpInjectionAvailable, sessionMcpConfigPath, sessionMcpConfigIsPerDispatch, writeSessionMcpConfig, resolveSessionMcpAlwaysLoad } from '../services/session-mcp-config.js';
|
|
48
|
+
export function toStructuredUsage(u) {
|
|
49
|
+
return {
|
|
50
|
+
input_tokens: u.input_tokens,
|
|
51
|
+
output_tokens: u.output_tokens,
|
|
52
|
+
cache_read_input_tokens: u.cache_read_input_tokens ?? 0,
|
|
53
|
+
cache_creation_input_tokens: u.cache_creation_input_tokens ?? 0,
|
|
54
|
+
total_tokens: u.input_tokens + u.output_tokens,
|
|
55
|
+
...(typeof u.cost_usd === 'number' ? { cost_usd: u.cost_usd } : {}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Failure classes that win over a permission denial carried in the same
|
|
59
|
+
* result: the caller acts on these (resume, re-provision, retry later). */
|
|
60
|
+
const TYPED_FAILURE_CATEGORIES = new Set(['auth', 'server', 'overloaded', 'workspace_not_trusted', 'max_turns']);
|
|
42
61
|
export const executePromptSchema = z.object({
|
|
43
62
|
...memberIdentifier,
|
|
44
63
|
prompt: z.string().describe('The prompt to send to the LLM on the remote member'),
|
|
45
64
|
session_id: z.string().optional().describe('Shorthand for explicit session resume. Equivalent to resume: "<session_id>". If provided, takes precedence over resume.'),
|
|
46
65
|
resume: z.union([z.boolean(), z.string()]).default(true).describe('Session-resume control (default: true). ' +
|
|
47
|
-
'true = best-effort resume of the member\'s stored last session (a stale/unknown stored session transparently falls back to a fresh session). ' +
|
|
66
|
+
'true = best-effort resume of the member\'s stored last session (a stale/unknown stored session, or one recorded by a different server build, transparently falls back to a fresh session). ' +
|
|
48
67
|
'false = always start a fresh session. ' +
|
|
49
68
|
'A session-id STRING = EXPLICIT resume of exactly that session, preferred over the member\'s stored session -- the caller asserts this prompt depends on that session\'s prior context, so an unknown/expired id is a TERMINAL error ' +
|
|
50
69
|
'(structured {isError, reason: "session_not_found"}, NO LLM call, and NO fresh-session fallback) rather than a silent wrong-context dispatch.'),
|
|
@@ -58,8 +77,9 @@ export const executePromptSchema = z.object({
|
|
|
58
77
|
'call. NOTE: this field only covers the schema + the mutual-exclusivity guard; actual fork ' +
|
|
59
78
|
'MODE RESOLUTION (minting/wiring the forked session) is implemented separately.'),
|
|
60
79
|
timeout_s: z.number().default(300).describe('Inactivity timeout in seconds -- always drives the stall detector\'s per-dispatch baseline threshold, measured against the member\'s own session transcript activity (default: 300s / 5 minutes). Omitting it yields a 300s baseline, a deliberate change from the previously silent 150s stall-detector default. Per-provider, it ALSO arms the exec-level rolling timer against this dispatch\'s stdout/stderr channel for Codex and Copilot, which have no pollable transcript; Claude and AGY take that exec-channel ceiling from max_total_s instead; and OpenCode keeps BOTH signals armed at once (this exec-channel timer plus coarse log-directory-mtime polling, combined with OR semantics -- either advancing counts as not-stalled), since its transcript signal is directory-level only, not a per-turn file (see ProviderAdapter.execTimeoutSource()).'),
|
|
61
|
-
max_total_s: z.number().optional().describe('Hard ceiling in seconds -- the command is killed after this total elapsed time regardless of activity. If omitted, there is no total time limit.'),
|
|
80
|
+
max_total_s: z.number().optional().describe('Hard ceiling in seconds, measured from the moment the call is received (setup such as member readiness and preflight counts) -- the command is killed after this total elapsed time regardless of activity and the call returns reason max_total_time. If omitted, there is no total time limit.'),
|
|
62
81
|
max_turns: z.number().min(1).max(500).optional().describe('Max turns for claude -p (default: 50)'),
|
|
82
|
+
fail_on_permission_denial: z.boolean().optional().describe('Strict permission handling (default: false). true = a tool call the member CLI refused fails the dispatch with reason "permission_denied" and a permissionDenied block (suggestedGrants to heal it with compose_permissions), even when the reply looks complete -- except a Claude refusal with healable:false (auto/bypass mode: safety classifier or deny rule) on a complete reply, which is only a permissionWarning. Omitted/false = each provider keeps its earlier behaviour: a complete Claude reply is a success carrying the refusals in permissionWarning; AGY refusals still fail permission_denied. Either way a max_turns / auth / server / overloaded result keeps its own reason, with the refusals attached as permissionDenied.'),
|
|
63
83
|
model: z.string().optional().describe('Model tier ("cheap", "standard", "premium") or a specific model ID for power users. Prefer tier names -- the server resolves them to the correct model per provider. If omitted, defaults to the standard tier. Applies to both new and resumed sessions.'),
|
|
64
84
|
substitutions: z.record(z.string(), z.string()).optional().describe('Optional map of token name to replacement value. ' +
|
|
65
85
|
'When provided, every occurrence of {{name}} in the prompt is replaced before the prompt is staged on the member. ' +
|
|
@@ -120,6 +140,41 @@ ${output}`;
|
|
|
120
140
|
// timeout_s -- is deliberately NOT taken: that is the exact coupling this
|
|
121
141
|
// removes, and for these providers timeout_s belongs to the StallDetector.
|
|
122
142
|
const EXEC_TIMER_NEVER_BINDS_MS = 86_400_000;
|
|
143
|
+
const FAILURE_STDERR_TAIL_CHARS = 2000;
|
|
144
|
+
const FAILURE_STDERR_TAIL_LINES = 20;
|
|
145
|
+
const FAILURE_EVENT_CHARS = 1000;
|
|
146
|
+
/**
|
|
147
|
+
* GitHub #585: the diagnostic payload logged when execute_prompt's dispatch
|
|
148
|
+
* exits non-zero -- the TAIL of stderr (the end is where CLIs print the
|
|
149
|
+
* fatal error), capped by lines and characters, plus the last JSON
|
|
150
|
+
* result/error event on stdout, capped. Redaction happens in logLine.
|
|
151
|
+
*/
|
|
152
|
+
export function formatPromptFailureTail(result) {
|
|
153
|
+
let stderrTail = (result.stderr ?? '').trimEnd();
|
|
154
|
+
const lines = stderrTail.split('\n');
|
|
155
|
+
if (lines.length > FAILURE_STDERR_TAIL_LINES)
|
|
156
|
+
stderrTail = lines.slice(-FAILURE_STDERR_TAIL_LINES).join('\n');
|
|
157
|
+
if (stderrTail.length > FAILURE_STDERR_TAIL_CHARS)
|
|
158
|
+
stderrTail = stderrTail.slice(-FAILURE_STDERR_TAIL_CHARS);
|
|
159
|
+
let lastEvent;
|
|
160
|
+
const outLines = (result.stdout ?? '').split('\n');
|
|
161
|
+
for (let i = outLines.length - 1; i >= 0 && lastEvent === undefined; i--) {
|
|
162
|
+
const line = outLines[i].trim();
|
|
163
|
+
if (!line.startsWith('{'))
|
|
164
|
+
continue;
|
|
165
|
+
try {
|
|
166
|
+
const ev = JSON.parse(line);
|
|
167
|
+
if (ev.type === 'result' || ev.type === 'error' || ev.is_error === true || ev.error !== undefined) {
|
|
168
|
+
lastEvent = line.length > FAILURE_EVENT_CHARS ? line.slice(0, FAILURE_EVENT_CHARS) + '...[truncated]' : line;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch { /* not a JSON event line */ }
|
|
172
|
+
}
|
|
173
|
+
return JSON.stringify({ exit: result.code, stderrTail, ...(lastEvent !== undefined ? { lastEvent } : {}) });
|
|
174
|
+
}
|
|
175
|
+
/** GitHub #563: max_total_s time held back from every attempt for prompt-file
|
|
176
|
+
* cleanup and the response (see cleanupReserveMs in executePrompt). */
|
|
177
|
+
export const EXECUTE_PROMPT_CLEANUP_RESERVE_MS = 5000;
|
|
123
178
|
const SERVER_RETRY_DELAY_MS = 5000;
|
|
124
179
|
// A prompt written whole into a single remote exec command line can exceed
|
|
125
180
|
// the SSH exec channel's / Windows CreateProcess's command-line ceiling once
|
|
@@ -165,7 +220,7 @@ async function writePromptFile(agent, strategy, promptFilePath, content) {
|
|
|
165
220
|
for (let i = 0; i < chunks.length; i++) {
|
|
166
221
|
const setup = i === 0 ? `New-Item -Path '${escapedFolder}' -ItemType Directory -Force | Out-Null; ` : '';
|
|
167
222
|
const cmdlet = i === 0 ? 'Set-Content' : 'Add-Content';
|
|
168
|
-
const psScript = `${setup}Set-Location "${escapedFolder}"; ${cmdlet} -Path "${promptFileName}" -Value '${chunks[i]
|
|
223
|
+
const psScript = `${setup}Set-Location "${escapedFolder}"; ${cmdlet} -Path "${promptFileName}" -Value '${escapePowerShellArgInner(chunks[i])}' -NoNewline -Encoding UTF8`;
|
|
169
224
|
const encoded = Buffer.from(psScript, 'utf16le').toString('base64');
|
|
170
225
|
// eslint-disable-next-line no-await-in-loop -- each chunk must land before the next appends
|
|
171
226
|
await strategy.execCommand(`powershell -EncodedCommand ${encoded}`);
|
|
@@ -199,12 +254,16 @@ async function deletePromptFile(agent, strategy, promptFilePath, extraPaths = []
|
|
|
199
254
|
const promptFileName = path.basename(promptFilePath);
|
|
200
255
|
const remoteDir = path.dirname(promptFilePath);
|
|
201
256
|
// apra-fleet-7dir.5.4: gitbash members take the POSIX branch, matching
|
|
202
|
-
// writePromptFile above --
|
|
203
|
-
//
|
|
204
|
-
//
|
|
257
|
+
// writePromptFile above -- the durable stdout mirror in `extraPaths` lives
|
|
258
|
+
// at a POSIX /tmp path PowerShell would resolve to a different directory
|
|
259
|
+
// entirely.
|
|
205
260
|
if (!isPosixShellMember(agent)) {
|
|
206
261
|
const escapedFolder = escapeWindowsArg(remoteDir);
|
|
207
|
-
|
|
262
|
+
// extraPaths here are only staged credential files (absolute member
|
|
263
|
+
// paths); PowerShell members have no durable stdout mirror.
|
|
264
|
+
// Removed first, by absolute path, independent of the work folder.
|
|
265
|
+
const extras = extraPaths.map(p => `Remove-Item -LiteralPath '${escapePowerShellArgInner(p)}' -Force -ErrorAction SilentlyContinue; `).join('');
|
|
266
|
+
const psScript = `${extras}Set-Location "${escapedFolder}"; Remove-Item "${promptFileName}" -Force -ErrorAction SilentlyContinue`;
|
|
208
267
|
const encoded = Buffer.from(psScript, 'utf16le').toString('base64');
|
|
209
268
|
await strategy.execCommand(`powershell -EncodedCommand ${encoded}`).catch(() => { });
|
|
210
269
|
}
|
|
@@ -213,7 +272,10 @@ async function deletePromptFile(agent, strategy, promptFilePath, extraPaths = []
|
|
|
213
272
|
// apra-fleet-6z8.1: the durable stdout mirror is cleaned up in the SAME
|
|
214
273
|
// round trip as the prompt file -- no extra exec per dispatch.
|
|
215
274
|
const extras = extraPaths.map(p => ` "${escapeDoubleQuoted(p)}"`).join('');
|
|
216
|
-
|
|
275
|
+
// extraPaths are absolute (durable mirror, staged credential files): removed
|
|
276
|
+
// unconditionally, even when the work folder is gone and the cd fails.
|
|
277
|
+
const extrasRm = extras ? `rm -f${extras}; ` : '';
|
|
278
|
+
await strategy.execCommand(`${extrasRm}cd "${escapedFolder}" && rm -f ${promptFileName}`).catch(() => { });
|
|
217
279
|
}
|
|
218
280
|
}
|
|
219
281
|
export function resolveModelForTier(agent, tier, provider) {
|
|
@@ -235,7 +297,7 @@ export { knownRepoRemoteUrl };
|
|
|
235
297
|
/**
|
|
236
298
|
* The sprint id this server process dispatches on behalf of, or undefined when
|
|
237
299
|
* run outside a sprint (e.g. a manual cli.mjs invocation). Sourced from
|
|
238
|
-
* APRA_FLEET_SPRINT_ID, which the
|
|
300
|
+
* APRA_FLEET_SPRINT_ID, which the fleet-sprint spawner stamps into the per-sprint
|
|
239
301
|
* server's environment (apra-fleet-eft.10.3). Read on every dispatch so a
|
|
240
302
|
* reservation set/cleared mid-run is observed without a restart.
|
|
241
303
|
*/
|
|
@@ -246,7 +308,7 @@ export function currentSprintId() {
|
|
|
246
308
|
const trimmed = raw.trim();
|
|
247
309
|
return trimmed.length > 0 ? trimmed : undefined;
|
|
248
310
|
}
|
|
249
|
-
export
|
|
311
|
+
export { inFlightAgents };
|
|
250
312
|
// Member ids whose remote agent files (planner.md, doer.md, _shared/, schemas/, ...)
|
|
251
313
|
// have already been probed/refreshed this server process uptime -- the #336
|
|
252
314
|
// provisioner is a real SSH round trip, so we pay that cost once per member per
|
|
@@ -452,6 +514,10 @@ async function executePromptInteractive(agent, renderedPrompt, input, workspaceI
|
|
|
452
514
|
}
|
|
453
515
|
}
|
|
454
516
|
export async function executePrompt(input, extra) {
|
|
517
|
+
// GitHub #563: max_total_s is measured from HERE, handler entry -- cloud
|
|
518
|
+
// readiness, preflight and agent provisioning are all charged to it, since
|
|
519
|
+
// the client's own deadline (max_total_s + a fixed grace) starts at the call.
|
|
520
|
+
const handlerStartedAt = Date.now();
|
|
455
521
|
if (hasSecretToken(input.prompt)) {
|
|
456
522
|
return 'error: execute_prompt prompt contains {{secret.NAME}} token. Secrets must never be passed to LLM prompts. Use execute_command with {{secret.NAME}} instead.';
|
|
457
523
|
}
|
|
@@ -518,7 +584,31 @@ export async function executePrompt(input, extra) {
|
|
|
518
584
|
return agentOrError;
|
|
519
585
|
let agent;
|
|
520
586
|
try {
|
|
521
|
-
|
|
587
|
+
// GitHub #563 review: a cold cloud start can take minutes. Bound it by the
|
|
588
|
+
// max_total_s budget (minus the cleanup reserve) so a slow start returns
|
|
589
|
+
// the typed max_total_time error before the client's own deadline. The
|
|
590
|
+
// start itself keeps going in the background; the next call finds the
|
|
591
|
+
// instance running.
|
|
592
|
+
const cloudBudgetMs = input.max_total_s !== undefined
|
|
593
|
+
? Math.max(0, input.max_total_s * 1000 - Math.min(EXECUTE_PROMPT_CLEANUP_RESERVE_MS, Math.floor(input.max_total_s * 100)) - (Date.now() - handlerStartedAt))
|
|
594
|
+
: undefined;
|
|
595
|
+
const ready = ensureCloudReady(agentOrError); // auto-start if stopped
|
|
596
|
+
if (cloudBudgetMs === undefined) {
|
|
597
|
+
agent = await ready;
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
let budgetTimer;
|
|
601
|
+
const outOfBudget = new Promise((resolve) => { budgetTimer = setTimeout(() => resolve(null), cloudBudgetMs); });
|
|
602
|
+
const raced = await Promise.race([ready, outOfBudget]).finally(() => clearTimeout(budgetTimer));
|
|
603
|
+
if (raced === null) {
|
|
604
|
+
ready.catch(() => { });
|
|
605
|
+
return {
|
|
606
|
+
text: `[FAIL] execute_prompt on "${agentOrError.friendlyName}" exceeded max_total_s (${input.max_total_s}s) while waiting for the cloud member to start -- the start continues in the background; retry shortly.`,
|
|
607
|
+
structuredContent: { isError: true, reason: 'max_total_time', dispatched: false },
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
agent = raced;
|
|
611
|
+
}
|
|
522
612
|
}
|
|
523
613
|
catch (err) {
|
|
524
614
|
return `[FAIL] Failed to execute prompt on "${agentOrError.friendlyName}": ${err.message}`;
|
|
@@ -671,8 +761,8 @@ export async function executePrompt(input, extra) {
|
|
|
671
761
|
// practice, but that is a fact about what each provider adapter currently
|
|
672
762
|
// advertises, not a name-based pre-filter here -- any provider that
|
|
673
763
|
// implements the same MCP channel capability is picked up automatically. A
|
|
674
|
-
// member CAN still have a live sessionRegistry entry (
|
|
675
|
-
// gives it basic MCP tool access
|
|
764
|
+
// member CAN still have a live sessionRegistry entry (its per-folder
|
|
765
|
+
// apra-fleet MCP entry gives it basic MCP tool access) without that meaning
|
|
676
766
|
// it can receive or act on this push -- routing to it anyway would silently
|
|
677
767
|
// spend the full timeout_s waiting for a response that can never arrive.
|
|
678
768
|
// R2-F3: re-query session registry after the preflight await (10-20s) so
|
|
@@ -742,6 +832,14 @@ export async function executePrompt(input, extra) {
|
|
|
742
832
|
deadScope.info(`member claude process (pid ${interactivePid}) for "${agent.friendlyName}" is dead -- evicting the stale interactive session and re-dispatching fresh (non-interactive)`);
|
|
743
833
|
interactiveSession = undefined;
|
|
744
834
|
}
|
|
835
|
+
// Project-level <workFolder>/.claude/agents files take precedence over the
|
|
836
|
+
// user-level role set; quarantine untracked shadows, report tracked ones on
|
|
837
|
+
// every dispatch. Runs before the interactive/subprocess split so both paths
|
|
838
|
+
// are covered, local members included. Independent of the user-level
|
|
839
|
+
// provisioning below (compares against the canonical set). Never throws.
|
|
840
|
+
const shadowWarning = await ensureNoProjectAgentShadows(agent);
|
|
841
|
+
if (shadowWarning)
|
|
842
|
+
heuristicWarningSuffix += `\n\n[WARN] ${shadowWarning}`;
|
|
745
843
|
if (interactiveSession?.server) {
|
|
746
844
|
// Lock already claimed above, before the preflight await -- do not
|
|
747
845
|
// re-add here (Set.add would be a harmless no-op, but keeping a second
|
|
@@ -779,6 +877,9 @@ export async function executePrompt(input, extra) {
|
|
|
779
877
|
await ensureAgentFilesProvisioned(agent);
|
|
780
878
|
const stallDetector = getStallDetector();
|
|
781
879
|
let clearedByStall = false;
|
|
880
|
+
// GitHub #562: which stall fired -- a frozen transcript, or a session log
|
|
881
|
+
// that never appeared at its authoritative path (the agent never started).
|
|
882
|
+
let stallReason = 'stalled';
|
|
782
883
|
// apra-fleet-3c9.1: a CONFIRMED stall must not only kill the remote pid but
|
|
783
884
|
// also cancel the in-flight strategy.execCommand() promise. Before this, the
|
|
784
885
|
// client kept waiting out its full deriveTimeoutMs deadline after the
|
|
@@ -805,7 +906,8 @@ export async function executePrompt(input, extra) {
|
|
|
805
906
|
provisional: true,
|
|
806
907
|
stallReported: false,
|
|
807
908
|
thresholdMs: stallThresholdMs,
|
|
808
|
-
onStall: () => {
|
|
909
|
+
onStall: (reason) => {
|
|
910
|
+
stallReason = reason ?? 'stalled';
|
|
809
911
|
// Stall detector already wrote 'unknown' to the statusline before calling here.
|
|
810
912
|
// Our job: clear in-process state so the member can accept new calls.
|
|
811
913
|
// clearedByStall prevents the eventually-resolving finally block from clobbering
|
|
@@ -838,7 +940,6 @@ export async function executePrompt(input, extra) {
|
|
|
838
940
|
const strategy = getStrategy(agent);
|
|
839
941
|
const cmds = getOsCommands(getAgentOS(agent), getAgentShell(agent));
|
|
840
942
|
const provider = getProvider(agent.llmProvider);
|
|
841
|
-
const authPrefix = buildAuthEnvPrefix(agent, getAgentOS(agent));
|
|
842
943
|
const tiers = provider.modelTiers();
|
|
843
944
|
let resolvedModel = input.model || 'standard';
|
|
844
945
|
let resolvedTier;
|
|
@@ -903,7 +1004,17 @@ export async function executePrompt(input, extra) {
|
|
|
903
1004
|
// fresh session: that is exactly the wrong-context dispatch this feature
|
|
904
1005
|
// forbids. resume=true/false and fork=true keep their transparent recovery.
|
|
905
1006
|
const allowFreshSessionFallback = explicitResumeId === undefined && explicitForkId === undefined;
|
|
906
|
-
|
|
1007
|
+
// A DEFAULT resume (resume=true) of a stored session recorded under another
|
|
1008
|
+
// server build -- or before builds were stamped -- starts fresh: that
|
|
1009
|
+
// session's transcript lists tools/MCP config this build no longer serves,
|
|
1010
|
+
// and resuming it can end with no tool run yet a "successful" reply.
|
|
1011
|
+
// Explicit-id resumes are the caller's assertion and are left alone.
|
|
1012
|
+
const staleBuildSession = input.resume === true && explicitResumeId === undefined && !forkRequested
|
|
1013
|
+
&& !!agent.sessionId && agent.sessionServerVersion !== serverVersion;
|
|
1014
|
+
if (staleBuildSession) {
|
|
1015
|
+
logWarn('execute_prompt', `"${agent.friendlyName}": stored session "${agent.sessionId}" was recorded by server build ${agent.sessionServerVersion ?? '(unrecorded, older build)'}, this server is ${serverVersion} -- starting a fresh session instead of resuming it`, agent);
|
|
1016
|
+
}
|
|
1017
|
+
const resuming = !!(resumeRequested && resumeTargetId && provider.supportsResume()) && !staleBuildSession;
|
|
907
1018
|
const isCallerMinted = provider.sessionIdStrategy().type === 'caller-minted';
|
|
908
1019
|
const mintedId = isCallerMinted
|
|
909
1020
|
? (resuming ? resumeTargetId : uuid())
|
|
@@ -996,6 +1107,14 @@ export async function executePrompt(input, extra) {
|
|
|
996
1107
|
const forkDescriptor = forkActive && forkSourceId
|
|
997
1108
|
? { sourceSessionId: forkSourceId, newSessionId: mintedId ?? uuid() }
|
|
998
1109
|
: undefined;
|
|
1110
|
+
// Per-session member MCP config (Claude --mcp-config): the dispatched
|
|
1111
|
+
// session gets the ?member=<uuid> apra-fleet server whatever the folder or
|
|
1112
|
+
// user config says. Path resolved here so every retry (freshOpts spreads
|
|
1113
|
+
// promptOpts) carries it; the file is written with the prompt file below,
|
|
1114
|
+
// and a failed write clears it (fallback: the session's own MCP config).
|
|
1115
|
+
const sessionMcpPath = sessionMcpInjectionAvailable(agent)
|
|
1116
|
+
? sessionMcpConfigPath(agent, resolvedWorkFolder)
|
|
1117
|
+
: undefined;
|
|
999
1118
|
const promptOpts = {
|
|
1000
1119
|
folder: resolvedWorkFolder,
|
|
1001
1120
|
promptFile: promptFileName,
|
|
@@ -1009,6 +1128,7 @@ export async function executePrompt(input, extra) {
|
|
|
1009
1128
|
agentName: input.agent,
|
|
1010
1129
|
fork: forkDescriptor,
|
|
1011
1130
|
projectId: agyProjectId,
|
|
1131
|
+
...(sessionMcpPath ? { mcpConfigPath: sessionMcpPath } : {}),
|
|
1012
1132
|
};
|
|
1013
1133
|
// apra-fleet issue #390: session log paths live on the MEMBER's machine, under
|
|
1014
1134
|
// the MEMBER's home directory, joined with the MEMBER's OS convention. Before
|
|
@@ -1033,13 +1153,36 @@ export async function executePrompt(input, extra) {
|
|
|
1033
1153
|
resolvedLogPath = null;
|
|
1034
1154
|
}
|
|
1035
1155
|
}
|
|
1156
|
+
// GitHub #562: a path built from a local or probed home is authoritative --
|
|
1157
|
+
// if it never appears, the agent never started. A username-convention guess
|
|
1158
|
+
// is not, and a missing file there stays a warning.
|
|
1159
|
+
// Known causes of a transcript landing somewhere else make the path a
|
|
1160
|
+
// guess too: a relocated Claude config dir (CLAUDE_CONFIG_DIR, in this
|
|
1161
|
+
// process for a local member or in the member's configured env vars), or a
|
|
1162
|
+
// local POSIX work folder reached through a symlink (the CLI names the
|
|
1163
|
+
// project dir after the physical cwd).
|
|
1164
|
+
const claudeConfigRelocated = (agent.llmProvider ?? 'claude') === 'claude' && (Object.keys(agent.encryptedEnvVars ?? {}).includes('CLAUDE_CONFIG_DIR')
|
|
1165
|
+
|| (agent.agentType === 'local' && !!process.env.CLAUDE_CONFIG_DIR));
|
|
1166
|
+
let localCwdIsSymlinked = false;
|
|
1167
|
+
if (agent.agentType === 'local' && process.platform !== 'win32') {
|
|
1168
|
+
try {
|
|
1169
|
+
const real = fs.realpathSync(resolvedWorkFolder);
|
|
1170
|
+
localCwdIsSymlinked = real.replace(/\/+$/, '') !== path.resolve(resolvedWorkFolder).replace(/\/+$/, '');
|
|
1171
|
+
}
|
|
1172
|
+
catch {
|
|
1173
|
+
localCwdIsSymlinked = true; // cannot resolve -> not authoritative
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
const logPathAuthoritative = (memberPathCtx.source === 'local' || memberPathCtx.source === 'probe')
|
|
1177
|
+
&& !claudeConfigRelocated && !localCwdIsSymlinked;
|
|
1036
1178
|
stallDetector.update(agent.id, {
|
|
1037
1179
|
sessionId: activePreSpawnSid,
|
|
1038
1180
|
logFilePath: resolvedLogPath,
|
|
1039
1181
|
provisional: !resolvedLogPath,
|
|
1040
1182
|
thresholdMs: stallThresholdMs,
|
|
1183
|
+
logPathAuthoritative: !!resolvedLogPath && logPathAuthoritative,
|
|
1041
1184
|
});
|
|
1042
|
-
|
|
1185
|
+
let claudeCmd = cmds.buildAgentPromptCommand(provider, promptOpts);
|
|
1043
1186
|
// apra-fleet-6z8.1: the per-invocation durable stdout mirror the unix prompt
|
|
1044
1187
|
// wrapper tees to (see durableOutputPath / buildAgentPromptCommand). A
|
|
1045
1188
|
// PowerShell Windows member has no such companion tee, so recovery is
|
|
@@ -1064,8 +1207,17 @@ export async function executePrompt(input, extra) {
|
|
|
1064
1207
|
const durableMirrorSupported = getAgentOS(agent) !== 'windows'
|
|
1065
1208
|
|| (getAgentShell(agent) === 'gitbash' && agent.agentType !== 'local');
|
|
1066
1209
|
const durablePath = durableMirrorSupported ? durableOutputPath(scope.getInv()) : undefined;
|
|
1067
|
-
|
|
1210
|
+
// GitHub #563: the shared deadline is anchored at handler entry, not here --
|
|
1211
|
+
// setup awaits above (cloud readiness, preflight, provisioning) count.
|
|
1212
|
+
const dispatchStartedAt = handlerStartedAt;
|
|
1068
1213
|
const maxTotalMs = input.max_total_s !== undefined ? input.max_total_s * 1000 : undefined;
|
|
1214
|
+
// Time kept back from every attempt's budget for the finally-block prompt
|
|
1215
|
+
// file cleanup and the response, so the whole call settles inside
|
|
1216
|
+
// max_total_s and well within the client's max_total_s + grace window.
|
|
1217
|
+
// Fixed 5s, capped at 10% of a very small max_total_s.
|
|
1218
|
+
const cleanupReserveMs = maxTotalMs !== undefined
|
|
1219
|
+
? Math.min(EXECUTE_PROMPT_CLEANUP_RESERVE_MS, Math.floor(maxTotalMs / 10))
|
|
1220
|
+
: 0;
|
|
1069
1221
|
// apra-fleet-25yl.2.1: the exec-level ROLLING (inactivity) deadline handed to
|
|
1070
1222
|
// strategy.execCommand() is no longer provider-blind. It used to be
|
|
1071
1223
|
// `timeout_s` for everyone, which is a false kill for the batch-only
|
|
@@ -1112,7 +1264,7 @@ export async function executePrompt(input, extra) {
|
|
|
1112
1264
|
function retryBudget() {
|
|
1113
1265
|
if (maxTotalMs === undefined)
|
|
1114
1266
|
return { timeoutMs, maxTotalMs: undefined, exhausted: false };
|
|
1115
|
-
const remaining = Math.max(0, maxTotalMs - (Date.now() - dispatchStartedAt));
|
|
1267
|
+
const remaining = Math.max(0, maxTotalMs - cleanupReserveMs - (Date.now() - dispatchStartedAt));
|
|
1116
1268
|
return { timeoutMs: Math.min(timeoutMs, remaining), maxTotalMs: remaining, exhausted: remaining <= 0 };
|
|
1117
1269
|
}
|
|
1118
1270
|
// Agent file validation -- verify named agent exists before any CLI invocation
|
|
@@ -1215,10 +1367,64 @@ export async function executePrompt(input, extra) {
|
|
|
1215
1367
|
};
|
|
1216
1368
|
}
|
|
1217
1369
|
}
|
|
1218
|
-
//
|
|
1219
|
-
|
|
1220
|
-
//
|
|
1221
|
-
|
|
1370
|
+
// Stage the first attempt's credential file BEFORE touching the member
|
|
1371
|
+
// (kill, prompt write, dispatch). A delivery failure (relay member, SFTP
|
|
1372
|
+
// subsystem disabled) is deterministic: a typed failure, never retried.
|
|
1373
|
+
const stagedEnvPaths = [];
|
|
1374
|
+
/** Per-dispatch session MCP config files to remove with the prompt file. */
|
|
1375
|
+
const sessionMcpCleanup = [];
|
|
1376
|
+
let preStaged;
|
|
1377
|
+
try {
|
|
1378
|
+
preStaged = await stageAuthEnv(agent);
|
|
1379
|
+
}
|
|
1380
|
+
catch (err) {
|
|
1381
|
+
if (!(err instanceof SecretDeliveryError))
|
|
1382
|
+
throw err;
|
|
1383
|
+
scope.abort(`secret delivery unavailable (no LLM call)`);
|
|
1384
|
+
inFlightAgents.delete(agent.id);
|
|
1385
|
+
stallDetector.remove(agent.id);
|
|
1386
|
+
writeStatusline(new Map([[agent.id, 'idle']]));
|
|
1387
|
+
return {
|
|
1388
|
+
text: `[FAIL] execute_prompt on "${agent.friendlyName}" rejected -- ${err.message} No LLM call was made.`,
|
|
1389
|
+
structuredContent: { isError: true, reason: 'secret_delivery_unavailable' },
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
if (preStaged.path)
|
|
1393
|
+
stagedEnvPaths.push(preStaged.path);
|
|
1394
|
+
try {
|
|
1395
|
+
// Kill any leftover session from a previous (possibly zombie) execute_prompt call
|
|
1396
|
+
await tryKillPid(agent, strategy, cmds);
|
|
1397
|
+
// Write the rendered prompt (with substitutions applied) to the prompt file before execution
|
|
1398
|
+
await writePromptFile(agent, strategy, promptFilePath, renderedPrompt);
|
|
1399
|
+
}
|
|
1400
|
+
catch (err) {
|
|
1401
|
+
if (preStaged.path)
|
|
1402
|
+
await removeMemberSecretFile(agent, preStaged.path);
|
|
1403
|
+
throw err;
|
|
1404
|
+
}
|
|
1405
|
+
if (sessionMcpPath) {
|
|
1406
|
+
const memberExec = (cmd, t) => strategy.execCommand(cmd, t);
|
|
1407
|
+
// Non-deferral of the member's kb_*/code_* tools (Claude: alwaysLoad in
|
|
1408
|
+
// the session config). When it cannot be applied the config is still
|
|
1409
|
+
// attached, the tools stay deferred, and the cause is logged.
|
|
1410
|
+
const loadPolicy = await resolveSessionMcpAlwaysLoad(agent, provider.mcpAlwaysLoadMinVersion?.(), cmds.agentVersion(provider), memberExec);
|
|
1411
|
+
if (loadPolicy.warning)
|
|
1412
|
+
scope.warn(`session MCP config: ${loadPolicy.warning}`);
|
|
1413
|
+
const wrote = await writeSessionMcpConfig(agent, sessionMcpPath, memberExec, { alwaysLoad: loadPolicy.alwaysLoad });
|
|
1414
|
+
if (wrote.ok) {
|
|
1415
|
+
if (sessionMcpConfigIsPerDispatch(agent))
|
|
1416
|
+
sessionMcpCleanup.push(sessionMcpPath);
|
|
1417
|
+
}
|
|
1418
|
+
else {
|
|
1419
|
+
// Fallback, never zero: dispatch without the flag; the session then
|
|
1420
|
+
// uses the per-folder / user-scope apra-fleet entry it would have had.
|
|
1421
|
+
scope.warn(`session MCP config not written (${wrote.detail}); dispatching without --mcp-config`);
|
|
1422
|
+
delete promptOpts.mcpConfigPath;
|
|
1423
|
+
claudeCmd = cmds.buildAgentPromptCommand(provider, promptOpts);
|
|
1424
|
+
if (sessionMcpConfigIsPerDispatch(agent))
|
|
1425
|
+
sessionMcpCleanup.push(sessionMcpPath);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1222
1428
|
// apra-fleet-6z8.1: remembered for the lease-of-life gate below -- the pid
|
|
1223
1429
|
// outlives the SSH channel that reported it, and is the only way to tell a
|
|
1224
1430
|
// fabricated "exit 0 / empty" close apart from a real one.
|
|
@@ -1239,6 +1445,7 @@ export async function executePrompt(input, extra) {
|
|
|
1239
1445
|
logFilePath: logPath,
|
|
1240
1446
|
provisional: !logPath,
|
|
1241
1447
|
thresholdMs: stallThresholdMs,
|
|
1448
|
+
logPathAuthoritative: !!logPath && logPathAuthoritative,
|
|
1242
1449
|
});
|
|
1243
1450
|
}
|
|
1244
1451
|
};
|
|
@@ -1255,12 +1462,74 @@ export async function executePrompt(input, extra) {
|
|
|
1255
1462
|
const dispatchSignal = extra?.signal
|
|
1256
1463
|
? AbortSignal.any([extra.signal, stallAbortController.signal])
|
|
1257
1464
|
: stallAbortController.signal;
|
|
1465
|
+
// GitHub #563 review: when the inactivity window is as long as the attempt's
|
|
1466
|
+
// remaining max_total_s budget (timeout_s >= max_total_s -- every
|
|
1467
|
+
// fleet-sprint dispatch, and Claude's total-ceiling mode), both timers come
|
|
1468
|
+
// due together and the inactivity one, armed first, wins the tie. That
|
|
1469
|
+
// kill IS the max_total_s ceiling, so it is classified as max_total_time.
|
|
1470
|
+
let lastAttempt;
|
|
1471
|
+
// Stored auth env vars reach the CLI through a per-attempt owner-only file
|
|
1472
|
+
// the command loads and deletes (stageAuthEnv) -- never as inline values in
|
|
1473
|
+
// the command line, which would sit in the member shell's argv (readable
|
|
1474
|
+
// via ps) for the whole dispatch. Each attempt stages its own file because
|
|
1475
|
+
// the prefix deletes it once loaded; any file a failed attempt left behind
|
|
1476
|
+
// is removed with the prompt file at the end.
|
|
1477
|
+
// The first attempt uses the file staged before dispatch (preStaged).
|
|
1478
|
+
// The session whose saved cost total the last dispatched invocation started
|
|
1479
|
+
// from: the resumed session (or a fork's source) for the original command,
|
|
1480
|
+
// nothing for every fresh-session retry. Read by parseDispatch below.
|
|
1481
|
+
// Compared against the UNPREFIXED cmd: the auth-env prefix is added here,
|
|
1482
|
+
// per attempt, so it never affects the resume-cost-delta decision.
|
|
1483
|
+
let lastAttemptContinues;
|
|
1484
|
+
const dispatchAttempt = async (cmd, attemptTimeoutMs, attemptMaxTotalMs) => {
|
|
1485
|
+
lastAttempt = { timeoutMs: attemptTimeoutMs, maxTotalMs: attemptMaxTotalMs };
|
|
1486
|
+
lastAttemptContinues = cmd === claudeCmd
|
|
1487
|
+
? (forkDescriptor ? forkDescriptor.sourceSessionId : (resuming ? resumeTargetId : undefined))
|
|
1488
|
+
: undefined;
|
|
1489
|
+
let staged = preStaged;
|
|
1490
|
+
preStaged = undefined;
|
|
1491
|
+
if (!staged) {
|
|
1492
|
+
staged = await stageAuthEnv(agent);
|
|
1493
|
+
if (staged.path)
|
|
1494
|
+
stagedEnvPaths.push(staged.path);
|
|
1495
|
+
}
|
|
1496
|
+
return strategy.execCommand(staged.prefix + cmd, attemptTimeoutMs, attemptMaxTotalMs, onPidCaptured, dispatchSignal);
|
|
1497
|
+
};
|
|
1498
|
+
const isMaxTotalKill = (err) => {
|
|
1499
|
+
const msg = err?.message;
|
|
1500
|
+
if (maxTotalMs === undefined || typeof msg !== 'string')
|
|
1501
|
+
return false;
|
|
1502
|
+
if (/exceeded max total time/i.test(msg))
|
|
1503
|
+
return true;
|
|
1504
|
+
return /of inactivity/i.test(msg) && lastAttempt?.maxTotalMs !== undefined
|
|
1505
|
+
&& lastAttempt.timeoutMs >= lastAttempt.maxTotalMs;
|
|
1506
|
+
};
|
|
1258
1507
|
// Mark agent as busy in statusline
|
|
1259
1508
|
writeStatusline(new Map([[agent.id, 'busy']]));
|
|
1260
1509
|
let _epExitCode = 'error';
|
|
1261
1510
|
let _epError;
|
|
1262
1511
|
let _epUsage;
|
|
1263
1512
|
let _epOffline = false;
|
|
1513
|
+
// The last session id a provider parse produced. Typed failures that follow a
|
|
1514
|
+
// parse (max_turns_exhausted, empty_response, dispatch_failed) carry it so an
|
|
1515
|
+
// explicit-id resume of that exact session passes isKnownSession.
|
|
1516
|
+
let _epParsedSid;
|
|
1517
|
+
const sessionIdField = (sid) => {
|
|
1518
|
+
if (!sid)
|
|
1519
|
+
return {};
|
|
1520
|
+
recordKnownSession(agent.id, sid);
|
|
1521
|
+
return { sessionId: sid };
|
|
1522
|
+
};
|
|
1523
|
+
// GitHub #563: the typed result for a dispatch that ran out of max_total_s
|
|
1524
|
+
// (measured from handler entry), so callers never see a raw transport timeout.
|
|
1525
|
+
// dispatched=false: the budget ran out before anything was sent to the
|
|
1526
|
+
// member, so callers can skip publishing work that cannot exist.
|
|
1527
|
+
const maxTotalTimeResult = (dispatched = true) => ({
|
|
1528
|
+
text: dispatched
|
|
1529
|
+
? `[FAIL] execute_prompt on "${agent.friendlyName}" exceeded max_total_s (${input.max_total_s}s, measured from the call, including setup) -- the dispatch was stopped.`
|
|
1530
|
+
: `[FAIL] execute_prompt on "${agent.friendlyName}" exceeded max_total_s (${input.max_total_s}s, measured from the call) during setup -- nothing was dispatched.`,
|
|
1531
|
+
structuredContent: { isError: true, reason: 'max_total_time', ...(dispatched ? {} : { dispatched: false }) },
|
|
1532
|
+
});
|
|
1264
1533
|
// apra-fleet-6a7.1: gates the exit-0/empty-stdout workspace_not_trusted
|
|
1265
1534
|
// self-heal-and-retry below to exactly one attempt per call, mirroring
|
|
1266
1535
|
// runGitStep's authHealAttempted shape (fleet-sprint/runner.js:616) -- a
|
|
@@ -1276,7 +1545,126 @@ export async function executePrompt(input, extra) {
|
|
|
1276
1545
|
// since a 0-exit result event whose text carries the limit message must not
|
|
1277
1546
|
// be returned as a success response either.
|
|
1278
1547
|
// The member's OS reaches the parser (agy's permission-denial hint differs on Windows).
|
|
1279
|
-
|
|
1548
|
+
// unattended + model let the provider tell which permission mode the
|
|
1549
|
+
// session ran in (Claude: a denial in auto mode is never healable).
|
|
1550
|
+
const parseCtx = { agentOs: agent.os, unattended: agent.unattended, model: resolvedModel };
|
|
1551
|
+
// Session-id assertion: the returned id must match the one we minted/resumed.
|
|
1552
|
+
// apra-fleet-lmtg.5: a fork now gets the SAME assertion as any other
|
|
1553
|
+
// caller-minted session. mintedId is explicitly passed to the CLI as
|
|
1554
|
+
// --session-id even in fork mode (provider.forkFlag/buildForkFlag), and the
|
|
1555
|
+
// CLI honors it -- so it is no longer a placeholder the CLI silently
|
|
1556
|
+
// discards, and a genuine mismatch is a real signal worth catching rather
|
|
1557
|
+
// than something to exempt. Shared by the success path and the
|
|
1558
|
+
// permission_denied early return so the two cannot drift apart.
|
|
1559
|
+
const sessionExpectation = (p) => {
|
|
1560
|
+
const expectedSid = resuming ? resumeTargetId : (isCallerMinted ? mintedId : undefined);
|
|
1561
|
+
return { expectedSid, isMismatch: !!(expectedSid && p.sessionId && p.sessionId !== expectedSid) };
|
|
1562
|
+
};
|
|
1563
|
+
// A mismatch on an EXPLICIT resume/fork with no fresh-session fallback is
|
|
1564
|
+
// terminal: the caller asked for that exact session and did not get it.
|
|
1565
|
+
const mismatchIsTerminal = () => !allowFreshSessionFallback && (explicitResumeId !== undefined || explicitForkId !== undefined);
|
|
1566
|
+
// The terminal session_not_found failure for such a mismatch, with the
|
|
1567
|
+
// returned session's usage still recorded. `extra` rides on structuredContent
|
|
1568
|
+
// (the permission_denied path attaches its denial).
|
|
1569
|
+
const terminalMismatchFailure = async (p, expectedSid, extra = {}) => {
|
|
1570
|
+
inFlightAgents.delete(agent.id);
|
|
1571
|
+
stallDetector.remove(agent.id);
|
|
1572
|
+
writeStatusline(new Map([[agent.id, 'idle']]));
|
|
1573
|
+
clearStoredPid(agent.id);
|
|
1574
|
+
if (p.sessionId) {
|
|
1575
|
+
recordKnownSession(agent.id, p.sessionId);
|
|
1576
|
+
}
|
|
1577
|
+
if (p.usage) {
|
|
1578
|
+
const prev = agent.tokenUsage ?? { input: 0, output: 0 };
|
|
1579
|
+
updateAgent(agent.id, {
|
|
1580
|
+
tokenUsage: {
|
|
1581
|
+
input: prev.input + p.usage.input_tokens,
|
|
1582
|
+
output: prev.output + p.usage.output_tokens,
|
|
1583
|
+
},
|
|
1584
|
+
});
|
|
1585
|
+
recordSessionUsage(p.sessionId ?? expectedSid, p.usage);
|
|
1586
|
+
if (budgetScope) {
|
|
1587
|
+
await recordAndEvaluate({ scope: budgetScope, agent, provider, tier: resolvedTier, usage: p.usage });
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
return {
|
|
1591
|
+
text: `[FAIL] execute_prompt on "${agent.friendlyName}" failed -- resumed session mismatch. Expected session "${expectedSid}", but provider returned "${p.sessionId}".`,
|
|
1592
|
+
structuredContent: {
|
|
1593
|
+
isError: true,
|
|
1594
|
+
reason: 'session_not_found',
|
|
1595
|
+
sessionId: expectedSid,
|
|
1596
|
+
returnedSessionId: p.sessionId,
|
|
1597
|
+
...(p.usage ? { usage: toStructuredUsage(p.usage) } : {}),
|
|
1598
|
+
...extra,
|
|
1599
|
+
},
|
|
1600
|
+
};
|
|
1601
|
+
};
|
|
1602
|
+
// apra-fleet-eft.78.1: mark the session this dispatch actually landed on as
|
|
1603
|
+
// known/resumable for this member (so a later explicit-id resume of it passes
|
|
1604
|
+
// the terminal session_not_found gate), and hand the stall detector the
|
|
1605
|
+
// session's real log path.
|
|
1606
|
+
const recordLandedSession = (finalSid) => {
|
|
1607
|
+
if (!finalSid)
|
|
1608
|
+
return;
|
|
1609
|
+
recordKnownSession(agent.id, finalSid);
|
|
1610
|
+
let postLogPath = null;
|
|
1611
|
+
try {
|
|
1612
|
+
postLogPath = resolveSessionLogPath(agent.llmProvider ?? 'claude', finalSid, resolvedWorkFolder, memberPathCtx.homeDir, memberPathCtx.targetOs);
|
|
1613
|
+
}
|
|
1614
|
+
catch {
|
|
1615
|
+
postLogPath = null;
|
|
1616
|
+
}
|
|
1617
|
+
stallDetector.update(agent.id, {
|
|
1618
|
+
sessionId: finalSid,
|
|
1619
|
+
logFilePath: postLogPath,
|
|
1620
|
+
provisional: !postLogPath,
|
|
1621
|
+
thresholdMs: stallThresholdMs,
|
|
1622
|
+
logPathAuthoritative: !!postLogPath && logPathAuthoritative,
|
|
1623
|
+
});
|
|
1624
|
+
};
|
|
1625
|
+
// The session/usage/budget/PID bookkeeping a dispatch that RAN gets, for an
|
|
1626
|
+
// early return that is not the success path (permission_denied): the
|
|
1627
|
+
// member's stored session advances (a mismatched id is not persisted, as on
|
|
1628
|
+
// the success path) so a later resume continues this turn, the stall
|
|
1629
|
+
// detector learns the landed session, the spend reaches the member total,
|
|
1630
|
+
// the session total and the budget, and the stored PID is cleared. Same
|
|
1631
|
+
// order and side effects as the success path.
|
|
1632
|
+
const recordDispatchBookkeeping = async (p, expectation = sessionExpectation(p)) => {
|
|
1633
|
+
const { expectedSid, isMismatch } = expectation;
|
|
1634
|
+
if (isMismatch)
|
|
1635
|
+
touchAgent(agent.id, undefined);
|
|
1636
|
+
else
|
|
1637
|
+
touchAgent(agent.id, p.sessionId ?? expectedSid);
|
|
1638
|
+
recordLandedSession(p.sessionId ?? expectedSid);
|
|
1639
|
+
clearStoredPid(agent.id);
|
|
1640
|
+
if (p.usage) {
|
|
1641
|
+
const prev = agent.tokenUsage ?? { input: 0, output: 0 };
|
|
1642
|
+
updateAgent(agent.id, {
|
|
1643
|
+
tokenUsage: { input: prev.input + p.usage.input_tokens, output: prev.output + p.usage.output_tokens },
|
|
1644
|
+
});
|
|
1645
|
+
recordSessionUsage(p.sessionId ?? mintedId, p.usage);
|
|
1646
|
+
if (budgetScope)
|
|
1647
|
+
await recordAndEvaluate({ scope: budgetScope, agent, provider, tier: resolvedTier, usage: p.usage });
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
// Every provider.parseResponse in the dispatch path goes through this, so
|
|
1651
|
+
// a provider-reported cumulative session cost (Claude total_cost_usd) is
|
|
1652
|
+
// turned into THIS dispatch's cost exactly once per invocation, on every
|
|
1653
|
+
// path (success and failure alike), and the session's baseline advances.
|
|
1654
|
+
// The per-dispatch figure rides on usage.cost_usd; when the baseline of a
|
|
1655
|
+
// continued session is unknown it is left off and cost consumers price the
|
|
1656
|
+
// token counts instead.
|
|
1657
|
+
const parseDispatch = (r) => {
|
|
1658
|
+
const p = provider.parseResponse(r, parseCtx);
|
|
1659
|
+
_epParsedSid = p.sessionId;
|
|
1660
|
+
if (typeof p.sessionCostUsd === 'number') {
|
|
1661
|
+
const landedOn = p.sessionId ?? (lastAttemptContinues && !forkDescriptor ? lastAttemptContinues : undefined);
|
|
1662
|
+
const cost = dispatchCostFromCumulative(p.sessionCostUsd, landedOn, lastAttemptContinues);
|
|
1663
|
+
if (cost !== undefined && p.usage)
|
|
1664
|
+
p.usage = { ...p.usage, cost_usd: cost };
|
|
1665
|
+
}
|
|
1666
|
+
return p;
|
|
1667
|
+
};
|
|
1280
1668
|
const checkUsageLimit = (r, p) => {
|
|
1281
1669
|
const signal = provider.detectUsageLimit(r, p);
|
|
1282
1670
|
if (!signal)
|
|
@@ -1300,15 +1688,24 @@ export async function executePrompt(input, extra) {
|
|
|
1300
1688
|
reason: 'usage_limit',
|
|
1301
1689
|
usageLimit: signal,
|
|
1302
1690
|
...(p.sessionId ? { sessionId: p.sessionId } : {}),
|
|
1303
|
-
...(p.usage ? { usage:
|
|
1691
|
+
...(p.usage ? { usage: toStructuredUsage(p.usage) } : {}),
|
|
1304
1692
|
},
|
|
1305
1693
|
};
|
|
1306
1694
|
};
|
|
1307
1695
|
claimGuardActive = false;
|
|
1308
1696
|
try {
|
|
1309
1697
|
let result;
|
|
1698
|
+
// GitHub #563: the FIRST attempt is capped by the same shared budget as
|
|
1699
|
+
// any retry (max_total_s since handler entry, minus the cleanup reserve),
|
|
1700
|
+
// not handed a fresh full max_total_s after setup already spent some.
|
|
1701
|
+
const firstBudget = retryBudget();
|
|
1702
|
+
if (firstBudget.exhausted) {
|
|
1703
|
+
_epExitCode = 'error';
|
|
1704
|
+
_epError = 'max_total_s exhausted before dispatch';
|
|
1705
|
+
return maxTotalTimeResult(false);
|
|
1706
|
+
}
|
|
1310
1707
|
try {
|
|
1311
|
-
result = await
|
|
1708
|
+
result = await dispatchAttempt(claudeCmd, firstBudget.timeoutMs, firstBudget.maxTotalMs);
|
|
1312
1709
|
}
|
|
1313
1710
|
catch (dispatchErr) {
|
|
1314
1711
|
// apra-fleet-02s.1: a genuine command-execution exception (e.g. an
|
|
@@ -1344,10 +1741,10 @@ export async function executePrompt(input, extra) {
|
|
|
1344
1741
|
scope.info(`[${resolvedModel}] retrying -- dispatch exception: ${dispatchErr.message}`);
|
|
1345
1742
|
await tryKillPid(agent, strategy, cmds);
|
|
1346
1743
|
const freshOpts = { ...promptOpts, sessionId: isCallerMinted ? uuid() : undefined, resuming: false, fork: undefined };
|
|
1347
|
-
const retryCmd =
|
|
1348
|
-
result = await
|
|
1744
|
+
const retryCmd = cmds.buildAgentPromptCommand(provider, freshOpts);
|
|
1745
|
+
result = await dispatchAttempt(retryCmd, budget.timeoutMs, budget.maxTotalMs);
|
|
1349
1746
|
}
|
|
1350
|
-
let parsed =
|
|
1747
|
+
let parsed = parseDispatch(result);
|
|
1351
1748
|
if (parsed.usage)
|
|
1352
1749
|
_epUsage = parsed.usage;
|
|
1353
1750
|
{
|
|
@@ -1366,7 +1763,8 @@ export async function executePrompt(input, extra) {
|
|
|
1366
1763
|
if (result.code !== 0 && provider.classifyError(result.stderr || result.stdout) === 'workspace_not_trusted') {
|
|
1367
1764
|
return {
|
|
1368
1765
|
text: `[FAIL] ${workspaceNotTrustedAdvice(agent.friendlyName)}\n${result.stderr || result.stdout}`,
|
|
1369
|
-
|
|
1766
|
+
// A typed failure keeps its own reason; an incidental refusal rides along.
|
|
1767
|
+
structuredContent: { isError: true, reason: 'workspace_not_trusted', ...(parsed.permissionDenial ? { permissionDenied: parsed.permissionDenial } : {}) },
|
|
1370
1768
|
};
|
|
1371
1769
|
}
|
|
1372
1770
|
// Stale session retry -- fresh session ID, no resume. apra-fleet-eft.78.1:
|
|
@@ -1388,9 +1786,9 @@ export async function executePrompt(input, extra) {
|
|
|
1388
1786
|
scope.info(`[${resolvedModel}] retrying -- stale session`);
|
|
1389
1787
|
await tryKillPid(agent, strategy, cmds);
|
|
1390
1788
|
const freshOpts = { ...promptOpts, sessionId: isCallerMinted ? uuid() : undefined, resuming: false, fork: undefined };
|
|
1391
|
-
const retryCmd =
|
|
1392
|
-
result = await
|
|
1393
|
-
parsed =
|
|
1789
|
+
const retryCmd = cmds.buildAgentPromptCommand(provider, freshOpts);
|
|
1790
|
+
result = await dispatchAttempt(retryCmd, staleBudget.timeoutMs, staleBudget.maxTotalMs);
|
|
1791
|
+
parsed = parseDispatch(result);
|
|
1394
1792
|
if (parsed.usage)
|
|
1395
1793
|
_epUsage = parsed.usage;
|
|
1396
1794
|
const usageLimitResult = checkUsageLimit(result, parsed);
|
|
@@ -1410,9 +1808,9 @@ export async function executePrompt(input, extra) {
|
|
|
1410
1808
|
await tryKillPid(agent, strategy, cmds);
|
|
1411
1809
|
await new Promise(r => setTimeout(r, SERVER_RETRY_DELAY_MS));
|
|
1412
1810
|
const freshOpts = { ...promptOpts, sessionId: isCallerMinted ? uuid() : undefined, resuming: false, fork: undefined };
|
|
1413
|
-
const retryCmd =
|
|
1414
|
-
result = await
|
|
1415
|
-
parsed =
|
|
1811
|
+
const retryCmd = cmds.buildAgentPromptCommand(provider, freshOpts);
|
|
1812
|
+
result = await dispatchAttempt(retryCmd, overloadBudget.timeoutMs, overloadBudget.maxTotalMs);
|
|
1813
|
+
parsed = parseDispatch(result);
|
|
1416
1814
|
if (parsed.usage)
|
|
1417
1815
|
_epUsage = parsed.usage;
|
|
1418
1816
|
const usageLimitResult = checkUsageLimit(result, parsed);
|
|
@@ -1421,27 +1819,76 @@ export async function executePrompt(input, extra) {
|
|
|
1421
1819
|
}
|
|
1422
1820
|
}
|
|
1423
1821
|
_epExitCode = result.code;
|
|
1424
|
-
//
|
|
1425
|
-
//
|
|
1426
|
-
//
|
|
1427
|
-
//
|
|
1428
|
-
//
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1822
|
+
// Permission refusals (parsed.permissionDenial). Order matters:
|
|
1823
|
+
//
|
|
1824
|
+
// 1. A TYPED failure is classified first and wins: a max_turns-terminated
|
|
1825
|
+
// turn, or a nonzero exit the provider classifies as auth / server /
|
|
1826
|
+
// overloaded / workspace_not_trusted. Its reason is what a caller acts
|
|
1827
|
+
// on (fleet-sprint resumes a max_turns turn, re-provisions on auth);
|
|
1828
|
+
// an incidental refusal inside such a turn rides along as an extra
|
|
1829
|
+
// `permissionDenied` field and never turns it into permission_denied.
|
|
1830
|
+
//
|
|
1831
|
+
// 2. Otherwise the caller's choice decides. `fail_on_permission_denial`
|
|
1832
|
+
// (fleet-sprint passes it) makes any refusal a `permission_denied`
|
|
1833
|
+
// failure the caller can heal with compose_permissions -- except a
|
|
1834
|
+
// denial the provider marks healable:false (Claude auto/bypass mode:
|
|
1835
|
+
// safety classifier or deny rule) on a complete reply, which is only a
|
|
1836
|
+
// warning. Without the flag each provider keeps its v0.4.3 semantics:
|
|
1837
|
+
// Claude's reply stands (a complete reply is a success carrying the
|
|
1838
|
+
// refusals as `permissionWarning`; an incomplete one gets its ordinary
|
|
1839
|
+
// classification with the denial attached), while AGY -- whose headless
|
|
1840
|
+
// denials exit 0 with an empty reply -- still fails permission_denied.
|
|
1841
|
+
const denial = parsed.permissionDenial;
|
|
1842
|
+
const strictDenials = input.fail_on_permission_denial === true || provider.name !== 'claude';
|
|
1843
|
+
const typedFailure = isMaxTurnsResponse(parsed)
|
|
1844
|
+
|| (result.code !== 0 && TYPED_FAILURE_CATEGORIES.has(provider.classifyError(result.stderr || result.stdout)));
|
|
1845
|
+
const replyComplete = result.code === 0 && !parsed.isError && !!parsed.result?.trim();
|
|
1846
|
+
let permissionWarning;
|
|
1847
|
+
// A denial carried along on a non-permission outcome (typed failure, or
|
|
1848
|
+
// non-strict Claude whose reply was not complete).
|
|
1849
|
+
let carriedDenial;
|
|
1850
|
+
if (denial) {
|
|
1851
|
+
if (typedFailure) {
|
|
1852
|
+
carriedDenial = denial;
|
|
1853
|
+
}
|
|
1854
|
+
else if (replyComplete && (denial.healable === false || !strictDenials)) {
|
|
1855
|
+
permissionWarning = denial;
|
|
1856
|
+
logWarn('permission_denied_incidental', `"${agent.friendlyName}" (${denial.permissionMode ?? 'unknown'} mode): ${denial.hint} -- reply complete, reported as a warning${denial.healable === false ? '; never auto-granted' : ''}.`);
|
|
1857
|
+
}
|
|
1858
|
+
else if (strictDenials) {
|
|
1859
|
+
const partial = parsed.result?.trim() ? parsed.result.trim() : undefined;
|
|
1860
|
+
// The turn ran: keep the session, usage, budget and PID bookkeeping
|
|
1861
|
+
// a completed dispatch gets, so a later resume continues THIS session
|
|
1862
|
+
// and the spend is recorded.
|
|
1863
|
+
const expectation = sessionExpectation(parsed);
|
|
1864
|
+
if (expectation.isMismatch) {
|
|
1865
|
+
scope.info(`session-id mismatch: expected=${expectation.expectedSid} got=${parsed.sessionId} -- not persisting`);
|
|
1866
|
+
if (mismatchIsTerminal())
|
|
1867
|
+
return await terminalMismatchFailure(parsed, expectation.expectedSid, { permissionDenied: denial });
|
|
1868
|
+
}
|
|
1869
|
+
await recordDispatchBookkeeping(parsed, expectation);
|
|
1870
|
+
return {
|
|
1871
|
+
text: `[FAIL] execute_prompt on "${agent.friendlyName}": permission denied -- ${denial.hint}${partial ? `\n[partial response]\n${partial}` : ''}`,
|
|
1872
|
+
structuredContent: {
|
|
1873
|
+
isError: true,
|
|
1874
|
+
reason: 'permission_denied',
|
|
1875
|
+
permissionDenied: denial,
|
|
1876
|
+
...(partial ? { response: partial } : {}),
|
|
1877
|
+
...(parsed.sessionId ? { sessionId: parsed.sessionId } : {}),
|
|
1878
|
+
...(_epUsage ? { usage: toStructuredUsage(_epUsage) } : {}),
|
|
1879
|
+
},
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
else {
|
|
1883
|
+
carriedDenial = denial;
|
|
1884
|
+
}
|
|
1443
1885
|
}
|
|
1886
|
+
const carriedDenialField = carriedDenial ? { permissionDenied: carriedDenial } : {};
|
|
1444
1887
|
if (result.code !== 0) {
|
|
1888
|
+
// GitHub #585: a failed dispatch used to log only exit=N. Log a capped
|
|
1889
|
+
// stderr tail plus the last result/error event (logLine applies the
|
|
1890
|
+
// usual secret redaction). Success paths log nothing extra.
|
|
1891
|
+
logLine('prompt_failure_output', formatPromptFailureTail(result), { id: agent.id, friendlyName: agent.friendlyName }, scope.getInv());
|
|
1445
1892
|
// apra-fleet-391: surface an auth failure as a STRUCTURED reason (not
|
|
1446
1893
|
// just prose in `text`) so callers -- notably fleet-sprint's
|
|
1447
1894
|
// isAuthDispatchError -- can key off it directly instead of regexing
|
|
@@ -1476,7 +1923,9 @@ export async function executePrompt(input, extra) {
|
|
|
1476
1923
|
// 10-hour run with dozens of max_turns exhaustions reporting
|
|
1477
1924
|
// stats.totalCost of $0). Attach it here whenever it's available so
|
|
1478
1925
|
// the caller can record the real partial cost instead of nothing.
|
|
1479
|
-
...(_epUsage ? { usage:
|
|
1926
|
+
...(_epUsage ? { usage: toStructuredUsage(_epUsage) } : {}),
|
|
1927
|
+
...sessionIdField(parsed.sessionId),
|
|
1928
|
+
...carriedDenialField,
|
|
1480
1929
|
},
|
|
1481
1930
|
};
|
|
1482
1931
|
}
|
|
@@ -1515,7 +1964,7 @@ export async function executePrompt(input, extra) {
|
|
|
1515
1964
|
// short-circuits every Windows member: it selects the POSIX
|
|
1516
1965
|
// `kill -0` / `cat` probes over the PowerShell ones (apra-fleet-7dir.2.4).
|
|
1517
1966
|
shell: getAgentShell(agent),
|
|
1518
|
-
maxWaitMs: maxTotalMs !== undefined ?
|
|
1967
|
+
maxWaitMs: maxTotalMs !== undefined ? retryBudget().maxTotalMs : undefined,
|
|
1519
1968
|
scope,
|
|
1520
1969
|
});
|
|
1521
1970
|
if (recovery.status === 'timeout') {
|
|
@@ -1529,7 +1978,7 @@ export async function executePrompt(input, extra) {
|
|
|
1529
1978
|
// Feed the durable output through the normal provider parse path,
|
|
1530
1979
|
// exactly as if it had arrived on the original channel.
|
|
1531
1980
|
const recoveredResult = { stdout: recovery.stdout, stderr: result.stderr ?? '', code: 0 };
|
|
1532
|
-
const recoveredParsed =
|
|
1981
|
+
const recoveredParsed = parseDispatch(recoveredResult);
|
|
1533
1982
|
if (recoveredParsed.result && recoveredParsed.result.trim() !== '') {
|
|
1534
1983
|
scope.info(`recovered the real result from the durable output file after a false-alarm empty_response (waited ${Math.round((recovery.waitedMs ?? 0) / 1000)}s)`);
|
|
1535
1984
|
parsed = recoveredParsed;
|
|
@@ -1563,9 +2012,9 @@ export async function executePrompt(input, extra) {
|
|
|
1563
2012
|
if (!healBudget.exhausted) {
|
|
1564
2013
|
await tryKillPid(agent, strategy, cmds);
|
|
1565
2014
|
const freshOpts = { ...promptOpts, sessionId: isCallerMinted ? uuid() : undefined, resuming: false, fork: undefined };
|
|
1566
|
-
const retryCmd =
|
|
1567
|
-
result = await
|
|
1568
|
-
parsed =
|
|
2015
|
+
const retryCmd = cmds.buildAgentPromptCommand(provider, freshOpts);
|
|
2016
|
+
result = await dispatchAttempt(retryCmd, healBudget.timeoutMs, healBudget.maxTotalMs);
|
|
2017
|
+
parsed = parseDispatch(result);
|
|
1569
2018
|
if (parsed.usage)
|
|
1570
2019
|
_epUsage = parsed.usage;
|
|
1571
2020
|
const usageLimitResult = checkUsageLimit(result, parsed);
|
|
@@ -1580,79 +2029,22 @@ export async function executePrompt(input, extra) {
|
|
|
1580
2029
|
text: trustClassified
|
|
1581
2030
|
? `[FAIL] ${workspaceNotTrustedAdvice(agent.friendlyName)}\n${stderrTail}`
|
|
1582
2031
|
: `[FAIL] execute_prompt on "${agent.friendlyName}" exited 0 but produced no parseable output (empty result -- the member CLI likely died mid-turn without printing its result envelope).${stderrTail ? `\n[stderr tail]\n${stderrTail}` : ''}`,
|
|
1583
|
-
structuredContent: { isError: true, reason: trustClassified ? 'workspace_not_trusted' : 'empty_response' },
|
|
2032
|
+
structuredContent: { isError: true, reason: trustClassified ? 'workspace_not_trusted' : 'empty_response', ...(trustClassified ? {} : sessionIdField(parsed.sessionId)), ...carriedDenialField },
|
|
1584
2033
|
};
|
|
1585
2034
|
}
|
|
1586
2035
|
}
|
|
1587
|
-
// Session-id assertion
|
|
1588
|
-
|
|
1589
|
-
// caller-minted session. mintedId is explicitly passed to the CLI as
|
|
1590
|
-
// --session-id even in fork mode (provider.forkFlag/buildForkFlag), and the
|
|
1591
|
-
// CLI honors it -- so it is no longer a placeholder the CLI silently
|
|
1592
|
-
// discards, and a genuine mismatch here is a real signal worth catching
|
|
1593
|
-
// rather than something to exempt.
|
|
1594
|
-
const expectedSid = resuming ? resumeTargetId : (isCallerMinted ? mintedId : undefined);
|
|
1595
|
-
const isMismatch = expectedSid && parsed.sessionId && parsed.sessionId !== expectedSid;
|
|
2036
|
+
// Session-id assertion (see sessionExpectation).
|
|
2037
|
+
const { expectedSid, isMismatch } = sessionExpectation(parsed);
|
|
1596
2038
|
if (isMismatch) {
|
|
1597
2039
|
scope.info(`session-id mismatch: expected=${expectedSid} got=${parsed.sessionId} -- not persisting`);
|
|
1598
|
-
if (
|
|
1599
|
-
|
|
1600
|
-
stallDetector.remove(agent.id);
|
|
1601
|
-
writeStatusline(new Map([[agent.id, 'idle']]));
|
|
1602
|
-
clearStoredPid(agent.id);
|
|
1603
|
-
if (parsed.sessionId) {
|
|
1604
|
-
recordKnownSession(agent.id, parsed.sessionId);
|
|
1605
|
-
}
|
|
1606
|
-
if (parsed.usage) {
|
|
1607
|
-
const prev = agent.tokenUsage ?? { input: 0, output: 0 };
|
|
1608
|
-
updateAgent(agent.id, {
|
|
1609
|
-
tokenUsage: {
|
|
1610
|
-
input: prev.input + parsed.usage.input_tokens,
|
|
1611
|
-
output: prev.output + parsed.usage.output_tokens,
|
|
1612
|
-
},
|
|
1613
|
-
});
|
|
1614
|
-
recordSessionUsage(parsed.sessionId ?? expectedSid, parsed.usage);
|
|
1615
|
-
if (budgetScope) {
|
|
1616
|
-
await recordAndEvaluate({ scope: budgetScope, agent, provider, tier: resolvedTier, usage: parsed.usage });
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
return {
|
|
1620
|
-
text: `[FAIL] execute_prompt on "${agent.friendlyName}" failed -- resumed session mismatch. Expected session "${expectedSid}", but provider returned "${parsed.sessionId}".`,
|
|
1621
|
-
structuredContent: {
|
|
1622
|
-
isError: true,
|
|
1623
|
-
reason: 'session_not_found',
|
|
1624
|
-
sessionId: expectedSid,
|
|
1625
|
-
returnedSessionId: parsed.sessionId,
|
|
1626
|
-
...(parsed.usage ? { usage: { ...parsed.usage, total_tokens: parsed.usage.input_tokens + parsed.usage.output_tokens } } : {}),
|
|
1627
|
-
},
|
|
1628
|
-
};
|
|
1629
|
-
}
|
|
2040
|
+
if (mismatchIsTerminal())
|
|
2041
|
+
return await terminalMismatchFailure(parsed, expectedSid);
|
|
1630
2042
|
touchAgent(agent.id, undefined);
|
|
1631
2043
|
}
|
|
1632
2044
|
else {
|
|
1633
2045
|
touchAgent(agent.id, parsed.sessionId ?? expectedSid);
|
|
1634
2046
|
}
|
|
1635
|
-
|
|
1636
|
-
// known/resumable for this member, so a later explicit-id resume of it
|
|
1637
|
-
// passes the terminal session_not_found gate above instead of being
|
|
1638
|
-
// rejected as unknown.
|
|
1639
|
-
const finalSid = parsed.sessionId ?? expectedSid;
|
|
1640
|
-
if (finalSid) {
|
|
1641
|
-
recordKnownSession(agent.id, finalSid);
|
|
1642
|
-
let postLogPath = null;
|
|
1643
|
-
try {
|
|
1644
|
-
postLogPath = resolveSessionLogPath(agent.llmProvider ?? 'claude', finalSid, resolvedWorkFolder, memberPathCtx.homeDir, memberPathCtx.targetOs);
|
|
1645
|
-
}
|
|
1646
|
-
catch {
|
|
1647
|
-
postLogPath = null;
|
|
1648
|
-
}
|
|
1649
|
-
stallDetector.update(agent.id, {
|
|
1650
|
-
sessionId: finalSid,
|
|
1651
|
-
logFilePath: postLogPath,
|
|
1652
|
-
provisional: !postLogPath,
|
|
1653
|
-
thresholdMs: stallThresholdMs,
|
|
1654
|
-
});
|
|
1655
|
-
}
|
|
2047
|
+
recordLandedSession(parsed.sessionId ?? expectedSid);
|
|
1656
2048
|
clearStoredPid(agent.id);
|
|
1657
2049
|
if (parsed.usage) {
|
|
1658
2050
|
const prev = agent.tokenUsage ?? { input: 0, output: 0 };
|
|
@@ -1723,12 +2115,13 @@ session: ${parsed.sessionId}`;
|
|
|
1723
2115
|
// paths at all, and an entry with no basis is refused by design. A high
|
|
1724
2116
|
// rejected count is the invariant working, not a regression to tune away.
|
|
1725
2117
|
void import('./kb-harvest.js')
|
|
1726
|
-
.then(({ kbHarvest }) =>
|
|
1727
|
-
|
|
1728
|
-
|
|
2118
|
+
.then(({ kbHarvest }) =>
|
|
2119
|
+
// Explicit in-process anchor (not a tool input): this harvest is for
|
|
2120
|
+
// the dispatched member's repo, not the server's own session.
|
|
2121
|
+
kbHarvest({
|
|
1729
2122
|
session_transcript: parsed.result,
|
|
1730
2123
|
session_id: parsed.sessionId,
|
|
1731
|
-
}))
|
|
2124
|
+
}, { folder: resolvedWorkFolder, remoteUrl: knownRepoRemoteUrl(agent) }))
|
|
1732
2125
|
.then((raw) => {
|
|
1733
2126
|
try {
|
|
1734
2127
|
const r = JSON.parse(raw);
|
|
@@ -1744,14 +2137,20 @@ session: ${parsed.sessionId}`;
|
|
|
1744
2137
|
}
|
|
1745
2138
|
if (heuristicWarningSuffix)
|
|
1746
2139
|
output += heuristicWarningSuffix;
|
|
2140
|
+
// A refusal that did not fail the dispatch (incidental, or carried on a
|
|
2141
|
+
// turn that still exited 0) rides on the success as a warning.
|
|
2142
|
+
const successWarning = permissionWarning ?? carriedDenial;
|
|
2143
|
+
if (successWarning)
|
|
2144
|
+
output += `\n\n[WARN] ${successWarning.hint}`;
|
|
1747
2145
|
return {
|
|
1748
2146
|
text: output,
|
|
1749
2147
|
structuredContent: {
|
|
1750
2148
|
response: parsed.result,
|
|
1751
|
-
...(_epUsage ? { usage:
|
|
2149
|
+
...(_epUsage ? { usage: toStructuredUsage(_epUsage) } : {}),
|
|
1752
2150
|
...(parsed.sessionId ? { sessionId: parsed.sessionId } : {}),
|
|
1753
2151
|
...(contextWarning ? { contextWarning } : {}),
|
|
1754
2152
|
...(budgetUsage ? { budgetUsage } : {}),
|
|
2153
|
+
...(successWarning ? { permissionWarning: successWarning } : {}),
|
|
1755
2154
|
},
|
|
1756
2155
|
};
|
|
1757
2156
|
}
|
|
@@ -1760,6 +2159,13 @@ session: ${parsed.sessionId}`;
|
|
|
1760
2159
|
// NOT the MCP client). Surface it as a typed 'stalled' error so the dispatch
|
|
1761
2160
|
// settles here -- well under the client hard timeout -- instead of being
|
|
1762
2161
|
// mislabeled dispatch_failed or waiting out the full deadline.
|
|
2162
|
+
if (stallAbortController.signal.aborted && !extra?.signal?.aborted && stallReason === 'agent_never_started') {
|
|
2163
|
+
_epError = 'dispatch aborted: agent never started (session log never appeared)';
|
|
2164
|
+
return {
|
|
2165
|
+
text: `[FAIL] execute_prompt on "${agent.friendlyName}" was aborted: the agent never started -- its session log never appeared at the expected path within the inactivity threshold (timeout_s). Its process was killed and the dispatch cancelled.`,
|
|
2166
|
+
structuredContent: { isError: true, reason: 'agent_never_started' },
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
1763
2169
|
if (stallAbortController.signal.aborted && !extra?.signal?.aborted) {
|
|
1764
2170
|
_epError = 'dispatch aborted by confirmed stall';
|
|
1765
2171
|
return {
|
|
@@ -1767,17 +2173,22 @@ session: ${parsed.sessionId}`;
|
|
|
1767
2173
|
structuredContent: { isError: true, reason: 'stalled' },
|
|
1768
2174
|
};
|
|
1769
2175
|
}
|
|
2176
|
+
// GitHub #563: the shared max_total_s ceiling fired -- a typed error.
|
|
2177
|
+
if (isMaxTotalKill(err)) {
|
|
2178
|
+
_epError = err.message;
|
|
2179
|
+
return maxTotalTimeResult();
|
|
2180
|
+
}
|
|
1770
2181
|
// Only mark offline for genuine SSH/network connection failures, not for cancellations
|
|
1771
2182
|
_epOffline = !!(err.message && /ssh|network|econnrefused|ehostunreach|connection timed out/i.test(err.message));
|
|
1772
2183
|
_epError = err.message;
|
|
1773
2184
|
return {
|
|
1774
2185
|
text: `[FAIL] Failed to execute prompt on "${agent.friendlyName}": ${err.message}`,
|
|
1775
|
-
structuredContent: { isError: true, reason: 'dispatch_failed' },
|
|
2186
|
+
structuredContent: { isError: true, reason: 'dispatch_failed', ...sessionIdField(_epParsedSid) },
|
|
1776
2187
|
};
|
|
1777
2188
|
}
|
|
1778
2189
|
finally {
|
|
1779
2190
|
extra?.signal?.removeEventListener('abort', abortHandler);
|
|
1780
|
-
const _epTok = _epUsage ? ` in=${_epUsage.input_tokens} out=${_epUsage.output_tokens}` : '';
|
|
2191
|
+
const _epTok = _epUsage ? ` in=${_epUsage.input_tokens} out=${_epUsage.output_tokens} cache_read=${_epUsage.cache_read_input_tokens ?? 0} cache_write=${_epUsage.cache_creation_input_tokens ?? 0}` : '';
|
|
1781
2192
|
if (_epExitCode === 'error')
|
|
1782
2193
|
scope.abort(`${_epError ?? 'exception'}${_epTok}`);
|
|
1783
2194
|
else if (_epExitCode !== 0)
|
|
@@ -1791,7 +2202,7 @@ session: ${parsed.sessionId}`;
|
|
|
1791
2202
|
inFlightAgents.delete(agent.id);
|
|
1792
2203
|
}
|
|
1793
2204
|
stallDetector.remove(agent.id);
|
|
1794
|
-
await deletePromptFile(agent, strategy, promptFilePath, durablePath ? [durablePath] : []);
|
|
2205
|
+
await deletePromptFile(agent, strategy, promptFilePath, [...(durablePath ? [durablePath] : []), ...stagedEnvPaths, ...sessionMcpCleanup]);
|
|
1795
2206
|
}
|
|
1796
2207
|
}
|
|
1797
2208
|
catch (err) {
|