@apralabs/apra-fleet 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -30
- package/dist/agents/backlog-groomer.md +75 -27
- package/dist/agents/ci-watcher.md +37 -22
- package/dist/agents/deployer.md +39 -22
- package/dist/agents/doer.md +74 -40
- package/dist/agents/harvester.md +49 -40
- package/dist/agents/integ-test-runner.md +40 -23
- package/dist/agents/kb-reconciler.md +28 -7
- package/dist/agents/plan-reviewer.md +49 -24
- package/dist/agents/planner.md +66 -43
- package/dist/agents/regression-test-runner.md +101 -78
- package/dist/agents/reviewer.md +117 -56
- package/dist/agents/schemas/backlog-groomer-output.json +1 -1
- package/dist/agents/schemas/doer-output.json +32 -0
- package/dist/agents/schemas/harvester-input.json +1 -5
- package/dist/agents/schemas/planner-output.json +1 -1
- package/dist/agents/schemas/regression-test-runner-output.json +41 -7
- package/dist/agents/schemas/reviewer-output.json +62 -3
- package/dist/cli/agent-transform.d.ts +7 -0
- package/dist/cli/agent-transform.js +46 -1
- package/dist/cli/auth.d.ts +1 -0
- package/dist/cli/auth.js +38 -8
- package/dist/cli/beads-install.d.ts +35 -0
- package/dist/cli/beads-install.js +125 -0
- package/dist/cli/beads-pin.d.ts +5 -0
- package/dist/cli/beads-pin.js +27 -0
- package/dist/cli/call.d.ts +27 -0
- package/dist/cli/call.js +177 -0
- package/dist/cli/config.d.ts +24 -1
- package/dist/cli/config.js +69 -2
- package/dist/cli/dolt-install.d.ts +18 -2
- package/dist/cli/dolt-install.js +46 -15
- package/dist/cli/fleet-se-guard.d.ts +51 -0
- package/dist/cli/fleet-se-guard.js +215 -0
- package/dist/cli/install-guard.d.ts +54 -0
- package/dist/cli/install-guard.js +132 -4
- package/dist/cli/install.d.ts +77 -21
- package/dist/cli/install.js +610 -152
- package/dist/cli/kb-commit.d.ts +2 -1
- package/dist/cli/kb-commit.js +1 -1
- package/dist/cli/kb-import.d.ts +2 -1
- package/dist/cli/kb-import.js +1 -1
- package/dist/cli/register-member.js +20 -3
- package/dist/cli/remove-member.d.ts +4 -0
- package/dist/cli/remove-member.js +63 -0
- package/dist/cli/secret.js +9 -0
- package/dist/cli/start.js +59 -4
- package/dist/cli/status.d.ts +3 -0
- package/dist/cli/status.js +45 -12
- package/dist/cli/stop.js +64 -9
- package/dist/cli/uninstall.js +101 -15
- package/dist/cli/update.js +33 -2
- package/dist/cli/watch.js +1 -1
- package/dist/cli/workflow.js +3 -2
- package/dist/commands/kb-server.js +9 -2
- package/dist/hub-service/http-server.d.ts +5 -1
- package/dist/hub-service/http-server.js +55 -5
- package/dist/index.js +155 -8
- package/dist/os/child-env-bound.d.ts +77 -0
- package/dist/os/child-env-bound.js +171 -0
- package/dist/os/linux.d.ts +7 -2
- package/dist/os/linux.js +40 -14
- package/dist/os/macos.d.ts +1 -1
- package/dist/os/macos.js +2 -11
- package/dist/os/os-commands.d.ts +17 -2
- package/dist/os/windows-gitbash.d.ts +1 -0
- package/dist/os/windows-gitbash.js +17 -3
- package/dist/os/windows-wrapper.d.ts +0 -4
- package/dist/os/windows-wrapper.js +2 -1
- package/dist/os/windows.d.ts +5 -2
- package/dist/os/windows.js +75 -29
- package/dist/paths.d.ts +21 -0
- package/dist/paths.js +35 -0
- package/dist/providers/agy.d.ts +6 -2
- package/dist/providers/agy.js +245 -106
- package/dist/providers/claude-permission-denial.d.ts +7 -0
- package/dist/providers/claude-permission-denial.js +137 -0
- package/dist/providers/claude.d.ts +86 -38
- package/dist/providers/claude.js +426 -164
- package/dist/providers/codex.js +5 -1
- package/dist/providers/copilot.js +5 -1
- package/dist/providers/opencode.d.ts +10 -2
- package/dist/providers/opencode.js +114 -53
- package/dist/providers/provider.d.ts +171 -33
- package/dist/providers/provider.js +164 -3
- package/dist/services/agent-provisioner.d.ts +29 -0
- package/dist/services/agent-provisioner.js +107 -0
- package/dist/services/agent-shadow.d.ts +96 -0
- package/dist/services/agent-shadow.js +479 -0
- package/dist/services/agy-project.d.ts +2 -1
- package/dist/services/agy-project.js +15 -17
- package/dist/services/auth-socket.d.ts +25 -0
- package/dist/services/auth-socket.js +68 -23
- package/dist/services/auth-web.js +1 -1
- package/dist/services/budget-awareness.d.ts +11 -11
- package/dist/services/budget-awareness.js +15 -3
- package/dist/services/claude-local-scope-mcp.d.ts +19 -0
- package/dist/services/claude-local-scope-mcp.js +91 -0
- package/dist/services/cloud/aws.js +2 -1
- package/dist/services/cloud/lifecycle.js +19 -2
- package/dist/services/cloud/task-wrapper.d.ts +0 -9
- package/dist/services/cloud/task-wrapper.js +15 -6
- package/dist/services/event-loop-watchdog.d.ts +32 -0
- package/dist/services/event-loop-watchdog.js +140 -0
- package/dist/services/http-transport.d.ts +49 -1
- package/dist/services/http-transport.js +190 -24
- package/dist/services/in-flight-agents.d.ts +2 -0
- package/dist/services/in-flight-agents.js +4 -0
- package/dist/services/knowledge/bible-basis-filter.d.ts +53 -0
- package/dist/services/knowledge/bible-basis-filter.js +134 -0
- package/dist/services/knowledge/bible-blob-id.d.ts +44 -0
- package/dist/services/knowledge/bible-blob-id.js +113 -0
- package/dist/services/knowledge/bible-import.d.ts +65 -0
- package/dist/services/knowledge/bible-import.js +211 -0
- package/dist/services/knowledge/file-hash.d.ts +31 -0
- package/dist/services/knowledge/file-hash.js +153 -23
- package/dist/services/knowledge/http-provider.d.ts +4 -3
- package/dist/services/knowledge/http-provider.js +17 -5
- package/dist/services/knowledge/kb-maintainer-grant.d.ts +15 -0
- package/dist/services/knowledge/kb-maintainer-grant.js +34 -0
- package/dist/services/knowledge/kb-providers.d.ts +4 -0
- package/dist/services/knowledge/kb-providers.js +8 -0
- package/dist/services/knowledge/kb-removed-scope-keys.d.ts +28 -0
- package/dist/services/knowledge/kb-removed-scope-keys.js +59 -0
- package/dist/services/knowledge/kb-scopes.d.ts +14 -0
- package/dist/services/knowledge/kb-scopes.js +47 -0
- package/dist/services/knowledge/kb-self.d.ts +91 -0
- package/dist/services/knowledge/kb-self.js +198 -0
- package/dist/services/knowledge/member-bible-view.d.ts +21 -0
- package/dist/services/knowledge/member-bible-view.js +194 -0
- package/dist/services/knowledge/pre-init.js +1 -0
- package/dist/services/knowledge/project-slug.js +2 -2
- package/dist/services/knowledge/sqlite-provider.d.ts +64 -11
- package/dist/services/knowledge/sqlite-provider.js +303 -41
- package/dist/services/knowledge/types.d.ts +45 -2
- package/dist/services/member-access-secret.d.ts +70 -0
- package/dist/services/member-access-secret.js +195 -0
- package/dist/services/member-call-counts.d.ts +24 -0
- package/dist/services/member-call-counts.js +58 -0
- package/dist/services/member-config-io.d.ts +192 -0
- package/dist/services/member-config-io.js +443 -0
- package/dist/services/member-fleet-install.d.ts +710 -0
- package/dist/services/member-fleet-install.js +1895 -0
- package/dist/services/member-secret-env.d.ts +42 -0
- package/dist/services/member-secret-env.js +68 -0
- package/dist/services/member-tool-allowlist.d.ts +49 -0
- package/dist/services/member-tool-allowlist.js +111 -0
- package/dist/services/model-pricing.d.ts +19 -0
- package/dist/services/model-pricing.js +54 -8
- package/dist/services/port-holder.d.ts +86 -0
- package/dist/services/port-holder.js +351 -0
- package/dist/services/preflight-check.js +2 -0
- package/dist/services/registry.d.ts +13 -2
- package/dist/services/registry.js +27 -1
- package/dist/services/relay-strategy.d.ts +2 -0
- package/dist/services/relay-strategy.js +8 -0
- package/dist/services/server-lifecycle.d.ts +26 -0
- package/dist/services/server-lifecycle.js +85 -0
- package/dist/services/service-manager/index.d.ts +7 -1
- package/dist/services/service-manager/index.js +17 -4
- package/dist/services/service-manager/linux.d.ts +1 -1
- package/dist/services/service-manager/linux.js +15 -7
- package/dist/services/service-manager/macos.d.ts +11 -1
- package/dist/services/service-manager/macos.js +45 -7
- package/dist/services/service-manager/service-path.d.ts +24 -0
- package/dist/services/service-manager/service-path.js +55 -0
- package/dist/services/service-manager/types.d.ts +38 -3
- package/dist/services/service-manager/types.js +29 -0
- package/dist/services/service-manager/windows.d.ts +181 -2
- package/dist/services/service-manager/windows.js +666 -49
- package/dist/services/service-notice.d.ts +14 -0
- package/dist/services/service-notice.js +62 -0
- package/dist/services/service-start-guard.d.ts +20 -0
- package/dist/services/service-start-guard.js +86 -0
- package/dist/services/session-cost.d.ts +24 -0
- package/dist/services/session-cost.js +105 -0
- package/dist/services/session-mcp-config.d.ts +83 -0
- package/dist/services/session-mcp-config.js +211 -0
- package/dist/services/sftp.d.ts +34 -0
- package/dist/services/sftp.js +304 -76
- package/dist/services/shell-probe.d.ts +0 -24
- package/dist/services/shell-probe.js +28 -3
- package/dist/services/singleton.d.ts +68 -2
- package/dist/services/singleton.js +168 -11
- package/dist/services/sprint-coordination.js +9 -3
- package/dist/services/ssh.d.ts +27 -0
- package/dist/services/ssh.js +229 -38
- package/dist/services/stall/find-log-file.js +12 -5
- package/dist/services/stall/index.d.ts +1 -1
- package/dist/services/stall/read-log-tail.d.ts +23 -0
- package/dist/services/stall/read-log-tail.js +33 -2
- package/dist/services/stall/stall-detector.d.ts +25 -1
- package/dist/services/stall/stall-detector.js +85 -6
- package/dist/services/stall/stall-poller.d.ts +16 -0
- package/dist/services/stall/stall-poller.js +50 -6
- package/dist/services/stopped-marker.d.ts +16 -0
- package/dist/services/stopped-marker.js +55 -0
- package/dist/services/strategy.d.ts +33 -1
- package/dist/services/strategy.js +86 -17
- package/dist/services/supervisor-service-cleanup.d.ts +52 -0
- package/dist/services/supervisor-service-cleanup.js +332 -0
- package/dist/services/tool-registry.d.ts +8 -1
- package/dist/services/tool-registry.js +160 -59
- package/dist/services/tool-scope.d.ts +58 -0
- package/dist/services/tool-scope.js +99 -0
- package/dist/services/watch/project-resolver.js +1 -0
- package/dist/skills/auto-sprint-args/SKILL.md +2 -2
- package/dist/skills/fleet-sprint-cli/SKILL.md +39 -15
- package/dist/skills/pm/SKILL.md +3 -3
- package/dist/skills/pm/index.md +4 -2
- package/dist/skills/pm/kb-reconcile.md +29 -14
- package/dist/skills/pm/kb-review.md +1 -0
- package/dist/skills/pm/sprint.md +5 -5
- package/dist/tools/check-status.d.ts +53 -5
- package/dist/tools/check-status.js +210 -53
- package/dist/tools/child-id-allocator.d.ts +2 -2
- package/dist/tools/child-id-allocator.js +1 -1
- package/dist/tools/code-index-heal.d.ts +8 -0
- package/dist/tools/code-index-heal.js +21 -0
- package/dist/tools/code-index-state.d.ts +45 -0
- package/dist/tools/code-index-state.js +115 -0
- package/dist/tools/code-intelligence-codebase-memory.js +6 -33
- package/dist/tools/code-intelligence-freshness.js +1 -1
- package/dist/tools/code-intelligence-gitnexus.d.ts +30 -0
- package/dist/tools/code-intelligence-gitnexus.js +333 -57
- package/dist/tools/code-intelligence-kb-enrich.js +7 -6
- package/dist/tools/code-intelligence-readiness.d.ts +99 -0
- package/dist/tools/code-intelligence-readiness.js +206 -0
- package/dist/tools/code-intelligence-reindex.d.ts +195 -0
- package/dist/tools/code-intelligence-reindex.js +530 -50
- package/dist/tools/code-intelligence-telemetry.d.ts +6 -1
- package/dist/tools/code-intelligence-telemetry.js +12 -3
- package/dist/tools/code-intelligence.d.ts +81 -31
- package/dist/tools/code-intelligence.js +156 -52
- package/dist/tools/compose-permissions.d.ts +57 -2
- package/dist/tools/compose-permissions.js +497 -44
- package/dist/tools/execute-command.d.ts +11 -0
- package/dist/tools/execute-command.js +80 -12
- package/dist/tools/execute-prompt.d.ts +59 -15
- package/dist/tools/execute-prompt.js +544 -133
- package/dist/tools/kb-bible-commit.d.ts +65 -0
- package/dist/tools/kb-bible-commit.js +239 -0
- package/dist/tools/kb-capture.d.ts +13 -9
- package/dist/tools/kb-capture.js +42 -11
- package/dist/tools/kb-context.d.ts +27 -7
- package/dist/tools/kb-context.js +60 -9
- package/dist/tools/kb-export.d.ts +96 -7
- package/dist/tools/kb-export.js +228 -65
- package/dist/tools/kb-feedback.d.ts +13 -9
- package/dist/tools/kb-feedback.js +13 -7
- package/dist/tools/kb-freshness-sweep.d.ts +11 -7
- package/dist/tools/kb-freshness-sweep.js +7 -7
- package/dist/tools/kb-harvest.d.ts +11 -7
- package/dist/tools/kb-harvest.js +7 -7
- package/dist/tools/kb-import.d.ts +26 -10
- package/dist/tools/kb-import.js +169 -159
- package/dist/tools/kb-invalidate.d.ts +17 -10
- package/dist/tools/kb-invalidate.js +41 -8
- package/dist/tools/kb-list.d.ts +14 -10
- package/dist/tools/kb-list.js +30 -10
- package/dist/tools/kb-promote.d.ts +11 -7
- package/dist/tools/kb-promote.js +14 -8
- package/dist/tools/kb-query.d.ts +21 -11
- package/dist/tools/kb-query.js +76 -13
- package/dist/tools/kb-reconcile-prefilter.d.ts +11 -7
- package/dist/tools/kb-reconcile-prefilter.js +10 -8
- package/dist/tools/kb-resolve-contradiction.d.ts +11 -7
- package/dist/tools/kb-resolve-contradiction.js +7 -7
- package/dist/tools/kb-session-prime.d.ts +14 -7
- package/dist/tools/kb-session-prime.js +44 -44
- package/dist/tools/kb-setup.d.ts +11 -4
- package/dist/tools/kb-setup.js +25 -11
- package/dist/tools/kb-stats.d.ts +11 -10
- package/dist/tools/kb-stats.js +22 -41
- package/dist/tools/list-members.js +5 -2
- package/dist/tools/member-detail.d.ts +3 -0
- package/dist/tools/member-detail.js +88 -17
- package/dist/tools/member-reservation.d.ts +2 -2
- package/dist/tools/provision-auth.d.ts +39 -1
- package/dist/tools/provision-auth.js +269 -47
- package/dist/tools/provision-vcs-auth.d.ts +2 -2
- package/dist/tools/receive-files.js +3 -1
- package/dist/tools/register-member.d.ts +34 -8
- package/dist/tools/register-member.js +76 -58
- package/dist/tools/remove-member.js +110 -32
- package/dist/tools/send-email.d.ts +2 -2
- package/dist/tools/send-files.js +6 -4
- package/dist/tools/session-stats.d.ts +17 -0
- package/dist/tools/session-stats.js +27 -0
- package/dist/tools/shutdown-server.js +5 -0
- package/dist/tools/update-agent-cli.d.ts +19 -0
- package/dist/tools/update-agent-cli.js +59 -2
- package/dist/tools/update-member.d.ts +13 -10
- package/dist/tools/update-member.js +138 -7
- package/dist/tools/vcs-credential-exec.js +8 -2
- package/dist/types.d.ts +98 -1
- package/dist/utils/agent-helpers.js +2 -0
- package/dist/utils/auth-env.d.ts +15 -4
- package/dist/utils/auth-env.js +52 -23
- package/dist/utils/find-on-path.d.ts +37 -0
- package/dist/utils/find-on-path.js +85 -0
- package/dist/utils/log-helpers.d.ts +37 -0
- package/dist/utils/log-helpers.js +106 -20
- package/dist/utils/owner-only-fs.d.ts +56 -0
- package/dist/utils/owner-only-fs.js +98 -0
- package/dist/utils/process-utils.d.ts +28 -0
- package/dist/utils/process-utils.js +68 -0
- package/dist/utils/prompt-errors.js +4 -1
- package/dist/utils/session-caller.d.ts +4 -2
- package/dist/utils/session-caller.js +3 -2
- package/dist/utils/shell-escape.d.ts +42 -3
- package/dist/utils/shell-escape.js +70 -4
- package/dist/utils/ssh-error-messages.js +3 -0
- package/dist/utils/workspace-trust.d.ts +24 -1
- package/dist/utils/workspace-trust.js +21 -17
- package/dist/workflows/auto-sprint.js +223 -43
- package/package.json +11 -8
- package/packages/apra-fleet-client/package.json +2 -2
- package/packages/apra-fleet-client/src/client/api.mjs +558 -27
- package/packages/apra-fleet-client/src/client/auto-start.mjs +434 -0
- package/packages/apra-fleet-client/src/client/client.mjs +9 -0
- package/packages/apra-fleet-client/src/client/factory.mjs +23 -4
- package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +137 -0
- package/packages/apra-fleet-client/src/client/server-resolution.mjs +267 -30
- package/packages/apra-fleet-client/src/client/transport.mjs +37 -3
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +75 -27
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +37 -22
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +39 -22
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +74 -40
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +49 -40
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +40 -23
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +28 -7
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +49 -24
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +66 -43
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +101 -78
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +117 -56
- package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-output.json +1 -1
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +32 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-input.json +1 -5
- package/packages/apra-fleet-se/apra-pm/agents/schemas/planner-output.json +1 -1
- package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +41 -7
- package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +62 -3
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +3 -3
- package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +4 -2
- package/packages/apra-fleet-se/apra-pm/skills/pm/kb-reconcile.md +29 -14
- package/packages/apra-fleet-se/apra-pm/skills/pm/kb-review.md +1 -0
- package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +5 -5
- package/packages/apra-fleet-se/bin/cli.mjs +184 -54
- package/packages/apra-fleet-se/bin/serve.mjs +143 -10
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +56 -20
- package/packages/apra-fleet-se/fleet-sprint/backlog-role.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +208 -53
- package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +576 -33
- package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +9 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-memory-hygiene.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +114 -7
- package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +154 -8
- package/packages/apra-fleet-se/fleet-sprint/ci-gate.mjs +353 -0
- package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +12 -0
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +60 -1
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +25 -2
- package/packages/apra-fleet-se/fleet-sprint/dispatch-accounting.mjs +270 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +22 -2
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +205 -16
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +52 -14
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +6 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/fleet-sprint-diagram.md +3 -3
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +339 -20
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +210 -11
- package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +4 -4
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +200 -9
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +57 -9
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +53 -4
- package/packages/apra-fleet-se/fleet-sprint/kb-hints.mjs +181 -0
- package/packages/apra-fleet-se/fleet-sprint/kb-injection.mjs +64 -0
- package/packages/apra-fleet-se/fleet-sprint/kb-maintainer.mjs +298 -0
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +1257 -301
- package/packages/apra-fleet-se/fleet-sprint/lower-quality.mjs +39 -0
- package/packages/apra-fleet-se/fleet-sprint/member-align.mjs +391 -0
- package/packages/apra-fleet-se/fleet-sprint/member-call.mjs +374 -0
- package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +644 -0
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +447 -0
- package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +250 -29
- package/packages/apra-fleet-se/fleet-sprint/orphan-reclaim.mjs +153 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +82 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +97 -50
- package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +1 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +81 -18
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +43 -11
- package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +6 -6
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +20 -15
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +60 -38
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +42 -10
- package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +16 -11
- package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +36 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +72 -12
- package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +259 -0
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +83 -25
- package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +19 -1
- package/packages/apra-fleet-se/fleet-sprint/runner.js +834 -142
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +24 -0
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +130 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +111 -0
- package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +44 -1
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +39 -15
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +84 -30
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +138 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +111 -11
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +22 -0
- package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +7 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +180 -14
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +134 -7
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +99 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +223 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +49 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +8 -4
- package/packages/apra-fleet-se/fleet-sprint/verify-block.mjs +152 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +235 -21
- package/packages/apra-fleet-se/package.json +2 -2
- package/packages/apra-fleet-se/src/supervisor/api.mjs +919 -0
- package/packages/apra-fleet-se/src/supervisor/backlog-member.mjs +332 -0
- package/packages/apra-fleet-se/src/supervisor/backlog.mjs +982 -0
- package/packages/apra-fleet-se/src/supervisor/beads-identity.mjs +246 -0
- package/packages/apra-fleet-se/src/supervisor/beads-view.mjs +438 -0
- package/packages/apra-fleet-se/src/supervisor/child-port.mjs +36 -0
- package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +1659 -0
- package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +350 -0
- package/packages/apra-fleet-se/src/supervisor/dolt-orphan-sweep.mjs +338 -0
- package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +279 -0
- package/packages/apra-fleet-se/src/supervisor/history-view.mjs +276 -0
- package/packages/apra-fleet-se/src/supervisor/history.mjs +328 -0
- package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +521 -0
- package/packages/apra-fleet-se/src/supervisor/launch-form.mjs +444 -0
- package/packages/apra-fleet-se/src/supervisor/ledger.mjs +629 -0
- package/packages/apra-fleet-se/src/supervisor/lib/exec-bd.mjs +303 -0
- package/packages/apra-fleet-se/src/supervisor/log-timestamp.mjs +51 -0
- package/packages/apra-fleet-se/src/supervisor/log-view.mjs +159 -0
- package/packages/apra-fleet-se/src/supervisor/proxy.mjs +474 -0
- package/packages/apra-fleet-se/src/supervisor/readopt.mjs +136 -0
- package/packages/apra-fleet-se/src/supervisor/reconcile.mjs +263 -0
- package/packages/apra-fleet-se/src/supervisor/rename-with-retry.mjs +87 -0
- package/packages/apra-fleet-se/src/supervisor/scope-overlap.mjs +327 -0
- package/packages/apra-fleet-se/src/supervisor/self-log.mjs +133 -0
- package/packages/apra-fleet-se/src/supervisor/server.mjs +399 -0
- package/packages/apra-fleet-se/src/supervisor/spawner.mjs +542 -0
- package/packages/apra-fleet-se/src/supervisor/sprint-identity.mjs +96 -0
- package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +987 -0
- package/packages/apra-fleet-workflow/package.json +1 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +64 -9
- package/packages/apra-fleet-workflow/src/viewer/run-summary.mjs +127 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +71 -5
- package/packages/apra-fleet-workflow/src/workflow/pricing.mjs +75 -25
- package/skills/fleet/permissions.md +9 -0
- package/skills/fleet/profiles/tag-kb-reconciler.json +2 -6
- package/version.json +1 -1
- package/dist/cli/agent-transform.d.ts.map +0 -1
- package/dist/cli/agent-transform.js.map +0 -1
- package/dist/cli/auth.d.ts.map +0 -1
- package/dist/cli/auth.js.map +0 -1
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/dolt-install.d.ts.map +0 -1
- package/dist/cli/dolt-install.js.map +0 -1
- package/dist/cli/install-guard.d.ts.map +0 -1
- package/dist/cli/install-guard.js.map +0 -1
- package/dist/cli/install.d.ts.map +0 -1
- package/dist/cli/install.js.map +0 -1
- package/dist/cli/join.d.ts.map +0 -1
- package/dist/cli/join.js.map +0 -1
- package/dist/cli/kb-commit.d.ts.map +0 -1
- package/dist/cli/kb-commit.js.map +0 -1
- package/dist/cli/kb-directives.d.ts.map +0 -1
- package/dist/cli/kb-directives.js.map +0 -1
- package/dist/cli/kb-import.d.ts.map +0 -1
- package/dist/cli/kb-import.js.map +0 -1
- package/dist/cli/register-member.d.ts.map +0 -1
- package/dist/cli/register-member.js.map +0 -1
- package/dist/cli/restart.d.ts.map +0 -1
- package/dist/cli/restart.js.map +0 -1
- package/dist/cli/secret.d.ts.map +0 -1
- package/dist/cli/secret.js.map +0 -1
- package/dist/cli/spoke.d.ts.map +0 -1
- package/dist/cli/spoke.js.map +0 -1
- package/dist/cli/start.d.ts.map +0 -1
- package/dist/cli/start.js.map +0 -1
- package/dist/cli/status.d.ts.map +0 -1
- package/dist/cli/status.js.map +0 -1
- package/dist/cli/stop.d.ts.map +0 -1
- package/dist/cli/stop.js.map +0 -1
- package/dist/cli/uninstall.d.ts.map +0 -1
- package/dist/cli/uninstall.js.map +0 -1
- package/dist/cli/update.d.ts.map +0 -1
- package/dist/cli/update.js.map +0 -1
- package/dist/cli/watch.d.ts.map +0 -1
- package/dist/cli/watch.js.map +0 -1
- package/dist/cli/workflow-assets.d.ts.map +0 -1
- package/dist/cli/workflow-assets.js.map +0 -1
- package/dist/cli/workflow.d.ts.map +0 -1
- package/dist/cli/workflow.js.map +0 -1
- package/dist/commands/kb-server.d.ts.map +0 -1
- package/dist/commands/kb-server.js.map +0 -1
- package/dist/delivery-mode.d.ts.map +0 -1
- package/dist/delivery-mode.js.map +0 -1
- package/dist/hub-service/activity.d.ts.map +0 -1
- package/dist/hub-service/activity.js.map +0 -1
- package/dist/hub-service/audit-log.d.ts.map +0 -1
- package/dist/hub-service/audit-log.js.map +0 -1
- package/dist/hub-service/db/pool.d.ts.map +0 -1
- package/dist/hub-service/db/pool.js.map +0 -1
- package/dist/hub-service/enrollment.d.ts.map +0 -1
- package/dist/hub-service/enrollment.js.map +0 -1
- package/dist/hub-service/envelope-routes.d.ts.map +0 -1
- package/dist/hub-service/envelope-routes.js.map +0 -1
- package/dist/hub-service/handlers/installers.d.ts.map +0 -1
- package/dist/hub-service/handlers/installers.js.map +0 -1
- package/dist/hub-service/http-server.d.ts.map +0 -1
- package/dist/hub-service/http-server.js.map +0 -1
- package/dist/hub-service/hub-jwt.d.ts.map +0 -1
- package/dist/hub-service/hub-jwt.js.map +0 -1
- package/dist/hub-service/jwt-revocation.d.ts.map +0 -1
- package/dist/hub-service/jwt-revocation.js.map +0 -1
- package/dist/hub-service/machines.d.ts.map +0 -1
- package/dist/hub-service/machines.js.map +0 -1
- package/dist/hub-service/main.d.ts.map +0 -1
- package/dist/hub-service/main.js.map +0 -1
- package/dist/hub-service/member-tokens.d.ts.map +0 -1
- package/dist/hub-service/member-tokens.js.map +0 -1
- package/dist/hub-service/member-view.d.ts.map +0 -1
- package/dist/hub-service/member-view.js.map +0 -1
- package/dist/hub-service/members.d.ts.map +0 -1
- package/dist/hub-service/members.js.map +0 -1
- package/dist/hub-service/presence.d.ts.map +0 -1
- package/dist/hub-service/presence.js.map +0 -1
- package/dist/hub-service/project-view.d.ts.map +0 -1
- package/dist/hub-service/project-view.js.map +0 -1
- package/dist/hub-service/projects.d.ts.map +0 -1
- package/dist/hub-service/projects.js.map +0 -1
- package/dist/hub-service/relay-queue.d.ts.map +0 -1
- package/dist/hub-service/relay-queue.js.map +0 -1
- package/dist/hub-service/session-jwt.d.ts.map +0 -1
- package/dist/hub-service/session-jwt.js.map +0 -1
- package/dist/hub-service/usage.d.ts.map +0 -1
- package/dist/hub-service/usage.js.map +0 -1
- package/dist/hub-service/users.d.ts.map +0 -1
- package/dist/hub-service/users.js.map +0 -1
- package/dist/hub-service/workspaces.d.ts.map +0 -1
- package/dist/hub-service/workspaces.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/onboarding/text.d.ts.map +0 -1
- package/dist/onboarding/text.js.map +0 -1
- package/dist/os/git-bash-candidates.d.ts.map +0 -1
- package/dist/os/git-bash-candidates.js.map +0 -1
- package/dist/os/index.d.ts.map +0 -1
- package/dist/os/index.js.map +0 -1
- package/dist/os/linux.d.ts.map +0 -1
- package/dist/os/linux.js.map +0 -1
- package/dist/os/macos.d.ts.map +0 -1
- package/dist/os/macos.js.map +0 -1
- package/dist/os/os-commands.d.ts.map +0 -1
- package/dist/os/os-commands.js.map +0 -1
- package/dist/os/windows-gitbash.d.ts.map +0 -1
- package/dist/os/windows-gitbash.js.map +0 -1
- package/dist/os/windows-wrapper.d.ts.map +0 -1
- package/dist/os/windows-wrapper.js.map +0 -1
- package/dist/os/windows.d.ts.map +0 -1
- package/dist/os/windows.js.map +0 -1
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/providers/agy.d.ts.map +0 -1
- package/dist/providers/agy.js.map +0 -1
- package/dist/providers/claude.d.ts.map +0 -1
- package/dist/providers/claude.js.map +0 -1
- package/dist/providers/codex.d.ts.map +0 -1
- package/dist/providers/codex.js.map +0 -1
- package/dist/providers/copilot.d.ts.map +0 -1
- package/dist/providers/copilot.js.map +0 -1
- package/dist/providers/email/headers.d.ts.map +0 -1
- package/dist/providers/email/headers.js.map +0 -1
- package/dist/providers/email/index.d.ts.map +0 -1
- package/dist/providers/email/index.js.map +0 -1
- package/dist/providers/email/provider.d.ts.map +0 -1
- package/dist/providers/email/provider.js.map +0 -1
- package/dist/providers/email/sendgrid.d.ts.map +0 -1
- package/dist/providers/email/sendgrid.js.map +0 -1
- package/dist/providers/email/smtp.d.ts.map +0 -1
- package/dist/providers/email/smtp.js.map +0 -1
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/none.d.ts.map +0 -1
- package/dist/providers/none.js.map +0 -1
- package/dist/providers/opencode.d.ts.map +0 -1
- package/dist/providers/opencode.js.map +0 -1
- package/dist/providers/provider.d.ts.map +0 -1
- package/dist/providers/provider.js.map +0 -1
- package/dist/services/agent-provisioner.d.ts.map +0 -1
- package/dist/services/agent-provisioner.js.map +0 -1
- package/dist/services/agy-project.d.ts.map +0 -1
- package/dist/services/agy-project.js.map +0 -1
- package/dist/services/auth-socket.d.ts.map +0 -1
- package/dist/services/auth-socket.js.map +0 -1
- package/dist/services/auth-web.d.ts.map +0 -1
- package/dist/services/auth-web.js.map +0 -1
- package/dist/services/budget-awareness.d.ts.map +0 -1
- package/dist/services/budget-awareness.js.map +0 -1
- package/dist/services/cloud/activity.d.ts.map +0 -1
- package/dist/services/cloud/activity.js.map +0 -1
- package/dist/services/cloud/aws.d.ts.map +0 -1
- package/dist/services/cloud/aws.js.map +0 -1
- package/dist/services/cloud/cost.d.ts.map +0 -1
- package/dist/services/cloud/cost.js.map +0 -1
- package/dist/services/cloud/idle-manager.d.ts.map +0 -1
- package/dist/services/cloud/idle-manager.js.map +0 -1
- package/dist/services/cloud/lifecycle.d.ts.map +0 -1
- package/dist/services/cloud/lifecycle.js.map +0 -1
- package/dist/services/cloud/task-wrapper.d.ts.map +0 -1
- package/dist/services/cloud/task-wrapper.js.map +0 -1
- package/dist/services/cloud/types.d.ts.map +0 -1
- package/dist/services/cloud/types.js.map +0 -1
- package/dist/services/cloud-sync.d.ts.map +0 -1
- package/dist/services/cloud-sync.js.map +0 -1
- package/dist/services/context-admission.d.ts.map +0 -1
- package/dist/services/context-admission.js.map +0 -1
- package/dist/services/credential-cleanup.d.ts.map +0 -1
- package/dist/services/credential-cleanup.js.map +0 -1
- package/dist/services/credential-store.d.ts.map +0 -1
- package/dist/services/credential-store.js.map +0 -1
- package/dist/services/event-bus.d.ts.map +0 -1
- package/dist/services/event-bus.js.map +0 -1
- package/dist/services/exit-drain.d.ts.map +0 -1
- package/dist/services/exit-drain.js.map +0 -1
- package/dist/services/file-chunker.d.ts.map +0 -1
- package/dist/services/file-chunker.js.map +0 -1
- package/dist/services/file-transfer-relay.d.ts.map +0 -1
- package/dist/services/file-transfer-relay.js.map +0 -1
- package/dist/services/file-transfer.d.ts.map +0 -1
- package/dist/services/file-transfer.js.map +0 -1
- package/dist/services/git-config.d.ts.map +0 -1
- package/dist/services/git-config.js.map +0 -1
- package/dist/services/github-app.d.ts.map +0 -1
- package/dist/services/github-app.js.map +0 -1
- package/dist/services/http-transport.d.ts.map +0 -1
- package/dist/services/http-transport.js.map +0 -1
- package/dist/services/hub-client.d.ts.map +0 -1
- package/dist/services/hub-client.js.map +0 -1
- package/dist/services/icons.d.ts.map +0 -1
- package/dist/services/icons.js.map +0 -1
- package/dist/services/jwt.d.ts.map +0 -1
- package/dist/services/jwt.js.map +0 -1
- package/dist/services/knowledge/audn.d.ts.map +0 -1
- package/dist/services/knowledge/audn.js.map +0 -1
- package/dist/services/knowledge/file-hash.d.ts.map +0 -1
- package/dist/services/knowledge/file-hash.js.map +0 -1
- package/dist/services/knowledge/http-provider.d.ts.map +0 -1
- package/dist/services/knowledge/http-provider.js.map +0 -1
- package/dist/services/knowledge/kb-config.d.ts.map +0 -1
- package/dist/services/knowledge/kb-config.js.map +0 -1
- package/dist/services/knowledge/kb-providers.d.ts.map +0 -1
- package/dist/services/knowledge/kb-providers.js.map +0 -1
- package/dist/services/knowledge/kb-scope-input.d.ts +0 -5
- package/dist/services/knowledge/kb-scope-input.d.ts.map +0 -1
- package/dist/services/knowledge/kb-scope-input.js +0 -11
- package/dist/services/knowledge/kb-scope-input.js.map +0 -1
- package/dist/services/knowledge/kb-service.d.ts.map +0 -1
- package/dist/services/knowledge/kb-service.js.map +0 -1
- package/dist/services/knowledge/path-validation.d.ts.map +0 -1
- package/dist/services/knowledge/path-validation.js.map +0 -1
- package/dist/services/knowledge/pre-init.d.ts.map +0 -1
- package/dist/services/knowledge/pre-init.js.map +0 -1
- package/dist/services/knowledge/project-slug.d.ts.map +0 -1
- package/dist/services/knowledge/project-slug.js.map +0 -1
- package/dist/services/knowledge/require-sqlite-project.d.ts.map +0 -1
- package/dist/services/knowledge/require-sqlite-project.js.map +0 -1
- package/dist/services/knowledge/sqlite-provider.d.ts.map +0 -1
- package/dist/services/knowledge/sqlite-provider.js.map +0 -1
- package/dist/services/knowledge/types.d.ts.map +0 -1
- package/dist/services/knowledge/types.js.map +0 -1
- package/dist/services/known-hosts.d.ts.map +0 -1
- package/dist/services/known-hosts.js.map +0 -1
- package/dist/services/known-sessions.d.ts.map +0 -1
- package/dist/services/known-sessions.js.map +0 -1
- package/dist/services/member-home.d.ts.map +0 -1
- package/dist/services/member-home.js.map +0 -1
- package/dist/services/member-remote-url.d.ts.map +0 -1
- package/dist/services/member-remote-url.js.map +0 -1
- package/dist/services/model-pricing.d.ts.map +0 -1
- package/dist/services/model-pricing.js.map +0 -1
- package/dist/services/onboarding.d.ts.map +0 -1
- package/dist/services/onboarding.js.map +0 -1
- package/dist/services/orphan-recovery.d.ts.map +0 -1
- package/dist/services/orphan-recovery.js.map +0 -1
- package/dist/services/pending-responses.d.ts.map +0 -1
- package/dist/services/pending-responses.js.map +0 -1
- package/dist/services/preflight-check.d.ts.map +0 -1
- package/dist/services/preflight-check.js.map +0 -1
- package/dist/services/registry.d.ts.map +0 -1
- package/dist/services/registry.js.map +0 -1
- package/dist/services/relay-context.d.ts.map +0 -1
- package/dist/services/relay-context.js.map +0 -1
- package/dist/services/relay-executor.d.ts.map +0 -1
- package/dist/services/relay-executor.js.map +0 -1
- package/dist/services/relay-request.d.ts.map +0 -1
- package/dist/services/relay-request.js.map +0 -1
- package/dist/services/relay-strategy.d.ts.map +0 -1
- package/dist/services/relay-strategy.js.map +0 -1
- package/dist/services/secret-token.d.ts.map +0 -1
- package/dist/services/secret-token.js.map +0 -1
- package/dist/services/service-manager/index.d.ts.map +0 -1
- package/dist/services/service-manager/index.js.map +0 -1
- package/dist/services/service-manager/linux.d.ts.map +0 -1
- package/dist/services/service-manager/linux.js.map +0 -1
- package/dist/services/service-manager/macos.d.ts.map +0 -1
- package/dist/services/service-manager/macos.js.map +0 -1
- package/dist/services/service-manager/types.d.ts.map +0 -1
- package/dist/services/service-manager/types.js.map +0 -1
- package/dist/services/service-manager/windows.d.ts.map +0 -1
- package/dist/services/service-manager/windows.js.map +0 -1
- package/dist/services/session-registry.d.ts.map +0 -1
- package/dist/services/session-registry.js.map +0 -1
- package/dist/services/sftp.d.ts.map +0 -1
- package/dist/services/sftp.js.map +0 -1
- package/dist/services/shell-probe.d.ts.map +0 -1
- package/dist/services/shell-probe.js.map +0 -1
- package/dist/services/singleton.d.ts.map +0 -1
- package/dist/services/singleton.js.map +0 -1
- package/dist/services/sprint-coordination.d.ts.map +0 -1
- package/dist/services/sprint-coordination.js.map +0 -1
- package/dist/services/ssh.d.ts.map +0 -1
- package/dist/services/ssh.js.map +0 -1
- package/dist/services/stall/find-log-file.d.ts.map +0 -1
- package/dist/services/stall/find-log-file.js.map +0 -1
- package/dist/services/stall/index.d.ts.map +0 -1
- package/dist/services/stall/index.js.map +0 -1
- package/dist/services/stall/log-path-resolver.d.ts.map +0 -1
- package/dist/services/stall/log-path-resolver.js.map +0 -1
- package/dist/services/stall/read-log-tail.d.ts.map +0 -1
- package/dist/services/stall/read-log-tail.js.map +0 -1
- package/dist/services/stall/stall-detector.d.ts.map +0 -1
- package/dist/services/stall/stall-detector.js.map +0 -1
- package/dist/services/stall/stall-poller.d.ts.map +0 -1
- package/dist/services/stall/stall-poller.js.map +0 -1
- package/dist/services/stall/time-utils.d.ts.map +0 -1
- package/dist/services/stall/time-utils.js.map +0 -1
- package/dist/services/statusline.d.ts.map +0 -1
- package/dist/services/statusline.js.map +0 -1
- package/dist/services/strategy.d.ts.map +0 -1
- package/dist/services/strategy.js.map +0 -1
- package/dist/services/substitution-engine.d.ts.map +0 -1
- package/dist/services/substitution-engine.js.map +0 -1
- package/dist/services/task-cleanup.d.ts.map +0 -1
- package/dist/services/task-cleanup.js.map +0 -1
- package/dist/services/token-issuer.d.ts.map +0 -1
- package/dist/services/token-issuer.js.map +0 -1
- package/dist/services/tool-registry.d.ts.map +0 -1
- package/dist/services/tool-registry.js.map +0 -1
- package/dist/services/update-check.d.ts.map +0 -1
- package/dist/services/update-check.js.map +0 -1
- package/dist/services/user-config.d.ts.map +0 -1
- package/dist/services/user-config.js.map +0 -1
- package/dist/services/vcs/azure-devops.d.ts.map +0 -1
- package/dist/services/vcs/azure-devops.js.map +0 -1
- package/dist/services/vcs/bitbucket.d.ts.map +0 -1
- package/dist/services/vcs/bitbucket.js.map +0 -1
- package/dist/services/vcs/constants.d.ts.map +0 -1
- package/dist/services/vcs/constants.js.map +0 -1
- package/dist/services/vcs/github.d.ts.map +0 -1
- package/dist/services/vcs/github.js.map +0 -1
- package/dist/services/vcs/types.d.ts.map +0 -1
- package/dist/services/vcs/types.js.map +0 -1
- package/dist/services/version-check.d.ts.map +0 -1
- package/dist/services/version-check.js.map +0 -1
- package/dist/services/watch/fleet-log.d.ts.map +0 -1
- package/dist/services/watch/fleet-log.js.map +0 -1
- package/dist/services/watch/project-resolver.d.ts.map +0 -1
- package/dist/services/watch/project-resolver.js.map +0 -1
- package/dist/services/watch/transcript-formatter.d.ts.map +0 -1
- package/dist/services/watch/transcript-formatter.js.map +0 -1
- package/dist/smoke-test.d.ts.map +0 -1
- package/dist/smoke-test.js.map +0 -1
- package/dist/tools/check-status.d.ts.map +0 -1
- package/dist/tools/check-status.js.map +0 -1
- package/dist/tools/child-id-allocator.d.ts.map +0 -1
- package/dist/tools/child-id-allocator.js.map +0 -1
- package/dist/tools/cloud-control.d.ts.map +0 -1
- package/dist/tools/cloud-control.js.map +0 -1
- package/dist/tools/code-intelligence-codebase-memory.d.ts.map +0 -1
- package/dist/tools/code-intelligence-codebase-memory.js.map +0 -1
- package/dist/tools/code-intelligence-freshness.d.ts.map +0 -1
- package/dist/tools/code-intelligence-freshness.js.map +0 -1
- package/dist/tools/code-intelligence-gitnexus.d.ts.map +0 -1
- package/dist/tools/code-intelligence-gitnexus.js.map +0 -1
- package/dist/tools/code-intelligence-kb-enrich.d.ts.map +0 -1
- package/dist/tools/code-intelligence-kb-enrich.js.map +0 -1
- package/dist/tools/code-intelligence-reindex.d.ts.map +0 -1
- package/dist/tools/code-intelligence-reindex.js.map +0 -1
- package/dist/tools/code-intelligence-telemetry.d.ts.map +0 -1
- package/dist/tools/code-intelligence-telemetry.js.map +0 -1
- package/dist/tools/code-intelligence-tests.d.ts.map +0 -1
- package/dist/tools/code-intelligence-tests.js.map +0 -1
- package/dist/tools/code-intelligence.d.ts.map +0 -1
- package/dist/tools/code-intelligence.js.map +0 -1
- package/dist/tools/compose-permissions.d.ts.map +0 -1
- package/dist/tools/compose-permissions.js.map +0 -1
- package/dist/tools/credential-store-delete.d.ts.map +0 -1
- package/dist/tools/credential-store-delete.js.map +0 -1
- package/dist/tools/credential-store-list.d.ts.map +0 -1
- package/dist/tools/credential-store-list.js.map +0 -1
- package/dist/tools/credential-store-set.d.ts.map +0 -1
- package/dist/tools/credential-store-set.js.map +0 -1
- package/dist/tools/credential-store-update.d.ts.map +0 -1
- package/dist/tools/credential-store-update.js.map +0 -1
- package/dist/tools/dolt-push-mutex.d.ts.map +0 -1
- package/dist/tools/dolt-push-mutex.js.map +0 -1
- package/dist/tools/execute-command.d.ts.map +0 -1
- package/dist/tools/execute-command.js.map +0 -1
- package/dist/tools/execute-prompt.d.ts.map +0 -1
- package/dist/tools/execute-prompt.js.map +0 -1
- package/dist/tools/get-member-model-pricing.d.ts.map +0 -1
- package/dist/tools/get-member-model-pricing.js.map +0 -1
- package/dist/tools/kb-capture.d.ts.map +0 -1
- package/dist/tools/kb-capture.js.map +0 -1
- package/dist/tools/kb-context.d.ts.map +0 -1
- package/dist/tools/kb-context.js.map +0 -1
- package/dist/tools/kb-export.d.ts.map +0 -1
- package/dist/tools/kb-export.js.map +0 -1
- package/dist/tools/kb-feedback.d.ts.map +0 -1
- package/dist/tools/kb-feedback.js.map +0 -1
- package/dist/tools/kb-freshness-sweep.d.ts.map +0 -1
- package/dist/tools/kb-freshness-sweep.js.map +0 -1
- package/dist/tools/kb-harvest.d.ts.map +0 -1
- package/dist/tools/kb-harvest.js.map +0 -1
- package/dist/tools/kb-import.d.ts.map +0 -1
- package/dist/tools/kb-import.js.map +0 -1
- package/dist/tools/kb-invalidate.d.ts.map +0 -1
- package/dist/tools/kb-invalidate.js.map +0 -1
- package/dist/tools/kb-list.d.ts.map +0 -1
- package/dist/tools/kb-list.js.map +0 -1
- package/dist/tools/kb-promote.d.ts.map +0 -1
- package/dist/tools/kb-promote.js.map +0 -1
- package/dist/tools/kb-query.d.ts.map +0 -1
- package/dist/tools/kb-query.js.map +0 -1
- package/dist/tools/kb-reconcile-prefilter.d.ts.map +0 -1
- package/dist/tools/kb-reconcile-prefilter.js.map +0 -1
- package/dist/tools/kb-resolve-contradiction.d.ts.map +0 -1
- package/dist/tools/kb-resolve-contradiction.js.map +0 -1
- package/dist/tools/kb-session-prime.d.ts.map +0 -1
- package/dist/tools/kb-session-prime.js.map +0 -1
- package/dist/tools/kb-setup.d.ts.map +0 -1
- package/dist/tools/kb-setup.js.map +0 -1
- package/dist/tools/kb-stats.d.ts.map +0 -1
- package/dist/tools/kb-stats.js.map +0 -1
- package/dist/tools/list-members.d.ts.map +0 -1
- package/dist/tools/list-members.js.map +0 -1
- package/dist/tools/member-detail.d.ts.map +0 -1
- package/dist/tools/member-detail.js.map +0 -1
- package/dist/tools/member-reservation.d.ts.map +0 -1
- package/dist/tools/member-reservation.js.map +0 -1
- package/dist/tools/monitor-task.d.ts.map +0 -1
- package/dist/tools/monitor-task.js.map +0 -1
- package/dist/tools/provision-auth.d.ts.map +0 -1
- package/dist/tools/provision-auth.js.map +0 -1
- package/dist/tools/provision-vcs-auth.d.ts.map +0 -1
- package/dist/tools/provision-vcs-auth.js.map +0 -1
- package/dist/tools/receive-files.d.ts.map +0 -1
- package/dist/tools/receive-files.js.map +0 -1
- package/dist/tools/register-member.d.ts.map +0 -1
- package/dist/tools/register-member.js.map +0 -1
- package/dist/tools/remove-member.d.ts.map +0 -1
- package/dist/tools/remove-member.js.map +0 -1
- package/dist/tools/report-status.d.ts.map +0 -1
- package/dist/tools/report-status.js.map +0 -1
- package/dist/tools/respond-to-message.d.ts.map +0 -1
- package/dist/tools/respond-to-message.js.map +0 -1
- package/dist/tools/revoke-vcs-auth.d.ts.map +0 -1
- package/dist/tools/revoke-vcs-auth.js.map +0 -1
- package/dist/tools/send-email.d.ts.map +0 -1
- package/dist/tools/send-email.js.map +0 -1
- package/dist/tools/send-files.d.ts.map +0 -1
- package/dist/tools/send-files.js.map +0 -1
- package/dist/tools/send-message.d.ts.map +0 -1
- package/dist/tools/send-message.js.map +0 -1
- package/dist/tools/setup-git-app.d.ts.map +0 -1
- package/dist/tools/setup-git-app.js.map +0 -1
- package/dist/tools/setup-ssh-key.d.ts.map +0 -1
- package/dist/tools/setup-ssh-key.js.map +0 -1
- package/dist/tools/shutdown-server.d.ts.map +0 -1
- package/dist/tools/shutdown-server.js.map +0 -1
- package/dist/tools/stop-prompt.d.ts.map +0 -1
- package/dist/tools/stop-prompt.js.map +0 -1
- package/dist/tools/update-agent-cli.d.ts.map +0 -1
- package/dist/tools/update-agent-cli.js.map +0 -1
- package/dist/tools/update-member.d.ts.map +0 -1
- package/dist/tools/update-member.js.map +0 -1
- package/dist/tools/vcs-credential-exec.d.ts.map +0 -1
- package/dist/tools/vcs-credential-exec.js.map +0 -1
- package/dist/tools/version.d.ts.map +0 -1
- package/dist/tools/version.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/agent-helpers.d.ts.map +0 -1
- package/dist/utils/agent-helpers.js.map +0 -1
- package/dist/utils/ansi.d.ts.map +0 -1
- package/dist/utils/ansi.js.map +0 -1
- package/dist/utils/auth-env.d.ts.map +0 -1
- package/dist/utils/auth-env.js.map +0 -1
- package/dist/utils/collect-secret.d.ts.map +0 -1
- package/dist/utils/collect-secret.js.map +0 -1
- package/dist/utils/credential-validation.d.ts.map +0 -1
- package/dist/utils/credential-validation.js.map +0 -1
- package/dist/utils/crypto.d.ts.map +0 -1
- package/dist/utils/crypto.js.map +0 -1
- package/dist/utils/deep-merge.d.ts.map +0 -1
- package/dist/utils/deep-merge.js.map +0 -1
- package/dist/utils/file-permissions.d.ts.map +0 -1
- package/dist/utils/file-permissions.js.map +0 -1
- package/dist/utils/gpu-parser.d.ts.map +0 -1
- package/dist/utils/gpu-parser.js.map +0 -1
- package/dist/utils/log-helpers.d.ts.map +0 -1
- package/dist/utils/log-helpers.js.map +0 -1
- package/dist/utils/oob-timeout.d.ts.map +0 -1
- package/dist/utils/oob-timeout.js.map +0 -1
- package/dist/utils/opencode-model-validation.d.ts.map +0 -1
- package/dist/utils/opencode-model-validation.js.map +0 -1
- package/dist/utils/pid-helpers.d.ts.map +0 -1
- package/dist/utils/pid-helpers.js.map +0 -1
- package/dist/utils/platform.d.ts.map +0 -1
- package/dist/utils/platform.js.map +0 -1
- package/dist/utils/process-utils.d.ts.map +0 -1
- package/dist/utils/process-utils.js.map +0 -1
- package/dist/utils/prompt-errors.d.ts.map +0 -1
- package/dist/utils/prompt-errors.js.map +0 -1
- package/dist/utils/resolve-member.d.ts.map +0 -1
- package/dist/utils/resolve-member.js.map +0 -1
- package/dist/utils/secure-input.d.ts.map +0 -1
- package/dist/utils/secure-input.js.map +0 -1
- package/dist/utils/session-caller.d.ts.map +0 -1
- package/dist/utils/session-caller.js.map +0 -1
- package/dist/utils/shell-escape.d.ts.map +0 -1
- package/dist/utils/shell-escape.js.map +0 -1
- package/dist/utils/skill-matrix.d.ts.map +0 -1
- package/dist/utils/skill-matrix.js.map +0 -1
- package/dist/utils/ssh-error-messages.d.ts.map +0 -1
- package/dist/utils/ssh-error-messages.js.map +0 -1
- package/dist/utils/vcs-provider-detect.d.ts.map +0 -1
- package/dist/utils/vcs-provider-detect.js.map +0 -1
- package/dist/utils/work-folder-validation.d.ts.map +0 -1
- package/dist/utils/work-folder-validation.js.map +0 -1
- package/dist/utils/workspace-trust.d.ts.map +0 -1
- package/dist/utils/workspace-trust.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
package/dist/providers/claude.js
CHANGED
|
@@ -1,12 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { escapeForDoubleQuotes } from '../utils/shell-escape.js';
|
|
2
|
+
import { randomBytes } from 'node:crypto';
|
|
3
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
|
-
|
|
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
|
+
}
|
|
10
58
|
// apra-fleet-iuc.1 / apra-fleet-ekm: reliable max_turns detection in the CLI
|
|
11
59
|
// transcript. A max_turns-terminated session must ALWAYS classify as max_turns,
|
|
12
60
|
// but the Claude Code CLI signals it INCONSISTENTLY across versions/streams:
|
|
@@ -52,6 +100,10 @@ const CLAUDE_LIMIT_MESSAGE_RE = /hit your (session|weekly|opus|\w+) limit/i;
|
|
|
52
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;
|
|
53
101
|
// Best-effort relative shape, e.g. "resets in 45 minutes" / "resets in 2 hours".
|
|
54
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'];
|
|
55
107
|
// apra-fleet-hzeb.1.2: the wall-clock fields of `instant` as observed in
|
|
56
108
|
// `timeZone`, via Intl (no external dependency). `hourCycle: 'h23'` yields
|
|
57
109
|
// 00-23; a few engines still emit '24' for midnight, so normalize it.
|
|
@@ -206,14 +258,37 @@ export class ClaudeProvider {
|
|
|
206
258
|
else if (sessionId) {
|
|
207
259
|
cmd += ` ${buildSessionIdFlag(sessionId)}`;
|
|
208
260
|
}
|
|
209
|
-
const permFlag = this.resolvePermissionFlag(unattended);
|
|
261
|
+
const permFlag = this.resolvePermissionFlag(unattended, model);
|
|
210
262
|
if (permFlag)
|
|
211
263
|
cmd += ` ${permFlag}`;
|
|
212
264
|
if (model) {
|
|
213
265
|
cmd += ` --model "${escapeDoubleQuoted(model)}"`;
|
|
214
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
|
+
}
|
|
215
272
|
return cmd;
|
|
216
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
|
+
}
|
|
217
292
|
skipPermissionsFlag() {
|
|
218
293
|
return '--dangerously-skip-permissions';
|
|
219
294
|
}
|
|
@@ -226,10 +301,13 @@ export class ClaudeProvider {
|
|
|
226
301
|
// prompt) WITHOUT the broad --dangerously-skip-permissions bypass.
|
|
227
302
|
return '--permission-mode acceptEdits';
|
|
228
303
|
}
|
|
229
|
-
resolvePermissionFlag(unattended) {
|
|
230
|
-
|
|
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')
|
|
231
309
|
return '--permission-mode auto';
|
|
232
|
-
if (
|
|
310
|
+
if (mode === 'bypassPermissions')
|
|
233
311
|
return '--dangerously-skip-permissions';
|
|
234
312
|
// apra-fleet-eft.65.1: interactive-session parity for the work folder.
|
|
235
313
|
// A headless `-p` dispatch cannot present a permission prompt, so with no
|
|
@@ -242,11 +320,70 @@ export class ClaudeProvider {
|
|
|
242
320
|
// broadening the permission model (unlike --dangerously-skip-permissions).
|
|
243
321
|
return this.workspaceEditPermissionFlag() ?? '';
|
|
244
322
|
}
|
|
245
|
-
|
|
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) {
|
|
246
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);
|
|
247
375
|
const extractUsage = (u) => u && typeof u.input_tokens === 'number' && typeof u.output_tokens === 'number'
|
|
248
|
-
? {
|
|
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
|
+
}
|
|
249
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);
|
|
250
387
|
// apra-fleet-eft.28.6: first non-blank string wins. Used so an EMPTY
|
|
251
388
|
// (present-but-blank) result field on the `type:result` event falls back to
|
|
252
389
|
// the assistant text we harvested from the stream, instead of being kept as
|
|
@@ -292,6 +429,7 @@ export class ClaudeProvider {
|
|
|
292
429
|
isError: obj.is_error === true || obj.subtype === 'error' || result.code !== 0,
|
|
293
430
|
raw,
|
|
294
431
|
usage: extractUsage(obj.usage),
|
|
432
|
+
sessionCostUsd: extractCost(obj.total_cost_usd),
|
|
295
433
|
subtype: obj.subtype,
|
|
296
434
|
terminalReason: obj.terminal_reason ?? (maxTurns ? 'max_turns' : undefined),
|
|
297
435
|
apiErrorStatus: extractApiErrorStatus(obj),
|
|
@@ -320,6 +458,7 @@ export class ClaudeProvider {
|
|
|
320
458
|
isError: parsed.is_error === true || result.code !== 0,
|
|
321
459
|
raw,
|
|
322
460
|
usage: extractUsage(parsed.usage),
|
|
461
|
+
sessionCostUsd: extractCost(parsed.total_cost_usd),
|
|
323
462
|
subtype: parsed.subtype,
|
|
324
463
|
terminalReason: parsed.terminal_reason ?? (maxTurns ? 'max_turns' : undefined),
|
|
325
464
|
apiErrorStatus: extractApiErrorStatus(parsed),
|
|
@@ -427,14 +566,14 @@ export class ClaudeProvider {
|
|
|
427
566
|
const home = resolveHomeDir(homeDir);
|
|
428
567
|
if (!home)
|
|
429
568
|
return '';
|
|
430
|
-
const encoded = encodeClaudeProjectDir(workFolder);
|
|
569
|
+
const encoded = encodeClaudeProjectDir(workFolder, targetOs ? targetOs === 'windows' : process.platform === 'win32');
|
|
431
570
|
return joinForOS(targetOs, home, '.claude', 'projects', encoded, `${sessionId}.jsonl`);
|
|
432
571
|
}
|
|
433
572
|
resolveSessionLogDir(workFolder, homeDir, targetOs) {
|
|
434
573
|
const home = resolveHomeDir(homeDir);
|
|
435
574
|
if (!home)
|
|
436
575
|
return null;
|
|
437
|
-
const encoded = encodeClaudeProjectDir(workFolder);
|
|
576
|
+
const encoded = encodeClaudeProjectDir(workFolder, targetOs ? targetOs === 'windows' : process.platform === 'win32');
|
|
438
577
|
return joinForOS(targetOs, home, '.claude', 'projects', encoded);
|
|
439
578
|
}
|
|
440
579
|
// Bare family aliases -- the claude CLI resolves these to the current
|
|
@@ -475,8 +614,103 @@ export class ClaudeProvider {
|
|
|
475
614
|
permissionConfigPaths() {
|
|
476
615
|
return ['.claude/settings.local.json'];
|
|
477
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.
|
|
478
621
|
composePermissionConfig(_role, allow = []) {
|
|
479
|
-
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}` };
|
|
480
714
|
}
|
|
481
715
|
supportsOAuthCopy() {
|
|
482
716
|
return true;
|
|
@@ -490,11 +724,41 @@ export class ClaudeProvider {
|
|
|
490
724
|
oauthSettingsMerge() {
|
|
491
725
|
return null;
|
|
492
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).
|
|
493
731
|
oauthEnvVarsToUnset() {
|
|
494
732
|
return [];
|
|
495
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.
|
|
496
740
|
authEnvVarForToken(token) {
|
|
497
|
-
|
|
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'] : [];
|
|
498
762
|
}
|
|
499
763
|
wrapWindowsPrompt(setupCmd, filePath, argList, _sessionId, _model) {
|
|
500
764
|
// Native claude.exe (2.1.113+) does not inherit stdout via ProcessStartInfo.
|
|
@@ -508,29 +772,7 @@ export class ClaudeProvider {
|
|
|
508
772
|
headlessInvocation(promptLiteral) {
|
|
509
773
|
return `-p "${promptLiteral}"`;
|
|
510
774
|
}
|
|
511
|
-
async
|
|
512
|
-
// Live-verified (apra-fleet-2xs.5, docs/member-onboarding-journey.md 3a): `claude
|
|
513
|
-
// mcp add` is Claude's own native registration mechanism -- it writes .mcp.json
|
|
514
|
-
// (project scope) or the user-scope config itself, round-tripping the bearer
|
|
515
|
-
// header intact. Shelling out here (rather than hand-writing .mcp.json) means
|
|
516
|
-
// future changes to Claude Code's config format are Anthropic's problem, not
|
|
517
|
-
// ours, and it composes correctly with whatever the user does afterward via the
|
|
518
|
-
// same CLI.
|
|
519
|
-
const args = [
|
|
520
|
-
'mcp', 'add',
|
|
521
|
-
'--transport', 'http',
|
|
522
|
-
'--scope', opts.scope,
|
|
523
|
-
'apra-fleet-member',
|
|
524
|
-
opts.url,
|
|
525
|
-
'--header', `Authorization: Bearer ${opts.token}`,
|
|
526
|
-
];
|
|
527
|
-
await execFileAsync('claude', args, { cwd: opts.workFolder });
|
|
528
|
-
return {
|
|
529
|
-
mechanism: 'cli-verb',
|
|
530
|
-
detail: `claude mcp add --transport http --scope ${opts.scope} apra-fleet-member <url> (cwd=${opts.workFolder})`,
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
async ensureWorkspaceTrusted(workFolder, execCommand, agentOs = 'linux', shell, transport, memberHomeDir) {
|
|
775
|
+
async ensureWorkspaceTrusted(workFolder, execCommand, agentOs = 'linux', shell, transport, memberHomeDir, secretChannel) {
|
|
534
776
|
// apra-fleet-eft.40: Claude gates project-scoped permissions.allow entries on
|
|
535
777
|
// projects[<key>].hasTrustDialogAccepted in the member-side ~/.claude.json -- an
|
|
536
778
|
// untrusted workspace silently DROPS them (not merely a cosmetic warning), degrading
|
|
@@ -554,31 +796,43 @@ export class ClaudeProvider {
|
|
|
554
796
|
const usePosix = isPosixShell(agentOs, shell);
|
|
555
797
|
const isWindows = !usePosix;
|
|
556
798
|
const staging = workspaceTrustStagingNames();
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
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);
|
|
572
819
|
// apra-fleet-9oo: the project's .mcp.json lives in the MEMBER's work folder, not on
|
|
573
820
|
// the orchestrator host, so it must be read through the same execCommand channel --
|
|
574
821
|
// never local node:fs. It rides along in the SAME read command as ~/.claude.json:
|
|
575
822
|
// one round-trip, and (crucially) the already-satisfied case still costs exactly one
|
|
576
823
|
// exec, so the "no write when nothing to do" contract is observable as before.
|
|
577
|
-
const mcpFile = `${key}/.mcp.json`;
|
|
824
|
+
const mcpFile = `${escapeForDoubleQuotes(key, isWindows)}/.mcp.json`;
|
|
578
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.
|
|
579
833
|
const readCmd = isWindows
|
|
580
|
-
? `Get-Content -Raw "${homeFile}" -ErrorAction SilentlyContinue; Write-Output "${SPLIT}"; Get-Content -Raw "${mcpFile}" -ErrorAction SilentlyContinue`
|
|
581
|
-
: `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`;
|
|
582
836
|
const readResult = await execCommand(readCmd, 10000);
|
|
583
837
|
// Substring split (not line-split): if ~/.claude.json has no trailing newline the
|
|
584
838
|
// marker glues onto its closing brace, and only a substring split separates cleanly.
|
|
@@ -587,6 +841,11 @@ export class ClaudeProvider {
|
|
|
587
841
|
const splitIdx = rawStdout.indexOf(SPLIT);
|
|
588
842
|
const homeRaw = (splitIdx === -1 ? rawStdout : rawStdout.slice(0, splitIdx)).trim();
|
|
589
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
|
+
}
|
|
590
849
|
let existing = {};
|
|
591
850
|
try {
|
|
592
851
|
const parsed = JSON.parse(homeRaw);
|
|
@@ -652,18 +911,12 @@ export class ClaudeProvider {
|
|
|
652
911
|
// real file in one filesystem operation -- a crash or concurrent read mid-write can
|
|
653
912
|
// never observe a partially-written ~/.claude.json.
|
|
654
913
|
//
|
|
655
|
-
//
|
|
656
|
-
//
|
|
657
|
-
//
|
|
658
|
-
//
|
|
659
|
-
//
|
|
660
|
-
|
|
661
|
-
// no command line carries the content at all;
|
|
662
|
-
// 2. one exec when the command comfortably fits (unchanged behaviour);
|
|
663
|
-
// 3. otherwise base64 chunks appended with several small execs, then one
|
|
664
|
-
// decode+move -- works for both PowerShell and gitbash members.
|
|
665
|
-
// Non-Windows POSIX hosts keep the heredoc: their ARG_MAX is far larger.
|
|
666
|
-
await deliverWorkspaceTrustFile(contentStr, { isWindows, agentOs, execCommand, transport, homeFile, tmpFile, staging });
|
|
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 });
|
|
667
920
|
const mcpNote = serversToAdd.length > 0 ? `; enabled MCP servers: ${serversToAdd.join(', ')}` : '';
|
|
668
921
|
// eft.40.1 requires logging distinctly when trust is SEEDED vs already present --
|
|
669
922
|
// `detail` already encodes that distinction, so log it verbatim rather than
|
|
@@ -676,81 +929,29 @@ export class ClaudeProvider {
|
|
|
676
929
|
}
|
|
677
930
|
}
|
|
678
931
|
export function workspaceTrustStagingNames() {
|
|
679
|
-
|
|
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')}`;
|
|
680
935
|
return {
|
|
681
936
|
tmpRel: `.claude.json.fleet-trust-${token}.tmp`,
|
|
682
|
-
b64Rel: `.claude.json.fleet-trust-${token}.b64`,
|
|
683
937
|
};
|
|
684
938
|
}
|
|
685
|
-
/** Longest single command string ensureWorkspaceTrusted will hand to execCommand on
|
|
686
|
-
* a Windows host. The hard caps are CreateProcess's 32767 chars (LocalStrategy
|
|
687
|
-
* spawns powershell.exe/bash.exe directly; a Windows sshd hands the command to
|
|
688
|
-
* its default shell the same way) and cmd.exe's 8191 (only when sshd's default
|
|
689
|
-
* shell is cmd.exe, where these PowerShell/bash commands would not run anyway).
|
|
690
|
-
* 8000 is deliberately conservative: it is under BOTH caps with room for any
|
|
691
|
-
* wrapper a strategy may add, and the cost is only more round-trips on the
|
|
692
|
-
* chunked FALLBACK path (the file channel is the primary path), e.g. ~31 execs
|
|
693
|
-
* for a 128 KB file. */
|
|
694
|
-
export const WORKSPACE_TRUST_MAX_COMMAND_CHARS = 8000;
|
|
695
|
-
/** Base64 characters per chunk command: chunk + ~200 chars of PowerShell/bash
|
|
696
|
-
* scaffolding stays well under WORKSPACE_TRUST_MAX_COMMAND_CHARS. */
|
|
697
|
-
const TRUST_CHUNK_CHARS = 6000;
|
|
698
939
|
/**
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
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.
|
|
704
948
|
*/
|
|
705
|
-
export function buildChunkedTrustWriteCommands(contentStr, opts) {
|
|
706
|
-
const chunkChars = opts.chunkChars ?? TRUST_CHUNK_CHARS;
|
|
707
|
-
const b64 = Buffer.from(contentStr, 'utf8').toString('base64');
|
|
708
|
-
const chunks = [];
|
|
709
|
-
for (let i = 0; i < b64.length; i += chunkChars)
|
|
710
|
-
chunks.push(b64.slice(i, i + chunkChars));
|
|
711
|
-
if (chunks.length === 0)
|
|
712
|
-
chunks.push('');
|
|
713
|
-
const cmds = [];
|
|
714
|
-
if (opts.posix) {
|
|
715
|
-
// gitbash on a Windows host: bash.exe -c '<cmd>' is still one CreateProcess call.
|
|
716
|
-
chunks.forEach((chunk, i) => {
|
|
717
|
-
cmds.push(`printf '%s' '${chunk}' ${i === 0 ? '>' : '>>'} "${opts.b64File}"`);
|
|
718
|
-
});
|
|
719
|
-
cmds.push(`base64 -d "${opts.b64File}" > "${opts.tmpFile}" && rm -f "${opts.b64File}" && mv "${opts.tmpFile}" "${opts.homeFile}"`);
|
|
720
|
-
}
|
|
721
|
-
else {
|
|
722
|
-
chunks.forEach((chunk, i) => {
|
|
723
|
-
const method = i === 0 ? 'WriteAllText' : 'AppendAllText';
|
|
724
|
-
cmds.push(`[System.IO.File]::${method}("${opts.b64File}", '${chunk}')`);
|
|
725
|
-
});
|
|
726
|
-
// WriteAllBytes of the decoded UTF-8 bytes: no BOM, no encoding round-trip.
|
|
727
|
-
// Error-gated (see psGated): a decode failure must never let the Move-Item run.
|
|
728
|
-
cmds.push(psGated(`[System.IO.File]::WriteAllBytes("${opts.tmpFile}", [System.Convert]::FromBase64String([System.IO.File]::ReadAllText("${opts.b64File}"))); Remove-Item -Force "${opts.b64File}"; Move-Item -Force "${opts.tmpFile}" "${opts.homeFile}"`));
|
|
729
|
-
}
|
|
730
|
-
return cmds;
|
|
731
|
-
}
|
|
732
|
-
/**
|
|
733
|
-
* Gate a multi-statement PowerShell write so a failure in an earlier statement
|
|
734
|
-
* aborts the whole command with exit 1. Without this, a .NET exception (e.g. in
|
|
735
|
-
* WriteAllText/WriteAllBytes) is only STATEMENT-terminating: the trailing
|
|
736
|
-
* Move-Item still runs, moves whatever stale tmp exists over the real
|
|
737
|
-
* ~/.claude.json, and the command exits 0. The single-command write is the
|
|
738
|
-
* cheapest path; it is still gated by the same helper.
|
|
739
|
-
*/
|
|
740
|
-
function psGated(script) {
|
|
741
|
-
return `$ErrorActionPreference = 'Stop'; try { ${script} } catch { [Console]::Error.WriteLine($_.Exception.Message); exit 1 }`;
|
|
742
|
-
}
|
|
743
|
-
/** The single-exec write command ensureWorkspaceTrusted has always used -- still the
|
|
744
|
-
* cheapest path when it fits. The PowerShell form is error-gated (psGated); the
|
|
745
|
-
* POSIX heredoc form is unchanged. */
|
|
746
|
-
export function buildSingleTrustWriteCommand(contentStr, opts) {
|
|
747
|
-
return opts.isWindows
|
|
748
|
-
? psGated(`[System.IO.File]::WriteAllText("${opts.tmpFile}", '${contentStr.replace(/'/g, "''")}', (New-Object System.Text.UTF8Encoding($false))); Move-Item -Force "${opts.tmpFile}" "${opts.homeFile}"`)
|
|
749
|
-
: `cat > "${opts.tmpFile}" << 'FLEET_TRUST_EOF'\n${contentStr}\nFLEET_TRUST_EOF\nmv "${opts.tmpFile}" "${opts.homeFile}"`;
|
|
750
|
-
}
|
|
751
949
|
export async function deliverWorkspaceTrustFile(contentStr, opts) {
|
|
752
|
-
const { isWindows,
|
|
753
|
-
const
|
|
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 = [];
|
|
754
955
|
// 1. Out-of-band file channel: content never touches a command line.
|
|
755
956
|
if (transport?.writeHomeFile) {
|
|
756
957
|
try {
|
|
@@ -759,44 +960,105 @@ export async function deliverWorkspaceTrustFile(contentStr, opts) {
|
|
|
759
960
|
if (homeRel) {
|
|
760
961
|
return { mechanism: 'file-channel', commands: [] };
|
|
761
962
|
}
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
: `mv "${tmpFile}" "${homeFile}"`;
|
|
765
|
-
const r = await execCommand(moveCmd, 10000);
|
|
963
|
+
const cmd = moveCmd(tmpFile);
|
|
964
|
+
const r = await execCommand(cmd, 10000);
|
|
766
965
|
if (r.code !== 0)
|
|
767
966
|
throw new Error(`move into place failed (exit ${r.code}): ${(r.stderr || r.stdout).trim().slice(0, 300)}`);
|
|
768
|
-
return { mechanism: 'file-channel', commands: [
|
|
967
|
+
return { mechanism: 'file-channel', commands: [cmd] };
|
|
769
968
|
}
|
|
770
969
|
catch (err) {
|
|
771
|
-
|
|
772
|
-
console.error(`[claude] workspace trust: file channel failed (${msg}); falling back to exec delivery`);
|
|
970
|
+
failures.push(`file channel: ${err instanceof Error ? err.message : String(err)}`);
|
|
773
971
|
}
|
|
774
972
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
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 */ }
|
|
795
993
|
}
|
|
796
|
-
|
|
797
|
-
throw new Error(`chunked write of ~/.claude.json failed on a Windows member (exit ${r.code}, ${cmds.length} commands of <=${WORKSPACE_TRUST_MAX_COMMAND_CHARS} chars): ${(r.stderr || r.stdout).trim().slice(0, 300)}`);
|
|
994
|
+
failures.push(`secret-file channel: ${err instanceof Error ? err.message : String(err)}`);
|
|
798
995
|
}
|
|
799
996
|
}
|
|
800
|
-
|
|
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 };
|
|
801
1063
|
}
|
|
802
1064
|
//# sourceMappingURL=claude.js.map
|