@chankov/agent-fleet 1.0.4 → 2.0.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/.pi/harnesses/agent-hub/README.md +57 -66
- package/.pi/harnesses/agent-hub/capability-packs.ts +4 -4
- package/.pi/harnesses/agent-hub/commands/agent-model-thinking.ts +10 -0
- package/.pi/harnesses/agent-hub/commands/agent-model.ts +10 -0
- package/.pi/harnesses/agent-hub/commands/agent-models-substitute.ts +10 -0
- package/.pi/harnesses/agent-hub/commands/agents-add.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/agents-drop.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/agents-history.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/agents-kill.ts +10 -0
- package/.pi/harnesses/agent-hub/commands/agents-list.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/agents-restart.ts +10 -0
- package/.pi/harnesses/agent-hub/commands/agents-save.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/agents-team.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/compound.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/coms.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/context-command.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/context.ts +39 -0
- package/.pi/harnesses/agent-hub/commands/dispatch-policy.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/handoff.ts +10 -0
- package/.pi/harnesses/agent-hub/commands/hub-report.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/models.ts +10 -0
- package/.pi/harnesses/agent-hub/commands/watchdog.ts +9 -0
- package/.pi/harnesses/agent-hub/commands/work-mode.ts +29 -0
- package/.pi/harnesses/agent-hub/commands/zoom.ts +10 -0
- package/.pi/harnesses/agent-hub/config/agents.ts +171 -0
- package/.pi/harnesses/agent-hub/config/overrides.ts +118 -0
- package/.pi/harnesses/agent-hub/context/agent-state.ts +30 -0
- package/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +211 -0
- package/.pi/harnesses/agent-hub/context/budgets.ts +208 -0
- package/.pi/harnesses/agent-hub/context/hub-state.ts +40 -0
- package/.pi/harnesses/agent-hub/dispatch-coms.ts +232 -0
- package/.pi/harnesses/agent-hub/dispatch-core.ts +27 -0
- package/.pi/harnesses/agent-hub/dispatch-native-complete.ts +135 -0
- package/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +153 -0
- package/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +191 -0
- package/.pi/harnesses/agent-hub/dispatch-native-types.ts +207 -0
- package/.pi/harnesses/agent-hub/dispatch-native.ts +184 -0
- package/.pi/harnesses/agent-hub/dispatch-observability.ts +220 -0
- package/.pi/harnesses/agent-hub/drift-watchdog.js +3 -3
- package/.pi/harnesses/agent-hub/footer.ts +3 -9
- package/.pi/harnesses/agent-hub/helpers.ts +2 -2
- package/.pi/harnesses/agent-hub/index.ts +1324 -9645
- package/.pi/harnesses/agent-hub/input/completions.ts +76 -0
- package/.pi/harnesses/agent-hub/input/shortcuts.ts +47 -0
- package/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +123 -0
- package/.pi/harnesses/agent-hub/lifecycle/monitor-session.ts +104 -0
- package/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +139 -0
- package/.pi/harnesses/agent-hub/lifecycle/turn-handlers.ts +95 -0
- package/.pi/harnesses/agent-hub/package.json +1 -1
- package/.pi/harnesses/agent-hub/policy/models.ts +126 -0
- package/.pi/harnesses/agent-hub/policy/roster.ts +79 -0
- package/.pi/harnesses/agent-hub/policy/work-mode.ts +118 -0
- package/.pi/harnesses/agent-hub/presentation.ts +48 -0
- package/.pi/harnesses/agent-hub/prompts/context.ts +46 -0
- package/.pi/harnesses/agent-hub/prompts/fragments.ts +115 -0
- package/.pi/harnesses/agent-hub/prompts/session-start.ts +88 -0
- package/.pi/harnesses/agent-hub/prompts/system-prompt.ts +110 -0
- package/.pi/harnesses/agent-hub/research/controls.ts +75 -0
- package/.pi/harnesses/agent-hub/research/runtime.ts +184 -0
- package/.pi/harnesses/agent-hub/research/spawn-run.ts +146 -0
- package/.pi/harnesses/agent-hub/session-start.ts +42 -0
- package/.pi/harnesses/agent-hub/timeline.ts +54 -0
- package/.pi/harnesses/agent-hub/tools/action-executors.ts +146 -0
- package/.pi/harnesses/agent-hub/tools/coms-tools.ts +139 -0
- package/.pi/harnesses/agent-hub/tools/context.ts +132 -0
- package/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +79 -0
- package/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +200 -0
- package/.pi/harnesses/agent-hub/tools/execution-orchestration.ts +22 -0
- package/.pi/harnesses/agent-hub/tools/fleet-tools.ts +202 -0
- package/.pi/harnesses/agent-hub/tools/herdr-executors.ts +82 -0
- package/.pi/harnesses/agent-hub/tools/set-task-tier.ts +29 -0
- package/.pi/harnesses/agent-hub/tools/spawn-research.ts +62 -0
- package/.pi/harnesses/agent-hub/tools/team-adjust.ts +29 -0
- package/.pi/harnesses/agent-hub/tools/verification-contract.ts +77 -0
- package/.pi/harnesses/agent-hub/types.ts +60 -0
- package/.pi/harnesses/agent-hub/ui/context-budget.ts +86 -0
- package/.pi/harnesses/agent-hub/ui/detail-panel.ts +175 -0
- package/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +130 -0
- package/.pi/harnesses/agent-hub/ui/grid.ts +306 -0
- package/.pi/harnesses/agent-hub/ui/history-store.ts +137 -0
- package/.pi/harnesses/agent-hub/ui/history.ts +234 -0
- package/.pi/harnesses/agent-hub/ui/pool.ts +103 -0
- package/.pi/harnesses/agent-hub/ui/zoom.ts +204 -0
- package/.pi/harnesses/agent-hub/work-mode-controls.ts +56 -0
- package/.pi/harnesses/agent-hub/{posture.ts → work-mode.ts} +36 -27
- package/.pi/harnesses/coms/index.ts +139 -1630
- package/.pi/harnesses/coms/package.json +1 -1
- package/.pi/harnesses/damage-control-continue/package.json +1 -1
- package/.pi/harnesses/lib/coms-core-io.ts +385 -0
- package/.pi/harnesses/lib/coms-core.ts +577 -0
- package/.pi/harnesses/lib/context-budget-hub-prompt.ts +3 -5
- package/.versions/2.0.0/.pi/agents/dispatch-policy.yaml +32 -0
- package/.versions/2.0.0/.pi/agents/model-profiles.yaml +27 -0
- package/.versions/2.0.0/.pi/agents/peers.yaml +142 -0
- package/.versions/2.0.0/.pi/agents/teams.yaml +41 -0
- package/.versions/2.0.0/.pi/damage-control-rules.yaml +297 -0
- package/.versions/2.0.0/.pi/extensions/agent-fleet-update-check/README.md +57 -0
- package/.versions/2.0.0/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
- package/.versions/2.0.0/.pi/extensions/agent-fleet-update-check/package.json +6 -0
- package/.versions/2.0.0/.pi/extensions/btw/README.md +120 -0
- package/.versions/2.0.0/.pi/extensions/btw/index.ts +914 -0
- package/.versions/2.0.0/.pi/extensions/btw/package.json +6 -0
- package/.versions/2.0.0/.pi/extensions/btw/state.js +179 -0
- package/.versions/2.0.0/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
- package/.versions/2.0.0/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
- package/.versions/2.0.0/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.versions/2.0.0/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.versions/2.0.0/.pi/extensions/compact-and-continue/index.ts +120 -0
- package/.versions/2.0.0/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.versions/2.0.0/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.versions/2.0.0/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.versions/2.0.0/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.versions/2.0.0/.pi/extensions/package-lock.json +1175 -0
- package/.versions/2.0.0/.pi/extensions/package.json +9 -0
- package/.versions/2.0.0/.pi/extensions/pi-voice-stt/README.md +205 -0
- package/.versions/2.0.0/.pi/extensions/pi-voice-stt/config.ts +198 -0
- package/.versions/2.0.0/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
- package/.versions/2.0.0/.pi/extensions/pi-voice-stt/index.ts +248 -0
- package/.versions/2.0.0/.pi/extensions/pi-voice-stt/package.json +6 -0
- package/.versions/2.0.0/.pi/extensions/pi-voice-stt/providers.ts +214 -0
- package/.versions/2.0.0/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/README.md +1161 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/access-approval.ts +135 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/artifacts.js +146 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/backend-policy.js +174 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/budget-continuation.ts +73 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/capability-confirmation.ts +47 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/capability-packs.ts +180 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agent-model-thinking.ts +10 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agent-model.ts +10 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agent-models-substitute.ts +10 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-add.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-drop.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-history.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-kill.ts +10 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-list.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-restart.ts +10 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-save.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/agents-team.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/compound.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/coms.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/context-command.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/context.ts +39 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/dispatch-policy.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/handoff.ts +10 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/hub-report.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/models.ts +10 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/watchdog.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/work-mode.ts +29 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/commands/zoom.ts +10 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/config/agents.ts +171 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/config/overrides.ts +118 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/context/agent-state.ts +30 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +211 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/context/budgets.ts +208 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/context/hub-state.ts +40 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/context-budget-snapshot.ts +105 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/context-pressure.ts +191 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/context-window.js +106 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/delegate.ts +446 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-coms.ts +232 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-core.ts +27 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-native-complete.ts +135 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +153 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +191 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-native-types.ts +207 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-native.ts +184 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/dispatch-observability.ts +220 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/docs-lane.js +122 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/drift-watchdog.js +218 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/external-blocker.js +85 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/fixtures/registration-surface.json +53 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/footer.ts +30 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/helpers.ts +266 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/hub-state-audit.js +59 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/index.ts +1850 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/input/completions.ts +76 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/input/shortcuts.ts +47 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +123 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/lifecycle/monitor-session.ts +104 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +139 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/lifecycle/turn-handlers.ts +95 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/package.json +7 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/policy/models.ts +126 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/policy/roster.ts +79 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/policy/work-mode.ts +118 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/presentation.ts +48 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/prompts/context.ts +46 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/prompts/fragments.ts +115 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/prompts/session-start.ts +88 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/prompts/system-prompt.ts +110 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/research/controls.ts +75 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/research/runtime.ts +184 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/research/spawn-run.ts +146 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/research-retention.js +34 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/return-contract.js +293 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/return-extract.js +75 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/review-findings.js +102 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/run-budget.js +537 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/run-namespace.js +87 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/scope-gate.js +103 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/session-health.js +110 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/session-start.ts +42 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/spawn.ts +388 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/timeline.ts +54 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/action-executors.ts +146 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/coms-tools.ts +139 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/context.ts +132 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +79 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +200 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/execution-orchestration.ts +22 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/fleet-tools.ts +202 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/herdr-executors.ts +82 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/set-task-tier.ts +29 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/spawn-research.ts +62 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/team-adjust.ts +29 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/tools/verification-contract.ts +77 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/types.ts +60 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/context-budget.ts +86 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/detail-panel.ts +175 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +130 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/grid.ts +306 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/history-store.ts +137 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/history.ts +234 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/pool.ts +103 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/ui/zoom.ts +204 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/version.ts +42 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/work-mode-controls.ts +56 -0
- package/.versions/2.0.0/.pi/harnesses/agent-hub/work-mode.ts +167 -0
- package/.versions/2.0.0/.pi/harnesses/ask-user-remote/README.md +53 -0
- package/.versions/2.0.0/.pi/harnesses/ask-user-remote/index.ts +532 -0
- package/.versions/2.0.0/.pi/harnesses/ask-user-remote/race-core.js +106 -0
- package/.versions/2.0.0/.pi/harnesses/coms/README.md +100 -0
- package/.versions/2.0.0/.pi/harnesses/coms/index.ts +276 -0
- package/.versions/2.0.0/.pi/harnesses/coms/package.json +7 -0
- package/.versions/2.0.0/.pi/harnesses/coms/version.ts +42 -0
- package/.versions/2.0.0/.pi/harnesses/damage-control-continue/README.md +124 -0
- package/.versions/2.0.0/.pi/harnesses/damage-control-continue/index.ts +536 -0
- package/.versions/2.0.0/.pi/harnesses/damage-control-continue/package.json +7 -0
- package/.versions/2.0.0/.pi/harnesses/damage-control-continue/version.ts +42 -0
- package/.versions/2.0.0/.pi/harnesses/lib/coms-core-io.ts +385 -0
- package/.versions/2.0.0/.pi/harnesses/lib/coms-core.ts +577 -0
- package/.versions/2.0.0/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
- package/.versions/2.0.0/.pi/harnesses/lib/context-budget-child-prompt.ts +179 -0
- package/.versions/2.0.0/.pi/harnesses/lib/context-budget-hub-prompt.ts +114 -0
- package/.versions/2.0.0/.pi/harnesses/lib/context-budget-view.ts +107 -0
- package/.versions/2.0.0/.pi/harnesses/lib/context-budget.ts +114 -0
- package/.versions/2.0.0/.pi/harnesses/lib/damage-control-shared.ts +197 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fixtures/context-budget-profiles.json +11 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fixtures/hub-prompt-operator.legacy.txt +73 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fixtures/hub-prompt-orchestrator.legacy.txt +73 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fleet-dashboard-ops.ts +155 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fleet-dashboard-view.ts +142 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fleet-detail-view.ts +247 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fleet-overlay.ts +26 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fleet-panel.ts +34 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fleet-read-model.ts +131 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fleet-selection.ts +24 -0
- package/.versions/2.0.0/.pi/harnesses/lib/fleet-transcript-store.ts +244 -0
- package/.versions/2.0.0/.pi/harnesses/lib/herdr-client.ts +472 -0
- package/.versions/2.0.0/.pi/harnesses/lib/herdr-presence.ts +399 -0
- package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
- package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
- package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
- package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
- package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
- package/.versions/2.0.0/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
- package/.versions/2.0.0/.pi/harnesses/lib/spawned-peers.js +190 -0
- package/.versions/2.0.0/.pi/harnesses/package-lock.json +2039 -0
- package/.versions/2.0.0/.pi/harnesses/package.json +10 -0
- package/.versions/2.0.0/.pi/prompts/af-build.md +24 -0
- package/.versions/2.0.0/.pi/prompts/af-code-simplify.md +22 -0
- package/.versions/2.0.0/.pi/prompts/af-plan.md +17 -0
- package/.versions/2.0.0/.pi/prompts/af-review.md +16 -0
- package/.versions/2.0.0/.pi/prompts/af-set-hermes-telegram.md +15 -0
- package/.versions/2.0.0/.pi/prompts/af-set-hermes-watchdog.md +6 -0
- package/.versions/2.0.0/.pi/prompts/af-ship.md +17 -0
- package/.versions/2.0.0/.pi/prompts/af-spec.md +15 -0
- package/.versions/2.0.0/.pi/prompts/af-test.md +19 -0
- package/.versions/2.0.0/.pi/skills/bowser/SKILL.md +145 -0
- package/.versions/2.0.0/.version +1 -0
- package/.versions/2.0.0/agents/architect.md +25 -0
- package/.versions/2.0.0/agents/bowser.md +28 -0
- package/.versions/2.0.0/agents/builder.md +56 -0
- package/.versions/2.0.0/agents/code-reviewer.md +209 -0
- package/.versions/2.0.0/agents/deep-researcher.md +33 -0
- package/.versions/2.0.0/agents/documenter.md +19 -0
- package/.versions/2.0.0/agents/orchestrator.md +23 -0
- package/.versions/2.0.0/agents/plan-reviewer.md +84 -0
- package/.versions/2.0.0/agents/planner.md +71 -0
- package/.versions/2.0.0/agents/releaser.md +25 -0
- package/.versions/2.0.0/agents/researcher.md +29 -0
- package/.versions/2.0.0/agents/security-auditor.md +168 -0
- package/.versions/2.0.0/agents/test-engineer.md +154 -0
- package/.versions/2.0.0/agents/web-debugger.md +44 -0
- package/.versions/2.0.0/agents/web-performance-auditor.md +194 -0
- package/.versions/2.0.0/bin/catalog/harness-runtime-closure.json +38 -0
- package/.versions/2.0.0/codex/CONDUCTOR.md +148 -0
- package/.versions/2.0.0/docs/ARCHITECTURE.md +404 -0
- package/.versions/2.0.0/docs/agent-fleet-setup.md +468 -0
- package/.versions/2.0.0/docs/claude-code-coms-bridge.md +128 -0
- package/.versions/2.0.0/docs/codex-remote-conductor.md +170 -0
- package/.versions/2.0.0/docs/coms-hermes-bridge.md +189 -0
- package/.versions/2.0.0/docs/getting-started.md +98 -0
- package/.versions/2.0.0/docs/npm-install.md +292 -0
- package/.versions/2.0.0/docs/pi-extensions.md +439 -0
- package/.versions/2.0.0/docs/pi-setup.md +74 -0
- package/.versions/2.0.0/docs/skill-anatomy.md +150 -0
- package/.versions/2.0.0/hermes/README.md +347 -0
- package/.versions/2.0.0/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
- package/.versions/2.0.0/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
- package/.versions/2.0.0/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
- package/.versions/2.0.0/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
- package/.versions/2.0.0/hermes/gates/gate-o-capability.md +8 -0
- package/.versions/2.0.0/hermes/gates/gate-o-validator-fixtures.json +1 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
- package/.versions/2.0.0/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
- package/.versions/2.0.0/hermes/skills/hub-conductor/SKILL.md +84 -0
- package/.versions/2.0.0/hermes/skills/hub-liaison/SKILL.md +84 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/SKILL.md +76 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/manifest.json +1 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
- package/.versions/2.0.0/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
- package/.versions/2.0.0/hermes/watchdog-tests/__init__.py +0 -0
- package/.versions/2.0.0/hooks/coms-stop-hook.mjs +84 -0
- package/.versions/2.0.0/install-manifest.json +2745 -0
- package/.versions/2.0.0/justfile +272 -0
- package/.versions/2.0.0/manifest-meta.json +882 -0
- package/.versions/2.0.0/references/accessibility-checklist.md +160 -0
- package/.versions/2.0.0/references/definition-of-done.md +67 -0
- package/.versions/2.0.0/references/fleet-coordination-patterns.md +151 -0
- package/.versions/2.0.0/references/observability-checklist.md +91 -0
- package/.versions/2.0.0/references/orchestration-patterns.md +370 -0
- package/.versions/2.0.0/references/performance-checklist.md +153 -0
- package/.versions/2.0.0/references/prompting-patterns.md +380 -0
- package/.versions/2.0.0/references/security-checklist.md +179 -0
- package/.versions/2.0.0/references/testing-patterns.md +236 -0
- package/.versions/2.0.0/scripts/codex-conductor.ts +41 -0
- package/.versions/2.0.0/scripts/codex-remote-control.ts +167 -0
- package/.versions/2.0.0/scripts/coms-claude-bridge.ts +411 -0
- package/.versions/2.0.0/scripts/coms-cli.ts +484 -0
- package/.versions/2.0.0/scripts/coms-hermes-bridge.ts +413 -0
- package/.versions/2.0.0/scripts/fleet.ts +185 -0
- package/.versions/2.0.0/scripts/hermes-monitor-capability-runner.ts +25 -0
- package/.versions/2.0.0/scripts/hermes-monitor-scenario.ts +474 -0
- package/.versions/2.0.0/scripts/hermes-watchdog-capability-probe.ts +45 -0
- package/.versions/2.0.0/scripts/install-hermes-plugin.sh +180 -0
- package/.versions/2.0.0/scripts/lib/claude-bridge-core.ts +210 -0
- package/.versions/2.0.0/scripts/lib/codex-conductor.ts +88 -0
- package/.versions/2.0.0/scripts/lib/codex-remote-control.ts +480 -0
- package/.versions/2.0.0/scripts/lib/coms-envelope.ts +582 -0
- package/.versions/2.0.0/scripts/lib/fake-herdr-server.ts +88 -0
- package/.versions/2.0.0/scripts/lib/fleet-command.ts +270 -0
- package/.versions/2.0.0/scripts/lib/herdr-layout.ts +281 -0
- package/.versions/2.0.0/scripts/lib/hermes-bridge-core.ts +241 -0
- package/.versions/2.0.0/scripts/lib/hermes-monitor-events.ts +1 -0
- package/.versions/2.0.0/scripts/lib/hermes-monitor-herdr.ts +2 -0
- package/.versions/2.0.0/scripts/lib/hermes-monitor-model.ts +3 -0
- package/.versions/2.0.0/scripts/lib/hermes-monitor-registry.ts +2 -0
- package/.versions/2.0.0/scripts/lib/hermes-monitor-socket.ts +2 -0
- package/.versions/2.0.0/scripts/lib/hermes-monitor-store.ts +2 -0
- package/.versions/2.0.0/scripts/lib/monitor-env.ts +146 -0
- package/.versions/2.0.0/scripts/lib/peer-launch.ts +318 -0
- package/.versions/2.0.0/scripts/lib/persona-banner.ts +62 -0
- package/.versions/2.0.0/scripts/lib/spawn-stagger.ts +101 -0
- package/.versions/2.0.0/scripts/lib/team-project.ts +213 -0
- package/.versions/2.0.0/scripts/lib/team-snapshot.ts +147 -0
- package/.versions/2.0.0/scripts/peer-banner.ts +40 -0
- package/.versions/2.0.0/scripts/peer-launch.ts +259 -0
- package/.versions/2.0.0/scripts/team-snapshot.ts +237 -0
- package/.versions/2.0.0/scripts/team-up.ts +406 -0
- package/.versions/2.0.0/skills/_internal/grilling.md +59 -0
- package/.versions/2.0.0/skills/browser-testing-with-devtools/SKILL.md +351 -0
- package/.versions/2.0.0/skills/code-review-and-quality/SKILL.md +381 -0
- package/.versions/2.0.0/skills/compound-learning/SKILL.md +137 -0
- package/.versions/2.0.0/skills/context-engineering/SKILL.md +291 -0
- package/.versions/2.0.0/skills/deprecation-and-migration/SKILL.md +206 -0
- package/.versions/2.0.0/skills/designing-agents/SKILL.md +394 -0
- package/.versions/2.0.0/skills/designing-agents/pi-harness-authoring.md +222 -0
- package/.versions/2.0.0/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/2.0.0/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/.versions/2.0.0/skills/idea-refine/SKILL.md +182 -0
- package/.versions/2.0.0/skills/idea-refine/examples.md +238 -0
- package/.versions/2.0.0/skills/idea-refine/frameworks.md +99 -0
- package/.versions/2.0.0/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/2.0.0/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/2.0.0/skills/incremental-implementation/SKILL.md +298 -0
- package/.versions/2.0.0/skills/interview-me/SKILL.md +226 -0
- package/.versions/2.0.0/skills/orchestration-verification/SKILL.md +181 -0
- package/.versions/2.0.0/skills/peer-coms/SKILL.md +90 -0
- package/.versions/2.0.0/skills/performance-optimization/SKILL.md +350 -0
- package/.versions/2.0.0/skills/planning-and-task-breakdown/SKILL.md +263 -0
- package/.versions/2.0.0/skills/security-and-hardening/SKILL.md +461 -0
- package/.versions/2.0.0/skills/spec-driven-development/SKILL.md +256 -0
- package/.versions/2.0.0/skills/using-agent-skills/SKILL.md +197 -0
- package/.versions/2.0.0/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/LICENSE +21 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/README.md +11 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
- package/.versions/2.0.0/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
- package/CHANGELOG.md +33 -0
- package/README.md +5 -5
- package/agents/orchestrator.md +3 -1
- package/bin/lib/overrides.js +2 -0
- package/bin/lib/validate-overrides.js +1 -1
- package/docs/ARCHITECTURE.md +42 -13
- package/docs/MIGRATION-agent-fleet.md +4 -4
- package/docs/agent-fleet-setup.md +15 -15
- package/docs/npm-install.md +1 -1
- package/docs/pi-extensions.md +16 -18
- package/install-manifest.json +1 -1
- package/justfile +2 -2
- package/package.json +3 -2
- package/scripts/fleet.ts +10 -10
- package/scripts/lib/fleet-command.ts +15 -11
- package/scripts/lib/team-project.ts +2 -2
- package/scripts/team-up.ts +10 -10
- package/.pi/harnesses/agent-hub/execution-profile.ts +0 -69
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// scripts/lib/peer-launch.ts
|
|
2
|
+
//
|
|
3
|
+
// Pure logic for `just fleet peer <name>` — ONE addressable coms peer, in its
|
|
4
|
+
// own herdr pane by default, with no peers.yaml team involved.
|
|
5
|
+
//
|
|
6
|
+
// One verb, three shapes of peer, two placements:
|
|
7
|
+
//
|
|
8
|
+
// runner: claude-code → `just _claude-peer …` (Claude + its coms bridge)
|
|
9
|
+
// runner: pi, persona resolved → `just _peer[-plus] …` (guarded reusable persona peer)
|
|
10
|
+
// runner: pi, no persona → `just _fleet-peer …` (Fleet Core + coms, no persona)
|
|
11
|
+
//
|
|
12
|
+
// default → the command runs in a pane of its own
|
|
13
|
+
// --here → the command takes over the CALLING terminal
|
|
14
|
+
//
|
|
15
|
+
// The third shape is what `just fleet peer <name>` meant before pane placement
|
|
16
|
+
// existed, so `--here` reproduces the old behavior exactly while the same
|
|
17
|
+
// invocation without it now opens a pane.
|
|
18
|
+
//
|
|
19
|
+
// Resolution order for every field: explicit CLI flag → the peers.yaml
|
|
20
|
+
// declaration for that NAME (searched across all teams, see findPeerByName) →
|
|
21
|
+
// a convention default. So `just fleet peer code-reviewer` gets the
|
|
22
|
+
// `runner: claude-code` the fleet declares, and `--runner claude-code` needs no
|
|
23
|
+
// manifest entry at all.
|
|
24
|
+
//
|
|
25
|
+
// No sockets, no process.exit, no fs — callers supply the manifest text and a
|
|
26
|
+
// persona-existence probe, and every failure is a plain Error.
|
|
27
|
+
|
|
28
|
+
import { findPeerByName, parsePeersYaml, peerCommand, type Peer } from "./herdr-layout.ts";
|
|
29
|
+
import { DEFAULT_PROJECT, teamWorkspaceLabel, validateProject } from "./team-project.ts";
|
|
30
|
+
|
|
31
|
+
/** Synthetic team name used in peerCommand errors for a peer that has no team. */
|
|
32
|
+
export const ADHOC_TEAM = "ad-hoc";
|
|
33
|
+
|
|
34
|
+
/** The extension `--browser` adds to a pi persona peer (the `_peer-plus` route). */
|
|
35
|
+
export const BROWSER_EXTENSION = "chrome-devtools-mcp";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Pane label + coms identity charset. Stricter than herdr-layout's SAFE, which
|
|
39
|
+
* also permits `.`, `/` and `,` — fine inside a model spec, wrong for a name
|
|
40
|
+
* that becomes a pane label, a workspace label segment, and a coms address.
|
|
41
|
+
*/
|
|
42
|
+
export const PEER_NAME_SAFE = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
43
|
+
|
|
44
|
+
export type PeerRunner = "pi" | "claude-code";
|
|
45
|
+
/** Which hidden recipe launches this peer — see the header table. */
|
|
46
|
+
export type PeerKind = "persona-peer" | "core-peer" | "claude-peer";
|
|
47
|
+
|
|
48
|
+
export interface PeerLaunchOptions {
|
|
49
|
+
name: string;
|
|
50
|
+
/** --runner; omit to inherit the peers.yaml declaration, else defaults to pi. */
|
|
51
|
+
runner?: string;
|
|
52
|
+
/** --persona; omit to inherit the declaration, else the same-named persona. */
|
|
53
|
+
persona?: string;
|
|
54
|
+
/**
|
|
55
|
+
* --no-persona: force the identity-only Fleet Core peer even when the name
|
|
56
|
+
* resolves to a persona. The escape hatch for raw pi arguments and
|
|
57
|
+
* --all-extensions under a name that happens to match `agents/<name>.md`.
|
|
58
|
+
*/
|
|
59
|
+
noPersona?: boolean;
|
|
60
|
+
model?: string;
|
|
61
|
+
project?: string;
|
|
62
|
+
extensions?: string;
|
|
63
|
+
/** --browser: an extra extension for a persona peer, a capability flag for a core peer. */
|
|
64
|
+
browser?: boolean;
|
|
65
|
+
/** --all-extensions: core peers only — persona peers are deliberately deterministic. */
|
|
66
|
+
allExtensions?: boolean;
|
|
67
|
+
/** Raw pi arguments after `--`; core peers only. */
|
|
68
|
+
piArgs?: string[];
|
|
69
|
+
direction?: "right" | "down";
|
|
70
|
+
/** --here: run in the calling terminal instead of a pane. */
|
|
71
|
+
here?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface PeerLaunchContext {
|
|
75
|
+
/** Raw .pi/agents/peers.yaml, or "" when the repo has none. */
|
|
76
|
+
peersYaml: string;
|
|
77
|
+
/** True when `agents/<persona>.md` or `.pi/agents/<persona>.md` exists. */
|
|
78
|
+
personaExists(persona: string): boolean;
|
|
79
|
+
/** worktreeTag(REPO_ROOT) — scopes the standalone workspace label. */
|
|
80
|
+
worktreeTag: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface PeerLaunchPlan {
|
|
84
|
+
name: string;
|
|
85
|
+
runner: PeerRunner;
|
|
86
|
+
kind: PeerKind;
|
|
87
|
+
persona?: string;
|
|
88
|
+
model?: string;
|
|
89
|
+
extensions?: string;
|
|
90
|
+
/** Repo-relative env_file inherited from the declaration, if any. */
|
|
91
|
+
envFile?: string;
|
|
92
|
+
project: string;
|
|
93
|
+
/** argv for the pane (or for this terminal under --here). */
|
|
94
|
+
command: string[];
|
|
95
|
+
placement: "pane" | "here";
|
|
96
|
+
direction: "right" | "down";
|
|
97
|
+
/** Workspace label used only when launching a pane outside a herdr pane. */
|
|
98
|
+
workspaceLabel: string;
|
|
99
|
+
/** True when peers.yaml declares this name (its fields seeded the plan). */
|
|
100
|
+
declared: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function validateName(name: string): string {
|
|
104
|
+
if (!PEER_NAME_SAFE.test(name)) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Invalid peer name: ${JSON.stringify(name)} (letters, numbers, underscores and hyphens; must start alphanumeric)`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return name;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function normalizeRunner(runner: string | undefined, source: string): PeerRunner | undefined {
|
|
113
|
+
if (runner === undefined) return undefined;
|
|
114
|
+
if (runner === "pi" || runner === "claude-code") return runner;
|
|
115
|
+
throw new Error(`Unknown runner ${JSON.stringify(runner)} from ${source} (supported: pi, claude-code)`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function mergeExtensions(...values: (string | undefined)[]): string | undefined {
|
|
119
|
+
const names = values
|
|
120
|
+
.flatMap((v) => (v ?? "").split(","))
|
|
121
|
+
.map((v) => v.trim())
|
|
122
|
+
.filter((v) => v !== "");
|
|
123
|
+
return names.length > 0 ? [...new Set(names)].join(",") : undefined;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The pre-pane-placement `just fleet peer <name>` command: Fleet Core + coms
|
|
128
|
+
* under the given identity, with no persona and arbitrary pi arguments. Its
|
|
129
|
+
* positionals are `<name> <browser> <all_extensions>` followed by raw pi args,
|
|
130
|
+
* so `--project` travels as an ordinary pi flag rather than a placeholder slot.
|
|
131
|
+
*/
|
|
132
|
+
function corePeerCommand(name: string, opts: PeerLaunchOptions, project: string, model?: string): string[] {
|
|
133
|
+
const command = ["just", "_fleet-peer", name, opts.browser ? "true" : "false", opts.allExtensions ? "true" : "false"];
|
|
134
|
+
if (model !== undefined) {
|
|
135
|
+
if (/[\r\n]/.test(model)) throw new Error(`model contains a line break: ${JSON.stringify(model)}`);
|
|
136
|
+
command.push("--model", model);
|
|
137
|
+
}
|
|
138
|
+
if (project !== DEFAULT_PROJECT) command.push("--project", project);
|
|
139
|
+
for (const arg of opts.piArgs ?? []) {
|
|
140
|
+
// A pane launch types this argv at a shell prompt one line at a time, so
|
|
141
|
+
// an embedded newline would execute half of it as a separate command.
|
|
142
|
+
if (/[\r\n]/.test(arg)) throw new Error(`pi argument contains a line break: ${JSON.stringify(arg)}`);
|
|
143
|
+
command.push(arg);
|
|
144
|
+
}
|
|
145
|
+
return command;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Merge CLI options with the peers.yaml declaration for the same name and
|
|
150
|
+
* produce the launch argv. Nothing is silently dropped: a flag that cannot
|
|
151
|
+
* apply to the resolved runner is an error, not a no-op.
|
|
152
|
+
*/
|
|
153
|
+
export function buildPeerLaunchPlan(opts: PeerLaunchOptions, ctx: PeerLaunchContext): PeerLaunchPlan {
|
|
154
|
+
const name = validateName(opts.name);
|
|
155
|
+
const project = validateProject(opts.project ?? DEFAULT_PROJECT);
|
|
156
|
+
const teams = ctx.peersYaml ? parsePeersYaml(ctx.peersYaml) : {};
|
|
157
|
+
const declared: Peer | undefined = findPeerByName(teams, name);
|
|
158
|
+
|
|
159
|
+
const runner =
|
|
160
|
+
normalizeRunner(opts.runner, "--runner") ??
|
|
161
|
+
normalizeRunner(declared?.runner, `peers.yaml peer "${name}"`) ??
|
|
162
|
+
"pi";
|
|
163
|
+
|
|
164
|
+
const model = opts.model ?? declared?.model;
|
|
165
|
+
const common = {
|
|
166
|
+
name,
|
|
167
|
+
runner,
|
|
168
|
+
...(model ? { model } : {}),
|
|
169
|
+
...(declared?.env_file ? { envFile: declared.env_file } : {}),
|
|
170
|
+
project,
|
|
171
|
+
placement: (opts.here ? "here" : "pane") as "here" | "pane",
|
|
172
|
+
direction: opts.direction ?? ("right" as const),
|
|
173
|
+
workspaceLabel: teamWorkspaceLabel("peer", name, project, ctx.worktreeTag),
|
|
174
|
+
declared: declared !== undefined,
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
if (runner === "claude-code") {
|
|
178
|
+
if (opts.persona) throw new Error("--persona is pi-only; a claude-code peer carries no pi persona.");
|
|
179
|
+
if (opts.extensions || opts.browser || opts.allExtensions) {
|
|
180
|
+
throw new Error("--extensions/--browser/--all-extensions are pi-only and cannot combine with --runner claude-code.");
|
|
181
|
+
}
|
|
182
|
+
if (opts.piArgs?.length) throw new Error("arguments after `--` are pi arguments and cannot combine with --runner claude-code.");
|
|
183
|
+
return {
|
|
184
|
+
...common,
|
|
185
|
+
kind: "claude-peer",
|
|
186
|
+
command: peerCommand({ name, ...(model ? { model } : {}), runner }, ADHOC_TEAM, undefined, project),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (opts.noPersona && opts.persona) throw new Error("--no-persona and --persona are contradictory.");
|
|
191
|
+
const persona = opts.noPersona
|
|
192
|
+
? undefined
|
|
193
|
+
: opts.persona ?? declared?.persona ?? (ctx.personaExists(name) ? name : undefined);
|
|
194
|
+
|
|
195
|
+
// No persona anywhere → the identity-only Fleet Core peer, which is exactly
|
|
196
|
+
// what this command did before pane placement existed. Not an error: it is
|
|
197
|
+
// the third shape of peer, and the only one that takes raw pi arguments.
|
|
198
|
+
if (!persona) {
|
|
199
|
+
if (opts.extensions) {
|
|
200
|
+
throw new Error(
|
|
201
|
+
`--extensions needs a persona peer. Pass --persona <name>, add agents/${name}.md, ` +
|
|
202
|
+
"or use --all-extensions / raw pi flags after `--`.",
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
return { ...common, kind: "core-peer", command: corePeerCommand(name, opts, project, model) };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (!ctx.personaExists(persona)) throw new Error(`Persona "${persona}" not found under agents/ or .pi/agents/.`);
|
|
209
|
+
if (opts.allExtensions) {
|
|
210
|
+
throw new Error(
|
|
211
|
+
`--all-extensions is not available to persona peer "${name}": reusable peers load a deterministic set. ` +
|
|
212
|
+
"Use --extensions <names>, declare extensions: in .pi/agents/peers.yaml, or --no-persona for a plain Fleet Core peer.",
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
if (opts.piArgs?.length) {
|
|
216
|
+
throw new Error(
|
|
217
|
+
`arguments after \`--\` need a personaless core peer; persona peer "${name}" builds its own pi command line. ` +
|
|
218
|
+
`Add --no-persona to launch "${name}" as a plain Fleet Core peer instead.`,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
const extensions = mergeExtensions(opts.extensions ?? declared?.extensions, opts.browser ? BROWSER_EXTENSION : undefined);
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
...common,
|
|
225
|
+
kind: "persona-peer",
|
|
226
|
+
persona,
|
|
227
|
+
...(extensions ? { extensions } : {}),
|
|
228
|
+
command: peerCommand(
|
|
229
|
+
{ name, persona, ...(model ? { model } : {}), ...(extensions ? { extensions } : {}) },
|
|
230
|
+
ADHOC_TEAM,
|
|
231
|
+
undefined,
|
|
232
|
+
project,
|
|
233
|
+
),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface ParsedPeerArgs extends PeerLaunchOptions {
|
|
238
|
+
dryRun: boolean;
|
|
239
|
+
/** --peers: alternate manifest path (tests use it). */
|
|
240
|
+
peersYaml?: string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function takeValue(argv: string[], i: number, flag: string): string {
|
|
244
|
+
const value = argv[i + 1];
|
|
245
|
+
if (value === undefined || value.startsWith("--")) throw new Error(`${flag} requires a value`);
|
|
246
|
+
return value;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* `<name> [--runner r] [--persona p|--no-persona] [--model m] [--project p]
|
|
251
|
+
* [--extensions a,b] [--browser] [--all-extensions] [--direction right|down]
|
|
252
|
+
* [--here] [--dry-run] [--peers path] [-- PI_ARGS…]`
|
|
253
|
+
*
|
|
254
|
+
* The peer name is the only positional and everything after `--` goes to pi
|
|
255
|
+
* verbatim. An unrecognized flag BEFORE `--` is an error rather than silently
|
|
256
|
+
* dropped argv — the failure mode `project=af` already taught this fleet about.
|
|
257
|
+
*/
|
|
258
|
+
export function parsePeerArgs(argv: string[]): ParsedPeerArgs {
|
|
259
|
+
const out: ParsedPeerArgs = { name: "", dryRun: false };
|
|
260
|
+
let name: string | undefined;
|
|
261
|
+
for (let i = 0; i < argv.length; i++) {
|
|
262
|
+
const arg = argv[i];
|
|
263
|
+
if (arg === "--") {
|
|
264
|
+
out.piArgs = argv.slice(i + 1);
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
switch (arg) {
|
|
268
|
+
case "--dry-run":
|
|
269
|
+
out.dryRun = true;
|
|
270
|
+
break;
|
|
271
|
+
case "--here":
|
|
272
|
+
out.here = true;
|
|
273
|
+
break;
|
|
274
|
+
case "--browser":
|
|
275
|
+
out.browser = true;
|
|
276
|
+
break;
|
|
277
|
+
case "--all-extensions":
|
|
278
|
+
out.allExtensions = true;
|
|
279
|
+
break;
|
|
280
|
+
case "--runner":
|
|
281
|
+
out.runner = takeValue(argv, i++, arg);
|
|
282
|
+
break;
|
|
283
|
+
case "--persona":
|
|
284
|
+
out.persona = takeValue(argv, i++, arg);
|
|
285
|
+
break;
|
|
286
|
+
case "--no-persona":
|
|
287
|
+
out.noPersona = true;
|
|
288
|
+
break;
|
|
289
|
+
case "--model":
|
|
290
|
+
out.model = takeValue(argv, i++, arg);
|
|
291
|
+
break;
|
|
292
|
+
case "--project":
|
|
293
|
+
out.project = takeValue(argv, i++, arg);
|
|
294
|
+
break;
|
|
295
|
+
case "--extensions":
|
|
296
|
+
out.extensions = takeValue(argv, i++, arg);
|
|
297
|
+
break;
|
|
298
|
+
case "--peers":
|
|
299
|
+
out.peersYaml = takeValue(argv, i++, arg);
|
|
300
|
+
break;
|
|
301
|
+
case "--direction": {
|
|
302
|
+
const value = takeValue(argv, i++, arg);
|
|
303
|
+
if (value !== "right" && value !== "down") throw new Error(`--direction expects right or down, got ${JSON.stringify(value)}`);
|
|
304
|
+
out.direction = value;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
default:
|
|
308
|
+
if (arg.startsWith("-")) {
|
|
309
|
+
throw new Error(`Unknown flag: ${arg} — pass pi flags after \`--\` (e.g. just fleet peer ${name ?? "<name>"} -- ${arg})`);
|
|
310
|
+
}
|
|
311
|
+
if (name !== undefined) throw new Error(`fleet peer takes one peer name, got ${JSON.stringify(name)} and ${JSON.stringify(arg)}`);
|
|
312
|
+
name = arg;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (!name) throw new Error("fleet peer requires a peer name");
|
|
316
|
+
out.name = name;
|
|
317
|
+
return out;
|
|
318
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// scripts/lib/persona-banner.ts
|
|
2
|
+
//
|
|
3
|
+
// Pure logic for the per-pane identity banner (`just _peer`/`_peer-plus`
|
|
4
|
+
// print it before exec'ing pi): persona frontmatter → colored ANSI banner.
|
|
5
|
+
// Frontmatter parsing mirrors the coms harness convention (name /
|
|
6
|
+
// description / color, quoted values allowed). Backend-agnostic — works in
|
|
7
|
+
// any terminal, inside or outside herdr.
|
|
8
|
+
|
|
9
|
+
export interface PersonaMeta {
|
|
10
|
+
name?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
color?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function parsePersonaFrontmatter(raw: string): PersonaMeta {
|
|
16
|
+
const match = raw.match(/^---\n([\s\S]*?)\n---\n?/);
|
|
17
|
+
if (!match) return {};
|
|
18
|
+
const fm: Record<string, string> = {};
|
|
19
|
+
for (const line of match[1].split("\n")) {
|
|
20
|
+
const idx = line.indexOf(":");
|
|
21
|
+
if (idx > 0) {
|
|
22
|
+
const key = line.slice(0, idx).trim();
|
|
23
|
+
let val = line.slice(idx + 1).trim();
|
|
24
|
+
if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
|
|
25
|
+
val = val.slice(1, -1);
|
|
26
|
+
}
|
|
27
|
+
fm[key] = val;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return { name: fm.name, description: fm.description, color: fm.color };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isValidHex(hex: string): boolean {
|
|
34
|
+
return /^#[0-9a-fA-F]{6}$/.test(hex);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function hexFg(hex: string, s: string): string {
|
|
38
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
39
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
40
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
41
|
+
return `\x1b[38;2;${r};${g};${b}m${s}\x1b[0m`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const DEFAULT_COLOR = "#36F9F6";
|
|
45
|
+
|
|
46
|
+
// Colored banner lines for a peer pane: name in the persona color, purpose
|
|
47
|
+
// dimmed below, framed by a rule in the same color. `width` caps the rule so
|
|
48
|
+
// narrow panes don't wrap.
|
|
49
|
+
export function renderBanner(
|
|
50
|
+
peerName: string,
|
|
51
|
+
meta: PersonaMeta,
|
|
52
|
+
width = 60,
|
|
53
|
+
): string[] {
|
|
54
|
+
const color = meta.color && isValidHex(meta.color) ? meta.color : DEFAULT_COLOR;
|
|
55
|
+
const purpose = (meta.description ?? "").trim();
|
|
56
|
+
const rule = hexFg(color, "━".repeat(Math.max(8, Math.min(width, 100))));
|
|
57
|
+
const title = hexFg(color, `● ${peerName}`);
|
|
58
|
+
const lines = [rule, title];
|
|
59
|
+
if (purpose) lines.push(`\x1b[2m${purpose}\x1b[0m`);
|
|
60
|
+
lines.push(rule);
|
|
61
|
+
return lines;
|
|
62
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// scripts/lib/spawn-stagger.ts
|
|
2
|
+
//
|
|
3
|
+
// Pre-warm/stagger for simultaneous pi pane spawns (team-up, hub-team,
|
|
4
|
+
// team-resume). pi's credential store (~/.pi/agent/auth.json) is loaded once
|
|
5
|
+
// at boot under a short-retry file lock; when a stale OAuth token forces one
|
|
6
|
+
// pane to refresh it over the network WHILE holding that lock, sibling panes
|
|
7
|
+
// booting in the same instant lose the lock race and come up with an empty
|
|
8
|
+
// credential store — every provider shows "unconfigured". The fix is local:
|
|
9
|
+
// when a stale OAuth credential is detected, one pi pane starts immediately
|
|
10
|
+
// (the warmer — it refreshes the token) and every other pi pane sleeps a few
|
|
11
|
+
// seconds before launching. Fresh tokens mean zero delay everywhere.
|
|
12
|
+
//
|
|
13
|
+
// Pure logic only — no fs, no sockets, no process.exit. Callers read
|
|
14
|
+
// auth.json themselves (lock-free, same as pi's readStoredCredential) and
|
|
15
|
+
// inject delays into pane env; the `_peer`/`_peer-plus` recipes honor
|
|
16
|
+
// AGENT_FLEET_SPAWN_DELAY with a plain `sleep`.
|
|
17
|
+
|
|
18
|
+
/** Env var the justfile peer recipes read: seconds to sleep before launching pi. */
|
|
19
|
+
export const STAGGER_ENV_VAR = "AGENT_FLEET_SPAWN_DELAY";
|
|
20
|
+
|
|
21
|
+
/** Delay for the first staggered pane — long enough for the warmer's token refresh round-trip. */
|
|
22
|
+
export const WARMUP_SECONDS = 4;
|
|
23
|
+
|
|
24
|
+
/** Extra spacing between subsequent staggered panes. */
|
|
25
|
+
export const STEP_SECONDS = 1;
|
|
26
|
+
|
|
27
|
+
/** Treat tokens expiring within this window as stale — pane boot takes seconds. */
|
|
28
|
+
export const EXPIRY_MARGIN_MS = 60_000;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Does auth.json hold an OAuth credential that a booting pi would refresh?
|
|
32
|
+
* `raw` is the file's contents (undefined when unreadable/absent). Missing or
|
|
33
|
+
* malformed files never stagger: with no stored credential there is nothing
|
|
34
|
+
* to refresh, so there is no long lock hold to dodge.
|
|
35
|
+
*/
|
|
36
|
+
export function oauthNeedsWarmup(raw: string | undefined, now = Date.now()): boolean {
|
|
37
|
+
if (!raw) return false;
|
|
38
|
+
let data: unknown;
|
|
39
|
+
try {
|
|
40
|
+
data = JSON.parse(raw);
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (typeof data !== "object" || data === null) return false;
|
|
45
|
+
for (const credential of Object.values(data)) {
|
|
46
|
+
if (typeof credential !== "object" || credential === null) continue;
|
|
47
|
+
const { type, expires } = credential as { type?: unknown; expires?: unknown };
|
|
48
|
+
if (type !== "oauth" || typeof expires !== "number") continue;
|
|
49
|
+
if (expires <= now + EXPIRY_MARGIN_MS) return true;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface StaggerOptions {
|
|
55
|
+
/** Per-peer flag, in spawn order: does this pane boot a pi process? */
|
|
56
|
+
peerIsPi: boolean[];
|
|
57
|
+
/** Does the root pane (hub) boot a pi process? The hub warms when present. */
|
|
58
|
+
rootIsPi: boolean;
|
|
59
|
+
/** Result of oauthNeedsWarmup — false short-circuits to all-zero delays. */
|
|
60
|
+
needed: boolean;
|
|
61
|
+
warmupSeconds?: number;
|
|
62
|
+
stepSeconds?: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Per-peer delay seconds (spawn order). Exactly one pi process — the hub when
|
|
67
|
+
* present, otherwise the first pi peer — starts at 0 and refreshes the stale
|
|
68
|
+
* token; every other pi peer starts after the warm-up window. Non-pi panes
|
|
69
|
+
* (runner: claude-code) never wait: they do not touch pi's credential store.
|
|
70
|
+
*/
|
|
71
|
+
export function staggerDelays(opts: StaggerOptions): number[] {
|
|
72
|
+
const { peerIsPi, rootIsPi, needed, warmupSeconds = WARMUP_SECONDS, stepSeconds = STEP_SECONDS } = opts;
|
|
73
|
+
if (!needed) return peerIsPi.map(() => 0);
|
|
74
|
+
let staggered = 0;
|
|
75
|
+
let warmerAssigned = rootIsPi;
|
|
76
|
+
return peerIsPi.map((isPi) => {
|
|
77
|
+
if (!isPi) return 0;
|
|
78
|
+
if (!warmerAssigned) {
|
|
79
|
+
warmerAssigned = true;
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
return warmupSeconds + staggered++ * stepSeconds;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Convenience for the team entrypoints: auth.json contents + peers → a
|
|
88
|
+
* `delayForPeer` hook for buildTeamLayout. Structural peer type avoids a
|
|
89
|
+
* circular import with herdr-layout.ts.
|
|
90
|
+
*/
|
|
91
|
+
export function planSpawnDelays<P extends { runner?: string }>(
|
|
92
|
+
peers: P[],
|
|
93
|
+
rootIsPi: boolean,
|
|
94
|
+
authJsonRaw: string | undefined,
|
|
95
|
+
now = Date.now(),
|
|
96
|
+
): { needed: boolean; delayForPeer: (peer: P) => number | undefined } {
|
|
97
|
+
const needed = oauthNeedsWarmup(authJsonRaw, now);
|
|
98
|
+
const delays = staggerDelays({ peerIsPi: peers.map((p) => p.runner !== "claude-code"), rootIsPi, needed });
|
|
99
|
+
const byPeer = new Map<P, number>(peers.map((p, i) => [p, delays[i]]));
|
|
100
|
+
return { needed, delayForPeer: (peer) => byPeer.get(peer) };
|
|
101
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// scripts/lib/team-project.ts
|
|
2
|
+
//
|
|
3
|
+
// Shared project scoping helpers for herdr team commands. The coms harness
|
|
4
|
+
// already isolates peers by --project; this file only keeps team workspace
|
|
5
|
+
// labels, snapshot files, and generated launch argv in sync with that scope.
|
|
6
|
+
|
|
7
|
+
import * as os from "node:os";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
|
|
10
|
+
export const DEFAULT_PROJECT = "default";
|
|
11
|
+
|
|
12
|
+
// Conservative project names: no empty string, path separators, traversal,
|
|
13
|
+
// whitespace, shell metacharacters, or glob stars. Dots are allowed for names
|
|
14
|
+
// like "acme.prod", but ".." is not allowed anywhere.
|
|
15
|
+
export const PROJECT_SAFE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
16
|
+
export const TEAM_SAFE = /^[A-Za-z0-9_-]+$/;
|
|
17
|
+
export const CODEX_CONTRACT_IDENTITY = "agent-fleet-codex-conductor-pilot-v1";
|
|
18
|
+
export const DEFAULT_CODEX_TIMEOUT_MS = 300_000;
|
|
19
|
+
|
|
20
|
+
export type ConductorBackend = "hermes" | "codex";
|
|
21
|
+
// "peer" is the `just fleet peer <name>` workspace: a single pane for
|
|
22
|
+
// a single peer, labelled by the PEER name where the others use a team name.
|
|
23
|
+
export type WorkspaceMode = "peers" | "peer" | "hub" | "conductor-hermes" | "conductor-codex";
|
|
24
|
+
|
|
25
|
+
export interface ConductorSpec {
|
|
26
|
+
backend: ConductorBackend;
|
|
27
|
+
workspaceMode: Extract<WorkspaceMode, `conductor-${string}`>;
|
|
28
|
+
paneLabel: string;
|
|
29
|
+
command: string[];
|
|
30
|
+
cwd: string;
|
|
31
|
+
env: Record<string, string>;
|
|
32
|
+
ratio: number;
|
|
33
|
+
displayText: string;
|
|
34
|
+
expectedServiceScope: "none" | "agent-fleet-codex-remote-control.service";
|
|
35
|
+
conductorName: string;
|
|
36
|
+
team: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function validateAbsoluteRepoRoot(repoRoot: string): string {
|
|
40
|
+
if (!path.isAbsolute(repoRoot) || path.resolve(repoRoot) !== repoRoot || repoRoot.includes("..")) {
|
|
41
|
+
throw new Error(`Invalid absolute repository root: ${JSON.stringify(repoRoot)}`);
|
|
42
|
+
}
|
|
43
|
+
return repoRoot;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function validateProject(project: string): string {
|
|
47
|
+
if (
|
|
48
|
+
project.length === 0 ||
|
|
49
|
+
project === "." ||
|
|
50
|
+
project.includes("..") ||
|
|
51
|
+
project.includes("/") ||
|
|
52
|
+
project.includes("\\") ||
|
|
53
|
+
!PROJECT_SAFE.test(project)
|
|
54
|
+
) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Invalid project name: ${JSON.stringify(project)} (use letters, numbers, dots, underscores, or hyphens; no '..')`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return project;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function validateTeamName(team: string): string {
|
|
63
|
+
if (!TEAM_SAFE.test(team)) throw new Error(`Invalid team name: ${JSON.stringify(team)}`);
|
|
64
|
+
return team;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// The worktree/repo identity that scopes a workspace label so the same team
|
|
68
|
+
// launched from different checkouts never collides. It is the LAST dot-segment
|
|
69
|
+
// of the checkout directory's basename — the convention the fleet uses for
|
|
70
|
+
// git worktrees: `main.wt2` → `wt2`, `ringithub.end2` → `end2`, a plain
|
|
71
|
+
// `agent-fleet` checkout → `agent-fleet`. Sanitized to the label-safe charset;
|
|
72
|
+
// falls back to "repo" when nothing usable remains.
|
|
73
|
+
export function worktreeTag(repoRoot: string): string {
|
|
74
|
+
const base = path.basename(repoRoot);
|
|
75
|
+
const dot = base.lastIndexOf(".");
|
|
76
|
+
const seg = dot > 0 ? base.slice(dot + 1) : base;
|
|
77
|
+
const safe = seg.replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
78
|
+
return safe || "repo";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function parseProjectFlag(argv: string[]): string {
|
|
82
|
+
let project = DEFAULT_PROJECT;
|
|
83
|
+
let seen = false;
|
|
84
|
+
for (let i = 0; i < argv.length; i++) {
|
|
85
|
+
if (argv[i] !== "--project") continue;
|
|
86
|
+
if (seen) throw new Error("--project may only be provided once");
|
|
87
|
+
seen = true;
|
|
88
|
+
const value = argv[i + 1];
|
|
89
|
+
if (!value || value.startsWith("--")) throw new Error("--project requires a name");
|
|
90
|
+
project = value;
|
|
91
|
+
i++;
|
|
92
|
+
}
|
|
93
|
+
return validateProject(project);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Workspace label = <worktree-tag>-<mode>-<team>, with a `--project.<name>`
|
|
97
|
+
// suffix when the coms project is non-default. The worktree tag keys the label
|
|
98
|
+
// to the checkout, so `just fleet team <team>` from two repos/worktrees yields
|
|
99
|
+
// distinct labels (e.g. `wt2-hub-plan` vs `end2-hub-plan`) instead of colliding
|
|
100
|
+
// on a shared `pi-hub-<team>`. Pass `tag` from worktreeTag(REPO_ROOT); it
|
|
101
|
+
// defaults to "repo" only for callers that have no checkout in hand.
|
|
102
|
+
export function teamWorkspaceLabel(
|
|
103
|
+
kind: WorkspaceMode,
|
|
104
|
+
team: string,
|
|
105
|
+
project = DEFAULT_PROJECT,
|
|
106
|
+
tag = "repo",
|
|
107
|
+
): string {
|
|
108
|
+
validateTeamName(team);
|
|
109
|
+
validateProject(project);
|
|
110
|
+
const base = `${tag}-${kind}-${team}`;
|
|
111
|
+
return project === DEFAULT_PROJECT ? base : `${base}--project.${project}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface HubCommandOptions {
|
|
115
|
+
workMode?: "operator" | "orchestrator";
|
|
116
|
+
agentTeam?: string;
|
|
117
|
+
noComs?: boolean;
|
|
118
|
+
browser?: boolean;
|
|
119
|
+
allExtensions?: boolean;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function resolveLegacyAgentRoster(teams: Record<string, string[]>, requested: string): string {
|
|
123
|
+
validateTeamName(requested);
|
|
124
|
+
const wanted = requested.toLowerCase();
|
|
125
|
+
return Object.keys(teams).find(name => name.toLowerCase() === wanted)
|
|
126
|
+
?? Object.keys(teams).find(name => name.toLowerCase() === "default")
|
|
127
|
+
?? "default";
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function hubCommand(
|
|
131
|
+
project = DEFAULT_PROJECT,
|
|
132
|
+
options: HubCommandOptions = {},
|
|
133
|
+
): string[] {
|
|
134
|
+
validateProject(project);
|
|
135
|
+
if (options.agentTeam) validateTeamName(options.agentTeam);
|
|
136
|
+
const command = ["just", "fleet"];
|
|
137
|
+
if (options.workMode) command.push("--work-mode", options.workMode);
|
|
138
|
+
if (options.agentTeam) command.push("--agents", options.agentTeam);
|
|
139
|
+
if (options.noComs) command.push("--no-coms");
|
|
140
|
+
if (options.browser) command.push("--browser");
|
|
141
|
+
if (options.allExtensions) command.push("--all-extensions");
|
|
142
|
+
if (project !== DEFAULT_PROJECT) command.push("--project", project);
|
|
143
|
+
return command;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function conductorCommand(): string[] {
|
|
147
|
+
return ["hermes", "-p", "dev"];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function conductorSpec(
|
|
151
|
+
backend: ConductorBackend,
|
|
152
|
+
input: { repoRoot: string; runtimeDir?: string; team: string; project?: string; nodeBin?: string },
|
|
153
|
+
): ConductorSpec {
|
|
154
|
+
const repoRoot = validateAbsoluteRepoRoot(input.repoRoot);
|
|
155
|
+
const team = validateTeamName(input.team);
|
|
156
|
+
const project = validateProject(input.project ?? DEFAULT_PROJECT);
|
|
157
|
+
const conductorName = `${backend}-${team}-conductor`;
|
|
158
|
+
if (backend === "hermes") {
|
|
159
|
+
return {
|
|
160
|
+
backend,
|
|
161
|
+
workspaceMode: "conductor-hermes",
|
|
162
|
+
paneLabel: "conductor-hermes",
|
|
163
|
+
command: conductorCommand(),
|
|
164
|
+
cwd: repoRoot,
|
|
165
|
+
env: {},
|
|
166
|
+
ratio: 0.35,
|
|
167
|
+
displayText: "Hermes conductor; no herdr control",
|
|
168
|
+
expectedServiceScope: "none",
|
|
169
|
+
conductorName,
|
|
170
|
+
team,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const runtimeDir = input.runtimeDir ?? path.join(os.homedir(), ".local", "state", "agent-fleet", "codex-conductor");
|
|
174
|
+
if (!path.isAbsolute(runtimeDir) || path.resolve(runtimeDir) !== runtimeDir) {
|
|
175
|
+
throw new Error(`Codex conductor requires an absolute runtime directory: ${JSON.stringify(runtimeDir)}`);
|
|
176
|
+
}
|
|
177
|
+
const relativeRuntime = path.relative(repoRoot, runtimeDir);
|
|
178
|
+
if (relativeRuntime === "" || (!relativeRuntime.startsWith("..") && !path.isAbsolute(relativeRuntime))) {
|
|
179
|
+
throw new Error("Codex conductor requires a runtime directory outside repoRoot");
|
|
180
|
+
}
|
|
181
|
+
const workspaceDir = path.join(runtimeDir, "workspace");
|
|
182
|
+
const nodeBin = input.nodeBin ?? process.execPath;
|
|
183
|
+
if (!path.isAbsolute(nodeBin)) throw new Error(`Codex conductor requires an absolute Node binary path: ${JSON.stringify(nodeBin)}`);
|
|
184
|
+
return {
|
|
185
|
+
backend,
|
|
186
|
+
workspaceMode: "conductor-codex",
|
|
187
|
+
paneLabel: "conductor-codex-control",
|
|
188
|
+
command: [nodeBin, "--experimental-strip-types", path.join(repoRoot, "scripts", "codex-remote-control.ts"), "control-pane"],
|
|
189
|
+
cwd: workspaceDir,
|
|
190
|
+
env: {
|
|
191
|
+
AGENT_FLEET_REPO_ROOT: repoRoot,
|
|
192
|
+
COMS_CLI_PROJECT: project,
|
|
193
|
+
COMS_CLI_NAME: conductorName,
|
|
194
|
+
COMS_CLI_TIMEOUT_MS: String(DEFAULT_CODEX_TIMEOUT_MS),
|
|
195
|
+
AGENT_FLEET_CODEX_CONTRACT_PATH: path.join(workspaceDir, "AGENTS.md"),
|
|
196
|
+
AGENT_FLEET_CODEX_CONTRACT_IDENTITY: CODEX_CONTRACT_IDENTITY,
|
|
197
|
+
AGENT_FLEET_CONDUCTOR_BACKEND: "codex",
|
|
198
|
+
},
|
|
199
|
+
ratio: 0.35,
|
|
200
|
+
displayText: "Codex control pane; requested systemd state only",
|
|
201
|
+
expectedServiceScope: "agent-fleet-codex-remote-control.service",
|
|
202
|
+
conductorName,
|
|
203
|
+
team,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function teamSnapshotPath(snapshotDir: string, team: string, project = DEFAULT_PROJECT): string {
|
|
208
|
+
validateTeamName(team);
|
|
209
|
+
validateProject(project);
|
|
210
|
+
return project === DEFAULT_PROJECT
|
|
211
|
+
? path.join(snapshotDir, `${team}.json`)
|
|
212
|
+
: path.join(snapshotDir, "projects", project, `${team}.json`);
|
|
213
|
+
}
|