@apralabs/apra-fleet 0.4.1 → 0.4.3
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 +53 -12
- package/dist/agents/backlog-groomer.md +42 -21
- package/dist/agents/ci-watcher.md +14 -0
- package/dist/agents/deployer.md +59 -46
- package/dist/agents/doer.md +157 -134
- package/dist/agents/harvester.md +31 -32
- package/dist/agents/integ-test-runner.md +92 -113
- package/dist/agents/kb-reconciler.md +40 -42
- package/dist/agents/plan-reviewer.md +139 -63
- package/dist/agents/planner.md +176 -100
- package/dist/agents/regression-test-runner.md +77 -81
- package/dist/agents/reviewer.md +69 -85
- package/dist/agents/schemas/integ-test-runner-output.json +1 -1
- package/dist/agents/schemas/plan-reviewer-output.json +37 -0
- package/dist/agents/schemas/regression-test-runner-output.json +4 -17
- package/dist/cli/agent-transform.d.ts +83 -2
- package/dist/cli/agent-transform.d.ts.map +1 -1
- package/dist/cli/agent-transform.js +266 -21
- package/dist/cli/agent-transform.js.map +1 -1
- package/dist/cli/auth.d.ts.map +1 -1
- package/dist/cli/auth.js +29 -11
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/config.d.ts +7 -5
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +44 -43
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/install.d.ts +33 -0
- package/dist/cli/install.d.ts.map +1 -1
- package/dist/cli/install.js +294 -61
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/kb-directives.d.ts.map +1 -1
- package/dist/cli/kb-directives.js +2 -1
- package/dist/cli/kb-directives.js.map +1 -1
- package/dist/cli/register-member.d.ts.map +1 -1
- package/dist/cli/register-member.js +7 -3
- package/dist/cli/register-member.js.map +1 -1
- package/dist/cli/start.d.ts.map +1 -1
- package/dist/cli/start.js +7 -0
- package/dist/cli/start.js.map +1 -1
- package/dist/cli/uninstall.d.ts.map +1 -1
- package/dist/cli/uninstall.js +5 -3
- package/dist/cli/uninstall.js.map +1 -1
- package/dist/cli/watch.d.ts +26 -3
- package/dist/cli/watch.d.ts.map +1 -1
- package/dist/cli/watch.js +41 -9
- package/dist/cli/watch.js.map +1 -1
- package/dist/commands/kb-server.d.ts +3 -0
- package/dist/commands/kb-server.d.ts.map +1 -1
- package/dist/commands/kb-server.js +43 -3
- package/dist/commands/kb-server.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/os/git-bash-candidates.d.ts +35 -0
- package/dist/os/git-bash-candidates.d.ts.map +1 -0
- package/dist/os/git-bash-candidates.js +46 -0
- package/dist/os/git-bash-candidates.js.map +1 -0
- package/dist/os/index.d.ts +13 -4
- package/dist/os/index.d.ts.map +1 -1
- package/dist/os/index.js +17 -2
- package/dist/os/index.js.map +1 -1
- package/dist/os/linux.d.ts +6 -0
- package/dist/os/linux.d.ts.map +1 -1
- package/dist/os/linux.js +36 -3
- package/dist/os/linux.js.map +1 -1
- package/dist/os/os-commands.d.ts +68 -2
- package/dist/os/os-commands.d.ts.map +1 -1
- package/dist/os/os-commands.js.map +1 -1
- package/dist/os/windows-gitbash.d.ts +98 -0
- package/dist/os/windows-gitbash.d.ts.map +1 -0
- package/dist/os/windows-gitbash.js +259 -0
- package/dist/os/windows-gitbash.js.map +1 -0
- package/dist/os/windows.d.ts +6 -0
- package/dist/os/windows.d.ts.map +1 -1
- package/dist/os/windows.js +73 -8
- package/dist/os/windows.js.map +1 -1
- package/dist/providers/agy.d.ts +118 -8
- package/dist/providers/agy.d.ts.map +1 -1
- package/dist/providers/agy.js +580 -55
- package/dist/providers/agy.js.map +1 -1
- package/dist/providers/claude.d.ts +83 -4
- package/dist/providers/claude.d.ts.map +1 -1
- package/dist/providers/claude.js +365 -12
- package/dist/providers/claude.js.map +1 -1
- package/dist/providers/codex.d.ts +7 -4
- package/dist/providers/codex.d.ts.map +1 -1
- package/dist/providers/codex.js +24 -4
- package/dist/providers/codex.js.map +1 -1
- package/dist/providers/copilot.d.ts +7 -4
- package/dist/providers/copilot.d.ts.map +1 -1
- package/dist/providers/copilot.js +27 -4
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +0 -3
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/none.d.ts +7 -4
- package/dist/providers/none.d.ts.map +1 -1
- package/dist/providers/none.js +22 -4
- package/dist/providers/none.js.map +1 -1
- package/dist/providers/opencode.d.ts +6 -3
- package/dist/providers/opencode.d.ts.map +1 -1
- package/dist/providers/opencode.js +27 -4
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/provider.d.ts +215 -11
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/provider.js +58 -2
- package/dist/providers/provider.js.map +1 -1
- package/dist/services/agent-provisioner.js +2 -2
- package/dist/services/agent-provisioner.js.map +1 -1
- package/dist/services/agy-project.d.ts +102 -0
- package/dist/services/agy-project.d.ts.map +1 -0
- package/dist/services/agy-project.js +356 -0
- package/dist/services/agy-project.js.map +1 -0
- package/dist/services/auth-socket.js +4 -4
- package/dist/services/auth-web.js +1 -1
- package/dist/services/cloud/activity.js +2 -2
- package/dist/services/cloud/activity.js.map +1 -1
- package/dist/services/cloud/lifecycle.d.ts.map +1 -1
- package/dist/services/cloud/lifecycle.js +33 -4
- package/dist/services/cloud/lifecycle.js.map +1 -1
- package/dist/services/context-admission.d.ts.map +1 -1
- package/dist/services/context-admission.js +9 -7
- package/dist/services/context-admission.js.map +1 -1
- package/dist/services/credential-cleanup.d.ts.map +1 -1
- package/dist/services/credential-cleanup.js +47 -10
- package/dist/services/credential-cleanup.js.map +1 -1
- package/dist/services/exit-drain.d.ts +44 -0
- package/dist/services/exit-drain.d.ts.map +1 -0
- package/dist/services/exit-drain.js +52 -0
- package/dist/services/exit-drain.js.map +1 -0
- package/dist/services/github-app.d.ts.map +1 -1
- package/dist/services/github-app.js +32 -4
- package/dist/services/github-app.js.map +1 -1
- package/dist/services/http-transport.d.ts +1 -0
- package/dist/services/http-transport.d.ts.map +1 -1
- package/dist/services/http-transport.js +48 -1
- package/dist/services/http-transport.js.map +1 -1
- package/dist/services/knowledge/kb-config.d.ts +42 -0
- package/dist/services/knowledge/kb-config.d.ts.map +1 -0
- package/dist/services/knowledge/kb-config.js +54 -0
- package/dist/services/knowledge/kb-config.js.map +1 -0
- package/dist/services/knowledge/kb-providers.d.ts +7 -1
- package/dist/services/knowledge/kb-providers.d.ts.map +1 -1
- package/dist/services/knowledge/kb-providers.js +191 -17
- package/dist/services/knowledge/kb-providers.js.map +1 -1
- package/dist/services/knowledge/require-sqlite-project.d.ts +32 -0
- package/dist/services/knowledge/require-sqlite-project.d.ts.map +1 -0
- package/dist/services/knowledge/require-sqlite-project.js +38 -0
- package/dist/services/knowledge/require-sqlite-project.js.map +1 -0
- package/dist/services/member-home.d.ts +1 -1
- package/dist/services/member-home.d.ts.map +1 -1
- package/dist/services/member-home.js +15 -12
- package/dist/services/member-home.js.map +1 -1
- package/dist/services/model-pricing.d.ts.map +1 -1
- package/dist/services/model-pricing.js +7 -8
- package/dist/services/model-pricing.js.map +1 -1
- package/dist/services/orphan-recovery.d.ts +6 -3
- package/dist/services/orphan-recovery.d.ts.map +1 -1
- package/dist/services/orphan-recovery.js +17 -14
- package/dist/services/orphan-recovery.js.map +1 -1
- package/dist/services/preflight-check.js +2 -2
- package/dist/services/preflight-check.js.map +1 -1
- package/dist/services/secret-token.d.ts +38 -0
- package/dist/services/secret-token.d.ts.map +1 -0
- package/dist/services/secret-token.js +51 -0
- package/dist/services/secret-token.js.map +1 -0
- package/dist/services/service-manager/types.d.ts +3 -1
- package/dist/services/service-manager/types.d.ts.map +1 -1
- package/dist/services/service-manager/windows.d.ts +14 -2
- package/dist/services/service-manager/windows.d.ts.map +1 -1
- package/dist/services/service-manager/windows.js +65 -7
- package/dist/services/service-manager/windows.js.map +1 -1
- package/dist/services/shell-probe.d.ts +131 -0
- package/dist/services/shell-probe.d.ts.map +1 -0
- package/dist/services/shell-probe.js +210 -0
- package/dist/services/shell-probe.js.map +1 -0
- package/dist/services/singleton.d.ts +2 -0
- package/dist/services/singleton.d.ts.map +1 -1
- package/dist/services/singleton.js +1 -1
- package/dist/services/singleton.js.map +1 -1
- package/dist/services/ssh.d.ts.map +1 -1
- package/dist/services/ssh.js +60 -4
- package/dist/services/ssh.js.map +1 -1
- package/dist/services/stall/find-log-file.d.ts.map +1 -1
- package/dist/services/stall/find-log-file.js +22 -16
- package/dist/services/stall/find-log-file.js.map +1 -1
- package/dist/services/stall/read-log-tail.d.ts.map +1 -1
- package/dist/services/stall/read-log-tail.js +26 -15
- package/dist/services/stall/read-log-tail.js.map +1 -1
- package/dist/services/stall/stall-detector.d.ts +53 -4
- package/dist/services/stall/stall-detector.d.ts.map +1 -1
- package/dist/services/stall/stall-detector.js +212 -34
- package/dist/services/stall/stall-detector.js.map +1 -1
- package/dist/services/stall/stall-poller.d.ts.map +1 -1
- package/dist/services/stall/stall-poller.js +35 -42
- package/dist/services/stall/stall-poller.js.map +1 -1
- package/dist/services/strategy.d.ts +9 -0
- package/dist/services/strategy.d.ts.map +1 -1
- package/dist/services/strategy.js +119 -8
- package/dist/services/strategy.js.map +1 -1
- package/dist/services/substitution-engine.js +2 -2
- package/dist/services/substitution-engine.js.map +1 -1
- package/dist/services/tool-registry.d.ts.map +1 -1
- package/dist/services/tool-registry.js +5 -3
- package/dist/services/tool-registry.js.map +1 -1
- package/dist/services/user-config.js +1 -1
- package/dist/services/user-config.js.map +1 -1
- package/dist/services/vcs/azure-devops.d.ts +67 -2
- package/dist/services/vcs/azure-devops.d.ts.map +1 -1
- package/dist/services/vcs/azure-devops.js +281 -15
- package/dist/services/vcs/azure-devops.js.map +1 -1
- package/dist/services/vcs/bitbucket.d.ts.map +1 -1
- package/dist/services/vcs/bitbucket.js +16 -0
- package/dist/services/vcs/bitbucket.js.map +1 -1
- package/dist/services/vcs/github.d.ts.map +1 -1
- package/dist/services/vcs/github.js +24 -0
- package/dist/services/vcs/github.js.map +1 -1
- package/dist/services/vcs/types.d.ts +123 -2
- package/dist/services/vcs/types.d.ts.map +1 -1
- package/dist/skills/fleet-sprint-cli/SKILL.md +20 -1
- package/dist/skills/pm/SKILL.md +1 -2
- package/dist/skills/pm/cost.md +0 -4
- package/dist/skills/pm/fleet-addendum.md +2 -3
- package/dist/tools/check-status.d.ts +7 -4
- package/dist/tools/check-status.d.ts.map +1 -1
- package/dist/tools/check-status.js +5 -3
- package/dist/tools/check-status.js.map +1 -1
- package/dist/tools/cloud-control.js +2 -2
- package/dist/tools/cloud-control.js.map +1 -1
- package/dist/tools/compose-permissions.d.ts +6 -0
- package/dist/tools/compose-permissions.d.ts.map +1 -1
- package/dist/tools/compose-permissions.js +211 -50
- package/dist/tools/compose-permissions.js.map +1 -1
- package/dist/tools/credential-store-set.js +1 -1
- package/dist/tools/execute-command.d.ts.map +1 -1
- package/dist/tools/execute-command.js +56 -29
- package/dist/tools/execute-command.js.map +1 -1
- package/dist/tools/execute-prompt.d.ts +15 -2
- package/dist/tools/execute-prompt.d.ts.map +1 -1
- package/dist/tools/execute-prompt.js +1214 -873
- package/dist/tools/execute-prompt.js.map +1 -1
- package/dist/tools/kb-capture.d.ts +2 -2
- package/dist/tools/kb-capture.d.ts.map +1 -1
- package/dist/tools/kb-capture.js +29 -5
- package/dist/tools/kb-capture.js.map +1 -1
- package/dist/tools/kb-export.d.ts +2 -2
- package/dist/tools/kb-export.d.ts.map +1 -1
- package/dist/tools/kb-export.js +3 -28
- package/dist/tools/kb-export.js.map +1 -1
- package/dist/tools/kb-feedback.d.ts.map +1 -1
- package/dist/tools/kb-feedback.js +3 -1
- package/dist/tools/kb-feedback.js.map +1 -1
- package/dist/tools/kb-freshness-sweep.d.ts.map +1 -1
- package/dist/tools/kb-freshness-sweep.js +3 -1
- package/dist/tools/kb-freshness-sweep.js.map +1 -1
- package/dist/tools/kb-import.d.ts.map +1 -1
- package/dist/tools/kb-import.js +2 -1
- package/dist/tools/kb-import.js.map +1 -1
- package/dist/tools/kb-list.d.ts.map +1 -1
- package/dist/tools/kb-list.js +3 -1
- package/dist/tools/kb-list.js.map +1 -1
- package/dist/tools/kb-query.d.ts +2 -2
- package/dist/tools/kb-reconcile-prefilter.d.ts.map +1 -1
- package/dist/tools/kb-reconcile-prefilter.js +3 -1
- package/dist/tools/kb-reconcile-prefilter.js.map +1 -1
- package/dist/tools/kb-resolve-contradiction.d.ts.map +1 -1
- package/dist/tools/kb-resolve-contradiction.js +3 -1
- package/dist/tools/kb-resolve-contradiction.js.map +1 -1
- package/dist/tools/kb-setup.d.ts.map +1 -1
- package/dist/tools/kb-setup.js +125 -20
- package/dist/tools/kb-setup.js.map +1 -1
- package/dist/tools/kb-stats.d.ts.map +1 -1
- package/dist/tools/kb-stats.js +64 -43
- package/dist/tools/kb-stats.js.map +1 -1
- package/dist/tools/list-members.d.ts +2 -2
- package/dist/tools/list-members.d.ts.map +1 -1
- package/dist/tools/list-members.js +7 -2
- package/dist/tools/list-members.js.map +1 -1
- package/dist/tools/member-detail.d.ts +2 -2
- package/dist/tools/member-detail.d.ts.map +1 -1
- package/dist/tools/member-detail.js +22 -3
- package/dist/tools/member-detail.js.map +1 -1
- package/dist/tools/member-reservation.d.ts +58 -1
- package/dist/tools/member-reservation.d.ts.map +1 -1
- package/dist/tools/member-reservation.js +71 -18
- package/dist/tools/member-reservation.js.map +1 -1
- package/dist/tools/monitor-task.d.ts.map +1 -1
- package/dist/tools/monitor-task.js +17 -2
- package/dist/tools/monitor-task.js.map +1 -1
- package/dist/tools/provision-auth.d.ts +80 -1
- package/dist/tools/provision-auth.d.ts.map +1 -1
- package/dist/tools/provision-auth.js +147 -59
- package/dist/tools/provision-auth.js.map +1 -1
- package/dist/tools/provision-vcs-auth.d.ts +96 -3
- package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
- package/dist/tools/provision-vcs-auth.js +254 -88
- package/dist/tools/provision-vcs-auth.js.map +1 -1
- package/dist/tools/register-member.d.ts +21 -12
- package/dist/tools/register-member.d.ts.map +1 -1
- package/dist/tools/register-member.js +141 -16
- package/dist/tools/register-member.js.map +1 -1
- package/dist/tools/remove-member.d.ts.map +1 -1
- package/dist/tools/remove-member.js +29 -4
- package/dist/tools/remove-member.js.map +1 -1
- package/dist/tools/revoke-vcs-auth.js +2 -2
- package/dist/tools/revoke-vcs-auth.js.map +1 -1
- package/dist/tools/send-email.d.ts +2 -2
- package/dist/tools/setup-git-app.d.ts.map +1 -1
- package/dist/tools/setup-git-app.js +11 -7
- package/dist/tools/setup-git-app.js.map +1 -1
- package/dist/tools/setup-ssh-key.d.ts.map +1 -1
- package/dist/tools/setup-ssh-key.js +2 -1
- package/dist/tools/setup-ssh-key.js.map +1 -1
- package/dist/tools/shutdown-server.d.ts +2 -0
- package/dist/tools/shutdown-server.d.ts.map +1 -1
- package/dist/tools/shutdown-server.js +23 -1
- package/dist/tools/shutdown-server.js.map +1 -1
- package/dist/tools/stop-prompt.js +2 -2
- package/dist/tools/stop-prompt.js.map +1 -1
- package/dist/tools/update-agent-cli.js +2 -2
- package/dist/tools/update-agent-cli.js.map +1 -1
- package/dist/tools/update-member.d.ts +21 -12
- package/dist/tools/update-member.d.ts.map +1 -1
- package/dist/tools/update-member.js +61 -12
- package/dist/tools/update-member.js.map +1 -1
- package/dist/tools/vcs-credential-exec.d.ts +127 -0
- package/dist/tools/vcs-credential-exec.d.ts.map +1 -0
- package/dist/tools/vcs-credential-exec.js +197 -0
- package/dist/tools/vcs-credential-exec.js.map +1 -0
- package/dist/types.d.ts +24 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/agent-helpers.d.ts +36 -0
- package/dist/utils/agent-helpers.d.ts.map +1 -1
- package/dist/utils/agent-helpers.js +39 -1
- package/dist/utils/agent-helpers.js.map +1 -1
- package/dist/utils/log-helpers.d.ts.map +1 -1
- package/dist/utils/log-helpers.js +2 -2
- package/dist/utils/log-helpers.js.map +1 -1
- package/dist/utils/platform.d.ts +7 -0
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js +11 -1
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/prompt-errors.d.ts.map +1 -1
- package/dist/utils/prompt-errors.js +7 -1
- package/dist/utils/prompt-errors.js.map +1 -1
- package/dist/utils/shell-escape.d.ts +16 -0
- package/dist/utils/shell-escape.d.ts.map +1 -1
- package/dist/utils/shell-escape.js +22 -2
- package/dist/utils/shell-escape.js.map +1 -1
- package/dist/utils/vcs-provider-detect.d.ts +65 -0
- package/dist/utils/vcs-provider-detect.d.ts.map +1 -0
- package/dist/utils/vcs-provider-detect.js +109 -0
- package/dist/utils/vcs-provider-detect.js.map +1 -0
- package/dist/utils/workspace-trust.d.ts +20 -17
- package/dist/utils/workspace-trust.d.ts.map +1 -1
- package/dist/utils/workspace-trust.js +91 -1
- package/dist/utils/workspace-trust.js.map +1 -1
- package/dist/workflows/auto-sprint.js +180 -32
- package/package.json +7 -5
- package/packages/apra-fleet-client/src/client/api.mjs +403 -12
- package/packages/apra-fleet-client/src/client/errors.mjs +6 -2
- package/packages/apra-fleet-se/apra-pm/agents/_shared/GRAPH-SEMANTICS.md +10 -2
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +42 -21
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +14 -0
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +59 -46
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +157 -134
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +31 -32
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +92 -113
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +40 -42
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +139 -63
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +176 -100
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +77 -81
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +69 -85
- package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +1 -1
- package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +37 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +4 -17
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +1 -2
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -4
- package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +2 -3
- package/packages/apra-fleet-se/bin/cli.mjs +280 -3
- package/packages/apra-fleet-se/bin/serve.mjs +114 -5
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +481 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +491 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +282 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +208 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +638 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +301 -0
- package/packages/apra-fleet-se/fleet-sprint/branch-ensure.mjs +96 -0
- package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +8 -0
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +199 -34
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +516 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +184 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +1121 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +216 -4
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +23 -8
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-manual-recovery-verified.md +10 -8
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +285 -4
- package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +3 -3
- package/packages/apra-fleet-se/fleet-sprint/docs/run-sprint-cycle-prelude-decision.md +215 -0
- package/packages/apra-fleet-se/fleet-sprint/docs/shared-orchestrator-reservation-design.md +12 -12
- package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +14 -4
- package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +56 -1
- package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +275 -99
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +1054 -39
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +308 -0
- package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +501 -0
- package/packages/apra-fleet-se/fleet-sprint/fatal-diagnostics.mjs +134 -0
- package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +102 -0
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +556 -0
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +495 -0
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +564 -0
- package/packages/apra-fleet-se/fleet-sprint/inline-ladder-guard.mjs +216 -0
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +728 -0
- package/packages/apra-fleet-se/fleet-sprint/mcp-result.mjs +75 -0
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +252 -0
- package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +581 -0
- package/packages/apra-fleet-se/fleet-sprint/member-target.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/newtask-text.mjs +266 -0
- package/packages/apra-fleet-se/fleet-sprint/parent-notes-staleness.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +136 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +822 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +294 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +403 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +180 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +358 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +390 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +323 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +232 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +174 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +197 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +305 -0
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +559 -0
- package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +1416 -0
- package/packages/apra-fleet-se/fleet-sprint/round-session.mjs +100 -0
- package/packages/apra-fleet-se/fleet-sprint/runner.js +1672 -9072
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +134 -0
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +159 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows-gitbash.mjs +97 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +143 -0
- package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +304 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +20 -1
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +21 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +454 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +239 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +163 -0
- package/packages/apra-fleet-se/fleet-sprint/unbracketed-push-guard.mjs +234 -0
- package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +211 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +1279 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +204 -19
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +707 -12
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +28 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +33 -4
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +191 -43
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +333 -6
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +165 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +167 -37
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +559 -0
- package/packages/apra-fleet-se/package.json +1 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +178 -1
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +478 -32
- package/skills/fleet/SKILL.md +27 -16
- package/skills/fleet/auth-azdevops.md +57 -7
- package/skills/fleet/auth-bitbucket.md +5 -5
- package/skills/fleet/auth-github.md +7 -6
- package/skills/fleet/beads-conflict-resolution.md +141 -0
- package/skills/fleet/beads.md +16 -12
- package/skills/fleet/onboarding.md +6 -6
- package/skills/fleet/permissions.md +11 -7
- package/skills/fleet/profiles/node.json +1 -1
- package/skills/fleet/skill-matrix.md +1 -1
- package/skills/fleet/troubleshooting.md +4 -3
- package/version.json +1 -1
- package/dist/providers/gemini.d.ts +0 -52
- package/dist/providers/gemini.d.ts.map +0 -1
- package/dist/providers/gemini.js +0 -236
- package/dist/providers/gemini.js.map +0 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +0 -23
package/dist/providers/agy.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { joinForOS, resolveHomeDir } from './provider.js';
|
|
1
|
+
import { joinForOS, resolveHomeDir, defaultUsageLimitSignal } from './provider.js';
|
|
2
2
|
import { classifyPromptError } from '../utils/prompt-errors.js';
|
|
3
3
|
import { escapeDoubleQuoted } from '../os/os-commands.js';
|
|
4
|
+
import { wrapPowerShellEncoded } from '../os/windows.js';
|
|
4
5
|
import { stripAnsi } from '../utils/ansi.js';
|
|
5
6
|
import { logWarn } from '../utils/log-helpers.js';
|
|
6
7
|
import { getModelOverride } from '../services/user-config.js';
|
|
@@ -8,15 +9,47 @@ import { transformAgentForAgy } from '../cli/agent-transform.js';
|
|
|
8
9
|
import fs from 'node:fs';
|
|
9
10
|
import path from 'node:path';
|
|
10
11
|
import os from 'node:os';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/**
|
|
13
|
+
* SINGLE source of truth for AGY's tier -> model mapping, keyed by the STABLE
|
|
14
|
+
* slug ids `agy models` prints in its first column (verified accepted by
|
|
15
|
+
* `agy --model <slug>` on 1.2.8).
|
|
16
|
+
*
|
|
17
|
+
* This used to be two maps that drifted: display names ("Gemini 3.5 Flash
|
|
18
|
+
* (Medium)") for dispatch and slugs ("gemini-3.5-flash-lite") for
|
|
19
|
+
* modelTiers()/modelForTier(). Both catalogs went stale, and because the doer
|
|
20
|
+
* runs on the CHEAP tier, EVERY doer dispatch in an agy sprint came back as
|
|
21
|
+
* invalid model selection (--model "Gemini 3.5 Flash (Medium)"): model ...
|
|
22
|
+
* is not recognized as a known model or custom model in settings
|
|
23
|
+
* -- which the engine then reported as unparseable structured output, three
|
|
24
|
+
* rounds in a row, with no code ever written. Slugs are preferred over display
|
|
25
|
+
* names precisely because they are the stable identifier, and keeping ONE map
|
|
26
|
+
* removes the drift that caused this.
|
|
27
|
+
*/
|
|
28
|
+
export const AGY_MODEL_FOR_TIER = {
|
|
29
|
+
cheap: 'gemini-3.8-flash-low',
|
|
30
|
+
standard: 'gemini-3.8-flash-high',
|
|
31
|
+
premium: 'gemini-3.1-pro-high',
|
|
15
32
|
};
|
|
16
33
|
// Paths to the fleet-installed agy helper scripts on the member machine.
|
|
17
34
|
// Unix (bash): uses $HOME; Windows (PowerShell): uses $env:USERPROFILE.
|
|
18
35
|
const SCRIPTS_UNIX = '$HOME/.apra-fleet/scripts';
|
|
19
36
|
const SCRIPTS_WIN = '$env:USERPROFILE\\.apra-fleet\\scripts';
|
|
37
|
+
/**
|
|
38
|
+
* Wrap a JavaScript snippet for remote node execution across member operating systems.
|
|
39
|
+
* On Windows, wraps as PowerShell here-string encoded in base64 (-EncodedCommand)
|
|
40
|
+
* targeting `node --input-type=commonjs -` so that no outer shell (PowerShell,
|
|
41
|
+
* cmd.exe, or MSYS2/Git Bash) can re-parse or unescape backslashes, quotes, or
|
|
42
|
+
* regexes in the script.
|
|
43
|
+
* On POSIX (Linux/macOS), delivers via verbatim heredoc to `node --input-type=commonjs -`.
|
|
44
|
+
* Passing `--input-type=commonjs` explicitly prevents Node 22+ from treating stdin as TypeScript.
|
|
45
|
+
*/
|
|
46
|
+
export function buildAgyNodeCommand(jsCode, agentOs = 'linux', eofMarker = 'FLEET_NODE_EOF') {
|
|
47
|
+
if (agentOs === 'windows') {
|
|
48
|
+
const psScript = `$code = @'\n${jsCode}\n'@\n$code | node --input-type=commonjs -`;
|
|
49
|
+
return wrapPowerShellEncoded(psScript);
|
|
50
|
+
}
|
|
51
|
+
return `cat << '${eofMarker}' | node --input-type=commonjs -\n${jsCode}\n${eofMarker}`;
|
|
52
|
+
}
|
|
20
53
|
export class AgyProvider {
|
|
21
54
|
name = 'agy';
|
|
22
55
|
processName = 'agy';
|
|
@@ -29,8 +62,16 @@ export class AgyProvider {
|
|
|
29
62
|
versionCommand() {
|
|
30
63
|
return 'agy --version 2>&1';
|
|
31
64
|
}
|
|
32
|
-
installCommand(os) {
|
|
65
|
+
installCommand(os, shell) {
|
|
33
66
|
if (os === 'windows') {
|
|
67
|
+
// A gitbash member's command strings run in bash directly
|
|
68
|
+
// (apra-fleet-7dir.2.4/2.7) -- route through the same base64
|
|
69
|
+
// -EncodedCommand envelope every other Windows-targeting PowerShell
|
|
70
|
+
// invocation in this codebase uses, instead of the raw `powershell
|
|
71
|
+
// -Command "..."` form.
|
|
72
|
+
if (shell === 'gitbash') {
|
|
73
|
+
return wrapPowerShellEncoded('irm https://antigravity.google/cli/install.ps1 | iex');
|
|
74
|
+
}
|
|
34
75
|
return 'powershell -Command "irm https://antigravity.google/cli/install.ps1 | iex"';
|
|
35
76
|
}
|
|
36
77
|
return 'curl -fsSL https://antigravity.google/cli/install.sh | bash';
|
|
@@ -47,7 +88,7 @@ export class AgyProvider {
|
|
|
47
88
|
return 'standard';
|
|
48
89
|
}
|
|
49
90
|
buildPromptCommand(opts) {
|
|
50
|
-
const { folder, promptFile, sessionId, resuming, unattended, inv, model, tier: inputTier, agentName } = opts;
|
|
91
|
+
const { folder, promptFile, sessionId, resuming, unattended, inv, model, tier: inputTier, agentName, projectId } = opts;
|
|
51
92
|
const escapedFolder = escapeDoubleQuoted(folder);
|
|
52
93
|
const normalizedFolder = folder.replace(/\\/g, '/');
|
|
53
94
|
const fullPromptPath = path.posix.join(normalizedFolder, promptFile);
|
|
@@ -58,7 +99,15 @@ export class AgyProvider {
|
|
|
58
99
|
// Write per-workspace model override before launching agy.
|
|
59
100
|
const tier = inputTier ?? this.resolveTierFromModel(model);
|
|
60
101
|
const displayModel = getModelOverride('agy', tier) ?? AGY_MODEL_FOR_TIER[tier];
|
|
61
|
-
|
|
102
|
+
// --add-dir is REQUIRED, not cosmetic: AGY does not adopt the process's
|
|
103
|
+
// working directory as its workspace. A bare `cd <folder> && agy -p ...`
|
|
104
|
+
// starts with NO active workspace, so the model cannot see the repo at all
|
|
105
|
+
// and falls back to shelling out from ~/.gemini/antigravity-cli/scratch --
|
|
106
|
+
// which then trips the headless permission wall on the first run_command.
|
|
107
|
+
// (Live-verified on agy 1.2.8: the same prompt fails without --add-dir and
|
|
108
|
+
// succeeds with it.) The `cd` is kept so relative paths a dispatched agent
|
|
109
|
+
// builds itself still resolve.
|
|
110
|
+
let cmd = `cd "${escapedFolder}" && agy ${this.workspaceDirFlag(escapedFolder)} ${this.projectFlag(projectId)} --model "${escapeDoubleQuoted(displayModel)}" --output-format json`;
|
|
62
111
|
if (agentName) {
|
|
63
112
|
cmd += ` --agent "${escapeDoubleQuoted(agentName)}"`;
|
|
64
113
|
}
|
|
@@ -74,8 +123,10 @@ export class AgyProvider {
|
|
|
74
123
|
const permFlag = this.resolvePermissionFlag(unattended);
|
|
75
124
|
if (permFlag)
|
|
76
125
|
cmd += ` ${permFlag}`;
|
|
77
|
-
// After agy exits,
|
|
78
|
-
//
|
|
126
|
+
// After agy exits, also print its transcript from disk. The JSON result
|
|
127
|
+
// usually arrives on stdout (observed under gitbash on Windows too), but
|
|
128
|
+
// agy can write to CONOUT$ instead, and the transcript is also where a
|
|
129
|
+
// permission denial names its concrete target (detectAgyPermissionDenial).
|
|
79
130
|
const transcriptScript = `${SCRIPTS_UNIX}/agy-transcript-reader.js`;
|
|
80
131
|
const convArg = sessionId ? `"${escapeDoubleQuoted(sessionId)}"` : '""';
|
|
81
132
|
const folderArg = `"${escapeDoubleQuoted(folder)}"`;
|
|
@@ -85,6 +136,21 @@ export class AgyProvider {
|
|
|
85
136
|
skipPermissionsFlag() {
|
|
86
137
|
return '--dangerously-skip-permissions';
|
|
87
138
|
}
|
|
139
|
+
/** `--project <id>` binds the run to the member's own agy project, whose
|
|
140
|
+
* permissionGrants compose_permissions writes. Without it agy runs under the
|
|
141
|
+
* machine-wide default-cli-project (docs/agy-provider.md
|
|
142
|
+
* section 1), so a missing id is a hard error, never an omitted flag. */
|
|
143
|
+
projectFlag(projectId) {
|
|
144
|
+
if (!projectId || !/^[A-Za-z0-9][A-Za-z0-9-]*$/.test(projectId)) {
|
|
145
|
+
throw new Error('agy: refusing to dispatch without a valid agy project id (--project); run compose_permissions to provision one');
|
|
146
|
+
}
|
|
147
|
+
return `--project "${projectId}"`;
|
|
148
|
+
}
|
|
149
|
+
/** AGY's workspace is set by --add-dir, never inherited from the process cwd.
|
|
150
|
+
* See the comment in buildPromptCommand for why this is load-bearing. */
|
|
151
|
+
workspaceDirFlag(escapedFolder) {
|
|
152
|
+
return `--add-dir "${escapedFolder}"`;
|
|
153
|
+
}
|
|
88
154
|
permissionModeAutoFlag() {
|
|
89
155
|
return '--mode accept-edits';
|
|
90
156
|
}
|
|
@@ -109,7 +175,18 @@ export class AgyProvider {
|
|
|
109
175
|
// default (false/undefined) and 'auto' both resolve to the same baseline.
|
|
110
176
|
return this.workspaceEditPermissionFlag() ?? '';
|
|
111
177
|
}
|
|
112
|
-
|
|
178
|
+
/** Parses the run's result and, when agy refused a tool call for lack of a
|
|
179
|
+
* grant, attaches the denial (see detectAgyPermissionDenial). A headless
|
|
180
|
+
* denial exits 0 with status SUCCESS and an empty response, so without this
|
|
181
|
+
* it is indistinguishable from a blank reply. */
|
|
182
|
+
parseResponse(result, ctx) {
|
|
183
|
+
const parsed = this.parseResult(result);
|
|
184
|
+
const denial = detectAgyPermissionDenial(result, ctx?.agentOs);
|
|
185
|
+
if (denial)
|
|
186
|
+
parsed.permissionDenial = denial;
|
|
187
|
+
return parsed;
|
|
188
|
+
}
|
|
189
|
+
parseResult(result) {
|
|
113
190
|
const raw = result.stdout;
|
|
114
191
|
let extractedSessionId;
|
|
115
192
|
const sessionMatch = raw.match(/FLEET_SESSION_ID:([^\r\n]+)/);
|
|
@@ -225,6 +302,11 @@ export class AgyProvider {
|
|
|
225
302
|
usage: undefined,
|
|
226
303
|
};
|
|
227
304
|
}
|
|
305
|
+
// apra-fleet-hzeb.1: AGY has no distinct usage-limit event surface, so key off
|
|
306
|
+
// the raw output using the shared quota detector (guessed resume window).
|
|
307
|
+
detectUsageLimit(result, parsed) {
|
|
308
|
+
return defaultUsageLimitSignal(result.stderr || result.stdout || parsed.result);
|
|
309
|
+
}
|
|
228
310
|
supportsResume() {
|
|
229
311
|
return true;
|
|
230
312
|
}
|
|
@@ -234,6 +316,14 @@ export class AgyProvider {
|
|
|
234
316
|
sessionIdStrategy() {
|
|
235
317
|
return { type: 'provider-minted' };
|
|
236
318
|
}
|
|
319
|
+
// apra-fleet-25yl.2.1: like Claude, an AGY dispatch is batch/CONOUT$-only --
|
|
320
|
+
// the exec channel carries no mid-turn signal, so a `timeout_s`-sized
|
|
321
|
+
// rolling deadline there is a false kill. AGY's working mechanism is the
|
|
322
|
+
// StallDetector watching its brain/transcript directory (resolveSessionLogDir
|
|
323
|
+
// below returns a real path), which still gets `timeout_s` as thresholdMs.
|
|
324
|
+
execTimeoutSource() {
|
|
325
|
+
return 'total_ceiling';
|
|
326
|
+
}
|
|
237
327
|
resolveSessionLogPath(sessionId, _workFolder, homeDir, targetOs) {
|
|
238
328
|
const home = resolveHomeDir(homeDir);
|
|
239
329
|
if (!home)
|
|
@@ -255,18 +345,10 @@ export class AgyProvider {
|
|
|
255
345
|
return `--conversation "${escapeDoubleQuoted(sessionId)}"`;
|
|
256
346
|
}
|
|
257
347
|
modelTiers() {
|
|
258
|
-
return {
|
|
259
|
-
cheap: 'gemini-3.5-flash-lite',
|
|
260
|
-
standard: 'gemini-3.5-flash',
|
|
261
|
-
premium: 'claude-sonnet-4.6',
|
|
262
|
-
};
|
|
348
|
+
return { ...AGY_MODEL_FOR_TIER };
|
|
263
349
|
}
|
|
264
350
|
modelForTier(tier) {
|
|
265
|
-
|
|
266
|
-
return 'gemini-3.5-flash-lite';
|
|
267
|
-
if (tier === 'premium')
|
|
268
|
-
return 'claude-sonnet-4.6';
|
|
269
|
-
return 'gemini-3.5-flash';
|
|
351
|
+
return AGY_MODEL_FOR_TIER[tier];
|
|
270
352
|
}
|
|
271
353
|
modelFlag(model) {
|
|
272
354
|
return '';
|
|
@@ -284,12 +366,43 @@ export class AgyProvider {
|
|
|
284
366
|
classifyError(output) {
|
|
285
367
|
return classifyPromptError(output);
|
|
286
368
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
|
|
369
|
+
/** The member's own agy project file, named by the id `agy --new-project`
|
|
370
|
+
* created for it (Agent.agyProjectId). ensureAgyProject must have run first;
|
|
371
|
+
* a member without an id has no file fleet may write. */
|
|
372
|
+
permissionConfigPaths(agent) {
|
|
373
|
+
const id = agent?.agyProjectId;
|
|
374
|
+
if (!id) {
|
|
375
|
+
throw new Error('agy: member has no agy project id -- provision it (ensureAgyProject) before composing permissions');
|
|
376
|
+
}
|
|
377
|
+
return [`~/.gemini/config/projects/${id}.json`];
|
|
378
|
+
}
|
|
379
|
+
/** Only `permissionGrants.permissionGrants.{allow,deny}` -- deliverConfigFile
|
|
380
|
+
* deep-merges this into the file agy created, so the id, name and
|
|
381
|
+
* projectResources agy wrote are kept as they are. */
|
|
382
|
+
composePermissionConfig(_role, allow = [], agent, opts = {}) {
|
|
383
|
+
this.permissionConfigPaths(agent);
|
|
384
|
+
const agyAllow = formatAgyPermissionRules(convertClaudeAllowToAgyPermissions(allow, {
|
|
385
|
+
os: agent?.os,
|
|
386
|
+
homeDir: opts.memberHomeDir,
|
|
387
|
+
warnings: opts.warnings,
|
|
388
|
+
}));
|
|
389
|
+
return [{
|
|
390
|
+
permissionGrants: {
|
|
391
|
+
permissionGrants: {
|
|
392
|
+
allow: agyAllow,
|
|
393
|
+
deny: AGY_ORCHESTRATOR_DENY_RULES,
|
|
394
|
+
},
|
|
395
|
+
},
|
|
396
|
+
}];
|
|
397
|
+
}
|
|
398
|
+
async preparePermissionsDelivery(_agent, execCommand, memberHomeDir, agentOs = 'linux', shell) {
|
|
399
|
+
const warnings = [];
|
|
400
|
+
const skillsResult = await checkAgyMemberSkills(execCommand, memberHomeDir, agentOs, shell);
|
|
401
|
+
if (skillsResult?.warning) {
|
|
402
|
+
logWarn('agy', skillsResult.warning);
|
|
403
|
+
warnings.push(skillsResult.warning);
|
|
404
|
+
}
|
|
405
|
+
return warnings;
|
|
293
406
|
}
|
|
294
407
|
supportsOAuthCopy() {
|
|
295
408
|
return false;
|
|
@@ -364,14 +477,391 @@ export class AgyProvider {
|
|
|
364
477
|
detail: `merged apra-fleet-member into ${configFile} (mcpServers.apra-fleet-member)`,
|
|
365
478
|
};
|
|
366
479
|
}
|
|
367
|
-
async ensureWorkspaceTrusted(_workFolder, _execCommand, _agentOs) {
|
|
368
|
-
//
|
|
369
|
-
//
|
|
370
|
-
//
|
|
371
|
-
return { seeded: false, detail: 'agy: no
|
|
480
|
+
async ensureWorkspaceTrusted(_workFolder, _execCommand, _agentOs, _shell) {
|
|
481
|
+
// Live-verified (docs/agy-provider.md section 5): a
|
|
482
|
+
// headless run with --project enforces the project's grants in a folder
|
|
483
|
+
// fleet never seeded into trustedWorkspaces, so there is nothing to seed.
|
|
484
|
+
return { seeded: false, detail: 'agy: no workspace trust needed -- grants bind via --project' };
|
|
372
485
|
}
|
|
373
486
|
}
|
|
374
|
-
|
|
487
|
+
// --- Permission denials -----------------------------------------------------
|
|
488
|
+
//
|
|
489
|
+
// A headless agy run that needs a grant it does not have exits 0 and reports
|
|
490
|
+
// the refusal in three places (docs/agy-provider.md section 4):
|
|
491
|
+
// 1. the --output-format json result: "denied_actions":[{"action":"command",...}]
|
|
492
|
+
// (with "status":"SUCCESS" and usually "response":"");
|
|
493
|
+
// 2. stderr: a tool required the "command" permission that headless mode
|
|
494
|
+
// cannot prompt for, so it was auto-denied ...;
|
|
495
|
+
// 3. the transcript (printed between FLEET_TRANSCRIPT_START/END by
|
|
496
|
+
// agy-transcript-reader.js): an ERROR step
|
|
497
|
+
// permission check failed for command "git status --short --branch": user denied ...
|
|
498
|
+
// (Linux/macOS name a shell command "unsandboxed" there: permission check
|
|
499
|
+
// failed for unsandboxed "whoami": user denied ...).
|
|
500
|
+
const AGY_STDERR_DENIAL_RE = /a tool required the "([a-z_]+)" permission that headless mode cannot prompt for/g;
|
|
501
|
+
const AGY_TRANSCRIPT_DENIAL_RES = [
|
|
502
|
+
/permission check failed for ([a-z_]+) "([\s\S]*?)": user denied/,
|
|
503
|
+
/user denied permission for ([a-z_]+)\(([^)]*)\)/,
|
|
504
|
+
];
|
|
505
|
+
const SHELL_CHAIN_RE = /[|;`]|&&|\$\(/;
|
|
506
|
+
function stripTranscript(text) {
|
|
507
|
+
return text.replace(/FLEET_TRANSCRIPT_START[\s\S]*?FLEET_TRANSCRIPT_END/g, '');
|
|
508
|
+
}
|
|
509
|
+
const SHELL_SEQUENCE_RE = /[|;`]|&&/;
|
|
510
|
+
const PLAIN_COMMAND_WORD_RE = /^[\w.+-]+$/;
|
|
511
|
+
/** The compose_permissions grants that allow one denied call, primary first.
|
|
512
|
+
* The prefix grant Bash(<first word>:*) composes to command(<word>) plus
|
|
513
|
+
* command(regex:<word> .*) on every OS, and the regex matches the full raw
|
|
514
|
+
* line, including a $(...) argument (docs/agy-provider.md section 3), so it comes first and the
|
|
515
|
+
* exact command follows as the narrow option. Linux/macOS agy reports a shell
|
|
516
|
+
* command it refuses as `unsandboxed "<command line>"` (the JSON result says
|
|
517
|
+
* `command`), so both actions are handled alike. */
|
|
518
|
+
function suggestedGrantsFor(item) {
|
|
519
|
+
const t = item.target?.trim();
|
|
520
|
+
if (item.action === 'command' || item.action === 'unsandboxed') {
|
|
521
|
+
if (!t || SHELL_SEQUENCE_RE.test(t))
|
|
522
|
+
return [];
|
|
523
|
+
const first = t.split(/\s+/)[0];
|
|
524
|
+
const out = [];
|
|
525
|
+
if (PLAIN_COMMAND_WORD_RE.test(first))
|
|
526
|
+
out.push(`Bash(${first}:*)`);
|
|
527
|
+
if (!SHELL_CHAIN_RE.test(t) && t !== first)
|
|
528
|
+
out.push(`Bash(${t})`);
|
|
529
|
+
return out;
|
|
530
|
+
}
|
|
531
|
+
const one = suggestedGrantFor(item);
|
|
532
|
+
return one ? [one] : [];
|
|
533
|
+
}
|
|
534
|
+
function suggestedGrantFor(item) {
|
|
535
|
+
const t = item.target?.trim();
|
|
536
|
+
switch (item.action) {
|
|
537
|
+
case 'command':
|
|
538
|
+
return t && !SHELL_CHAIN_RE.test(t) ? `Bash(${t})` : undefined;
|
|
539
|
+
case 'read_file':
|
|
540
|
+
return t ? `Read(${t})` : 'Read';
|
|
541
|
+
case 'write_file':
|
|
542
|
+
return t ? `Write(${t})` : 'Write';
|
|
543
|
+
case 'mcp': {
|
|
544
|
+
const m = t ? /^([^/\s]+)\/([^/\s]+)$/.exec(t) : null;
|
|
545
|
+
return m ? `mcp__${m[1]}__${m[2]}` : undefined;
|
|
546
|
+
}
|
|
547
|
+
case 'read_url':
|
|
548
|
+
return 'WebSearch';
|
|
549
|
+
default:
|
|
550
|
+
return undefined;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Detects an agy permission denial in a dispatch's output. The JSON result is
|
|
555
|
+
* authoritative when present: a non-empty denied_actions is a denial whatever
|
|
556
|
+
* its status, and a result without it is not (older transcript steps are
|
|
557
|
+
* ignored). Without a JSON result, the stderr auto-denied line or a
|
|
558
|
+
* transcript ERROR step from the current turn counts. Targets always come
|
|
559
|
+
* from the current turn's transcript steps.
|
|
560
|
+
*/
|
|
561
|
+
export function detectAgyPermissionDenial(result, agentOs) {
|
|
562
|
+
const stdout = stripAnsi(result.stdout ?? '');
|
|
563
|
+
const outside = stripTranscript(stdout);
|
|
564
|
+
const signals = [];
|
|
565
|
+
// 1. JSON result envelope(s) outside the transcript section.
|
|
566
|
+
let sawEnvelope = false;
|
|
567
|
+
const jsonActions = [];
|
|
568
|
+
for (const line of outside.split(/\r?\n/)) {
|
|
569
|
+
const l = line.trim();
|
|
570
|
+
const start = l.indexOf('{');
|
|
571
|
+
if (start < 0 || !l.endsWith('}'))
|
|
572
|
+
continue;
|
|
573
|
+
let obj;
|
|
574
|
+
try {
|
|
575
|
+
obj = JSON.parse(l.slice(start));
|
|
576
|
+
}
|
|
577
|
+
catch {
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
if (!obj || typeof obj !== 'object')
|
|
581
|
+
continue;
|
|
582
|
+
if ('conversation_id' in obj || 'denied_actions' in obj || obj.status === 'SUCCESS' || obj.status === 'ERROR')
|
|
583
|
+
sawEnvelope = true;
|
|
584
|
+
if (Array.isArray(obj.denied_actions)) {
|
|
585
|
+
for (const d of obj.denied_actions) {
|
|
586
|
+
const action = typeof d === 'string' ? d : (d && typeof d.action === 'string' ? d.action : undefined);
|
|
587
|
+
if (action)
|
|
588
|
+
jsonActions.push(action);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (jsonActions.length)
|
|
593
|
+
signals.push('result_json');
|
|
594
|
+
// 2. stderr (and, defensively, stdout outside the transcript).
|
|
595
|
+
const stderrActions = [];
|
|
596
|
+
for (const text of [result.stderr ?? '', outside]) {
|
|
597
|
+
for (const m of text.matchAll(AGY_STDERR_DENIAL_RE))
|
|
598
|
+
stderrActions.push(m[1]);
|
|
599
|
+
}
|
|
600
|
+
if (stderrActions.length)
|
|
601
|
+
signals.push('stderr');
|
|
602
|
+
// 3. Transcript ERROR steps of the current turn (after the last user input).
|
|
603
|
+
const transcriptItems = [];
|
|
604
|
+
const section = /FLEET_TRANSCRIPT_START([\s\S]*?)FLEET_TRANSCRIPT_END/.exec(stdout)?.[1];
|
|
605
|
+
if (section) {
|
|
606
|
+
const entries = [];
|
|
607
|
+
for (const line of section.split(/\r?\n/)) {
|
|
608
|
+
const l = line.trim();
|
|
609
|
+
if (!l.startsWith('{'))
|
|
610
|
+
continue;
|
|
611
|
+
try {
|
|
612
|
+
entries.push(JSON.parse(l));
|
|
613
|
+
}
|
|
614
|
+
catch { /* skip */ }
|
|
615
|
+
}
|
|
616
|
+
let from = 0;
|
|
617
|
+
entries.forEach((e, i) => { if (e && e.type === 'USER_INPUT')
|
|
618
|
+
from = i + 1; });
|
|
619
|
+
for (const e of entries.slice(from)) {
|
|
620
|
+
if (!e || e.status !== 'ERROR' || typeof e.error !== 'string')
|
|
621
|
+
continue;
|
|
622
|
+
for (const re of AGY_TRANSCRIPT_DENIAL_RES) {
|
|
623
|
+
const m = re.exec(e.error);
|
|
624
|
+
if (m) {
|
|
625
|
+
transcriptItems.push({ action: m[1], target: m[2] });
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
if (transcriptItems.length)
|
|
632
|
+
signals.push('transcript');
|
|
633
|
+
const denied = jsonActions.length > 0 || stderrActions.length > 0 || (!sawEnvelope && transcriptItems.length > 0);
|
|
634
|
+
if (!denied)
|
|
635
|
+
return undefined;
|
|
636
|
+
const denials = [];
|
|
637
|
+
const seen = new Set();
|
|
638
|
+
const add = (item) => {
|
|
639
|
+
const key = `${item.action}\u0000${item.target ?? ''}`;
|
|
640
|
+
if (!seen.has(key)) {
|
|
641
|
+
seen.add(key);
|
|
642
|
+
denials.push(item);
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
transcriptItems.forEach(add);
|
|
646
|
+
for (const action of [...jsonActions, ...stderrActions]) {
|
|
647
|
+
if (!denials.some(d => d.action === action))
|
|
648
|
+
add({ action });
|
|
649
|
+
}
|
|
650
|
+
const actions = [...new Set(denials.map(d => d.action))];
|
|
651
|
+
const perDenial = denials.map(d => suggestedGrantsFor(d));
|
|
652
|
+
const primary = [...new Set(perDenial.map(g => g[0]).filter((g) => !!g))];
|
|
653
|
+
const narrow = [...new Set(perDenial.flatMap(g => g.slice(1)))].filter(g => !primary.includes(g));
|
|
654
|
+
const suggestedGrants = [...primary, ...narrow];
|
|
655
|
+
const what = denials.map(d => (d.target ? `${d.action} "${d.target}"` : d.action)).join(', ');
|
|
656
|
+
let hint = `agy auto-denied ${what} (headless mode cannot prompt for permission).`;
|
|
657
|
+
if (suggestedGrants.length) {
|
|
658
|
+
hint += ` Grant it with compose_permissions grant: ${JSON.stringify(primary)} and retry.`;
|
|
659
|
+
if (narrow.length)
|
|
660
|
+
hint += ` Narrower alternative (this exact command line only): ${JSON.stringify(narrow)}.`;
|
|
661
|
+
}
|
|
662
|
+
else {
|
|
663
|
+
hint += ' No compose_permissions grant maps to this action automatically; grant it on the member by hand or escalate.';
|
|
664
|
+
}
|
|
665
|
+
if (actions.includes('command') || actions.includes('unsandboxed')) {
|
|
666
|
+
hint += agentOs === 'windows'
|
|
667
|
+
? ' On Windows, Bash(<bin>:*) composes to command(<bin>) plus command(regex:<bin> .*), which allows <bin> with any arguments.'
|
|
668
|
+
: ' Bash(<bin>:*) composes to command(<bin>) plus command(regex:<bin> .*): command(<bin>) matches <bin> and its arguments by word prefix, and a command line with $(...), backticks, brace expansion or redirections needs the regex rule, which matches the full line.';
|
|
669
|
+
}
|
|
670
|
+
return { actions, denials, suggestedGrants, hint, signals };
|
|
671
|
+
}
|
|
672
|
+
export const AGY_MEMBER_ALLOWED_TOOLS = [
|
|
673
|
+
'code_graph', 'code_impact', 'code_query', 'code_context', 'code_map',
|
|
674
|
+
'code_flow', 'code_tests', 'kb_session_prime', 'kb_query', 'kb_stats',
|
|
675
|
+
'kb_capture', 'kb_feedback', 'kb_list',
|
|
676
|
+
];
|
|
677
|
+
export const AGY_ORCHESTRATOR_DENIED_TOOLS = [
|
|
678
|
+
'register_member', 'list_members', 'get_member_model_pricing', 'remove_member',
|
|
679
|
+
'update_member', 'dolt_push_mutex', 'child_id_allocator', 'member_reservation',
|
|
680
|
+
'send_files', 'receive_files', 'execute_prompt', 'execute_command',
|
|
681
|
+
'provision_llm_auth', 'setup_ssh_key', 'setup_git_app', 'provision_vcs_auth',
|
|
682
|
+
'revoke_vcs_auth', 'vcs_credential_exec', 'fleet_status', 'member_detail',
|
|
683
|
+
'update_llm_cli', 'shutdown_server', 'version', 'compose_permissions',
|
|
684
|
+
'cloud_control', 'monitor_task', 'stop_prompt', 'credential_store_set',
|
|
685
|
+
'credential_store_list', 'credential_store_delete', 'credential_store_update',
|
|
686
|
+
'send_email', 'send_message', 'report_status', 'respond_to_message',
|
|
687
|
+
'kb_invalidate', 'kb_context', 'kb_harvest', 'kb_promote',
|
|
688
|
+
'kb_freshness_sweep', 'kb_import', 'kb_resolve_contradiction',
|
|
689
|
+
'kb_reconcile_prefilter', 'kb_setup', 'kb_export',
|
|
690
|
+
];
|
|
691
|
+
export const AGY_ORCHESTRATOR_DENY_RULES = AGY_ORCHESTRATOR_DENIED_TOOLS.flatMap(tool => [
|
|
692
|
+
`mcp(apra-fleet/${tool})`,
|
|
693
|
+
`mcp(apra-fleet-member/${tool})`
|
|
694
|
+
]);
|
|
695
|
+
export async function checkAgyMemberSkills(execCommand, memberHomeDir, agentOs = 'linux', shell) {
|
|
696
|
+
const jsCode = `const fs = require('fs');
|
|
697
|
+
const path = require('path');
|
|
698
|
+
const home = ${memberHomeDir ? JSON.stringify(memberHomeDir) : 'process.env.HOME || process.env.USERPROFILE'};
|
|
699
|
+
const skillsDir = path.join(home, '.gemini', 'antigravity-cli', 'skills');
|
|
700
|
+
const pmInstalled = fs.existsSync(path.join(skillsDir, 'pm'));
|
|
701
|
+
const fleetInstalled = fs.existsSync(path.join(skillsDir, 'fleet'));
|
|
702
|
+
console.log(JSON.stringify({ pmInstalled, fleetInstalled, skillsDir }));
|
|
703
|
+
`;
|
|
704
|
+
const cmd = buildAgyNodeCommand(jsCode, agentOs, 'FLEET_SKILLS_EOF');
|
|
705
|
+
let result;
|
|
706
|
+
try {
|
|
707
|
+
result = await execCommand(cmd, 5000);
|
|
708
|
+
}
|
|
709
|
+
catch (err) {
|
|
710
|
+
const detail = err?.message || String(err);
|
|
711
|
+
return {
|
|
712
|
+
installed: [],
|
|
713
|
+
probeFailed: true,
|
|
714
|
+
warning: `[fleet:warn] agy: member skills check probe could not run (${detail}). Global skill isolation status unverified.`,
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
if (result.code !== 0) {
|
|
718
|
+
const errOutput = (result.stderr || result.stdout || '').trim();
|
|
719
|
+
const detail = errOutput ? `exit code ${result.code}: ${errOutput}` : `exit code ${result.code}`;
|
|
720
|
+
return {
|
|
721
|
+
installed: [],
|
|
722
|
+
probeFailed: true,
|
|
723
|
+
warning: `[fleet:warn] agy: member skills check probe could not run (${detail}). Global skill isolation status unverified.`,
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
const raw = result.stdout ? result.stdout.trim() : '';
|
|
727
|
+
if (!raw) {
|
|
728
|
+
return {
|
|
729
|
+
installed: [],
|
|
730
|
+
probeFailed: true,
|
|
731
|
+
warning: `[fleet:warn] agy: member skills check probe could not run (empty output). Global skill isolation status unverified.`,
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
try {
|
|
735
|
+
const parsed = JSON.parse(raw);
|
|
736
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
737
|
+
return {
|
|
738
|
+
installed: [],
|
|
739
|
+
probeFailed: true,
|
|
740
|
+
warning: `[fleet:warn] agy: member skills check probe could not run (non-object JSON output). Global skill isolation status unverified.`,
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
const installed = [];
|
|
744
|
+
if (parsed.pmInstalled)
|
|
745
|
+
installed.push('pm');
|
|
746
|
+
if (parsed.fleetInstalled)
|
|
747
|
+
installed.push('fleet');
|
|
748
|
+
const skillsDir = typeof parsed.skillsDir === 'string' ? parsed.skillsDir : undefined;
|
|
749
|
+
if (installed.length > 0) {
|
|
750
|
+
const list = installed.join(', ');
|
|
751
|
+
const loc = skillsDir ? ` in ${skillsDir}` : '';
|
|
752
|
+
return {
|
|
753
|
+
installed,
|
|
754
|
+
skillsDir,
|
|
755
|
+
probeFailed: false,
|
|
756
|
+
warning: `[fleet:warn] agy: AGY provider has no per-member skill isolation mechanism. Global skill(s) [${list}] are installed${loc} and will be visible to this member.`,
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
return {
|
|
760
|
+
installed: [],
|
|
761
|
+
skillsDir,
|
|
762
|
+
probeFailed: false,
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
catch (e) {
|
|
766
|
+
return {
|
|
767
|
+
installed: [],
|
|
768
|
+
probeFailed: true,
|
|
769
|
+
warning: `[fleet:warn] agy: member skills check probe could not run (unparseable output: ${raw}). Global skill isolation status unverified.`,
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
export function checkAgyGlobalSkillsWarning(homeDir) {
|
|
774
|
+
const home = resolveHomeDir(homeDir);
|
|
775
|
+
if (!home)
|
|
776
|
+
return null;
|
|
777
|
+
const skillsDir = path.join(home, '.gemini', 'antigravity-cli', 'skills');
|
|
778
|
+
const pmInstalled = fs.existsSync(path.join(skillsDir, 'pm'));
|
|
779
|
+
const fleetInstalled = fs.existsSync(path.join(skillsDir, 'fleet'));
|
|
780
|
+
if (pmInstalled || fleetInstalled) {
|
|
781
|
+
const list = [pmInstalled && 'pm', fleetInstalled && 'fleet'].filter(Boolean).join(', ');
|
|
782
|
+
return `[fleet:warn] agy: AGY provider has no per-member skill isolation mechanism. Global skill(s) [${list}] are installed in ${skillsDir} and will be visible to AGY members.`;
|
|
783
|
+
}
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
786
|
+
/** The ONLY actions AGY accepts in `permissions.allow`. Taken verbatim from the
|
|
787
|
+
* CLI's own validation regex (agy 1.2.8):
|
|
788
|
+
* ^(command|read_file|write_file|read_url|mcp|execute_url|unsandboxed)\s*\(.*\)$
|
|
789
|
+
* `custom`, `invoke_subagent` and `send_message` are NOT permission actions --
|
|
790
|
+
* the latter two are AGY *tool* names with no permission gate of their own --
|
|
791
|
+
* so rules carrying them are dropped at serialization time rather than written
|
|
792
|
+
* as entries AGY would reject. */
|
|
793
|
+
const AGY_PERMISSION_ACTIONS = new Set(['command', 'read_file', 'write_file', 'read_url', 'mcp', 'execute_url', 'unsandboxed']);
|
|
794
|
+
/**
|
|
795
|
+
* Render structured rules into the ONLY shape AGY's permission parser
|
|
796
|
+
* accepts: a flat array of `action(target)` STRINGS in permissionGrants.allow.
|
|
797
|
+
*
|
|
798
|
+
* Before this, fleet wrote the `{ action, target }` objects straight through.
|
|
799
|
+
* AGY silently ignored every one of them, so a headless `-p` dispatch behaved
|
|
800
|
+
* as if the member had no grants at all and died on the first tool call with
|
|
801
|
+
* "a tool required the \"command\" permission that headless mode cannot prompt
|
|
802
|
+
* for, so it was auto-denied" -- the failure this function exists to prevent.
|
|
803
|
+
*
|
|
804
|
+
* Rules whose action is outside AGY's vocabulary are dropped with a warning:
|
|
805
|
+
* writing entries its parser rejects causes validation failure.
|
|
806
|
+
* The dropped tokens are already surfaced by
|
|
807
|
+
* convertClaudeAllowToAgyPermissions' own warnings for manual escalation.
|
|
808
|
+
*/
|
|
809
|
+
export function formatAgyPermissionRules(rules) {
|
|
810
|
+
const out = [];
|
|
811
|
+
for (const rule of rules) {
|
|
812
|
+
if (!AGY_PERMISSION_ACTIONS.has(rule.action)) {
|
|
813
|
+
console.warn(`[agy] dropping permission rule "${rule.action}(${rule.target})": AGY's permissions.allow accepts only ${[...AGY_PERMISSION_ACTIONS].join(', ')}.`);
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
816
|
+
const entry = `${rule.action}(${rule.target})`;
|
|
817
|
+
if (!out.includes(entry))
|
|
818
|
+
out.push(entry);
|
|
819
|
+
}
|
|
820
|
+
return out;
|
|
821
|
+
}
|
|
822
|
+
const PATH_SCOPED_READ_RE = /^(?:Read|Glob|Grep)\((.+)\)$/;
|
|
823
|
+
const PATH_SCOPED_WRITE_RE = /^(?:Write|Edit)\((.+)\)$/;
|
|
824
|
+
/** Escapes regex metacharacters so a literal command prefix can sit inside an
|
|
825
|
+
* agy `regex:` target. Spaces are kept. */
|
|
826
|
+
export function escapeAgyRegex(s) {
|
|
827
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
828
|
+
}
|
|
829
|
+
/** The agy `command` targets for one Claude command prefix, on every OS. agy
|
|
830
|
+
* prefix-matches `command(git)` word by word only for a command line it can
|
|
831
|
+
* split into words: on Windows that excludes most lines (PowerShell/cmd), and
|
|
832
|
+
* on Linux/macOS a line with command substitution, backticks, brace expansion
|
|
833
|
+
* or fd redirections disables prefix matching. A `regex:` target is matched
|
|
834
|
+
* against the full raw line (docs/agy-provider.md section 3),
|
|
835
|
+
* so a prefix grant becomes the bare command plus a regex for any arguments.
|
|
836
|
+
* A command deny rule must be built here too, so it matches full lines. */
|
|
837
|
+
export function agyCommandRules(cmd) {
|
|
838
|
+
if (cmd === '*')
|
|
839
|
+
return ['*'];
|
|
840
|
+
return [cmd, `regex:${escapeAgyRegex(cmd)} .*`];
|
|
841
|
+
}
|
|
842
|
+
/** Reduces a Claude path pattern to the plain path agy's read_file/write_file
|
|
843
|
+
* targets take (agy has no globs and grants a directory recursively): a
|
|
844
|
+
* leading `~` becomes the member's home directory, a trailing `/**` or `/*`
|
|
845
|
+
* becomes the directory itself, and a bare `*`/`**` is the global wildcard.
|
|
846
|
+
* A glob anywhere else cannot be expressed: no target is returned and the
|
|
847
|
+
* caller drops the grant with a warning. */
|
|
848
|
+
function agyPathTarget(item, opts) {
|
|
849
|
+
let inner = item.slice(item.indexOf('(') + 1, -1).trim();
|
|
850
|
+
if (inner === '*' || inner === '**')
|
|
851
|
+
return { target: '*' };
|
|
852
|
+
if (inner === '~' || inner.startsWith('~/') || inner.startsWith('~\\')) {
|
|
853
|
+
if (!opts.homeDir)
|
|
854
|
+
return { reason: 'the member home directory is unknown, so ~ cannot be resolved' };
|
|
855
|
+
const home = opts.homeDir.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
856
|
+
inner = inner === '~' ? home : `${home}/${inner.slice(2).replace(/\\/g, '/')}`;
|
|
857
|
+
}
|
|
858
|
+
const stripped = inner.replace(/[\\/]\*{1,2}$/, '');
|
|
859
|
+
if (/[*?]/.test(stripped))
|
|
860
|
+
return { reason: 'agy path targets cannot hold a glob' };
|
|
861
|
+
const trimmed = stripped.replace(/[\\/]+$/, '');
|
|
862
|
+
return { target: trimmed || '*' };
|
|
863
|
+
}
|
|
864
|
+
export function convertClaudeAllowToAgyPermissions(allow, opts = {}) {
|
|
375
865
|
const rules = [];
|
|
376
866
|
const added = new Set();
|
|
377
867
|
const addRule = (action, target) => {
|
|
@@ -381,6 +871,17 @@ export function convertClaudeAllowToAgyPermissions(allow) {
|
|
|
381
871
|
rules.push({ action, target });
|
|
382
872
|
}
|
|
383
873
|
};
|
|
874
|
+
const addPathRule = (action, item) => {
|
|
875
|
+
const { target, reason } = agyPathTarget(item, opts);
|
|
876
|
+
if (target !== undefined) {
|
|
877
|
+
addRule(action, target);
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
const line = `agy: dropped "${item}" -- ${reason}; grant a directory or an exact path instead.`;
|
|
881
|
+
console.warn(`[fleet:warn] ${line}`);
|
|
882
|
+
if (opts.warnings && !opts.warnings.includes(line))
|
|
883
|
+
opts.warnings.push(line);
|
|
884
|
+
};
|
|
384
885
|
for (const item of allow) {
|
|
385
886
|
if (item === 'Read' || item === 'Glob' || item === 'Grep') {
|
|
386
887
|
addRule('read_file', '*');
|
|
@@ -388,18 +889,35 @@ export function convertClaudeAllowToAgyPermissions(allow) {
|
|
|
388
889
|
else if (item === 'Write' || item === 'Edit') {
|
|
389
890
|
addRule('write_file', '*');
|
|
390
891
|
}
|
|
892
|
+
else if (PATH_SCOPED_READ_RE.test(item)) {
|
|
893
|
+
// Path-scoped Claude grant, e.g. Read(/home/u/.claude/skills/**). AGY
|
|
894
|
+
// targets are path PREFIXES (`read_file(/Users/alice/notes)`), so the
|
|
895
|
+
// trailing glob is stripped; a bare `Read`/`Write` (no argument) is
|
|
896
|
+
// unrestricted in Claude and keeps mapping to '*' above.
|
|
897
|
+
addPathRule('read_file', item);
|
|
898
|
+
}
|
|
899
|
+
else if (PATH_SCOPED_WRITE_RE.test(item)) {
|
|
900
|
+
addPathRule('write_file', item);
|
|
901
|
+
}
|
|
391
902
|
else if (item === 'Agent') {
|
|
392
903
|
addRule('invoke_subagent', '*');
|
|
393
904
|
addRule('send_message', '*');
|
|
394
905
|
}
|
|
395
906
|
else if (item.startsWith('Bash(')) {
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
398
|
-
|
|
399
|
-
addRule('command',
|
|
907
|
+
const inner = item.endsWith(')') ? item.slice(5, -1).trim() : '';
|
|
908
|
+
if (inner && !inner.includes('*')) {
|
|
909
|
+
// Exact grant (no wildcard): that command line only, no widening.
|
|
910
|
+
addRule('command', inner);
|
|
400
911
|
}
|
|
401
912
|
else {
|
|
402
|
-
|
|
913
|
+
const match = item.match(/^Bash\(([^:*]+)(?::|\s|\*|\))/);
|
|
914
|
+
if (match && match[1]) {
|
|
915
|
+
for (const t of agyCommandRules(match[1].trim()))
|
|
916
|
+
addRule('command', t);
|
|
917
|
+
}
|
|
918
|
+
else {
|
|
919
|
+
addRule('command', '*');
|
|
920
|
+
}
|
|
403
921
|
}
|
|
404
922
|
}
|
|
405
923
|
else if (item === 'Bash') {
|
|
@@ -413,25 +931,32 @@ export function convertClaudeAllowToAgyPermissions(allow) {
|
|
|
413
931
|
addRule('mcp', '*');
|
|
414
932
|
}
|
|
415
933
|
else if (item.startsWith('mcp__')) {
|
|
416
|
-
// Claude's real MCP permission-string format is `mcp__<server>__<tool>`
|
|
417
|
-
// "mcp__apra-fleet__kb_capture") -- NOT the fictional `Mcp(name)`
|
|
418
|
-
//
|
|
419
|
-
//
|
|
420
|
-
//
|
|
421
|
-
//
|
|
422
|
-
//
|
|
423
|
-
//
|
|
424
|
-
//
|
|
425
|
-
//
|
|
426
|
-
//
|
|
427
|
-
//
|
|
428
|
-
//
|
|
429
|
-
//
|
|
934
|
+
// Claude's real MCP permission-string format is `mcp__<server>__<tool>`
|
|
935
|
+
// (e.g. "mcp__apra-fleet__kb_capture") -- NOT the fictional `Mcp(name)`
|
|
936
|
+
// shape above. AGY expresses the SAME per-tool granularity as
|
|
937
|
+
// `mcp(<server>/<tool>)` (its own docs: "mcp(<server_name>/<tool_name>)
|
|
938
|
+
// e.g. mcp(buganizer/get_bugs)", and a denial reads
|
|
939
|
+
// `user denied permission for mcp(apra-fleet/kb_session_prime)`), so the
|
|
940
|
+
// two map across exactly, with no widening.
|
|
941
|
+
//
|
|
942
|
+
// This previously refused to map at all, on the belief that AGY was
|
|
943
|
+
// server-granular only -- which WOULD have been a privilege escalation,
|
|
944
|
+
// since the 'apra-fleet' server colocates safe read-only KB tools with
|
|
945
|
+
// destructive fleet-admin ones (remove_member, shutdown_server,
|
|
946
|
+
// credential_store_*; see src/services/tool-registry.ts). That belief is
|
|
947
|
+
// wrong for AGY 1.2.8, and the cost of the workaround was real: the
|
|
948
|
+
// deployer's Step 0 kb_session_prime was auto-denied in headless mode,
|
|
949
|
+
// taking the whole Deploy phase down with it. Note what is NOT done here:
|
|
950
|
+
// a bare server-level `mcp(apra-fleet)` is still never emitted.
|
|
430
951
|
const rest = item.slice('mcp__'.length);
|
|
431
952
|
const sep = rest.indexOf('__');
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
953
|
+
if (sep < 0) {
|
|
954
|
+
console.warn(`[agy] warning: unmapped mcp permission token "${item}" (expected mcp__<server>__<tool>)`);
|
|
955
|
+
addRule('custom', item);
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
addRule('mcp', `${rest.slice(0, sep)}/${rest.slice(sep + 2)}`);
|
|
959
|
+
}
|
|
435
960
|
}
|
|
436
961
|
else if (item === 'Web' || item === 'Fetch' || item === 'WebSearch') {
|
|
437
962
|
addRule('read_url', '*');
|