@apralabs/apra-fleet 0.4.3 → 0.4.5
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 +114 -33
- package/dist/agents/backlog-groomer.md +80 -27
- package/dist/agents/ci-watcher.md +42 -22
- package/dist/agents/deployer.md +59 -24
- package/dist/agents/doer.md +111 -41
- package/dist/agents/harvester.md +60 -48
- package/dist/agents/integ-test-runner.md +45 -23
- package/dist/agents/kb-reconciler.md +34 -7
- package/dist/agents/plan-reviewer.md +54 -24
- package/dist/agents/planner.md +71 -43
- package/dist/agents/regression-test-runner.md +106 -78
- package/dist/agents/reviewer.md +170 -57
- package/dist/agents/schemas/backlog-groomer-output.json +1 -1
- package/dist/agents/schemas/deployer-output.json +5 -0
- package/dist/agents/schemas/doer-output.json +110 -2
- 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 +166 -5
- 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 +42 -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 +26 -0
- package/dist/cli/call.d.ts +27 -0
- package/dist/cli/call.js +177 -0
- package/dist/cli/claude-mod.d.ts +75 -0
- package/dist/cli/claude-mod.js +288 -0
- package/dist/cli/config.d.ts +24 -1
- package/dist/cli/config.js +69 -2
- package/dist/cli/dolt-install.d.ts +19 -3
- package/dist/cli/dolt-install.js +51 -16
- package/dist/cli/fleet-se-guard.d.ts +59 -0
- package/dist/cli/fleet-se-guard.js +231 -0
- package/dist/cli/install-guard.d.ts +63 -0
- package/dist/cli/install-guard.js +156 -4
- package/dist/cli/install.d.ts +89 -21
- package/dist/cli/install.js +778 -160
- 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/kb-profile.d.ts +16 -0
- package/dist/cli/kb-profile.js +81 -0
- 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 +62 -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 +112 -16
- package/dist/cli/update.d.ts +4 -0
- package/dist/cli/update.js +52 -5
- package/dist/cli/watch.js +1 -1
- package/dist/cli/workflow.js +3 -2
- package/dist/commands/kb-server.d.ts +10 -1
- package/dist/commands/kb-server.js +292 -11
- package/dist/hub-service/http-server.d.ts +5 -1
- package/dist/hub-service/http-server.js +55 -5
- package/dist/index.js +177 -9
- package/dist/os/child-env-bound.d.ts +77 -0
- package/dist/os/child-env-bound.js +171 -0
- package/dist/os/git-executable.d.ts +57 -0
- package/dist/os/git-executable.js +85 -0
- package/dist/os/go-concurrency.d.ts +44 -0
- package/dist/os/go-concurrency.js +53 -0
- package/dist/os/index.d.ts +1 -0
- package/dist/os/index.js +1 -0
- package/dist/os/linux.d.ts +9 -2
- package/dist/os/linux.js +50 -15
- package/dist/os/macos.d.ts +1 -1
- package/dist/os/macos.js +2 -11
- package/dist/os/os-commands.d.ts +42 -2
- package/dist/os/os-commands.js +2 -0
- package/dist/os/windows-executable.d.ts +53 -0
- package/dist/os/windows-executable.js +185 -0
- package/dist/os/windows-gitbash.d.ts +24 -14
- package/dist/os/windows-gitbash.js +56 -18
- package/dist/os/windows-wrapper.d.ts +0 -4
- package/dist/os/windows-wrapper.js +2 -1
- package/dist/os/windows.d.ts +7 -2
- package/dist/os/windows.js +109 -32
- package/dist/paths.d.ts +30 -0
- package/dist/paths.js +52 -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 +9 -2
- package/dist/services/agy-project.js +22 -19
- package/dist/services/auth-socket.d.ts +43 -0
- package/dist/services/auth-socket.js +97 -26
- 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/credential-store.d.ts +33 -0
- package/dist/services/credential-store.js +79 -2
- 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 +78 -1
- package/dist/services/http-transport.js +347 -52
- package/dist/services/in-flight-agents.d.ts +2 -0
- package/dist/services/in-flight-agents.js +4 -0
- package/dist/services/kb-tool-profile.d.ts +36 -0
- package/dist/services/kb-tool-profile.js +88 -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 +122 -0
- package/dist/services/knowledge/bible-import.d.ts +173 -0
- package/dist/services/knowledge/bible-import.js +344 -0
- package/dist/services/knowledge/file-hash.d.ts +31 -0
- package/dist/services/knowledge/file-hash.js +155 -24
- package/dist/services/knowledge/http-provider.d.ts +305 -21
- package/dist/services/knowledge/http-provider.js +801 -119
- package/dist/services/knowledge/kb-config.d.ts +65 -1
- package/dist/services/knowledge/kb-config.js +143 -3
- package/dist/services/knowledge/kb-http-auth-state.d.ts +26 -0
- package/dist/services/knowledge/kb-http-auth-state.js +40 -0
- package/dist/services/knowledge/kb-maintainer-grant.d.ts +15 -0
- package/dist/services/knowledge/kb-maintainer-grant.js +34 -0
- package/dist/services/knowledge/kb-providers.d.ts +13 -2
- package/dist/services/knowledge/kb-providers.js +75 -37
- 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 +204 -0
- package/dist/services/knowledge/kb-self.js +358 -0
- package/dist/services/knowledge/member-bible-view.d.ts +21 -0
- package/dist/services/knowledge/member-bible-view.js +207 -0
- package/dist/services/knowledge/path-validation.d.ts +7 -0
- package/dist/services/knowledge/path-validation.js +11 -0
- package/dist/services/knowledge/pre-init.js +1 -0
- package/dist/services/knowledge/project-slug.js +5 -4
- package/dist/services/knowledge/repository-header.d.ts +77 -0
- package/dist/services/knowledge/repository-header.js +233 -0
- package/dist/services/knowledge/require-sqlite-project.d.ts +1 -1
- package/dist/services/knowledge/require-sqlite-project.js +1 -1
- package/dist/services/knowledge/sqlite-provider.d.ts +233 -11
- package/dist/services/knowledge/sqlite-provider.js +719 -45
- package/dist/services/knowledge/types.d.ts +59 -3
- package/dist/services/member-access-secret.d.ts +70 -0
- package/dist/services/member-access-secret.js +195 -0
- package/dist/services/member-busy.d.ts +12 -0
- package/dist/services/member-busy.js +20 -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 +193 -0
- package/dist/services/member-config-io.js +446 -0
- package/dist/services/member-fleet-install.d.ts +710 -0
- package/dist/services/member-fleet-install.js +1896 -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 +115 -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 +352 -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 +54 -3
- package/dist/services/service-manager/types.js +29 -0
- package/dist/services/service-manager/windows.d.ts +187 -3
- package/dist/services/service-manager/windows.js +684 -50
- package/dist/services/service-notice.d.ts +21 -0
- package/dist/services/service-notice.js +81 -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/session-registry.d.ts +13 -0
- package/dist/services/session-registry.js +13 -0
- package/dist/services/session-roots.d.ts +67 -0
- package/dist/services/session-roots.js +126 -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/statusline.d.ts +21 -0
- package/dist/services/statusline.js +97 -1
- 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 +333 -0
- package/dist/services/tool-registry.d.ts +8 -1
- package/dist/services/tool-registry.js +251 -62
- package/dist/services/tool-scope.d.ts +91 -0
- package/dist/services/tool-scope.js +124 -0
- package/dist/services/vcs/azure-devops.js +10 -0
- package/dist/services/vcs/bitbucket.d.ts +22 -1
- package/dist/services/vcs/bitbucket.js +163 -17
- package/dist/services/vcs/types.d.ts +25 -2
- package/dist/services/watch/project-resolver.js +3 -1
- 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/cost.md +5 -1
- package/dist/skills/pm/index.md +11 -9
- package/dist/skills/pm/kb-reconcile.md +29 -14
- package/dist/skills/pm/kb-review.md +1 -0
- package/dist/skills/pm/sprint.md +7 -6
- package/dist/tools/check-status.d.ts +104 -5
- package/dist/tools/check-status.js +326 -57
- 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 +49 -0
- package/dist/tools/code-intelligence-gitnexus.js +488 -55
- package/dist/tools/code-intelligence-kb-enrich.js +7 -6
- package/dist/tools/code-intelligence-readiness.d.ts +156 -0
- package/dist/tools/code-intelligence-readiness.js +291 -0
- package/dist/tools/code-intelligence-reindex.d.ts +219 -0
- package/dist/tools/code-intelligence-reindex.js +602 -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 +92 -18
- package/dist/tools/execute-prompt.d.ts +59 -15
- package/dist/tools/execute-prompt.js +550 -135
- package/dist/tools/fleet-snapshot.d.ts +21 -0
- package/dist/tools/fleet-snapshot.js +78 -0
- package/dist/tools/kb-bible-commit.d.ts +79 -0
- package/dist/tools/kb-bible-commit.js +348 -0
- package/dist/tools/kb-capture.d.ts +15 -11
- package/dist/tools/kb-capture.js +42 -11
- package/dist/tools/kb-context.d.ts +27 -7
- package/dist/tools/kb-context.js +85 -14
- package/dist/tools/kb-demote.d.ts +27 -0
- package/dist/tools/kb-demote.js +37 -0
- package/dist/tools/kb-export.d.ts +128 -7
- package/dist/tools/kb-export.js +273 -67
- package/dist/tools/kb-feedback.d.ts +15 -9
- package/dist/tools/kb-feedback.js +27 -11
- 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 +35 -16
- package/dist/tools/kb-import.d.ts +42 -10
- package/dist/tools/kb-import.js +185 -160
- package/dist/tools/kb-invalidate.d.ts +26 -11
- package/dist/tools/kb-invalidate.js +118 -12
- package/dist/tools/kb-list.d.ts +14 -10
- package/dist/tools/kb-list.js +61 -13
- package/dist/tools/kb-promote.d.ts +11 -7
- package/dist/tools/kb-promote.js +16 -8
- package/dist/tools/kb-query.d.ts +24 -11
- package/dist/tools/kb-query.js +230 -23
- 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 +127 -47
- package/dist/tools/kb-setup.d.ts +31 -4
- package/dist/tools/kb-setup.js +172 -20
- package/dist/tools/kb-stats.d.ts +11 -10
- package/dist/tools/kb-stats.js +22 -41
- package/dist/tools/list-members.js +6 -3
- package/dist/tools/member-detail.d.ts +3 -0
- package/dist/tools/member-detail.js +95 -20
- 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 +30 -5
- package/dist/tools/provision-vcs-auth.js +53 -7
- package/dist/tools/receive-files.js +8 -3
- 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 +9 -6
- package/dist/tools/send-message.d.ts +3 -0
- package/dist/tools/send-message.js +15 -2
- 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/stop-prompt.js +3 -1
- package/dist/tools/update-agent-cli.d.ts +19 -0
- package/dist/tools/update-agent-cli.js +59 -2
- package/dist/tools/update-member.d.ts +13 -10
- package/dist/tools/update-member.js +138 -7
- package/dist/tools/vcs-credential-exec.d.ts +45 -3
- package/dist/tools/vcs-credential-exec.js +98 -13
- 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 +72 -0
- package/dist/utils/prompt-errors.js +4 -1
- package/dist/utils/redact-known-secrets.d.ts +17 -0
- package/dist/utils/redact-known-secrets.js +70 -0
- 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/skill-matrix.js +1 -1
- package/dist/utils/ssh-error-messages.js +3 -0
- package/dist/utils/vcs-provider-detect.js +2 -2
- package/dist/utils/workspace-trust.d.ts +24 -1
- package/dist/utils/workspace-trust.js +21 -17
- package/dist/workflows/auto-sprint.js +468 -52
- package/package.json +15 -9
- package/packages/apra-fleet-client/package.json +2 -2
- package/packages/apra-fleet-client/src/client/api.mjs +722 -38
- 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 +170 -0
- package/packages/apra-fleet-client/src/client/server-resolution.mjs +267 -30
- package/packages/apra-fleet-client/src/client/transport.mjs +43 -3
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +80 -27
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +42 -22
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +59 -24
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +111 -41
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +60 -48
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +45 -23
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +34 -7
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +54 -24
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +71 -43
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +106 -78
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +170 -57
- package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-output.json +1 -1
- package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +110 -2
- 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 +166 -5
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +3 -3
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +5 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +11 -9
- 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 +7 -6
- package/packages/apra-fleet-se/bin/cli.mjs +282 -79
- package/packages/apra-fleet-se/bin/serve.mjs +186 -15
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +234 -46
- package/packages/apra-fleet-se/fleet-sprint/backlog-role.mjs +93 -0
- package/packages/apra-fleet-se/fleet-sprint/bd-sync-command.mjs +69 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +229 -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-lock-probe.mjs +176 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-memory-hygiene.mjs +201 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-reachability.mjs +126 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +271 -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 +142 -3
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +48 -8
- package/packages/apra-fleet-se/fleet-sprint/decision-notify.mjs +338 -0
- package/packages/apra-fleet-se/fleet-sprint/decision-wait.mjs +731 -0
- package/packages/apra-fleet-se/fleet-sprint/decisions.mjs +372 -0
- 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 +244 -22
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +56 -15
- 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-settle.mjs +9 -3
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +651 -37
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +282 -15
- package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +4 -4
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +207 -10
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +169 -10
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +88 -5
- 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 +1896 -305
- 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 +454 -1
- 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 +129 -0
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +302 -52
- 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 +142 -21
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +118 -36
- package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +6 -6
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +27 -18
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +99 -52
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +58 -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 +90 -15
- package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +272 -0
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +113 -28
- package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +19 -1
- package/packages/apra-fleet-se/fleet-sprint/runner.js +1631 -213
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +26 -0
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +183 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +138 -0
- package/packages/apra-fleet-se/fleet-sprint/set-aside.mjs +288 -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 +87 -32
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +158 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +132 -11
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +31 -0
- package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +7 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +774 -35
- 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/bitbucket.mjs +811 -17
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +223 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +138 -1
- 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 +460 -23
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +59 -3
- package/packages/apra-fleet-se/package.json +2 -2
- package/packages/apra-fleet-se/src/supervisor/api.mjs +1059 -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 +1662 -0
- package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +370 -0
- package/packages/apra-fleet-se/src/supervisor/dolt-orphan-sweep.mjs +338 -0
- package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +292 -0
- package/packages/apra-fleet-se/src/supervisor/history-view.mjs +276 -0
- package/packages/apra-fleet-se/src/supervisor/history.mjs +335 -0
- package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +611 -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 +499 -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 +542 -0
- package/packages/apra-fleet-se/src/supervisor/spawner.mjs +544 -0
- package/packages/apra-fleet-se/src/supervisor/sprint-identity.mjs +96 -0
- package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +993 -0
- package/packages/apra-fleet-workflow/package.json +3 -2
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +150 -14
- package/packages/apra-fleet-workflow/src/viewer/request-guard.mjs +222 -0
- package/packages/apra-fleet-workflow/src/viewer/run-summary.mjs +127 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +105 -7
- package/packages/apra-fleet-workflow/src/workflow/pricing.mjs +75 -25
- package/plugins/claude-code/fleet-status/.claude-plugin/plugin.json +7 -0
- package/plugins/claude-code/fleet-status/hooks/hooks.json +1 -0
- package/plugins/claude-code/fleet-status/hooks/register.tsx +906 -0
- package/plugins/claude-code/fleet-status/types/index.d.ts +88 -0
- package/skills/fleet/auth-bitbucket.md +47 -20
- package/skills/fleet/onboarding.md +1 -1
- package/skills/fleet/permissions.md +9 -0
- package/skills/fleet/profiles/tag-kb-reconciler.json +2 -6
- package/skills/fleet/skill-matrix.md +3 -3
- package/version.json +1 -1
- package/dist/cli/agent-transform.d.ts.map +0 -1
- package/dist/cli/agent-transform.js.map +0 -1
- package/dist/cli/auth.d.ts.map +0 -1
- package/dist/cli/auth.js.map +0 -1
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/dolt-install.d.ts.map +0 -1
- package/dist/cli/dolt-install.js.map +0 -1
- package/dist/cli/install-guard.d.ts.map +0 -1
- package/dist/cli/install-guard.js.map +0 -1
- package/dist/cli/install.d.ts.map +0 -1
- package/dist/cli/install.js.map +0 -1
- package/dist/cli/join.d.ts.map +0 -1
- package/dist/cli/join.js.map +0 -1
- package/dist/cli/kb-commit.d.ts.map +0 -1
- package/dist/cli/kb-commit.js.map +0 -1
- package/dist/cli/kb-directives.d.ts.map +0 -1
- package/dist/cli/kb-directives.js.map +0 -1
- package/dist/cli/kb-import.d.ts.map +0 -1
- package/dist/cli/kb-import.js.map +0 -1
- package/dist/cli/register-member.d.ts.map +0 -1
- package/dist/cli/register-member.js.map +0 -1
- package/dist/cli/restart.d.ts.map +0 -1
- package/dist/cli/restart.js.map +0 -1
- package/dist/cli/secret.d.ts.map +0 -1
- package/dist/cli/secret.js.map +0 -1
- package/dist/cli/spoke.d.ts.map +0 -1
- package/dist/cli/spoke.js.map +0 -1
- package/dist/cli/start.d.ts.map +0 -1
- package/dist/cli/start.js.map +0 -1
- package/dist/cli/status.d.ts.map +0 -1
- package/dist/cli/status.js.map +0 -1
- package/dist/cli/stop.d.ts.map +0 -1
- package/dist/cli/stop.js.map +0 -1
- package/dist/cli/uninstall.d.ts.map +0 -1
- package/dist/cli/uninstall.js.map +0 -1
- package/dist/cli/update.d.ts.map +0 -1
- package/dist/cli/update.js.map +0 -1
- package/dist/cli/watch.d.ts.map +0 -1
- package/dist/cli/watch.js.map +0 -1
- package/dist/cli/workflow-assets.d.ts.map +0 -1
- package/dist/cli/workflow-assets.js.map +0 -1
- package/dist/cli/workflow.d.ts.map +0 -1
- package/dist/cli/workflow.js.map +0 -1
- package/dist/commands/kb-server.d.ts.map +0 -1
- package/dist/commands/kb-server.js.map +0 -1
- package/dist/delivery-mode.d.ts.map +0 -1
- package/dist/delivery-mode.js.map +0 -1
- package/dist/hub-service/activity.d.ts.map +0 -1
- package/dist/hub-service/activity.js.map +0 -1
- package/dist/hub-service/audit-log.d.ts.map +0 -1
- package/dist/hub-service/audit-log.js.map +0 -1
- package/dist/hub-service/db/pool.d.ts.map +0 -1
- package/dist/hub-service/db/pool.js.map +0 -1
- package/dist/hub-service/enrollment.d.ts.map +0 -1
- package/dist/hub-service/enrollment.js.map +0 -1
- package/dist/hub-service/envelope-routes.d.ts.map +0 -1
- package/dist/hub-service/envelope-routes.js.map +0 -1
- package/dist/hub-service/handlers/installers.d.ts.map +0 -1
- package/dist/hub-service/handlers/installers.js.map +0 -1
- package/dist/hub-service/http-server.d.ts.map +0 -1
- package/dist/hub-service/http-server.js.map +0 -1
- package/dist/hub-service/hub-jwt.d.ts.map +0 -1
- package/dist/hub-service/hub-jwt.js.map +0 -1
- package/dist/hub-service/jwt-revocation.d.ts.map +0 -1
- package/dist/hub-service/jwt-revocation.js.map +0 -1
- package/dist/hub-service/machines.d.ts.map +0 -1
- package/dist/hub-service/machines.js.map +0 -1
- package/dist/hub-service/main.d.ts.map +0 -1
- package/dist/hub-service/main.js.map +0 -1
- package/dist/hub-service/member-tokens.d.ts.map +0 -1
- package/dist/hub-service/member-tokens.js.map +0 -1
- package/dist/hub-service/member-view.d.ts.map +0 -1
- package/dist/hub-service/member-view.js.map +0 -1
- package/dist/hub-service/members.d.ts.map +0 -1
- package/dist/hub-service/members.js.map +0 -1
- package/dist/hub-service/presence.d.ts.map +0 -1
- package/dist/hub-service/presence.js.map +0 -1
- package/dist/hub-service/project-view.d.ts.map +0 -1
- package/dist/hub-service/project-view.js.map +0 -1
- package/dist/hub-service/projects.d.ts.map +0 -1
- package/dist/hub-service/projects.js.map +0 -1
- package/dist/hub-service/relay-queue.d.ts.map +0 -1
- package/dist/hub-service/relay-queue.js.map +0 -1
- package/dist/hub-service/session-jwt.d.ts.map +0 -1
- package/dist/hub-service/session-jwt.js.map +0 -1
- package/dist/hub-service/usage.d.ts.map +0 -1
- package/dist/hub-service/usage.js.map +0 -1
- package/dist/hub-service/users.d.ts.map +0 -1
- package/dist/hub-service/users.js.map +0 -1
- package/dist/hub-service/workspaces.d.ts.map +0 -1
- package/dist/hub-service/workspaces.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/onboarding/text.d.ts.map +0 -1
- package/dist/onboarding/text.js.map +0 -1
- package/dist/os/git-bash-candidates.d.ts.map +0 -1
- package/dist/os/git-bash-candidates.js.map +0 -1
- package/dist/os/index.d.ts.map +0 -1
- package/dist/os/index.js.map +0 -1
- package/dist/os/linux.d.ts.map +0 -1
- package/dist/os/linux.js.map +0 -1
- package/dist/os/macos.d.ts.map +0 -1
- package/dist/os/macos.js.map +0 -1
- package/dist/os/os-commands.d.ts.map +0 -1
- package/dist/os/os-commands.js.map +0 -1
- package/dist/os/windows-gitbash.d.ts.map +0 -1
- package/dist/os/windows-gitbash.js.map +0 -1
- package/dist/os/windows-wrapper.d.ts.map +0 -1
- package/dist/os/windows-wrapper.js.map +0 -1
- package/dist/os/windows.d.ts.map +0 -1
- package/dist/os/windows.js.map +0 -1
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/providers/agy.d.ts.map +0 -1
- package/dist/providers/agy.js.map +0 -1
- package/dist/providers/claude.d.ts.map +0 -1
- package/dist/providers/claude.js.map +0 -1
- package/dist/providers/codex.d.ts.map +0 -1
- package/dist/providers/codex.js.map +0 -1
- package/dist/providers/copilot.d.ts.map +0 -1
- package/dist/providers/copilot.js.map +0 -1
- package/dist/providers/email/headers.d.ts.map +0 -1
- package/dist/providers/email/headers.js.map +0 -1
- package/dist/providers/email/index.d.ts.map +0 -1
- package/dist/providers/email/index.js.map +0 -1
- package/dist/providers/email/provider.d.ts.map +0 -1
- package/dist/providers/email/provider.js.map +0 -1
- package/dist/providers/email/sendgrid.d.ts.map +0 -1
- package/dist/providers/email/sendgrid.js.map +0 -1
- package/dist/providers/email/smtp.d.ts.map +0 -1
- package/dist/providers/email/smtp.js.map +0 -1
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/none.d.ts.map +0 -1
- package/dist/providers/none.js.map +0 -1
- package/dist/providers/opencode.d.ts.map +0 -1
- package/dist/providers/opencode.js.map +0 -1
- package/dist/providers/provider.d.ts.map +0 -1
- package/dist/providers/provider.js.map +0 -1
- package/dist/services/agent-provisioner.d.ts.map +0 -1
- package/dist/services/agent-provisioner.js.map +0 -1
- package/dist/services/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
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// NEEDS-DECISION: a doer or reviewer asks a human operator to choose.
|
|
3
|
+
//
|
|
4
|
+
// A doer (status) or reviewer (verdict) may return NEEDS-DECISION with a
|
|
5
|
+
// `decision` object -- { beadId, question, options: [{ id, text }, ...],
|
|
6
|
+
// recommendation } (doer-output.json / reviewer-output.json). The bead cannot
|
|
7
|
+
// go on until an operator chooses, so re-dispatching it only burns dispatches.
|
|
8
|
+
// recordPendingDecision() below:
|
|
9
|
+
//
|
|
10
|
+
// 1. files a dedicated DECISION bead for the operator: labelled `human`,
|
|
11
|
+
// type `decision`, status `deferred`, carrying the full question and
|
|
12
|
+
// every option verbatim, linked to the work bead by a `discovered-from`
|
|
13
|
+
// edge. It is NEVER the work bead itself: `bd human respond <id>` adds a
|
|
14
|
+
// comment AND CLOSES the bead it is given (reason "Responded"), so a
|
|
15
|
+
// `human` label on the work bead would let an operator's answer close
|
|
16
|
+
// unfinished work. It is not a child of anything and has no blocks edge,
|
|
17
|
+
// so it is never sprint work; the deferred status keeps it out of
|
|
18
|
+
// `bd ready` and out of the open-bead counts even in a sprint whose
|
|
19
|
+
// scope is the whole database. `bd human list` still lists it.
|
|
20
|
+
// 2. appends the full request to the work bead's notes (`bd note --file`,
|
|
21
|
+
// which appends; never `bd update --notes`, which replaces);
|
|
22
|
+
// 3. records the decision on `sprintState.pendingDecisions` (Map
|
|
23
|
+
// decisionId -> { decisionId, beadId, question, options, recommendation,
|
|
24
|
+
// decisionBeadId, raisedBy, cycle, round, notification: {} });
|
|
25
|
+
// 4. sets the work bead aside for the rest of the run on
|
|
26
|
+
// `sprintState.doctorBlockedIds` with kind 'needs-decision' (and its open
|
|
27
|
+
// blocks-edge dependents with kind 'dependent'), exactly like a doer
|
|
28
|
+
// BLOCKED report, so it is excluded from every later round's streaks and
|
|
29
|
+
// counts as set aside for the stall decision and the "Set aside this
|
|
30
|
+
// run" report.
|
|
31
|
+
//
|
|
32
|
+
// The question and options are never truncated anywhere on this path: the
|
|
33
|
+
// set-aside reason carries the whole question.
|
|
34
|
+
//
|
|
35
|
+
// Every bd write is best-effort: a failed decision-bead create or note
|
|
36
|
+
// append is logged and the bead is still set aside (re-dispatching it would
|
|
37
|
+
// not answer the question either).
|
|
38
|
+
// =============================================================================
|
|
39
|
+
|
|
40
|
+
import { stageCommandBodyMemberSide } from './member-provisioning.mjs';
|
|
41
|
+
import { openBlocksDependents } from './beads-scope.mjs';
|
|
42
|
+
import { createDecisionBead } from './beads-children.mjs';
|
|
43
|
+
|
|
44
|
+
/** The doer status / reviewer verdict asking for an operator decision. */
|
|
45
|
+
export const NEEDS_DECISION = 'NEEDS-DECISION';
|
|
46
|
+
|
|
47
|
+
/** The set-aside kind recorded on sprintState.doctorBlockedIds for it. */
|
|
48
|
+
export const NEEDS_DECISION_KIND = 'needs-decision';
|
|
49
|
+
|
|
50
|
+
/** The label `bd human list` / `bd human respond` select on. */
|
|
51
|
+
export const DECISION_BEAD_LABEL = 'human';
|
|
52
|
+
|
|
53
|
+
const BEAD_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Checks a NEEDS-DECISION request beyond the schema: trimmed non-empty
|
|
57
|
+
* question and recommendation, at least two options each with an id and
|
|
58
|
+
* text, unique option ids, and a bead id safe to put on a command line.
|
|
59
|
+
* Returns the normalized request (strings trimmed, nothing shortened).
|
|
60
|
+
*
|
|
61
|
+
* @param {unknown} decision
|
|
62
|
+
* @returns {{ ok: true, decision: { beadId: string, question: string, options: { id: string, text: string }[], recommendation: string } } | { ok: false, reason: string }}
|
|
63
|
+
*/
|
|
64
|
+
export function validateDecisionRequest(decision) {
|
|
65
|
+
if (!decision || typeof decision !== 'object') return { ok: false, reason: 'no decision object' };
|
|
66
|
+
const beadId = typeof decision.beadId === 'string' ? decision.beadId.trim() : '';
|
|
67
|
+
if (!BEAD_ID_RE.test(beadId)) return { ok: false, reason: `decision.beadId ${JSON.stringify(decision.beadId)} is not a bead id` };
|
|
68
|
+
const question = typeof decision.question === 'string' ? decision.question.trim() : '';
|
|
69
|
+
if (!question) return { ok: false, reason: 'decision.question is empty' };
|
|
70
|
+
const recommendation = typeof decision.recommendation === 'string' ? decision.recommendation.trim() : '';
|
|
71
|
+
if (!recommendation) return { ok: false, reason: 'decision.recommendation is empty' };
|
|
72
|
+
const rawOptions = Array.isArray(decision.options) ? decision.options : [];
|
|
73
|
+
const options = [];
|
|
74
|
+
for (const o of rawOptions) {
|
|
75
|
+
const id = o && typeof o.id === 'string' ? o.id.trim() : '';
|
|
76
|
+
const text = o && typeof o.text === 'string' ? o.text.trim() : '';
|
|
77
|
+
if (!id || !text) return { ok: false, reason: 'every decision option needs an id and a text' };
|
|
78
|
+
options.push({ id, text });
|
|
79
|
+
}
|
|
80
|
+
if (options.length < 2) return { ok: false, reason: `decision needs at least 2 options, got ${options.length}` };
|
|
81
|
+
if (new Set(options.map((o) => o.id)).size !== options.length) return { ok: false, reason: 'decision option ids must be unique' };
|
|
82
|
+
return { ok: true, decision: { beadId, question, options, recommendation } };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The full, untruncated decision request text: the body of the decision
|
|
87
|
+
* bead and of the note appended to the work bead.
|
|
88
|
+
*
|
|
89
|
+
* @param {{ beadId: string, question: string, options: { id: string, text: string }[], recommendation: string }} decision
|
|
90
|
+
* @param {{ raisedBy?: string, cycle?: number, round?: number, decisionBeadId?: string|null }} [meta]
|
|
91
|
+
* @returns {string}
|
|
92
|
+
*/
|
|
93
|
+
export function formatDecisionRequest(decision, { raisedBy, cycle, round, decisionBeadId } = {}) {
|
|
94
|
+
const where = Number.isInteger(cycle) ? ` in C${cycle}${Number.isInteger(round) ? ` R${round}` : ''}` : '';
|
|
95
|
+
const lines = [
|
|
96
|
+
`[fleet-sprint] NEEDS-DECISION on ${decision.beadId}${raisedBy ? ` (raised by ${raisedBy}${where})` : where}`,
|
|
97
|
+
'',
|
|
98
|
+
'Question:',
|
|
99
|
+
decision.question,
|
|
100
|
+
'',
|
|
101
|
+
'Options:',
|
|
102
|
+
...decision.options.map((o) => `(${o.id}) ${o.text}`),
|
|
103
|
+
'',
|
|
104
|
+
'Recommendation:',
|
|
105
|
+
decision.recommendation,
|
|
106
|
+
];
|
|
107
|
+
if (decisionBeadId) {
|
|
108
|
+
lines.push('', `Answer with: bd human respond ${decisionBeadId} "<chosen option id and any instructions>" ` +
|
|
109
|
+
'(then resume the run from its dashboard), or answer from the sprint dashboard\'s decision banner.');
|
|
110
|
+
}
|
|
111
|
+
return lines.join('\n');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The decision bead's title (inline on the command line: bead ids only). */
|
|
115
|
+
export function decisionBeadTitle(beadId) {
|
|
116
|
+
return `Decision needed for ${beadId}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Looks up an existing NOT-closed decision bead for `beadId` (a relaunch has a
|
|
121
|
+
* fresh sprintState, so the per-run pending map cannot see the prior run's).
|
|
122
|
+
* Decision beads are filed `deferred`, so every non-closed status counts.
|
|
123
|
+
* Best-effort: a failed or unparseable lookup returns null (caller files).
|
|
124
|
+
* @returns {Promise<string|null>} the open decision bead's id, or null
|
|
125
|
+
*/
|
|
126
|
+
export async function findOpenDecisionBead({ command, member, beadId, log = () => {} }) {
|
|
127
|
+
const title = decisionBeadTitle(beadId);
|
|
128
|
+
try {
|
|
129
|
+
const out = await command(
|
|
130
|
+
`bd list -t decision -l ${DECISION_BEAD_LABEL} --title-contains "${title}" --status open,in_progress,blocked,deferred --json`,
|
|
131
|
+
{ member_name: member, silent: true, label: `Look up open decision bead for ${beadId}` },
|
|
132
|
+
);
|
|
133
|
+
const parsed = JSON.parse(String(out ?? '').trim() || '[]');
|
|
134
|
+
const list = Array.isArray(parsed) ? parsed : [];
|
|
135
|
+
const hit = list.find((b) => b && b.title === title && b.status !== 'closed' && BEAD_ID_RE.test(String(b.id)));
|
|
136
|
+
return hit ? String(hit.id) : null;
|
|
137
|
+
} catch (err) {
|
|
138
|
+
log(`NEEDS-DECISION on '${beadId}': open decision bead lookup FAILED (non-fatal, filing a new one): ${err.message}`);
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** The set-aside reason for the work bead: names the decision bead and carries the whole question. */
|
|
144
|
+
export function needsDecisionReason({ decision, raisedBy, decisionBeadId }) {
|
|
145
|
+
const where = decisionBeadId
|
|
146
|
+
? ` (decision bead ${decisionBeadId})`
|
|
147
|
+
: ' (the decision bead could NOT be filed, so this run has no bd human respond path for it: ' +
|
|
148
|
+
'record the decision in this bead\'s notes and re-run)';
|
|
149
|
+
return `awaiting an operator decision${where} raised by ${raisedBy}: ${decision.question}`;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Deletes a member-side staged body file once bd has read it. Best-effort:
|
|
153
|
+
// a failure only leaves one temp file behind. No backticks or `$`, like the
|
|
154
|
+
// staging script itself, so it is inert on every member shell.
|
|
155
|
+
export async function removeStagedBody({ command, member, file, log = () => {} }) {
|
|
156
|
+
if (!file) return;
|
|
157
|
+
try {
|
|
158
|
+
await command(
|
|
159
|
+
`node -e "require('fs').rmSync(process.argv[1],{force:true})" "${file}"`,
|
|
160
|
+
{ member_name: member, silent: true, label: 'Remove staged decision body' },
|
|
161
|
+
);
|
|
162
|
+
} catch (err) {
|
|
163
|
+
log(`NEEDS-DECISION: could not remove staged body file (non-fatal): ${err.message}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function normalizePriority(priority) {
|
|
168
|
+
const n = Number(String(priority ?? '').replace(/^P/i, ''));
|
|
169
|
+
return Number.isInteger(n) && n >= 0 && n <= 4 ? n : 2;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Records one NEEDS-DECISION request (see this file's header). A bead with a
|
|
174
|
+
* decision already pending this run is not filed twice.
|
|
175
|
+
*
|
|
176
|
+
* @param {object} opts
|
|
177
|
+
* @param {object} opts.sprintState
|
|
178
|
+
* @param {object} opts.decision a request that passed validateDecisionRequest()
|
|
179
|
+
* @param {string} opts.raisedBy e.g. "doer on member 'm1'"
|
|
180
|
+
* @param {number} opts.cycle
|
|
181
|
+
* @param {number|null} [opts.round]
|
|
182
|
+
* @param {Function} opts.command the workflow command() seam
|
|
183
|
+
* @param {string} opts.member the member whose beads clone the engine writes through
|
|
184
|
+
* @param {Array<object>} [opts.scopeBeads] every in-scope bead (for blocks-edge dependents and the priority)
|
|
185
|
+
* @param {Function} [opts.log]
|
|
186
|
+
* @returns {Promise<object|null>} the pending-decision record, or null when one was already pending
|
|
187
|
+
*/
|
|
188
|
+
export async function recordPendingDecision({ sprintState, decision, raisedBy, cycle, round = null, command, member, scopeBeads = [], log = () => {} }) {
|
|
189
|
+
sprintState.pendingDecisions = sprintState.pendingDecisions instanceof Map ? sprintState.pendingDecisions : new Map();
|
|
190
|
+
sprintState.doctorBlockedIds = sprintState.doctorBlockedIds instanceof Map ? sprintState.doctorBlockedIds : new Map();
|
|
191
|
+
const pending = sprintState.pendingDecisions;
|
|
192
|
+
const blocked = sprintState.doctorBlockedIds;
|
|
193
|
+
const beadId = decision.beadId;
|
|
194
|
+
for (const existing of pending.values()) {
|
|
195
|
+
if (existing.beadId === beadId) {
|
|
196
|
+
log(`NEEDS-DECISION on '${beadId}' from ${raisedBy}: a decision is already pending for this bead (${existing.decisionId}) -- not filing a second one.`);
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
sprintState.decisionSeq = (Number.isInteger(sprintState.decisionSeq) ? sprintState.decisionSeq : 0) + 1;
|
|
201
|
+
const decisionId = `decision-${sprintState.decisionSeq}-${beadId}`;
|
|
202
|
+
const workBead = (scopeBeads || []).find((b) => b && String(b.id) === beadId);
|
|
203
|
+
const priority = normalizePriority(workBead && workBead.priority);
|
|
204
|
+
|
|
205
|
+
let decisionBeadId = await findOpenDecisionBead({ command, member, beadId, log });
|
|
206
|
+
const reused = decisionBeadId !== null;
|
|
207
|
+
if (reused) log(`NEEDS-DECISION on '${beadId}': reusing the open decision bead ${decisionBeadId} from an earlier run -- not filing a new one.`);
|
|
208
|
+
let bodyFile = null;
|
|
209
|
+
if (!reused) try {
|
|
210
|
+
bodyFile = await stageCommandBodyMemberSide({
|
|
211
|
+
command, member,
|
|
212
|
+
content: formatDecisionRequest(decision, { raisedBy, cycle, round }),
|
|
213
|
+
label: `Stage decision request for ${beadId}`,
|
|
214
|
+
});
|
|
215
|
+
const out = await createDecisionBead({
|
|
216
|
+
command, member, workBeadId: beadId, title: decisionBeadTitle(beadId), bodyFile, priority,
|
|
217
|
+
labelName: DECISION_BEAD_LABEL, label: `File decision bead for ${beadId}`,
|
|
218
|
+
});
|
|
219
|
+
const id = String(out ?? '').trim().split(/\s+/).pop() || '';
|
|
220
|
+
decisionBeadId = BEAD_ID_RE.test(id) ? id : null;
|
|
221
|
+
if (!decisionBeadId) log(`NEEDS-DECISION on '${beadId}': bd create returned no bead id (${JSON.stringify(String(out ?? ''))}).`);
|
|
222
|
+
} catch (err) {
|
|
223
|
+
log(`NEEDS-DECISION on '${beadId}': filing the decision bead FAILED (non-fatal, the bead is still set aside): ${err.message}`);
|
|
224
|
+
}
|
|
225
|
+
await removeStagedBody({ command, member, file: bodyFile, log });
|
|
226
|
+
|
|
227
|
+
let noteFile = null;
|
|
228
|
+
try {
|
|
229
|
+
noteFile = await stageCommandBodyMemberSide({
|
|
230
|
+
command, member,
|
|
231
|
+
content: formatDecisionRequest(decision, { raisedBy, cycle, round, decisionBeadId }),
|
|
232
|
+
label: `Stage decision note for ${beadId}`,
|
|
233
|
+
});
|
|
234
|
+
await command(
|
|
235
|
+
`bd note ${beadId} --file "${noteFile}"`,
|
|
236
|
+
{ member_name: member, silent: true, label: `Append decision request to ${beadId} notes` },
|
|
237
|
+
);
|
|
238
|
+
} catch (err) {
|
|
239
|
+
log(`NEEDS-DECISION on '${beadId}': appending the request to its notes FAILED (non-fatal): ${err.message}`);
|
|
240
|
+
}
|
|
241
|
+
await removeStagedBody({ command, member, file: noteFile, log });
|
|
242
|
+
|
|
243
|
+
const record = {
|
|
244
|
+
decisionId, beadId,
|
|
245
|
+
question: decision.question,
|
|
246
|
+
options: decision.options.map((o) => ({ id: o.id, text: o.text })),
|
|
247
|
+
recommendation: decision.recommendation,
|
|
248
|
+
decisionBeadId, raisedBy, cycle,
|
|
249
|
+
raisedAt: new Date().toISOString(),
|
|
250
|
+
round: Number.isInteger(round) ? round : null,
|
|
251
|
+
notification: {},
|
|
252
|
+
};
|
|
253
|
+
pending.set(decisionId, record);
|
|
254
|
+
|
|
255
|
+
const where = { cycle, round: record.round };
|
|
256
|
+
blocked.set(beadId, {
|
|
257
|
+
kind: NEEDS_DECISION_KIND, blockedBy: beadId,
|
|
258
|
+
reason: needsDecisionReason({ decision, raisedBy, decisionBeadId }),
|
|
259
|
+
decisionId, decisionBeadId,
|
|
260
|
+
...where,
|
|
261
|
+
});
|
|
262
|
+
const dependents = [];
|
|
263
|
+
for (const [id, root] of openBlocksDependents([beadId], scopeBeads || [])) {
|
|
264
|
+
if (blocked.has(id)) continue;
|
|
265
|
+
blocked.set(id, {
|
|
266
|
+
kind: 'dependent', blockedBy: root,
|
|
267
|
+
reason: `depends (via blocks edges) on bead '${root}', which awaits an operator decision${decisionBeadId ? ` (${decisionBeadId})` : ''}`,
|
|
268
|
+
decisionId,
|
|
269
|
+
...where,
|
|
270
|
+
});
|
|
271
|
+
dependents.push(id);
|
|
272
|
+
}
|
|
273
|
+
log(
|
|
274
|
+
`NEEDS-DECISION set-aside C${cycle}${record.round !== null ? ` R${record.round}` : ''}: bead '${beadId}' awaits an operator decision ` +
|
|
275
|
+
`(${decisionId}, decision bead ${decisionBeadId || 'NOT FILED'}); set aside for the rest of this run with its open dependent(s) ` +
|
|
276
|
+
`[${dependents.join(', ')}] and not re-dispatched while the decision is pending. Request: ${JSON.stringify(record)}`,
|
|
277
|
+
);
|
|
278
|
+
// Tell the operator (decision-notify.mjs). Injected by the runner as
|
|
279
|
+
// sprintState.notifyDecision; it never throws, and a failure here must
|
|
280
|
+
// never change the sprint, so this guard is belt and braces.
|
|
281
|
+
if (typeof sprintState.notifyDecision === 'function') {
|
|
282
|
+
try {
|
|
283
|
+
await sprintState.notifyDecision(record);
|
|
284
|
+
} catch (err) {
|
|
285
|
+
log(`NOTIFICATION FAILED for decision ${decisionId}: ${err && err.message}. The sprint continues unchanged.`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return record;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Every pending decision of this run, in raise order.
|
|
293
|
+
* @param {{ pendingDecisions?: Map<string, object> }|null|undefined} sprintState
|
|
294
|
+
* @returns {object[]}
|
|
295
|
+
*/
|
|
296
|
+
export function collectPendingDecisions(sprintState) {
|
|
297
|
+
const pending = sprintState && sprintState.pendingDecisions instanceof Map ? sprintState.pendingDecisions : new Map();
|
|
298
|
+
return [...pending.values()];
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* The reopen entries for a reviewer verdict: its `reopenIds`, plus -- for a
|
|
303
|
+
* usable NEEDS-DECISION naming a bead in this review's scope -- that bead, so
|
|
304
|
+
* a closed bead is reopened through the SAME guarded reopen call as every
|
|
305
|
+
* other reopen of the verdict (applyGuardedReopens in
|
|
306
|
+
* beads-transitions.mjs). Reopening a bead that is already open is a no-op.
|
|
307
|
+
*
|
|
308
|
+
* @param {{ verdict: string, reopenIds?: string[], decision?: object }} verdict
|
|
309
|
+
* @param {string[]} scopeIds bead ids this review covered
|
|
310
|
+
* @returns {string[]}
|
|
311
|
+
*/
|
|
312
|
+
export function reviewerReopenEntries(verdict, scopeIds) {
|
|
313
|
+
const entries = Array.isArray(verdict && verdict.reopenIds) ? [...verdict.reopenIds] : [];
|
|
314
|
+
if (!verdict || verdict.verdict !== NEEDS_DECISION) return entries;
|
|
315
|
+
const checked = validateDecisionRequest(verdict.decision);
|
|
316
|
+
if (!checked.ok || !(scopeIds || []).map(String).includes(checked.decision.beadId)) return entries;
|
|
317
|
+
if (!entries.includes(checked.decision.beadId)) entries.push(checked.decision.beadId);
|
|
318
|
+
return entries;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Applies a reviewer NEEDS-DECISION verdict (per-round Review and
|
|
323
|
+
* Re-Review), AFTER the caller applied the verdict's reopens with
|
|
324
|
+
* reviewerReopenEntries(): the named bead must be in this review's scope and
|
|
325
|
+
* open now (it was open already, or the guarded reopen just reopened it);
|
|
326
|
+
* the decision is then recorded exactly as for a doer
|
|
327
|
+
* (recordPendingDecision). A non-NEEDS-DECISION verdict is a no-op.
|
|
328
|
+
*
|
|
329
|
+
* @param {object} opts
|
|
330
|
+
* @param {{ verdict: string, decision?: object }} opts.verdict
|
|
331
|
+
* @param {string[]} opts.scopeIds bead ids this review covered
|
|
332
|
+
* @param {Set<string>} opts.reopenedIds ids the guarded reopen actually reopened
|
|
333
|
+
* @param {object} opts.sprintState
|
|
334
|
+
* @param {Function} opts.command
|
|
335
|
+
* @param {string} opts.member
|
|
336
|
+
* @param {Function} opts.bdListScoped
|
|
337
|
+
* @param {number} opts.cycle
|
|
338
|
+
* @param {number|null} [opts.round]
|
|
339
|
+
* @param {string} opts.site e.g. 'Review C1 R2'
|
|
340
|
+
* @param {Function} [opts.log]
|
|
341
|
+
* @returns {Promise<object|null>} the pending-decision record, or null
|
|
342
|
+
*/
|
|
343
|
+
export async function applyReviewerDecision({ verdict, scopeIds, reopenedIds = new Set(), sprintState, command, member, bdListScoped, cycle, round = null, site, log = () => {} }) {
|
|
344
|
+
if (!verdict || verdict.verdict !== NEEDS_DECISION) return null;
|
|
345
|
+
const checked = validateDecisionRequest(verdict.decision);
|
|
346
|
+
if (!checked.ok) {
|
|
347
|
+
log(`${site}: reviewer returned NEEDS-DECISION with an unusable decision (${checked.reason}) -- nothing is set aside.`);
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
const decision = checked.decision;
|
|
351
|
+
if (!(scopeIds || []).map(String).includes(decision.beadId)) {
|
|
352
|
+
log(`${site}: reviewer returned NEEDS-DECISION on '${decision.beadId}', which is not in this review's scope -- nothing is set aside.`);
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
const reopened = reopenedIds instanceof Set && reopenedIds.has(decision.beadId);
|
|
356
|
+
const scopeBeads = (await bdListScoped(''))
|
|
357
|
+
.map((b) => (b && reopened && String(b.id) === decision.beadId ? { ...b, status: 'open' } : b));
|
|
358
|
+
const bead = scopeBeads.find((b) => b && String(b.id) === decision.beadId);
|
|
359
|
+
if (!bead) {
|
|
360
|
+
log(`${site}: reviewer returned NEEDS-DECISION on '${decision.beadId}', which is not in the sprint scope -- nothing is set aside.`);
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
if (bead.status === 'closed') {
|
|
364
|
+
log(`${site}: reviewer returned NEEDS-DECISION on closed bead '${decision.beadId}', which the guarded reopen did not reopen -- nothing is set aside.`);
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
return recordPendingDecision({
|
|
368
|
+
sprintState, decision,
|
|
369
|
+
raisedBy: `reviewer (${site})`,
|
|
370
|
+
cycle, round, command, member, scopeBeads, log,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Per-dispatch kb_* / code_* tool call accounting from session_stats snapshots.
|
|
3
|
+
//
|
|
4
|
+
// The member's agent makes its kb_* and code_* calls against the fleet server
|
|
5
|
+
// its own MCP config points at -- for a remote member that is the member's OWN
|
|
6
|
+
// server, which the engine cannot observe. That server counts those calls per
|
|
7
|
+
// member (session_stats). So the engine reads session_stats AS the member
|
|
8
|
+
// (memberCall: a local in-process member session, or `apra-fleet call` on a
|
|
9
|
+
// remote member -- both are engine-origin sessions, whose own calls the server
|
|
10
|
+
// does not count) immediately before and immediately after each dispatch, and
|
|
11
|
+
// records the difference as that dispatch's calls.
|
|
12
|
+
//
|
|
13
|
+
// HONESTY RULE: a count is either a number read from two good snapshots or the
|
|
14
|
+
// string 'unknown' -- never a fabricated 0. Any of these yields 'unknown' for
|
|
15
|
+
// the dispatch (with a reason): no member session available, no member record
|
|
16
|
+
// for the dispatched member name, a failed or unparseable read, a changed
|
|
17
|
+
// `since` between the two snapshots (the member's server restarted mid-
|
|
18
|
+
// dispatch, so the counters were reset), or a negative difference.
|
|
19
|
+
//
|
|
20
|
+
// Accounting is best-effort and never fails or delays a dispatch beyond the
|
|
21
|
+
// bounded snapshot reads: every error is logged and recorded as 'unknown'.
|
|
22
|
+
//
|
|
23
|
+
// Records are appended to a caller-supplied array (the sprint state's
|
|
24
|
+
// dispatchToolCalls list) and optionally published to the viewer under
|
|
25
|
+
// DISPATCH_TOOL_CALLS_STATE_NAMESPACE.
|
|
26
|
+
// =============================================================================
|
|
27
|
+
|
|
28
|
+
/** The value recorded for a count the engine could not establish. */
|
|
29
|
+
export const UNKNOWN_COUNT = 'unknown';
|
|
30
|
+
|
|
31
|
+
/** publishState namespace for the per-dispatch records (viewer tab). */
|
|
32
|
+
export const DISPATCH_TOOL_CALLS_STATE_NAMESPACE = 'dispatch-tool-calls';
|
|
33
|
+
|
|
34
|
+
/** Default bound on one session_stats read. */
|
|
35
|
+
export const SNAPSHOT_READ_TIMEOUT_MS = 60_000;
|
|
36
|
+
|
|
37
|
+
function isCount(n) {
|
|
38
|
+
return typeof n === 'number' && Number.isInteger(n) && n >= 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Extract a session_stats snapshot { since, kb, code } from a tool result
|
|
43
|
+
* (MCP { content: [{ text }] } or an already-parsed object). Returns null for
|
|
44
|
+
* anything that is not a well-formed snapshot.
|
|
45
|
+
*/
|
|
46
|
+
export function parseSessionStats(result) {
|
|
47
|
+
let obj = result;
|
|
48
|
+
if (obj && Array.isArray(obj.content)) {
|
|
49
|
+
if (obj.isError) return null;
|
|
50
|
+
const text = obj.content.map((c) => (c && typeof c.text === 'string' ? c.text : '')).join('');
|
|
51
|
+
try { obj = JSON.parse(text); } catch { return null; }
|
|
52
|
+
}
|
|
53
|
+
if (!obj || typeof obj !== 'object') return null;
|
|
54
|
+
if (typeof obj.since !== 'string' || !isCount(obj.kb) || !isCount(obj.code)) return null;
|
|
55
|
+
return { since: obj.since, kb: obj.kb, code: obj.code };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The per-dispatch counts from a before/after pair of parsed snapshots (either
|
|
60
|
+
* may be null). Returns { kb, code, reason } where kb/code are numbers or
|
|
61
|
+
* UNKNOWN_COUNT and reason explains an unknown (null otherwise).
|
|
62
|
+
*/
|
|
63
|
+
export function snapshotDelta(before, after) {
|
|
64
|
+
if (!before || !after) {
|
|
65
|
+
return { kb: UNKNOWN_COUNT, code: UNKNOWN_COUNT, reason: !before ? 'before-snapshot read failed' : 'after-snapshot read failed' };
|
|
66
|
+
}
|
|
67
|
+
if (before.since !== after.since) {
|
|
68
|
+
return { kb: UNKNOWN_COUNT, code: UNKNOWN_COUNT, reason: 'member server restarted during the dispatch (counters reset)' };
|
|
69
|
+
}
|
|
70
|
+
const kb = after.kb - before.kb;
|
|
71
|
+
const code = after.code - before.code;
|
|
72
|
+
if (kb < 0 || code < 0) {
|
|
73
|
+
return { kb: UNKNOWN_COUNT, code: UNKNOWN_COUNT, reason: 'counters went backwards' };
|
|
74
|
+
}
|
|
75
|
+
return { kb, code, reason: null };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The reason text for a count that is unknown because the member's own tools
|
|
80
|
+
* were unavailable at sprint init: "member tools unavailable: <reason>" plus
|
|
81
|
+
* the short cause the init record carries (problem detail), when known.
|
|
82
|
+
* Returns null when the init record is absent or the member was verified.
|
|
83
|
+
*
|
|
84
|
+
* @param {{verified?: boolean, reason?: string|null, problems?: Array<{reason?: string, detail?: string}>}|null|undefined} init
|
|
85
|
+
* @returns {string|null}
|
|
86
|
+
*/
|
|
87
|
+
export function memberToolsReason(init) {
|
|
88
|
+
if (!init || typeof init !== 'object' || init.verified === true) return null;
|
|
89
|
+
const reason = init.reason ? String(init.reason) : 'unverified';
|
|
90
|
+
const p = Array.isArray(init.problems) ? init.problems.find((x) => x && x.reason === init.reason && x.detail) : null;
|
|
91
|
+
const cause = p ? String(p.detail).replace(/\s+/g, ' ').trim().slice(0, 120) : '';
|
|
92
|
+
return `member tools unavailable: ${reason}${cause ? ` -- ${cause}` : ''}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Format one count for text output: a number, or the literal 'unknown'. */
|
|
96
|
+
export function formatCount(n) {
|
|
97
|
+
return isCount(n) ? String(n) : UNKNOWN_COUNT;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Per-member totals over a list of dispatch records. A member's total for a
|
|
102
|
+
* kind is a number only when every one of its dispatches has a number for
|
|
103
|
+
* that kind; otherwise it is UNKNOWN_COUNT (with the unknown dispatch count).
|
|
104
|
+
*/
|
|
105
|
+
export function memberTotals(records) {
|
|
106
|
+
const out = [];
|
|
107
|
+
const byMember = new Map();
|
|
108
|
+
for (const r of Array.isArray(records) ? records : []) {
|
|
109
|
+
if (!r || typeof r !== 'object') continue;
|
|
110
|
+
const name = String(r.member || '(unknown member)');
|
|
111
|
+
let t = byMember.get(name);
|
|
112
|
+
if (!t) {
|
|
113
|
+
t = { member: name, dispatches: 0, kb: 0, code: 0, unknownDispatches: 0, unknownReason: null };
|
|
114
|
+
byMember.set(name, t);
|
|
115
|
+
out.push(t);
|
|
116
|
+
}
|
|
117
|
+
t.dispatches++;
|
|
118
|
+
if (!isCount(r.kb) || !isCount(r.code)) {
|
|
119
|
+
t.unknownDispatches++;
|
|
120
|
+
if (!t.unknownReason && r.reason) t.unknownReason = String(r.reason);
|
|
121
|
+
}
|
|
122
|
+
t.kb = isCount(t.kb) && isCount(r.kb) ? t.kb + r.kb : UNKNOWN_COUNT;
|
|
123
|
+
t.code = isCount(t.code) && isCount(r.code) ? t.code + r.code : UNKNOWN_COUNT;
|
|
124
|
+
}
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Create the accounting helper.
|
|
130
|
+
*
|
|
131
|
+
* @param {object} deps
|
|
132
|
+
* @param {(member: object, tool: string, args: object) => Promise<object>} [deps.memberCall]
|
|
133
|
+
* the engine's memberCall (MEMBER-scoped, engine-origin); absent means
|
|
134
|
+
* every dispatch records 'unknown'.
|
|
135
|
+
* @param {(memberName: string) => object|null} [deps.getMemberInit]
|
|
136
|
+
* the member-init record for a member NAME (verified, reason, problems);
|
|
137
|
+
* an unknown count caused by a failed snapshot read or a missing member
|
|
138
|
+
* session then carries the member-tools reason instead of the bare read
|
|
139
|
+
* failure. Other unknowns (restart, counters backwards) keep their own.
|
|
140
|
+
* @param {(memberName: string) => object|null} [deps.memberOf]
|
|
141
|
+
* resolves a dispatched member NAME to its member record ({id, name, type}).
|
|
142
|
+
* @param {object[]} [deps.store] array records are appended to (sprint state).
|
|
143
|
+
* @param {(ns: string, payload: object) => void} [deps.publishState]
|
|
144
|
+
* @param {Function} [deps.log]
|
|
145
|
+
* @param {number} [deps.readTimeoutMs]
|
|
146
|
+
* @param {() => string} [deps.now] ISO timestamp source (tests).
|
|
147
|
+
*/
|
|
148
|
+
export function createDispatchAccounting(deps = {}) {
|
|
149
|
+
const {
|
|
150
|
+
memberCall,
|
|
151
|
+
memberOf,
|
|
152
|
+
getMemberInit,
|
|
153
|
+
publishState,
|
|
154
|
+
log = () => {},
|
|
155
|
+
readTimeoutMs = SNAPSHOT_READ_TIMEOUT_MS,
|
|
156
|
+
now = () => new Date().toISOString(),
|
|
157
|
+
} = deps;
|
|
158
|
+
const store = Array.isArray(deps.store) ? deps.store : [];
|
|
159
|
+
let seq = 0;
|
|
160
|
+
|
|
161
|
+
function publish() {
|
|
162
|
+
if (typeof publishState !== 'function') return;
|
|
163
|
+
try {
|
|
164
|
+
publishState(DISPATCH_TOOL_CALLS_STATE_NAMESPACE, { dispatches: store.slice() });
|
|
165
|
+
} catch (err) {
|
|
166
|
+
log(`[dispatch-accounting] could not publish dispatch tool-call records (non-fatal): ${err && err.message || err}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function withTimeout(promise) {
|
|
171
|
+
let timer;
|
|
172
|
+
return Promise.race([
|
|
173
|
+
promise,
|
|
174
|
+
new Promise((_, reject) => {
|
|
175
|
+
timer = setTimeout(() => reject(new Error(`session_stats read timed out after ${readTimeoutMs}ms`)), readTimeoutMs);
|
|
176
|
+
}),
|
|
177
|
+
]).finally(() => clearTimeout(timer));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** One snapshot read; null on any failure (logged). */
|
|
181
|
+
async function readSnapshot(record, memberName, which) {
|
|
182
|
+
try {
|
|
183
|
+
const res = await withTimeout(Promise.resolve().then(() => memberCall(record, 'session_stats', {})));
|
|
184
|
+
const snap = parseSessionStats(res);
|
|
185
|
+
if (!snap) log(`[dispatch-accounting] ${which} session_stats for member '${memberName}' was unparseable; counts for this dispatch are unknown.`);
|
|
186
|
+
return snap;
|
|
187
|
+
} catch (err) {
|
|
188
|
+
log(`[dispatch-accounting] ${which} session_stats read for member '${memberName}' failed (counts for this dispatch are unknown): ${err && err.message || err}`);
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function resolveRecord(memberName) {
|
|
194
|
+
try {
|
|
195
|
+
return typeof memberOf === 'function' ? memberOf(memberName) : null;
|
|
196
|
+
} catch {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
/** The records so far (a copy). */
|
|
203
|
+
records() {
|
|
204
|
+
return store.slice();
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* Run `fn` (one dispatch to `memberName`) between two session_stats
|
|
208
|
+
* snapshots and record the per-dispatch counts. `fn`'s result or
|
|
209
|
+
* error passes through unchanged.
|
|
210
|
+
*/
|
|
211
|
+
async around({ memberName, role, label } = {}, fn) {
|
|
212
|
+
const index = ++seq;
|
|
213
|
+
const startedAt = now();
|
|
214
|
+
const record = memberName ? resolveRecord(memberName) : null;
|
|
215
|
+
let skipReason = null;
|
|
216
|
+
if (!memberName) skipReason = 'dispatch named no member';
|
|
217
|
+
else if (typeof memberCall !== 'function') skipReason = 'no member session available to read session_stats';
|
|
218
|
+
else if (!record || !(record.id || record.member_id)) skipReason = `no member record for '${memberName}'`;
|
|
219
|
+
const before = skipReason ? null : await readSnapshot(record, memberName, 'before');
|
|
220
|
+
try {
|
|
221
|
+
return await fn();
|
|
222
|
+
} finally {
|
|
223
|
+
const after = skipReason ? null : await readSnapshot(record, memberName, 'after');
|
|
224
|
+
const delta = skipReason
|
|
225
|
+
? { kb: UNKNOWN_COUNT, code: UNKNOWN_COUNT, reason: skipReason }
|
|
226
|
+
: snapshotDelta(before, after);
|
|
227
|
+
if (delta.reason && (skipReason || /snapshot read failed$/.test(delta.reason)) && memberName && typeof getMemberInit === 'function') {
|
|
228
|
+
let toolsReason = null;
|
|
229
|
+
try { toolsReason = memberToolsReason(getMemberInit(memberName)); } catch { /* informational only */ }
|
|
230
|
+
if (toolsReason) delta.reason = toolsReason;
|
|
231
|
+
}
|
|
232
|
+
store.push({
|
|
233
|
+
index,
|
|
234
|
+
member: memberName ? String(memberName) : '(unknown member)',
|
|
235
|
+
role: role ? String(role) : null,
|
|
236
|
+
label: label ? String(label) : null,
|
|
237
|
+
startedAt,
|
|
238
|
+
endedAt: now(),
|
|
239
|
+
kb: delta.kb,
|
|
240
|
+
code: delta.code,
|
|
241
|
+
reason: delta.reason,
|
|
242
|
+
});
|
|
243
|
+
publish();
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Text lines for the sprint summary: calls per member per dispatch, then
|
|
251
|
+
* per-member totals. Pure. 'unknown' is printed as unknown, never 0.
|
|
252
|
+
*/
|
|
253
|
+
export function formatDispatchToolCalls(records) {
|
|
254
|
+
const list = (Array.isArray(records) ? records : []).filter((r) => r && typeof r === 'object');
|
|
255
|
+
if (list.length === 0) return ['No member dispatch was recorded this sprint.'];
|
|
256
|
+
const lines = [];
|
|
257
|
+
for (const r of list) {
|
|
258
|
+
const who = r.role ? `${r.role} on member '${r.member}'` : `member '${r.member}'`;
|
|
259
|
+
const label = r.label ? ` [${r.label}]` : '';
|
|
260
|
+
const why = (!isCount(r.kb) || !isCount(r.code)) && r.reason ? ` (unknown: ${r.reason})` : '';
|
|
261
|
+
lines.push(`- Dispatch ${r.index}: ${who}${label} -- kb_* calls: ${formatCount(r.kb)}, code_* calls: ${formatCount(r.code)}${why}.`);
|
|
262
|
+
}
|
|
263
|
+
lines.push('');
|
|
264
|
+
lines.push('Per-member totals:');
|
|
265
|
+
for (const t of memberTotals(list)) {
|
|
266
|
+
const unknown = t.unknownDispatches > 0 ? ` (${t.unknownDispatches} dispatch(es) with unknown counts)${t.unknownReason ? ` (unknown: ${t.unknownReason})` : ''}` : '';
|
|
267
|
+
lines.push(`- member '${t.member}': ${t.dispatches} dispatch(es), kb_* calls: ${formatCount(t.kb)}, code_* calls: ${formatCount(t.code)}${unknown}.`);
|
|
268
|
+
}
|
|
269
|
+
return lines;
|
|
270
|
+
}
|