@memnexus-ai/mx-agent-cli 0.1.294 → 0.1.295-next.0
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/dist/__tests__/agents-md-canonicalization.test.js +31 -1
- package/dist/__tests__/agents-md-canonicalization.test.js.map +1 -1
- package/dist/__tests__/behavioral-extraction.test.js +50 -0
- package/dist/__tests__/behavioral-extraction.test.js.map +1 -1
- package/dist/__tests__/bootstrap-behavioral-contract.test.js +6 -3
- package/dist/__tests__/bootstrap-behavioral-contract.test.js.map +1 -1
- package/dist/__tests__/bundle-config.test.js +28 -2
- package/dist/__tests__/bundle-config.test.js.map +1 -1
- package/dist/__tests__/catalog-interaction.test.d.ts +25 -0
- package/dist/__tests__/catalog-interaction.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-interaction.test.js +269 -0
- package/dist/__tests__/catalog-interaction.test.js.map +1 -0
- package/dist/__tests__/catalog-named-memories.test.d.ts +2 -0
- package/dist/__tests__/catalog-named-memories.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-named-memories.test.js +204 -0
- package/dist/__tests__/catalog-named-memories.test.js.map +1 -0
- package/dist/__tests__/catalog-origin-main.test.d.ts +15 -0
- package/dist/__tests__/catalog-origin-main.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-origin-main.test.js +296 -0
- package/dist/__tests__/catalog-origin-main.test.js.map +1 -0
- package/dist/__tests__/catalog.test.d.ts +2 -0
- package/dist/__tests__/catalog.test.d.ts.map +1 -0
- package/dist/__tests__/catalog.test.js +131 -0
- package/dist/__tests__/catalog.test.js.map +1 -0
- package/dist/__tests__/cli-build-integration.test.d.ts +2 -0
- package/dist/__tests__/cli-build-integration.test.d.ts.map +1 -0
- package/dist/__tests__/cli-build-integration.test.js +64 -0
- package/dist/__tests__/cli-build-integration.test.js.map +1 -0
- package/dist/__tests__/cli-build.test.d.ts +2 -0
- package/dist/__tests__/cli-build.test.d.ts.map +1 -0
- package/dist/__tests__/cli-build.test.js +640 -0
- package/dist/__tests__/cli-build.test.js.map +1 -0
- package/dist/__tests__/codex-deploy-config.test.js +60 -0
- package/dist/__tests__/codex-deploy-config.test.js.map +1 -1
- package/dist/__tests__/completion-rows-discriminate.test.d.ts +20 -0
- package/dist/__tests__/completion-rows-discriminate.test.d.ts.map +1 -0
- package/dist/__tests__/completion-rows-discriminate.test.js +481 -0
- package/dist/__tests__/completion-rows-discriminate.test.js.map +1 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts +2 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts.map +1 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.js +127 -0
- package/dist/__tests__/config-fidelity-archived-symlinks.test.js.map +1 -0
- package/dist/__tests__/config-fidelity-display.test.d.ts +2 -0
- package/dist/__tests__/config-fidelity-display.test.d.ts.map +1 -0
- package/dist/__tests__/config-fidelity-display.test.js +77 -0
- package/dist/__tests__/config-fidelity-display.test.js.map +1 -0
- package/dist/__tests__/config-fidelity.test.js +166 -33
- package/dist/__tests__/config-fidelity.test.js.map +1 -1
- package/dist/__tests__/config-generation-gate.test.js +78 -0
- package/dist/__tests__/config-generation-gate.test.js.map +1 -1
- package/dist/__tests__/config-sync.test.js +89 -1
- package/dist/__tests__/config-sync.test.js.map +1 -1
- package/dist/__tests__/coordination-401-production-wiring.test.js +12 -7
- package/dist/__tests__/coordination-401-production-wiring.test.js.map +1 -1
- package/dist/__tests__/coordination-401-recovery.test.js +39 -32
- package/dist/__tests__/coordination-401-recovery.test.js.map +1 -1
- package/dist/__tests__/coordination-brief-pin.test.js +21 -8
- package/dist/__tests__/coordination-brief-pin.test.js.map +1 -1
- package/dist/__tests__/coordination-client.test.js +227 -3
- package/dist/__tests__/coordination-client.test.js.map +1 -1
- package/dist/__tests__/coordination-credential-endpoint.test.d.ts +24 -0
- package/dist/__tests__/coordination-credential-endpoint.test.d.ts.map +1 -0
- package/dist/__tests__/coordination-credential-endpoint.test.js +1230 -0
- package/dist/__tests__/coordination-credential-endpoint.test.js.map +1 -0
- package/dist/__tests__/coordination-memory.test.js +20 -4
- package/dist/__tests__/coordination-memory.test.js.map +1 -1
- package/dist/__tests__/coordination-provision.test.js +22 -14
- package/dist/__tests__/coordination-provision.test.js.map +1 -1
- package/dist/__tests__/coordination-status-registration.test.d.ts +16 -0
- package/dist/__tests__/coordination-status-registration.test.d.ts.map +1 -0
- package/dist/__tests__/coordination-status-registration.test.js +480 -0
- package/dist/__tests__/coordination-status-registration.test.js.map +1 -0
- package/dist/__tests__/coordination-token-multitenant.test.js +11 -11
- package/dist/__tests__/coordination-token-multitenant.test.js.map +1 -1
- package/dist/__tests__/coordination-token.test.js +35 -28
- package/dist/__tests__/coordination-token.test.js.map +1 -1
- package/dist/__tests__/creation-pr-class-check.test.d.ts +17 -0
- package/dist/__tests__/creation-pr-class-check.test.d.ts.map +1 -0
- package/dist/__tests__/creation-pr-class-check.test.js +346 -0
- package/dist/__tests__/creation-pr-class-check.test.js.map +1 -0
- package/dist/__tests__/decision-check.test.d.ts +2 -0
- package/dist/__tests__/decision-check.test.d.ts.map +1 -0
- package/dist/__tests__/decision-check.test.js +105 -0
- package/dist/__tests__/decision-check.test.js.map +1 -0
- package/dist/__tests__/digest-team-omission.test.d.ts +15 -0
- package/dist/__tests__/digest-team-omission.test.d.ts.map +1 -0
- package/dist/__tests__/digest-team-omission.test.js +247 -0
- package/dist/__tests__/digest-team-omission.test.js.map +1 -0
- package/dist/__tests__/doctor-worktree-path.test.d.ts +17 -0
- package/dist/__tests__/doctor-worktree-path.test.d.ts.map +1 -0
- package/dist/__tests__/doctor-worktree-path.test.js +158 -0
- package/dist/__tests__/doctor-worktree-path.test.js.map +1 -0
- package/dist/__tests__/fleet-data.test.js +40 -7
- package/dist/__tests__/fleet-data.test.js.map +1 -1
- package/dist/__tests__/fleet-tmux.test.js +2 -2
- package/dist/__tests__/fleet-tmux.test.js.map +1 -1
- package/dist/__tests__/generate-claude.test.js +137 -3
- package/dist/__tests__/generate-claude.test.js.map +1 -1
- package/dist/__tests__/git-env.test.d.ts +14 -0
- package/dist/__tests__/git-env.test.d.ts.map +1 -0
- package/dist/__tests__/git-env.test.js +131 -0
- package/dist/__tests__/git-env.test.js.map +1 -0
- package/dist/__tests__/git-identity-isolation.test.d.ts +33 -0
- package/dist/__tests__/git-identity-isolation.test.d.ts.map +1 -0
- package/dist/__tests__/git-identity-isolation.test.js +626 -0
- package/dist/__tests__/git-identity-isolation.test.js.map +1 -0
- package/dist/__tests__/harness-extract.test.d.ts +19 -0
- package/dist/__tests__/harness-extract.test.d.ts.map +1 -0
- package/dist/__tests__/harness-extract.test.js +566 -0
- package/dist/__tests__/harness-extract.test.js.map +1 -0
- package/dist/__tests__/harness-wiring.test.d.ts +16 -0
- package/dist/__tests__/harness-wiring.test.d.ts.map +1 -0
- package/dist/__tests__/harness-wiring.test.js +469 -0
- package/dist/__tests__/harness-wiring.test.js.map +1 -0
- package/dist/__tests__/hook-heal.test.js +17 -0
- package/dist/__tests__/hook-heal.test.js.map +1 -1
- package/dist/__tests__/init-coordination-url.test.d.ts +11 -0
- package/dist/__tests__/init-coordination-url.test.d.ts.map +1 -0
- package/dist/__tests__/init-coordination-url.test.js +114 -0
- package/dist/__tests__/init-coordination-url.test.js.map +1 -0
- package/dist/__tests__/memory-autocreate.test.js +574 -8
- package/dist/__tests__/memory-autocreate.test.js.map +1 -1
- package/dist/__tests__/memory-log-result.test.d.ts +13 -0
- package/dist/__tests__/memory-log-result.test.d.ts.map +1 -0
- package/dist/__tests__/memory-log-result.test.js +113 -0
- package/dist/__tests__/memory-log-result.test.js.map +1 -0
- package/dist/__tests__/memory-named-exists.test.d.ts +16 -0
- package/dist/__tests__/memory-named-exists.test.d.ts.map +1 -0
- package/dist/__tests__/memory-named-exists.test.js +288 -0
- package/dist/__tests__/memory-named-exists.test.js.map +1 -0
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js +23 -47
- package/dist/__tests__/mx-agent-cli-pin-validation.test.js.map +1 -1
- package/dist/__tests__/mx-agent-cli-version-pin.test.js +34 -88
- package/dist/__tests__/mx-agent-cli-version-pin.test.js.map +1 -1
- package/dist/__tests__/new-project-first-team.test.d.ts +15 -0
- package/dist/__tests__/new-project-first-team.test.d.ts.map +1 -0
- package/dist/__tests__/new-project-first-team.test.js +263 -0
- package/dist/__tests__/new-project-first-team.test.js.map +1 -0
- package/dist/__tests__/otel-env.test.d.ts +2 -0
- package/dist/__tests__/otel-env.test.d.ts.map +1 -0
- package/dist/__tests__/otel-env.test.js +127 -0
- package/dist/__tests__/otel-env.test.js.map +1 -0
- package/dist/__tests__/project-config.test.js +283 -1
- package/dist/__tests__/project-config.test.js.map +1 -1
- package/dist/__tests__/provision-behavioral-contract.test.js +96 -4
- package/dist/__tests__/provision-behavioral-contract.test.js.map +1 -1
- package/dist/__tests__/provision-catalog-precondition.test.d.ts +26 -0
- package/dist/__tests__/provision-catalog-precondition.test.d.ts.map +1 -0
- package/dist/__tests__/provision-catalog-precondition.test.js +620 -0
- package/dist/__tests__/provision-catalog-precondition.test.js.map +1 -0
- package/dist/__tests__/provision-completion-rows.test.d.ts +17 -0
- package/dist/__tests__/provision-completion-rows.test.d.ts.map +1 -0
- package/dist/__tests__/provision-completion-rows.test.js +3095 -0
- package/dist/__tests__/provision-completion-rows.test.js.map +1 -0
- package/dist/__tests__/provision-identity-gate.test.d.ts +20 -0
- package/dist/__tests__/provision-identity-gate.test.d.ts.map +1 -0
- package/dist/__tests__/provision-identity-gate.test.js +600 -0
- package/dist/__tests__/provision-identity-gate.test.js.map +1 -0
- package/dist/__tests__/provision-resume.test.d.ts +26 -0
- package/dist/__tests__/provision-resume.test.d.ts.map +1 -0
- package/dist/__tests__/provision-resume.test.js +1164 -0
- package/dist/__tests__/provision-resume.test.js.map +1 -0
- package/dist/__tests__/provision-roleguide-anchors.test.d.ts +27 -0
- package/dist/__tests__/provision-roleguide-anchors.test.d.ts.map +1 -0
- package/dist/__tests__/provision-roleguide-anchors.test.js +747 -0
- package/dist/__tests__/provision-roleguide-anchors.test.js.map +1 -0
- package/dist/__tests__/provision-skeleton-fill.test.d.ts +16 -0
- package/dist/__tests__/provision-skeleton-fill.test.d.ts.map +1 -0
- package/dist/__tests__/provision-skeleton-fill.test.js +488 -0
- package/dist/__tests__/provision-skeleton-fill.test.js.map +1 -0
- package/dist/__tests__/provision-teambuilder-flow.test.js +93 -7
- package/dist/__tests__/provision-teambuilder-flow.test.js.map +1 -1
- package/dist/__tests__/repo-guard-wiring.test.d.ts +21 -0
- package/dist/__tests__/repo-guard-wiring.test.d.ts.map +1 -0
- package/dist/__tests__/repo-guard-wiring.test.js +638 -0
- package/dist/__tests__/repo-guard-wiring.test.js.map +1 -0
- package/dist/__tests__/report-format.test.d.ts +2 -0
- package/dist/__tests__/report-format.test.d.ts.map +1 -0
- package/dist/__tests__/report-format.test.js +219 -0
- package/dist/__tests__/report-format.test.js.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts +2 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.js +309 -0
- package/dist/__tests__/runtime-codex-gateway-pilot.test.js.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts +2 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.js +163 -0
- package/dist/__tests__/runtime-codex-gateway-provider.test.js.map +1 -0
- package/dist/__tests__/runtime-identity.test.d.ts +2 -0
- package/dist/__tests__/runtime-identity.test.d.ts.map +1 -0
- package/dist/__tests__/runtime-identity.test.js +117 -0
- package/dist/__tests__/runtime-identity.test.js.map +1 -0
- package/dist/__tests__/session-pause-provisioning.test.js +6 -1
- package/dist/__tests__/session-pause-provisioning.test.js.map +1 -1
- package/dist/__tests__/session-record-disclosure.test.d.ts +24 -0
- package/dist/__tests__/session-record-disclosure.test.d.ts.map +1 -0
- package/dist/__tests__/session-record-disclosure.test.js +494 -0
- package/dist/__tests__/session-record-disclosure.test.js.map +1 -0
- package/dist/__tests__/session.test.js +35 -0
- package/dist/__tests__/session.test.js.map +1 -1
- package/dist/__tests__/slug-validation.test.js +27 -21
- package/dist/__tests__/slug-validation.test.js.map +1 -1
- package/dist/__tests__/standards-injection.test.d.ts +2 -0
- package/dist/__tests__/standards-injection.test.d.ts.map +1 -0
- package/dist/__tests__/standards-injection.test.js +179 -0
- package/dist/__tests__/standards-injection.test.js.map +1 -0
- package/dist/__tests__/start-interactive-role.test.d.ts +22 -0
- package/dist/__tests__/start-interactive-role.test.d.ts.map +1 -0
- package/dist/__tests__/start-interactive-role.test.js +204 -0
- package/dist/__tests__/start-interactive-role.test.js.map +1 -0
- package/dist/__tests__/start-team-identity.test.d.ts +25 -0
- package/dist/__tests__/start-team-identity.test.d.ts.map +1 -0
- package/dist/__tests__/start-team-identity.test.js +307 -0
- package/dist/__tests__/start-team-identity.test.js.map +1 -0
- package/dist/__tests__/team-memory-commands.test.js +142 -19
- package/dist/__tests__/team-memory-commands.test.js.map +1 -1
- package/dist/__tests__/template-sync.test.d.ts +19 -0
- package/dist/__tests__/template-sync.test.d.ts.map +1 -0
- package/dist/__tests__/template-sync.test.js +270 -0
- package/dist/__tests__/template-sync.test.js.map +1 -0
- package/dist/__tests__/test-project.test.d.ts +18 -0
- package/dist/__tests__/test-project.test.d.ts.map +1 -0
- package/dist/__tests__/test-project.test.js +465 -0
- package/dist/__tests__/test-project.test.js.map +1 -0
- package/dist/__tests__/usage-per-call-grouping.test.d.ts +25 -0
- package/dist/__tests__/usage-per-call-grouping.test.d.ts.map +1 -0
- package/dist/__tests__/usage-per-call-grouping.test.js +952 -0
- package/dist/__tests__/usage-per-call-grouping.test.js.map +1 -0
- package/dist/__tests__/verify-hooks-check-all.test.d.ts +32 -0
- package/dist/__tests__/verify-hooks-check-all.test.d.ts.map +1 -0
- package/dist/__tests__/verify-hooks-check-all.test.js +553 -0
- package/dist/__tests__/verify-hooks-check-all.test.js.map +1 -0
- package/dist/__tests__/worktree-sync-fixture.test.d.ts +17 -0
- package/dist/__tests__/worktree-sync-fixture.test.d.ts.map +1 -0
- package/dist/__tests__/worktree-sync-fixture.test.js +519 -0
- package/dist/__tests__/worktree-sync-fixture.test.js.map +1 -0
- package/dist/__tests__/worktree-sync-hardening.test.d.ts +13 -0
- package/dist/__tests__/worktree-sync-hardening.test.d.ts.map +1 -0
- package/dist/__tests__/worktree-sync-hardening.test.js +919 -0
- package/dist/__tests__/worktree-sync-hardening.test.js.map +1 -0
- package/dist/__tests__/worktree-sync-shell-free.test.d.ts +25 -0
- package/dist/__tests__/worktree-sync-shell-free.test.d.ts.map +1 -0
- package/dist/__tests__/worktree-sync-shell-free.test.js +185 -0
- package/dist/__tests__/worktree-sync-shell-free.test.js.map +1 -0
- package/dist/__tests__/worktree.test.js +75 -1
- package/dist/__tests__/worktree.test.js.map +1 -1
- package/dist/agent-config/.mx-config-generation.json +2 -2
- package/dist/agent-config/AGENTS.md.template +2 -2
- package/dist/agent-config/agents/bar-raiser.md +34 -1
- package/dist/agent-config/agents/red-team.md +34 -1
- package/dist/agent-config/agents/security-reviewer.md +22 -1
- package/dist/agent-config/claude-md/CLAUDE.core.md +6 -1
- package/dist/agent-config/claude-md/CLAUDE.overlay.memnexus.md +1 -3
- package/dist/agent-config/coordination-rosters.generated.json +10 -0
- package/dist/agent-config/hooks/HOOK-TIMEOUTS.md +27 -1
- package/dist/agent-config/hooks/OR-TRUE-AUDIT.md +8 -8
- package/dist/agent-config/hooks/auto-capture-precompact.sh +180 -83
- package/dist/agent-config/hooks/auto-capture-session-end.sh +216 -87
- package/dist/agent-config/hooks/auto-checkpoint.sh +75 -5
- package/dist/agent-config/hooks/coordination-brief.sh +290 -245
- package/dist/agent-config/hooks/deploy-verification-reminder.sh +359 -22
- package/dist/agent-config/hooks/git-mutation-guard.sh +85 -13
- package/dist/agent-config/hooks/observability-sync.sh +46 -9
- package/dist/agent-config/hooks/session-idle-gate.sh +177 -12
- package/dist/agent-config/hooks/subagent-write-guard.sh +670 -0
- package/dist/agent-config/hooks/worktree-guard.sh +36 -7
- package/dist/agent-config/settings.json +15 -2
- package/dist/agent-config/shared/creation-pr-review-checklist.md +317 -0
- package/dist/commands/bootstrap.d.ts.map +1 -1
- package/dist/commands/bootstrap.js +22 -10
- package/dist/commands/bootstrap.js.map +1 -1
- package/dist/commands/config-sync.d.ts +37 -0
- package/dist/commands/config-sync.d.ts.map +1 -1
- package/dist/commands/config-sync.js +36 -18
- package/dist/commands/config-sync.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +28 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/coordination.d.ts +150 -8
- package/dist/commands/coordination.d.ts.map +1 -1
- package/dist/commands/coordination.js +519 -25
- package/dist/commands/coordination.js.map +1 -1
- package/dist/commands/create.d.ts +913 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +4879 -345
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +10 -2
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/decision.d.ts +20 -0
- package/dist/commands/decision.d.ts.map +1 -0
- package/dist/commands/decision.js +54 -0
- package/dist/commands/decision.js.map +1 -0
- package/dist/commands/digest.d.ts.map +1 -1
- package/dist/commands/digest.js +91 -7
- package/dist/commands/digest.js.map +1 -1
- package/dist/commands/fleet-tmux.js +1 -1
- package/dist/commands/fleet-tmux.js.map +1 -1
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +26 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list.d.ts +32 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +98 -5
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/monitor.d.ts.map +1 -1
- package/dist/commands/monitor.js +8 -2
- package/dist/commands/monitor.js.map +1 -1
- package/dist/commands/new.d.ts +2 -0
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +114 -21
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/report.d.ts +33 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +73 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/session.js +1 -1
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/start.d.ts +42 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +177 -8
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/sync.d.ts +57 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +117 -3
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/update.d.ts +13 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +50 -1
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/usage.d.ts +64 -0
- package/dist/commands/usage.d.ts.map +1 -1
- package/dist/commands/usage.js +96 -3
- package/dist/commands/usage.js.map +1 -1
- package/dist/commands/verify-hooks.d.ts +37 -1
- package/dist/commands/verify-hooks.d.ts.map +1 -1
- package/dist/commands/verify-hooks.js +114 -2
- package/dist/commands/verify-hooks.js.map +1 -1
- package/dist/commands/window.d.ts +10 -0
- package/dist/commands/window.d.ts.map +1 -0
- package/dist/commands/window.js +265 -0
- package/dist/commands/window.js.map +1 -0
- package/dist/commands/worktree-sync.d.ts +54 -0
- package/dist/commands/worktree-sync.d.ts.map +1 -0
- package/dist/commands/worktree-sync.js +135 -0
- package/dist/commands/worktree-sync.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +189 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-session.d.ts +12 -0
- package/dist/lib/agent-session.d.ts.map +1 -1
- package/dist/lib/agent-session.js +189 -42
- package/dist/lib/agent-session.js.map +1 -1
- package/dist/lib/catalog.d.ts +321 -2
- package/dist/lib/catalog.d.ts.map +1 -1
- package/dist/lib/catalog.js +490 -11
- package/dist/lib/catalog.js.map +1 -1
- package/dist/lib/claude.d.ts +65 -23
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +335 -19
- package/dist/lib/claude.js.map +1 -1
- package/dist/lib/cli-build.d.ts +172 -0
- package/dist/lib/cli-build.d.ts.map +1 -0
- package/dist/lib/cli-build.js +654 -0
- package/dist/lib/cli-build.js.map +1 -0
- package/dist/lib/code-context-file.d.ts +109 -0
- package/dist/lib/code-context-file.d.ts.map +1 -0
- package/dist/lib/code-context-file.js +219 -0
- package/dist/lib/code-context-file.js.map +1 -0
- package/dist/lib/code-context-file.test.d.ts +19 -0
- package/dist/lib/code-context-file.test.d.ts.map +1 -0
- package/dist/lib/code-context-file.test.js +202 -0
- package/dist/lib/code-context-file.test.js.map +1 -0
- package/dist/lib/config-fidelity.d.ts +40 -20
- package/dist/lib/config-fidelity.d.ts.map +1 -1
- package/dist/lib/config-fidelity.js +144 -56
- package/dist/lib/config-fidelity.js.map +1 -1
- package/dist/lib/coordination-client.d.ts +73 -0
- package/dist/lib/coordination-client.d.ts.map +1 -1
- package/dist/lib/coordination-client.js +180 -8
- package/dist/lib/coordination-client.js.map +1 -1
- package/dist/lib/coordination-token.d.ts +304 -6
- package/dist/lib/coordination-token.d.ts.map +1 -1
- package/dist/lib/coordination-token.js +851 -52
- package/dist/lib/coordination-token.js.map +1 -1
- package/dist/lib/decision-check.d.ts +48 -0
- package/dist/lib/decision-check.d.ts.map +1 -0
- package/dist/lib/decision-check.js +149 -0
- package/dist/lib/decision-check.js.map +1 -0
- package/dist/lib/fleet-data.d.ts +34 -0
- package/dist/lib/fleet-data.d.ts.map +1 -1
- package/dist/lib/fleet-data.js +37 -9
- package/dist/lib/fleet-data.js.map +1 -1
- package/dist/lib/fleet-render.js +1 -1
- package/dist/lib/fleet-render.js.map +1 -1
- package/dist/lib/git-identity.d.ts +302 -0
- package/dist/lib/git-identity.d.ts.map +1 -0
- package/dist/lib/git-identity.js +546 -0
- package/dist/lib/git-identity.js.map +1 -0
- package/dist/lib/harness/console/announce.d.ts +45 -0
- package/dist/lib/harness/console/announce.d.ts.map +1 -0
- package/dist/lib/harness/console/announce.js +48 -0
- package/dist/lib/harness/console/announce.js.map +1 -0
- package/dist/lib/harness/console/announce.test.d.ts +2 -0
- package/dist/lib/harness/console/announce.test.d.ts.map +1 -0
- package/dist/lib/harness/console/announce.test.js +104 -0
- package/dist/lib/harness/console/announce.test.js.map +1 -0
- package/dist/lib/harness/console/by-session.d.ts +50 -0
- package/dist/lib/harness/console/by-session.d.ts.map +1 -0
- package/dist/lib/harness/console/by-session.js +83 -0
- package/dist/lib/harness/console/by-session.js.map +1 -0
- package/dist/lib/harness/console/by-session.test.d.ts +2 -0
- package/dist/lib/harness/console/by-session.test.d.ts.map +1 -0
- package/dist/lib/harness/console/by-session.test.js +86 -0
- package/dist/lib/harness/console/by-session.test.js.map +1 -0
- package/dist/lib/harness/console/console.d.ts +67 -0
- package/dist/lib/harness/console/console.d.ts.map +1 -0
- package/dist/lib/harness/console/console.js +373 -0
- package/dist/lib/harness/console/console.js.map +1 -0
- package/dist/lib/harness/console/console.test.d.ts +2 -0
- package/dist/lib/harness/console/console.test.d.ts.map +1 -0
- package/dist/lib/harness/console/console.test.js +269 -0
- package/dist/lib/harness/console/console.test.js.map +1 -0
- package/dist/lib/harness/console/decision-request.d.ts +32 -0
- package/dist/lib/harness/console/decision-request.d.ts.map +1 -0
- package/dist/lib/harness/console/decision-request.js +112 -0
- package/dist/lib/harness/console/decision-request.js.map +1 -0
- package/dist/lib/harness/console/decision-request.test.d.ts +2 -0
- package/dist/lib/harness/console/decision-request.test.d.ts.map +1 -0
- package/dist/lib/harness/console/decision-request.test.js +75 -0
- package/dist/lib/harness/console/decision-request.test.js.map +1 -0
- package/dist/lib/harness/console/fixtures.d.ts +16 -0
- package/dist/lib/harness/console/fixtures.d.ts.map +1 -0
- package/dist/lib/harness/console/fixtures.js +49 -0
- package/dist/lib/harness/console/fixtures.js.map +1 -0
- package/dist/lib/harness/console/index.d.ts +15 -0
- package/dist/lib/harness/console/index.d.ts.map +1 -0
- package/dist/lib/harness/console/index.js +14 -0
- package/dist/lib/harness/console/index.js.map +1 -0
- package/dist/lib/harness/console/rank.d.ts +73 -0
- package/dist/lib/harness/console/rank.d.ts.map +1 -0
- package/dist/lib/harness/console/rank.js +113 -0
- package/dist/lib/harness/console/rank.js.map +1 -0
- package/dist/lib/harness/console/rank.test.d.ts +2 -0
- package/dist/lib/harness/console/rank.test.d.ts.map +1 -0
- package/dist/lib/harness/console/rank.test.js +124 -0
- package/dist/lib/harness/console/rank.test.js.map +1 -0
- package/dist/lib/harness/console/render.d.ts +22 -0
- package/dist/lib/harness/console/render.d.ts.map +1 -0
- package/dist/lib/harness/console/render.js +65 -0
- package/dist/lib/harness/console/render.js.map +1 -0
- package/dist/lib/harness/console/render.test.d.ts +2 -0
- package/dist/lib/harness/console/render.test.d.ts.map +1 -0
- package/dist/lib/harness/console/render.test.js +96 -0
- package/dist/lib/harness/console/render.test.js.map +1 -0
- package/dist/lib/harness/console/replay-cli.test.d.ts +2 -0
- package/dist/lib/harness/console/replay-cli.test.d.ts.map +1 -0
- package/dist/lib/harness/console/replay-cli.test.js +96 -0
- package/dist/lib/harness/console/replay-cli.test.js.map +1 -0
- package/dist/lib/harness/console/replay.d.ts +36 -0
- package/dist/lib/harness/console/replay.d.ts.map +1 -0
- package/dist/lib/harness/console/replay.js +59 -0
- package/dist/lib/harness/console/replay.js.map +1 -0
- package/dist/lib/harness/console/replay.test.d.ts +2 -0
- package/dist/lib/harness/console/replay.test.d.ts.map +1 -0
- package/dist/lib/harness/console/replay.test.js +81 -0
- package/dist/lib/harness/console/replay.test.js.map +1 -0
- package/dist/lib/harness/console/turn-reader.d.ts +50 -0
- package/dist/lib/harness/console/turn-reader.d.ts.map +1 -0
- package/dist/lib/harness/console/turn-reader.js +184 -0
- package/dist/lib/harness/console/turn-reader.js.map +1 -0
- package/dist/lib/harness/console/turn-reader.test.d.ts +2 -0
- package/dist/lib/harness/console/turn-reader.test.d.ts.map +1 -0
- package/dist/lib/harness/console/turn-reader.test.js +108 -0
- package/dist/lib/harness/console/turn-reader.test.js.map +1 -0
- package/dist/lib/harness/console/types.d.ts +109 -0
- package/dist/lib/harness/console/types.d.ts.map +1 -0
- package/dist/lib/harness/console/types.js +2 -0
- package/dist/lib/harness/console/types.js.map +1 -0
- package/dist/lib/harness/contract.d.ts +229 -0
- package/dist/lib/harness/contract.d.ts.map +1 -0
- package/dist/lib/harness/contract.js +22 -0
- package/dist/lib/harness/contract.js.map +1 -0
- package/dist/lib/harness/credential.d.ts +23 -0
- package/dist/lib/harness/credential.d.ts.map +1 -0
- package/dist/lib/harness/credential.js +81 -0
- package/dist/lib/harness/credential.js.map +1 -0
- package/dist/lib/harness/credential.test.d.ts +2 -0
- package/dist/lib/harness/credential.test.d.ts.map +1 -0
- package/dist/lib/harness/credential.test.js +74 -0
- package/dist/lib/harness/credential.test.js.map +1 -0
- package/dist/lib/harness/evaluate.d.ts +390 -0
- package/dist/lib/harness/evaluate.d.ts.map +1 -0
- package/dist/lib/harness/evaluate.js +988 -0
- package/dist/lib/harness/evaluate.js.map +1 -0
- package/dist/lib/harness/evaluate.test.d.ts +2 -0
- package/dist/lib/harness/evaluate.test.d.ts.map +1 -0
- package/dist/lib/harness/evaluate.test.js +621 -0
- package/dist/lib/harness/evaluate.test.js.map +1 -0
- package/dist/lib/harness/extract.d.ts +152 -0
- package/dist/lib/harness/extract.d.ts.map +1 -0
- package/dist/lib/harness/extract.js +1601 -0
- package/dist/lib/harness/extract.js.map +1 -0
- package/dist/lib/harness/gate.d.ts +48 -0
- package/dist/lib/harness/gate.d.ts.map +1 -0
- package/dist/lib/harness/gate.js +60 -0
- package/dist/lib/harness/gate.js.map +1 -0
- package/dist/lib/harness/gate.test.d.ts +2 -0
- package/dist/lib/harness/gate.test.d.ts.map +1 -0
- package/dist/lib/harness/gate.test.js +111 -0
- package/dist/lib/harness/gate.test.js.map +1 -0
- package/dist/lib/harness/self-check.d.ts +59 -0
- package/dist/lib/harness/self-check.d.ts.map +1 -0
- package/dist/lib/harness/self-check.js +56 -0
- package/dist/lib/harness/self-check.js.map +1 -0
- package/dist/lib/harness/self-check.test.d.ts +2 -0
- package/dist/lib/harness/self-check.test.d.ts.map +1 -0
- package/dist/lib/harness/self-check.test.js +43 -0
- package/dist/lib/harness/self-check.test.js.map +1 -0
- package/dist/lib/harness/transcript.d.ts +65 -0
- package/dist/lib/harness/transcript.d.ts.map +1 -0
- package/dist/lib/harness/transcript.js +144 -0
- package/dist/lib/harness/transcript.js.map +1 -0
- package/dist/lib/harness/transcript.test.d.ts +2 -0
- package/dist/lib/harness/transcript.test.d.ts.map +1 -0
- package/dist/lib/harness/transcript.test.js +118 -0
- package/dist/lib/harness/transcript.test.js.map +1 -0
- package/dist/lib/harness-wiring.d.ts +145 -0
- package/dist/lib/harness-wiring.d.ts.map +1 -0
- package/dist/lib/harness-wiring.js +280 -0
- package/dist/lib/harness-wiring.js.map +1 -0
- package/dist/lib/hook-staleness.d.ts +95 -0
- package/dist/lib/hook-staleness.d.ts.map +1 -0
- package/dist/lib/hook-staleness.js +304 -0
- package/dist/lib/hook-staleness.js.map +1 -0
- package/dist/lib/jsonl.d.ts +270 -2
- package/dist/lib/jsonl.d.ts.map +1 -1
- package/dist/lib/jsonl.js +472 -76
- package/dist/lib/jsonl.js.map +1 -1
- package/dist/lib/memory.d.ts +350 -23
- package/dist/lib/memory.d.ts.map +1 -1
- package/dist/lib/memory.js +751 -38
- package/dist/lib/memory.js.map +1 -1
- package/dist/lib/otel-env.d.ts +90 -0
- package/dist/lib/otel-env.d.ts.map +1 -0
- package/dist/lib/otel-env.js +98 -0
- package/dist/lib/otel-env.js.map +1 -0
- package/dist/lib/project-config.d.ts +167 -0
- package/dist/lib/project-config.d.ts.map +1 -1
- package/dist/lib/project-config.js +321 -5
- package/dist/lib/project-config.js.map +1 -1
- package/dist/lib/projects-registry.d.ts +82 -0
- package/dist/lib/projects-registry.d.ts.map +1 -0
- package/dist/lib/projects-registry.js +145 -0
- package/dist/lib/projects-registry.js.map +1 -0
- package/dist/lib/projects-registry.test.d.ts +2 -0
- package/dist/lib/projects-registry.test.d.ts.map +1 -0
- package/dist/lib/projects-registry.test.js +176 -0
- package/dist/lib/projects-registry.test.js.map +1 -0
- package/dist/lib/repo-guard-scope.d.ts +126 -0
- package/dist/lib/repo-guard-scope.d.ts.map +1 -0
- package/dist/lib/repo-guard-scope.js +249 -0
- package/dist/lib/repo-guard-scope.js.map +1 -0
- package/dist/lib/report-format.d.ts +132 -0
- package/dist/lib/report-format.d.ts.map +1 -0
- package/dist/lib/report-format.js +317 -0
- package/dist/lib/report-format.js.map +1 -0
- package/dist/lib/roster.d.ts +87 -0
- package/dist/lib/roster.d.ts.map +1 -0
- package/dist/lib/roster.js +332 -0
- package/dist/lib/roster.js.map +1 -0
- package/dist/lib/roster.test.d.ts +15 -0
- package/dist/lib/roster.test.d.ts.map +1 -0
- package/dist/lib/roster.test.js +299 -0
- package/dist/lib/roster.test.js.map +1 -0
- package/dist/lib/runtime/codex-adapter.d.ts.map +1 -1
- package/dist/lib/runtime/codex-adapter.js +5 -0
- package/dist/lib/runtime/codex-adapter.js.map +1 -1
- package/dist/lib/runtime/codex-config.d.ts +129 -0
- package/dist/lib/runtime/codex-config.d.ts.map +1 -1
- package/dist/lib/runtime/codex-config.js +225 -0
- package/dist/lib/runtime/codex-config.js.map +1 -1
- package/dist/lib/runtime/identity.d.ts +72 -0
- package/dist/lib/runtime/identity.d.ts.map +1 -0
- package/dist/lib/runtime/identity.js +128 -0
- package/dist/lib/runtime/identity.js.map +1 -0
- package/dist/lib/standards.d.ts +99 -0
- package/dist/lib/standards.d.ts.map +1 -0
- package/dist/lib/standards.js +201 -0
- package/dist/lib/standards.js.map +1 -0
- package/dist/lib/team-identity.d.ts +134 -0
- package/dist/lib/team-identity.d.ts.map +1 -0
- package/dist/lib/team-identity.js +193 -0
- package/dist/lib/team-identity.js.map +1 -0
- package/dist/lib/templates.d.ts +29 -2
- package/dist/lib/templates.d.ts.map +1 -1
- package/dist/lib/templates.js +1042 -82
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/terminal-ui.d.ts.map +1 -1
- package/dist/lib/terminal-ui.js +12 -1
- package/dist/lib/terminal-ui.js.map +1 -1
- package/dist/lib/test-project.d.ts +95 -0
- package/dist/lib/test-project.d.ts.map +1 -0
- package/dist/lib/test-project.js +103 -0
- package/dist/lib/test-project.js.map +1 -0
- package/dist/lib/vault.d.ts +60 -0
- package/dist/lib/vault.d.ts.map +1 -0
- package/dist/lib/vault.js +102 -0
- package/dist/lib/vault.js.map +1 -0
- package/dist/lib/vault.test.d.ts +17 -0
- package/dist/lib/vault.test.d.ts.map +1 -0
- package/dist/lib/vault.test.js +169 -0
- package/dist/lib/vault.test.js.map +1 -0
- package/dist/lib/window-view.d.ts +63 -0
- package/dist/lib/window-view.d.ts.map +1 -0
- package/dist/lib/window-view.js +217 -0
- package/dist/lib/window-view.js.map +1 -0
- package/dist/lib/window-view.test.d.ts +2 -0
- package/dist/lib/window-view.test.d.ts.map +1 -0
- package/dist/lib/window-view.test.js +168 -0
- package/dist/lib/window-view.test.js.map +1 -0
- package/dist/lib/worktree-sync.d.ts +439 -0
- package/dist/lib/worktree-sync.d.ts.map +1 -0
- package/dist/lib/worktree-sync.js +1167 -0
- package/dist/lib/worktree-sync.js.map +1 -0
- package/dist/lib/worktree.d.ts +58 -1
- package/dist/lib/worktree.d.ts.map +1 -1
- package/dist/lib/worktree.js +91 -4
- package/dist/lib/worktree.js.map +1 -1
- package/dist/standards/decision-request.md +98 -0
- package/dist/standards/fail-loud-standard.md +495 -0
- package/dist/standards/po-communication-standard.md +126 -0
- package/dist/standards/report-format.md +128 -0
- package/dist/standards/writing-standard.md +382 -0
- package/package.json +3 -2
- package/scripts/generate-claude.mjs +119 -46
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
* only a local durable fallback file and flushes it on the next success.
|
|
11
11
|
*/
|
|
12
12
|
import { existsSync, readFileSync, writeFileSync, readdirSync, statSync, realpathSync } from 'node:fs';
|
|
13
|
+
import { spawnSync } from 'node:child_process';
|
|
13
14
|
import { join } from 'node:path';
|
|
14
15
|
import { HttpCoordinationClient, resolveClientConfig, resolveCoordinationMode, ServiceUnreachableError, ServiceHttpError, CONFIG_KEY_URL, } from '../lib/coordination-client.js';
|
|
15
|
-
import { resolveCoordinationToken, refreshCoordinationToken, } from '../lib/coordination-token.js';
|
|
16
|
+
import { resolveCoordinationToken, refreshCoordinationToken, usesCredentialEndpoint, ENV_KEY_EXPECT_PROJECT, ENV_KEY_EXPECT_TEAM, } from '../lib/coordination-token.js';
|
|
16
17
|
import { isValidProjectSlug, invalidProjectSlugMessage } from '../lib/slug.js';
|
|
17
18
|
import { appendFallbackEntry, flushFallback } from '../lib/coordination-fallback.js';
|
|
18
19
|
import { renderMessages, renderRoutingDescription, renderPipelineExtractionWarning, findOverBudgetDropped, } from '../lib/coordination-render.js';
|
|
@@ -229,7 +230,7 @@ function authFailureMessage(res, retried) {
|
|
|
229
230
|
else {
|
|
230
231
|
lines.push(' No token refresh was available for this invocation.');
|
|
231
232
|
}
|
|
232
|
-
lines.push(' What to do:', ' 1. mx-agent coordination status — confirm this worktree\'s identity', ' 2. mx-agent coordination brief — run it by hand and read the full error', ' 3. Still rejected? This team\'s token needs re-issuing
|
|
233
|
+
lines.push(' What to do:', ' 1. mx-agent coordination status — confirm this worktree\'s identity', ' 2. mx-agent coordination brief — run it by hand and read the full error', ' 3. Still rejected? This team\'s token needs re-issuing. Run `az login` in this worktree.', ' Filing an escalation from here queues locally and will not reach `bootstrap` until a token works again.');
|
|
233
234
|
return lines.join('\n');
|
|
234
235
|
}
|
|
235
236
|
/**
|
|
@@ -304,7 +305,9 @@ class AuthRetryingClient {
|
|
|
304
305
|
const rejected = this.currentToken ?? process.env.MX_COORD_SERVICE_TOKEN ?? '';
|
|
305
306
|
let res;
|
|
306
307
|
try {
|
|
307
|
-
|
|
308
|
+
// `await` because the credential path (#288) is an HTTP request; a
|
|
309
|
+
// synchronous test double is awaited unchanged.
|
|
310
|
+
res = await this.refresh(rejected);
|
|
308
311
|
}
|
|
309
312
|
catch (refreshErr) {
|
|
310
313
|
// refreshCoordinationToken is documented never-throws; belt and braces —
|
|
@@ -369,7 +372,7 @@ export function withTokenRefresh(inner, rebuild, refresh, initialToken) {
|
|
|
369
372
|
* still goes through env — it is read by the session-start hook in another process,
|
|
370
373
|
* which is the whole point of it.
|
|
371
374
|
*/
|
|
372
|
-
export function prepareClient(deps) {
|
|
375
|
+
export async function prepareClient(deps) {
|
|
373
376
|
if (deps?.client) {
|
|
374
377
|
// Provisioning is still skipped for an injected client, but the 401 recovery
|
|
375
378
|
// wrapper is NOT: it is the single path every command goes through, and a
|
|
@@ -388,7 +391,31 @@ export function prepareClient(deps) {
|
|
|
388
391
|
// hiccup must never crash `mx-agent coordination brief` (breaks session start).
|
|
389
392
|
let res = { status: 'unprovisioned', detail: 'token resolution failed' };
|
|
390
393
|
try {
|
|
391
|
-
|
|
394
|
+
// #290 Must Fix 3: arm the #220 interlock EXPLICITLY.
|
|
395
|
+
//
|
|
396
|
+
// What this changes and what it does not, stated exactly. The interlock
|
|
397
|
+
// already falls back to these two environment variables inside
|
|
398
|
+
// `identityInterlockMismatch`, so passing them here is the same comparison
|
|
399
|
+
// made visible at the call site rather than a new one: a mutation test that
|
|
400
|
+
// removes this argument still refuses when the variables are set. It is here
|
|
401
|
+
// so the contract is greppable and so a future caller cannot assume the
|
|
402
|
+
// resolver invents an assertion of its own.
|
|
403
|
+
//
|
|
404
|
+
// The substantive half of Must Fix 3 is in `start.ts`, which asserts the team
|
|
405
|
+
// it was ASKED to start, a value that does not come from the worktree.
|
|
406
|
+
//
|
|
407
|
+
// What neither fixes: a bare `coordination brief` in a worktree, with these
|
|
408
|
+
// variables unset, has no second source for the team. The marker is the
|
|
409
|
+
// authoritative one, and comparing it with itself proves nothing, so the
|
|
410
|
+
// interlock cannot fire on that path. The arming below at `??=` is exactly
|
|
411
|
+
// that self-comparison and is why this was reported as never armed. Closing
|
|
412
|
+
// that needs a source outside the worktree, which is #220's own fix.
|
|
413
|
+
res = await resolveCoordinationToken({
|
|
414
|
+
expect: {
|
|
415
|
+
project: process.env[ENV_KEY_EXPECT_PROJECT],
|
|
416
|
+
team: process.env[ENV_KEY_EXPECT_TEAM],
|
|
417
|
+
},
|
|
418
|
+
});
|
|
392
419
|
let provisioned;
|
|
393
420
|
if (res.status === 'resolved' && res.token) {
|
|
394
421
|
// Handed to resolveClientConfig as an override — in-process, never env, never
|
|
@@ -398,7 +425,7 @@ export function prepareClient(deps) {
|
|
|
398
425
|
// self-provisioned path, matching the hook (which set MX_COORD_EXPECT_TEAM).
|
|
399
426
|
// `??=` so an explicit hook-set value is never overwritten. Not a secret.
|
|
400
427
|
if (res.slug)
|
|
401
|
-
process.env
|
|
428
|
+
process.env[ENV_KEY_EXPECT_TEAM] ??= res.slug;
|
|
402
429
|
}
|
|
403
430
|
const cfg = resolveClientConfig({ token: provisioned });
|
|
404
431
|
// #4970: every provisioned client recovers from a rotated token — invalidate
|
|
@@ -415,6 +442,30 @@ export function prepareClient(deps) {
|
|
|
415
442
|
` To check status: mx-agent coordination status\n` +
|
|
416
443
|
` Falling back to memory-based coordination for this session.\n`);
|
|
417
444
|
}
|
|
445
|
+
else if (res.status === 'identity-mismatch') {
|
|
446
|
+
// #220: the resolved identity is not the one the caller asserted. No
|
|
447
|
+
// credential was requested. Both slugs are in res.detail and neither is a
|
|
448
|
+
// secret.
|
|
449
|
+
process.stderr.write(`coordination: refusing to obtain a credential — ${res.detail}\n` +
|
|
450
|
+
` Falling back to memory-based coordination for this session.\n`);
|
|
451
|
+
}
|
|
452
|
+
else if (res.status === 'invalid-key') {
|
|
453
|
+
// Names the KEY. Says nothing about the team.
|
|
454
|
+
process.stderr.write(`coordination: ${res.detail}\n` +
|
|
455
|
+
` Falling back to memory-based coordination for this session.\n`);
|
|
456
|
+
}
|
|
457
|
+
else if (res.status === 'not-authorized') {
|
|
458
|
+
// Fixed wording, identical whether the team exists or not. Nothing is added
|
|
459
|
+
// here that would distinguish the two cases.
|
|
460
|
+
process.stderr.write(`coordination: ${res.detail}\n` +
|
|
461
|
+
` Falling back to memory-based coordination for this session.\n`);
|
|
462
|
+
}
|
|
463
|
+
else if (res.status === 'unavailable') {
|
|
464
|
+
// Could-not-run, reported as itself. Never "unprovisioned": nothing is
|
|
465
|
+
// missing and there is nothing for an operator to provision.
|
|
466
|
+
process.stderr.write(`coordination: ${res.detail}\n` +
|
|
467
|
+
` Falling back to memory-based coordination for this session.\n`);
|
|
468
|
+
}
|
|
418
469
|
else if (res.status === 'misconfigured') {
|
|
419
470
|
// Fail-CLOSED on an invalid explicitly-set project slug: name the offending
|
|
420
471
|
// value + rule (res.detail) so the operator can fix the config. We do NOT
|
|
@@ -794,7 +845,7 @@ export async function runEscalate(opts, deps) {
|
|
|
794
845
|
}
|
|
795
846
|
const team = resolveTeam(opts.team);
|
|
796
847
|
const entry = { team, to: opts.to, priority: opts.priority, body, from: team };
|
|
797
|
-
const client = prepareClient(deps);
|
|
848
|
+
const client = await prepareClient(deps);
|
|
798
849
|
if (!client) {
|
|
799
850
|
// No token/URL could be provisioned (prepareClient already printed the reason).
|
|
800
851
|
// Degrade to the local fallback so the message is never lost.
|
|
@@ -866,7 +917,7 @@ export async function runDrain(opts, deps) {
|
|
|
866
917
|
memoryModeQueueOnlyNote('drain');
|
|
867
918
|
return; // exit 0 — no crash
|
|
868
919
|
}
|
|
869
|
-
const client = prepareClient(deps);
|
|
920
|
+
const client = await prepareClient(deps);
|
|
870
921
|
if (!client)
|
|
871
922
|
return; // could not provision — fall back (prepareClient printed why)
|
|
872
923
|
// Flush any queued-locally entries now that the service is reachable.
|
|
@@ -920,7 +971,7 @@ export async function runBrief(opts = {}, deps) {
|
|
|
920
971
|
if (resolveCoordinationMode() === 'memory') {
|
|
921
972
|
return runBriefMemory(opts, deps);
|
|
922
973
|
}
|
|
923
|
-
const client = prepareClient(deps);
|
|
974
|
+
const client = await prepareClient(deps);
|
|
924
975
|
if (!client)
|
|
925
976
|
return; // could not provision — fall back (prepareClient printed why)
|
|
926
977
|
await opportunisticFlush(client);
|
|
@@ -1024,7 +1075,7 @@ export async function runWatch(opts = {}, deps) {
|
|
|
1024
1075
|
memoryModeQueueOnlyNote('watch');
|
|
1025
1076
|
return; // exit 0 — no crash
|
|
1026
1077
|
}
|
|
1027
|
-
const client = prepareClient(deps);
|
|
1078
|
+
const client = await prepareClient(deps);
|
|
1028
1079
|
if (!client)
|
|
1029
1080
|
return; // could not provision — fall back (prepareClient printed why)
|
|
1030
1081
|
const intervalMs = opts.intervalMs ?? envInt('MX_COORD_PRIORITY_POLL_MS', 15_000);
|
|
@@ -1117,7 +1168,7 @@ export async function runRespond(opts, deps) {
|
|
|
1117
1168
|
console.error('Note: "open" and "acked" are set automatically by the system.');
|
|
1118
1169
|
process.exit(1);
|
|
1119
1170
|
}
|
|
1120
|
-
const client = prepareClient(deps);
|
|
1171
|
+
const client = await prepareClient(deps);
|
|
1121
1172
|
if (!client)
|
|
1122
1173
|
return;
|
|
1123
1174
|
try {
|
|
@@ -1146,7 +1197,7 @@ export async function runObligations(deps) {
|
|
|
1146
1197
|
memoryModeQueueOnlyNote('obligations');
|
|
1147
1198
|
return;
|
|
1148
1199
|
}
|
|
1149
|
-
const client = prepareClient(deps);
|
|
1200
|
+
const client = await prepareClient(deps);
|
|
1150
1201
|
if (!client)
|
|
1151
1202
|
return;
|
|
1152
1203
|
try {
|
|
@@ -1189,7 +1240,7 @@ export async function runAck(messageId, deps) {
|
|
|
1189
1240
|
memoryModeQueueOnlyNote('ack');
|
|
1190
1241
|
return; // exit 0 — no crash
|
|
1191
1242
|
}
|
|
1192
|
-
const client = prepareClient(deps);
|
|
1243
|
+
const client = await prepareClient(deps);
|
|
1193
1244
|
if (!client)
|
|
1194
1245
|
return; // could not provision — fall back (prepareClient printed why)
|
|
1195
1246
|
await client.ack(messageId);
|
|
@@ -1272,7 +1323,7 @@ export async function runHistory(opts = {}, deps) {
|
|
|
1272
1323
|
memoryModeQueueOnlyNote('history');
|
|
1273
1324
|
return; // exit 0 — no crash
|
|
1274
1325
|
}
|
|
1275
|
-
const client = prepareClient(deps);
|
|
1326
|
+
const client = await prepareClient(deps);
|
|
1276
1327
|
if (!client)
|
|
1277
1328
|
return; // could not provision — fall back (prepareClient printed why)
|
|
1278
1329
|
const collected = [];
|
|
@@ -1460,9 +1511,20 @@ function howToGetMore(s) {
|
|
|
1460
1511
|
return 'Re-run with --all to follow the pagination cursor through the full archive.';
|
|
1461
1512
|
return 'Re-run to page further.';
|
|
1462
1513
|
}
|
|
1463
|
-
// ── status (
|
|
1514
|
+
// ── status (diagnostics; asks the live service when a bearer resolves) ──
|
|
1464
1515
|
/**
|
|
1465
|
-
* Load the offline roster for a project from the generated roster file
|
|
1516
|
+
* Load the offline roster for a project from the generated roster file at
|
|
1517
|
+
* `findProjectRoot()`.
|
|
1518
|
+
*
|
|
1519
|
+
* This reads a WORKING TREE, and `findProjectRoot` skips linked worktrees
|
|
1520
|
+
* (`worktree.ts:26-33`), so in a worktree it resolves to the shared main
|
|
1521
|
+
* checkout. That checkout is nobody's job to keep current and was measured 24
|
|
1522
|
+
* commits behind origin/main on 2026-09-02. `status` no longer uses this for
|
|
1523
|
+
* the registration question (#376); `resolveRegistration` does, and it prefers
|
|
1524
|
+
* the live service and states the provenance of every offline answer. The one
|
|
1525
|
+
* remaining caller is `runEscalate`, which uses it to name valid targets before
|
|
1526
|
+
* a send, where the service revalidates and refuses an unknown team anyway.
|
|
1527
|
+
*
|
|
1466
1528
|
* Returns an empty array on any failure (missing file, parse error).
|
|
1467
1529
|
*/
|
|
1468
1530
|
function loadOfflineRoster(projectSlug) {
|
|
@@ -1544,10 +1606,395 @@ export function oversizeBodyWarning(body) {
|
|
|
1544
1606
|
`\`mx-agent coordination history\` renders up to ${HISTORY_BODY_MAX_CHARS} chars of it. Put the conclusion in the first ` +
|
|
1545
1607
|
`${MESSAGE_BODY_MAX_CHARS} chars, or split the message (#5188).\n`);
|
|
1546
1608
|
}
|
|
1609
|
+
// ── registration resolution (#376) ───────────────────────────────────
|
|
1610
|
+
/**
|
|
1611
|
+
* The roster file, relative to a project root. Same path `resolveRoster` reads
|
|
1612
|
+
* in coordination-token.ts, and the same one `loadOfflineRoster` reads above.
|
|
1613
|
+
*/
|
|
1614
|
+
const ROSTER_REL_PATH = join('mx-agent-system', 'agent-config', 'coordination-rosters.generated.json');
|
|
1615
|
+
/** Cap on the `git show` used for the origin-ref roster read. */
|
|
1616
|
+
const ORIGIN_ROSTER_TIMEOUT_MS = 5_000;
|
|
1617
|
+
const ORIGIN_ROSTER_MAX_BYTES = 1024 * 1024;
|
|
1618
|
+
/**
|
|
1619
|
+
* Read the roster from `origin/<baseBranch>` through the git object store.
|
|
1620
|
+
*
|
|
1621
|
+
* This is the ref the rest of the tooling deploys from — `syncClaudeConfig`
|
|
1622
|
+
* materialises `.claude/` from the same place (`claude.ts:1170`). Refs and
|
|
1623
|
+
* objects are shared between the main checkout and every linked worktree, so
|
|
1624
|
+
* this answer does not depend on which working tree the command runs in. That is
|
|
1625
|
+
* the whole defect in `loadOfflineRoster`: it reads a working tree, and
|
|
1626
|
+
* `findProjectRoot` resolves that to the shared main checkout, which nobody
|
|
1627
|
+
* keeps current.
|
|
1628
|
+
*
|
|
1629
|
+
* `spawnSync` with an argument array runs no shell. `baseBranch` comes from the
|
|
1630
|
+
* committed project config and is interpolated into the rev exactly as
|
|
1631
|
+
* `lib/claude.ts:1170` and `lib/config-generation.ts:55` already interpolate it.
|
|
1632
|
+
*/
|
|
1633
|
+
export function readOriginRefRoster(cwd, baseBranch, projectSlug) {
|
|
1634
|
+
const ref = `origin/${baseBranch}`;
|
|
1635
|
+
let out;
|
|
1636
|
+
try {
|
|
1637
|
+
out = spawnSync('git', ['show', `${ref}:${ROSTER_REL_PATH}`], {
|
|
1638
|
+
cwd,
|
|
1639
|
+
encoding: 'utf-8',
|
|
1640
|
+
stdio: 'pipe',
|
|
1641
|
+
timeout: ORIGIN_ROSTER_TIMEOUT_MS,
|
|
1642
|
+
maxBuffer: ORIGIN_ROSTER_MAX_BYTES,
|
|
1643
|
+
env: gitChildEnv(),
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
catch (err) {
|
|
1647
|
+
return { teams: null, source: ref, error: `git show failed (${err instanceof Error ? err.name : 'error'})` };
|
|
1648
|
+
}
|
|
1649
|
+
// Three failures, told apart. A missing git binary, a timeout and a killed
|
|
1650
|
+
// process all set `out.error`; only a nonzero exit means git ran and refused.
|
|
1651
|
+
// Reporting the first as "the ref does not hold this file" sends an operator
|
|
1652
|
+
// to look at a ref when the problem is their PATH.
|
|
1653
|
+
if (out.error) {
|
|
1654
|
+
return { teams: null, source: ref, error: `git could not be run (${out.error.name}: ${out.error.message})` };
|
|
1655
|
+
}
|
|
1656
|
+
if (out.status !== 0 || typeof out.stdout !== 'string' || out.stdout === '') {
|
|
1657
|
+
return { teams: null, source: ref, error: `${ref} does not hold ${ROSTER_REL_PATH} (is the remote fetched?)` };
|
|
1658
|
+
}
|
|
1659
|
+
let parsed;
|
|
1660
|
+
try {
|
|
1661
|
+
parsed = JSON.parse(out.stdout);
|
|
1662
|
+
}
|
|
1663
|
+
catch {
|
|
1664
|
+
return { teams: null, source: ref, error: `the roster on ${ref} is not valid JSON` };
|
|
1665
|
+
}
|
|
1666
|
+
const sha = originRefSha(cwd, ref);
|
|
1667
|
+
const source = `offline roster from ${ROSTER_REL_PATH} at ${ref}${sha ? ` (${sha})` : ''}`;
|
|
1668
|
+
const teams = parsed.projects?.[projectSlug];
|
|
1669
|
+
return { teams: Array.isArray(teams) ? teams : [], source };
|
|
1670
|
+
}
|
|
1671
|
+
/** Short sha for a ref, or undefined. Advisory: it makes staleness checkable. */
|
|
1672
|
+
function originRefSha(cwd, ref) {
|
|
1673
|
+
try {
|
|
1674
|
+
const r = spawnSync('git', ['rev-parse', '--short', ref], {
|
|
1675
|
+
cwd, encoding: 'utf-8', stdio: 'pipe', timeout: ORIGIN_ROSTER_TIMEOUT_MS, env: gitChildEnv(),
|
|
1676
|
+
});
|
|
1677
|
+
if (r.status !== 0 || typeof r.stdout !== 'string')
|
|
1678
|
+
return undefined;
|
|
1679
|
+
const sha = r.stdout.trim();
|
|
1680
|
+
return sha === '' ? undefined : sha;
|
|
1681
|
+
}
|
|
1682
|
+
catch {
|
|
1683
|
+
return undefined;
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
/**
|
|
1687
|
+
* The environment for the git children this file spawns, with every coordination
|
|
1688
|
+
* bearer removed.
|
|
1689
|
+
*
|
|
1690
|
+
* `resolveClientConfig` reads a token from `process.env.MX_COORD_SERVICE_TOKEN`
|
|
1691
|
+
* (`coordination-client.ts:432`), so that variable can hold a live bearer, and a
|
|
1692
|
+
* spawned child inherits the whole environment by default. `prepareClient`'s own
|
|
1693
|
+
* doc comment (above, on this file) named this exact future: the env write "was
|
|
1694
|
+
* harmless while nothing on these paths spawned a child ... a bearer in the
|
|
1695
|
+
* environment is inherited by any subprocess a future change adds." This is that
|
|
1696
|
+
* change — `status` is the first coordination path to spawn one.
|
|
1697
|
+
*
|
|
1698
|
+
* No exfiltration path was found for these two calls: `git show` and
|
|
1699
|
+
* `git rev-parse` against a local object store invoke no hook, no pager and no
|
|
1700
|
+
* credential helper. The control is nonetheless absent rather than unnecessary,
|
|
1701
|
+
* and a later reader adding a third git call should inherit the stripped env by
|
|
1702
|
+
* default rather than rediscover the reasoning.
|
|
1703
|
+
*/
|
|
1704
|
+
export function gitChildEnv() {
|
|
1705
|
+
const env = { ...process.env };
|
|
1706
|
+
delete env.MX_COORD_SERVICE_TOKEN;
|
|
1707
|
+
delete env.MX_COORD_ADMIN_TOKEN;
|
|
1708
|
+
delete env.MX_API_KEY;
|
|
1709
|
+
return env;
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Read the roster from a working-tree file, stating the path and its mtime.
|
|
1713
|
+
*
|
|
1714
|
+
* Every answer from here is `could-not-verify` at the caller, whatever the file
|
|
1715
|
+
* says. A working tree's age is not knowable from inside it, so a yes from this
|
|
1716
|
+
* source is exactly as unverified as a no.
|
|
1717
|
+
*/
|
|
1718
|
+
export function readWorkingTreeRoster(path, projectSlug) {
|
|
1719
|
+
if (!existsSync(path))
|
|
1720
|
+
return { teams: null, source: path, error: `no roster file at ${path}` };
|
|
1721
|
+
let mtime = 'unknown mtime';
|
|
1722
|
+
try {
|
|
1723
|
+
mtime = statSync(path).mtime.toISOString();
|
|
1724
|
+
}
|
|
1725
|
+
catch {
|
|
1726
|
+
/* the read below is what matters; an unstattable file still reports its path */
|
|
1727
|
+
}
|
|
1728
|
+
const source = `offline roster from ${path} at mtime ${mtime}`;
|
|
1729
|
+
try {
|
|
1730
|
+
const parsed = JSON.parse(readFileSync(path, 'utf-8'));
|
|
1731
|
+
const teams = parsed.projects?.[projectSlug];
|
|
1732
|
+
return { teams: Array.isArray(teams) ? teams : [], source };
|
|
1733
|
+
}
|
|
1734
|
+
catch {
|
|
1735
|
+
return { teams: null, source, error: `${path} could not be read or parsed` };
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Whether an offline roster may REFUSE for this project, or may only fail to
|
|
1740
|
+
* confirm.
|
|
1741
|
+
*
|
|
1742
|
+
* For `mx-agent` and `mx-agent-test` the roster file is explicitly not the
|
|
1743
|
+
* registration authority: `coordination-token.ts:865-869` states the service's
|
|
1744
|
+
* grant table authorizes, and that "a local roster file that predates a
|
|
1745
|
+
* registration would refuse a team the service admits". `mx-agent-test` is
|
|
1746
|
+
* stronger still — `coordination-token.ts:133-139` documents that NO OPERATOR
|
|
1747
|
+
* AUTHORISES THE TEST TEAM, because the service auto-enrols it on its first
|
|
1748
|
+
* credential request, so a registration can exist with no roster commit anywhere.
|
|
1749
|
+
*
|
|
1750
|
+
* The window this closes: team provisioned on the service, roster commit still in
|
|
1751
|
+
* an unmerged pull request, no bearer resolves. Refusing there would be #376's own
|
|
1752
|
+
* defect one source deeper — a confident no computed from a file that is not the
|
|
1753
|
+
* authority, wearing an `origin/<base> (<sha>)` provenance string that makes it
|
|
1754
|
+
* look checked.
|
|
1755
|
+
*/
|
|
1756
|
+
function offlineRosterMayRefuse(projectSlug) {
|
|
1757
|
+
return !usesCredentialEndpoint(projectSlug);
|
|
1758
|
+
}
|
|
1759
|
+
/** Say WHICH of the two reasons stopped an offline absence from being a refusal. */
|
|
1760
|
+
function unverifiableAbsenceReason(projectSlug, teamSlugAuthoritative, liveReason) {
|
|
1761
|
+
const why = [];
|
|
1762
|
+
if (!offlineRosterMayRefuse(projectSlug)) {
|
|
1763
|
+
why.push(`on project "${projectSlug}" the coordination service's grant table is the registration authority, not the roster file, and it can hold a team the file does not`);
|
|
1764
|
+
}
|
|
1765
|
+
if (!teamSlugAuthoritative) {
|
|
1766
|
+
why.push('the team name came from the worktree name, not the .mx-coordination-team marker, so it may not be the team slug at all');
|
|
1767
|
+
}
|
|
1768
|
+
return `${why.join('; ')}. The live service was not asked: ${liveReason}`;
|
|
1769
|
+
}
|
|
1547
1770
|
/**
|
|
1548
|
-
*
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1771
|
+
* Resolve the base branch to read the roster from, preferring the worktree's own
|
|
1772
|
+
* committed config over the shared checkout's. Defaults to `main` on any failure:
|
|
1773
|
+
* this is a status line, and it must never throw.
|
|
1774
|
+
*/
|
|
1775
|
+
function resolveBaseBranch(worktreePath) {
|
|
1776
|
+
for (const root of [worktreePath, safeProjectRoot()]) {
|
|
1777
|
+
if (!root)
|
|
1778
|
+
continue;
|
|
1779
|
+
try {
|
|
1780
|
+
const branch = loadProjectConfig(root)?.baseBranch;
|
|
1781
|
+
if (branch)
|
|
1782
|
+
return branch;
|
|
1783
|
+
}
|
|
1784
|
+
catch {
|
|
1785
|
+
/* an unreadable or refused config is not a base branch; try the next root */
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
return 'main';
|
|
1789
|
+
}
|
|
1790
|
+
function safeProjectRoot() {
|
|
1791
|
+
try {
|
|
1792
|
+
return findProjectRoot();
|
|
1793
|
+
}
|
|
1794
|
+
catch {
|
|
1795
|
+
return undefined;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Answer "is this team on the coordination queue?" and say who answered.
|
|
1800
|
+
*
|
|
1801
|
+
* Order, and the reason for it: the live service is the only authority that is
|
|
1802
|
+
* never stale, so it is asked first whenever a credential resolves. The offline
|
|
1803
|
+
* roster is a fallback, and a fallback that cannot say how old it is must not be
|
|
1804
|
+
* allowed to print a refusal.
|
|
1805
|
+
*
|
|
1806
|
+
* A refusal therefore needs THREE things to be true, not one. The answer must be
|
|
1807
|
+
* a no; the source must be entitled to refuse for this project
|
|
1808
|
+
* (`offlineRosterMayRefuse` — on `mx-agent` and `mx-agent-test` no offline source
|
|
1809
|
+
* ever is, because the service's grant table is the authority and auto-enrolment
|
|
1810
|
+
* can register a team with no roster commit anywhere); and the name asked about
|
|
1811
|
+
* must be the marker's, not the worktree's. Any other combination is
|
|
1812
|
+
* could-not-verify, which is why that outcome exists.
|
|
1813
|
+
*
|
|
1814
|
+
* The live probe is `GET /obligations`. It is the cheapest existing authenticated
|
|
1815
|
+
* read: it mutates nothing, it leases nothing (unlike `/drain`, which is what
|
|
1816
|
+
* `brief` calls and which hands back a batch to confirm), and it returns
|
|
1817
|
+
* obligation metadata with no message bodies, so a self-check never pulls
|
|
1818
|
+
* coordination content into the process. A 200 proves the service authenticated
|
|
1819
|
+
* this team's bearer and resolved it to a (project, team), which is the
|
|
1820
|
+
* registration question exactly. No new endpoint is added.
|
|
1821
|
+
*
|
|
1822
|
+
* Never throws.
|
|
1823
|
+
*/
|
|
1824
|
+
export async function resolveRegistration(projectSlug, teamSlug, deps = {}) {
|
|
1825
|
+
const env = deps.env ?? process.env;
|
|
1826
|
+
const worktreePath = env.CLAUDE_WORKTREE_PATH;
|
|
1827
|
+
const teamSlugAuthoritative = deps.teamSlugAuthoritative ?? true;
|
|
1828
|
+
// 1. Live path. An injected client is probed directly; otherwise a credential
|
|
1829
|
+
// must resolve first.
|
|
1830
|
+
let client = deps.client ?? null;
|
|
1831
|
+
let credentialResolved = client !== null;
|
|
1832
|
+
let liveReason = 'no live check was attempted';
|
|
1833
|
+
if (!client) {
|
|
1834
|
+
let res;
|
|
1835
|
+
try {
|
|
1836
|
+
res = deps.resolveToken ? await deps.resolveToken() : await resolveCoordinationToken();
|
|
1837
|
+
}
|
|
1838
|
+
catch (err) {
|
|
1839
|
+
res = { status: 'unavailable', detail: `token resolution threw (${err instanceof Error ? err.name : 'error'})` };
|
|
1840
|
+
}
|
|
1841
|
+
// A 409 from the credential endpoint is the SERVICE saying this team is not
|
|
1842
|
+
// registered. That is a live no, and it is the one `not-on-roster` that is.
|
|
1843
|
+
// On a project that does not use the credential endpoint the same status
|
|
1844
|
+
// comes from the offline roster gate in resolveIdentity, which is a file and
|
|
1845
|
+
// must not print a refusal — so the source of the status decides, not its name.
|
|
1846
|
+
if (res.status === 'not-on-roster' && usesCredentialEndpoint(projectSlug)) {
|
|
1847
|
+
return {
|
|
1848
|
+
verdict: 'not-registered',
|
|
1849
|
+
kind: 'live',
|
|
1850
|
+
source: 'the live coordination service (credential endpoint answered: team not registered)',
|
|
1851
|
+
credentialResolved: false,
|
|
1852
|
+
};
|
|
1853
|
+
}
|
|
1854
|
+
if ((res.status === 'resolved' || res.status === 'already-configured') && res.token) {
|
|
1855
|
+
credentialResolved = true;
|
|
1856
|
+
// Build the client here rather than through `prepareClient`.
|
|
1857
|
+
//
|
|
1858
|
+
// `prepareClient` reports its own failures on stderr, including the fixed
|
|
1859
|
+
// line `coordination: team "<slug>" is not registered on the coordination
|
|
1860
|
+
// queue.` and, on its final else, `falling back to the manual channel`
|
|
1861
|
+
// (this file, the catch chain in prepareClient). Both bypass the verdict
|
|
1862
|
+
// machinery, so `status` could print `unverified` on stdout while stderr
|
|
1863
|
+
// asserted a refusal, and a diagnostic would be announcing a session
|
|
1864
|
+
// fallback it is not performing. Building here keeps ONE voice: this
|
|
1865
|
+
// function's return value.
|
|
1866
|
+
//
|
|
1867
|
+
// The 401 recovery is preserved verbatim — same wrapper, same rebuild, same
|
|
1868
|
+
// refresh — so a rotated bearer is still retried rather than reported as a
|
|
1869
|
+
// missing team. The bearer is passed through ClientConfig only: never the
|
|
1870
|
+
// process env, never the global config (SF-2 of the #5188/#5189 review).
|
|
1871
|
+
try {
|
|
1872
|
+
const cfg = resolveClientConfig({ token: res.token });
|
|
1873
|
+
client = withTokenRefresh(new HttpCoordinationClient(cfg), (token) => new HttpCoordinationClient({ ...cfg, token }), refreshCoordinationToken, cfg.token);
|
|
1874
|
+
}
|
|
1875
|
+
catch (err) {
|
|
1876
|
+
// The only throw here is resolveClientConfig's: no service URL, or a URL
|
|
1877
|
+
// that fails the suffix gate. Both are configuration, not registration.
|
|
1878
|
+
client = null;
|
|
1879
|
+
liveReason = `a bearer resolved but no coordination client could be built (${err instanceof Error ? err.message : 'configuration error'})`;
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
else {
|
|
1883
|
+
liveReason = `no coordination credential resolved (${res.status}${res.detail ? `: ${res.detail}` : ''})`;
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
// 2. Probe.
|
|
1887
|
+
if (client) {
|
|
1888
|
+
try {
|
|
1889
|
+
await client.getObligations();
|
|
1890
|
+
return {
|
|
1891
|
+
verdict: 'registered',
|
|
1892
|
+
kind: 'live',
|
|
1893
|
+
source: 'the live coordination service (GET /obligations answered for this team)',
|
|
1894
|
+
credentialResolved,
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
catch (err) {
|
|
1898
|
+
if (err instanceof ServiceHttpError && err.status === 409) {
|
|
1899
|
+
return {
|
|
1900
|
+
verdict: 'not-registered',
|
|
1901
|
+
kind: 'live',
|
|
1902
|
+
source: 'the live coordination service (GET /obligations answered: team not registered)',
|
|
1903
|
+
credentialResolved,
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
// Everything else is could-not-verify, and 403 deliberately so: the service
|
|
1907
|
+
// returns a byte-identical 403 whether the team exists or not
|
|
1908
|
+
// (coordination-token.ts:418-419), so it is not evidence either way.
|
|
1909
|
+
liveReason = describeLiveFailure(err);
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
// 3. Offline fallback, in provenance order: the deploy ref first, a working
|
|
1913
|
+
// tree only if the ref cannot be read.
|
|
1914
|
+
const baseBranch = resolveBaseBranch(worktreePath);
|
|
1915
|
+
const gitCwd = worktreePath ?? safeProjectRoot();
|
|
1916
|
+
if (gitCwd) {
|
|
1917
|
+
const readOrigin = deps.readOriginRoster ?? readOriginRefRoster;
|
|
1918
|
+
const fromRef = readOrigin(gitCwd, baseBranch, projectSlug);
|
|
1919
|
+
if (fromRef.teams !== null) {
|
|
1920
|
+
if (fromRef.teams.includes(teamSlug)) {
|
|
1921
|
+
return {
|
|
1922
|
+
verdict: 'registered',
|
|
1923
|
+
kind: 'origin-ref',
|
|
1924
|
+
source: fromRef.source,
|
|
1925
|
+
reason: `the live service was not asked: ${liveReason}`,
|
|
1926
|
+
credentialResolved,
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
// An absence on the ref is only a refusal where the file is the authority
|
|
1930
|
+
// and the name asked about is the real one. Neither holds for a
|
|
1931
|
+
// credential-endpoint project, and the second does not hold when the team
|
|
1932
|
+
// name came from the worktree name.
|
|
1933
|
+
if (offlineRosterMayRefuse(projectSlug) && teamSlugAuthoritative) {
|
|
1934
|
+
return {
|
|
1935
|
+
verdict: 'not-registered',
|
|
1936
|
+
kind: 'origin-ref',
|
|
1937
|
+
source: fromRef.source,
|
|
1938
|
+
reason: `the live service was not asked: ${liveReason}`,
|
|
1939
|
+
credentialResolved,
|
|
1940
|
+
};
|
|
1941
|
+
}
|
|
1942
|
+
return {
|
|
1943
|
+
verdict: 'could-not-verify',
|
|
1944
|
+
kind: 'origin-ref',
|
|
1945
|
+
source: `${fromRef.source} (does not list this team)`,
|
|
1946
|
+
reason: unverifiableAbsenceReason(projectSlug, teamSlugAuthoritative, liveReason),
|
|
1947
|
+
credentialResolved,
|
|
1948
|
+
};
|
|
1949
|
+
}
|
|
1950
|
+
liveReason = `${liveReason}; ${fromRef.error ?? 'the deploy ref could not be read'}`;
|
|
1951
|
+
}
|
|
1952
|
+
else {
|
|
1953
|
+
liveReason = `${liveReason}; no worktree or project root to read a git ref from`;
|
|
1954
|
+
}
|
|
1955
|
+
// 4. A working-tree file. Whatever it says, the verdict is could-not-verify.
|
|
1956
|
+
const filePath = join(gitCwd ?? '', ROSTER_REL_PATH);
|
|
1957
|
+
const readFile = deps.readFileRoster ?? readWorkingTreeRoster;
|
|
1958
|
+
const fromFile = gitCwd ? readFile(filePath, projectSlug) : { teams: null, source: 'no roster file', error: 'no project root' };
|
|
1959
|
+
const said = fromFile.teams === null
|
|
1960
|
+
? 'could not be read'
|
|
1961
|
+
: fromFile.teams.includes(teamSlug) ? 'lists this team' : 'does not list this team';
|
|
1962
|
+
return {
|
|
1963
|
+
verdict: 'could-not-verify',
|
|
1964
|
+
kind: fromFile.teams === null ? 'none' : 'offline-file',
|
|
1965
|
+
source: `${fromFile.source} (${said})`,
|
|
1966
|
+
reason: liveReason,
|
|
1967
|
+
credentialResolved,
|
|
1968
|
+
};
|
|
1969
|
+
}
|
|
1970
|
+
/** Classify a live-probe failure into an operator line. Never includes a bearer. */
|
|
1971
|
+
function describeLiveFailure(err) {
|
|
1972
|
+
if (err instanceof ServiceUnreachableError)
|
|
1973
|
+
return 'the coordination service was unreachable';
|
|
1974
|
+
if (err instanceof CoordinationAuthError)
|
|
1975
|
+
return 'the coordination service refused this bearer (401) after a refresh';
|
|
1976
|
+
if (err instanceof ServiceHttpError) {
|
|
1977
|
+
if (err.status === 401)
|
|
1978
|
+
return 'the coordination service refused this bearer (401)';
|
|
1979
|
+
if (err.status === 403)
|
|
1980
|
+
return 'the coordination service answered 403, which is identical for a registered and an unregistered team';
|
|
1981
|
+
if (err.status === 404)
|
|
1982
|
+
return 'the coordination service has no /obligations route (service older than v2.55)';
|
|
1983
|
+
return `the coordination service answered HTTP ${err.status}`;
|
|
1984
|
+
}
|
|
1985
|
+
return `the live check failed (${err instanceof Error ? err.name : 'error'})`;
|
|
1986
|
+
}
|
|
1987
|
+
/**
|
|
1988
|
+
* `mx-agent coordination status` — display coordination state, service health,
|
|
1989
|
+
* and whether this team is on the queue. Designed for debugging "am I on the
|
|
1990
|
+
* queue?" questions (PO P1 request, issue #4142).
|
|
1991
|
+
*
|
|
1992
|
+
* Authentication is OPTIONAL, not absent (#376). When a bearer resolves, the
|
|
1993
|
+
* registration question is put to the live service, which is the only authority
|
|
1994
|
+
* that cannot be stale. When none resolves, the check falls back to the roster
|
|
1995
|
+
* on the deploy ref and then to a working-tree file, and it says which one
|
|
1996
|
+
* answered. Every path is crash-proof and every path terminates: a diagnostic
|
|
1997
|
+
* that hangs or throws is worse than one that says it could not tell.
|
|
1551
1998
|
*/
|
|
1552
1999
|
export async function runStatus(deps) {
|
|
1553
2000
|
// 1. Resolve project slug.
|
|
@@ -1556,6 +2003,11 @@ export async function runStatus(deps) {
|
|
|
1556
2003
|
const worktreePath = process.env.CLAUDE_WORKTREE_PATH;
|
|
1557
2004
|
let teamSlug = 'not set';
|
|
1558
2005
|
let teamSource = '';
|
|
2006
|
+
// The marker is the authoritative team identity. Track whether it supplied the
|
|
2007
|
+
// name, because an offline roster lookup of a NON-authoritative name answers
|
|
2008
|
+
// about the wrong string: this box runs worktree `bootstrap-20260821` for team
|
|
2009
|
+
// `bootstrap`, and no roster will ever list the former.
|
|
2010
|
+
let teamSlugAuthoritative = false;
|
|
1559
2011
|
if (worktreePath) {
|
|
1560
2012
|
const markerPath = join(worktreePath, '.mx-coordination-team');
|
|
1561
2013
|
try {
|
|
@@ -1564,6 +2016,7 @@ export async function runStatus(deps) {
|
|
|
1564
2016
|
if (raw) {
|
|
1565
2017
|
teamSlug = raw;
|
|
1566
2018
|
teamSource = '';
|
|
2019
|
+
teamSlugAuthoritative = true;
|
|
1567
2020
|
}
|
|
1568
2021
|
}
|
|
1569
2022
|
}
|
|
@@ -1614,11 +2067,21 @@ export async function runStatus(deps) {
|
|
|
1614
2067
|
}
|
|
1615
2068
|
}
|
|
1616
2069
|
}
|
|
1617
|
-
// 7.
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
//
|
|
1621
|
-
|
|
2070
|
+
// 7. Answer the registration question, preferring the live service (#376).
|
|
2071
|
+
// The old check read the generated roster through findProjectRoot(), which
|
|
2072
|
+
// walks past a linked worktree to the shared main checkout. That checkout is
|
|
2073
|
+
// nobody's responsibility to keep current, so a team the service had already
|
|
2074
|
+
// registered read as absent and `status` printed a refusal.
|
|
2075
|
+
const registration = await resolveRegistration(projectSlug, teamSlug, {
|
|
2076
|
+
teamSlugAuthoritative,
|
|
2077
|
+
...deps?.registration,
|
|
2078
|
+
});
|
|
2079
|
+
// 8. Determine overall status. A registered verdict from the live service
|
|
2080
|
+
// already proves a bearer worked, so the cache FILE is not required on that
|
|
2081
|
+
// path; it remains the signal on the offline one.
|
|
2082
|
+
const isReady = registration.verdict === 'registered' &&
|
|
2083
|
+
serviceHealth === 'up' &&
|
|
2084
|
+
(registration.credentialResolved || tokenCached);
|
|
1622
2085
|
// 9. Print the summary.
|
|
1623
2086
|
console.log('Coordination Queue Status');
|
|
1624
2087
|
console.log('─'.repeat(25));
|
|
@@ -1628,6 +2091,7 @@ export async function runStatus(deps) {
|
|
|
1628
2091
|
console.log(` Token cached: ${tokenCached ? 'yes' : 'no'}`);
|
|
1629
2092
|
console.log(` Service URL: ${serviceUrl ?? 'not configured'}`);
|
|
1630
2093
|
console.log(` Service health: ${serviceHealth}`);
|
|
2094
|
+
console.log(` Registered: ${registrationLine(registration)}`);
|
|
1631
2095
|
if (isReady) {
|
|
1632
2096
|
console.log(' Status: ✓ Ready — this team can send and receive coordination messages');
|
|
1633
2097
|
console.log('');
|
|
@@ -1636,7 +2100,7 @@ export async function runStatus(deps) {
|
|
|
1636
2100
|
console.log(' mx-agent coordination brief');
|
|
1637
2101
|
console.log(' mx-agent coordination drain');
|
|
1638
2102
|
}
|
|
1639
|
-
else {
|
|
2103
|
+
else if (registration.verdict === 'not-registered') {
|
|
1640
2104
|
console.log(' Status: ✗ Not registered — this team is not on the coordination queue');
|
|
1641
2105
|
console.log('');
|
|
1642
2106
|
console.log(' To register:');
|
|
@@ -1645,6 +2109,36 @@ export async function runStatus(deps) {
|
|
|
1645
2109
|
console.log(' If setup fails (503), ask your project admin to provision your team,');
|
|
1646
2110
|
console.log(' or set MX_COORD_ADMIN_TOKEN and retry.');
|
|
1647
2111
|
}
|
|
2112
|
+
else if (registration.verdict === 'could-not-verify') {
|
|
2113
|
+
console.log(` Status: ? Could not verify — ${registration.reason ?? 'the live service did not answer'}`);
|
|
2114
|
+
console.log('');
|
|
2115
|
+
console.log(' This is not a refusal. The queue may hold this team; nothing here could');
|
|
2116
|
+
console.log(' confirm it. To get a live answer:');
|
|
2117
|
+
console.log(' mx-agent coordination brief # drains this team\'s own inbox');
|
|
2118
|
+
console.log(' mx-agent coordination setup # registers the team if it is absent');
|
|
2119
|
+
}
|
|
2120
|
+
else {
|
|
2121
|
+
// Registered, but something else is missing. Name what, rather than printing
|
|
2122
|
+
// a refusal for a team the check just confirmed (#376).
|
|
2123
|
+
const missing = [];
|
|
2124
|
+
if (serviceHealth !== 'up')
|
|
2125
|
+
missing.push(`service health is "${serviceHealth}"`);
|
|
2126
|
+
if (!registration.credentialResolved && !tokenCached)
|
|
2127
|
+
missing.push('no coordination token is cached or resolvable');
|
|
2128
|
+
console.log(` Status: ✓ Registered, not ready — ${missing.join('; ')}`);
|
|
2129
|
+
console.log('');
|
|
2130
|
+
console.log(' The team is on the queue. Fix the item named above, then re-run this check.');
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
/**
|
|
2134
|
+
* The one line that says what the verdict is and who produced it (#344, #376).
|
|
2135
|
+
*
|
|
2136
|
+
* Verdict and source only. The `reason` is what the Status line below carries,
|
|
2137
|
+
* and printing it twice pushed the short answer off the top of the screen.
|
|
2138
|
+
*/
|
|
2139
|
+
export function registrationLine(r) {
|
|
2140
|
+
const verdict = r.verdict === 'registered' ? 'yes' : r.verdict === 'not-registered' ? 'no' : 'unverified';
|
|
2141
|
+
return `${verdict} (source: ${r.source})`;
|
|
1648
2142
|
}
|
|
1649
2143
|
/**
|
|
1650
2144
|
* A team file is RETIRED (a tombstone, not a live team) when its first non-empty
|