@apralabs/apra-fleet 0.4.2 → 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 +103 -34
- package/dist/agents/backlog-groomer.md +87 -14
- package/dist/agents/ci-watcher.md +35 -9
- package/dist/agents/deployer.md +63 -11
- package/dist/agents/doer.md +99 -41
- package/dist/agents/harvester.md +47 -27
- package/dist/agents/integ-test-runner.md +38 -10
- package/dist/agents/kb-reconciler.md +37 -7
- package/dist/agents/plan-reviewer.md +145 -32
- package/dist/agents/planner.md +180 -69
- package/dist/agents/regression-test-runner.md +98 -64
- package/dist/agents/reviewer.md +117 -45
- 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/plan-reviewer-output.json +37 -0
- 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 +90 -2
- package/dist/cli/agent-transform.js +310 -20
- package/dist/cli/auth.d.ts +1 -0
- package/dist/cli/auth.js +66 -17
- 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 +31 -6
- package/dist/cli/config.js +113 -36
- 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 +100 -11
- package/dist/cli/install.js +864 -139
- package/dist/cli/kb-commit.d.ts +2 -1
- package/dist/cli/kb-commit.js +1 -1
- package/dist/cli/kb-directives.js +2 -1
- package/dist/cli/kb-import.d.ts +2 -1
- package/dist/cli/kb-import.js +1 -1
- package/dist/cli/register-member.js +26 -5
- 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.d.ts +3 -0
- package/dist/commands/kb-server.js +52 -5
- package/dist/hub-service/http-server.d.ts +5 -1
- package/dist/hub-service/http-server.js +55 -5
- package/dist/index.js +158 -11
- 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 +13 -2
- package/dist/os/linux.js +75 -16
- package/dist/os/macos.d.ts +1 -1
- package/dist/os/macos.js +2 -11
- package/dist/os/os-commands.d.ts +78 -4
- package/dist/os/windows-gitbash.d.ts +6 -0
- package/dist/os/windows-gitbash.js +32 -3
- package/dist/os/windows-wrapper.d.ts +0 -4
- package/dist/os/windows-wrapper.js +2 -1
- package/dist/os/windows.d.ts +11 -2
- package/dist/os/windows.js +121 -32
- package/dist/paths.d.ts +21 -0
- package/dist/paths.js +35 -0
- package/dist/providers/agy.d.ts +120 -7
- package/dist/providers/agy.js +741 -86
- 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 +132 -6
- package/dist/providers/claude.js +644 -48
- package/dist/providers/codex.d.ts +4 -2
- package/dist/providers/codex.js +23 -2
- package/dist/providers/copilot.d.ts +4 -2
- package/dist/providers/copilot.js +24 -2
- package/dist/providers/none.d.ts +4 -2
- package/dist/providers/none.js +17 -2
- package/dist/providers/opencode.d.ts +12 -2
- package/dist/providers/opencode.js +135 -54
- package/dist/providers/provider.d.ts +368 -35
- package/dist/providers/provider.js +219 -2
- 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 +103 -0
- package/dist/services/agy-project.js +354 -0
- package/dist/services/auth-socket.d.ts +25 -0
- package/dist/services/auth-socket.js +72 -27
- package/dist/services/auth-web.js +2 -2
- 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 +52 -6
- package/dist/services/cloud/task-wrapper.d.ts +0 -9
- package/dist/services/cloud/task-wrapper.js +15 -6
- package/dist/services/credential-cleanup.js +35 -17
- package/dist/services/event-loop-watchdog.d.ts +32 -0
- package/dist/services/event-loop-watchdog.js +140 -0
- package/dist/services/exit-drain.d.ts +44 -0
- package/dist/services/exit-drain.js +52 -0
- package/dist/services/github-app.js +32 -4
- package/dist/services/http-transport.d.ts +50 -1
- package/dist/services/http-transport.js +238 -25
- 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-config.d.ts +42 -0
- package/dist/services/knowledge/kb-config.js +54 -0
- 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 +11 -1
- package/dist/services/knowledge/kb-providers.js +199 -17
- 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/require-sqlite-project.d.ts +32 -0
- package/dist/services/knowledge/require-sqlite-project.js +38 -0
- 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 +60 -10
- 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/secret-token.d.ts +38 -0
- package/dist/services/secret-token.js +51 -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 +39 -2
- package/dist/services/service-manager/types.js +29 -0
- package/dist/services/service-manager/windows.d.ts +194 -3
- package/dist/services/service-manager/windows.js +705 -30
- 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 +287 -40
- 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 +53 -12
- package/dist/services/stall/stall-detector.d.ts +78 -5
- package/dist/services/stall/stall-detector.js +296 -39
- 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 +165 -19
- package/dist/services/substitution-engine.js +2 -2
- 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 +164 -61
- package/dist/services/tool-scope.d.ts +58 -0
- package/dist/services/tool-scope.js +99 -0
- package/dist/services/vcs/azure-devops.d.ts +66 -1
- package/dist/services/vcs/azure-devops.js +192 -21
- package/dist/services/vcs/types.d.ts +1 -1
- 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 +48 -6
- package/dist/skills/pm/SKILL.md +4 -4
- package/dist/skills/pm/cost.md +0 -3
- package/dist/skills/pm/fleet-addendum.md +2 -2
- 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 +60 -9
- package/dist/tools/check-status.js +211 -52
- 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 +63 -2
- package/dist/tools/compose-permissions.js +673 -72
- package/dist/tools/credential-store-set.js +1 -1
- package/dist/tools/execute-command.d.ts +11 -0
- package/dist/tools/execute-command.js +111 -32
- package/dist/tools/execute-prompt.d.ts +69 -12
- package/dist/tools/execute-prompt.js +1610 -895
- 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 +15 -11
- package/dist/tools/kb-capture.js +71 -16
- package/dist/tools/kb-context.d.ts +27 -7
- package/dist/tools/kb-context.js +60 -9
- package/dist/tools/kb-export.d.ts +98 -9
- package/dist/tools/kb-export.js +230 -92
- package/dist/tools/kb-feedback.d.ts +13 -9
- package/dist/tools/kb-feedback.js +16 -8
- package/dist/tools/kb-freshness-sweep.d.ts +11 -7
- package/dist/tools/kb-freshness-sweep.js +10 -8
- 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 +170 -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 +33 -11
- 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 +13 -9
- package/dist/tools/kb-resolve-contradiction.d.ts +11 -7
- package/dist/tools/kb-resolve-contradiction.js +10 -8
- 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 +146 -27
- package/dist/tools/kb-stats.d.ts +11 -10
- package/dist/tools/kb-stats.js +84 -82
- package/dist/tools/list-members.d.ts +2 -2
- package/dist/tools/list-members.js +6 -2
- package/dist/tools/member-detail.d.ts +5 -2
- package/dist/tools/member-detail.js +105 -17
- package/dist/tools/member-reservation.d.ts +60 -3
- package/dist/tools/member-reservation.js +61 -20
- package/dist/tools/provision-auth.d.ts +118 -1
- package/dist/tools/provision-auth.js +402 -92
- package/dist/tools/provision-vcs-auth.d.ts +93 -3
- package/dist/tools/provision-vcs-auth.js +209 -49
- package/dist/tools/receive-files.js +3 -1
- package/dist/tools/register-member.d.ts +44 -15
- package/dist/tools/register-member.js +175 -70
- package/dist/tools/remove-member.js +118 -15
- 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/setup-git-app.js +11 -7
- package/dist/tools/shutdown-server.d.ts +2 -0
- package/dist/tools/shutdown-server.js +28 -1
- 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 +23 -17
- package/dist/tools/update-member.js +181 -18
- package/dist/tools/vcs-credential-exec.d.ts +127 -0
- package/dist/tools/vcs-credential-exec.js +203 -0
- package/dist/types.d.ts +111 -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 +108 -22
- 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 +11 -2
- package/dist/utils/session-caller.d.ts +4 -2
- package/dist/utils/session-caller.js +3 -2
- package/dist/utils/shell-escape.d.ts +58 -3
- package/dist/utils/shell-escape.js +91 -5
- package/dist/utils/ssh-error-messages.js +3 -0
- package/dist/utils/vcs-provider-detect.d.ts +65 -0
- package/dist/utils/vcs-provider-detect.js +109 -0
- package/dist/utils/workspace-trust.d.ts +26 -0
- package/dist/utils/workspace-trust.js +91 -1
- package/dist/workflows/auto-sprint.js +397 -56
- package/package.json +15 -10
- package/packages/apra-fleet-client/package.json +2 -2
- package/packages/apra-fleet-client/src/client/api.mjs +864 -31
- 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/errors.mjs +6 -2
- 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/_shared/GRAPH-SEMANTICS.md +10 -2
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +87 -14
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +35 -9
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +63 -11
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +99 -41
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +47 -27
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +38 -10
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +37 -7
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +145 -32
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +180 -69
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +98 -64
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +117 -45
- 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/plan-reviewer-output.json +37 -0
- 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 +4 -4
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -3
- package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +2 -2
- 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 +326 -48
- package/packages/apra-fleet-se/bin/serve.mjs +218 -11
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +517 -0
- package/packages/apra-fleet-se/fleet-sprint/backlog-role.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +646 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +825 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +217 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-memory-hygiene.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +745 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +447 -0
- package/packages/apra-fleet-se/fleet-sprint/branch-ensure.mjs +96 -0
- package/packages/apra-fleet-se/fleet-sprint/ci-gate.mjs +353 -0
- package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +20 -0
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +121 -15
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +539 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-accounting.mjs +270 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +204 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +1310 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +216 -4
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +53 -15
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +281 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +1 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/fleet-sprint-diagram.md +3 -3
- package/packages/apra-fleet-se/fleet-sprint/docs/run-sprint-cycle-prelude-decision.md +215 -0
- package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +56 -1
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +1327 -44
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +470 -4
- package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +501 -0
- package/packages/apra-fleet-se/fleet-sprint/fatal-diagnostics.mjs +134 -0
- package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +102 -0
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +747 -0
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +543 -0
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +613 -0
- package/packages/apra-fleet-se/fleet-sprint/inline-ladder-guard.mjs +216 -0
- 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 +1684 -0
- package/packages/apra-fleet-se/fleet-sprint/lower-quality.mjs +39 -0
- package/packages/apra-fleet-se/fleet-sprint/mcp-result.mjs +75 -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 +699 -0
- package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +802 -0
- package/packages/apra-fleet-se/fleet-sprint/member-target.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/newtask-text.mjs +266 -0
- package/packages/apra-fleet-se/fleet-sprint/orphan-reclaim.mjs +153 -0
- package/packages/apra-fleet-se/fleet-sprint/parent-notes-staleness.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +218 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +869 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +295 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +466 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +212 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +358 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +395 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +345 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +264 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +179 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +230 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +365 -0
- package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +259 -0
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +617 -0
- package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +1434 -0
- package/packages/apra-fleet-se/fleet-sprint/round-session.mjs +100 -0
- package/packages/apra-fleet-se/fleet-sprint/runner.js +2289 -9928
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +24 -0
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +147 -12
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +111 -0
- package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +347 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +48 -6
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +98 -25
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +590 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +339 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +185 -0
- package/packages/apra-fleet-se/fleet-sprint/unbracketed-push-guard.mjs +234 -0
- package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +218 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +1445 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +284 -23
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +170 -21
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +28 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +354 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +189 -16
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +9 -4
- package/packages/apra-fleet-se/fleet-sprint/verify-block.mjs +152 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +311 -22
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +559 -0
- 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 +81 -15
- package/packages/apra-fleet-workflow/src/viewer/run-summary.mjs +127 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +118 -10
- package/packages/apra-fleet-workflow/src/workflow/pricing.mjs +75 -25
- package/skills/fleet/SKILL.md +8 -8
- package/skills/fleet/auth-azdevops.md +14 -3
- package/skills/fleet/auth-bitbucket.md +2 -2
- package/skills/fleet/auth-github.md +5 -4
- package/skills/fleet/onboarding.md +3 -3
- package/skills/fleet/permissions.md +14 -1
- package/skills/fleet/profiles/node.json +1 -1
- package/skills/fleet/profiles/tag-kb-reconciler.json +2 -6
- package/skills/fleet/troubleshooting.md +3 -3
- 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/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/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-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/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/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/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/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
package/dist/services/ssh.js
CHANGED
|
@@ -7,8 +7,14 @@ import { decryptPassword } from '../utils/crypto.js';
|
|
|
7
7
|
import { verifyHostKey, replaceKnownHost, HostKeyMismatchError } from './known-hosts.js';
|
|
8
8
|
import { setStoredPid, clearStoredPid, getAgentOS, getAgentShell } from '../utils/agent-helpers.js';
|
|
9
9
|
import { getOsCommands } from '../os/index.js';
|
|
10
|
+
import { completesOnProcessExit, exitDrainMs } from './exit-drain.js';
|
|
11
|
+
import { logWarn } from '../utils/log-helpers.js';
|
|
10
12
|
const MAX_OUTPUT_BYTES = 10 * 1024 * 1024; // 10 MB
|
|
11
13
|
const pool = new Map();
|
|
14
|
+
// In-flight connects per pool key, so concurrent callers share one new
|
|
15
|
+
// connection instead of each opening one (only the last would be pooled; the
|
|
16
|
+
// others would be orphaned and never idle-reaped).
|
|
17
|
+
const connecting = new Map();
|
|
12
18
|
const IDLE_TIMEOUT = 5 * 60 * 1000; // 5 minutes
|
|
13
19
|
function poolKey(agent) {
|
|
14
20
|
return `${agent.username}@${agent.host}:${agent.port}`;
|
|
@@ -75,17 +81,28 @@ function connectClient(config, key) {
|
|
|
75
81
|
const timer = setTimeout(() => cleanupEntry(key), IDLE_TIMEOUT);
|
|
76
82
|
timer.unref();
|
|
77
83
|
pool.set(key, { client, lastUsed: Date.now(), timer, activeChannels: 0 });
|
|
84
|
+
// Guarded by identity: once this client has been retired and replaced,
|
|
85
|
+
// its late close/error must not drop or reap the replacement entry.
|
|
78
86
|
client.on('close', () => {
|
|
79
|
-
pool.
|
|
87
|
+
if (pool.get(key)?.client === client)
|
|
88
|
+
pool.delete(key);
|
|
80
89
|
});
|
|
81
90
|
client.on('error', () => {
|
|
82
|
-
|
|
91
|
+
if (pool.get(key)?.client === client)
|
|
92
|
+
cleanupEntry(key);
|
|
83
93
|
});
|
|
84
94
|
resolve(client);
|
|
85
95
|
});
|
|
86
96
|
client.on('error', (err) => {
|
|
87
97
|
reject(err);
|
|
88
98
|
});
|
|
99
|
+
// ssh2 emits 'error' only when no SSH banner was seen; a socket that
|
|
100
|
+
// closes after the banner but before 'ready' (no DISCONNECT) would
|
|
101
|
+
// otherwise leave this promise -- shared by every concurrent caller for
|
|
102
|
+
// the member via `connecting` -- pending forever. A no-op once resolved.
|
|
103
|
+
client.once('close', () => {
|
|
104
|
+
reject(new Error(`SSH connection to ${key} closed before it became ready`));
|
|
105
|
+
});
|
|
89
106
|
client.connect(config);
|
|
90
107
|
});
|
|
91
108
|
}
|
|
@@ -96,7 +113,126 @@ export async function getConnection(agent) {
|
|
|
96
113
|
resetIdleTimer(key);
|
|
97
114
|
return entry.client;
|
|
98
115
|
}
|
|
99
|
-
|
|
116
|
+
const inFlight = connecting.get(key);
|
|
117
|
+
if (inFlight)
|
|
118
|
+
return inFlight;
|
|
119
|
+
const p = connectClient(getSSHConfig(agent), key);
|
|
120
|
+
connecting.set(key, p);
|
|
121
|
+
const clear = () => { if (connecting.get(key) === p)
|
|
122
|
+
connecting.delete(key); };
|
|
123
|
+
p.then(clear, clear);
|
|
124
|
+
return p;
|
|
125
|
+
}
|
|
126
|
+
/** True for ssh2's "(SSH) Channel open failure: ..." -- sshd refused a new channel. */
|
|
127
|
+
export function isChannelOpenFailure(err) {
|
|
128
|
+
const msg = err instanceof Error ? err.message : String(err ?? '');
|
|
129
|
+
return /Channel open failure/i.test(msg);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Transport error for a refused channel open, naming the member and the
|
|
133
|
+
* likely cause. ssh2's raw text ("open failed") says nothing actionable.
|
|
134
|
+
*/
|
|
135
|
+
export function channelOpenFailureError(agent, err) {
|
|
136
|
+
const raw = err instanceof Error ? err.message : String(err);
|
|
137
|
+
const e = new Error(`SSH transport error on member "${agent.friendlyName}" (${agent.username}@${agent.host}:${agent.port}): ` +
|
|
138
|
+
`the member's sshd refused to open a new session channel (${raw}), also on a fresh connection. ` +
|
|
139
|
+
`Likely cause: its per-connection session limit (sshd MaxSessions, default 10) is exhausted by ` +
|
|
140
|
+
`concurrent or leaked SSH sessions (e.g. stale sftp-server processes). Close the stale sessions on ` +
|
|
141
|
+
`the member (or restart its sshd) or raise MaxSessions, then retry.`);
|
|
142
|
+
e.cause = err;
|
|
143
|
+
return e;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Take a pool entry out of service after a refused channel open: new work
|
|
147
|
+
* gets a fresh connection, while channels still running on this one finish
|
|
148
|
+
* undisturbed. Its client is ended now if idle, else on its last release.
|
|
149
|
+
*/
|
|
150
|
+
function retireEntry(key, entry) {
|
|
151
|
+
if (!entry)
|
|
152
|
+
return;
|
|
153
|
+
entry.retired = true;
|
|
154
|
+
clearTimeout(entry.timer);
|
|
155
|
+
if (pool.get(key) === entry)
|
|
156
|
+
pool.delete(key);
|
|
157
|
+
if (entry.activeChannels === 0) {
|
|
158
|
+
try {
|
|
159
|
+
entry.client.end();
|
|
160
|
+
}
|
|
161
|
+
catch { }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function leaseConnection(agent) {
|
|
165
|
+
const { client, warning } = await connectWithTOFU(agent);
|
|
166
|
+
const key = poolKey(agent);
|
|
167
|
+
resetIdleTimer(key);
|
|
168
|
+
// Bind the lease to THIS connection's entry (not a later pool lookup by
|
|
169
|
+
// key), so a release after a reconnect never decrements the replacement.
|
|
170
|
+
const found = pool.get(key);
|
|
171
|
+
const entry = found && found.client === client ? found : undefined;
|
|
172
|
+
if (entry)
|
|
173
|
+
entry.activeChannels += 1;
|
|
174
|
+
let released = false;
|
|
175
|
+
const release = () => {
|
|
176
|
+
if (released)
|
|
177
|
+
return;
|
|
178
|
+
released = true;
|
|
179
|
+
if (!entry)
|
|
180
|
+
return;
|
|
181
|
+
entry.activeChannels = Math.max(0, entry.activeChannels - 1);
|
|
182
|
+
if (entry.retired && entry.activeChannels === 0) {
|
|
183
|
+
try {
|
|
184
|
+
entry.client.end();
|
|
185
|
+
}
|
|
186
|
+
catch { }
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
return { client, warning, release, key, entry };
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Open one channel (exec or sftp) on the member's pooled connection, counted
|
|
193
|
+
* in the entry's activeChannels until release(). The caller owns the channel
|
|
194
|
+
* and MUST close it and call release() on every path (success, error,
|
|
195
|
+
* timeout, abort) -- an unclosed channel holds one of the member sshd's
|
|
196
|
+
* per-connection sessions (MaxSessions) forever.
|
|
197
|
+
*
|
|
198
|
+
* A "Channel open failure" means nothing started on the far side, so it is
|
|
199
|
+
* safe to retry: the connection is retired and the open is retried ONCE on a
|
|
200
|
+
* fresh connection (MaxSessions is per connection). A second refusal
|
|
201
|
+
* surfaces as channelOpenFailureError.
|
|
202
|
+
*/
|
|
203
|
+
export async function openPooledChannel(agent, open) {
|
|
204
|
+
const first = await leaseConnection(agent);
|
|
205
|
+
try {
|
|
206
|
+
const channel = await open(first.client);
|
|
207
|
+
return { channel, client: first.client, warning: first.warning, release: first.release };
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
first.release();
|
|
211
|
+
if (!isChannelOpenFailure(err))
|
|
212
|
+
throw err;
|
|
213
|
+
retireEntry(first.key, first.entry);
|
|
214
|
+
}
|
|
215
|
+
const second = await leaseConnection(agent);
|
|
216
|
+
try {
|
|
217
|
+
const channel = await open(second.client);
|
|
218
|
+
return { channel, client: second.client, warning: first.warning ?? second.warning, release: second.release };
|
|
219
|
+
}
|
|
220
|
+
catch (err) {
|
|
221
|
+
second.release();
|
|
222
|
+
if (isChannelOpenFailure(err))
|
|
223
|
+
throw channelOpenFailureError(agent, err);
|
|
224
|
+
throw err;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function openExec(client, command) {
|
|
228
|
+
return new Promise((resolve, reject) => {
|
|
229
|
+
client.exec(command, (err, stream) => {
|
|
230
|
+
if (err)
|
|
231
|
+
reject(err);
|
|
232
|
+
else
|
|
233
|
+
resolve(stream);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
100
236
|
}
|
|
101
237
|
/**
|
|
102
238
|
* Connect with TOFU: on HostKeyMismatchError, auto-accept the new key and retry once.
|
|
@@ -112,33 +248,38 @@ export async function connectWithTOFU(agent) {
|
|
|
112
248
|
replaceKnownHost(err.host, err.port, err.newFingerprint);
|
|
113
249
|
closeConnection(agent);
|
|
114
250
|
const client = await getConnection(agent);
|
|
251
|
+
// The re-accept is logged here, at its one source, because most callers
|
|
252
|
+
// never surface the returned warning (execCommand folds it into stderr,
|
|
253
|
+
// which many callers ignore; SFTP transfers drop it entirely). A silently
|
|
254
|
+
// re-trusted host key is exactly what an operator must be able to see.
|
|
255
|
+
logWarn('ssh', `Host key for ${err.host}:${err.port} changed (was ${err.oldFingerprint}, now ${err.newFingerprint}); ` +
|
|
256
|
+
`the new key was auto-accepted (TOFU) and the connection re-established. ` +
|
|
257
|
+
`If this member was not reinstalled, investigate a possible man-in-the-middle.`, agent);
|
|
115
258
|
return { client, warning: `Host key updated for ${err.host}:${err.port}` };
|
|
116
259
|
}
|
|
117
260
|
throw err;
|
|
118
261
|
}
|
|
119
262
|
}
|
|
120
263
|
export async function execCommand(agent, command, timeoutMs = 30000, maxTotalMs, onPidCaptured, abortSignal) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// apra-fleet-9zz.1:
|
|
125
|
-
// BEFORE
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (entry)
|
|
141
|
-
entry.activeChannels = Math.max(0, entry.activeChannels - 1);
|
|
264
|
+
// Connect (and TOFU-heal a changed host key) before the command timers
|
|
265
|
+
// start -- connection setup has its own readyTimeout.
|
|
266
|
+
const { warning } = await connectWithTOFU(agent);
|
|
267
|
+
// apra-fleet-9zz.1: the channel is counted as active on its pool entry from
|
|
268
|
+
// BEFORE the exec request until settle (openPooledChannel/releaseChannel),
|
|
269
|
+
// so cleanupEntry's idle-timer reap never ends the connection out from
|
|
270
|
+
// under it. The channel itself is closed on every non-'close' settle path
|
|
271
|
+
// (timeout, abort, error, late open) -- a channel left open holds one of
|
|
272
|
+
// the member sshd's per-connection sessions (MaxSessions) forever.
|
|
273
|
+
let client;
|
|
274
|
+
let activeStream;
|
|
275
|
+
let releaseChannel = () => { };
|
|
276
|
+
function closeStream() {
|
|
277
|
+
if (activeStream) {
|
|
278
|
+
try {
|
|
279
|
+
activeStream.close();
|
|
280
|
+
}
|
|
281
|
+
catch { /* best-effort */ }
|
|
282
|
+
}
|
|
142
283
|
}
|
|
143
284
|
// Remote PID captured from the FLEET_PID marker (see execute-command.ts's
|
|
144
285
|
// wrapPidCapture), if the wrapped command emits one. A closed/rejected SSH
|
|
@@ -149,24 +290,58 @@ export async function execCommand(agent, command, timeoutMs = 30000, maxTotalMs,
|
|
|
149
290
|
// path, using the marker PID instead of a local handle.
|
|
150
291
|
let capturedPid;
|
|
151
292
|
function killRemoteTree() {
|
|
152
|
-
if (capturedPid === undefined)
|
|
293
|
+
if (capturedPid === undefined || !client)
|
|
153
294
|
return;
|
|
295
|
+
let killCmd;
|
|
154
296
|
try {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
297
|
+
killCmd = getOsCommands(getAgentOS(agent), getAgentShell(agent)).killPid(capturedPid);
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
return; /* best-effort */
|
|
301
|
+
}
|
|
302
|
+
// Best-effort, fire-and-forget on a FRESH channel -- the timed-out
|
|
303
|
+
// command's own channel may itself be wedged and must not be relied on
|
|
304
|
+
// to carry the kill. Opened through openPooledChannel so it is LEASED:
|
|
305
|
+
// the timed-out command's release can no longer end a retired connection
|
|
306
|
+
// before the kill is sent (a PID kill works over any connection to the
|
|
307
|
+
// member), and a refused open retries once on a fresh connection.
|
|
308
|
+
// stdin EOF + a safety close so this channel can never outlive the kill.
|
|
309
|
+
openPooledChannel(agent, (c) => openExec(c, killCmd)).then(({ channel: killStream, release }) => {
|
|
310
|
+
let done = false;
|
|
311
|
+
const finish = () => {
|
|
312
|
+
if (done)
|
|
161
313
|
return;
|
|
162
|
-
|
|
163
|
-
|
|
314
|
+
done = true;
|
|
315
|
+
clearTimeout(killTimer);
|
|
316
|
+
release();
|
|
317
|
+
};
|
|
318
|
+
const killTimer = setTimeout(() => {
|
|
319
|
+
try {
|
|
320
|
+
killStream.close();
|
|
321
|
+
}
|
|
322
|
+
catch { /* best-effort */ }
|
|
323
|
+
finish();
|
|
324
|
+
}, 30000);
|
|
325
|
+
killTimer.unref();
|
|
326
|
+
try {
|
|
327
|
+
killStream.end();
|
|
328
|
+
}
|
|
329
|
+
catch { /* best-effort */ }
|
|
330
|
+
killStream.on('data', () => { });
|
|
331
|
+
killStream.stderr?.on('data', () => { });
|
|
332
|
+
killStream.on('close', finish);
|
|
333
|
+
killStream.on('error', () => {
|
|
334
|
+
try {
|
|
335
|
+
killStream.close();
|
|
336
|
+
}
|
|
337
|
+
catch { /* best-effort */ }
|
|
338
|
+
finish();
|
|
164
339
|
});
|
|
165
|
-
}
|
|
166
|
-
catch { /* best-effort; connection may already be gone */ }
|
|
340
|
+
}).catch(() => { });
|
|
167
341
|
}
|
|
168
342
|
return new Promise((resolve, reject) => {
|
|
169
343
|
let settled = false;
|
|
344
|
+
let exitDrainTimer;
|
|
170
345
|
function settle(fn) {
|
|
171
346
|
if (settled)
|
|
172
347
|
return;
|
|
@@ -174,6 +349,8 @@ export async function execCommand(agent, command, timeoutMs = 30000, maxTotalMs,
|
|
|
174
349
|
clearTimeout(inactivityTimer);
|
|
175
350
|
if (maxTotalTimer)
|
|
176
351
|
clearTimeout(maxTotalTimer);
|
|
352
|
+
if (exitDrainTimer)
|
|
353
|
+
clearTimeout(exitDrainTimer);
|
|
177
354
|
releaseChannel();
|
|
178
355
|
fn();
|
|
179
356
|
}
|
|
@@ -183,6 +360,7 @@ export async function execCommand(agent, command, timeoutMs = 30000, maxTotalMs,
|
|
|
183
360
|
clearTimeout(inactivityTimer);
|
|
184
361
|
inactivityTimer = setTimeout(() => {
|
|
185
362
|
killRemoteTree();
|
|
363
|
+
closeStream();
|
|
186
364
|
settle(() => reject(new Error(`Command timed out after ${timeoutMs}ms of inactivity`)));
|
|
187
365
|
}, timeoutMs);
|
|
188
366
|
inactivityTimer.unref();
|
|
@@ -193,15 +371,26 @@ export async function execCommand(agent, command, timeoutMs = 30000, maxTotalMs,
|
|
|
193
371
|
if (maxTotalMs !== undefined) {
|
|
194
372
|
maxTotalTimer = setTimeout(() => {
|
|
195
373
|
killRemoteTree();
|
|
374
|
+
closeStream();
|
|
196
375
|
settle(() => reject(new Error(`Command exceeded max total time of ${maxTotalMs}ms`)));
|
|
197
376
|
}, maxTotalMs);
|
|
198
377
|
maxTotalTimer.unref();
|
|
199
378
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
379
|
+
openPooledChannel(agent, (c) => openExec(c, command)).then((lease) => {
|
|
380
|
+
const stream = lease.channel;
|
|
381
|
+
if (settled) {
|
|
382
|
+
// A timer settled this call before the channel opened: nobody will
|
|
383
|
+
// ever read it, so close it now instead of leaking the session.
|
|
384
|
+
try {
|
|
385
|
+
stream.close();
|
|
386
|
+
}
|
|
387
|
+
catch { /* best-effort */ }
|
|
388
|
+
lease.release();
|
|
203
389
|
return;
|
|
204
390
|
}
|
|
391
|
+
client = lease.client;
|
|
392
|
+
activeStream = stream;
|
|
393
|
+
releaseChannel = lease.release;
|
|
205
394
|
// Close stdin so commands that read from it (e.g. claude -p) get EOF
|
|
206
395
|
stream.end();
|
|
207
396
|
let stdout = '';
|
|
@@ -255,7 +444,7 @@ export async function execCommand(agent, command, timeoutMs = 30000, maxTotalMs,
|
|
|
255
444
|
stderrSpillStream.write(data);
|
|
256
445
|
}
|
|
257
446
|
});
|
|
258
|
-
|
|
447
|
+
const finalize = (code) => {
|
|
259
448
|
clearStoredPid(agent.id);
|
|
260
449
|
if (stdoutSpillStream)
|
|
261
450
|
stdoutSpillStream.end();
|
|
@@ -271,13 +460,69 @@ export async function execCommand(agent, command, timeoutMs = 30000, maxTotalMs,
|
|
|
271
460
|
stderr = `Warning: ${warning}\n${stderr}`;
|
|
272
461
|
}
|
|
273
462
|
settle(() => resolve({ stdout, stderr, code: code ?? 0 }));
|
|
274
|
-
}
|
|
463
|
+
};
|
|
464
|
+
stream.on('close', (code) => finalize(code));
|
|
465
|
+
// apra-fleet-qe83.1.2 (READ SIDE of the fix; rationale in
|
|
466
|
+
// src/services/exit-drain.ts). The SSH twin of the LocalStrategy change in
|
|
467
|
+
// strategy.ts: sshd sends `exit-status` when the command process itself
|
|
468
|
+
// exits, but only closes the channel once every inherited handle on the
|
|
469
|
+
// far side is released -- so one surviving grandchild (sandbox server,
|
|
470
|
+
// orphaned find.exe) holds the channel open indefinitely. On Windows
|
|
471
|
+
// members, treat the remote process exit as completion, drain briefly, then
|
|
472
|
+
// settle; the remote grandchild is left running on purpose.
|
|
473
|
+
if (completesOnProcessExit(getAgentOS(agent))) {
|
|
474
|
+
stream.on('exit', (code) => {
|
|
475
|
+
if (settled || exitDrainTimer)
|
|
476
|
+
return;
|
|
477
|
+
exitDrainTimer = setTimeout(() => {
|
|
478
|
+
if (settled)
|
|
479
|
+
return;
|
|
480
|
+
// Invariant: settle the result before releasing the read ends.
|
|
481
|
+
finalize(code);
|
|
482
|
+
// Release our end of the wedged channel; the remote grandchild is
|
|
483
|
+
// unaffected (closing an ssh2 channel never signals the far side's
|
|
484
|
+
// processes -- see killRemoteTree above for why that is deliberate).
|
|
485
|
+
try {
|
|
486
|
+
stream.close();
|
|
487
|
+
}
|
|
488
|
+
catch { /* best-effort */ }
|
|
489
|
+
}, exitDrainMs());
|
|
490
|
+
// apra-fleet-qe83.6 (VERIFIED: this unref-ed timer can NOT be the
|
|
491
|
+
// last live handle, so unref-ing it cannot strand the promise).
|
|
492
|
+
// The handle that always outlives the drain window here is the ssh2
|
|
493
|
+
// Client's TCP socket: the channel is still open (that is why the
|
|
494
|
+
// drain is running at all), so its connection socket is live, and
|
|
495
|
+
// ssh2 never unrefs it -- `unref` appears nowhere in
|
|
496
|
+
// node_modules/ssh2/lib/client.js (only in http-agents.js and
|
|
497
|
+
// server.js). Measured standalone that this is sufficient: a
|
|
498
|
+
// connected, reading net.Socket with the helper listener process
|
|
499
|
+
// unref-ed gave getActiveResourcesInfo() = [TCPSocketWrap] and an
|
|
500
|
+
// unref-ed 3000 ms timer still fired at 3014 ms -- i.e. the socket
|
|
501
|
+
// alone kept the loop alive with no ref-ed timer present. If the
|
|
502
|
+
// channel had already closed instead, `close` would have settled the
|
|
503
|
+
// promise without this timer. The connection-pool idle timers
|
|
504
|
+
// (resetIdleTimer above) are all unref-ed and are deliberately NOT
|
|
505
|
+
// part of this argument. Caller paths enumerated as for the
|
|
506
|
+
// strategy.ts twin: every execCommand() call site runs inside the
|
|
507
|
+
// long-lived MCP server, except src/cli/watch.ts, which holds a
|
|
508
|
+
// ref-ed setInterval for its watch loop.
|
|
509
|
+
// Residual risk: if the TCP socket dies during the drain window the
|
|
510
|
+
// callback is skipped -- but that path emits 'error', which settles
|
|
511
|
+
// via reject(), so the promise still settles. The narrow uncovered
|
|
512
|
+
// case is a socket destroyed with no 'error' and no 'close'.
|
|
513
|
+
exitDrainTimer.unref();
|
|
514
|
+
});
|
|
515
|
+
}
|
|
275
516
|
stream.on('error', (err) => {
|
|
276
517
|
clearStoredPid(agent.id);
|
|
277
518
|
if (stdoutSpillStream)
|
|
278
519
|
stdoutSpillStream.end();
|
|
279
520
|
if (stderrSpillStream)
|
|
280
521
|
stderrSpillStream.end();
|
|
522
|
+
try {
|
|
523
|
+
stream.close();
|
|
524
|
+
}
|
|
525
|
+
catch { /* best-effort */ }
|
|
281
526
|
settle(() => reject(err));
|
|
282
527
|
});
|
|
283
528
|
if (abortSignal) {
|
|
@@ -294,6 +539,8 @@ export async function execCommand(agent, command, timeoutMs = 30000, maxTotalMs,
|
|
|
294
539
|
else
|
|
295
540
|
abortSignal.addEventListener('abort', onAbort, { once: true });
|
|
296
541
|
}
|
|
542
|
+
}, (err) => {
|
|
543
|
+
settle(() => reject(err));
|
|
297
544
|
});
|
|
298
545
|
});
|
|
299
546
|
}
|
|
@@ -4,14 +4,21 @@ import { getAgent } from '../registry.js';
|
|
|
4
4
|
import { getStrategy } from '../strategy.js';
|
|
5
5
|
import { getAgentOS, getAgentShell, isPosixShell } from '../../utils/agent-helpers.js';
|
|
6
6
|
import { logLine, logWarn } from '../../utils/log-helpers.js';
|
|
7
|
+
import { wrapStallPowerShell, psQuote } from './read-log-tail.js';
|
|
7
8
|
const RETRY_INTERVAL_MS = 10_000;
|
|
8
9
|
const MAX_ATTEMPTS = 4; // initial + 3 retries = 30s total
|
|
9
10
|
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
10
11
|
function toFindNewermt(t0) {
|
|
11
12
|
return new Date(t0).toISOString().slice(0, 19).replace('T', ' ');
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* apra-fleet-uob4: a PowerShell expression for the UTC instant t0, compared
|
|
16
|
+
* against LastWriteTimeUtc. The old Z-less ISO string was parsed as LOCAL
|
|
17
|
+
* time and compared with local LastWriteTime, skewing the cutoff by the
|
|
18
|
+
* host's UTC offset.
|
|
19
|
+
*/
|
|
20
|
+
function toPsUtcDateTime(t0) {
|
|
21
|
+
return `[DateTimeOffset]::Parse('${new Date(t0).toISOString().slice(0, 19)}Z', [Globalization.CultureInfo]::InvariantCulture).UtcDateTime`;
|
|
15
22
|
}
|
|
16
23
|
// --- Local helpers ---
|
|
17
24
|
function findLocalMtimeCandidates(dir, t0) {
|
|
@@ -87,7 +94,7 @@ async function findRemoteMtimeCandidates(agent, dir, t0) {
|
|
|
87
94
|
const shell = getAgentShell(agent);
|
|
88
95
|
const cmd = isPosixShell(os, shell)
|
|
89
96
|
? `find "${dir}" -maxdepth 1 -name "*.jsonl" -newermt "${toFindNewermt(t0)}" 2>/dev/null`
|
|
90
|
-
: `
|
|
97
|
+
: wrapStallPowerShell(`Get-ChildItem -Path '${psQuote(dir)}' -Filter '*.jsonl' -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTimeUtc -gt ${toPsUtcDateTime(t0)} } | ForEach-Object { $_.FullName }`);
|
|
91
98
|
const lines = await execLines(agent, cmd, 10_000);
|
|
92
99
|
return lines.filter(l => l.endsWith('.jsonl'));
|
|
93
100
|
}
|
|
@@ -96,7 +103,7 @@ async function checkRemoteInvToken(agent, candidates, inv) {
|
|
|
96
103
|
const shell = getAgentShell(agent);
|
|
97
104
|
const cmd = isPosixShell(os, shell)
|
|
98
105
|
? `grep -l "\\[${inv}\\]" ${candidates.map(c => `"${c}"`).join(' ')} 2>/dev/null`
|
|
99
|
-
: `
|
|
106
|
+
: wrapStallPowerShell(`Select-String -Pattern '\\[${psQuote(inv)}\\]' -Path @(${candidates.map(c => `'${psQuote(c)}'`).join(',')}) -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Path -Unique`);
|
|
100
107
|
const lines = await execLines(agent, cmd, 5_000);
|
|
101
108
|
return lines.length > 0 ? lines[0] : null;
|
|
102
109
|
}
|
|
@@ -122,7 +129,7 @@ async function tryFindRemote(memberId, agent, t0, inv, logDir, sessionId, provid
|
|
|
122
129
|
const directPath = `${logDir}${sep}${sessionId}.jsonl`;
|
|
123
130
|
const cmd = posix
|
|
124
131
|
? `find "${directPath}" -newermt "${toFindNewermt(t0)}" 2>/dev/null`
|
|
125
|
-
: `
|
|
132
|
+
: wrapStallPowerShell(`Get-Item -Path '${psQuote(directPath)}' -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTimeUtc -gt ${toPsUtcDateTime(t0)} } | ForEach-Object { $_.FullName }`);
|
|
126
133
|
const lines = await execLines(agent, cmd, 5_000);
|
|
127
134
|
return lines.length > 0 ? lines[0] : null;
|
|
128
135
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getStallDetector, StallDetector, type StallEntry } from './stall-detector.js';
|
|
1
|
+
export { getStallDetector, StallDetector, type StallEntry, type StallReason } from './stall-detector.js';
|
|
2
2
|
export { resolveSessionLogPath, resolveSessionLogDir } from './log-path-resolver.js';
|
|
3
3
|
export { readLogTail, type ReadLogResult } from './read-log-tail.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
import { escapePowerShellArgInner } from '../../utils/shell-escape.js';
|
|
2
|
+
/**
|
|
3
|
+
* apra-fleet-uob4: every Windows (non-POSIX) stall command goes through
|
|
4
|
+
* -EncodedCommand. A raw `powershell -c "..."` is re-parsed by the member's
|
|
5
|
+
* outer shell: under powershell.exe (local members, PowerShell-default sshd)
|
|
6
|
+
* `$c`/`$_` were expanded to empty before the inner PowerShell ever ran,
|
|
7
|
+
* turning the script into a parse error. Progress output is silenced so an
|
|
8
|
+
* encoded run does not also emit a `#< CLIXML` progress record on stderr.
|
|
9
|
+
*/
|
|
10
|
+
export declare function wrapStallPowerShell(psScript: string): string;
|
|
11
|
+
/** Interior of a PowerShell single-quoted literal: `'` doubled to `''`. */
|
|
12
|
+
export declare const psQuote: typeof escapePowerShellArgInner;
|
|
13
|
+
/**
|
|
14
|
+
* True when a failed tail read's stderr means "the log file does not exist
|
|
15
|
+
* yet" (benign). A PowerShell parse / command-not-found error is never that,
|
|
16
|
+
* even if its text happens to mention a missing item -- it is a broken
|
|
17
|
+
* command and must surface as a read failure (apra-fleet-uob4).
|
|
18
|
+
*
|
|
19
|
+
* An -EncodedCommand run reports errors as `#< CLIXML` with the message
|
|
20
|
+
* wrapped mid-phrase ("does not _x000D__x000A_</S><S S="Error">exist"), so
|
|
21
|
+
* the XML/line-break markup is flattened to plain spaces before matching.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isLogNotYetCreatedStderr(stderr: string): boolean;
|
|
1
24
|
export interface ReadLogResult {
|
|
2
25
|
lastTimestamp: string | null;
|
|
3
26
|
error?: string;
|
|
@@ -2,6 +2,37 @@ import { getAgent } from '../registry.js';
|
|
|
2
2
|
import { getStrategy } from '../strategy.js';
|
|
3
3
|
import { getAgentOS, getAgentShell, isPosixShell } from '../../utils/agent-helpers.js';
|
|
4
4
|
import { logLine, logWarn } from '../../utils/log-helpers.js';
|
|
5
|
+
import { wrapPowerShellEncoded } from '../../os/windows.js';
|
|
6
|
+
import { escapePowerShellArgInner } from '../../utils/shell-escape.js';
|
|
7
|
+
/**
|
|
8
|
+
* apra-fleet-uob4: every Windows (non-POSIX) stall command goes through
|
|
9
|
+
* -EncodedCommand. A raw `powershell -c "..."` is re-parsed by the member's
|
|
10
|
+
* outer shell: under powershell.exe (local members, PowerShell-default sshd)
|
|
11
|
+
* `$c`/`$_` were expanded to empty before the inner PowerShell ever ran,
|
|
12
|
+
* turning the script into a parse error. Progress output is silenced so an
|
|
13
|
+
* encoded run does not also emit a `#< CLIXML` progress record on stderr.
|
|
14
|
+
*/
|
|
15
|
+
export function wrapStallPowerShell(psScript) {
|
|
16
|
+
return wrapPowerShellEncoded(`$ProgressPreference = 'SilentlyContinue'; ${psScript}`);
|
|
17
|
+
}
|
|
18
|
+
/** Interior of a PowerShell single-quoted literal: `'` doubled to `''`. */
|
|
19
|
+
export const psQuote = escapePowerShellArgInner;
|
|
20
|
+
/**
|
|
21
|
+
* True when a failed tail read's stderr means "the log file does not exist
|
|
22
|
+
* yet" (benign). A PowerShell parse / command-not-found error is never that,
|
|
23
|
+
* even if its text happens to mention a missing item -- it is a broken
|
|
24
|
+
* command and must surface as a read failure (apra-fleet-uob4).
|
|
25
|
+
*
|
|
26
|
+
* An -EncodedCommand run reports errors as `#< CLIXML` with the message
|
|
27
|
+
* wrapped mid-phrase ("does not _x000D__x000A_</S><S S="Error">exist"), so
|
|
28
|
+
* the XML/line-break markup is flattened to plain spaces before matching.
|
|
29
|
+
*/
|
|
30
|
+
export function isLogNotYetCreatedStderr(stderr) {
|
|
31
|
+
const text = stderr.replace(/_x000D__x000A_/g, ' ').replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ');
|
|
32
|
+
if (/ParserError|CommandNotFoundException|is not recognized as/i.test(text))
|
|
33
|
+
return false;
|
|
34
|
+
return /No such file|cannot access|does not exist|ItemNotFoundException/i.test(text);
|
|
35
|
+
}
|
|
5
36
|
export async function readLogTail(memberId, logFilePath) {
|
|
6
37
|
const agent = getAgent(memberId);
|
|
7
38
|
if (!agent) {
|
|
@@ -12,26 +43,36 @@ export async function readLogTail(memberId, logFilePath) {
|
|
|
12
43
|
const shell = getAgentShell(agent);
|
|
13
44
|
const cmd = isPosixShell(os, shell)
|
|
14
45
|
? `tail -c 512 "${logFilePath}"`
|
|
15
|
-
: `
|
|
46
|
+
: wrapStallPowerShell(`Get-Content -Tail 5 -Path '${psQuote(logFilePath)}'`);
|
|
16
47
|
try {
|
|
17
48
|
const strategy = getStrategy(agent);
|
|
18
49
|
const result = await strategy.execCommand(cmd, 5000);
|
|
19
50
|
if (result.code === 0) {
|
|
20
51
|
const lines = result.stdout.split('\n').filter(l => l.trim());
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
52
|
+
// apra-fleet-qe83.2.2: scan backwards for the last entry that actually
|
|
53
|
+
// carries a timestamp, mirroring stall-poller.ts's
|
|
54
|
+
// extractClaudeTimestamp -- inspecting only the very last line missed
|
|
55
|
+
// a dated entry sitting one line above a trailing untimestamped record
|
|
56
|
+
// (e.g. an attachment or a last-prompt entry), exactly the shape of
|
|
57
|
+
// the recorded missed stall.
|
|
58
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(lines[i]);
|
|
61
|
+
const ts = parsed['timestamp'];
|
|
62
|
+
if (typeof ts === 'string') {
|
|
63
|
+
return { lastTimestamp: ts };
|
|
64
|
+
}
|
|
65
|
+
// Entry with no timestamp (e.g. an attachment/last-prompt record)
|
|
66
|
+
// -- keep scanning backwards rather than giving up on the sample.
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// partial line at start of tail -- skip
|
|
70
|
+
}
|
|
31
71
|
}
|
|
72
|
+
return { lastTimestamp: null };
|
|
32
73
|
}
|
|
33
74
|
// File not yet created — not an error per resilience decision
|
|
34
|
-
if (
|
|
75
|
+
if (isLogNotYetCreatedStderr(result.stderr)) {
|
|
35
76
|
return { lastTimestamp: null };
|
|
36
77
|
}
|
|
37
78
|
logWarn('stall_log_read', `readLogTail failed for ${memberId}: code=${result.code} stderr=${result.stderr}`);
|