@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/providers/claude.js
CHANGED
|
@@ -1,11 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { buildResumeFlag, buildSessionIdFlag, encodeClaudeProjectDir, joinForOS, resolveHomeDir } from './provider.js';
|
|
1
|
+
import { escapeForDoubleQuotes } from '../utils/shell-escape.js';
|
|
2
|
+
import { randomBytes } from 'node:crypto';
|
|
3
|
+
import { buildResumeFlag, buildSessionIdFlag, buildForkFlag, encodeClaudeProjectDir, joinForOS, resolveHomeDir, guessedUsageLimitSignal } from './provider.js';
|
|
4
4
|
import { classifyPromptError } from '../utils/prompt-errors.js';
|
|
5
5
|
import { escapeDoubleQuoted } from '../os/os-commands.js';
|
|
6
6
|
import { wrapPowerShellEncoded } from '../os/windows.js';
|
|
7
7
|
import { isPosixShell } from '../utils/agent-helpers.js';
|
|
8
|
-
|
|
8
|
+
import { transformAgentForClaude } from '../cli/agent-transform.js';
|
|
9
|
+
import { claudeMemberDenyRules, joinMemberPath, quotePosixPath, quotePwshPath, readMemberJson, resolveClaudeProjectKey, normalizeProjectKey, LEGACY_MEMBER_MCP_SERVER_NAME, MEMBER_MCP_SERVER_NAME, } from '../services/member-config-io.js';
|
|
10
|
+
import { detectClaudePermissionDenial } from './claude-permission-denial.js';
|
|
11
|
+
/**
|
|
12
|
+
* Whether Claude Code's auto permission mode works with this model. Per the
|
|
13
|
+
* Claude Code permission-modes docs, auto needs Opus 4.6+, Sonnet 4.6+ or
|
|
14
|
+
* Fable; "Older models, including ... Haiku ... are not supported on any
|
|
15
|
+
* provider", and such a session silently starts in Manual (default) mode,
|
|
16
|
+
* which in a headless -p dispatch denies even Edit/Write in the work folder
|
|
17
|
+
* (observed: every haiku dispatch on an unattended=auto member recorded
|
|
18
|
+
* permissionMode "default"). Undefined model = the CLI's default model, which
|
|
19
|
+
* is a supported one.
|
|
20
|
+
*/
|
|
21
|
+
export function claudeModelSupportsAuto(model) {
|
|
22
|
+
if (!model)
|
|
23
|
+
return true;
|
|
24
|
+
const m = model.toLowerCase();
|
|
25
|
+
if (m.includes('haiku'))
|
|
26
|
+
return false;
|
|
27
|
+
if (/claude-3/.test(m))
|
|
28
|
+
return false;
|
|
29
|
+
const v = /claude-(?:sonnet|opus)-(\d+)(?:[-.](\d+))?/.exec(m);
|
|
30
|
+
if (v) {
|
|
31
|
+
const major = Number(v[1]);
|
|
32
|
+
const minor = v[2] !== undefined && v[2].length <= 2 ? Number(v[2]) : 0;
|
|
33
|
+
if (major < 4)
|
|
34
|
+
return false;
|
|
35
|
+
if (major === 4 && minor < 6)
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The ONE place that decides a Claude session's permission mode from the
|
|
42
|
+
* member's unattended setting and the dispatch's model: both the CLI flag
|
|
43
|
+
* (resolvePermissionFlag) and the treatment of a denial (parseResponse) read
|
|
44
|
+
* it. 'auto' on a model without auto support falls back to acceptEdits rather
|
|
45
|
+
* than letting the CLI start the session in the stricter Manual mode.
|
|
46
|
+
*
|
|
47
|
+
* Residual gap: a CLI that drops auto for another reason (a CLI older than
|
|
48
|
+
* 2.1.281, managed disableAutoMode, a classifier outage) still counts as auto
|
|
49
|
+
* here. That errs toward never granting on its denials -- the safe direction.
|
|
50
|
+
*/
|
|
51
|
+
export function claudePermissionMode(unattended, model) {
|
|
52
|
+
if (unattended === 'dangerous')
|
|
53
|
+
return 'bypassPermissions';
|
|
54
|
+
if (unattended === 'auto' && claudeModelSupportsAuto(model))
|
|
55
|
+
return 'auto';
|
|
56
|
+
return 'acceptEdits';
|
|
57
|
+
}
|
|
9
58
|
// apra-fleet-iuc.1 / apra-fleet-ekm: reliable max_turns detection in the CLI
|
|
10
59
|
// transcript. A max_turns-terminated session must ALWAYS classify as max_turns,
|
|
11
60
|
// but the Claude Code CLI signals it INCONSISTENTLY across versions/streams:
|
|
@@ -27,6 +76,140 @@ export function isMaxTurnsSignal(obj) {
|
|
|
27
76
|
obj.type === 'max_turns_reached' ||
|
|
28
77
|
obj.stop_reason === 'max_turns');
|
|
29
78
|
}
|
|
79
|
+
// apra-fleet-hzeb.1: the Claude result event's `api_error_status` carries the
|
|
80
|
+
// upstream HTTP status (e.g. 429) when the CLI terminated on an API error. The
|
|
81
|
+
// parser previously dropped it; capture it (coercing a numeric string) so
|
|
82
|
+
// detectUsageLimit can distinguish a 429 usage limit. Returns undefined when
|
|
83
|
+
// absent or non-numeric.
|
|
84
|
+
export function extractApiErrorStatus(obj) {
|
|
85
|
+
if (!obj || typeof obj !== 'object')
|
|
86
|
+
return undefined;
|
|
87
|
+
const raw = obj.api_error_status;
|
|
88
|
+
if (typeof raw === 'number' && Number.isFinite(raw))
|
|
89
|
+
return raw;
|
|
90
|
+
if (typeof raw === 'string' && raw.trim() !== '' && Number.isFinite(Number(raw)))
|
|
91
|
+
return Number(raw);
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
// apra-fleet-hzeb.1: Claude's own usage-limit message shape, e.g.
|
|
95
|
+
// "You've hit your session limit", "hit your weekly limit", "hit your opus limit".
|
|
96
|
+
const CLAUDE_LIMIT_MESSAGE_RE = /hit your (session|weekly|opus|\w+) limit/i;
|
|
97
|
+
// apra-fleet-hzeb.1.2: Claude's usage-limit message sometimes exposes the actual
|
|
98
|
+
// reset time verbatim, e.g. "resets 8:20am (America/New_York)" or "resets at 8pm
|
|
99
|
+
// (America/New_York)". This wall-clock-plus-IANA-zone shape is the primary parse.
|
|
100
|
+
const CLAUDE_RESET_AT_RE = /resets\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)\s*\(\s*([A-Za-z][A-Za-z0-9_+\-/]*)\s*\)/i;
|
|
101
|
+
// Best-effort relative shape, e.g. "resets in 45 minutes" / "resets in 2 hours".
|
|
102
|
+
const CLAUDE_RESET_IN_RE = /resets\s+in\s+(\d+)\s*(minute|hour)s?/i;
|
|
103
|
+
// Credential-kind prefixes (provision_llm_auth api_key routing).
|
|
104
|
+
const CLAUDE_OAUTH_TOKEN_PREFIX = 'sk-ant-oat';
|
|
105
|
+
const CLAUDE_API_KEY_PREFIX = 'sk-ant-api';
|
|
106
|
+
const CLAUDE_AUTH_ENV_VARS = ['ANTHROPIC_API_KEY', 'CLAUDE_CODE_OAUTH_TOKEN'];
|
|
107
|
+
// apra-fleet-hzeb.1.2: the wall-clock fields of `instant` as observed in
|
|
108
|
+
// `timeZone`, via Intl (no external dependency). `hourCycle: 'h23'` yields
|
|
109
|
+
// 00-23; a few engines still emit '24' for midnight, so normalize it.
|
|
110
|
+
function claudeZoneParts(instant, timeZone) {
|
|
111
|
+
const dtf = new Intl.DateTimeFormat('en-US', {
|
|
112
|
+
timeZone,
|
|
113
|
+
hourCycle: 'h23',
|
|
114
|
+
year: 'numeric',
|
|
115
|
+
month: '2-digit',
|
|
116
|
+
day: '2-digit',
|
|
117
|
+
hour: '2-digit',
|
|
118
|
+
minute: '2-digit',
|
|
119
|
+
second: '2-digit',
|
|
120
|
+
});
|
|
121
|
+
const map = {};
|
|
122
|
+
for (const p of dtf.formatToParts(instant))
|
|
123
|
+
map[p.type] = p.value;
|
|
124
|
+
let hour = Number(map.hour);
|
|
125
|
+
if (hour === 24)
|
|
126
|
+
hour = 0;
|
|
127
|
+
return {
|
|
128
|
+
year: Number(map.year),
|
|
129
|
+
month: Number(map.month),
|
|
130
|
+
day: Number(map.day),
|
|
131
|
+
hour,
|
|
132
|
+
minute: Number(map.minute),
|
|
133
|
+
second: Number(map.second),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
// Offset (ms) between the wall clock in `timeZone` and UTC at `instant`
|
|
137
|
+
// (positive = zone ahead of UTC).
|
|
138
|
+
function claudeZoneOffsetMs(instant, timeZone) {
|
|
139
|
+
const p = claudeZoneParts(instant, timeZone);
|
|
140
|
+
const asUtc = Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute, p.second);
|
|
141
|
+
return asUtc - instant.getTime();
|
|
142
|
+
}
|
|
143
|
+
// UTC epoch ms for a wall-clock time (`y`-`mo`-`d` `h`:`min`, mo 1-based) as it
|
|
144
|
+
// occurs in `timeZone`. The double-offset re-check handles DST boundaries where
|
|
145
|
+
// the offset that applies at the naive guess differs from the offset that
|
|
146
|
+
// actually applies at the resolved instant (spring-forward / fall-back).
|
|
147
|
+
function claudeZonedWallClockToUtc(y, mo, d, h, min, timeZone) {
|
|
148
|
+
const utcGuess = Date.UTC(y, mo - 1, d, h, min, 0);
|
|
149
|
+
const offset1 = claudeZoneOffsetMs(new Date(utcGuess), timeZone);
|
|
150
|
+
let ts = utcGuess - offset1;
|
|
151
|
+
const offset2 = claudeZoneOffsetMs(new Date(ts), timeZone);
|
|
152
|
+
if (offset2 !== offset1)
|
|
153
|
+
ts = utcGuess - offset2;
|
|
154
|
+
return ts;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* apra-fleet-hzeb.1.2: parse a Claude usage-limit reset time from its verbatim
|
|
158
|
+
* message into a concrete instant, so the usage-limit signal can schedule a
|
|
159
|
+
* precise resume instead of guessing now+1h. Pure and deterministic: `now` is
|
|
160
|
+
* injected. Returns null when no reset time is readable -- the caller then falls
|
|
161
|
+
* back to the guessed window (never to a null signal; a 429 is still a usage
|
|
162
|
+
* limit even when its reset time is unreadable).
|
|
163
|
+
*
|
|
164
|
+
* Supported shapes (case-insensitive, best-effort):
|
|
165
|
+
* - "resets 8:20am (America/New_York)" -> the NEXT 08:20 wall-clock in that
|
|
166
|
+
* zone that is >= `now` (DST-correct via Intl offset projection).
|
|
167
|
+
* - "resets at 8pm (America/New_York)" -> same, with an optional "at" and no
|
|
168
|
+
* explicit minutes.
|
|
169
|
+
* - "resets in 45 minutes" / "resets in 2 hours" -> `now` + the stated delta.
|
|
170
|
+
*/
|
|
171
|
+
export function parseClaudeResetTime(text, now) {
|
|
172
|
+
if (!text)
|
|
173
|
+
return null;
|
|
174
|
+
const inM = CLAUDE_RESET_IN_RE.exec(text);
|
|
175
|
+
if (inM) {
|
|
176
|
+
const n = Number(inM[1]);
|
|
177
|
+
if (Number.isFinite(n) && n >= 0) {
|
|
178
|
+
const unitMs = /hour/i.test(inM[2]) ? 60 * 60 * 1000 : 60 * 1000;
|
|
179
|
+
return new Date(now.getTime() + n * unitMs);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const atM = CLAUDE_RESET_AT_RE.exec(text);
|
|
183
|
+
if (atM) {
|
|
184
|
+
let hour = Number(atM[1]);
|
|
185
|
+
const minute = atM[2] ? Number(atM[2]) : 0;
|
|
186
|
+
const ampm = atM[3].toLowerCase();
|
|
187
|
+
const timeZone = atM[4].trim();
|
|
188
|
+
if (hour < 1 || hour > 12 || minute > 59)
|
|
189
|
+
return null;
|
|
190
|
+
// 12-hour -> 24-hour: 12am -> 0, 12pm -> 12, otherwise +12 for pm.
|
|
191
|
+
if (ampm === 'am')
|
|
192
|
+
hour = hour === 12 ? 0 : hour;
|
|
193
|
+
else
|
|
194
|
+
hour = hour === 12 ? 12 : hour + 12;
|
|
195
|
+
// Reject an unknown IANA zone (Intl throws on construction) -> guessed.
|
|
196
|
+
try {
|
|
197
|
+
new Intl.DateTimeFormat('en-US', { timeZone });
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
const today = claudeZoneParts(now, timeZone);
|
|
203
|
+
let ts = claudeZonedWallClockToUtc(today.year, today.month, today.day, hour, minute, timeZone);
|
|
204
|
+
if (ts < now.getTime()) {
|
|
205
|
+
// Already passed today in that zone; advance to the next calendar day
|
|
206
|
+
// (Date.UTC normalizes day overflow before we re-project through the zone).
|
|
207
|
+
ts = claudeZonedWallClockToUtc(today.year, today.month, today.day + 1, hour, minute, timeZone);
|
|
208
|
+
}
|
|
209
|
+
return new Date(ts);
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
30
213
|
export class ClaudeProvider {
|
|
31
214
|
name = 'claude';
|
|
32
215
|
processName = 'claude';
|
|
@@ -75,14 +258,37 @@ export class ClaudeProvider {
|
|
|
75
258
|
else if (sessionId) {
|
|
76
259
|
cmd += ` ${buildSessionIdFlag(sessionId)}`;
|
|
77
260
|
}
|
|
78
|
-
const permFlag = this.resolvePermissionFlag(unattended);
|
|
261
|
+
const permFlag = this.resolvePermissionFlag(unattended, model);
|
|
79
262
|
if (permFlag)
|
|
80
263
|
cmd += ` ${permFlag}`;
|
|
81
264
|
if (model) {
|
|
82
265
|
cmd += ` --model "${escapeDoubleQuoted(model)}"`;
|
|
83
266
|
}
|
|
267
|
+
// Per-session member MCP config. Appended LAST: --mcp-config is variadic,
|
|
268
|
+
// so it must never precede the positional prompt.
|
|
269
|
+
if (opts.mcpConfigPath) {
|
|
270
|
+
cmd += ` ${this.mcpConfigFlag(opts.mcpConfigPath, true)}`;
|
|
271
|
+
}
|
|
84
272
|
return cmd;
|
|
85
273
|
}
|
|
274
|
+
mcpConfigFlag(absPath, posix) {
|
|
275
|
+
return `--mcp-config ${posix ? quotePosixPath(absPath) : quotePwshPath(absPath.replace(/\//g, '\\'))}`;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Claude Code defers MCP tools behind its tool-search tool, so a role
|
|
279
|
+
* session would have to discover kb_* / code_* before calling them. A
|
|
280
|
+
* `--mcp-config` server entry with `alwaysLoad: true` keeps that server's
|
|
281
|
+
* tools loaded from the first turn (per server, so other servers keep
|
|
282
|
+
* their deferral). The non-deferral mechanism therefore lives in the config
|
|
283
|
+
* file the --mcp-config flag names -- no env var or extra flag in the
|
|
284
|
+
* member command string. Relied on: Claude Code 2.1.291 (verified that its
|
|
285
|
+
* --mcp-config schema accepts alwaysLoad and that the key is present in
|
|
286
|
+
* 2.1.288-2.1.291); 2.1.288 is the oldest version verified, so it is the
|
|
287
|
+
* floor. Older CLIs get the config without the key and a dispatch WARN.
|
|
288
|
+
*/
|
|
289
|
+
mcpAlwaysLoadMinVersion() {
|
|
290
|
+
return '2.1.288';
|
|
291
|
+
}
|
|
86
292
|
skipPermissionsFlag() {
|
|
87
293
|
return '--dangerously-skip-permissions';
|
|
88
294
|
}
|
|
@@ -95,10 +301,13 @@ export class ClaudeProvider {
|
|
|
95
301
|
// prompt) WITHOUT the broad --dangerously-skip-permissions bypass.
|
|
96
302
|
return '--permission-mode acceptEdits';
|
|
97
303
|
}
|
|
98
|
-
resolvePermissionFlag(unattended) {
|
|
99
|
-
|
|
304
|
+
resolvePermissionFlag(unattended, model) {
|
|
305
|
+
// One mode function decides both the flag and how a denial from the
|
|
306
|
+
// session is treated (parseResponse), so the two cannot drift apart.
|
|
307
|
+
const mode = claudePermissionMode(unattended, model);
|
|
308
|
+
if (mode === 'auto')
|
|
100
309
|
return '--permission-mode auto';
|
|
101
|
-
if (
|
|
310
|
+
if (mode === 'bypassPermissions')
|
|
102
311
|
return '--dangerously-skip-permissions';
|
|
103
312
|
// apra-fleet-eft.65.1: interactive-session parity for the work folder.
|
|
104
313
|
// A headless `-p` dispatch cannot present a permission prompt, so with no
|
|
@@ -111,11 +320,70 @@ export class ClaudeProvider {
|
|
|
111
320
|
// broadening the permission model (unlike --dangerously-skip-permissions).
|
|
112
321
|
return this.workspaceEditPermissionFlag() ?? '';
|
|
113
322
|
}
|
|
114
|
-
|
|
323
|
+
/** Parses the run's result and, when Claude refused tool calls (a
|
|
324
|
+
* non-empty permission_denials on the result event), attaches the denial
|
|
325
|
+
* with the session's permission mode. In acceptEdits mode a refusal is a
|
|
326
|
+
* missing allow rule (healable by a grant); in auto or bypass mode it comes
|
|
327
|
+
* from the safety classifier or a deny rule and is never healable
|
|
328
|
+
* (execute_prompt reports it as a warning when the reply is complete). */
|
|
329
|
+
parseResponse(result, ctx) {
|
|
330
|
+
const parsed = this.parseResult(result);
|
|
331
|
+
const denial = detectClaudePermissionDenial(result.stdout);
|
|
332
|
+
if (denial) {
|
|
333
|
+
const mode = claudePermissionMode(ctx?.unattended, ctx?.model);
|
|
334
|
+
denial.permissionMode = mode;
|
|
335
|
+
// A refusal of a fleet tool outside the member allowlist hit one of the
|
|
336
|
+
// deny rules compose writes on purpose (claudeMemberDenyRules), in ANY
|
|
337
|
+
// mode: it is policy, never a missing grant. One such call makes the
|
|
338
|
+
// whole denial non-healable -- a grant must never override the member
|
|
339
|
+
// tool policy, and suggestedGrants stays empty whenever healable is
|
|
340
|
+
// false -- so a complete reply is a warning and the heal never runs.
|
|
341
|
+
const policyRules = new Set(claudeMemberDenyRules());
|
|
342
|
+
const policyCalls = denial.denials.filter(d => policyRules.has(d.action));
|
|
343
|
+
if (policyCalls.length > 0) {
|
|
344
|
+
denial.healable = false;
|
|
345
|
+
denial.cause = 'policy_deny';
|
|
346
|
+
denial.suggestedGrants = [];
|
|
347
|
+
for (const d of denial.denials)
|
|
348
|
+
d.suggestedGrants = [];
|
|
349
|
+
const tools = [...new Set(policyCalls.map(d => d.action))].join(', ');
|
|
350
|
+
const what = denial.denials.map(d => (d.target ? `${d.action} "${d.target}"` : d.action)).join(', ');
|
|
351
|
+
denial.hint = `claude (${mode} mode) refused ${what}: ${tools} ${policyCalls.length === 1 ? 'is a fleet tool' : 'are fleet tools'} outside the member tool allowlist, denied by the member's own permission config on purpose. A member session may only use the knowledge-bank and code-intelligence tools; no grant is ever added for this. Do the work without ${policyCalls.length === 1 ? 'that tool' : 'those tools'}.`;
|
|
352
|
+
parsed.permissionDenial = denial;
|
|
353
|
+
return parsed;
|
|
354
|
+
}
|
|
355
|
+
denial.healable = mode === 'acceptEdits';
|
|
356
|
+
if (!denial.healable) {
|
|
357
|
+
// A classifier or deny-rule refusal must never come with a
|
|
358
|
+
// ready-to-paste grant: blank every suggestion, overall and per call.
|
|
359
|
+
denial.suggestedGrants = [];
|
|
360
|
+
for (const d of denial.denials)
|
|
361
|
+
d.suggestedGrants = [];
|
|
362
|
+
const what = denial.denials.map(d => (d.target ? `${d.action} "${d.target}"` : d.action)).join(', ');
|
|
363
|
+
denial.hint = `claude (${mode} mode) refused ${what}: in this mode a refusal comes from the safety classifier or a deny rule, not from a missing grant, so no grant is ever added for it automatically. Review the refused calls; change the member's permissions by hand only if the action is really intended.`;
|
|
364
|
+
}
|
|
365
|
+
parsed.permissionDenial = denial;
|
|
366
|
+
}
|
|
367
|
+
return parsed;
|
|
368
|
+
}
|
|
369
|
+
parseResult(result) {
|
|
115
370
|
const raw = result.stdout.trim();
|
|
371
|
+
// Claude reports prompt-cache traffic in two fields separate from (not
|
|
372
|
+
// included in) input_tokens; both are billed, so they are carried through
|
|
373
|
+
// (0 when the CLI omits them) for cost/budget accounting downstream.
|
|
374
|
+
const cacheCount = (n) => (typeof n === 'number' && Number.isFinite(n) && n > 0 ? n : 0);
|
|
116
375
|
const extractUsage = (u) => u && typeof u.input_tokens === 'number' && typeof u.output_tokens === 'number'
|
|
117
|
-
? {
|
|
376
|
+
? {
|
|
377
|
+
input_tokens: u.input_tokens,
|
|
378
|
+
output_tokens: u.output_tokens,
|
|
379
|
+
cache_read_input_tokens: cacheCount(u.cache_read_input_tokens),
|
|
380
|
+
cache_creation_input_tokens: cacheCount(u.cache_creation_input_tokens),
|
|
381
|
+
}
|
|
118
382
|
: undefined;
|
|
383
|
+
// The CLI's own cost figure (list price, model- and cache-TTL-correct).
|
|
384
|
+
// CUMULATIVE for the session across --resume; execute_prompt turns it into
|
|
385
|
+
// the dispatch's delta (services/session-cost.ts).
|
|
386
|
+
const extractCost = (c) => (typeof c === 'number' && Number.isFinite(c) && c >= 0 ? c : undefined);
|
|
119
387
|
// apra-fleet-eft.28.6: first non-blank string wins. Used so an EMPTY
|
|
120
388
|
// (present-but-blank) result field on the `type:result` event falls back to
|
|
121
389
|
// the assistant text we harvested from the stream, instead of being kept as
|
|
@@ -161,8 +429,10 @@ export class ClaudeProvider {
|
|
|
161
429
|
isError: obj.is_error === true || obj.subtype === 'error' || result.code !== 0,
|
|
162
430
|
raw,
|
|
163
431
|
usage: extractUsage(obj.usage),
|
|
432
|
+
sessionCostUsd: extractCost(obj.total_cost_usd),
|
|
164
433
|
subtype: obj.subtype,
|
|
165
434
|
terminalReason: obj.terminal_reason ?? (maxTurns ? 'max_turns' : undefined),
|
|
435
|
+
apiErrorStatus: extractApiErrorStatus(obj),
|
|
166
436
|
};
|
|
167
437
|
};
|
|
168
438
|
try {
|
|
@@ -188,8 +458,10 @@ export class ClaudeProvider {
|
|
|
188
458
|
isError: parsed.is_error === true || result.code !== 0,
|
|
189
459
|
raw,
|
|
190
460
|
usage: extractUsage(parsed.usage),
|
|
461
|
+
sessionCostUsd: extractCost(parsed.total_cost_usd),
|
|
191
462
|
subtype: parsed.subtype,
|
|
192
463
|
terminalReason: parsed.terminal_reason ?? (maxTurns ? 'max_turns' : undefined),
|
|
464
|
+
apiErrorStatus: extractApiErrorStatus(parsed),
|
|
193
465
|
};
|
|
194
466
|
}
|
|
195
467
|
}
|
|
@@ -223,6 +495,36 @@ export class ClaudeProvider {
|
|
|
223
495
|
terminalReason: maxTurnsSeen ? 'max_turns' : undefined,
|
|
224
496
|
};
|
|
225
497
|
}
|
|
498
|
+
// apra-fleet-hzeb.1 / hzeb.1.2: Claude signals a usage limit via a 429
|
|
499
|
+
// api_error_status OR a terminal_reason of 'api_error' -- independent of process
|
|
500
|
+
// exit code (exit 1 with is_error, OR exit 0 carrying the message as the result
|
|
501
|
+
// text). A 429 is definitively a usage/quota limit on its own; the broader
|
|
502
|
+
// 'api_error' terminal reason can mean other things, so there we additionally
|
|
503
|
+
// require Claude's own "hit your <...> limit" message to avoid misclassifying an
|
|
504
|
+
// unrelated API error. When the message exposes a real reset time we parse it
|
|
505
|
+
// into a concrete `resumeAt` (source 'parsed'); otherwise we fall back to the
|
|
506
|
+
// guessed window (source 'guessed') -- NEVER to null, since a 429 is still a
|
|
507
|
+
// usage limit even when its reset time is unreadable.
|
|
508
|
+
detectUsageLimit(_result, parsed) {
|
|
509
|
+
const is429 = parsed.apiErrorStatus === 429;
|
|
510
|
+
const isApiErrorTerminal = parsed.terminalReason === 'api_error';
|
|
511
|
+
if (!is429 && !isApiErrorTerminal)
|
|
512
|
+
return null;
|
|
513
|
+
const text = parsed.result ?? '';
|
|
514
|
+
if (!is429 && !CLAUDE_LIMIT_MESSAGE_RE.test(text))
|
|
515
|
+
return null;
|
|
516
|
+
const now = new Date();
|
|
517
|
+
const parsedReset = parseClaudeResetTime(text, now);
|
|
518
|
+
if (parsedReset) {
|
|
519
|
+
return {
|
|
520
|
+
type: 'usage_limit',
|
|
521
|
+
resumeAt: parsedReset.toISOString(),
|
|
522
|
+
resumeAtSource: 'parsed',
|
|
523
|
+
message: text,
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
return guessedUsageLimitSignal(text, now.getTime());
|
|
527
|
+
}
|
|
226
528
|
supportsResume() {
|
|
227
529
|
return true;
|
|
228
530
|
}
|
|
@@ -237,18 +539,41 @@ export class ClaudeProvider {
|
|
|
237
539
|
sessionIdStrategy() {
|
|
238
540
|
return { type: 'caller-minted' };
|
|
239
541
|
}
|
|
542
|
+
// apra-fleet-25yl.2.1: a headless `claude -p` dispatch is batch-only -- it
|
|
543
|
+
// emits nothing on the exec channel until the whole turn is done, so a
|
|
544
|
+
// `timeout_s`-sized rolling deadline on that channel is a false kill, not a
|
|
545
|
+
// stall signal. Claude's real mechanism is the StallDetector polling the
|
|
546
|
+
// session transcript (resolveSessionLogPath below returns a real file), and
|
|
547
|
+
// that still receives `timeout_s` as its thresholdMs.
|
|
548
|
+
execTimeoutSource() {
|
|
549
|
+
return 'total_ceiling';
|
|
550
|
+
}
|
|
551
|
+
// apra-fleet-lmtg.1: Claude Code's CLI supports fork-mode dispatch natively
|
|
552
|
+
// via `--resume <source> --fork-session` -- per `claude --help`, --fork-session
|
|
553
|
+
// "When resuming, create a new session ID instead of reusing the original".
|
|
554
|
+
// The CLI honors a caller-supplied `--session-id` even in fork mode, so we
|
|
555
|
+
// pre-mint the forked session's id (same as a plain caller-minted dispatch)
|
|
556
|
+
// and pass it explicitly rather than letting the CLI mint its own and
|
|
557
|
+
// scraping it out of the response afterward. The source session is left
|
|
558
|
+
// untouched; only the forked dispatch continues under the new id.
|
|
559
|
+
supportsFork() {
|
|
560
|
+
return true;
|
|
561
|
+
}
|
|
562
|
+
forkFlag(sourceSessionId, newSessionId) {
|
|
563
|
+
return buildForkFlag(sourceSessionId, newSessionId);
|
|
564
|
+
}
|
|
240
565
|
resolveSessionLogPath(sessionId, workFolder, homeDir, targetOs) {
|
|
241
566
|
const home = resolveHomeDir(homeDir);
|
|
242
567
|
if (!home)
|
|
243
568
|
return '';
|
|
244
|
-
const encoded = encodeClaudeProjectDir(workFolder);
|
|
569
|
+
const encoded = encodeClaudeProjectDir(workFolder, targetOs ? targetOs === 'windows' : process.platform === 'win32');
|
|
245
570
|
return joinForOS(targetOs, home, '.claude', 'projects', encoded, `${sessionId}.jsonl`);
|
|
246
571
|
}
|
|
247
572
|
resolveSessionLogDir(workFolder, homeDir, targetOs) {
|
|
248
573
|
const home = resolveHomeDir(homeDir);
|
|
249
574
|
if (!home)
|
|
250
575
|
return null;
|
|
251
|
-
const encoded = encodeClaudeProjectDir(workFolder);
|
|
576
|
+
const encoded = encodeClaudeProjectDir(workFolder, targetOs ? targetOs === 'windows' : process.platform === 'win32');
|
|
252
577
|
return joinForOS(targetOs, home, '.claude', 'projects', encoded);
|
|
253
578
|
}
|
|
254
579
|
// Bare family aliases -- the claude CLI resolves these to the current
|
|
@@ -276,8 +601,9 @@ export class ClaudeProvider {
|
|
|
276
601
|
const rel = `.claude/agents/${agentName}.md`;
|
|
277
602
|
return { project: rel, home: rel };
|
|
278
603
|
}
|
|
279
|
-
transformAgent(content,
|
|
280
|
-
|
|
604
|
+
transformAgent(content, relPath) {
|
|
605
|
+
// Same resolver the local install uses for this provider, so remote == local.
|
|
606
|
+
return transformAgentForClaude(content, relPath);
|
|
281
607
|
}
|
|
282
608
|
agentNameFlag(agentName) {
|
|
283
609
|
return `--agent "${escapeDoubleQuoted(agentName)}"`;
|
|
@@ -288,8 +614,103 @@ export class ClaudeProvider {
|
|
|
288
614
|
permissionConfigPaths() {
|
|
289
615
|
return ['.claude/settings.local.json'];
|
|
290
616
|
}
|
|
617
|
+
// The member's apra-fleet MCP entry is NOT written here: it lives in Claude's
|
|
618
|
+
// LOCAL scope (~/.claude.json projects[<repo root of workFolder>].mcpServers), written by
|
|
619
|
+
// syncMemberMcpEntry. This file only carries the client-side deny rules for
|
|
620
|
+
// every registered fleet tool outside the member allowlist.
|
|
291
621
|
composePermissionConfig(_role, allow = []) {
|
|
292
|
-
return [{ permissions: { allow
|
|
622
|
+
return [{ permissions: { allow, deny: claudeMemberDenyRules() }, skillOverrides: { pm: 'off', fleet: 'off' } }];
|
|
623
|
+
}
|
|
624
|
+
async syncMemberMcpEntry(ctx) {
|
|
625
|
+
const { agent, url } = ctx;
|
|
626
|
+
const posix = isPosixShell(ctx.agentOs, ctx.shell);
|
|
627
|
+
const isWindows = ctx.agentOs === 'windows';
|
|
628
|
+
const configDir = await probeMemberClaudeConfigDir(ctx.execCommand, ctx.agentOs, ctx.shell);
|
|
629
|
+
const target = claudeLocalScopeConfigFile(configDir, ctx.memberHomeDir, isWindows, ctx.shell);
|
|
630
|
+
const exec = checkedExec(ctx.execCommand);
|
|
631
|
+
const config = await readMemberJson(ctx.execCommand, target.file, posix);
|
|
632
|
+
// Claude Code keys local-scope servers by the git repository ROOT of the
|
|
633
|
+
// folder (the exact folder only outside a git repo) -- the same resolver
|
|
634
|
+
// the fleetMcp probe reads back with.
|
|
635
|
+
const key = await resolveClaudeProjectKey(exec, agent.workFolder, isWindows, posix);
|
|
636
|
+
let changed = false;
|
|
637
|
+
// User-scope legacy entry (top-level mcpServers).
|
|
638
|
+
const userServers = config.mcpServers;
|
|
639
|
+
if (isRecord(userServers) && LEGACY_MEMBER_MCP_SERVER_NAME in userServers) {
|
|
640
|
+
delete userServers[LEGACY_MEMBER_MCP_SERVER_NAME];
|
|
641
|
+
changed = true;
|
|
642
|
+
}
|
|
643
|
+
const projects = isRecord(config.projects) ? config.projects : {};
|
|
644
|
+
const entry = isRecord(projects[key]) ? projects[key] : null;
|
|
645
|
+
if (url !== null || entry) {
|
|
646
|
+
const project = entry ?? {};
|
|
647
|
+
const servers = isRecord(project.mcpServers) ? project.mcpServers : {};
|
|
648
|
+
if (LEGACY_MEMBER_MCP_SERVER_NAME in servers) {
|
|
649
|
+
delete servers[LEGACY_MEMBER_MCP_SERVER_NAME];
|
|
650
|
+
changed = true;
|
|
651
|
+
}
|
|
652
|
+
if (url !== null) {
|
|
653
|
+
const current = servers[MEMBER_MCP_SERVER_NAME];
|
|
654
|
+
const wanted = { type: 'http', url, ...(ctx.headers ? { headers: ctx.headers } : {}) };
|
|
655
|
+
if (!isRecord(current) || JSON.stringify(current) !== JSON.stringify(wanted)) {
|
|
656
|
+
servers[MEMBER_MCP_SERVER_NAME] = wanted;
|
|
657
|
+
changed = true;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
else if (MEMBER_MCP_SERVER_NAME in servers) {
|
|
661
|
+
const current = servers[MEMBER_MCP_SERVER_NAME];
|
|
662
|
+
const own = isRecord(current) && typeof current.url === 'string'
|
|
663
|
+
&& current.url.endsWith(`?member=${encodeURIComponent(agent.id)}`);
|
|
664
|
+
if (!ctx.removeOnlyOwnEntry || own) {
|
|
665
|
+
delete servers[MEMBER_MCP_SERVER_NAME];
|
|
666
|
+
changed = true;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
project.mcpServers = servers;
|
|
670
|
+
projects[key] = project;
|
|
671
|
+
config.projects = projects;
|
|
672
|
+
}
|
|
673
|
+
// An older compose keyed the entry by the work folder exactly as
|
|
674
|
+
// registered. The resolved key differs when the folder sits below its
|
|
675
|
+
// repository root, or when git reports the root symlink-resolved
|
|
676
|
+
// (macOS /var -> /private/var). Clean up what this member left
|
|
677
|
+
// under that spelling: the legacy entry and its OWN apra-fleet entry,
|
|
678
|
+
// never someone else's.
|
|
679
|
+
const folderKey = normalizeProjectKey(agent.workFolder);
|
|
680
|
+
const aliased = folderKey !== key && isRecord(projects[folderKey]) ? projects[folderKey] : null;
|
|
681
|
+
if (aliased && isRecord(aliased.mcpServers)) {
|
|
682
|
+
const servers = aliased.mcpServers;
|
|
683
|
+
if (LEGACY_MEMBER_MCP_SERVER_NAME in servers) {
|
|
684
|
+
delete servers[LEGACY_MEMBER_MCP_SERVER_NAME];
|
|
685
|
+
changed = true;
|
|
686
|
+
}
|
|
687
|
+
const stale = servers[MEMBER_MCP_SERVER_NAME];
|
|
688
|
+
if (isRecord(stale) && typeof stale.url === 'string' && stale.url.endsWith(`?member=${encodeURIComponent(agent.id)}`)) {
|
|
689
|
+
delete servers[MEMBER_MCP_SERVER_NAME];
|
|
690
|
+
changed = true;
|
|
691
|
+
}
|
|
692
|
+
config.projects = projects;
|
|
693
|
+
}
|
|
694
|
+
if (!changed) {
|
|
695
|
+
return { workFolderFiles: [], detail: `claude: ${target.file} already up to date for ${key}` };
|
|
696
|
+
}
|
|
697
|
+
const staging = workspaceTrustStagingNames();
|
|
698
|
+
await deliverWorkspaceTrustFile(JSON.stringify(config, null, 2), {
|
|
699
|
+
isWindows: !posix,
|
|
700
|
+
agentOs: ctx.agentOs,
|
|
701
|
+
execCommand: exec,
|
|
702
|
+
// The file channel writes relative to the member's HOME, so it only fits
|
|
703
|
+
// when the config file is home-anchored (not a CLAUDE_CONFIG_DIR override).
|
|
704
|
+
transport: target.homeAnchored ? ctx.transport : undefined,
|
|
705
|
+
// Embedded inside "..." in the delivery commands: escape what is live
|
|
706
|
+
// there for the member's shell (the read above quotes the path itself).
|
|
707
|
+
homeFile: escapeForDoubleQuotes(target.file, !posix),
|
|
708
|
+
tmpFile: escapeForDoubleQuotes(joinMemberPath(target.dir, staging.tmpRel, isWindows, ctx.shell), !posix),
|
|
709
|
+
staging,
|
|
710
|
+
secretChannel: ctx.secretChannel,
|
|
711
|
+
});
|
|
712
|
+
const what = url !== null ? `wrote ${MEMBER_MCP_SERVER_NAME} (local scope)` : `removed ${MEMBER_MCP_SERVER_NAME}`;
|
|
713
|
+
return { workFolderFiles: [], detail: `claude: ${what} for ${key} in ${target.file}` };
|
|
293
714
|
}
|
|
294
715
|
supportsOAuthCopy() {
|
|
295
716
|
return true;
|
|
@@ -303,11 +724,41 @@ export class ClaudeProvider {
|
|
|
303
724
|
oauthSettingsMerge() {
|
|
304
725
|
return null;
|
|
305
726
|
}
|
|
727
|
+
// A plain OAuth-file copy leaves Claude env credentials alone: it also runs
|
|
728
|
+
// automatically (cloud start, sprint self-heal) and must never erase an
|
|
729
|
+
// operator-provisioned token. Clearing them is the explicit
|
|
730
|
+
// force_oauth_copy path in provision_llm_auth (via authEnvVarNames).
|
|
306
731
|
oauthEnvVarsToUnset() {
|
|
307
732
|
return [];
|
|
308
733
|
}
|
|
734
|
+
// Kind is decided by prefix: sk-ant-oat... is a Claude Code OAuth token
|
|
735
|
+
// (`claude setup-token`) and belongs in CLAUDE_CODE_OAUTH_TOKEN; sk-ant-api...
|
|
736
|
+
// is an Anthropic API key (ANTHROPIC_API_KEY). Any other sk-ant- shape keeps
|
|
737
|
+
// the legacy API-key routing and any non-sk-ant token the legacy OAuth
|
|
738
|
+
// routing -- authTokenKindWarning flags both as guesses. Pure: preflight
|
|
739
|
+
// probes this with fake tokens.
|
|
309
740
|
authEnvVarForToken(token) {
|
|
310
|
-
|
|
741
|
+
const t = token.trim();
|
|
742
|
+
if (t.startsWith(CLAUDE_OAUTH_TOKEN_PREFIX))
|
|
743
|
+
return 'CLAUDE_CODE_OAUTH_TOKEN';
|
|
744
|
+
if (t.startsWith('sk-ant-'))
|
|
745
|
+
return 'ANTHROPIC_API_KEY';
|
|
746
|
+
return 'CLAUDE_CODE_OAUTH_TOKEN';
|
|
747
|
+
}
|
|
748
|
+
authEnvVarNames() {
|
|
749
|
+
return [...CLAUDE_AUTH_ENV_VARS];
|
|
750
|
+
}
|
|
751
|
+
authTokenKindWarning(token) {
|
|
752
|
+
const t = token.trim();
|
|
753
|
+
if (t.startsWith(CLAUDE_OAUTH_TOKEN_PREFIX) || t.startsWith(CLAUDE_API_KEY_PREFIX))
|
|
754
|
+
return null;
|
|
755
|
+
return `Unrecognised Claude credential prefix -- expected ${CLAUDE_OAUTH_TOKEN_PREFIX}... (Claude Code OAuth token from \`claude setup-token\`, set as CLAUDE_CODE_OAUTH_TOKEN) or ${CLAUDE_API_KEY_PREFIX}... (Anthropic API key, set as ANTHROPIC_API_KEY). Deployed as ${this.authEnvVarForToken(t)}; check the value if auth fails.`;
|
|
756
|
+
}
|
|
757
|
+
// Only an OAuth token replaces the /login file. A real API key leaves it in
|
|
758
|
+
// place: on a shared member it may be a human's own login, and either env
|
|
759
|
+
// var outranks the file anyway.
|
|
760
|
+
credentialFilesSupersededByEnvToken(token) {
|
|
761
|
+
return token.trim().startsWith(CLAUDE_OAUTH_TOKEN_PREFIX) ? ['~/.claude/.credentials.json'] : [];
|
|
311
762
|
}
|
|
312
763
|
wrapWindowsPrompt(setupCmd, filePath, argList, _sessionId, _model) {
|
|
313
764
|
// Native claude.exe (2.1.113+) does not inherit stdout via ProcessStartInfo.
|
|
@@ -321,29 +772,7 @@ export class ClaudeProvider {
|
|
|
321
772
|
headlessInvocation(promptLiteral) {
|
|
322
773
|
return `-p "${promptLiteral}"`;
|
|
323
774
|
}
|
|
324
|
-
async
|
|
325
|
-
// Live-verified (apra-fleet-2xs.5, docs/member-onboarding-journey.md 3a): `claude
|
|
326
|
-
// mcp add` is Claude's own native registration mechanism -- it writes .mcp.json
|
|
327
|
-
// (project scope) or the user-scope config itself, round-tripping the bearer
|
|
328
|
-
// header intact. Shelling out here (rather than hand-writing .mcp.json) means
|
|
329
|
-
// future changes to Claude Code's config format are Anthropic's problem, not
|
|
330
|
-
// ours, and it composes correctly with whatever the user does afterward via the
|
|
331
|
-
// same CLI.
|
|
332
|
-
const args = [
|
|
333
|
-
'mcp', 'add',
|
|
334
|
-
'--transport', 'http',
|
|
335
|
-
'--scope', opts.scope,
|
|
336
|
-
'apra-fleet-member',
|
|
337
|
-
opts.url,
|
|
338
|
-
'--header', `Authorization: Bearer ${opts.token}`,
|
|
339
|
-
];
|
|
340
|
-
await execFileAsync('claude', args, { cwd: opts.workFolder });
|
|
341
|
-
return {
|
|
342
|
-
mechanism: 'cli-verb',
|
|
343
|
-
detail: `claude mcp add --transport http --scope ${opts.scope} apra-fleet-member <url> (cwd=${opts.workFolder})`,
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
async ensureWorkspaceTrusted(workFolder, execCommand, agentOs = 'linux', shell) {
|
|
775
|
+
async ensureWorkspaceTrusted(workFolder, execCommand, agentOs = 'linux', shell, transport, memberHomeDir, secretChannel) {
|
|
347
776
|
// apra-fleet-eft.40: Claude gates project-scoped permissions.allow entries on
|
|
348
777
|
// projects[<key>].hasTrustDialogAccepted in the member-side ~/.claude.json -- an
|
|
349
778
|
// untrusted workspace silently DROPS them (not merely a cosmetic warning), degrading
|
|
@@ -366,18 +795,44 @@ export class ClaudeProvider {
|
|
|
366
795
|
// byte-identical PowerShell strings it got before.
|
|
367
796
|
const usePosix = isPosixShell(agentOs, shell);
|
|
368
797
|
const isWindows = !usePosix;
|
|
369
|
-
const
|
|
370
|
-
|
|
798
|
+
const staging = workspaceTrustStagingNames();
|
|
799
|
+
// Every member-side path is resolved HERE, from the JS-resolved member home
|
|
800
|
+
// -- never left to the member shell ($env:USERPROFILE / $HOME). A shell
|
|
801
|
+
// expansion can resolve a different home than the one the file channel
|
|
802
|
+
// (getMemberHomeDir) writes to, so the read, the staged write and the move
|
|
803
|
+
// would address different files. No resolved home -> refuse, loudly.
|
|
804
|
+
const resolvedHome = memberHomeDir ? memberHomeDir.trim() : '';
|
|
805
|
+
if (!resolvedHome) {
|
|
806
|
+
const detail = 'E-MEMBER-HOME-UNRESOLVED: the member home directory could not be resolved, so its ~/.claude.json cannot be located; workspace trust NOT seeded';
|
|
807
|
+
console.error(`[claude] workspace trust: ${detail}`);
|
|
808
|
+
return { seeded: false, detail, mcpServersSeeded: [] };
|
|
809
|
+
}
|
|
810
|
+
// Every path below is embedded inside "..." in a member-bound command, and
|
|
811
|
+
// the resolved home is environment-derived (os.homedir() for a local
|
|
812
|
+
// member), so escape what is live inside double quotes for the target shell.
|
|
813
|
+
const homeDir = escapeForDoubleQuotes(isWindows
|
|
814
|
+
? resolvedHome.replace(/\//g, '\\').replace(/\\+$/, '')
|
|
815
|
+
: resolvedHome.replace(/\\/g, '/').replace(/\/+$/, ''), isWindows);
|
|
816
|
+
const inHome = (rel) => (isWindows ? `${homeDir}\\${rel}` : `${homeDir}/${rel}`);
|
|
817
|
+
const homeFile = inHome('.claude.json');
|
|
818
|
+
const tmpFile = inHome(staging.tmpRel);
|
|
371
819
|
// apra-fleet-9oo: the project's .mcp.json lives in the MEMBER's work folder, not on
|
|
372
820
|
// the orchestrator host, so it must be read through the same execCommand channel --
|
|
373
821
|
// never local node:fs. It rides along in the SAME read command as ~/.claude.json:
|
|
374
822
|
// one round-trip, and (crucially) the already-satisfied case still costs exactly one
|
|
375
823
|
// exec, so the "no write when nothing to do" contract is observable as before.
|
|
376
|
-
const mcpFile = `${key}/.mcp.json`;
|
|
824
|
+
const mcpFile = `${escapeForDoubleQuotes(key, isWindows)}/.mcp.json`;
|
|
377
825
|
const SPLIT = '---FLEET_MCP_SPLIT---';
|
|
826
|
+
const HOME_UNREADABLE = 'FLEET_HOME_CONFIG_UNREADABLE';
|
|
827
|
+
// An EXISTING but unreadable ~/.claude.json must never be read as {} and then
|
|
828
|
+
// atomically replaced with just the trust entry (that destroys the user's MCP
|
|
829
|
+
// servers and state). The read stays a one-exec round trip; when the home
|
|
830
|
+
// file exists and cat/Get-Content fails, a sentinel (printed without echo /
|
|
831
|
+
// Write-Output, which the split-marker lookup keys on) is emitted instead
|
|
832
|
+
// of the content, and nothing is written.
|
|
378
833
|
const readCmd = isWindows
|
|
379
|
-
? `Get-Content -Raw "${homeFile}" -ErrorAction SilentlyContinue; Write-Output "${SPLIT}"; Get-Content -Raw "${mcpFile}" -ErrorAction SilentlyContinue`
|
|
380
|
-
: `cat "${homeFile}" 2>/dev/null ||
|
|
834
|
+
? `Get-Content -Raw "${homeFile}" -ErrorAction SilentlyContinue -ErrorVariable fleetHomeReadErr; if ($fleetHomeReadErr -and (Test-Path "${homeFile}")) { [Console]::Out.Write("${HOME_UNREADABLE}") }; Write-Output "${SPLIT}"; Get-Content -Raw "${mcpFile}" -ErrorAction SilentlyContinue`
|
|
835
|
+
: `cat "${homeFile}" 2>/dev/null || { if test -e "${homeFile}"; then printf '%s' "${HOME_UNREADABLE}"; fi; }; echo "${SPLIT}"; cat "${mcpFile}" 2>/dev/null || true`;
|
|
381
836
|
const readResult = await execCommand(readCmd, 10000);
|
|
382
837
|
// Substring split (not line-split): if ~/.claude.json has no trailing newline the
|
|
383
838
|
// marker glues onto its closing brace, and only a substring split separates cleanly.
|
|
@@ -386,6 +841,11 @@ export class ClaudeProvider {
|
|
|
386
841
|
const splitIdx = rawStdout.indexOf(SPLIT);
|
|
387
842
|
const homeRaw = (splitIdx === -1 ? rawStdout : rawStdout.slice(0, splitIdx)).trim();
|
|
388
843
|
const mcpRaw = (splitIdx === -1 ? '' : rawStdout.slice(splitIdx + SPLIT.length)).trim();
|
|
844
|
+
if (homeRaw.includes(HOME_UNREADABLE)) {
|
|
845
|
+
const detail = `E-MEMBER-CONFIG-UNREADABLE: ${homeFile} exists but could not be read; workspace trust NOT seeded (the file is left untouched)`;
|
|
846
|
+
console.error(`[claude] workspace trust: ${detail}`);
|
|
847
|
+
return { seeded: false, detail, mcpServersSeeded: [] };
|
|
848
|
+
}
|
|
389
849
|
let existing = {};
|
|
390
850
|
try {
|
|
391
851
|
const parsed = JSON.parse(homeRaw);
|
|
@@ -450,10 +910,13 @@ export class ClaudeProvider {
|
|
|
450
910
|
// ATOMIC write: stage the full merged content in a temp file, then rename over the
|
|
451
911
|
// real file in one filesystem operation -- a crash or concurrent read mid-write can
|
|
452
912
|
// never observe a partially-written ~/.claude.json.
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
913
|
+
//
|
|
914
|
+
// The merged content must NEVER ride a command line: ~/.claude.json can hold
|
|
915
|
+
// other MCP servers' headers/tokens and OAuth state, and a command line is
|
|
916
|
+
// visible in process listings (and is capped at 32767 chars on Windows).
|
|
917
|
+
// Delivery is the file channel (node:fs / SFTP) or the owner-only secret
|
|
918
|
+
// file, then a content-free move into place; with neither, it fails loudly.
|
|
919
|
+
await deliverWorkspaceTrustFile(contentStr, { isWindows, agentOs, execCommand, transport, homeFile, tmpFile, staging, secretChannel });
|
|
457
920
|
const mcpNote = serversToAdd.length > 0 ? `; enabled MCP servers: ${serversToAdd.join(', ')}` : '';
|
|
458
921
|
// eft.40.1 requires logging distinctly when trust is SEEDED vs already present --
|
|
459
922
|
// `detail` already encodes that distinction, so log it verbatim rather than
|
|
@@ -465,4 +928,137 @@ export class ClaudeProvider {
|
|
|
465
928
|
return { seeded: trustNeeded, detail, mcpServersSeeded: serversToAdd };
|
|
466
929
|
}
|
|
467
930
|
}
|
|
931
|
+
export function workspaceTrustStagingNames() {
|
|
932
|
+
// CSPRNG, not Math.random: the names sit in the member's home next to
|
|
933
|
+
// .claude.json, so they should not be predictable.
|
|
934
|
+
const token = `${process.pid}-${randomBytes(4).toString('hex')}`;
|
|
935
|
+
return {
|
|
936
|
+
tmpRel: `.claude.json.fleet-trust-${token}.tmp`,
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Deliver `contentStr` (a merged ~/.claude.json) to `homeFile` on the member
|
|
941
|
+
* WITHOUT it ever appearing in an exec string -- not raw, not base64, not
|
|
942
|
+
* chunked, not inside -EncodedCommand. Two channels only:
|
|
943
|
+
* 1. transport.writeHomeFile (node:fs for a local member, SFTP for SSH)
|
|
944
|
+
* stages it next to the target, then a content-free move lands it;
|
|
945
|
+
* 2. the owner-only secret file (opts.secretChannel), then the same move.
|
|
946
|
+
* Neither available (or both failing) -> throws an error naming the missing
|
|
947
|
+
* channel; there is no inline fallback.
|
|
948
|
+
*/
|
|
949
|
+
export async function deliverWorkspaceTrustFile(contentStr, opts) {
|
|
950
|
+
const { isWindows, execCommand, transport, homeFile, tmpFile, staging, homeRel, secretChannel } = opts;
|
|
951
|
+
const moveCmd = (from) => (isWindows
|
|
952
|
+
? `Move-Item -Force "${from}" "${homeFile}"`
|
|
953
|
+
: `mv "${from}" "${homeFile}"`);
|
|
954
|
+
const failures = [];
|
|
955
|
+
// 1. Out-of-band file channel: content never touches a command line.
|
|
956
|
+
if (transport?.writeHomeFile) {
|
|
957
|
+
try {
|
|
958
|
+
const targetRel = homeRel ?? staging.tmpRel;
|
|
959
|
+
await transport.writeHomeFile(targetRel, contentStr);
|
|
960
|
+
if (homeRel) {
|
|
961
|
+
return { mechanism: 'file-channel', commands: [] };
|
|
962
|
+
}
|
|
963
|
+
const cmd = moveCmd(tmpFile);
|
|
964
|
+
const r = await execCommand(cmd, 10000);
|
|
965
|
+
if (r.code !== 0)
|
|
966
|
+
throw new Error(`move into place failed (exit ${r.code}): ${(r.stderr || r.stdout).trim().slice(0, 300)}`);
|
|
967
|
+
return { mechanism: 'file-channel', commands: [cmd] };
|
|
968
|
+
}
|
|
969
|
+
catch (err) {
|
|
970
|
+
failures.push(`file channel: ${err instanceof Error ? err.message : String(err)}`);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
else {
|
|
974
|
+
failures.push('file channel (SFTP / local file copy): not available for this member');
|
|
975
|
+
}
|
|
976
|
+
// 2. Owner-only secret file, then a content-free move.
|
|
977
|
+
if (secretChannel) {
|
|
978
|
+
let staged = null;
|
|
979
|
+
try {
|
|
980
|
+
staged = await secretChannel.write(contentStr);
|
|
981
|
+
const cmd = moveCmd(escapeForDoubleQuotes(staged, isWindows));
|
|
982
|
+
const r = await execCommand(cmd, 10000);
|
|
983
|
+
if (r.code !== 0)
|
|
984
|
+
throw new Error(`move into place failed (exit ${r.code}): ${(r.stderr || r.stdout).trim().slice(0, 300)}`);
|
|
985
|
+
return { mechanism: 'secret-file', commands: [cmd] };
|
|
986
|
+
}
|
|
987
|
+
catch (err) {
|
|
988
|
+
if (staged) {
|
|
989
|
+
try {
|
|
990
|
+
await secretChannel.remove(staged);
|
|
991
|
+
}
|
|
992
|
+
catch { /* best-effort */ }
|
|
993
|
+
}
|
|
994
|
+
failures.push(`secret-file channel: ${err instanceof Error ? err.message : String(err)}`);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
else {
|
|
998
|
+
failures.push('secret-file channel: not available for this member');
|
|
999
|
+
}
|
|
1000
|
+
throw new Error(`E-MEMBER-CONFIG-NO-FILE-CHANNEL: cannot write ${homeFile} on the member without putting its content on a command line (it can carry other MCP servers' tokens); ${failures.join('; ')}. Enable the SFTP subsystem on the member's sshd, or use a member type with a file channel.`);
|
|
1001
|
+
}
|
|
1002
|
+
function isRecord(v) {
|
|
1003
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
1004
|
+
}
|
|
1005
|
+
/** Wraps an exec fn so a nonzero exit throws instead of passing silently. */
|
|
1006
|
+
function checkedExec(exec) {
|
|
1007
|
+
return async (cmd, timeoutMs) => {
|
|
1008
|
+
const r = await exec(cmd, timeoutMs);
|
|
1009
|
+
if (r.code !== 0) {
|
|
1010
|
+
throw new Error(`member command failed (exit ${r.code}): ${(r.stderr || r.stdout || '').trim().slice(0, 300)}`);
|
|
1011
|
+
}
|
|
1012
|
+
return r;
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Reads CLAUDE_CONFIG_DIR as the MEMBER's own shell sees it -- the environment
|
|
1017
|
+
* a dispatched claude actually runs with (for a local member that is the
|
|
1018
|
+
* clean login env LocalStrategy builds, not this server's env). Returns null
|
|
1019
|
+
* when unset or not an absolute path. Same probe shape as member-home.ts:
|
|
1020
|
+
* POSIX printf, or base64-encoded PowerShell so no outer shell re-expands it.
|
|
1021
|
+
*/
|
|
1022
|
+
export async function probeMemberClaudeConfigDir(exec, agentOs, shell) {
|
|
1023
|
+
const posix = isPosixShell(agentOs, shell);
|
|
1024
|
+
const cmd = posix
|
|
1025
|
+
? 'printf \'%s\' "${CLAUDE_CONFIG_DIR:-}"'
|
|
1026
|
+
: wrapPowerShellEncoded('[Console]::Out.Write($env:CLAUDE_CONFIG_DIR)');
|
|
1027
|
+
let out = '';
|
|
1028
|
+
try {
|
|
1029
|
+
const r = await exec(cmd, 10000);
|
|
1030
|
+
if (r.code !== 0)
|
|
1031
|
+
return null;
|
|
1032
|
+
out = (r.stdout ?? '').trim();
|
|
1033
|
+
}
|
|
1034
|
+
catch {
|
|
1035
|
+
return null;
|
|
1036
|
+
}
|
|
1037
|
+
if (!out)
|
|
1038
|
+
return null;
|
|
1039
|
+
const absolute = out.startsWith('/') || /^[A-Za-z]:[\\/]/.test(out) || out.startsWith('\\\\');
|
|
1040
|
+
return absolute ? out : null;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* The member-side Claude config file that holds LOCAL-scope MCP servers
|
|
1044
|
+
* (projects[<folder>].mcpServers): $CLAUDE_CONFIG_DIR/.claude.json when the
|
|
1045
|
+
* member's environment sets that variable (see probeMemberClaudeConfigDir),
|
|
1046
|
+
* else ~/.claude.json. Throws when the member's home could not be resolved --
|
|
1047
|
+
* never guesses a path.
|
|
1048
|
+
*/
|
|
1049
|
+
export function claudeLocalScopeConfigFile(configDirOverride, memberHomeDir, isWindows, shell) {
|
|
1050
|
+
const normalize = (p) => (isWindows && !isPosixShell(isWindows, shell)
|
|
1051
|
+
? p.trim().replace(/\//g, '\\').replace(/\\+$/, '')
|
|
1052
|
+
: p.trim().replace(/\\/g, '/').replace(/\/+$/, ''));
|
|
1053
|
+
if (configDirOverride) {
|
|
1054
|
+
const dir = normalize(configDirOverride);
|
|
1055
|
+
const homeAnchored = !!memberHomeDir && normalize(memberHomeDir) === dir;
|
|
1056
|
+
return { file: joinMemberPath(dir, '.claude.json', isWindows, shell), dir, homeAnchored };
|
|
1057
|
+
}
|
|
1058
|
+
if (!memberHomeDir) {
|
|
1059
|
+
throw new Error('claude: the member home directory could not be resolved, so its ~/.claude.json cannot be located');
|
|
1060
|
+
}
|
|
1061
|
+
const dir = normalize(memberHomeDir);
|
|
1062
|
+
return { file: joinMemberPath(dir, '.claude.json', isWindows, shell), dir, homeAnchored: true };
|
|
1063
|
+
}
|
|
468
1064
|
//# sourceMappingURL=claude.js.map
|