@chankov/agent-fleet 2.0.13 → 2.0.15
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/agent-fleet/scripts/fleet.ts +2 -1
- package/.pi/extensions/compact-and-continue/README.md +2 -2
- package/.pi/harnesses/agent-hub/README.md +98 -10
- package/.pi/harnesses/agent-hub/budget-recovery.ts +2 -2
- package/.pi/harnesses/agent-hub/commands/context.ts +2 -0
- package/.pi/harnesses/agent-hub/commands/recover.ts +13 -4
- package/.pi/harnesses/agent-hub/commands/task-triage-recover.ts +12 -0
- package/.pi/harnesses/agent-hub/commands/task-triage-waive.ts +12 -0
- package/.pi/harnesses/agent-hub/context/budgets.ts +9 -7
- package/.pi/harnesses/agent-hub/deterministic-fs.ts +51 -12
- package/.pi/harnesses/agent-hub/dispatch-native-complete.ts +4 -0
- package/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +14 -3
- package/.pi/harnesses/agent-hub/dispatch-native-types.ts +3 -0
- package/.pi/harnesses/agent-hub/dispatch-native.ts +9 -1
- package/.pi/harnesses/agent-hub/dispatch-triage-contract.ts +38 -0
- package/.pi/harnesses/agent-hub/dispatch-triage-eval.ts +76 -0
- package/.pi/harnesses/agent-hub/dispatch-triage-policy.ts +29 -0
- package/.pi/harnesses/agent-hub/dispatch-triage-runtime.ts +55 -0
- package/.pi/harnesses/agent-hub/dispatch-triage-state.ts +33 -0
- package/.pi/harnesses/agent-hub/docs-lane.js +2 -1
- package/.pi/harnesses/agent-hub/evidence-manifest.ts +51 -0
- package/.pi/harnesses/agent-hub/filesystem-tool.ts +75 -11
- package/.pi/harnesses/agent-hub/index.ts +284 -23
- package/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +13 -5
- package/.pi/harnesses/agent-hub/no-progress.ts +232 -28
- package/.pi/harnesses/agent-hub/orchestration-activation.ts +112 -0
- package/.pi/harnesses/agent-hub/orchestration-metrics.ts +78 -0
- package/.pi/harnesses/agent-hub/orchestration-route.ts +76 -0
- package/.pi/harnesses/agent-hub/package.json +1 -1
- package/.pi/harnesses/agent-hub/policy/work-mode.ts +14 -5
- package/.pi/harnesses/agent-hub/process-obligations.ts +116 -15
- package/.pi/harnesses/agent-hub/prompts/context.ts +1 -0
- package/.pi/harnesses/agent-hub/prompts/fragments.ts +9 -11
- package/.pi/harnesses/agent-hub/prompts/system-prompt.ts +8 -1
- package/.pi/harnesses/agent-hub/recover-policy.ts +18 -1
- package/.pi/harnesses/agent-hub/recover-state.ts +1 -1
- package/.pi/harnesses/agent-hub/recovery-contract.ts +70 -0
- package/.pi/harnesses/agent-hub/rerun-policy.ts +40 -0
- package/.pi/harnesses/agent-hub/research/runtime.ts +2 -0
- package/.pi/harnesses/agent-hub/research/spawn-run.ts +15 -6
- package/.pi/harnesses/agent-hub/return-contract.js +27 -5
- package/.pi/harnesses/agent-hub/review-closure.ts +43 -0
- package/.pi/harnesses/agent-hub/routing-observation.ts +41 -0
- package/.pi/harnesses/agent-hub/routing-proposal.ts +46 -0
- package/.pi/harnesses/agent-hub/run-budget.js +12 -0
- package/.pi/harnesses/agent-hub/scope-gate.js +23 -2
- package/.pi/harnesses/agent-hub/session-audit.ts +94 -8
- package/.pi/harnesses/agent-hub/spawn.ts +10 -2
- package/.pi/harnesses/agent-hub/system1-activity.ts +116 -1
- package/.pi/harnesses/agent-hub/system1-communication-store.ts +129 -0
- package/.pi/harnesses/agent-hub/system1-report.ts +50 -0
- package/.pi/harnesses/agent-hub/system1-runtime.ts +8 -4
- package/.pi/harnesses/agent-hub/task-triage-authorization.ts +122 -0
- package/.pi/harnesses/agent-hub/task-triage-config.ts +37 -0
- package/.pi/harnesses/agent-hub/task-triage-contract.ts +19 -0
- package/.pi/harnesses/agent-hub/task-triage-obligations.ts +104 -0
- package/.pi/harnesses/agent-hub/task-triage-policy.ts +16 -0
- package/.pi/harnesses/agent-hub/task-triage-runtime.ts +125 -0
- package/.pi/harnesses/agent-hub/task-triage-stage-guard.ts +21 -0
- package/.pi/harnesses/agent-hub/task-triage-state.ts +46 -0
- package/.pi/harnesses/agent-hub/tools/action-executors.ts +33 -10
- package/.pi/harnesses/agent-hub/tools/context.ts +2 -0
- package/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +10 -4
- package/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +86 -26
- package/.pi/harnesses/agent-hub/tools/dispatch-triage.ts +16 -0
- package/.pi/harnesses/agent-hub/tools/herdr-executors.ts +9 -0
- package/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +37 -6
- package/.pi/harnesses/agent-hub/ui/fleet-source.ts +6 -2
- package/.pi/harnesses/agent-hub/ui/system1-communication.ts +59 -0
- package/.pi/harnesses/agent-hub/work-mode.ts +14 -8
- package/.pi/harnesses/coms/package.json +1 -1
- package/.pi/harnesses/damage-control-continue/package.json +1 -1
- package/.pi/harnesses/lib/context-budget-hub-prompt.ts +6 -1
- package/.pi/harnesses/lib/fleet-dashboard-view.ts +30 -5
- package/.pi/harnesses/lib/fleet-read-model.ts +73 -0
- package/.pi/harnesses/lib/fleet-strip-controller.ts +2 -1
- package/.pi/harnesses/lib/fleet-strip-view.ts +1 -1
- package/.pi/harnesses/lib/system1/demo.ts +2 -4
- package/.pi/harnesses/lib/system1/selection.js +11 -0
- package/.pi/prompts/af-build.md +9 -6
- package/.versions/2.0.14/.pi/agent-fleet/hermes/README.md +347 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/gates/gate-o-capability.md +8 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/gates/gate-o-validator-fixtures.json +1 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +773 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-conductor/SKILL.md +84 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-liaison/SKILL.md +84 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/SKILL.md +76 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/manifest.json +1 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
- package/.versions/2.0.14/.pi/agent-fleet/hermes/watchdog-tests/__init__.py +0 -0
- package/.versions/2.0.14/.pi/agent-fleet/hooks/coms-stop-hook.mjs +84 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/claude-code-preflight.ts +70 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/coms-claude-bridge.ts +411 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/coms-cli.ts +425 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/coms-hermes-bridge.ts +413 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/fleet-codex-client.ts +69 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/fleet-codex-read.py +148 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/fleet.ts +216 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/flow.ts +157 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/hermes-monitor-capability-runner.ts +25 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/hermes-monitor-scenario.ts +474 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/hermes-watchdog-capability-probe.ts +45 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/install-hermes-plugin.sh +180 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/claude-bridge-core.ts +210 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/coms-envelope.ts +582 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/fake-herdr-server.ts +88 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/fleet-codex-catalog.ts +63 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/fleet-codex-operations.ts +190 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/fleet-codex-session.ts +166 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/fleet-codex-transport.ts +124 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/fleet-command.ts +252 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/flow-command.ts +98 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/flow-maintenance.ts +230 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/herdr-layout.ts +281 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/hermes-bridge-core.ts +241 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/hermes-monitor-events.ts +1 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/hermes-monitor-herdr.ts +2 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/hermes-monitor-model.ts +3 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/hermes-monitor-registry.ts +2 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/hermes-monitor-socket.ts +2 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/hermes-monitor-store.ts +2 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/monitor-env.ts +146 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/peer-launch.ts +318 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/persona-banner.ts +62 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/persona-dirs.ts +25 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/runtime-dependencies.js +124 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/spawn-stagger.ts +101 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/team-project.ts +178 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/lib/team-snapshot.ts +147 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/package-lock.json +35 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/package.json +9 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/peer-banner.ts +41 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/peer-launch.ts +283 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/team-snapshot.ts +237 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/team-up.ts +378 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/agent-phase.ts +179 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/changes.ts +61 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/debate.ts +149 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/env.ts +34 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/envelopes.ts +169 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/gates.ts +81 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/git.ts +96 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/isolated-snapshot.ts +125 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/merge.ts +95 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/model-profile.ts +22 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/model-visibility.ts +92 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/permissions.ts +130 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/personas.ts +57 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/poll.ts +86 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/project-policy.ts +34 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/quality.ts +64 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/run.ts +108 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/scout-data-boundary.ts +55 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/trace.ts +34 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/voices.ts +128 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/lib/writer-lease.ts +112 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/tsconfig.json +22 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/wf-build-test.ts +61 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/wf-debate.ts +87 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/wf-document.ts +50 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/wf-poll.ts +95 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/wf-quality.ts +20 -0
- package/.versions/2.0.14/.pi/agent-fleet/scripts/workflows/wf-scout.ts +40 -0
- package/.versions/2.0.14/.pi/agents/dispatch-policy.yaml +32 -0
- package/.versions/2.0.14/.pi/agents/model-profiles.yaml +134 -0
- package/.versions/2.0.14/.pi/agents/peers.yaml +147 -0
- package/.versions/2.0.14/.pi/agents/teams.yaml +41 -0
- package/.versions/2.0.14/.pi/agents/voices.yaml +13 -0
- package/.versions/2.0.14/.pi/damage-control-rules.yaml +297 -0
- package/.versions/2.0.14/.pi/extensions/btw/README.md +120 -0
- package/.versions/2.0.14/.pi/extensions/btw/index.ts +914 -0
- package/.versions/2.0.14/.pi/extensions/btw/package.json +6 -0
- package/.versions/2.0.14/.pi/extensions/btw/state.js +179 -0
- package/.versions/2.0.14/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
- package/.versions/2.0.14/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
- package/.versions/2.0.14/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.versions/2.0.14/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.versions/2.0.14/.pi/extensions/compact-and-continue/index.ts +120 -0
- package/.versions/2.0.14/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.versions/2.0.14/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.versions/2.0.14/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.versions/2.0.14/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.versions/2.0.14/.pi/extensions/package-lock.json +1175 -0
- package/.versions/2.0.14/.pi/extensions/package.json +9 -0
- package/.versions/2.0.14/.pi/extensions/pi-voice-stt/README.md +224 -0
- package/.versions/2.0.14/.pi/extensions/pi-voice-stt/config.ts +198 -0
- package/.versions/2.0.14/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
- package/.versions/2.0.14/.pi/extensions/pi-voice-stt/index.ts +248 -0
- package/.versions/2.0.14/.pi/extensions/pi-voice-stt/package.json +6 -0
- package/.versions/2.0.14/.pi/extensions/pi-voice-stt/providers.ts +214 -0
- package/.versions/2.0.14/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/README.md +1369 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/acceptance.ts +199 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/access-approval.ts +135 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/artifacts.js +146 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/assertion-ledger.js +67 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/assist-profile.ts +16 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/backend-policy.js +174 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/bounded-output.ts +26 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/budget-continuation.ts +13 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/budget-recovery.ts +214 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/capability-confirmation.ts +47 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/capability-packs.ts +184 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agent-model-thinking.ts +10 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agent-model.ts +10 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agent-models-substitute.ts +10 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agents-add.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agents-drop.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agents-history.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agents-kill.ts +10 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agents-list.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agents-restart.ts +10 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agents-save.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/agents-team.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/audit.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/budget-continue.ts +10 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/compound.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/coms.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/context-command.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/context.ts +45 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/debate.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/dispatch-policy.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/handoff.ts +10 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/hub-report.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/models.ts +10 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/poll.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/recover.ts +52 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/retry.ts +10 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/watchdog.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/work-mode.ts +29 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/commands/zoom.ts +10 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/config/agents.ts +178 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/config/model-profiles.ts +236 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/config/overrides.ts +160 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/context/agent-state.ts +30 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +221 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/context/budgets.ts +204 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/context/hub-state.ts +40 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/context-budget-snapshot.ts +105 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/context-pressure.ts +191 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/context-window.js +108 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/debate-command.ts +176 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/delegate.ts +467 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/deterministic-fs.ts +127 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/diagnostic-probe-extension.ts +26 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/diagnostic-series-budget.ts +178 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-coms.ts +252 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-core.ts +27 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-native-complete.ts +169 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +248 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +231 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-native-types.ts +257 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-native.ts +226 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-observability.ts +225 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-triage-contract.ts +38 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-triage-eval.ts +75 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-triage-policy.ts +29 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-triage-runtime.ts +53 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/dispatch-triage-state.ts +15 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/docs-lane.js +122 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/drift-judge.ts +352 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/drift-runtime.ts +480 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/drift-system1-policy.ts +39 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/drift-system1.ts +469 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/drift-watchdog.js +349 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/execution-evidence.ts +80 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/external-blocker.js +85 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/filesystem-tool.ts +73 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/fixtures/registration-surface.json +62 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/fixtures/t0a-synthetic/catalog.ts +189 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/footer.ts +30 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/helpers.ts +270 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/hub-state-audit.js +65 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/index.ts +2370 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/input/completions.ts +82 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/input/shortcuts.ts +20 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +125 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/lifecycle/monitor-session.ts +104 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +143 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/lifecycle/turn-handlers.ts +74 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/no-progress.ts +359 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/package.json +7 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/policy/models.ts +153 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/policy/profile-activation.ts +62 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/policy/profile-runtime.ts +120 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/policy/roster.ts +94 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/policy/work-mode.ts +126 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/poll-command.ts +176 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/presentation.ts +48 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-config.ts +40 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-evaluate.ts +138 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-feedback.ts +104 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-findings.ts +115 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-local.ts +88 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-observer.ts +105 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-rules.ts +143 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-runtime.ts +316 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-selection.ts +68 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-snapshot-worker.mjs +12 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-snapshot.ts +243 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/proactive-types.ts +63 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/process-obligations.ts +57 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/prompts/context.ts +54 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/prompts/fragments.ts +118 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/prompts/session-start.ts +90 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/prompts/system-prompt.ts +122 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/reconcile.ts +26 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/recover-policy.ts +27 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/recover-state.ts +104 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/recovery-contract.ts +80 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/research/controls.ts +74 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/research/runtime.ts +195 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/research/spawn-run.ts +174 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/return-contract.js +327 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/return-extract.js +77 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/review-findings.js +104 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/run-budget.js +542 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/run-namespace.js +93 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/runtime-test-check.ts +54 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/scope-gate.js +123 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/session-audit.ts +227 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/session-health.js +110 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/session-start.ts +42 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/spawn.ts +526 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/system1-activity.ts +510 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/system1-communication-store.ts +95 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/system1-report.ts +225 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/system1-runtime.ts +279 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/task-resume-contract.ts +70 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/timeline.ts +72 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tool-catalog-runtime.ts +68 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tool-catalog-state.ts +123 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tool-protocol.ts +134 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/action-executors.ts +185 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/coms-tools.ts +139 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/context.ts +144 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +88 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +498 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/dispatch-triage.ts +16 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/execution-orchestration.ts +22 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/fleet-tools.ts +200 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/herdr-executors.ts +86 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/run-flow.ts +136 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/set-task-tier.ts +31 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/spawn-research.ts +65 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/team-adjust.ts +29 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tools/verification-contract.ts +80 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/tsconfig.json +22 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/types.ts +66 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/activity-dots.ts +25 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/context-budget.ts +87 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/detail-panel.ts +192 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/fleet-actions.ts +78 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +152 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/fleet-editor.ts +44 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/fleet-source.ts +175 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/grid.ts +159 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/history-store.ts +137 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/history.ts +234 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/pool.ts +103 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/running-strip.ts +2 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/system1-communication.ts +59 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/ui/zoom.ts +206 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/unknown-tool-counter.ts +116 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/version.ts +42 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/watchdog-evaluation.ts +110 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/work-mode-controls.ts +56 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/work-mode.ts +174 -0
- package/.versions/2.0.14/.pi/harnesses/agent-hub/write-isolation.ts +187 -0
- package/.versions/2.0.14/.pi/harnesses/ask-user-remote/README.md +59 -0
- package/.versions/2.0.14/.pi/harnesses/ask-user-remote/index.ts +558 -0
- package/.versions/2.0.14/.pi/harnesses/ask-user-remote/questions.ts +161 -0
- package/.versions/2.0.14/.pi/harnesses/ask-user-remote/race-core.js +124 -0
- package/.versions/2.0.14/.pi/harnesses/ask-user-remote/runtime-ask.ts +68 -0
- package/.versions/2.0.14/.pi/harnesses/coms/README.md +100 -0
- package/.versions/2.0.14/.pi/harnesses/coms/index.ts +282 -0
- package/.versions/2.0.14/.pi/harnesses/coms/package.json +7 -0
- package/.versions/2.0.14/.pi/harnesses/coms/version.ts +42 -0
- package/.versions/2.0.14/.pi/harnesses/damage-control-continue/README.md +135 -0
- package/.versions/2.0.14/.pi/harnesses/damage-control-continue/index.ts +550 -0
- package/.versions/2.0.14/.pi/harnesses/damage-control-continue/package.json +7 -0
- package/.versions/2.0.14/.pi/harnesses/damage-control-continue/version.ts +42 -0
- package/.versions/2.0.14/.pi/harnesses/lib/changed-file-diagnostics.ts +642 -0
- package/.versions/2.0.14/.pi/harnesses/lib/coms-core-io.ts +385 -0
- package/.versions/2.0.14/.pi/harnesses/lib/coms-core.ts +577 -0
- package/.versions/2.0.14/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
- package/.versions/2.0.14/.pi/harnesses/lib/context-budget-child-prompt.ts +219 -0
- package/.versions/2.0.14/.pi/harnesses/lib/context-budget-hub-prompt.ts +116 -0
- package/.versions/2.0.14/.pi/harnesses/lib/context-budget-view.ts +107 -0
- package/.versions/2.0.14/.pi/harnesses/lib/context-budget.ts +114 -0
- package/.versions/2.0.14/.pi/harnesses/lib/damage-control-shared.ts +197 -0
- package/.versions/2.0.14/.pi/harnesses/lib/deterministic-handle-path.ts +23 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fixtures/context-budget-profiles.json +11 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fixtures/hub-prompt-operator.legacy.txt +73 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fixtures/hub-prompt-orchestrator.legacy.txt +73 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fleet-dashboard-ops.ts +178 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fleet-dashboard-view.ts +147 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fleet-detail-view.ts +339 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fleet-overlay.ts +26 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fleet-panel.ts +34 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fleet-read-model.ts +536 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fleet-selection.ts +24 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fleet-strip-controller.ts +75 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fleet-strip-view.ts +179 -0
- package/.versions/2.0.14/.pi/harnesses/lib/fleet-transcript-store.ts +244 -0
- package/.versions/2.0.14/.pi/harnesses/lib/herdr-client.ts +472 -0
- package/.versions/2.0.14/.pi/harnesses/lib/herdr-presence.ts +399 -0
- package/.versions/2.0.14/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
- package/.versions/2.0.14/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
- package/.versions/2.0.14/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
- package/.versions/2.0.14/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
- package/.versions/2.0.14/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
- package/.versions/2.0.14/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
- package/.versions/2.0.14/.pi/harnesses/lib/spawned-peers.js +191 -0
- package/.versions/2.0.14/.pi/harnesses/lib/system1/config.js +61 -0
- package/.versions/2.0.14/.pi/harnesses/lib/system1/contracts.ts +152 -0
- package/.versions/2.0.14/.pi/harnesses/lib/system1/demo.ts +106 -0
- package/.versions/2.0.14/.pi/harnesses/lib/system1/jev.ts +503 -0
- package/.versions/2.0.14/.pi/harnesses/lib/system1/service.ts +245 -0
- package/.versions/2.0.14/.pi/harnesses/lib/update-check.ts +222 -0
- package/.versions/2.0.14/.pi/harnesses/package-lock.json +2039 -0
- package/.versions/2.0.14/.pi/harnesses/package.json +10 -0
- package/.versions/2.0.14/.pi/prompts/af-build.md +24 -0
- package/.versions/2.0.14/.pi/prompts/af-code-simplify.md +22 -0
- package/.versions/2.0.14/.pi/prompts/af-constraints.md +31 -0
- package/.versions/2.0.14/.pi/prompts/af-plan.md +17 -0
- package/.versions/2.0.14/.pi/prompts/af-review.md +16 -0
- package/.versions/2.0.14/.pi/prompts/af-set-hermes-telegram.md +15 -0
- package/.versions/2.0.14/.pi/prompts/af-set-hermes-watchdog.md +6 -0
- package/.versions/2.0.14/.pi/prompts/af-setup-rules.md +20 -0
- package/.versions/2.0.14/.pi/prompts/af-ship.md +17 -0
- package/.versions/2.0.14/.pi/prompts/af-spec.md +15 -0
- package/.versions/2.0.14/.pi/prompts/af-test.md +19 -0
- package/.versions/2.0.14/.pi/skills/bowser/SKILL.md +145 -0
- package/.versions/2.0.14/.version +1 -0
- package/.versions/2.0.14/agents/architect.md +24 -0
- package/.versions/2.0.14/agents/bowser.md +28 -0
- package/.versions/2.0.14/agents/builder.md +55 -0
- package/.versions/2.0.14/agents/code-reviewer.md +209 -0
- package/.versions/2.0.14/agents/deep-researcher.md +32 -0
- package/.versions/2.0.14/agents/documenter.md +22 -0
- package/.versions/2.0.14/agents/orchestrator.md +22 -0
- package/.versions/2.0.14/agents/plan-reviewer.md +83 -0
- package/.versions/2.0.14/agents/planner.md +105 -0
- package/.versions/2.0.14/agents/releaser.md +24 -0
- package/.versions/2.0.14/agents/researcher.md +30 -0
- package/.versions/2.0.14/agents/security-auditor.md +167 -0
- package/.versions/2.0.14/agents/test-engineer.md +153 -0
- package/.versions/2.0.14/agents/web-debugger.md +44 -0
- package/.versions/2.0.14/agents/web-performance-auditor.md +194 -0
- package/.versions/2.0.14/bin/catalog/harness-runtime-closure.json +73 -0
- package/.versions/2.0.14/codex/fleet-session-client/SKILL.md +34 -0
- package/.versions/2.0.14/codex/fleet-session-client.zip +0 -0
- package/.versions/2.0.14/docs/ARCHITECTURE.md +754 -0
- package/.versions/2.0.14/docs/agent-fleet-setup.md +917 -0
- package/.versions/2.0.14/docs/claude-code-coms-bridge.md +134 -0
- package/.versions/2.0.14/docs/codex-session-bridge.md +219 -0
- package/.versions/2.0.14/docs/coms-hermes-bridge.md +188 -0
- package/.versions/2.0.14/docs/getting-started.md +126 -0
- package/.versions/2.0.14/docs/npm-install.md +476 -0
- package/.versions/2.0.14/docs/pi-extensions.md +454 -0
- package/.versions/2.0.14/docs/pi-setup.md +92 -0
- package/.versions/2.0.14/docs/skill-anatomy.md +150 -0
- package/.versions/2.0.14/install-manifest.json +3183 -0
- package/.versions/2.0.14/justfile +247 -0
- package/.versions/2.0.14/manifest-meta.json +1065 -0
- package/.versions/2.0.14/references/accessibility-checklist.md +160 -0
- package/.versions/2.0.14/references/communication-contract.md +26 -0
- package/.versions/2.0.14/references/definition-of-done.md +67 -0
- package/.versions/2.0.14/references/fleet-coordination-patterns.md +171 -0
- package/.versions/2.0.14/references/observability-checklist.md +92 -0
- package/.versions/2.0.14/references/orchestration-patterns.md +370 -0
- package/.versions/2.0.14/references/performance-checklist.md +236 -0
- package/.versions/2.0.14/references/prompting-patterns.md +380 -0
- package/.versions/2.0.14/references/security-checklist.md +245 -0
- package/.versions/2.0.14/references/testing-patterns.md +235 -0
- package/.versions/2.0.14/references/workflow-authoring.md +304 -0
- package/.versions/2.0.14/skills/_internal/grilling.md +59 -0
- package/.versions/2.0.14/skills/browser-testing-with-devtools/SKILL.md +351 -0
- package/.versions/2.0.14/skills/code-review-and-quality/SKILL.md +396 -0
- package/.versions/2.0.14/skills/compound-learning/SKILL.md +137 -0
- package/.versions/2.0.14/skills/constraint-driven-development/SKILL.md +338 -0
- package/.versions/2.0.14/skills/constraint-driven-development/references/floor-guard.md +99 -0
- package/.versions/2.0.14/skills/context-engineering/SKILL.md +341 -0
- package/.versions/2.0.14/skills/deprecation-and-migration/SKILL.md +247 -0
- package/.versions/2.0.14/skills/designing-agents/SKILL.md +394 -0
- package/.versions/2.0.14/skills/designing-agents/pi-harness-authoring.md +222 -0
- package/.versions/2.0.14/skills/drafting-workflows/SKILL.md +143 -0
- package/.versions/2.0.14/skills/drafting-workflows/scripts/make-workflow.ts +177 -0
- package/.versions/2.0.14/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/2.0.14/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/.versions/2.0.14/skills/idea-refine/SKILL.md +182 -0
- package/.versions/2.0.14/skills/idea-refine/examples.md +238 -0
- package/.versions/2.0.14/skills/idea-refine/frameworks.md +99 -0
- package/.versions/2.0.14/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/2.0.14/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/2.0.14/skills/incremental-implementation/SKILL.md +302 -0
- package/.versions/2.0.14/skills/interview-me/SKILL.md +226 -0
- package/.versions/2.0.14/skills/orchestration-verification/SKILL.md +182 -0
- package/.versions/2.0.14/skills/peer-coms/SKILL.md +90 -0
- package/.versions/2.0.14/skills/performance-optimization/SKILL.md +496 -0
- package/.versions/2.0.14/skills/planning-and-task-breakdown/SKILL.md +289 -0
- package/.versions/2.0.14/skills/repository-ai-setup/SKILL.md +117 -0
- package/.versions/2.0.14/skills/repository-ai-setup/references/agent-fleet-ai-state.template.json +4 -0
- package/.versions/2.0.14/skills/repository-ai-setup/references/apply-contract.md +74 -0
- package/.versions/2.0.14/skills/repository-ai-setup/references/provenance-template.md +16 -0
- package/.versions/2.0.14/skills/repository-ai-setup/references/setup-flow.md +108 -0
- package/.versions/2.0.14/skills/repository-ai-setup/references/verify-setup.md +20 -0
- package/.versions/2.0.14/skills/security-and-hardening/SKILL.md +524 -0
- package/.versions/2.0.14/skills/spec-driven-development/SKILL.md +295 -0
- package/.versions/2.0.14/skills/using-agent-skills/SKILL.md +198 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/LICENSE +21 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/README.md +430 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +367 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/constraint-driven-development/SKILL.md +311 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/constraint-driven-development/references/floor-guard.md +99 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +337 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +288 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +238 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +496 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +257 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +524 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +330 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +216 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +245 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +398 -0
- package/.versions/2.0.14/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +192 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/README.md +347 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/gates/gate-o-capability.md +8 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/gates/gate-o-validator-fixtures.json +1 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +773 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-conductor/SKILL.md +84 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-liaison/SKILL.md +84 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/SKILL.md +76 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/manifest.json +1 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
- package/.versions/2.0.15/.pi/agent-fleet/hermes/watchdog-tests/__init__.py +0 -0
- package/.versions/2.0.15/.pi/agent-fleet/hooks/coms-stop-hook.mjs +84 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/claude-code-preflight.ts +70 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/coms-claude-bridge.ts +411 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/coms-cli.ts +425 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/coms-hermes-bridge.ts +413 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/fleet-codex-client.ts +69 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/fleet-codex-read.py +148 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/fleet.ts +217 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/flow.ts +157 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/hermes-monitor-capability-runner.ts +25 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/hermes-monitor-scenario.ts +474 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/hermes-watchdog-capability-probe.ts +45 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/install-hermes-plugin.sh +180 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/claude-bridge-core.ts +210 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/coms-envelope.ts +582 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/fake-herdr-server.ts +88 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/fleet-codex-catalog.ts +63 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/fleet-codex-operations.ts +190 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/fleet-codex-session.ts +166 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/fleet-codex-transport.ts +124 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/fleet-command.ts +252 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/flow-command.ts +98 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/flow-maintenance.ts +230 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/herdr-layout.ts +281 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/hermes-bridge-core.ts +241 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/hermes-monitor-events.ts +1 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/hermes-monitor-herdr.ts +2 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/hermes-monitor-model.ts +3 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/hermes-monitor-registry.ts +2 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/hermes-monitor-socket.ts +2 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/hermes-monitor-store.ts +2 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/monitor-env.ts +146 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/peer-launch.ts +318 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/persona-banner.ts +62 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/persona-dirs.ts +25 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/runtime-dependencies.js +124 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/spawn-stagger.ts +101 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/team-project.ts +178 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/lib/team-snapshot.ts +147 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/package-lock.json +35 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/package.json +9 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/peer-banner.ts +41 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/peer-launch.ts +283 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/team-snapshot.ts +237 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/team-up.ts +378 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/agent-phase.ts +179 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/changes.ts +61 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/debate.ts +149 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/env.ts +34 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/envelopes.ts +169 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/gates.ts +81 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/git.ts +96 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/isolated-snapshot.ts +125 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/merge.ts +95 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/model-profile.ts +22 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/model-visibility.ts +92 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/permissions.ts +130 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/personas.ts +57 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/poll.ts +86 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/project-policy.ts +34 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/quality.ts +64 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/run.ts +108 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/scout-data-boundary.ts +55 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/trace.ts +34 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/voices.ts +128 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/lib/writer-lease.ts +112 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/tsconfig.json +22 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/wf-build-test.ts +61 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/wf-debate.ts +87 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/wf-document.ts +50 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/wf-poll.ts +95 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/wf-quality.ts +20 -0
- package/.versions/2.0.15/.pi/agent-fleet/scripts/workflows/wf-scout.ts +40 -0
- package/.versions/2.0.15/.pi/agents/dispatch-policy.yaml +32 -0
- package/.versions/2.0.15/.pi/agents/model-profiles.yaml +134 -0
- package/.versions/2.0.15/.pi/agents/peers.yaml +147 -0
- package/.versions/2.0.15/.pi/agents/teams.yaml +41 -0
- package/.versions/2.0.15/.pi/agents/voices.yaml +13 -0
- package/.versions/2.0.15/.pi/damage-control-rules.yaml +297 -0
- package/.versions/2.0.15/.pi/extensions/btw/README.md +120 -0
- package/.versions/2.0.15/.pi/extensions/btw/index.ts +914 -0
- package/.versions/2.0.15/.pi/extensions/btw/package.json +6 -0
- package/.versions/2.0.15/.pi/extensions/btw/state.js +179 -0
- package/.versions/2.0.15/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
- package/.versions/2.0.15/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
- package/.versions/2.0.15/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.versions/2.0.15/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.versions/2.0.15/.pi/extensions/compact-and-continue/index.ts +120 -0
- package/.versions/2.0.15/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.versions/2.0.15/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.versions/2.0.15/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.versions/2.0.15/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.versions/2.0.15/.pi/extensions/package-lock.json +1175 -0
- package/.versions/2.0.15/.pi/extensions/package.json +9 -0
- package/.versions/2.0.15/.pi/extensions/pi-voice-stt/README.md +224 -0
- package/.versions/2.0.15/.pi/extensions/pi-voice-stt/config.ts +198 -0
- package/.versions/2.0.15/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
- package/.versions/2.0.15/.pi/extensions/pi-voice-stt/index.ts +248 -0
- package/.versions/2.0.15/.pi/extensions/pi-voice-stt/package.json +6 -0
- package/.versions/2.0.15/.pi/extensions/pi-voice-stt/providers.ts +214 -0
- package/.versions/2.0.15/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/README.md +1448 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/acceptance.ts +199 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/access-approval.ts +135 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/artifacts.js +146 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/assertion-ledger.js +67 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/assist-profile.ts +16 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/backend-policy.js +174 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/bounded-output.ts +26 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/budget-continuation.ts +13 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/budget-recovery.ts +214 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/capability-confirmation.ts +47 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/capability-packs.ts +184 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agent-model-thinking.ts +10 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agent-model.ts +10 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agent-models-substitute.ts +10 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agents-add.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agents-drop.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agents-history.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agents-kill.ts +10 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agents-list.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agents-restart.ts +10 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agents-save.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/agents-team.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/audit.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/budget-continue.ts +10 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/compound.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/coms.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/context-command.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/context.ts +47 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/debate.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/dispatch-policy.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/handoff.ts +10 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/hub-report.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/models.ts +10 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/poll.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/recover.ts +61 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/retry.ts +10 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/task-triage-recover.ts +12 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/task-triage-waive.ts +12 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/watchdog.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/work-mode.ts +29 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/commands/zoom.ts +10 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/config/agents.ts +178 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/config/model-profiles.ts +236 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/config/overrides.ts +160 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/context/agent-state.ts +30 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/context/assertions-artifacts.ts +221 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/context/budgets.ts +206 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/context/hub-state.ts +40 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/context-budget-snapshot.ts +105 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/context-pressure.ts +191 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/context-window.js +108 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/debate-command.ts +176 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/delegate.ts +467 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/deterministic-fs.ts +166 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/diagnostic-probe-extension.ts +26 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/diagnostic-series-budget.ts +178 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-coms.ts +252 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-core.ts +27 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-native-complete.ts +173 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-native-prepare.ts +259 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-native-spawn.ts +231 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-native-types.ts +260 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-native.ts +234 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-observability.ts +225 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-triage-contract.ts +38 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-triage-eval.ts +76 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-triage-policy.ts +29 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-triage-runtime.ts +55 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/dispatch-triage-state.ts +33 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/docs-lane.js +123 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/drift-judge.ts +352 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/drift-runtime.ts +480 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/drift-system1-policy.ts +39 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/drift-system1.ts +469 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/drift-watchdog.js +349 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/evidence-manifest.ts +51 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/execution-evidence.ts +80 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/external-blocker.js +85 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/filesystem-tool.ts +137 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/fixtures/registration-surface.json +64 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/fixtures/t0a-synthetic/catalog.ts +189 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/footer.ts +30 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/helpers.ts +270 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/hub-state-audit.js +65 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/index.ts +2597 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/input/completions.ts +82 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/input/shortcuts.ts +20 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/lifecycle/context-pressure.ts +133 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/lifecycle/monitor-session.ts +104 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/lifecycle/session-orchestration.ts +143 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/lifecycle/turn-handlers.ts +74 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/no-progress.ts +563 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/orchestration-activation.ts +112 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/orchestration-metrics.ts +78 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/orchestration-route.ts +76 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/package.json +7 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/policy/models.ts +153 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/policy/profile-activation.ts +62 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/policy/profile-runtime.ts +120 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/policy/roster.ts +94 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/policy/work-mode.ts +135 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/poll-command.ts +176 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/presentation.ts +48 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-config.ts +40 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-evaluate.ts +138 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-feedback.ts +104 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-findings.ts +115 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-local.ts +88 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-observer.ts +105 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-rules.ts +143 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-runtime.ts +316 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-selection.ts +68 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-snapshot-worker.mjs +12 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-snapshot.ts +243 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/proactive-types.ts +63 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/process-obligations.ts +158 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/prompts/context.ts +54 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/prompts/fragments.ts +116 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/prompts/session-start.ts +90 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/prompts/system-prompt.ts +122 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/reconcile.ts +26 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/recover-policy.ts +44 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/recover-state.ts +104 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/recovery-contract.ts +150 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/rerun-policy.ts +40 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/research/controls.ts +74 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/research/runtime.ts +197 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/research/spawn-run.ts +183 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/return-contract.js +349 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/return-extract.js +77 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/review-closure.ts +43 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/review-findings.js +104 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/routing-observation.ts +41 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/routing-proposal.ts +46 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/run-budget.js +554 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/run-namespace.js +93 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/runtime-test-check.ts +54 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/scope-gate.js +144 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/session-audit.ts +313 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/session-health.js +110 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/session-start.ts +42 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/spawn.ts +534 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/system1-activity.ts +625 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/system1-communication-store.ts +129 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/system1-report.ts +275 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/system1-runtime.ts +280 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-resume-contract.ts +70 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-authorization.ts +122 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-config.ts +37 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-contract.ts +19 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-live-stage-boundary.mjs +49 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-live-stage-closure.user-run.mjs +336 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-obligations.ts +104 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-policy.ts +16 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-review-contract.mjs +43 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-reviewer-only-contract.mjs +156 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-reviewer-only-diagnostics.mjs +112 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-reviewer-only.user-run.mjs +157 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-runtime.ts +125 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-stage-guard.ts +21 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/task-triage-state.ts +46 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/timeline.ts +72 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tool-catalog-runtime.ts +68 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tool-catalog-state.ts +123 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tool-protocol.ts +134 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/action-executors.ts +208 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/coms-tools.ts +139 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/context.ts +144 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/dispatch-agent.ts +88 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/dispatch-execution.ts +558 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/dispatch-triage.ts +16 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/execution-orchestration.ts +22 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/fleet-tools.ts +200 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/herdr-executors.ts +95 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/run-flow.ts +136 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/set-task-tier.ts +31 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/spawn-research.ts +65 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/team-adjust.ts +29 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tools/verification-contract.ts +80 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/tsconfig.json +22 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/types.ts +66 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/activity-dots.ts +25 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/context-budget.ts +87 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/detail-panel.ts +192 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/fleet-actions.ts +78 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/fleet-dashboard.ts +155 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/fleet-editor.ts +44 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/fleet-source.ts +179 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/grid.ts +159 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/history-store.ts +137 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/history.ts +234 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/pool.ts +103 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/running-strip.ts +2 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/system1-communication.ts +59 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/ui/zoom.ts +206 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/unknown-tool-counter.ts +116 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/version.ts +42 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/watchdog-evaluation.ts +110 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/work-mode-controls.ts +56 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/work-mode.ts +179 -0
- package/.versions/2.0.15/.pi/harnesses/agent-hub/write-isolation.ts +187 -0
- package/.versions/2.0.15/.pi/harnesses/ask-user-remote/README.md +59 -0
- package/.versions/2.0.15/.pi/harnesses/ask-user-remote/index.ts +558 -0
- package/.versions/2.0.15/.pi/harnesses/ask-user-remote/questions.ts +161 -0
- package/.versions/2.0.15/.pi/harnesses/ask-user-remote/race-core.js +124 -0
- package/.versions/2.0.15/.pi/harnesses/ask-user-remote/runtime-ask.ts +68 -0
- package/.versions/2.0.15/.pi/harnesses/coms/README.md +100 -0
- package/.versions/2.0.15/.pi/harnesses/coms/index.ts +282 -0
- package/.versions/2.0.15/.pi/harnesses/coms/package.json +7 -0
- package/.versions/2.0.15/.pi/harnesses/coms/version.ts +42 -0
- package/.versions/2.0.15/.pi/harnesses/damage-control-continue/README.md +135 -0
- package/.versions/2.0.15/.pi/harnesses/damage-control-continue/index.ts +550 -0
- package/.versions/2.0.15/.pi/harnesses/damage-control-continue/package.json +7 -0
- package/.versions/2.0.15/.pi/harnesses/damage-control-continue/version.ts +42 -0
- package/.versions/2.0.15/.pi/harnesses/lib/changed-file-diagnostics.ts +642 -0
- package/.versions/2.0.15/.pi/harnesses/lib/coms-core-io.ts +385 -0
- package/.versions/2.0.15/.pi/harnesses/lib/coms-core.ts +577 -0
- package/.versions/2.0.15/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
- package/.versions/2.0.15/.pi/harnesses/lib/context-budget-child-prompt.ts +219 -0
- package/.versions/2.0.15/.pi/harnesses/lib/context-budget-hub-prompt.ts +121 -0
- package/.versions/2.0.15/.pi/harnesses/lib/context-budget-view.ts +107 -0
- package/.versions/2.0.15/.pi/harnesses/lib/context-budget.ts +114 -0
- package/.versions/2.0.15/.pi/harnesses/lib/damage-control-shared.ts +197 -0
- package/.versions/2.0.15/.pi/harnesses/lib/deterministic-handle-path.ts +23 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fixtures/context-budget-profiles.json +11 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fixtures/hub-prompt-operator.legacy.txt +73 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fixtures/hub-prompt-orchestrator.legacy.txt +73 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fleet-dashboard-ops.ts +178 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fleet-dashboard-view.ts +172 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fleet-detail-view.ts +339 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fleet-overlay.ts +26 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fleet-panel.ts +34 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fleet-read-model.ts +609 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fleet-selection.ts +24 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fleet-strip-controller.ts +75 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fleet-strip-view.ts +179 -0
- package/.versions/2.0.15/.pi/harnesses/lib/fleet-transcript-store.ts +244 -0
- package/.versions/2.0.15/.pi/harnesses/lib/herdr-client.ts +472 -0
- package/.versions/2.0.15/.pi/harnesses/lib/herdr-presence.ts +399 -0
- package/.versions/2.0.15/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
- package/.versions/2.0.15/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
- package/.versions/2.0.15/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
- package/.versions/2.0.15/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
- package/.versions/2.0.15/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
- package/.versions/2.0.15/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
- package/.versions/2.0.15/.pi/harnesses/lib/spawned-peers.js +191 -0
- package/.versions/2.0.15/.pi/harnesses/lib/system1/config.js +61 -0
- package/.versions/2.0.15/.pi/harnesses/lib/system1/contracts.ts +152 -0
- package/.versions/2.0.15/.pi/harnesses/lib/system1/demo.ts +104 -0
- package/.versions/2.0.15/.pi/harnesses/lib/system1/jev.ts +503 -0
- package/.versions/2.0.15/.pi/harnesses/lib/system1/selection.js +11 -0
- package/.versions/2.0.15/.pi/harnesses/lib/system1/service.ts +245 -0
- package/.versions/2.0.15/.pi/harnesses/lib/update-check.ts +222 -0
- package/.versions/2.0.15/.pi/harnesses/package-lock.json +2039 -0
- package/.versions/2.0.15/.pi/harnesses/package.json +10 -0
- package/.versions/2.0.15/.pi/prompts/af-build.md +27 -0
- package/.versions/2.0.15/.pi/prompts/af-code-simplify.md +22 -0
- package/.versions/2.0.15/.pi/prompts/af-constraints.md +31 -0
- package/.versions/2.0.15/.pi/prompts/af-plan.md +17 -0
- package/.versions/2.0.15/.pi/prompts/af-review.md +16 -0
- package/.versions/2.0.15/.pi/prompts/af-set-hermes-telegram.md +15 -0
- package/.versions/2.0.15/.pi/prompts/af-set-hermes-watchdog.md +6 -0
- package/.versions/2.0.15/.pi/prompts/af-setup-rules.md +20 -0
- package/.versions/2.0.15/.pi/prompts/af-ship.md +17 -0
- package/.versions/2.0.15/.pi/prompts/af-spec.md +15 -0
- package/.versions/2.0.15/.pi/prompts/af-test.md +19 -0
- package/.versions/2.0.15/.pi/skills/bowser/SKILL.md +145 -0
- package/.versions/2.0.15/.version +1 -0
- package/.versions/2.0.15/agents/architect.md +24 -0
- package/.versions/2.0.15/agents/bowser.md +28 -0
- package/.versions/2.0.15/agents/builder.md +55 -0
- package/.versions/2.0.15/agents/code-reviewer.md +209 -0
- package/.versions/2.0.15/agents/deep-researcher.md +32 -0
- package/.versions/2.0.15/agents/documenter.md +22 -0
- package/.versions/2.0.15/agents/orchestrator.md +22 -0
- package/.versions/2.0.15/agents/plan-reviewer.md +83 -0
- package/.versions/2.0.15/agents/planner.md +105 -0
- package/.versions/2.0.15/agents/releaser.md +24 -0
- package/.versions/2.0.15/agents/researcher.md +30 -0
- package/.versions/2.0.15/agents/security-auditor.md +167 -0
- package/.versions/2.0.15/agents/test-engineer.md +153 -0
- package/.versions/2.0.15/agents/web-debugger.md +44 -0
- package/.versions/2.0.15/agents/web-performance-auditor.md +194 -0
- package/.versions/2.0.15/bin/catalog/harness-runtime-closure.json +73 -0
- package/.versions/2.0.15/codex/fleet-session-client/SKILL.md +34 -0
- package/.versions/2.0.15/codex/fleet-session-client.zip +0 -0
- package/.versions/2.0.15/docs/ARCHITECTURE.md +829 -0
- package/.versions/2.0.15/docs/agent-fleet-setup.md +1090 -0
- package/.versions/2.0.15/docs/claude-code-coms-bridge.md +134 -0
- package/.versions/2.0.15/docs/codex-session-bridge.md +219 -0
- package/.versions/2.0.15/docs/coms-hermes-bridge.md +188 -0
- package/.versions/2.0.15/docs/getting-started.md +126 -0
- package/.versions/2.0.15/docs/npm-install.md +525 -0
- package/.versions/2.0.15/docs/pi-extensions.md +454 -0
- package/.versions/2.0.15/docs/pi-setup.md +92 -0
- package/.versions/2.0.15/docs/skill-anatomy.md +150 -0
- package/.versions/2.0.15/install-manifest.json +3193 -0
- package/.versions/2.0.15/justfile +247 -0
- package/.versions/2.0.15/manifest-meta.json +1071 -0
- package/.versions/2.0.15/references/accessibility-checklist.md +160 -0
- package/.versions/2.0.15/references/communication-contract.md +26 -0
- package/.versions/2.0.15/references/definition-of-done.md +67 -0
- package/.versions/2.0.15/references/fleet-coordination-patterns.md +171 -0
- package/.versions/2.0.15/references/observability-checklist.md +92 -0
- package/.versions/2.0.15/references/orchestration-patterns.md +370 -0
- package/.versions/2.0.15/references/performance-checklist.md +236 -0
- package/.versions/2.0.15/references/prompting-patterns.md +380 -0
- package/.versions/2.0.15/references/security-checklist.md +245 -0
- package/.versions/2.0.15/references/testing-patterns.md +235 -0
- package/.versions/2.0.15/references/workflow-authoring.md +304 -0
- package/.versions/2.0.15/skills/_internal/grilling.md +59 -0
- package/.versions/2.0.15/skills/browser-testing-with-devtools/SKILL.md +351 -0
- package/.versions/2.0.15/skills/code-review-and-quality/SKILL.md +396 -0
- package/.versions/2.0.15/skills/compound-learning/SKILL.md +137 -0
- package/.versions/2.0.15/skills/constraint-driven-development/SKILL.md +338 -0
- package/.versions/2.0.15/skills/constraint-driven-development/references/floor-guard.md +99 -0
- package/.versions/2.0.15/skills/context-engineering/SKILL.md +341 -0
- package/.versions/2.0.15/skills/deprecation-and-migration/SKILL.md +247 -0
- package/.versions/2.0.15/skills/designing-agents/SKILL.md +394 -0
- package/.versions/2.0.15/skills/designing-agents/pi-harness-authoring.md +222 -0
- package/.versions/2.0.15/skills/drafting-workflows/SKILL.md +143 -0
- package/.versions/2.0.15/skills/drafting-workflows/scripts/make-workflow.ts +177 -0
- package/.versions/2.0.15/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/2.0.15/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/.versions/2.0.15/skills/idea-refine/SKILL.md +182 -0
- package/.versions/2.0.15/skills/idea-refine/examples.md +238 -0
- package/.versions/2.0.15/skills/idea-refine/frameworks.md +99 -0
- package/.versions/2.0.15/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/2.0.15/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/2.0.15/skills/incremental-implementation/SKILL.md +353 -0
- package/.versions/2.0.15/skills/interview-me/SKILL.md +226 -0
- package/.versions/2.0.15/skills/orchestration-verification/SKILL.md +182 -0
- package/.versions/2.0.15/skills/peer-coms/SKILL.md +90 -0
- package/.versions/2.0.15/skills/performance-optimization/SKILL.md +496 -0
- package/.versions/2.0.15/skills/planning-and-task-breakdown/SKILL.md +318 -0
- package/.versions/2.0.15/skills/repository-ai-setup/SKILL.md +117 -0
- package/.versions/2.0.15/skills/repository-ai-setup/references/agent-fleet-ai-state.template.json +4 -0
- package/.versions/2.0.15/skills/repository-ai-setup/references/apply-contract.md +74 -0
- package/.versions/2.0.15/skills/repository-ai-setup/references/provenance-template.md +16 -0
- package/.versions/2.0.15/skills/repository-ai-setup/references/setup-flow.md +108 -0
- package/.versions/2.0.15/skills/repository-ai-setup/references/verify-setup.md +20 -0
- package/.versions/2.0.15/skills/security-and-hardening/SKILL.md +524 -0
- package/.versions/2.0.15/skills/spec-driven-development/SKILL.md +295 -0
- package/.versions/2.0.15/skills/using-agent-skills/SKILL.md +198 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/LICENSE +21 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/README.md +430 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +367 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/constraint-driven-development/SKILL.md +311 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/constraint-driven-development/references/floor-guard.md +99 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +337 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +288 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +238 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +496 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +257 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +524 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +330 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +216 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +245 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +398 -0
- package/.versions/2.0.15/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +192 -0
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/agents/builder.md +2 -2
- package/bin/cli.js +16 -2
- package/bin/lib/apply.js +5 -0
- package/bin/lib/doctor.js +85 -12
- package/bin/lib/reconcile.js +9 -1
- package/bin/lib/state.js +1 -0
- package/bin/lib/task-triage-setup.js +76 -0
- package/bin/lib/transaction.js +4 -0
- package/docs/ARCHITECTURE.md +100 -24
- package/docs/agent-fleet-setup.md +196 -6
- package/docs/npm-install.md +72 -15
- package/docs/pi-extensions.md +1 -1
- package/install-manifest.json +21 -3
- package/manifest-meta.json +14 -0
- package/package.json +11 -3
- package/skills/incremental-implementation/SKILL.md +64 -13
- package/skills/planning-and-task-breakdown/SKILL.md +43 -14
- package/skills/using-agent-skills/SKILL.md +2 -2
|
@@ -0,0 +1,2370 @@
|
|
|
1
|
+
import { registerDispatchTriage } from "./tools/dispatch-triage.ts";
|
|
2
|
+
import { createTriageRuntime } from "./dispatch-triage-runtime.ts";
|
|
3
|
+
import { parseTriageConfig, type TriageInput } from "./dispatch-triage-contract.ts";
|
|
4
|
+
import { createCommunicationStore } from "./system1-communication-store.ts";
|
|
5
|
+
import { openSystem1Communication } from "./ui/system1-communication.ts";
|
|
6
|
+
import { registerRetry } from "./commands/retry.ts";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { loadProactiveConfig, isCaptureEnabled } from "./proactive-config.ts";
|
|
9
|
+
import { createProactiveRuntime, createHubCapture, composeHubProactive } from "./proactive-runtime.ts";
|
|
10
|
+
import type { ProactiveConfig } from "./proactive-types.ts";
|
|
11
|
+
import { registerRecover, runRecoverCommand } from "./commands/recover.ts";
|
|
12
|
+
import { createNoProgressGuard } from "./no-progress.ts";
|
|
13
|
+
import { renderNextInvocation, renderRecoverCommands } from './recover-policy.ts';
|
|
14
|
+
import { closeEvidenceSession, pruneEvidenceSessions } from "./execution-evidence.ts";
|
|
15
|
+
import { hasExplicitDispatcher, isCompleteProfile, dispatcherSelection, type ModelProfiles } from './config/model-profiles.ts';
|
|
16
|
+
import { createProfileActivation } from './policy/profile-activation.ts';
|
|
17
|
+
import { readActiveProfile, profileWorkInFlight, withProfileWork, assertProfileModel, profilePeerGate } from './policy/profile-runtime.ts';
|
|
18
|
+
import { resolveAssist } from './assist-profile.ts';
|
|
19
|
+
import { registerFilesystemTool } from './filesystem-tool.ts';
|
|
20
|
+
/** Agent Hub composition root: constructs mutable state, contexts, registrars, and ordered lifecycle ports. */
|
|
21
|
+
|
|
22
|
+
import type { AgentDef, AgentState, ResearchState } from "./types.ts";
|
|
23
|
+
import { DEFAULT_OVERRIDES, THINKING_LEVELS, parseAgentTeamOverrides, type AgentTeamOverrides } from "./config/overrides.ts";
|
|
24
|
+
import { loadAgentConfiguration } from "./config/agents.ts";
|
|
25
|
+
import { abbrevThinking, displayName, extractAskUserQuestions, extractNeedsResearch, resolveDelegateExtension, resolveThinkingLevel } from "./presentation.ts";
|
|
26
|
+
import { MAX_LIVE_ENTRY_CHARS, appendTimelineEvent, appendTimelineText, flushTimelineStore } from "./timeline.ts";
|
|
27
|
+
import type { ExtensionAPI, ExtensionContext, Theme } from "@mariozechner/pi-coding-agent";
|
|
28
|
+
import { DynamicBorder, getMarkdownTheme as getPiMdTheme, copyToClipboard } from "@mariozechner/pi-coding-agent";
|
|
29
|
+
import {
|
|
30
|
+
Text, Box, Container, Spacer, Markdown, matchesKey, Key,
|
|
31
|
+
type AutocompleteItem, truncateToWidth, visibleWidth,
|
|
32
|
+
} from "@mariozechner/pi-tui";
|
|
33
|
+
import { spawn, type ChildProcess } from "child_process";
|
|
34
|
+
import { spawnPiAgent, spawnPiAgentWithModelFallback, killPiTree, type Termination } from "./spawn.ts";
|
|
35
|
+
import { fenceOperatorCancel } from "./drift-runtime.ts";
|
|
36
|
+
import { researchTerminationOutcome, researchWatchdogSpawnOptions } from "./research-watchdog.ts";
|
|
37
|
+
import { composeFleetFooterHint, renderHubFooterLeft } from "./footer.ts";
|
|
38
|
+
import { HARNESS_VERSION, registerVersionStatus } from "./version.ts";
|
|
39
|
+
import { cancelLocalOwnedProcess, cancelLocalWaitOnly, monitorKeyForAgent } from "./monitor-control.ts";
|
|
40
|
+
import { createMonitorLifecycle } from "./monitor-lifecycle.ts";
|
|
41
|
+
import { createMonitorSessionBridge } from "./monitor-session-bridge.ts";
|
|
42
|
+
import {
|
|
43
|
+
AGENT_ID_ENV, ASK_ENDPOINT_ENV, EXEMPTIONS_FILE_ENV,
|
|
44
|
+
exemptionsFilePath, type AccessRequest,
|
|
45
|
+
} from "../lib/damage-control-shared.ts";
|
|
46
|
+
import { applyModelOverride, clampDelegateDepth, fallbackModelFor, isReadOnlyToolList, MAX_DELEGATE_DEPTH, normalizeAgentInput, orchestratorNeedsRoster, parseTeamsYaml, safeAgentKey, safePathWithin, taskFingerprint, upsertTeamInYaml } from "./helpers.ts";
|
|
47
|
+
import { DEFAULT_TASK_TIER, addTaskClockWait, applyTierChange, blockingFindingCap, checkReviewRoundCap, checkTaskBudget, checkTierPersonaGate, checkTurnBudget, createTaskClock, isReviewPersona, openTaskClock, remainingTaskResearch, reviewBudgetClause, reviewRoundCap } from "./run-budget.js";
|
|
48
|
+
import { countReviewFindings, findingBudgetNotice } from "./review-findings.js";
|
|
49
|
+
import { checkDocsLane, docsLaneNotice } from "./docs-lane.js";
|
|
50
|
+
import { checkExternalBlockerGate, extractExternalBlockers } from "./external-blocker.js";
|
|
51
|
+
import { DEFAULT_RUN_HISTORY_KEEP, normalizeRunHistoryKeep } from "./run-namespace.js";
|
|
52
|
+
import { validateAssertionBatch } from "./assertion-ledger.js";
|
|
53
|
+
import { DEFAULT_PROVIDER_LIMITS, createProviderSemaphore, parseProviderLimits } from "./provider-semaphore.js";
|
|
54
|
+
import {
|
|
55
|
+
PANE_PROMPT_TIMEOUT_MS,
|
|
56
|
+
launchPeerInPane,
|
|
57
|
+
peerReadyVerdict,
|
|
58
|
+
unaddressedPeerSweep,
|
|
59
|
+
} from "../lib/spawned-peers.js";
|
|
60
|
+
import { contextPct, estimatePromptTokens, resolveContextWindow } from "./context-window.js";
|
|
61
|
+
import { DEFAULT_WATCHDOG_SETTING, WATCHDOG_SETTINGS, normalizeWatchdogSetting, resolveWatchdogActive } from "./drift-watchdog.js";
|
|
62
|
+
import { createWatchdogActivity, type WatchdogActivity } from "./system1-activity.ts";
|
|
63
|
+
import { createWatchdogSystem1Session, disposeWatchdogSystem1Session, readWatchdogSystem1Snapshot, type WatchdogSystem1Session } from "./system1-runtime.ts";
|
|
64
|
+
import { shouldExtractReturn } from "./return-extract.js";
|
|
65
|
+
import { crossCheck, deliveryDisposition, extractAssertionIds, parseDeliveredReturn } from "./return-contract.js";
|
|
66
|
+
import { checkScope, diffAgainst, snapshotWorktree, worktreeRevision } from "./scope-gate.js";
|
|
67
|
+
import { validateEvidence } from "./evidence-rules.js";
|
|
68
|
+
import { comsRequiredRefusal, explicitComsRefusal, parseDispatchPolicy, resolveDispatchBackend } from "./backend-policy.js";
|
|
69
|
+
import { NATIVE_ROSTER_ENTRY_TYPE, persistedNativeRosterState, resolveSessionWorkMode, resolveSessionRoster, type WorkMode } from "./work-mode.ts";
|
|
70
|
+
import { compactWorkMode } from "./work-mode-controls.ts";
|
|
71
|
+
import { registerWorkMode } from "./commands/work-mode.ts";
|
|
72
|
+
import { registerAgentsTeam } from "./commands/agents-team.ts";
|
|
73
|
+
import { registerAgentsList } from "./commands/agents-list.ts";
|
|
74
|
+
import { registerAgentsHistory } from "./commands/agents-history.ts";
|
|
75
|
+
import { registerAgentsAdd } from "./commands/agents-add.ts";
|
|
76
|
+
import { registerAgentsDrop } from "./commands/agents-drop.ts";
|
|
77
|
+
import { registerAgentsSave } from "./commands/agents-save.ts";
|
|
78
|
+
import { registerAgentsKill } from "./commands/agents-kill.ts";
|
|
79
|
+
import { registerAgentsRestart } from "./commands/agents-restart.ts";
|
|
80
|
+
import { registerContextCommand } from "./commands/context-command.ts";
|
|
81
|
+
import { registerAudit } from "./commands/audit.ts";
|
|
82
|
+
import { showSessionAudit } from "./session-audit.ts";
|
|
83
|
+
import { buildWatchdogReport, buildProactiveReport, commandProactiveLabels, readProactiveReport, formatWatchdogStatus, readWatchdogEvents } from "./system1-report.ts";
|
|
84
|
+
import { createProcessState, processAllowsPersona, evaluateProcessObligations, latestProcessState, processAuditRecord, processPreEffectGate, type ProcessObligationState, type ProcessVerdict } from "./process-obligations.ts";
|
|
85
|
+
import { registerHubReport } from "./commands/hub-report.ts";
|
|
86
|
+
import { registerZoom } from "./commands/zoom.ts";
|
|
87
|
+
import { registerDispatchPolicy } from "./commands/dispatch-policy.ts";
|
|
88
|
+
import { registerAgentModel } from "./commands/agent-model.ts";
|
|
89
|
+
import { registerAgentModelThinking } from "./commands/agent-model-thinking.ts";
|
|
90
|
+
import { registerModels } from "./commands/models.ts";
|
|
91
|
+
import { registerAgentModelsSubstitute } from "./commands/agent-models-substitute.ts";
|
|
92
|
+
import { registerWatchdog } from "./commands/watchdog.ts";
|
|
93
|
+
import { registerComs } from "./commands/coms.ts";
|
|
94
|
+
import { registerHandoff } from "./commands/handoff.ts";
|
|
95
|
+
import { registerCompound } from "./commands/compound.ts";
|
|
96
|
+
import { registerPoll } from "./commands/poll.ts";
|
|
97
|
+
import { registerDebate } from "./commands/debate.ts";
|
|
98
|
+
import type { CommandContext } from "./commands/context.ts";
|
|
99
|
+
import { formatAfPollStarted, formatAfPollVoiceProgress, handleAfPoll } from "./poll-command.ts";
|
|
100
|
+
import { formatAfDebateStarted, formatAfDebateVoiceProgress, handleAfDebate } from "./debate-command.ts";
|
|
101
|
+
import { registerDispatchAgent } from "./tools/dispatch-agent.ts";
|
|
102
|
+
import { registerSpawnResearch } from "./tools/spawn-research.ts";
|
|
103
|
+
import { registerRunFlow } from "./tools/run-flow.ts";
|
|
104
|
+
import { resolvePersona as resolveFlowPersona } from "../../agent-fleet/scripts/workflows/lib/personas.ts";
|
|
105
|
+
import { assertProfileModel as assertFlowProfileModel } from "../../agent-fleet/scripts/workflows/lib/model-profile.ts";
|
|
106
|
+
import { registerSetTaskTier } from "./tools/set-task-tier.ts";
|
|
107
|
+
import { registerTeamAdjust } from "./tools/team-adjust.ts";
|
|
108
|
+
import { registerVerificationContract } from "./tools/verification-contract.ts";
|
|
109
|
+
import { registerComsTools } from "./tools/coms-tools.ts";
|
|
110
|
+
import { paneTail, peerManifest, peerPersonaExists, registerFleetTools, spawnDelaySeconds, STAGGER_ENV_VAR, waitForPeerRegistration } from "./tools/fleet-tools.ts";
|
|
111
|
+
import type { ToolContext } from "./tools/context.ts";
|
|
112
|
+
import { createToolExecutionOrchestration } from "./tools/execution-orchestration.ts";
|
|
113
|
+
import { latestPersistedCapabilityState, type ContextState, type PendingOperation } from "./capability-packs.ts";
|
|
114
|
+
import { contextPressureDiagnostic, createContextPressureState, transitionContextPressure, type ContextPressureState } from "./context-pressure.ts";
|
|
115
|
+
import { confirmationOutcome, capabilityConfirmationPack, capabilityConfirmationQuestion, type ConfirmableCapabilityPack } from "./capability-confirmation.ts";
|
|
116
|
+
import { confirmRecoverAction, confirmTaskSupersession, createBudgetRecovery, createReservedTaskIdentityReset } from "./budget-recovery.ts";
|
|
117
|
+
import { requestRuntimeAsk } from "../ask-user-remote/runtime-ask.ts";
|
|
118
|
+
import { registerBudgetContinue } from "./commands/budget-continue.ts";
|
|
119
|
+
import { observeAskUserResults } from "../ask-user-remote/index.ts";
|
|
120
|
+
import { handleQuestionEnvelope, registerQuestionPeer } from "../ask-user-remote/questions.ts";
|
|
121
|
+
import { buildHubPeerSpawnPlan, launchHubPeerInPane } from "./peer-spawn-plan.ts";
|
|
122
|
+
import { RESEARCH_TOOLS, createResearchRuntime, parseResearchHandle } from "./research/runtime.ts";
|
|
123
|
+
import { requireSafetyHarness, resolveSafetyHarness } from "./safety-routing.ts";
|
|
124
|
+
import { createAccessApprovalRouter } from "./access-approval.ts";
|
|
125
|
+
import { readdirSync, readFileSync, existsSync, mkdirSync, unlinkSync, writeFileSync, rmSync } from "fs";
|
|
126
|
+
import { herdrPaneId } from "../lib/herdr-presence.ts";
|
|
127
|
+
import { herdr as herdrApi, herdrAvailable } from "../lib/herdr-client.ts";
|
|
128
|
+
import {
|
|
129
|
+
abbreviateModel,
|
|
130
|
+
createComsPeer,
|
|
131
|
+
hexFg,
|
|
132
|
+
nowIso,
|
|
133
|
+
readAllRegistryEntries,
|
|
134
|
+
readAllRegistryEntriesAcrossProjects,
|
|
135
|
+
type ComsIdentity,
|
|
136
|
+
type RegistryEntry as ComsRegistryEntry,
|
|
137
|
+
TIMEOUT_MS,
|
|
138
|
+
} from "../lib/coms-core.ts";
|
|
139
|
+
import { createGridUI } from "./ui/grid.ts";
|
|
140
|
+
import { createFleetSource } from "./ui/fleet-source.ts";
|
|
141
|
+
import { buildFleetRows } from "../lib/fleet-read-model.ts";
|
|
142
|
+
import { createFleetActions } from "./ui/fleet-actions.ts";
|
|
143
|
+
import { createDetailPanel } from "./ui/detail-panel.ts";
|
|
144
|
+
import { createFleetDashboard } from "./ui/fleet-dashboard.ts";
|
|
145
|
+
import { createContextBudgetUi } from "./ui/context-budget.ts";
|
|
146
|
+
import { createPoolPresentation } from "./ui/pool.ts";
|
|
147
|
+
import { registerInputShortcuts } from "./input/shortcuts.ts";
|
|
148
|
+
import { createCompletionPresentation } from "./input/completions.ts";
|
|
149
|
+
import { createResearchControls } from "./research/controls.ts";
|
|
150
|
+
import { createContextPressureLifecycle, createContextPressureRootState } from "./lifecycle/context-pressure.ts";
|
|
151
|
+
import { createTurnLifecycleHandlers, registerTurnPresence } from "./lifecycle/turn-handlers.ts";
|
|
152
|
+
import { createMonitorSession } from "./lifecycle/monitor-session.ts";
|
|
153
|
+
import { applySessionOverrides, registerSessionOrchestration, resetHubSession } from "./lifecycle/session-orchestration.ts";
|
|
154
|
+
import { openZoom, type TimelineEntry, type Zoomable } from "./ui/zoom.ts";
|
|
155
|
+
import { openHistory } from "./ui/history.ts";
|
|
156
|
+
import { createExecutionHistoryStore, type HistoryEntry } from "./ui/history-store.ts";
|
|
157
|
+
import { createDispatchComs, createDispatchNative, createDispatchObservability, type DelegationChild } from "./dispatch-core.ts";
|
|
158
|
+
import type { FleetRow } from "../lib/fleet-read-model.ts";
|
|
159
|
+
import { gridColumnsForSize } from "../lib/fleet-dashboard-ops.ts";
|
|
160
|
+
import { createFleetTranscriptStore } from "../lib/fleet-transcript-store.ts";
|
|
161
|
+
import type { ContextBudgetComponent } from "../lib/context-budget.ts";
|
|
162
|
+
import { buildHubSystemPrompt as assembleHubPrompt } from "./prompts/system-prompt.ts";
|
|
163
|
+
import type { HubPromptContext } from "./prompts/context.ts";
|
|
164
|
+
import { buildSessionStartNotice, createSessionFooter } from "./prompts/session-start.ts";
|
|
165
|
+
import { registerSessionStart } from "./session-start.ts";
|
|
166
|
+
import { createHubStateContext } from "./context/hub-state.ts";
|
|
167
|
+
import { createAgentStateFactory } from "./context/agent-state.ts";
|
|
168
|
+
import { createBudgetContext, createSessionTotals, freshTurnReport, type TurnReport } from "./context/budgets.ts";
|
|
169
|
+
import { createAssertionsArtifactsContext, type Assertion, type InputArtifactPreview } from "./context/assertions-artifacts.ts";
|
|
170
|
+
import { createModelPolicy } from "./policy/models.ts";
|
|
171
|
+
import { createRosterPolicy } from "./policy/roster.ts";
|
|
172
|
+
import { createWorkModePolicy } from "./policy/work-mode.ts";
|
|
173
|
+
import { catalogSnapshot, latestPersistedToolCatalog, toolCatalogNotice, TOOL_CATALOG_ENTRY_TYPE, type ToolCatalogDelta } from "./tool-catalog-state.ts";
|
|
174
|
+
import { createToolCatalogRuntime } from "./tool-catalog-runtime.ts";
|
|
175
|
+
import { createUnknownToolCounter, latestPersistedUnknownToolCounter, observeUnknownToolCalls, restoreUnknownToolCounter, unknownToolNotice, UNKNOWN_TOOL_COUNTER_ENTRY_TYPE } from "./unknown-tool-counter.ts";
|
|
176
|
+
import { buildProjectDocsProtocol, buildProjectRulesProtocol, nativeResearchSystemPrompt } from "../lib/context-budget-child-prompt.ts";
|
|
177
|
+
import { parseEnvFile, resolveEnvFilePath } from "../../agent-fleet/scripts/lib/herdr-layout.ts";
|
|
178
|
+
import { worktreeTag } from "../../agent-fleet/scripts/lib/team-project.ts";
|
|
179
|
+
import { join, resolve } from "path";
|
|
180
|
+
import * as fs from "node:fs";
|
|
181
|
+
import * as path from "node:path";
|
|
182
|
+
import * as crypto from "node:crypto";
|
|
183
|
+
|
|
184
|
+
// ── Extension ────────────────────────────────────
|
|
185
|
+
|
|
186
|
+
const CONTEXT_WARN_THRESHOLD = 70;
|
|
187
|
+
const RESEARCHER_PERSONAS = new Set(["researcher", "deep-researcher"]);
|
|
188
|
+
|
|
189
|
+
export default function (pi: ExtensionAPI) {
|
|
190
|
+
// ── Embedded coms: identity CLI flags ──
|
|
191
|
+
// Registered here (factory load time) so pi's CLI parser accepts them. Because
|
|
192
|
+
// coms is EMBEDDED (one extension, not a second `-e`), these register exactly once.
|
|
193
|
+
pi.registerFlag("name", { description: "Coms: override agent name (else frontmatter or auto-generated)", type: "string", default: undefined });
|
|
194
|
+
pi.registerFlag("purpose", { description: "Coms: override agent purpose (else frontmatter description)", type: "string", default: undefined });
|
|
195
|
+
pi.registerFlag("project", { description: "Coms: project namespace for peer discovery", type: "string", default: "default" });
|
|
196
|
+
pi.registerFlag("color", { description: "Coms: hex color #RRGGBB (else frontmatter or palette fallback)", type: "string", default: undefined });
|
|
197
|
+
pi.registerFlag("explicit", { description: "Coms: hide from auto-discovery; addressable only by exact name", type: "boolean", default: false });
|
|
198
|
+
pi.registerFlag("solo", { description: "Run without the coms layer (fixed specialists + research only — `just fleet hub --solo`)", type: "boolean", default: false });
|
|
199
|
+
pi.registerFlag("work-mode", { description: "Fleet main-agent work mode: operator|orchestrator", type: "string", default: undefined });
|
|
200
|
+
pi.registerFlag("agent-team", { description: "Internal: activate a named native roster from .pi/agents/teams.yaml", type: "string", default: undefined });
|
|
201
|
+
|
|
202
|
+
// ── Embedded coms: shared peer state ──
|
|
203
|
+
let currentCtx: ExtensionContext | null = null;
|
|
204
|
+
let refreshFleetUi = () => {};
|
|
205
|
+
const coms = createComsPeer({
|
|
206
|
+
pi,
|
|
207
|
+
getContext: () => currentCtx,
|
|
208
|
+
onPeersChanged: () => refreshFleetUi(),
|
|
209
|
+
acceptInbound: () => currentCtx && modelWorkBlockedByRosterRecovery(currentCtx)
|
|
210
|
+
? "orchestrator roster recovery required"
|
|
211
|
+
: null,
|
|
212
|
+
handleCustomEnvelope: (socket, envelope) => {
|
|
213
|
+
if (handleQuestionEnvelope(socket, envelope)) return true;
|
|
214
|
+
if (envelope.type !== "access_request") return false;
|
|
215
|
+
void accessApprovalRouter.handle(socket, envelope as AccessRequest);
|
|
216
|
+
return true;
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
const unregisterQuestions = registerQuestionPeer(() => coms.ready && coms.identity ? {
|
|
220
|
+
project: coms.identity.project, peer: coms.identity.name,
|
|
221
|
+
sessionId: coms.identity.session_id, startedAt: coms.identity.started_at,
|
|
222
|
+
} : null);
|
|
223
|
+
let identity: ComsIdentity | null = null;
|
|
224
|
+
const peerCards = coms.peerCards;
|
|
225
|
+
const pendingReplies = coms.pendingReplies;
|
|
226
|
+
const inboundQueue = coms.inboundQueue;
|
|
227
|
+
let comsReady = false;
|
|
228
|
+
let monitorLifecycle: ReturnType<typeof createMonitorLifecycle> | null = null;
|
|
229
|
+
let monitorHubId: string | null = null;
|
|
230
|
+
let monitorTurnId: string | null = null;
|
|
231
|
+
let monitorBridge: ReturnType<typeof createMonitorSessionBridge> | null = null;
|
|
232
|
+
let monitorOwnerId: string | undefined;
|
|
233
|
+
|
|
234
|
+
// ── Damage-control exemptions + access escalation state ──
|
|
235
|
+
// exemptionsFile is the session-scoped shared exemptions file: /af-allow
|
|
236
|
+
// session grants (via the co-loaded damage-control-continue) and approved
|
|
237
|
+
// escalations land here, and spawned children read it through the
|
|
238
|
+
// AGENT_HUB_EXEMPTIONS_FILE env plumbing.
|
|
239
|
+
let exemptionsFile: string | null = null;
|
|
240
|
+
const accessApprovalRouter = createAccessApprovalRouter({
|
|
241
|
+
getContext: () => currentCtx,
|
|
242
|
+
getExemptionsFile: () => exemptionsFile,
|
|
243
|
+
appendLog: (entry) => { try { pi.appendEntry("damage-control-log", entry); } catch { /* best-effort */ } },
|
|
244
|
+
now: nowIso,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
const agentStates: Map<string, AgentState> = new Map();
|
|
248
|
+
// Live-only research helpers, keyed by numeric id (handle `rN`). Visible in the
|
|
249
|
+
// Fleet Dashboard (Alt+A) while running; evicted from this map on every terminal
|
|
250
|
+
// outcome. Session/transcript/findings files and /af-agents-history survive.
|
|
251
|
+
let researchStates: Map<number, ResearchState> = new Map();
|
|
252
|
+
// Metadata only: prompt text is never retained by this ledger.
|
|
253
|
+
let lastHubLedger: ContextBudgetComponent[] = [];
|
|
254
|
+
let nextResearchId = 1;
|
|
255
|
+
|
|
256
|
+
// ── Execution history (/af-agents-history) ──────────
|
|
257
|
+
// The typed store owns entries and turn/ask_user bookkeeping; index.ts owns
|
|
258
|
+
// composition and wires lifecycle events to its explicit API.
|
|
259
|
+
const executionHistory = createExecutionHistoryStore();
|
|
260
|
+
|
|
261
|
+
let researchPersonas: AgentDef[] = [];
|
|
262
|
+
let allAgentDefs: AgentDef[] = [];
|
|
263
|
+
let teams: Record<string, string[]> = {};
|
|
264
|
+
// Named model profiles from .pi/agents/model-profiles.yaml (validated at
|
|
265
|
+
// session start) and the session-lifetime per-persona model overrides set by
|
|
266
|
+
// /af-agent-model and /af-models (lowercase persona name → pi model spec). Overrides
|
|
267
|
+
// reset on session_start; profiles make re-applying cheap.
|
|
268
|
+
let modelProfiles: ModelProfiles = {};
|
|
269
|
+
let modelProfileErrors: string[] = [];
|
|
270
|
+
// Backend routing policy (.pi/agents/dispatch-policy.yaml): per dispatch, a
|
|
271
|
+
// member preferring coms is served by a live same-name pool peer instead of a
|
|
272
|
+
// native subagent spawn. Missing file → everything native (status quo).
|
|
273
|
+
let dispatchPolicy: {
|
|
274
|
+
default: string;
|
|
275
|
+
grace_s: number;
|
|
276
|
+
substitutions: Record<string, { prefer: string; fallback: string; timeout_s?: number }>;
|
|
277
|
+
} = { default: "native", grace_s: 30, substitutions: {} };
|
|
278
|
+
let dispatchPolicyWarnings: string[] = [];
|
|
279
|
+
// One "coms peer missing → native" notice per member per team activation.
|
|
280
|
+
const comsMissNotified = new Set<string>();
|
|
281
|
+
|
|
282
|
+
let activeTeamName = "";
|
|
283
|
+
let gridCols = 2;
|
|
284
|
+
let widgetCtx: any;
|
|
285
|
+
let sessionDir = "";
|
|
286
|
+
let contextWindow = 0;
|
|
287
|
+
// Per-provider in-flight cap for the hub's OWN spawns (specialists and
|
|
288
|
+
// research helpers, which the dispatcher can start in parallel). Delegate
|
|
289
|
+
// children are gated by the same policy inside their parent's process. The
|
|
290
|
+
// drift judge and the return extractor are deliberately NOT gated: both run
|
|
291
|
+
// while a specialist holds a permit, so queueing them behind that specialist
|
|
292
|
+
// would stall the very watchdog that is supposed to stop it.
|
|
293
|
+
const providerSemaphore = createProviderSemaphore({
|
|
294
|
+
...DEFAULT_PROVIDER_LIMITS,
|
|
295
|
+
...parseProviderLimits(process.env.AGENT_HUB_PROVIDER_LIMITS),
|
|
296
|
+
});
|
|
297
|
+
/**
|
|
298
|
+
* pi's model registry as a plain lookup — the documented source for every
|
|
299
|
+
* model's window, and the same one the dispatcher's own window comes from.
|
|
300
|
+
*/
|
|
301
|
+
function modelWindowLookup(ctx: any): (provider: string, modelId: string) => any {
|
|
302
|
+
return (provider, modelId) => ctx?.modelRegistry?.find?.(provider, modelId);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Say so when a run is about to wait on a provider permit, not just hang. */
|
|
306
|
+
function notifyProviderQueue(model: string, label: string, ctx: any): void {
|
|
307
|
+
const cap = providerSemaphore.limitFor(model);
|
|
308
|
+
if (cap == null || providerSemaphore.inFlight(model) < cap) return;
|
|
309
|
+
const ahead = providerSemaphore.queued(model) + 1;
|
|
310
|
+
ctx?.ui?.notify(
|
|
311
|
+
`${label}: queued — ${cap} requests already in flight on this provider (${ahead} waiting). ` +
|
|
312
|
+
"Raise or disable the cap with AGENT_HUB_PROVIDER_LIMITS (e.g. custom=4, custom=off).",
|
|
313
|
+
"info",
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
let activeWritableDispatches = 0;
|
|
318
|
+
let writableOverlapCounter = 0;
|
|
319
|
+
let pendingHandoff: { target: string; token: string } | null = null;
|
|
320
|
+
const hubStateCtx = createHubStateContext({
|
|
321
|
+
getCurrentContext: () => currentCtx, setCurrentContext: value => { currentCtx = value; },
|
|
322
|
+
getExemptionsFile: () => exemptionsFile, setExemptionsFile: value => { exemptionsFile = value; },
|
|
323
|
+
getSessionDir: () => sessionDir, setSessionDir: value => { sessionDir = value; },
|
|
324
|
+
getWidgetContext: () => widgetCtx, setWidgetContext: value => { widgetCtx = value; },
|
|
325
|
+
getPendingHandoff: () => pendingHandoff, setPendingHandoff: value => { pendingHandoff = value; },
|
|
326
|
+
});
|
|
327
|
+
let userLanguage: string = DEFAULT_OVERRIDES.language;
|
|
328
|
+
// Project rule folders from the overrides file's `rules:` key (repo-relative,
|
|
329
|
+
// validated at session_start). Non-empty → every dispatched specialist gets a
|
|
330
|
+
// "Project rules" prompt block; personas resolve the folders index-first (a
|
|
331
|
+
// top-level README.md/index.md is a loading manifest) with recursive discovery
|
|
332
|
+
// as the no-index fallback.
|
|
333
|
+
let projectRulesDirs: string[] = [];
|
|
334
|
+
// Project documentation entry points from the overrides file's `docs:` key
|
|
335
|
+
// (repo-relative files or folders, validated at session_start). Non-empty →
|
|
336
|
+
// dispatched specialists and research helpers get a "Project docs" prompt block.
|
|
337
|
+
let projectDocsPaths: string[] = [];
|
|
338
|
+
|
|
339
|
+
// Prompt blocks for the project's own rules (HOW — compliance) and docs
|
|
340
|
+
// (WHAT/WHY — orientation). Rules discovery is index-first so a curated rule
|
|
341
|
+
// tree (README manifest + session bundles) is honored instead of bulk-read;
|
|
342
|
+
// the blind recursive find is only the no-index fallback. The validation duty
|
|
343
|
+
// itself is written into the planner/code-reviewer personas.
|
|
344
|
+
function buildRulesProtocol(): string {
|
|
345
|
+
return buildProjectRulesProtocol(projectRulesDirs);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function buildDocsProtocol(): string {
|
|
349
|
+
return buildProjectDocsProtocol(projectDocsPaths);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** One canonical repository context file plus explicitly configured rule roots. */
|
|
353
|
+
function specialistProjectPolicyPaths(cwd: string): string[] {
|
|
354
|
+
const canonical = ["AGENTS.md", "CLAUDE.md"].find(candidate => existsSync(path.join(cwd, candidate)));
|
|
355
|
+
return [...new Set([...(canonical ? [canonical] : []), ...projectRulesDirs])];
|
|
356
|
+
}
|
|
357
|
+
// The one supported safety harness. Every native specialist, researcher, and
|
|
358
|
+
// nested delegate receives it; a missing harness refuses child dispatch.
|
|
359
|
+
let safetyHarnessPath: string | null = null;
|
|
360
|
+
// Resolved once at session_start: the delegate extension injected into
|
|
361
|
+
// specialists that declare `subagents:` (null → delegation disabled).
|
|
362
|
+
let delegateExtPath: string | null = null;
|
|
363
|
+
// Per-tool deadline for read/grep/find/ls in research helpers/delegates. The
|
|
364
|
+
// whole-run bound is separate: the turn budget's agentTurnMs (run-budget.js).
|
|
365
|
+
let reconSearchTimeoutMs: number | null = 120_000;
|
|
366
|
+
// ── Per-turn budgets (run-budget.js) ──
|
|
367
|
+
// Envelopes follow task tier. Override keys are a ceiling (min with the tier).
|
|
368
|
+
// Counters reset in before_agent_start, or after an explicit one-click
|
|
369
|
+
// continuation. executionHistory.turnStartedAt() is the active-time base; ask_user
|
|
370
|
+
// waits are subtracted.
|
|
371
|
+
let budgetOverrides: AgentTeamOverrides["budgetOverrides"] = {};
|
|
372
|
+
let turnDispatchCount = 0;
|
|
373
|
+
let turnResearchCount = 0;
|
|
374
|
+
// Human wait time is not fleet work. Track it separately from history UI
|
|
375
|
+
// intervals so a continuation can rebase the budget without erasing history.
|
|
376
|
+
let turnBudgetAskUserWaitMs = 0;
|
|
377
|
+
let taskContinuationCount = 0;
|
|
378
|
+
let turnContinuationCount = 0;
|
|
379
|
+
// ── Task-scoped budget & tier (run-budget.js) ──
|
|
380
|
+
// A per-message allowance cannot bound a task: every steering message opened a
|
|
381
|
+
// fresh turn window, so a run could spend 8 dispatches and 60 minutes again and
|
|
382
|
+
// again without any counter ever binding. These counters span the whole TASK
|
|
383
|
+
// and are cleared only by an explicit new task (`set_task_tier` with
|
|
384
|
+
// `new_task: true`) or an approved task-budget continuation — never by an
|
|
385
|
+
// ordinary user message.
|
|
386
|
+
let taskDispatchCount = 0;
|
|
387
|
+
let taskResearchCount = 0;
|
|
388
|
+
let taskLabel: string | null = null;
|
|
389
|
+
// The task clock charges ACTIVE time only — turns that ran, minus the time the
|
|
390
|
+
// dispatcher spent blocked on ask_user. Raw wall clock would bill the human's
|
|
391
|
+
// lunch break, an overnight pause, and every long answer against the task, and
|
|
392
|
+
// at small tier's 45-minute envelope that hard-stops a task with two dispatches
|
|
393
|
+
// spent. A false stop is worse than no stop: it teaches people to reset the
|
|
394
|
+
// task window reflexively, which is the one thing that must stay deliberate.
|
|
395
|
+
// The explicit clock state makes `active` authoritative: a stale timestamp can
|
|
396
|
+
// never turn inter-turn idle time into task work.
|
|
397
|
+
let taskClock = createTaskClock();
|
|
398
|
+
// Review dispatches spent on this task (review-round cap).
|
|
399
|
+
let taskReviewRounds = 0;
|
|
400
|
+
// Task tier (complexity triage): declared by the dispatcher via set_task_tier.
|
|
401
|
+
// TASK-scoped, not turn-scoped, and it moves by ratchet — down freely, up only
|
|
402
|
+
// with a stated reason (applyTierChange). Null until declared; the first
|
|
403
|
+
// dispatch assumes DEFAULT_TASK_TIER. Caps come from the tier envelope.
|
|
404
|
+
let taskTier: string | null = null;
|
|
405
|
+
// Was the tier ASSUMED by the hub rather than declared by the dispatcher? The
|
|
406
|
+
// distinction matters to the ratchet: an assumed tier must not turn the
|
|
407
|
+
// dispatcher's own first triage call into an "escalation" that needs a reason.
|
|
408
|
+
let taskTierAssumed = false;
|
|
409
|
+
// Correctness obligations are independent of the spend tier. They persist for
|
|
410
|
+
// the current task and reset only through the explicit new-task tool path.
|
|
411
|
+
let processState = createProcessState();
|
|
412
|
+
const persistProcessVerdict = (state: ProcessObligationState, verdict: ProcessVerdict) => {
|
|
413
|
+
try { pi.appendEntry("agent-hub-process-state", processAuditRecord(state, verdict)); } catch {}
|
|
414
|
+
};
|
|
415
|
+
// Duplicate-dispatch guard: fingerprints of (agent, task) already dispatched
|
|
416
|
+
// THIS turn. Auto-research resumes and /af-agents-restart call dispatchAgent
|
|
417
|
+
// directly, so only real dispatcher tool calls are guarded.
|
|
418
|
+
const turnDispatchFingerprints = new Set<string>();
|
|
419
|
+
// ── External-blocker circuit breaker (external-blocker.js) ──
|
|
420
|
+
// Set when a specialist reports it needs something outside the fleet's reach;
|
|
421
|
+
// gates the next dispatch until the human has been addressed. Cleared by an
|
|
422
|
+
// ask_user call, by a new user turn (the human spoke), and by a new task.
|
|
423
|
+
let externalBlockers: { agent: string; what: string }[] = [];
|
|
424
|
+
let externalBlockerAcknowledged = false;
|
|
425
|
+
let externalBlockerRefusedOnce = false;
|
|
426
|
+
// Per-run artifact archive retention (run-namespace.js).
|
|
427
|
+
let runHistoryKeep: number | null = DEFAULT_RUN_HISTORY_KEEP;
|
|
428
|
+
// ── Drift watchdog (drift-watchdog.js) ──
|
|
429
|
+
// Hub-wide setting from the overrides file, live-switchable via /af-watchdog;
|
|
430
|
+
// per-agent overrides ("on"/"off") win over it. In operator work mode a
|
|
431
|
+
// dispatch_agent `watchdog` param wins over both. In orchestrator work mode the
|
|
432
|
+
// watchdog auto-arms unless hub or per-agent is explicitly off; dispatch
|
|
433
|
+
// `watchdog: false` cannot disarm it.
|
|
434
|
+
let watchdogSetting: string = DEFAULT_WATCHDOG_SETTING;
|
|
435
|
+
let watchdogJudgeModel: string | null = null;
|
|
436
|
+
let watchdogSystem1: WatchdogSystem1Session | null = null;
|
|
437
|
+
const communicationStore = createCommunicationStore();
|
|
438
|
+
let triageRuntime: ReturnType<typeof createTriageRuntime> | null = null;
|
|
439
|
+
let proactiveRuntime: ReturnType<typeof createProactiveRuntime> | null = null;
|
|
440
|
+
let proactiveConfig: ProactiveConfig | null = null;
|
|
441
|
+
let proactiveHubDeliveries = 0;
|
|
442
|
+
const proactiveReportInput = () => proactiveRuntime ? { records: proactiveRuntime.records, history: proactiveRuntime.findings.history, current: proactiveRuntime.findings.current, activity: proactiveRuntime.activity.live(), feedback: { hubDelivered: proactiveHubDeliveries, nativeDelivered: null } } : undefined;
|
|
443
|
+
let hubTaskText: string | undefined;
|
|
444
|
+
const hubCapture = createHubCapture({ root: () => currentCtx?.cwd || process.cwd(), task: () => hubTaskText });
|
|
445
|
+
let watchdogActivity: WatchdogActivity | null = null;
|
|
446
|
+
const watchdogAgentOverrides = new Map<string, "on" | "off">();
|
|
447
|
+
// ── Per-turn cost report (/af-hub-report) ──
|
|
448
|
+
let turnReport: TurnReport = freshTurnReport();
|
|
449
|
+
let lastTurnReport: TurnReport | null = null;
|
|
450
|
+
const sessionTotals = createSessionTotals();
|
|
451
|
+
// Session-wide delegated-spend counter (tokens across all delegate children),
|
|
452
|
+
// surfaced in the status line. Resets on session_start.
|
|
453
|
+
let delegatedTokens = 0;
|
|
454
|
+
|
|
455
|
+
const noProgress = createNoProgressGuard((type, data) => pi.appendEntry(type, data));
|
|
456
|
+
let taskIdentityReset: ReturnType<typeof createReservedTaskIdentityReset>;
|
|
457
|
+
let unknownToolCounter = createUnknownToolCounter({ limit: 3 });
|
|
458
|
+
const toolCatalogRuntime = createToolCatalogRuntime(catalogSnapshot("operator", []));
|
|
459
|
+
let latestToolCatalogDelta: ToolCatalogDelta | null = null;
|
|
460
|
+
let latestUnknownToolNotice = "";
|
|
461
|
+
const seenUnknownToolCalls = new Set<string>();
|
|
462
|
+
const resetUnknownToolCounterForCurrentTask = () => {
|
|
463
|
+
unknownToolCounter.resetForNewTask(noProgress.taskId());
|
|
464
|
+
seenUnknownToolCalls.clear();
|
|
465
|
+
latestUnknownToolNotice = "";
|
|
466
|
+
};
|
|
467
|
+
const budgetCtx = createBudgetContext({
|
|
468
|
+
getBudgetOverrides: () => budgetOverrides,
|
|
469
|
+
getTurnDispatchCount: () => turnDispatchCount, setTurnDispatchCount: value => { turnDispatchCount = value; },
|
|
470
|
+
getTurnResearchCount: () => turnResearchCount, setTurnResearchCount: value => { turnResearchCount = value; },
|
|
471
|
+
getTurnBudgetAskUserWaitMs: () => turnBudgetAskUserWaitMs, setTurnBudgetAskUserWaitMs: value => { turnBudgetAskUserWaitMs = value; },
|
|
472
|
+
resetBudgetRecovery: () => budgetRecovery.reset(),
|
|
473
|
+
resetNoProgress: () => noProgress.reset(), resetUnknownToolCounter: resetUnknownToolCounterForCurrentTask,
|
|
474
|
+
getTaskContinuationCount: () => taskContinuationCount, setTaskContinuationCount: value => { taskContinuationCount = value; },
|
|
475
|
+
getTurnContinuationCount: () => turnContinuationCount, setTurnContinuationCount: value => { turnContinuationCount = value; },
|
|
476
|
+
getTaskDispatchCount: () => taskDispatchCount, setTaskDispatchCount: value => { taskDispatchCount = value; },
|
|
477
|
+
getTaskResearchCount: () => taskResearchCount, setTaskResearchCount: value => { taskResearchCount = value; },
|
|
478
|
+
getTaskLabel: () => taskLabel, setTaskLabel: value => { taskLabel = value; },
|
|
479
|
+
getTaskClock: () => taskClock, setTaskClock: value => { taskClock = value; },
|
|
480
|
+
getTaskReviewRounds: () => taskReviewRounds, setTaskReviewRounds: value => { taskReviewRounds = value; },
|
|
481
|
+
getTaskTier: () => taskTier, setTaskTier: value => { taskTier = value; },
|
|
482
|
+
getTaskTierAssumed: () => taskTierAssumed, setTaskTierAssumed: value => { taskTierAssumed = value; },
|
|
483
|
+
clearTurnDispatchFingerprints: () => turnDispatchFingerprints.clear(),
|
|
484
|
+
clearTaskCapabilities: () => workModePolicy.resetCapabilities(),
|
|
485
|
+
clearExternalBlockers: () => { externalBlockers = []; externalBlockerAcknowledged = false; externalBlockerRefusedOnce = false; },
|
|
486
|
+
resolveIncomingCapabilities: () => { resolveIncomingCapabilities("", true); }, applyWorkModeTools: () => { applyWorkModeTools(); },
|
|
487
|
+
getTurnReport: () => turnReport,
|
|
488
|
+
setStatus: (key, value) => { widgetCtx?.ui?.setStatus(key, value); },
|
|
489
|
+
getAuditContext: () => ({ cwd: identity?.cwd ?? currentCtx?.cwd, sessionId: identity?.session_id, project: identity?.project }),
|
|
490
|
+
appendEntry: (type, data) => { pi.appendEntry(type, data); },
|
|
491
|
+
executionHistory,
|
|
492
|
+
});
|
|
493
|
+
const {
|
|
494
|
+
currentBudget, currentTaskBudget, taskCounters, taskActiveElapsedMs, turnBudgetActiveElapsedMs,
|
|
495
|
+
renewTurnBudgetWindow, continueTaskBudgetWindow, closeTurnActiveTime, resetTaskWindow,
|
|
496
|
+
hubAuditIdentity, hubLocationSuffix, taskResetSnapshot, budgetContinuationSnapshot,
|
|
497
|
+
appendTaskResetEntry, appendBudgetContinuationEntry, updateModeStatus, ensureTaskTier,
|
|
498
|
+
} = budgetCtx;
|
|
499
|
+
const budgetRecovery = createBudgetRecovery({
|
|
500
|
+
check: operation => {
|
|
501
|
+
const task = checkTaskBudget(operation, taskCounters(), currentTaskBudget(), taskActiveElapsedMs(), taskTier);
|
|
502
|
+
if (task) return { ...task, kind: "task" };
|
|
503
|
+
const turn = checkTurnBudget(operation, { dispatches: turnDispatchCount, research: turnResearchCount }, currentBudget(), turnBudgetActiveElapsedMs(), taskTier);
|
|
504
|
+
return turn ? { ...turn, kind: "turn" } : null;
|
|
505
|
+
},
|
|
506
|
+
language: () => userLanguage,
|
|
507
|
+
ask: (id, params, ctx, signal) => requestRuntimeAsk(pi.events, id, params, ctx, signal),
|
|
508
|
+
startWait: id => executionHistory.startAskUser(id),
|
|
509
|
+
endWait: (id, sameTask) => {
|
|
510
|
+
const wait = executionHistory.endAskUser(id, Date.now());
|
|
511
|
+
if (!sameTask) return;
|
|
512
|
+
if (wait > 0) taskClock = addTaskClockWait(taskClock, wait);
|
|
513
|
+
turnBudgetAskUserWaitMs += wait;
|
|
514
|
+
},
|
|
515
|
+
renew: (refusal, correlation, ctx) => {
|
|
516
|
+
const at = Date.now(), prior = budgetContinuationSnapshot(refusal.kind, at);
|
|
517
|
+
if (refusal.kind === "task") continueTaskBudgetWindow(at); else renewTurnBudgetWindow(at);
|
|
518
|
+
appendBudgetContinuationEntry(refusal.kind, refusal.reason, prior, ctx, correlation);
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
taskIdentityReset = createReservedTaskIdentityReset(budgetRecovery, noProgress);
|
|
522
|
+
|
|
523
|
+
// ── Verification Contract: assertion ledger (advisory) ──
|
|
524
|
+
// Mutable ownership remains here; the extracted runtime receives explicit ports.
|
|
525
|
+
let assertions: Assertion[] = [];
|
|
526
|
+
const assertionsArtifactsCtx = createAssertionsArtifactsContext({
|
|
527
|
+
getAssertions: () => assertions,
|
|
528
|
+
getSessionDir: () => sessionDir,
|
|
529
|
+
getRunHistoryKeep: () => runHistoryKeep,
|
|
530
|
+
setStatus: (key, value) => { widgetCtx?.ui?.setStatus(key, value); },
|
|
531
|
+
});
|
|
532
|
+
const {
|
|
533
|
+
persistAssertions, assertionStatusLine, renderAssertionLedgerLines, renderAssertionLedgerText,
|
|
534
|
+
updateAssertionStatus, artifactsRoot, ensureArtifactsLayout, archivePreviousRun,
|
|
535
|
+
loadInputArtifacts, appendInputArtifacts, writeRunArtifact, evidencePathExists,
|
|
536
|
+
listArtifactFiles, renderArtifactIndexText, appendMachineHandoffSections,
|
|
537
|
+
} = assertionsArtifactsCtx;
|
|
538
|
+
|
|
539
|
+
const modelPolicy = createModelPolicy<AgentDef>({
|
|
540
|
+
getAllDefs: () => allAgentDefs,
|
|
541
|
+
getActiveDef: name => agentStates.get(name)?.def,
|
|
542
|
+
getResearchDefs: () => researchPersonas,
|
|
543
|
+
refreshUi: () => updateWidget(),
|
|
544
|
+
});
|
|
545
|
+
const {
|
|
546
|
+
allowedModels, substitutedModel, resolvedModel, resolvedSubagentModel,
|
|
547
|
+
resolvedThinking, switchablePersonaDef, allKnownModels,
|
|
548
|
+
} = modelPolicy;
|
|
549
|
+
|
|
550
|
+
let profileCommandContext: any;
|
|
551
|
+
const profileActivation = createProfileActivation({
|
|
552
|
+
busy: () => !profileCommandContext?.isIdle?.() || profileWorkInFlight()>0 ||
|
|
553
|
+
Array.from(agentStates.values()).some(state=>state.status==='running') ||
|
|
554
|
+
Array.from(researchStates.values()).some(state=>state.status==='running'),
|
|
555
|
+
defs: () => allAgentDefs,
|
|
556
|
+
available: async () => {
|
|
557
|
+
await profileCommandContext.modelRegistry.refresh?.();
|
|
558
|
+
return (profileCommandContext.modelRegistry.getAvailable?.()??[]).map((m:any)=>`${m.provider}/${m.id}`);
|
|
559
|
+
},
|
|
560
|
+
dispatcher: () => profileCommandContext?.model ? {model:`${profileCommandContext.model.provider}/${profileCommandContext.model.id}`,thinking:pi.getThinkingLevel()} : undefined,
|
|
561
|
+
setDispatcher: async selection => {
|
|
562
|
+
const slash=selection.model.indexOf('/');
|
|
563
|
+
const model=profileCommandContext.modelRegistry.find(selection.model.slice(0,slash),selection.model.slice(slash+1));
|
|
564
|
+
if(!model || !await pi.setModel(model)) return false;
|
|
565
|
+
if(selection.thinking) pi.setThinkingLevel(selection.thinking as any);
|
|
566
|
+
return true;
|
|
567
|
+
},
|
|
568
|
+
apply: profile => modelPolicy.applyProfile(profile),
|
|
569
|
+
});
|
|
570
|
+
pi.on('model_select', async (event,ctx) => {
|
|
571
|
+
contextWindow=event.model.contextWindow||0;
|
|
572
|
+
if(profileActivation.switching()) return;
|
|
573
|
+
const active=readActiveProfile();if(!active || !hasExplicitDispatcher(active.profile)) return;
|
|
574
|
+
try { assertProfileModel(`${event.model.provider}/${event.model.id}`,active); }
|
|
575
|
+
catch(error) {
|
|
576
|
+
ctx.abort();ctx.ui.notify(String(error),'error');
|
|
577
|
+
if(hasExplicitDispatcher(active.profile)) {
|
|
578
|
+
const target=dispatcherSelection(active.profile).model, slash=target.indexOf('/');
|
|
579
|
+
const model=ctx.modelRegistry.find(target.slice(0,slash),target.slice(slash+1));
|
|
580
|
+
if(model) await pi.setModel(model);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
pi.on('before_provider_request', async (_event,ctx) => {
|
|
585
|
+
const active=readActiveProfile();
|
|
586
|
+
if(!ctx.model || !active || !hasExplicitDispatcher(active.profile)) return;
|
|
587
|
+
try { assertProfileModel(`${ctx.model.provider}/${ctx.model.id}`,active); }
|
|
588
|
+
catch(error) {ctx.abort();ctx.ui.notify(String(error),'error');}
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
function appendDeclaredScope(task: string, scopeGlobs: string[]): string {
|
|
592
|
+
if (!scopeGlobs || scopeGlobs.length === 0) return task;
|
|
593
|
+
return task + `\n\n## Declared scope — advisory guardrail\nStay within these paths/globs when changing files; changes outside them will be flagged to the dispatcher for a human decision, not auto-reverted.\n${scopeGlobs.map(s => `- ${s}`).join("\n")}`;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function loadAgents(cwd: string): void {
|
|
597
|
+
if (sessionDir) closeEvidenceSession(sessionDir);
|
|
598
|
+
loadAgentConfiguration(cwd, {
|
|
599
|
+
setSessionDir: hubStateCtx.setSessionDir, getSessionDir: hubStateCtx.getSessionDir,
|
|
600
|
+
archivePreviousRun, ensureArtifactsLayout, resetAssertions: () => { assertions = []; },
|
|
601
|
+
setAgentDefs: value => { allAgentDefs = value; }, setTeams: value => { teams = value; },
|
|
602
|
+
setModelProfiles: value => { modelProfiles = value; }, setModelProfileErrors: errors => { modelProfileErrors=errors; }, setDispatchPolicy: value => { dispatchPolicy = value; },
|
|
603
|
+
setDispatchPolicyWarnings: value => { dispatchPolicyWarnings = value; },
|
|
604
|
+
});
|
|
605
|
+
pruneEvidenceSessions(sessionDir, runHistoryKeep);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
const agentStateFactory = createAgentStateFactory(() => sessionDir);
|
|
609
|
+
const { sessionHealthIo, adoptableSessionFile, freshAgentState } = agentStateFactory;
|
|
610
|
+
|
|
611
|
+
// Auto-size grid columns based on team size
|
|
612
|
+
function recomputeGrid() {
|
|
613
|
+
gridCols = gridColumnsForSize(agentStates.size);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const rosterPolicy = createRosterPolicy<AgentDef, AgentState>({
|
|
617
|
+
getTeams: () => teams, getAllDefs: () => allAgentDefs, getStates: () => agentStates,
|
|
618
|
+
getActiveTeamName: () => activeTeamName, setActiveTeamName: value => { activeTeamName = value; },
|
|
619
|
+
clearBackendNotices: () => comsMissNotified.clear(), createFreshState: freshAgentState,
|
|
620
|
+
adoptSession: adoptableSessionFile,
|
|
621
|
+
quarantineSession: agentStateFactory.quarantine,
|
|
622
|
+
persist: team => pi.appendEntry(NATIVE_ROSTER_ENTRY_TYPE, persistedNativeRosterState(team)),
|
|
623
|
+
recompute: recomputeGrid, refreshUi: () => updateWidget(), displayName,
|
|
624
|
+
orchestratorNeedsRosterAfterDrop: size => orchestratorNeedsRoster(getWorkMode(), size),
|
|
625
|
+
});
|
|
626
|
+
const { activateTeam, persistActiveRoster, add: rosterAdd, drop: rosterDrop } = rosterPolicy;
|
|
627
|
+
|
|
628
|
+
// ── Shared model presentation ─────────────────
|
|
629
|
+
// These formatters serve the extracted grid and the remaining composition-root
|
|
630
|
+
// call sites. Keep one implementation so cards, fleet rows, menus, fallback
|
|
631
|
+
// notices, and the footer retain the same presentation semantics.
|
|
632
|
+
function shortModel(model: string | undefined): string {
|
|
633
|
+
return model ? model.split("/").pop()! : "default";
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// A " (code)" thinking badge for display, or "" when the level is off.
|
|
637
|
+
function thinkingSuffix(rawThinking: string | undefined): string {
|
|
638
|
+
const code = abbrevThinking(resolveThinkingLevel(rawThinking));
|
|
639
|
+
return code ? ` (${code})` : "";
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// The model + thinking badge a persona would dispatch with: "gpt-5.5 (xh)".
|
|
643
|
+
function modelWithThinking(def: AgentDef): string {
|
|
644
|
+
return shortModel(resolvedModel(def)) + thinkingSuffix(resolvedThinking(def));
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// ── Shared fleet source + below-editor widget ───────────────────────────
|
|
648
|
+
const fleetSource = createFleetSource({
|
|
649
|
+
getAgents: () => agentStates,
|
|
650
|
+
getResearch: () => researchStates,
|
|
651
|
+
getPeerInputs: format => fleetPeerInputs(format),
|
|
652
|
+
getPeerCards: () => peerCards,
|
|
653
|
+
getPendingReplies: () => pendingReplies.values(),
|
|
654
|
+
displayName,
|
|
655
|
+
modelForAgent: state => state.lastBackend === "coms" ? shortModel(state.comsPeerModel) : modelWithThinking(state.def),
|
|
656
|
+
modelForResearch: state => shortModel(state.model) + thinkingSuffix(resolvedThinking(state.def)),
|
|
657
|
+
modelForPeer: abbreviateModel,
|
|
658
|
+
getSystem1: () => watchdogActivity?.live() ?? null,
|
|
659
|
+
getProactive: () => proactiveRuntime ? { records: proactiveRuntime.records, history: proactiveRuntime.findings.history, current: proactiveRuntime.findings.current, activity: proactiveRuntime.activity.live() } : null,
|
|
660
|
+
});
|
|
661
|
+
let fleetActions: ReturnType<typeof createFleetActions<AgentState, ResearchState>> | null = null;
|
|
662
|
+
let fleetUiGeneration = 0;
|
|
663
|
+
const gridUI = createGridUI({
|
|
664
|
+
getWidgetContext: () => widgetCtx,
|
|
665
|
+
getRows: now => fleetSource.rows(now, { showFinished: true }),
|
|
666
|
+
getSnapshot: now => { const source = fleetSource.snapshot(now); return { rows: buildFleetRows(source, { showFinished: true }), proactive: source.proactive }; },
|
|
667
|
+
handleIntent: async intent => {
|
|
668
|
+
if (!fleetActions || !widgetCtx) return;
|
|
669
|
+
if (intent.type === "system1") { await gridUI.withSuspended(() => openSystem1Communication(widgetCtx!, communicationStore)); return; }
|
|
670
|
+
if (intent.type === "open") await gridUI.withSuspended(() => fleetActions!.open(intent.key, intent.runToken, widgetCtx!));
|
|
671
|
+
else await fleetActions.execute(intent.type, intent.key, intent.runToken, widgetCtx);
|
|
672
|
+
},
|
|
673
|
+
});
|
|
674
|
+
const { updateWidget } = gridUI;
|
|
675
|
+
refreshFleetUi = updateWidget;
|
|
676
|
+
|
|
677
|
+
// ── Delegation observability ─────────────────
|
|
678
|
+
const dispatchObservability = createDispatchObservability({
|
|
679
|
+
getSessionDir: () => sessionDir,
|
|
680
|
+
getDelegatedTokens: () => delegatedTokens,
|
|
681
|
+
setDelegatedTokens: value => { delegatedTokens = value; },
|
|
682
|
+
getWidgetContext: () => widgetCtx,
|
|
683
|
+
executionHistory,
|
|
684
|
+
displayName,
|
|
685
|
+
safeAgentKey,
|
|
686
|
+
safePathWithin,
|
|
687
|
+
createTranscriptStore: createFleetTranscriptStore,
|
|
688
|
+
appendTimelineText,
|
|
689
|
+
appendTimelineEvent,
|
|
690
|
+
updateWidget,
|
|
691
|
+
});
|
|
692
|
+
const { startDelegationWatch } = dispatchObservability;
|
|
693
|
+
|
|
694
|
+
// ── Dispatch Agent (returns Promise) ─────────
|
|
695
|
+
|
|
696
|
+
// ── Extracted coms dispatch, drift judge, and return extraction ──
|
|
697
|
+
const dispatchComs = createDispatchComs({
|
|
698
|
+
getIdentity: () => identity,
|
|
699
|
+
resolveTarget: target => coms.resolveTarget(target),
|
|
700
|
+
send: (params, auditExtra) => coms.send(params, auditExtra),
|
|
701
|
+
getPendingReply: msgId => pendingReplies.get(msgId),
|
|
702
|
+
deletePendingReply: msgId => { pendingReplies.delete(msgId); },
|
|
703
|
+
getSessionDir: () => sessionDir,
|
|
704
|
+
getWatchdogJudgeModel: () => watchdogJudgeModel,
|
|
705
|
+
getResearcherModel: () => {
|
|
706
|
+
const researcherDef = allAgentDefs.find(def => def.name.toLowerCase() === "researcher");
|
|
707
|
+
return researcherDef ? resolvedModel(researcherDef) ?? null : null;
|
|
708
|
+
},
|
|
709
|
+
displayName,
|
|
710
|
+
safeAgentKey,
|
|
711
|
+
safePathWithin,
|
|
712
|
+
appendInputArtifacts,
|
|
713
|
+
appendDeclaredScope,
|
|
714
|
+
buildRulesProtocol,
|
|
715
|
+
buildDocsProtocol,
|
|
716
|
+
updateWidget,
|
|
717
|
+
spawnPiAgent,
|
|
718
|
+
});
|
|
719
|
+
const { dispatchViaComs, runDriftJudge, runReturnExtraction } = dispatchComs;
|
|
720
|
+
|
|
721
|
+
const nativeDispatch = createDispatchNative({
|
|
722
|
+
getAgentState: key => agentStates.get(key),
|
|
723
|
+
listAgentStates: () => Array.from(agentStates.values()),
|
|
724
|
+
getSessionDir: () => sessionDir,
|
|
725
|
+
getDispatchPolicy: () => dispatchPolicy,
|
|
726
|
+
isComsReady: () => comsReady,
|
|
727
|
+
getIdentity: () => identity,
|
|
728
|
+
peersInScope: () => peersInScope(),
|
|
729
|
+
wasComsMissNotified: personaKey => comsMissNotified.has(personaKey),
|
|
730
|
+
markComsMissNotified: personaKey => { comsMissNotified.add(personaKey); },
|
|
731
|
+
startMonitorChild: (input, env) => {
|
|
732
|
+
const monitorStart = monitorTurnId;
|
|
733
|
+
return monitorStart ? monitorBridge?.startChild({ ...input, parentId: monitorStart }, env) : undefined;
|
|
734
|
+
},
|
|
735
|
+
finalizeMonitorChild: (task, output, status) => monitorBridge?.finalizeChildFor(task, output, status),
|
|
736
|
+
registerMonitorWaitOnly: (monitorKey, state) => monitorBridge?.registerWaitOnly(monitorKey, () => state.comsAbort?.()),
|
|
737
|
+
registerMonitorProcess: (task, proc) => monitorBridge?.registerOwnedProcessFor(task, proc),
|
|
738
|
+
appendMonitorOutput: (task, delta) => monitorBridge?.appendOutputFor(task, delta),
|
|
739
|
+
getContextWindow: () => contextWindow,
|
|
740
|
+
currentBudget,
|
|
741
|
+
bumpRecycle: () => { turnReport.recycles++; sessionTotals.recycles++; },
|
|
742
|
+
bumpDriftStop: () => { turnReport.driftStops++; sessionTotals.driftStops++; },
|
|
743
|
+
getSessionHealthIo: () => sessionHealthIo,
|
|
744
|
+
getSafetyHarnessPath: () => safetyHarnessPath,
|
|
745
|
+
getDelegateExtensionPath: () => delegateExtPath,
|
|
746
|
+
getReconSearchTimeoutMs: () => reconSearchTimeoutMs,
|
|
747
|
+
getProjectDocsPaths: () => projectDocsPaths,
|
|
748
|
+
getUserLanguage: () => userLanguage,
|
|
749
|
+
getWatchdogSetting: () => watchdogSetting,
|
|
750
|
+
getWatchdogAgentOverride: key => watchdogAgentOverrides.get(key),
|
|
751
|
+
getWatchdogSystem1: () => watchdogSystem1,
|
|
752
|
+
getWatchdogActivity: () => watchdogActivity,
|
|
753
|
+
getProactiveRuntime: () => proactiveRuntime,
|
|
754
|
+
getProactiveConfig: () => proactiveConfig,
|
|
755
|
+
getProactiveCapture: () => proactiveRuntime ? hubCapture : null,
|
|
756
|
+
getWorkMode: () => getWorkMode(),
|
|
757
|
+
providerSemaphore,
|
|
758
|
+
executionHistory,
|
|
759
|
+
displayName,
|
|
760
|
+
shortModel: model => shortModel(model),
|
|
761
|
+
resolvedModel,
|
|
762
|
+
resolvedThinking,
|
|
763
|
+
resolveThinkingLevel,
|
|
764
|
+
resolvedSubagentModel,
|
|
765
|
+
substitutedModel,
|
|
766
|
+
modelWindowLookup,
|
|
767
|
+
specialistProjectPolicyPaths,
|
|
768
|
+
guardrailEnv,
|
|
769
|
+
appendInputArtifacts,
|
|
770
|
+
appendDeclaredScope,
|
|
771
|
+
flushTimelineStore,
|
|
772
|
+
appendTimelineText,
|
|
773
|
+
appendTimelineEvent,
|
|
774
|
+
createTranscriptStore: createFleetTranscriptStore,
|
|
775
|
+
updateWidget,
|
|
776
|
+
startDelegationWatch,
|
|
777
|
+
dispatchViaComs,
|
|
778
|
+
runDriftJudge,
|
|
779
|
+
notifyProviderQueue,
|
|
780
|
+
spawnPiAgentWithModelFallback,
|
|
781
|
+
});
|
|
782
|
+
const { dispatchAgent } = nativeDispatch;
|
|
783
|
+
|
|
784
|
+
// Shared child guardrail environment. Dispatch-native and research use the
|
|
785
|
+
// same root-owned exemptions and coms escalation endpoint.
|
|
786
|
+
function guardrailEnv(agentId: string): Record<string, string> {
|
|
787
|
+
const env: Record<string, string> = { [AGENT_ID_ENV]: agentId };
|
|
788
|
+
if (exemptionsFile) env[EXEMPTIONS_FILE_ENV] = exemptionsFile;
|
|
789
|
+
if (comsReady && identity) env[ASK_ENDPOINT_ENV] = identity.endpoint;
|
|
790
|
+
return env;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// ── Research helper runtime ────────────────────
|
|
794
|
+
// The composition root owns the mutable bindings; the runtime reaches them only
|
|
795
|
+
// through these explicit ports so later controls can keep stable handles.
|
|
796
|
+
const researchRuntime = createResearchRuntime<AgentDef>({
|
|
797
|
+
getResearchStates: () => researchStates,
|
|
798
|
+
setResearchStates: value => { researchStates = value; },
|
|
799
|
+
getNextResearchId: () => nextResearchId,
|
|
800
|
+
setNextResearchId: value => { nextResearchId = value; },
|
|
801
|
+
hubState: hubStateCtx, budget: budgetCtx, artifacts: assertionsArtifactsCtx,
|
|
802
|
+
executionHistory, providerSemaphore,
|
|
803
|
+
getSafetyHarnessPath: () => safetyHarnessPath,
|
|
804
|
+
getReconSearchTimeoutMs: () => reconSearchTimeoutMs,
|
|
805
|
+
getContextWindow: () => contextWindow,
|
|
806
|
+
resolvedModel, resolvedThinking, resolveThinkingLevel, fallbackModelFor, substitutedModel,
|
|
807
|
+
modelWindowLookup, guardrailEnv, notifyProviderQueue, spawnPiAgentWithModelFallback,
|
|
808
|
+
getProjectPolicyPaths: specialistProjectPolicyPaths,
|
|
809
|
+
getProjectDocsPaths: () => projectDocsPaths,
|
|
810
|
+
nativeResearchSystemPrompt, requireSafetyHarness, shortModel, displayName,
|
|
811
|
+
flushTimelineStore, appendTimelineText, appendTimelineEvent,
|
|
812
|
+
createTranscriptStore: createFleetTranscriptStore,
|
|
813
|
+
onElapsed: () => updateWidget(),
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
// ── Embedded coms: shared registry, transport, and pool core ──
|
|
817
|
+
const peersInScope = () => coms.peersInScope();
|
|
818
|
+
const resolveTarget = (target: string) => coms.resolveTarget(target);
|
|
819
|
+
|
|
820
|
+
const poolPresentation = createPoolPresentation({
|
|
821
|
+
getIdentity: () => identity,
|
|
822
|
+
getDisplayProject: () => coms.scope.displayProject,
|
|
823
|
+
includeExplicitPeers: () => coms.scope.includeExplicit,
|
|
824
|
+
getPeerCards: () => peerCards,
|
|
825
|
+
readProjectEntries: readAllRegistryEntries,
|
|
826
|
+
readAllEntries: readAllRegistryEntriesAcrossProjects,
|
|
827
|
+
truncate: truncateToWidth,
|
|
828
|
+
});
|
|
829
|
+
const fleetPeerInputs = poolPresentation.peerInputs;
|
|
830
|
+
|
|
831
|
+
// ── Extracted tool execution wiring ──
|
|
832
|
+
// Mutable fleet state remains composition-owned; executor modules receive ports.
|
|
833
|
+
let herdrFleetReady = false;
|
|
834
|
+
const hubSpawnedPeers = new Map<string, { name: string; paneId: string | null; addressed: boolean }>();
|
|
835
|
+
const markPeerAddressed = (name: string) => {
|
|
836
|
+
const entry = hubSpawnedPeers.get(String(name || "").toLowerCase());
|
|
837
|
+
if (entry) entry.addressed = true;
|
|
838
|
+
};
|
|
839
|
+
let lastHubPiSpawnAt: number | null = null;
|
|
840
|
+
|
|
841
|
+
let askUserAvailable = false;
|
|
842
|
+
let baselineTools: string[] = [];
|
|
843
|
+
let contextPressureState: ContextPressureState = createContextPressureState();
|
|
844
|
+
const pressureRootState = createContextPressureRootState();
|
|
845
|
+
|
|
846
|
+
function pendingCapabilityOperations(): PendingOperation[] {
|
|
847
|
+
const pending: PendingOperation[] = [];
|
|
848
|
+
if (Array.from(agentStates.values()).some(state => state.status === "running") || Array.from(researchStates.values()).some(state => state.status === "running")) pending.push({ pack: "fleet", kind: "child" });
|
|
849
|
+
if (pendingReplies.size > 0 || pendingHandoff) pending.push({ pack: "peer", kind: "message" });
|
|
850
|
+
if (hubSpawnedPeers.size > 0) pending.push({ pack: "workspace", kind: "pane" });
|
|
851
|
+
return pending;
|
|
852
|
+
}
|
|
853
|
+
function recordToolCatalogChange(change: { fromMode: WorkMode; toMode: WorkMode; previous: readonly string[]; next: readonly string[]; reason: "refresh" | "mode_switch" }): void {
|
|
854
|
+
const { snapshot, delta } = toolCatalogRuntime.reconcile(change);
|
|
855
|
+
latestToolCatalogDelta = delta;
|
|
856
|
+
unknownToolCounter.noteCatalogChange(delta.catalogVersion);
|
|
857
|
+
const evidenceRef = `session-entry:${TOOL_CATALOG_ENTRY_TYPE}:${delta.catalogVersion}`;
|
|
858
|
+
let persisted = false;
|
|
859
|
+
try { pi.appendEntry(TOOL_CATALOG_ENTRY_TYPE, { snapshot, delta, reason: change.reason }); persisted = true; } catch {}
|
|
860
|
+
if (persisted && delta.evidence.changed) noProgress.establishToolStateChange(delta.evidence.previousCatalogVersion, delta.evidence.catalogVersion, evidenceRef);
|
|
861
|
+
}
|
|
862
|
+
function capabilityContextState(): ContextState {
|
|
863
|
+
if (contextPressureState.phase === "warning") return "approaching-compaction";
|
|
864
|
+
if (contextPressureState.phase !== "normal" || contextPressureState.pressure === "imminent") return "imminent-compaction";
|
|
865
|
+
if (contextPressureState.pressure === "approaching") return "approaching-compaction";
|
|
866
|
+
const percent = currentCtx?.getContextUsage?.()?.percent;
|
|
867
|
+
if (typeof percent === "number" && percent >= 90) return "imminent-compaction";
|
|
868
|
+
if (typeof percent === "number" && percent >= 80) return "approaching-compaction";
|
|
869
|
+
return "normal";
|
|
870
|
+
}
|
|
871
|
+
const workModePolicy = createWorkModePolicy({
|
|
872
|
+
getBaselineTools: () => baselineTools, getRosterSize: () => agentStates.size,
|
|
873
|
+
getDeterministicToolsEnabled: () => resolveAssist(readActiveProfile()?.profile.assist)['deterministic-tools'],
|
|
874
|
+
activateFallbackRoster: ctx => {
|
|
875
|
+
if (!rosterPolicy.activateFirstValidTeam()) return;
|
|
876
|
+
workModePolicy.clearRosterRecovery();
|
|
877
|
+
persistActiveRoster();
|
|
878
|
+
setTimeout(replayDeferredRecoveryInputs, 0);
|
|
879
|
+
updateWidget();
|
|
880
|
+
ctx.ui.setStatus("agent-team", `Team: ${activeTeamName} (${agentStates.size})`);
|
|
881
|
+
},
|
|
882
|
+
getActiveTeamName: () => activeTeamName, getComsReady: () => comsReady,
|
|
883
|
+
getHerdrReady: () => herdrFleetReady, getAskUserAvailable: () => askUserAvailable,
|
|
884
|
+
getIdentityLabel: () => identity ? `${identity.name}@${identity.project}` : null,
|
|
885
|
+
getTaskTier: () => taskTier, getPendingOperations: pendingCapabilityOperations,
|
|
886
|
+
getContextState: capabilityContextState, getActiveTools: () => pi.getActiveTools(), setActiveTools: tools => pi.setActiveTools(tools),
|
|
887
|
+
recordToolCatalog: recordToolCatalogChange,
|
|
888
|
+
persist: (type, data) => pi.appendEntry(type, data), replayDeferredInputs: replayDeferredRecoveryInputs,
|
|
889
|
+
watchdogArmed: mode => resolveWatchdogActive(undefined, undefined, watchdogSetting, mode),
|
|
890
|
+
});
|
|
891
|
+
const {
|
|
892
|
+
getWorkMode, getCapabilityResolution, resolveIncomingCapabilities, provisionalCapabilityRefusal,
|
|
893
|
+
applyWorkModeTools, modelWorkBlockedByRosterRecovery,
|
|
894
|
+
statusText: workModeStatusText, applySelection: applyWorkModeSelection, openPicker: openWorkModePicker,
|
|
895
|
+
} = workModePolicy;
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
const toolCtx: ToolContext = createToolExecutionOrchestration({
|
|
899
|
+
dispatch: {
|
|
900
|
+
state: {
|
|
901
|
+
getTurnDispatchCount: () => turnDispatchCount, setTurnDispatchCount: value => { turnDispatchCount = value; },
|
|
902
|
+
getTurnResearchCount: () => turnResearchCount, setTurnResearchCount: value => { turnResearchCount = value; },
|
|
903
|
+
getTaskDispatchCount: () => taskDispatchCount, setTaskDispatchCount: value => { taskDispatchCount = value; },
|
|
904
|
+
getTaskResearchCount: () => taskResearchCount, setTaskResearchCount: value => { taskResearchCount = value; },
|
|
905
|
+
getTaskReviewRounds: () => taskReviewRounds, setTaskReviewRounds: value => { taskReviewRounds = value; },
|
|
906
|
+
getTaskTier: () => taskTier, getTurnReport: () => turnReport, getSessionTotals: () => sessionTotals,
|
|
907
|
+
getProcessState: () => processState, setProcessState: value => { processState = value; }, persistProcessVerdict,
|
|
908
|
+
getTurnDispatchFingerprints: () => turnDispatchFingerprints,
|
|
909
|
+
getExternalBlockers: () => externalBlockers,
|
|
910
|
+
getExternalBlockerAcknowledged: () => externalBlockerAcknowledged, setExternalBlockerAcknowledged: value => { externalBlockerAcknowledged = value; },
|
|
911
|
+
getExternalBlockerRefusedOnce: () => externalBlockerRefusedOnce, setExternalBlockerRefusedOnce: value => { externalBlockerRefusedOnce = value; },
|
|
912
|
+
isAskUserAvailable: () => askUserAvailable, getUserLanguage: () => userLanguage, getSessionDir: () => sessionDir,
|
|
913
|
+
getAgentStates: () => agentStates as any, getAssertions: () => assertions, getResearchPersonas: () => researchPersonas,
|
|
914
|
+
getActiveWritableDispatches: () => activeWritableDispatches, setActiveWritableDispatches: value => { activeWritableDispatches = value; },
|
|
915
|
+
getWritableOverlapCounter: () => writableOverlapCounter, setWritableOverlapCounter: value => { writableOverlapCounter = value; },
|
|
916
|
+
},
|
|
917
|
+
budget: budgetCtx, budgetRecovery, noProgress, artifacts: assertionsArtifactsCtx, research: researchRuntime,
|
|
918
|
+
provisionalCapabilityRefusal, dispatchAgent, runReturnExtraction,
|
|
919
|
+
extractNeedsResearch, extractAskUserQuestions, contextPressure: percent => percent >= CONTEXT_WARN_THRESHOLD, displayName,
|
|
920
|
+
resolvedAgentModel: (def, ctx) => resolvedModel(def as AgentDef) ?? (ctx.model ? `${ctx.model.provider}/${ctx.model.id}` : undefined),
|
|
921
|
+
getToolCatalogVersion: () => toolCatalogRuntime.catalogForMessage().catalogVersion,
|
|
922
|
+
},
|
|
923
|
+
actions: {
|
|
924
|
+
budget: budgetCtx, artifacts: assertionsArtifactsCtx, hubState: hubStateCtx,
|
|
925
|
+
provisionalCapabilityRefusal,
|
|
926
|
+
getTaskTier: () => taskTier, setTaskTier: value => { taskTier = value; },
|
|
927
|
+
getTaskTierAssumed: () => taskTierAssumed, setTaskTierAssumed: value => { taskTierAssumed = value; },
|
|
928
|
+
getProcessState: () => processState, setProcessState: value => { processState = value; },
|
|
929
|
+
persistProcessState: value => persistProcessVerdict(value, evaluateProcessObligations(value, { writable: true, budgetTier: taskTier ?? DEFAULT_TASK_TIER })),
|
|
930
|
+
getTaskDispatchCount: () => taskDispatchCount, getTaskResearchCount: () => taskResearchCount,
|
|
931
|
+
getTurnReport: () => turnReport, getAssertions: () => assertions, setAssertions: value => { assertions = value; },
|
|
932
|
+
currentTaskId: () => noProgress.taskId(), currentRevision: ctx => worktreeRevision(ctx.cwd || process.cwd(), []),
|
|
933
|
+
adoptReservedTaskId: (id, resetTaskWindow) => taskIdentityReset.run(id, resetTaskWindow),
|
|
934
|
+
confirmTaskSupersession: (input, ctx, signal) => confirmTaskSupersession(input, ctx, { language: () => userLanguage, currentTaskId: () => noProgress.taskId(), ask: (id, params, askCtx, askSignal) => requestRuntimeAsk(pi.events, id, params, askCtx, askSignal), startWait: id => executionHistory.startAskUser(id), endWait: (id, sameTask) => { const wait = executionHistory.endAskUser(id, Date.now()); if (sameTask && wait > 0) { taskClock = addTaskClockWait(taskClock, wait); turnBudgetAskUserWaitMs += wait; } } }, signal),
|
|
935
|
+
getAgentStates: () => agentStates, rosterAdd, rosterDrop,
|
|
936
|
+
getIdentity: () => identity, getComs: () => coms, resolveTarget,
|
|
937
|
+
appendMachineHandoffSections, markPeerAddressed,
|
|
938
|
+
},
|
|
939
|
+
herdr: {
|
|
940
|
+
provisionalCapabilityRefusal, isFleetReady: () => herdrFleetReady, isComsReady: () => comsReady,
|
|
941
|
+
getIdentity: () => identity, getCurrentContext: () => currentCtx, peersInScope,
|
|
942
|
+
getComsPeerNames: () => peersInScope().map(peer => peer.name), herdr: herdrApi,
|
|
943
|
+
readEnvFile: file => fs.readFileSync(file, "utf-8"), envFileExists: file => fs.existsSync(file),
|
|
944
|
+
getLastPiSpawnAt: () => lastHubPiSpawnAt, setLastPiSpawnAt: value => { lastHubPiSpawnAt = value; },
|
|
945
|
+
recordSpawnedPeer: (name, paneId) => { hubSpawnedPeers.set(name.toLowerCase(), { name, paneId, addressed: false }); },
|
|
946
|
+
},
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
function triageInput(task: string, scope: string[], language: string, domain: string): TriageInput {
|
|
950
|
+
const taskGate = checkTaskBudget("dispatch", budgetCtx.taskCounters(), budgetCtx.currentTaskBudget(), budgetCtx.taskActiveElapsedMs(), taskTier);
|
|
951
|
+
const turnGate = checkTurnBudget("dispatch", { dispatches: turnDispatchCount, research: turnResearchCount }, budgetCtx.currentBudget(), budgetCtx.turnBudgetActiveElapsedMs(), taskTier);
|
|
952
|
+
const candidates = [...agentStates.values()].map(s => {
|
|
953
|
+
const name = s.def.name.toLowerCase();
|
|
954
|
+
const research = ["researcher", "deep-researcher", ...researchPersonas.map(p => p.name.toLowerCase())].includes(name);
|
|
955
|
+
const gate = processPreEffectGate(processState, "child", name) ?? (processAllowsPersona(processState,name) ? null : checkTierPersonaGate(taskTier,name)) ?? checkReviewRoundCap(taskTier,name,taskReviewRounds) ?? checkDocsLane(name, scope, undefined) ?? taskGate ?? turnGate;
|
|
956
|
+
return { name, description: s.def.description, ...(research ? { excluded: "research_persona" } : s.status === "running" ? { excluded: "busy" } : gate ? { excluded: gate.reason } : {}) };
|
|
957
|
+
});
|
|
958
|
+
return { taskId: noProgress.taskId(), task, scope, language, domain, candidates, constraints: JSON.stringify({ tier: taskTier, process: { risk: processState.risk, scope: processState.scope }, externalBlocked: externalBlockers.length > 0 && !externalBlockerAcknowledged }), complete: !(externalBlockers.length > 0 && !externalBlockerAcknowledged) };
|
|
959
|
+
}
|
|
960
|
+
registerDispatchTriage(pi, { runtime: () => triageRuntime, input: triageInput, blocked: () => provisionalCapabilityRefusal("fleet") });
|
|
961
|
+
|
|
962
|
+
// Keep the extracted tool surface flat and greppable in this composition root.
|
|
963
|
+
registerDispatchAgent(pi, toolCtx, { disposition: (id, persona, reason) => triageRuntime?.disposition(id, persona, reason) ?? false, submitted: (id, persona, status) => triageRuntime?.submitted(id, persona, status) });
|
|
964
|
+
registerSpawnResearch(pi, toolCtx);
|
|
965
|
+
registerRunFlow(pi, {
|
|
966
|
+
sessionDir: () => sessionDir,
|
|
967
|
+
taskId: () => noProgress.taskId(),
|
|
968
|
+
processObligations: () => evaluateProcessObligations(processState, { writable: false, budgetTier: taskTier ?? DEFAULT_TASK_TIER }),
|
|
969
|
+
effectiveScoutConfig: cwd => {
|
|
970
|
+
const persona = resolveFlowPersona("researcher", cwd);
|
|
971
|
+
const model = persona.model!;
|
|
972
|
+
assertFlowProfileModel(model);
|
|
973
|
+
return { model, profile: readActiveProfile()?.name ?? null, tools: persona.tools.split(",").map(value => value.trim()).filter(Boolean), fallback: persona.fallbackModel ?? null, allowlisted: true };
|
|
974
|
+
},
|
|
975
|
+
reserveBudget: async (params, ctx, signal) => {
|
|
976
|
+
ensureTaskTier();
|
|
977
|
+
const blocked = await budgetRecovery.ensure("research", `flow scout: ${params.request}`, ctx, signal);
|
|
978
|
+
if (blocked) return { charged: false, operation: "research", owner: "hub", refusal: blocked.message };
|
|
979
|
+
if (signal?.aborted) return { charged: false, operation: "research", owner: "hub", refusal: "Flow cancelled before budget charge." };
|
|
980
|
+
const taskBlock = checkTaskBudget("research", budgetCtx.taskCounters(), budgetCtx.currentTaskBudget(), budgetCtx.taskActiveElapsedMs(), taskTier);
|
|
981
|
+
if (taskBlock) return { charged: false, operation: "research", owner: "hub", refusal: taskBlock.message };
|
|
982
|
+
const turnBlock = checkTurnBudget("research", { dispatches: turnDispatchCount, research: turnResearchCount }, budgetCtx.currentBudget(), budgetCtx.turnBudgetActiveElapsedMs(), taskTier);
|
|
983
|
+
if (turnBlock) return { charged: false, operation: "research", owner: "hub", refusal: turnBlock.message };
|
|
984
|
+
turnResearchCount++; taskResearchCount++; turnReport.research++; sessionTotals.research++; budgetCtx.updateModeStatus();
|
|
985
|
+
return { charged: true, operation: "research", owner: "hub" };
|
|
986
|
+
},
|
|
987
|
+
});
|
|
988
|
+
registerSetTaskTier(pi, toolCtx);
|
|
989
|
+
registerTeamAdjust(pi, toolCtx);
|
|
990
|
+
registerVerificationContract(pi, toolCtx);
|
|
991
|
+
registerComsTools(pi, toolCtx);
|
|
992
|
+
registerFleetTools(pi, toolCtx);
|
|
993
|
+
registerFilesystemTool(pi, {
|
|
994
|
+
enabled: () => resolveAssist(readActiveProfile()?.profile.assist)['deterministic-tools'],
|
|
995
|
+
sessionDir: () => sessionDir,
|
|
996
|
+
});
|
|
997
|
+
|
|
998
|
+
const researchControls = createResearchControls({
|
|
999
|
+
runtime: researchRuntime,
|
|
1000
|
+
refresh: () => {},
|
|
1001
|
+
getAgents: () => agentStates, displayName, modelWorkBlocked: modelWorkBlockedByRosterRecovery,
|
|
1002
|
+
cancelWait: (state, kind) => cancelLocalWaitOnly({ abort: state.comsAbort, monitorBridge, monitorKey: monitorKeyForAgent(state.def.name, state.dispatchId ?? state.runCount), event: { kind } }),
|
|
1003
|
+
cancelOwned: state => { fenceOperatorCancel(state); cancelLocalOwnedProcess({ process: state.proc, monitorBridge, monitorKey: monitorKeyForAgent(state.def.name, state.dispatchId ?? state.runCount), treeKill: killPiTree }); },
|
|
1004
|
+
restartSpecialist: async (state: AgentState, ctx) => {
|
|
1005
|
+
if (state.status === "running" && (state.proc || state.comsAbort)) {
|
|
1006
|
+
let resolveTermination!: () => void;
|
|
1007
|
+
const terminated = new Promise<void>(resolve => { resolveTermination = resolve; });
|
|
1008
|
+
state.onTerminate = resolveTermination;
|
|
1009
|
+
fenceOperatorCancel(state);
|
|
1010
|
+
if (state.proc) { state.killedByOperator = true; state.restarting = true; if (state.dispatchId) proactiveRuntime?.abort(safeAgentKey(state.def.name), state.dispatchId); killPiTree(state.proc); }
|
|
1011
|
+
else await cancelLocalWaitOnly({ abort: state.comsAbort, monitorBridge, monitorKey: monitorKeyForAgent(state.def.name, state.dispatchId ?? state.runCount), event: { kind: "restart" } });
|
|
1012
|
+
await terminated;
|
|
1013
|
+
}
|
|
1014
|
+
state.sessionFile = null;
|
|
1015
|
+
const result = await dispatchAgent(state.def.name, state.task, ctx);
|
|
1016
|
+
pi.sendMessage({ customType: "agent-restart-result", content: `[${displayName(state.def.name)}] restarted by operator and ${result.exitCode === 0 ? "completed" : "failed"} in ${Math.round(result.elapsed / 1000)}s.`, display: true }, { deliverAs: "followUp", triggerTurn: true });
|
|
1017
|
+
},
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
// ── ask_user Tool (dispatcher → human) ──
|
|
1021
|
+
//
|
|
1022
|
+
// We do NOT register `ask_user` here. The recommended companion package
|
|
1023
|
+
// `pi-ask-user` (see docs/pi-setup.md) owns that tool name with a richer
|
|
1024
|
+
// implementation. Registering our own conflicts regardless of load order:
|
|
1025
|
+
// - if we register first, pi-ask-user fails to load
|
|
1026
|
+
// - if pi-ask-user registers first, our registration fails
|
|
1027
|
+
// and pi has no synchronous probe at load time — `pi.getAllTools()` is
|
|
1028
|
+
// a runtime action method that throws when called from the factory.
|
|
1029
|
+
//
|
|
1030
|
+
// Instead, in `session_start` (where action methods ARE allowed) we check
|
|
1031
|
+
// `pi.getAllTools()`, gate `ask_user` into `setActiveTools` only if present,
|
|
1032
|
+
// and warn the user to `pi install npm:pi-ask-user` if it's missing.
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
// ── Commands ─────────────────────────────────
|
|
1036
|
+
|
|
1037
|
+
const commandCtx: CommandContext = {
|
|
1038
|
+
setWidgetContext: ctx => { widgetCtx = ctx; },
|
|
1039
|
+
applyWorkModeSelection,
|
|
1040
|
+
getWorkModeStatusText: workModeStatusText,
|
|
1041
|
+
openWorkModePicker,
|
|
1042
|
+
handleBudgetContinue: async ctx => { await budgetRecovery.resume(ctx); },
|
|
1043
|
+
handleAudit: async (ctx, args = "") => {
|
|
1044
|
+
const input = proactiveReportInput();
|
|
1045
|
+
await showSessionAudit(ctx, sessionDir, input && { ...input, labels: commandProactiveLabels(sessionDir, args) });
|
|
1046
|
+
},
|
|
1047
|
+
handleRetry: async (args, ctx) => {
|
|
1048
|
+
const dispatchId = args?.trim();
|
|
1049
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(dispatchId)) { ctx.ui.notify("Usage: /af-retry <dispatchId>", "error"); return; }
|
|
1050
|
+
const op = noProgress.byDispatch(dispatchId), attempt = op?.attempts.find(a => a.dispatchId === dispatchId);
|
|
1051
|
+
if (!op || !attempt) { ctx.ui.notify("Unknown dispatch ID; no retry authorized.", "error"); return; }
|
|
1052
|
+
await commandCtx.handleRecover(`retry ${op.operationId} ${attempt.attemptId}`, ctx);
|
|
1053
|
+
},
|
|
1054
|
+
handleRecover: async (args, ctx) => {
|
|
1055
|
+
await runRecoverCommand(args, ctx, {
|
|
1056
|
+
noProgress,
|
|
1057
|
+
currentRevision: cwd => worktreeRevision(cwd, []),
|
|
1058
|
+
confirm: confirmRecoverAction,
|
|
1059
|
+
askPorts: (op, attempt, action) => ({
|
|
1060
|
+
taskId: () => noProgress.taskId(), language: () => userLanguage,
|
|
1061
|
+
ask: (id: string, params: any, askCtx: any, signal: AbortSignal) => requestRuntimeAsk(pi.events, id, params, askCtx, signal),
|
|
1062
|
+
startWait: (id: string) => executionHistory.startAskUser(id),
|
|
1063
|
+
endWait: (id: string, sameTask: boolean) => { const wait = executionHistory.endAskUser(id, Date.now()); if (sameTask && wait > 0) { taskClock = addTaskClockWait(taskClock, wait); turnBudgetAskUserWaitMs += wait; } },
|
|
1064
|
+
valid: () => { const current = noProgress.inspect(op.operationId); return current?.attempts.at(-1)?.attemptId === attempt.attemptId && (action === "abandon" ? !current.abandoned && noProgress.isIdle(op.executor) : noProgress.canAuthorize(op.operationId, attempt.attemptId)); },
|
|
1065
|
+
consume: (nonce: string) => action === "abandon" ? noProgress.abandon(op.operationId, attempt.attemptId, nonce) : attempt.category === "indeterminate" ? noProgress.authorizeIndeterminate(op.operationId, attempt.attemptId, nonce) : noProgress.authorize(attempt.dispatchId),
|
|
1066
|
+
}),
|
|
1067
|
+
});
|
|
1068
|
+
},
|
|
1069
|
+
|
|
1070
|
+
handleAgentsTeam: async (_args, ctx) => {
|
|
1071
|
+
widgetCtx = ctx;
|
|
1072
|
+
const teamNames = Object.keys(teams);
|
|
1073
|
+
if (teamNames.length === 0) {
|
|
1074
|
+
ctx.ui.notify("No teams defined in .pi/agents/teams.yaml", "warning");
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
const options = teamNames.map(name => {
|
|
1079
|
+
const members = teams[name].map(m => displayName(m));
|
|
1080
|
+
return `${name} — ${members.join(", ")}`;
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1083
|
+
const choice = await ctx.ui.select("Select Team", options);
|
|
1084
|
+
if (choice === undefined) return;
|
|
1085
|
+
|
|
1086
|
+
const idx = options.indexOf(choice);
|
|
1087
|
+
const name = teamNames[idx];
|
|
1088
|
+
const selected = resolveSessionRoster({
|
|
1089
|
+
teams,
|
|
1090
|
+
entries: [],
|
|
1091
|
+
explicitRoster: name,
|
|
1092
|
+
availablePersonas: allAgentDefs.map(def => def.name),
|
|
1093
|
+
});
|
|
1094
|
+
if (!selected.roster) {
|
|
1095
|
+
ctx.ui.notify(`${selected.diagnostic} Fix .pi/agents/teams.yaml or select another team.`, "error");
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
activateTeam(selected.roster.name);
|
|
1099
|
+
workModePolicy.clearRosterRecovery();
|
|
1100
|
+
persistActiveRoster();
|
|
1101
|
+
resolveIncomingCapabilities("");
|
|
1102
|
+
applyWorkModeTools();
|
|
1103
|
+
setTimeout(replayDeferredRecoveryInputs, 0);
|
|
1104
|
+
updateWidget();
|
|
1105
|
+
ctx.ui.setStatus("agent-team", `Team: ${name} (${agentStates.size})`);
|
|
1106
|
+
ctx.ui.notify(`Team: ${name} — ${Array.from(agentStates.values()).map(s => displayName(s.def.name)).join(", ")}`, "info");
|
|
1107
|
+
},
|
|
1108
|
+
handleAgentsList: async (_args, _ctx) => {
|
|
1109
|
+
widgetCtx = _ctx;
|
|
1110
|
+
await openFleetDashboard(_ctx);
|
|
1111
|
+
},
|
|
1112
|
+
handleAgentsHistory: async (_args, ctx) => {
|
|
1113
|
+
widgetCtx = ctx;
|
|
1114
|
+
await openHistory(ctx, executionHistory, () => (activeTeamName ? `Team: ${activeTeamName}` : "Agent Hub"));
|
|
1115
|
+
},
|
|
1116
|
+
handleAgentsAdd: async (args, ctx) => {
|
|
1117
|
+
widgetCtx = ctx;
|
|
1118
|
+
const names = (args || "").trim().split(/\s+/).filter(Boolean);
|
|
1119
|
+
if (names.length === 0) {
|
|
1120
|
+
const available = allAgentDefs
|
|
1121
|
+
.filter(d => !agentStates.has(d.name.toLowerCase()))
|
|
1122
|
+
.map(d => d.name).sort().join(", ") || "(all personas are already in the team)";
|
|
1123
|
+
ctx.ui.notify(`Usage: /af-agents-add <persona> [<persona>…]\nNot in the team yet: ${available}`, "info");
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
const results = names.map(n => rosterAdd(n));
|
|
1127
|
+
const level = results.some(r => r.ok) ? "info" : "error";
|
|
1128
|
+
ctx.ui.notify(results.map(r => r.message).join("\n"), level);
|
|
1129
|
+
ctx.ui.setStatus("agent-team", `Native roster: ${activeTeamName || "(none)"}* (${agentStates.size})`);
|
|
1130
|
+
},
|
|
1131
|
+
handleAgentsDrop: async (args, ctx) => {
|
|
1132
|
+
widgetCtx = ctx;
|
|
1133
|
+
const names = (args || "").trim().split(/\s+/).filter(Boolean);
|
|
1134
|
+
if (names.length === 0) {
|
|
1135
|
+
ctx.ui.notify(`Usage: /af-agents-drop <persona> [<persona>…]\nActive team: ${Array.from(agentStates.values()).map(s => s.def.name).join(", ")}`, "info");
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
const results = names.map(n => rosterDrop(n));
|
|
1139
|
+
const level = results.some(r => r.ok) ? "info" : "error";
|
|
1140
|
+
ctx.ui.notify(results.map(r => r.message).join("\n"), level);
|
|
1141
|
+
ctx.ui.setStatus("agent-team", `Native roster: ${activeTeamName || "(none)"}* (${agentStates.size})`);
|
|
1142
|
+
},
|
|
1143
|
+
handleAgentsSave: async (args, ctx) => {
|
|
1144
|
+
widgetCtx = ctx;
|
|
1145
|
+
const name = (args || "").trim();
|
|
1146
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(name)) {
|
|
1147
|
+
ctx.ui.notify("Usage: /af-agents-save <team-name> (letters, digits, hyphens, underscores)", "error");
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
const members = Array.from(agentStates.values()).map(s => s.def.name);
|
|
1151
|
+
if (members.length === 0) {
|
|
1152
|
+
ctx.ui.notify("The active team is empty — nothing to save.", "error");
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
const teamsPath = join(ctx.cwd || process.cwd(), ".pi", "agents", "teams.yaml");
|
|
1156
|
+
let raw = "";
|
|
1157
|
+
try { raw = existsSync(teamsPath) ? readFileSync(teamsPath, "utf-8") : ""; } catch {}
|
|
1158
|
+
try {
|
|
1159
|
+
mkdirSync(join(ctx.cwd || process.cwd(), ".pi", "agents"), { recursive: true });
|
|
1160
|
+
writeFileSync(teamsPath, upsertTeamInYaml(raw, name, members), "utf-8");
|
|
1161
|
+
} catch (err) {
|
|
1162
|
+
ctx.ui.notify(`Could not write ${teamsPath}: ${err instanceof Error ? err.message : String(err)}`, "error");
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
teams[name] = members;
|
|
1166
|
+
activeTeamName = name;
|
|
1167
|
+
persistActiveRoster();
|
|
1168
|
+
ctx.ui.setStatus("agent-team", `Team: ${name} (${agentStates.size})`);
|
|
1169
|
+
ctx.ui.notify(`Team "${name}" saved to .pi/agents/teams.yaml — ${members.join(", ")}`, "info");
|
|
1170
|
+
},
|
|
1171
|
+
handleAgentsKill: async (args, ctx) => { widgetCtx = ctx; await researchControls.handleKill(args, ctx); },
|
|
1172
|
+
handleAgentsRestart: async (args, ctx) => { widgetCtx = ctx; await researchControls.handleRestart(args, ctx); },
|
|
1173
|
+
handleContext: async (_args, ctx) => {
|
|
1174
|
+
widgetCtx = ctx;
|
|
1175
|
+
await openContextBudget(ctx);
|
|
1176
|
+
},
|
|
1177
|
+
handleHubReport: async (args, ctx) => {
|
|
1178
|
+
widgetCtx = ctx;
|
|
1179
|
+
const fmtTok = (n: number) => n >= 1_000_000 ? `${(n / 1_000_000).toFixed(1)}M` : n >= 1000 ? `${Math.round(n / 1000)}k` : String(n);
|
|
1180
|
+
const renderReport = (label: string, r: TurnReport): string => {
|
|
1181
|
+
const billed = r.dispatches.reduce((n, d) => n + d.billed, 0);
|
|
1182
|
+
const out = r.dispatches.reduce((n, d) => n + d.out, 0);
|
|
1183
|
+
const rows = r.dispatches.map(d => ` ${d.agent}: ${d.status} in ${Math.round(d.elapsed / 1000)}s · ${fmtTok(d.billed)} billed / ${fmtTok(d.out)} out`);
|
|
1184
|
+
return [
|
|
1185
|
+
`${label} — tier ${r.tier ?? "(unset)"} · ${r.dispatches.length} dispatch(es) · ${r.research} research · ` +
|
|
1186
|
+
`${fmtTok(billed)} billed / ${fmtTok(out)} out · ${r.recycles} recycle(s) · ${r.driftStops} drift stop(s) · ${r.refusals} refusal(s)`,
|
|
1187
|
+
...rows,
|
|
1188
|
+
].join("\n");
|
|
1189
|
+
};
|
|
1190
|
+
const lines: string[] = [];
|
|
1191
|
+
if (turnReport.dispatches.length > 0 || turnReport.research > 0 || turnReport.refusals > 0) {
|
|
1192
|
+
lines.push(renderReport("Current turn", turnReport));
|
|
1193
|
+
}
|
|
1194
|
+
if (lastTurnReport) lines.push(renderReport("Last turn", lastTurnReport));
|
|
1195
|
+
lines.push(
|
|
1196
|
+
`Session — ${sessionTotals.turns} dispatching turn(s) · ${sessionTotals.dispatches} dispatch(es) · ${sessionTotals.research} research · ` +
|
|
1197
|
+
`${fmtTok(sessionTotals.billed)} billed / ${fmtTok(sessionTotals.out)} out · ${sessionTotals.recycles} recycle(s) · ` +
|
|
1198
|
+
`${sessionTotals.driftStops} drift stop(s) · ${sessionTotals.refusals} refusal(s)`,
|
|
1199
|
+
);
|
|
1200
|
+
const sweep = unaddressedPeerSweep(Array.from(hubSpawnedPeers.values()));
|
|
1201
|
+
if (sweep) lines.push(sweep.message);
|
|
1202
|
+
const trace = readWatchdogEvents(sessionDir);
|
|
1203
|
+
lines.push(`Watchdog System 1 — ${JSON.stringify(buildWatchdogReport(trace.events, watchdogActivity?.live(), trace.integrity))}`);
|
|
1204
|
+
const proactiveInput = proactiveReportInput();
|
|
1205
|
+
lines.push(`Proactive review — ${JSON.stringify(proactiveInput ? buildProactiveReport({ ...proactiveInput, labels: commandProactiveLabels(sessionDir, args) }) : readProactiveReport(sessionDir))}`);
|
|
1206
|
+
ctx.ui.notify(lines.join("\n\n"), "info");
|
|
1207
|
+
},
|
|
1208
|
+
handleZoom: async (args, ctx) => {
|
|
1209
|
+
widgetCtx = ctx;
|
|
1210
|
+
const arg = args?.trim() || "";
|
|
1211
|
+
const rid = parseResearchHandle(arg);
|
|
1212
|
+
const target: Zoomable | undefined = rid != null
|
|
1213
|
+
? researchStates.get(rid)
|
|
1214
|
+
: arg
|
|
1215
|
+
? agentStates.get(arg.toLowerCase()) ?? findDelegationChild(arg)?.child
|
|
1216
|
+
: undefined;
|
|
1217
|
+
if (!target) {
|
|
1218
|
+
const teamKnown = Array.from(agentStates.values()).map(s => displayName(s.def.name)).join(", ");
|
|
1219
|
+
const researchKnown = Array.from(researchStates.values()).map(s => `r${s.id}`).join(", ");
|
|
1220
|
+
const childKnown = Array.from(agentStates.values())
|
|
1221
|
+
.flatMap(s => Array.from(s.delegations?.keys() || [])).join(", ");
|
|
1222
|
+
const known = [teamKnown, researchKnown, childKnown].filter(Boolean).join(", ");
|
|
1223
|
+
ctx.ui.notify(`Usage: /af-zoom <name|rN|child-id>. Known: ${known || "none"}`, "error");
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1226
|
+
const rowKey = (rid != null ? `r${rid}` : arg).toLowerCase();
|
|
1227
|
+
const row = fleetRows(true).find(r => r.key.toLowerCase() === rowKey);
|
|
1228
|
+
if (row) await openFleetDetail(row, ctx);
|
|
1229
|
+
else await openZoom(target, ctx);
|
|
1230
|
+
},
|
|
1231
|
+
handleDispatchPolicy: async (_args, ctx) => {
|
|
1232
|
+
widgetCtx = ctx;
|
|
1233
|
+
const live = new Set(comsReady && identity ? peersInScope().map(e => e.name.toLowerCase()) : []);
|
|
1234
|
+
const lines = Array.from(agentStates.values()).map(s => {
|
|
1235
|
+
const key = s.def.name.toLowerCase();
|
|
1236
|
+
const sub = dispatchPolicy.substitutions[key];
|
|
1237
|
+
const prefer = sub ? sub.prefer : dispatchPolicy.default === "coms" ? "coms" : "native";
|
|
1238
|
+
if (prefer !== "coms") return `${displayName(s.def.name)}: native`;
|
|
1239
|
+
const fb = sub?.fallback === "none" ? "coms-required" : "coms, fallback native";
|
|
1240
|
+
return `${displayName(s.def.name)}: ${fb} — peer ${live.has(key) ? "LIVE" : "not in pool"}`;
|
|
1241
|
+
});
|
|
1242
|
+
const policyPath = join(ctx.cwd || process.cwd(), ".pi", "agents", "dispatch-policy.yaml");
|
|
1243
|
+
const src = existsSync(policyPath) ? ".pi/agents/dispatch-policy.yaml" : "(no dispatch-policy.yaml — all native)";
|
|
1244
|
+
ctx.ui.notify(
|
|
1245
|
+
`Dispatch backends — ${src}, default: ${dispatchPolicy.default}\n${lines.join("\n") || "(no active team)"}\n` +
|
|
1246
|
+
`Routing is decided per dispatch against the live coms pool (/af-coms to refresh).`,
|
|
1247
|
+
"info",
|
|
1248
|
+
);
|
|
1249
|
+
},
|
|
1250
|
+
handleAgentModel: async (args, ctx) => {
|
|
1251
|
+
widgetCtx = ctx;
|
|
1252
|
+
const arg = (args || "").trim().toLowerCase();
|
|
1253
|
+
|
|
1254
|
+
// Dot form: <persona>.<role> targets a delegate sub-role. Candidates are
|
|
1255
|
+
// the role's declared model (default) + the parent's candidate list.
|
|
1256
|
+
if (arg.includes(".")) {
|
|
1257
|
+
const dot = arg.indexOf(".");
|
|
1258
|
+
const personaName = arg.slice(0, dot);
|
|
1259
|
+
const roleName = arg.slice(dot + 1);
|
|
1260
|
+
const parent = agentStates.get(personaName);
|
|
1261
|
+
const roles = parent?.def.subagents || {};
|
|
1262
|
+
const roleKey = Object.keys(roles).find(r => r.toLowerCase() === roleName);
|
|
1263
|
+
if (!parent || !roleKey) {
|
|
1264
|
+
const valid = Array.from(agentStates.values()).flatMap(s =>
|
|
1265
|
+
Object.keys(s.def.subagents || {}).map(r => `${s.def.name}.${r}`));
|
|
1266
|
+
ctx.ui.notify(
|
|
1267
|
+
`No sub-role "${arg}". Valid targets: ${valid.join(", ") || "none (no persona declares subagents:)"}`,
|
|
1268
|
+
"error",
|
|
1269
|
+
);
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
const role = roles[roleKey];
|
|
1273
|
+
const overrideKey = `${personaName}.${roleKey.toLowerCase()}`;
|
|
1274
|
+
const candidates: string[] = [];
|
|
1275
|
+
for (const m of [role.model, ...allowedModels(parent.def)]) {
|
|
1276
|
+
if (m && !candidates.includes(m)) candidates.push(m);
|
|
1277
|
+
}
|
|
1278
|
+
const current = resolvedSubagentModel(parent.def.name, roleKey, role.model);
|
|
1279
|
+
const options = candidates.map(m => {
|
|
1280
|
+
const tags = [m === role.model ? "default" : "", m === current ? "current" : ""].filter(Boolean);
|
|
1281
|
+
return tags.length ? `${m} (${tags.join(", ")})` : m;
|
|
1282
|
+
});
|
|
1283
|
+
const label = `${displayName(parent.def.name)}.${roleKey}`;
|
|
1284
|
+
const choice = await ctx.ui.select(`Model for ${label}`, options);
|
|
1285
|
+
if (choice === undefined) return;
|
|
1286
|
+
const picked = candidates[options.indexOf(choice)];
|
|
1287
|
+
const effectivePicked = substitutedModel(picked) ?? picked;
|
|
1288
|
+
if (effectivePicked === current) {
|
|
1289
|
+
ctx.ui.notify(`${label} is already on ${effectivePicked}`, "info");
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
if (picked === role.model) {
|
|
1293
|
+
modelPolicy.setSubagentOverride(personaName, roleKey, undefined);
|
|
1294
|
+
} else {
|
|
1295
|
+
modelPolicy.setSubagentOverride(personaName, roleKey, picked);
|
|
1296
|
+
}
|
|
1297
|
+
updateWidget();
|
|
1298
|
+
ctx.ui.notify(
|
|
1299
|
+
`${label} → ${effectivePicked} (applies on next dispatch of ${parent.def.name})`,
|
|
1300
|
+
"info",
|
|
1301
|
+
);
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
const name = arg;
|
|
1306
|
+
// Team member (live state) OR a research persona — both switchable.
|
|
1307
|
+
const def = name ? switchablePersonaDef(name) : undefined;
|
|
1308
|
+
if (!def) {
|
|
1309
|
+
const known = [
|
|
1310
|
+
...Array.from(agentStates.values()).map(s => s.def.name),
|
|
1311
|
+
...researchPersonas.map(d => d.name),
|
|
1312
|
+
].join(", ");
|
|
1313
|
+
ctx.ui.notify(`Usage: /af-agent-model <persona>[.<role>]. Known: ${known || "none"}`, "error");
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
if (!def.models || def.models.length === 0) {
|
|
1317
|
+
ctx.ui.notify(
|
|
1318
|
+
`${displayName(def.name)} declares no model candidates — add a \`models:\` list to ${def.file} or a \`models.${def.name}:\` override in .ai/agent-fleet-overrides.md.`,
|
|
1319
|
+
"warning",
|
|
1320
|
+
);
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
const candidates = allowedModels(def);
|
|
1324
|
+
const current = resolvedModel(def);
|
|
1325
|
+
// A persona without a frontmatter default runs on the dispatcher's model —
|
|
1326
|
+
// offer that as an explicit candidate so the override can be cleared.
|
|
1327
|
+
const DISPATCHER_DEFAULT = "(dispatcher's model)";
|
|
1328
|
+
if (!def.model) candidates.unshift(DISPATCHER_DEFAULT);
|
|
1329
|
+
const options = candidates.map(m => {
|
|
1330
|
+
const isDefault = def.model ? m === def.model : m === DISPATCHER_DEFAULT;
|
|
1331
|
+
const isCurrent = current ? m === current : m === DISPATCHER_DEFAULT;
|
|
1332
|
+
const tags = [isDefault ? "default" : "", isCurrent ? "current" : ""].filter(Boolean);
|
|
1333
|
+
return tags.length ? `${m} (${tags.join(", ")})` : m;
|
|
1334
|
+
});
|
|
1335
|
+
const choice = await ctx.ui.select(`Model for ${displayName(def.name)}`, options);
|
|
1336
|
+
if (choice === undefined) return;
|
|
1337
|
+
const picked = candidates[options.indexOf(choice)];
|
|
1338
|
+
const effectivePicked = picked === DISPATCHER_DEFAULT ? picked : (substitutedModel(picked) ?? picked);
|
|
1339
|
+
const pickedIsCurrent = current ? effectivePicked === current : picked === DISPATCHER_DEFAULT;
|
|
1340
|
+
if (pickedIsCurrent) {
|
|
1341
|
+
ctx.ui.notify(`${displayName(def.name)} is already on ${effectivePicked}`, "info");
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
|
+
if (picked === def.model || picked === DISPATCHER_DEFAULT) {
|
|
1345
|
+
modelPolicy.setPersonaOverride(name, undefined);
|
|
1346
|
+
} else {
|
|
1347
|
+
modelPolicy.setPersonaOverride(name, picked);
|
|
1348
|
+
}
|
|
1349
|
+
updateWidget();
|
|
1350
|
+
// Research helpers spawn fresh each time, so the switch lands on their
|
|
1351
|
+
// next spawn; team members apply on next dispatch (restartable now).
|
|
1352
|
+
const applyHint = (def.kind || "").toLowerCase() === "research"
|
|
1353
|
+
? "applies on next spawn_research"
|
|
1354
|
+
: `applies on next dispatch; /af-agents-restart ${def.name} to apply now`;
|
|
1355
|
+
ctx.ui.notify(`${displayName(def.name)} → ${effectivePicked} (${applyHint})`, "info");
|
|
1356
|
+
if ((dispatchPolicy.substitutions[name]?.prefer ?? dispatchPolicy.default) === "coms") {
|
|
1357
|
+
ctx.ui.notify(
|
|
1358
|
+
`Note: ${displayName(def.name)} prefers a coms peer (dispatch-policy.yaml) — this model override only applies to native(-fallback) runs; the peer keeps its own model.`,
|
|
1359
|
+
"info",
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
handleAgentModelThinking: async (args, ctx) => {
|
|
1364
|
+
widgetCtx = ctx;
|
|
1365
|
+
const name = (args || "").trim().toLowerCase();
|
|
1366
|
+
// Team member (live state) OR a research persona — both switchable.
|
|
1367
|
+
const def = name ? switchablePersonaDef(name) : undefined;
|
|
1368
|
+
if (!def) {
|
|
1369
|
+
const known = [
|
|
1370
|
+
...Array.from(agentStates.values()).map(s => s.def.name),
|
|
1371
|
+
...researchPersonas.map(d => d.name),
|
|
1372
|
+
].join(", ");
|
|
1373
|
+
ctx.ui.notify(`Usage: /af-agent-model-thinking <persona>. Known: ${known || "none"}`, "error");
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
const defaultLevel = resolveThinkingLevel(def.thinking);
|
|
1377
|
+
const current = resolveThinkingLevel(resolvedThinking(def));
|
|
1378
|
+
const levels = [...THINKING_LEVELS];
|
|
1379
|
+
const options = levels.map(l => {
|
|
1380
|
+
const tags = [l === defaultLevel ? "default" : "", l === current ? "current" : ""].filter(Boolean);
|
|
1381
|
+
return tags.length ? `${l} (${tags.join(", ")})` : l;
|
|
1382
|
+
});
|
|
1383
|
+
const choice = await ctx.ui.select(`Thinking level for ${displayName(def.name)}`, options);
|
|
1384
|
+
if (choice === undefined) return;
|
|
1385
|
+
const picked = levels[options.indexOf(choice)];
|
|
1386
|
+
if (picked === current) {
|
|
1387
|
+
ctx.ui.notify(`${displayName(def.name)} is already on thinking: ${picked}`, "info");
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
if (picked === defaultLevel) {
|
|
1391
|
+
modelPolicy.setThinkingOverride(name, undefined);
|
|
1392
|
+
} else {
|
|
1393
|
+
modelPolicy.setThinkingOverride(name, picked);
|
|
1394
|
+
}
|
|
1395
|
+
updateWidget();
|
|
1396
|
+
// Research helpers spawn fresh each time, so the switch lands on their
|
|
1397
|
+
// next spawn; team members apply on next dispatch (restartable now).
|
|
1398
|
+
const applyHint = (def.kind || "").toLowerCase() === "research"
|
|
1399
|
+
? "applies on next spawn_research"
|
|
1400
|
+
: `applies on next dispatch; /af-agents-restart ${def.name} to apply now`;
|
|
1401
|
+
ctx.ui.notify(`${displayName(def.name)} thinking → ${picked} (${applyHint})`, "info");
|
|
1402
|
+
},
|
|
1403
|
+
handleModels: async (args, ctx) => {
|
|
1404
|
+
widgetCtx = ctx;
|
|
1405
|
+
const names = Object.keys(modelProfiles);
|
|
1406
|
+
if (names.length === 0) {
|
|
1407
|
+
ctx.ui.notify("No model profiles loaded — define .pi/agents/model-profiles.yaml (invalid profiles are dropped at session start).", "warning");
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
let profileName = (args || "").trim();
|
|
1411
|
+
if (!profileName) {
|
|
1412
|
+
const options = names.map(n =>
|
|
1413
|
+
isCompleteProfile(modelProfiles[n])
|
|
1414
|
+
? `${n} — complete fleet (${shortModel((modelProfiles[n] as any).defaults.model)} default)`
|
|
1415
|
+
: `${n} — ${Object.entries(modelProfiles[n]).map(([p, m]) => `${p}: ${shortModel(m)}`).join(", ")}`,
|
|
1416
|
+
);
|
|
1417
|
+
const choice = await ctx.ui.select("Select model profile", options);
|
|
1418
|
+
if (choice === undefined) return;
|
|
1419
|
+
profileName = names[options.indexOf(choice)];
|
|
1420
|
+
}
|
|
1421
|
+
const profile = modelProfiles[profileName];
|
|
1422
|
+
if (!profile) {
|
|
1423
|
+
ctx.ui.notify(`No profile "${profileName}". Known: ${names.join(", ")}`, "error");
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
profileCommandContext=ctx;
|
|
1427
|
+
try {
|
|
1428
|
+
const applied=await profileActivation.activate(profileName,profile);
|
|
1429
|
+
applyWorkModeTools();
|
|
1430
|
+
ctx.ui.setStatus('hub-model-profile',isCompleteProfile(profile)?`Models: ${profileName}`:undefined);
|
|
1431
|
+
ctx.ui.notify(`Profile "${profileName}": ${applied.length} personas${isCompleteProfile(profile)?', all children, dispatcher and auxiliary models':''} switched.`, 'info');
|
|
1432
|
+
} catch(error) {ctx.ui.notify(String(error),'error');}
|
|
1433
|
+
},
|
|
1434
|
+
handleAgentModelsSubstitute: async (args, ctx) => {
|
|
1435
|
+
widgetCtx = ctx;
|
|
1436
|
+
const tokens = (args || "").trim().split(/\s+/).filter(Boolean);
|
|
1437
|
+
if (tokens.length === 0) {
|
|
1438
|
+
if (allKnownModels().length === 0) {
|
|
1439
|
+
ctx.ui.notify("No configured persona or sub-role models are available as substitution sources.", "warning");
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
await openFleetDashboard(ctx, true);
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
if (tokens.length !== 2) {
|
|
1446
|
+
ctx.ui.notify("Usage: /af-agent-models-substitute [<source> <target>]", "error");
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
await applySessionModelSubstitution(tokens[0], tokens[1], ctx);
|
|
1450
|
+
},
|
|
1451
|
+
handleWatchdog: async (args, ctx) => {
|
|
1452
|
+
widgetCtx = ctx;
|
|
1453
|
+
const parts = (args || "").trim().split(/\s+/).filter(Boolean);
|
|
1454
|
+
if (parts.length === 0) {
|
|
1455
|
+
const perAgent = watchdogAgentOverrides.size > 0
|
|
1456
|
+
? Array.from(watchdogAgentOverrides.entries()).map(([k, v]) => `${k}: ${v}`).join(", ")
|
|
1457
|
+
: "(none)";
|
|
1458
|
+
ctx.ui.notify(
|
|
1459
|
+
`Drift watchdog: ${watchdogSetting} (hub-wide)\nPer-agent overrides: ${perAgent}\n` +
|
|
1460
|
+
`Judge model: ${watchdogJudgeModel || "(researcher persona's, else dispatcher's)"}\n` +
|
|
1461
|
+
`${formatWatchdogStatus(watchdogSystem1, watchdogActivity)}\n` +
|
|
1462
|
+
`Usage: /af-watchdog on|off|auto — or /af-watchdog <agent> on|off|clear`,
|
|
1463
|
+
"info",
|
|
1464
|
+
);
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
if (parts.length === 1) {
|
|
1468
|
+
const setting = normalizeWatchdogSetting(parts[0]);
|
|
1469
|
+
if (!setting) {
|
|
1470
|
+
ctx.ui.notify(`Unknown setting "${parts[0]}" — expected one of: ${WATCHDOG_SETTINGS.join(", ")} (or /af-watchdog <agent> on|off|clear)`, "error");
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
watchdogSetting = setting;
|
|
1474
|
+
ctx.ui.notify(`Drift watchdog → ${setting} (applies from the next dispatch)`, "info");
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
const agentKey = normalizeAgentInput(parts[0]);
|
|
1478
|
+
const value = parts[1].toLowerCase();
|
|
1479
|
+
if (!agentStates.has(agentKey)) {
|
|
1480
|
+
ctx.ui.notify(`"${parts[0]}" is not in the active team (${Array.from(agentStates.values()).map(s => s.def.name).join(", ")})`, "error");
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
if (value === "clear") {
|
|
1484
|
+
watchdogAgentOverrides.delete(agentKey);
|
|
1485
|
+
ctx.ui.notify(`Drift watchdog override cleared for ${agentKey} (hub-wide setting "${watchdogSetting}" applies)`, "info");
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
if (value !== "on" && value !== "off") {
|
|
1489
|
+
ctx.ui.notify(`Per-agent watchdog must be on, off, or clear — got "${parts[1]}"`, "error");
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1492
|
+
watchdogAgentOverrides.set(agentKey, value);
|
|
1493
|
+
ctx.ui.notify(`Drift watchdog for ${agentKey} → ${value} (overrides the hub-wide "${watchdogSetting}")`, "info");
|
|
1494
|
+
},
|
|
1495
|
+
handleComs: async (args, ctx) => {
|
|
1496
|
+
if (!comsReady) { ctx.ui.notify("coms is not active in this session.", "warning"); return; }
|
|
1497
|
+
await coms.updateScope((args ?? "").trim(), ctx);
|
|
1498
|
+
},
|
|
1499
|
+
handleHandoff: async (args, ctx) => {
|
|
1500
|
+
if (modelWorkBlockedByRosterRecovery(ctx)) return;
|
|
1501
|
+
if (!comsReady) { ctx.ui.notify("coms is not active in this session — /af-handoff unavailable.", "warning"); return; }
|
|
1502
|
+
const target = (args ?? "").trim();
|
|
1503
|
+
if (!target) {
|
|
1504
|
+
ctx.ui.notify("Usage: /af-handoff <peer>. See the coms pool for live peer names.", "error");
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
const peer = resolveTarget(target);
|
|
1508
|
+
if (!peer) {
|
|
1509
|
+
ctx.ui.notify(`coms: no live peer "${target}". Use /af-coms to refresh the pool.`, "error");
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
const refusal=profilePeerGate({ peerModel: peer.model, targetResolved: true });if(refusal){ctx.ui.notify(refusal.content[0].text,"error");return;}
|
|
1513
|
+
const handoffToken = crypto.randomBytes(8).toString("hex");
|
|
1514
|
+
hubStateCtx.setPendingHandoff({ target: peer.name, token: handoffToken });
|
|
1515
|
+
pi.sendMessage({
|
|
1516
|
+
customType: "coms-handoff",
|
|
1517
|
+
content:
|
|
1518
|
+
`HANDOFF REQUEST → peer "${peer.name}".\n\n` +
|
|
1519
|
+
`Compose a SELF-CONTAINED handoff brief (the peer does NOT share your context): state the ` +
|
|
1520
|
+
`overall goal, what's been done so far, key decisions and constraints, the current status, ` +
|
|
1521
|
+
`and the concrete next steps you want the peer to take. Then call ` +
|
|
1522
|
+
`coms_send(target: "${peer.name}", handoff_token: "${handoffToken}", prompt: <the brief only; the hub appends the verification ledger and artifact index in code only when this token matches>), coms_await its msg_id, and relay ` +
|
|
1523
|
+
`the peer's reply to me in ${userLanguage}.`,
|
|
1524
|
+
display: true,
|
|
1525
|
+
}, { deliverAs: "followUp", triggerTurn: true });
|
|
1526
|
+
ctx.ui.notify(`Handoff to ${peer.name}: asking the dispatcher to compose a brief…`, "info");
|
|
1527
|
+
},
|
|
1528
|
+
handleCompound: async (args, ctx) => {
|
|
1529
|
+
if (modelWorkBlockedByRosterRecovery(ctx)) return;
|
|
1530
|
+
if (!agentStates.has("documenter")) {
|
|
1531
|
+
ctx.ui.notify(
|
|
1532
|
+
"compound: the documenter persona is not in the active team — switch with /af-agents-team (e.g. default or release), then re-run /af-compound.",
|
|
1533
|
+
"warning",
|
|
1534
|
+
);
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
const focus = (args ?? "").trim();
|
|
1538
|
+
const rulesLine = projectRulesDirs.length > 0
|
|
1539
|
+
? projectRulesDirs.join(", ")
|
|
1540
|
+
: "(none declared in .ai/agent-fleet-overrides.md — the documenter must locate an existing rules tree or, failing that, propose lessons without writing)";
|
|
1541
|
+
const docsLine = projectDocsPaths.length > 0
|
|
1542
|
+
? projectDocsPaths.join(", ")
|
|
1543
|
+
: "(none declared)";
|
|
1544
|
+
pi.sendMessage({
|
|
1545
|
+
customType: "compound-learning",
|
|
1546
|
+
content:
|
|
1547
|
+
`COMPOUND REQUEST — capture this session's lessons into the project's rules and docs (compound-learning pass).\n\n` +
|
|
1548
|
+
`1. From THIS session's context, compose a candidate-lessons brief: user corrections, review findings that recurred, ` +
|
|
1549
|
+
`wrong assumptions that cost rework, debugging root causes, and changes that invalidated existing docs. At most 5 lessons; ` +
|
|
1550
|
+
`each is one imperative sentence plus a one-line Why (the failure it prevents) and a one-line Evidence (what happened this session). ` +
|
|
1551
|
+
`${focus ? `Focus especially on: ${focus}. ` : ""}` +
|
|
1552
|
+
`If nothing rises to a lesson, tell the user there is nothing worth compounding and stop.\n` +
|
|
1553
|
+
`2. Confirm the list with the user in ${userLanguage} (ask_user when available) — they approve, trim, or reword. Do not dispatch before this confirmation.\n` +
|
|
1554
|
+
`3. Dispatch the documenter with a SELF-CONTAINED task (it shares none of your context) containing: the approved lessons verbatim ` +
|
|
1555
|
+
`(with Why + Evidence); the project rule folders: ${rulesLine}; the docs entry points: ${docsLine}; the assertion ledger path ` +
|
|
1556
|
+
`.pi/agent-sessions/assertions.json (when it exists); and the instruction to read skills/compound-learning/SKILL.md and follow it exactly — ` +
|
|
1557
|
+
`dedupe index-first against the existing rule tree, minimal diffs on existing files, caps of 5 lessons / 1 new file. State that the user ` +
|
|
1558
|
+
`already approved this lesson list, so it may apply without a second gate. Pass the relevant review/return/evidence artifact paths via the ` +
|
|
1559
|
+
`dispatch's artifacts array — paths only, never pasted bodies.\n` +
|
|
1560
|
+
`4. Relay the documenter's file-by-file result to me in ${userLanguage}.`,
|
|
1561
|
+
display: true,
|
|
1562
|
+
}, { deliverAs: "followUp", triggerTurn: true });
|
|
1563
|
+
ctx.ui.notify("Compound: asking the dispatcher to compose the candidate-lessons brief…", "info");
|
|
1564
|
+
},
|
|
1565
|
+
handlePoll: async (args, ctx) => {
|
|
1566
|
+
return withProfileWork(async () => {
|
|
1567
|
+
if (modelWorkBlockedByRosterRecovery(ctx)) return;
|
|
1568
|
+
const cwd = ctx.cwd || process.cwd();
|
|
1569
|
+
const result = await handleAfPoll({
|
|
1570
|
+
args: args ?? "",
|
|
1571
|
+
cwd,
|
|
1572
|
+
pollPanelOverride: readActiveProfile()?.name ?? parseAgentTeamOverrides(cwd).pollPanel,
|
|
1573
|
+
listPanels: async dir => {
|
|
1574
|
+
const { listPanelNames } = await import("../../agent-fleet/scripts/workflows/lib/voices.ts");
|
|
1575
|
+
return listPanelNames(dir);
|
|
1576
|
+
},
|
|
1577
|
+
preflight: async ({ panel, persona, cwd: root }) => {
|
|
1578
|
+
const [{ resolvePersona }, { resolvePanel }, { checkChildVisibility }] = await Promise.all([
|
|
1579
|
+
import("../../agent-fleet/scripts/workflows/lib/personas.ts"),
|
|
1580
|
+
import("../../agent-fleet/scripts/workflows/lib/voices.ts"),
|
|
1581
|
+
import("../../agent-fleet/scripts/workflows/lib/model-visibility.ts"),
|
|
1582
|
+
]);
|
|
1583
|
+
try { resolvePersona(persona, root); }
|
|
1584
|
+
catch (error) { return error instanceof Error ? error.message : String(error); }
|
|
1585
|
+
let voices;
|
|
1586
|
+
try { voices = resolvePanel(panel, root); }
|
|
1587
|
+
catch (error) { return error instanceof Error ? error.message : String(error); }
|
|
1588
|
+
const report = checkChildVisibility(voices.map(voice => voice.model));
|
|
1589
|
+
if (report.diagnostic) return `could not verify clean-room model visibility (${report.diagnostic})`;
|
|
1590
|
+
const hidden = report.models.filter(model => !model.ok);
|
|
1591
|
+
if (hidden.length) {
|
|
1592
|
+
return `panel "${panel}" has models not visible to a clean-room child: ${hidden.map(model => model.reasons[0] ?? model.model).join("; ")}`;
|
|
1593
|
+
}
|
|
1594
|
+
return null;
|
|
1595
|
+
},
|
|
1596
|
+
checkBudget: async () => {
|
|
1597
|
+
ensureTaskTier();
|
|
1598
|
+
const blocked = await budgetRecovery.ensure("dispatch", args ?? "model panel", ctx);
|
|
1599
|
+
return blocked?.message ?? null;
|
|
1600
|
+
},
|
|
1601
|
+
chargeBudget: () => {
|
|
1602
|
+
turnDispatchCount += 1;
|
|
1603
|
+
taskDispatchCount += 1;
|
|
1604
|
+
sessionTotals.dispatches += 1;
|
|
1605
|
+
updateModeStatus();
|
|
1606
|
+
},
|
|
1607
|
+
onAccepted: async ({ panel, persona, question }) => {
|
|
1608
|
+
let voices: { name: string; model: string }[] = [];
|
|
1609
|
+
try {
|
|
1610
|
+
const { resolvePanel } = await import("../../agent-fleet/scripts/workflows/lib/voices.ts");
|
|
1611
|
+
voices = resolvePanel(panel, cwd).map(voice => ({ name: voice.name, model: voice.model }));
|
|
1612
|
+
} catch { /* names are decorative */ }
|
|
1613
|
+
const started = formatAfPollStarted({ panel, persona, question, voices });
|
|
1614
|
+
ctx.ui.setStatus("hub-poll", `Poll: ${panel} (${voices.length || "?"} voices) running…`);
|
|
1615
|
+
ctx.ui.notify(`Poll started — panel ${panel}. This can take a minute.`, "info");
|
|
1616
|
+
pi.sendMessage({ customType: "af-poll-started", content: started, display: true }, { deliverAs: "followUp", triggerTurn: false });
|
|
1617
|
+
},
|
|
1618
|
+
execute: async ({ panel, persona, question }) => {
|
|
1619
|
+
const [{ Run }, { runPoll }, { runMerge }, { resolvePersona }] = await Promise.all([
|
|
1620
|
+
import("../../agent-fleet/scripts/workflows/lib/run.ts"),
|
|
1621
|
+
import("../../agent-fleet/scripts/workflows/lib/poll.ts"),
|
|
1622
|
+
import("../../agent-fleet/scripts/workflows/lib/merge.ts"),
|
|
1623
|
+
import("../../agent-fleet/scripts/workflows/lib/personas.ts"),
|
|
1624
|
+
]);
|
|
1625
|
+
const run = new Run({ cwd, command: ["/af-poll", "--panel", panel, question] });
|
|
1626
|
+
const personaDef = resolvePersona(persona, cwd);
|
|
1627
|
+
const poll = await runPoll({
|
|
1628
|
+
run, cwd, persona: personaDef, panel, task: question,
|
|
1629
|
+
onVoice: result => {
|
|
1630
|
+
const voice = result.ok
|
|
1631
|
+
? { name: result.voice.name, model: result.voice.model, ok: true as const, position: result.report.position, confidence: result.report.confidence }
|
|
1632
|
+
: { name: result.voice.name, model: result.voice.model, ok: false as const, reason: result.reason };
|
|
1633
|
+
pi.sendMessage({ customType: "af-poll-voice", content: formatAfPollVoiceProgress(voice), display: true }, { deliverAs: "followUp", triggerTurn: false });
|
|
1634
|
+
},
|
|
1635
|
+
});
|
|
1636
|
+
ctx.ui.setStatus("hub-poll", `Poll: ${panel} merging…`);
|
|
1637
|
+
const merge = await runMerge({ run, cwd, persona: personaDef, panel, task: question, opinions: poll.results });
|
|
1638
|
+
const directory = path.relative(cwd, poll.directory) || poll.directory;
|
|
1639
|
+
return {
|
|
1640
|
+
panel,
|
|
1641
|
+
directory: directory.endsWith(path.sep) ? directory : `${directory}${path.sep}`,
|
|
1642
|
+
voices: poll.results.map(item => item.ok
|
|
1643
|
+
? { name: item.voice.name, model: item.voice.model, ok: true as const, position: item.report.position, confidence: item.report.confidence }
|
|
1644
|
+
: { name: item.voice.name, model: item.voice.model, ok: false as const, reason: item.reason }),
|
|
1645
|
+
recommendation: merge.report.recommendation,
|
|
1646
|
+
integrator: merge.integrator.name,
|
|
1647
|
+
};
|
|
1648
|
+
},
|
|
1649
|
+
});
|
|
1650
|
+
ctx.ui.setStatus("hub-poll", "");
|
|
1651
|
+
if (!result.ok) {
|
|
1652
|
+
ctx.ui.notify(result.message, "error");
|
|
1653
|
+
pi.sendMessage({ customType: "af-poll-failed", content: `POLL FAILED\n\n${result.message}`, display: true }, { deliverAs: "followUp", triggerTurn: false });
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
ctx.ui.notify(result.digest ?? result.message, "info");
|
|
1657
|
+
pi.sendMessage({
|
|
1658
|
+
customType: "af-poll",
|
|
1659
|
+
content: result.dispatcherNote ?? result.message,
|
|
1660
|
+
display: true,
|
|
1661
|
+
}, { deliverAs: "followUp", triggerTurn: true });
|
|
1662
|
+
});
|
|
1663
|
+
},
|
|
1664
|
+
handleDebate: async (args, ctx) => {
|
|
1665
|
+
return withProfileWork(async () => {
|
|
1666
|
+
if (modelWorkBlockedByRosterRecovery(ctx)) return;
|
|
1667
|
+
const cwd = ctx.cwd || process.cwd();
|
|
1668
|
+
const result = await handleAfDebate({
|
|
1669
|
+
args: args ?? "",
|
|
1670
|
+
cwd,
|
|
1671
|
+
pollPanelOverride: readActiveProfile()?.name ?? parseAgentTeamOverrides(cwd).pollPanel,
|
|
1672
|
+
listPanels: async dir => {
|
|
1673
|
+
const { listPanelNames } = await import("../../agent-fleet/scripts/workflows/lib/voices.ts");
|
|
1674
|
+
return listPanelNames(dir);
|
|
1675
|
+
},
|
|
1676
|
+
preflight: async ({ panel, persona, cwd: root }) => {
|
|
1677
|
+
const [{ resolvePersona }, { resolvePanel }, { checkChildVisibility }] = await Promise.all([
|
|
1678
|
+
import("../../agent-fleet/scripts/workflows/lib/personas.ts"),
|
|
1679
|
+
import("../../agent-fleet/scripts/workflows/lib/voices.ts"),
|
|
1680
|
+
import("../../agent-fleet/scripts/workflows/lib/model-visibility.ts"),
|
|
1681
|
+
]);
|
|
1682
|
+
try { resolvePersona(persona, root); }
|
|
1683
|
+
catch (error) { return error instanceof Error ? error.message : String(error); }
|
|
1684
|
+
let voices;
|
|
1685
|
+
try { voices = resolvePanel(panel, root); }
|
|
1686
|
+
catch (error) { return error instanceof Error ? error.message : String(error); }
|
|
1687
|
+
const report = checkChildVisibility(voices.map(voice => voice.model));
|
|
1688
|
+
if (report.diagnostic) return `could not verify clean-room model visibility (${report.diagnostic})`;
|
|
1689
|
+
const hidden = report.models.filter(model => !model.ok);
|
|
1690
|
+
if (hidden.length) {
|
|
1691
|
+
return `panel "${panel}" has models not visible to a clean-room child: ${hidden.map(model => model.reasons[0] ?? model.model).join("; ")}`;
|
|
1692
|
+
}
|
|
1693
|
+
return null;
|
|
1694
|
+
},
|
|
1695
|
+
checkBudget: async () => {
|
|
1696
|
+
ensureTaskTier();
|
|
1697
|
+
const blocked = await budgetRecovery.ensure("dispatch", args ?? "model panel", ctx);
|
|
1698
|
+
return blocked?.message ?? null;
|
|
1699
|
+
},
|
|
1700
|
+
chargeBudget: () => {
|
|
1701
|
+
turnDispatchCount += 1;
|
|
1702
|
+
taskDispatchCount += 1;
|
|
1703
|
+
sessionTotals.dispatches += 1;
|
|
1704
|
+
updateModeStatus();
|
|
1705
|
+
},
|
|
1706
|
+
onAccepted: async ({ panel, persona, question, rounds }) => {
|
|
1707
|
+
let voices: { name: string; model: string }[] = [];
|
|
1708
|
+
try {
|
|
1709
|
+
const { resolvePanel } = await import("../../agent-fleet/scripts/workflows/lib/voices.ts");
|
|
1710
|
+
voices = resolvePanel(panel, cwd).map(voice => ({ name: voice.name, model: voice.model }));
|
|
1711
|
+
} catch { /* names are decorative */ }
|
|
1712
|
+
const started = formatAfDebateStarted({ panel, persona, question, rounds, voices });
|
|
1713
|
+
ctx.ui.setStatus("hub-poll", `Debate: ${panel} (${rounds} rounds) running…`);
|
|
1714
|
+
ctx.ui.notify(`Debate started — panel ${panel}, ${rounds} rounds.`, "info");
|
|
1715
|
+
pi.sendMessage({ customType: "af-debate-started", content: started, display: true }, { deliverAs: "followUp", triggerTurn: false });
|
|
1716
|
+
},
|
|
1717
|
+
execute: async ({ panel, persona, question, rounds }) => {
|
|
1718
|
+
const [{ Run }, { runDebate }, { resolvePersona }] = await Promise.all([
|
|
1719
|
+
import("../../agent-fleet/scripts/workflows/lib/run.ts"),
|
|
1720
|
+
import("../../agent-fleet/scripts/workflows/lib/debate.ts"),
|
|
1721
|
+
import("../../agent-fleet/scripts/workflows/lib/personas.ts"),
|
|
1722
|
+
]);
|
|
1723
|
+
const run = new Run({ cwd, command: ["/af-debate", "--panel", panel, "--rounds", String(rounds), question] });
|
|
1724
|
+
const personaDef = resolvePersona(persona, cwd);
|
|
1725
|
+
const debate = await runDebate({
|
|
1726
|
+
run, cwd, persona: personaDef, panel, task: question, rounds,
|
|
1727
|
+
onVoice: (result, round) => {
|
|
1728
|
+
const voice = result.ok
|
|
1729
|
+
? { name: result.voice.name, model: result.voice.model, ok: true as const, round, position: result.report.position, changed: result.report.changed }
|
|
1730
|
+
: { name: result.voice.name, model: result.voice.model, ok: false as const, round, reason: result.reason };
|
|
1731
|
+
ctx.ui.setStatus("hub-poll", `Debate: ${panel} round ${round}…`);
|
|
1732
|
+
pi.sendMessage({ customType: "af-debate-voice", content: formatAfDebateVoiceProgress(voice), display: true }, { deliverAs: "followUp", triggerTurn: false });
|
|
1733
|
+
},
|
|
1734
|
+
});
|
|
1735
|
+
const last = debate.roundsRun.at(-1)?.results ?? [];
|
|
1736
|
+
const directory = path.relative(cwd, debate.directory) || debate.directory;
|
|
1737
|
+
return {
|
|
1738
|
+
panel, rounds: debate.rounds,
|
|
1739
|
+
directory: directory.endsWith(path.sep) ? directory : `${directory}${path.sep}`,
|
|
1740
|
+
voices: last.map(item => item.ok
|
|
1741
|
+
? { name: item.voice.name, model: item.voice.model, ok: true as const, round: item.round, position: item.report.position, changed: item.report.changed }
|
|
1742
|
+
: { name: item.voice.name, model: item.voice.model, ok: false as const, round: item.round, reason: item.reason }),
|
|
1743
|
+
};
|
|
1744
|
+
},
|
|
1745
|
+
});
|
|
1746
|
+
ctx.ui.setStatus("hub-poll", "");
|
|
1747
|
+
if (!result.ok) {
|
|
1748
|
+
ctx.ui.notify(result.message, "error");
|
|
1749
|
+
pi.sendMessage({ customType: "af-debate-failed", content: `DEBATE FAILED\n\n${result.message}`, display: true }, { deliverAs: "followUp", triggerTurn: false });
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
ctx.ui.notify(result.digest ?? result.message, "info");
|
|
1753
|
+
pi.sendMessage({
|
|
1754
|
+
customType: "af-debate",
|
|
1755
|
+
content: result.dispatcherNote ?? result.message,
|
|
1756
|
+
display: true,
|
|
1757
|
+
}, { deliverAs: "followUp", triggerTurn: true });
|
|
1758
|
+
});
|
|
1759
|
+
},
|
|
1760
|
+
getAgentsKillCompletions: prefix => completions.agentsKill(prefix),
|
|
1761
|
+
getZoomCompletions: prefix => completions.zoom(prefix),
|
|
1762
|
+
getAgentModelCompletions: prefix => completions.agentModels(prefix),
|
|
1763
|
+
getAgentModelThinkingCompletions: prefix => completions.agentThinking(prefix),
|
|
1764
|
+
getModelProfileCompletions: prefix => completions.modelProfiles(prefix),
|
|
1765
|
+
getSubstituteCompletions: prefix => completions.substitutions(prefix),
|
|
1766
|
+
getComsPeerCompletions: prefix => completions.comsPeers(prefix),
|
|
1767
|
+
getSubagentTargetCompletions: prefix => completions.subagentTargets(prefix),
|
|
1768
|
+
};
|
|
1769
|
+
|
|
1770
|
+
// Keep the complete command surface flat and greppable in this composition root.
|
|
1771
|
+
registerAgentsTeam(pi, commandCtx);
|
|
1772
|
+
registerAgentsList(pi, commandCtx);
|
|
1773
|
+
registerAgentsHistory(pi, commandCtx);
|
|
1774
|
+
registerContextCommand(pi, commandCtx);
|
|
1775
|
+
registerAudit(pi, commandCtx);
|
|
1776
|
+
registerWorkMode(pi, commandCtx);
|
|
1777
|
+
registerWatchdog(pi, commandCtx);
|
|
1778
|
+
registerAgentsAdd(pi, commandCtx);
|
|
1779
|
+
registerAgentsDrop(pi, commandCtx);
|
|
1780
|
+
registerAgentsSave(pi, commandCtx);
|
|
1781
|
+
registerHubReport(pi, commandCtx);
|
|
1782
|
+
registerZoom(pi, commandCtx);
|
|
1783
|
+
registerAgentModel(pi, commandCtx);
|
|
1784
|
+
registerAgentModelThinking(pi, commandCtx);
|
|
1785
|
+
registerModels(pi, commandCtx);
|
|
1786
|
+
registerAgentModelsSubstitute(pi, commandCtx);
|
|
1787
|
+
registerDispatchPolicy(pi, commandCtx);
|
|
1788
|
+
registerAgentsKill(pi, commandCtx);
|
|
1789
|
+
registerAgentsRestart(pi, commandCtx);
|
|
1790
|
+
registerComs(pi, commandCtx);
|
|
1791
|
+
registerHandoff(pi, commandCtx);
|
|
1792
|
+
registerCompound(pi, commandCtx);
|
|
1793
|
+
registerPoll(pi, commandCtx);
|
|
1794
|
+
registerBudgetContinue(pi, commandCtx);
|
|
1795
|
+
registerRetry(pi, commandCtx);
|
|
1796
|
+
registerRecover(pi, commandCtx);
|
|
1797
|
+
registerDebate(pi, commandCtx);
|
|
1798
|
+
|
|
1799
|
+
const detailPanel = createDetailPanel<AgentDef, AgentState, ResearchState>({
|
|
1800
|
+
getAgent: key => agentStates.get(key),
|
|
1801
|
+
getResearch: id => researchStates.get(id),
|
|
1802
|
+
parseResearchHandle,
|
|
1803
|
+
findDelegationChild,
|
|
1804
|
+
modelPolicy,
|
|
1805
|
+
displayName,
|
|
1806
|
+
shortModel,
|
|
1807
|
+
refreshUi: updateWidget,
|
|
1808
|
+
getDispatchPreference: name => (dispatchPolicy.substitutions[name.toLowerCase()]?.prefer ?? dispatchPolicy.default) === "coms" ? "coms" : "native",
|
|
1809
|
+
maxLiveEntryChars: MAX_LIVE_ENTRY_CHARS,
|
|
1810
|
+
getProactive: () => fleetSource.snapshot(Date.now()).proactive,
|
|
1811
|
+
readProactiveEvidence: (finding) => proactiveRuntime?.findings.readback(finding.snapshotHandle, finding.snapshotHash, finding.snapshotId, finding.unitId, finding.excerptHash) ?? null,
|
|
1812
|
+
currentFleetRow: key => fleetSource.rows(Date.now(), { showFinished: true }).find(row => row.key === key),
|
|
1813
|
+
});
|
|
1814
|
+
const { openFleetDetail, loadAvailableModelChoices } = detailPanel;
|
|
1815
|
+
const applySessionModelSubstitution = (source: string, target: string, ctx: any) => modelPolicy.applySessionSubstitution(source, target, {
|
|
1816
|
+
loadAvailable: current => loadAvailableModelChoices(ctx, current),
|
|
1817
|
+
notify: (message, level) => ctx.ui.notify(message, level),
|
|
1818
|
+
});
|
|
1819
|
+
|
|
1820
|
+
fleetActions = createFleetActions<AgentState, ResearchState>({
|
|
1821
|
+
getRows: () => fleetSource.rows(Date.now(), { showFinished: true }),
|
|
1822
|
+
getAgents: () => agentStates,
|
|
1823
|
+
getResearch: () => researchStates,
|
|
1824
|
+
parseResearchHandle,
|
|
1825
|
+
displayName,
|
|
1826
|
+
modelWorkBlocked: modelWorkBlockedByRosterRecovery,
|
|
1827
|
+
restartSpecialist: researchControls.restartSpecialist,
|
|
1828
|
+
removeResearch: researchControls.remove,
|
|
1829
|
+
killSpecialistProcess: state => { fenceOperatorCancel(state); cancelLocalOwnedProcess({ process: state.proc, monitorBridge, monitorKey: monitorKeyForAgent(state.def.name, state.dispatchId ?? state.runCount), treeKill: killPiTree }); },
|
|
1830
|
+
abortComs: state => { state.comsAbort?.(); },
|
|
1831
|
+
openDetail: openFleetDetail,
|
|
1832
|
+
generation: () => fleetUiGeneration,
|
|
1833
|
+
});
|
|
1834
|
+
let fleetShowFinished = false;
|
|
1835
|
+
let fleetFilter = "";
|
|
1836
|
+
const fleetDashboard = createFleetDashboard<AgentDef, AgentState, ResearchState>({
|
|
1837
|
+
onThinkingChanged: updateWidget,
|
|
1838
|
+
openSystem1: ctx => openSystem1Communication(ctx, communicationStore),
|
|
1839
|
+
getFleetRows: (now, unfiltered) => fleetSource.rows(now, unfiltered ? { showFinished: true } : { showFinished: fleetShowFinished, query: fleetFilter }),
|
|
1840
|
+
getProactive: () => fleetSource.snapshot(Date.now()).proactive,
|
|
1841
|
+
readProactiveEvidence: (finding) => proactiveRuntime?.findings.readback(finding.snapshotHandle, finding.snapshotHash, finding.snapshotId, finding.unitId, finding.excerptHash) ?? null,
|
|
1842
|
+
actions: fleetActions,
|
|
1843
|
+
getAgents: () => agentStates,
|
|
1844
|
+
getResearch: () => researchStates,
|
|
1845
|
+
getShowFinished: () => fleetShowFinished,
|
|
1846
|
+
setShowFinished: value => { fleetShowFinished = value; },
|
|
1847
|
+
getFilter: () => fleetFilter,
|
|
1848
|
+
setFilter: value => { fleetFilter = value; },
|
|
1849
|
+
parseResearchHandle,
|
|
1850
|
+
displayName,
|
|
1851
|
+
shortModel,
|
|
1852
|
+
thinkingSuffix,
|
|
1853
|
+
modelWithThinking,
|
|
1854
|
+
resolvedThinking,
|
|
1855
|
+
abbreviatePeerModel: abbreviateModel,
|
|
1856
|
+
modelPolicy,
|
|
1857
|
+
loadAvailableModels: loadAvailableModelChoices,
|
|
1858
|
+
openDetail: openFleetDetail,
|
|
1859
|
+
openHistory: ctx => openHistory(ctx, executionHistory, () => (activeTeamName ? `Team: ${activeTeamName}` : "Agent Hub")),
|
|
1860
|
+
modelWorkBlocked: modelWorkBlockedByRosterRecovery,
|
|
1861
|
+
restartSpecialist: researchControls.restartSpecialist,
|
|
1862
|
+
removeResearch: researchControls.remove,
|
|
1863
|
+
killSpecialistProcess: state => { fenceOperatorCancel(state); cancelLocalOwnedProcess({ process: state.proc, monitorBridge, monitorKey: monitorKeyForAgent(state.def.name, state.dispatchId ?? state.runCount), treeKill: killPiTree }); },
|
|
1864
|
+
abortComs: state => { state.comsAbort?.(); },
|
|
1865
|
+
getComsLines: (width, theme) => poolPresentation.render(width, theme),
|
|
1866
|
+
});
|
|
1867
|
+
const { fleetRows, openFleetDashboard: openFleetDashboardRaw } = fleetDashboard;
|
|
1868
|
+
const openFleetDashboard = (ctx: any, startSubstitution = false) => gridUI.withSuspended(() => openFleetDashboardRaw(ctx, startSubstitution));
|
|
1869
|
+
|
|
1870
|
+
const contextBudgetUi = createContextBudgetUi<AgentDef, AgentState, ResearchState>({
|
|
1871
|
+
getAgents: () => agentStates,
|
|
1872
|
+
getResearch: () => researchStates,
|
|
1873
|
+
getAllDefs: () => allAgentDefs,
|
|
1874
|
+
getResearchPersonas: () => researchPersonas,
|
|
1875
|
+
getPeers: () => peerCards.values(),
|
|
1876
|
+
modelPolicy,
|
|
1877
|
+
displayName,
|
|
1878
|
+
getProjectDocsPaths: () => projectDocsPaths,
|
|
1879
|
+
getUserLanguage: () => userLanguage,
|
|
1880
|
+
getDelegateExtensionPath: () => delegateExtPath,
|
|
1881
|
+
safeAgentKey,
|
|
1882
|
+
projectPolicyPaths: specialistProjectPolicyPaths,
|
|
1883
|
+
modelWindowLookup,
|
|
1884
|
+
getResearchTools: () => RESEARCH_TOOLS,
|
|
1885
|
+
getPromptLedger: () => lastHubLedger,
|
|
1886
|
+
getPressureState: () => contextPressureState,
|
|
1887
|
+
buildHubSystemPrompt: () => { buildHubSystemPrompt(); },
|
|
1888
|
+
getAllTools: () => typeof pi.getAllTools === "function" ? pi.getAllTools() : [],
|
|
1889
|
+
getActiveTools: () => typeof pi.getActiveTools === "function" ? pi.getActiveTools() : [],
|
|
1890
|
+
getCommands: () => typeof pi.getCommands === "function" ? pi.getCommands() : [],
|
|
1891
|
+
});
|
|
1892
|
+
const { openContextBudget } = contextBudgetUi;
|
|
1893
|
+
|
|
1894
|
+
// A delegate child anywhere in the team, by its id (e.g. "quality-1").
|
|
1895
|
+
function findDelegationChild(arg: string): { child: DelegationChild; owner: AgentState } | null {
|
|
1896
|
+
const lower = arg.toLowerCase();
|
|
1897
|
+
for (const state of agentStates.values()) {
|
|
1898
|
+
const child = Array.from(state.delegations?.values() ?? []).find(candidate => candidate.id.toLowerCase() === lower);
|
|
1899
|
+
if (child) return { child, owner: state };
|
|
1900
|
+
}
|
|
1901
|
+
return null;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
const completions = createCompletionPresentation({
|
|
1905
|
+
getAgents: () => agentStates.values(), getResearch: () => researchStates.values(),
|
|
1906
|
+
getResearchPersonas: () => researchPersonas, getModelProfiles: () => modelProfiles,
|
|
1907
|
+
getPeers: peersInScope, displayName, shortModel, resolvedModel, resolvedThinking,
|
|
1908
|
+
resolveThinkingLevel, resolvedSubagentModel,
|
|
1909
|
+
getSubagentOverride: (persona, role) => modelPolicy.getSubagentOverride(persona, role),
|
|
1910
|
+
getSubstitutionSources: () => modelPolicy.allKnownModels().map(spec => {
|
|
1911
|
+
const target = modelPolicy.getSubstitution(spec);
|
|
1912
|
+
return { spec, label: target ? `${spec} → ${target} (active this session)` : spec };
|
|
1913
|
+
}),
|
|
1914
|
+
});
|
|
1915
|
+
|
|
1916
|
+
registerInputShortcuts(pi, {
|
|
1917
|
+
setWidgetContext: ctx => { widgetCtx = ctx; }, openFleetDashboard,
|
|
1918
|
+
toggleFleetWidget: () => gridUI.toggle(),
|
|
1919
|
+
workModeStatusText, openWorkModePicker,
|
|
1920
|
+
});
|
|
1921
|
+
|
|
1922
|
+
// Root owns subscription order; lifecycle modules own handler bodies.
|
|
1923
|
+
registerTurnPresence(pi, {
|
|
1924
|
+
beforeAgentPresence: () => turnHandlers.beforeAgentPresence(),
|
|
1925
|
+
agentEndPresence: () => turnHandlers.agentEndPresence(),
|
|
1926
|
+
});
|
|
1927
|
+
|
|
1928
|
+
// /af-handoff <peer> — hand the session off to a coms peer. Per decision G1 we do NOT
|
|
1929
|
+
// extract the compaction summary; instead we ask the dispatcher LLM (next turn) to
|
|
1930
|
+
// compose a SELF-CONTAINED brief and coms_send it, then await + relay the reply.
|
|
1931
|
+
// /af-compound [focus] — end-of-session compound-learning pass. Mirrors /af-handoff's
|
|
1932
|
+
// shape: the dispatcher LLM (which saw the whole session) composes the
|
|
1933
|
+
// candidate-lessons brief itself, gates it on the user, then dispatches the
|
|
1934
|
+
// documenter to land the approved lessons per skills/compound-learning/SKILL.md.
|
|
1935
|
+
// The rules/docs targets come from the overrides file; artifacts travel as
|
|
1936
|
+
// paths through the dispatch's `artifacts` array, never as pasted bodies.
|
|
1937
|
+
// ── ask_user wait tracking (for /af-agents-history real-work) ──
|
|
1938
|
+
// pi-ask-user blocks the dispatcher turn while the human answers. Bracket each
|
|
1939
|
+
// ask_user call with its tool_execution start/end so /af-agents-history can subtract
|
|
1940
|
+
// that "away from keyboard" time from the dispatcher's real work.
|
|
1941
|
+
// T11 production pre-effect gate: operator direct side effects use the same task-scoped process state as child dispatch.
|
|
1942
|
+
pi.on("tool_call", async (event: any) => {
|
|
1943
|
+
if (!["bash", "edit", "write"].includes(String(event.toolName || "").toLowerCase())) return;
|
|
1944
|
+
const gate = processPreEffectGate(processState, "write");
|
|
1945
|
+
if (gate) return { block: true, reason: gate.message };
|
|
1946
|
+
});
|
|
1947
|
+
pi.on("tool_execution_start", async event => turnHandlers.toolStart(event));
|
|
1948
|
+
observeAskUserResults(({ params, result, phase }) => {
|
|
1949
|
+
const pack = capabilityConfirmationPack(params.context);
|
|
1950
|
+
if (!pack) return;
|
|
1951
|
+
if (phase === "start") workModePolicy.setCapabilityConfirmation(pack, "pending");
|
|
1952
|
+
else {
|
|
1953
|
+
const outcome = confirmationOutcome(result);
|
|
1954
|
+
if (!outcome) return;
|
|
1955
|
+
workModePolicy.setCapabilityConfirmation(pack, outcome);
|
|
1956
|
+
resolveIncomingCapabilities("");
|
|
1957
|
+
applyWorkModeTools();
|
|
1958
|
+
}
|
|
1959
|
+
});
|
|
1960
|
+
|
|
1961
|
+
pi.on("tool_execution_end", async event => turnHandlers.toolEnd(event));
|
|
1962
|
+
|
|
1963
|
+
// ── System Prompt Override ───────────────────
|
|
1964
|
+
|
|
1965
|
+
|
|
1966
|
+
const hubPromptCtx: HubPromptContext = {
|
|
1967
|
+
getTriageBeforeDispatch: () => triageRuntime?.orchestratorBeforeDispatch === true,
|
|
1968
|
+
getArtifactRoot: () => sessionDir ? artifactsRoot() : null,
|
|
1969
|
+
getCapabilityResolution,
|
|
1970
|
+
getActiveTools: () => pi.getActiveTools(),
|
|
1971
|
+
getToolCatalogNotice: () => [latestToolCatalogDelta ? toolCatalogNotice(latestToolCatalogDelta) : "", latestUnknownToolNotice].filter(Boolean).join("\n"),
|
|
1972
|
+
getAgents: () => Array.from(agentStates.values()).map(state => ({
|
|
1973
|
+
name: state.def.name,
|
|
1974
|
+
displayName: displayName(state.def.name),
|
|
1975
|
+
description: state.def.description,
|
|
1976
|
+
tools: state.def.tools,
|
|
1977
|
+
})),
|
|
1978
|
+
getResearchPersonas: () => researchPersonas.map(def => ({
|
|
1979
|
+
name: def.name,
|
|
1980
|
+
displayName: displayName(def.name),
|
|
1981
|
+
description: def.description,
|
|
1982
|
+
model: resolvedModel(def),
|
|
1983
|
+
thinking: resolveThinkingLevel(resolvedThinking(def)),
|
|
1984
|
+
})),
|
|
1985
|
+
getPromptState: () => ({
|
|
1986
|
+
taskTier: taskTier ?? DEFAULT_TASK_TIER,
|
|
1987
|
+
taskTierAssumed,
|
|
1988
|
+
processRisk: processState.risk,
|
|
1989
|
+
processScope: processState.scope,
|
|
1990
|
+
processOpen: Object.entries(evaluateProcessObligations(processState, { writable: true, budgetTier: taskTier ?? DEFAULT_TASK_TIER }).obligations).filter(([, value]) => value.status === "open").map(([name]) => name),
|
|
1991
|
+
turnDispatchCount,
|
|
1992
|
+
turnResearchCount,
|
|
1993
|
+
taskDispatchCount,
|
|
1994
|
+
taskResearchCount,
|
|
1995
|
+
taskReviewRounds,
|
|
1996
|
+
turnBudget: currentBudget(),
|
|
1997
|
+
taskBudget: currentTaskBudget(),
|
|
1998
|
+
provisionalConfirmations: getCapabilityResolution().provisional
|
|
1999
|
+
.filter(pack => workModePolicy.getCapabilityConfirmation()[pack as ConfirmableCapabilityPack] !== "declined")
|
|
2000
|
+
.map(pack => ({
|
|
2001
|
+
pack,
|
|
2002
|
+
reason: getCapabilityResolution().reasons[pack],
|
|
2003
|
+
question: capabilityConfirmationQuestion(pack as ConfirmableCapabilityPack),
|
|
2004
|
+
})),
|
|
2005
|
+
}),
|
|
2006
|
+
getWorkMode,
|
|
2007
|
+
getActiveTeamName: () => activeTeamName,
|
|
2008
|
+
getUserLanguage: () => userLanguage,
|
|
2009
|
+
getRulesProtocol: buildRulesProtocol,
|
|
2010
|
+
getDocsProtocol: buildDocsProtocol,
|
|
2011
|
+
isAskUserAvailable: () => askUserAvailable,
|
|
2012
|
+
isComsReady: () => comsReady,
|
|
2013
|
+
getIdentity: () => identity,
|
|
2014
|
+
isHerdrFleetReady: () => herdrFleetReady,
|
|
2015
|
+
};
|
|
2016
|
+
|
|
2017
|
+
// This is also called by /af-context before the first turn. Keep prompt assembly
|
|
2018
|
+
// in this one production path so its ledger describes the exact next replacement.
|
|
2019
|
+
function buildHubSystemPrompt(): { systemPrompt: string } {
|
|
2020
|
+
const built = assembleHubPrompt(hubPromptCtx);
|
|
2021
|
+
lastHubLedger = built.ledger;
|
|
2022
|
+
return { systemPrompt: built.systemPrompt };
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
const turnHandlers = createTurnLifecycleHandlers({
|
|
2026
|
+
setTurnState: state => coms.setTurnState(state),
|
|
2027
|
+
finishMonitorTurn: () => { if (monitorBridge && monitorTurnId) { monitorBridge.finishParent(monitorTurnId, "completed"); monitorTurnId = null; } },
|
|
2028
|
+
startMonitorTurn: () => { if (monitorBridge && monitorHubId) { monitorTurnId = `hub-turn-${monitorHubId}-${crypto.randomUUID()}`; monitorBridge.startParent({ id: monitorTurnId, hubInstanceId: monitorHubId, checkoutId: currentCtx?.cwd || process.cwd() }); } },
|
|
2029
|
+
startAskUser: id => executionHistory.startAskUser(id), endAskUser: (id, at) => executionHistory.endAskUser(id, at),
|
|
2030
|
+
acknowledgeExternalBlocker: () => { externalBlockerAcknowledged = true; externalBlockerRefusedOnce = false; },
|
|
2031
|
+
addAskUserWait: waitMs => { if (waitMs > 0) taskClock = addTaskClockWait(taskClock, waitMs); turnBudgetAskUserWaitMs += waitMs; },
|
|
2032
|
+
applyWorkMode: applyWorkModeTools, closeTurnActiveTime, openTaskClock: at => { taskClock = openTaskClock(taskClock, at); }, startHistoryTurn: at => executionHistory.startTurn(at),
|
|
2033
|
+
resetTurnBudgetState: () => {
|
|
2034
|
+
turnBudgetAskUserWaitMs = 0; // budgetRecovery is task-scoped: prose/new turns cannot clear a declined confirmation.
|
|
2035
|
+
turnDispatchCount = 0; turnResearchCount = 0; turnDispatchFingerprints.clear(); externalBlockerAcknowledged = true; externalBlockerRefusedOnce = false;
|
|
2036
|
+
if (turnReport.dispatches.length > 0 || turnReport.research > 0 || turnReport.refusals > 0) { lastTurnReport = turnReport; sessionTotals.turns++; }
|
|
2037
|
+
turnReport = freshTurnReport();
|
|
2038
|
+
},
|
|
2039
|
+
updateModeStatus, buildPrompt: buildHubSystemPrompt, endHistoryTurn: at => executionHistory.endTurn(at),
|
|
2040
|
+
unaddressedPeerWarning: () => unaddressedPeerSweep(Array.from(hubSpawnedPeers.values()))?.message ?? null,
|
|
2041
|
+
respondToPeer: ctx => coms.respond(ctx),
|
|
2042
|
+
});
|
|
2043
|
+
pi.on("before_agent_start", async () => {
|
|
2044
|
+
const result = turnHandlers.beforeAgentStart();
|
|
2045
|
+
toolCatalogRuntime.beginTurn();
|
|
2046
|
+
return result;
|
|
2047
|
+
});
|
|
2048
|
+
|
|
2049
|
+
const pressureLifecycle = createContextPressureLifecycle({
|
|
2050
|
+
getState: () => pressureRootState,
|
|
2051
|
+
setPressure: value => { contextPressureState = value; pressureRootState.pressure = value; },
|
|
2052
|
+
getCurrentContext: () => currentCtx,
|
|
2053
|
+
appendEntry: (type, data) => pi.appendEntry(type, data),
|
|
2054
|
+
sendUserMessage: (content, options) => pi.sendUserMessage(content as any, options),
|
|
2055
|
+
resolveCapabilities: resolveIncomingCapabilities, applyWorkMode: applyWorkModeTools,
|
|
2056
|
+
modelWorkBlocked: modelWorkBlockedByRosterRecovery,
|
|
2057
|
+
});
|
|
2058
|
+
function replayDeferredRecoveryInputs(): void { pressureLifecycle.replayDeferred(); }
|
|
2059
|
+
pi.on("message_end", async (event, ctx) => {
|
|
2060
|
+
const diagnostics = observeUnknownToolCalls({ message: event.message, catalog: toolCatalogRuntime.catalogForMessage(), taskId: unknownToolCounter.snapshot().activeTaskId || noProgress.taskId(), counter: unknownToolCounter, seenCallIds: seenUnknownToolCalls });
|
|
2061
|
+
for (const diagnostic of diagnostics) {
|
|
2062
|
+
latestUnknownToolNotice = unknownToolNotice(diagnostic);
|
|
2063
|
+
try { pi.appendEntry(UNKNOWN_TOOL_COUNTER_ENTRY_TYPE, { snapshot: unknownToolCounter.snapshot(), diagnostic }); } catch {}
|
|
2064
|
+
}
|
|
2065
|
+
pressureLifecycle.messageEnd(event, ctx);
|
|
2066
|
+
});
|
|
2067
|
+
pi.on("turn_start", event => hubCapture.start(event.turnIndex));
|
|
2068
|
+
pi.on("turn_end", async (event, ctx) => {
|
|
2069
|
+
pressureLifecycle.turnEnd(ctx);
|
|
2070
|
+
const text = event.message.role === "assistant" ? event.message.content.filter(c => c.type === "text").map(c => c.text).join("") : "";
|
|
2071
|
+
hubCapture.end(event.turnIndex, text);
|
|
2072
|
+
});
|
|
2073
|
+
pi.on("context", async (event, ctx) => {
|
|
2074
|
+
pressureLifecycle.context(ctx);
|
|
2075
|
+
const context = hubCapture.hubContext();
|
|
2076
|
+
const text = context && proactiveRuntime?.feedback?.take("hub", "direct", context);
|
|
2077
|
+
if (text) { proactiveHubDeliveries++; return { messages: [...event.messages, { role: "custom" as const, customType: "agent-fleet.proactive-advisory", content: text, display: false, timestamp: Date.now() }] }; }
|
|
2078
|
+
});
|
|
2079
|
+
pi.on("agent_settled", async (_event, ctx) => pressureLifecycle.agentSettled(ctx));
|
|
2080
|
+
pi.on("session_compact", async (_event, ctx) => {
|
|
2081
|
+
noProgress.compact(ctx.sessionManager.getEntries());
|
|
2082
|
+
persistProcessVerdict(processState, evaluateProcessObligations(processState, { writable: true, budgetTier: taskTier ?? DEFAULT_TASK_TIER }));
|
|
2083
|
+
const result = toolCatalogRuntime.compact({
|
|
2084
|
+
mode: getWorkMode(), getEffectiveTools: () => pi.getActiveTools(),
|
|
2085
|
+
persist: (type, data) => pi.appendEntry(type, data), counterSnapshot: () => unknownToolCounter.snapshot(),
|
|
2086
|
+
retainCounter: () => unknownToolCounter.noteCompaction(),
|
|
2087
|
+
establishToolStateChange: (previous, next, evidenceRef) => noProgress.establishToolStateChange(previous, next, evidenceRef),
|
|
2088
|
+
settle: () => pressureLifecycle.sessionCompact(),
|
|
2089
|
+
onError: error => { try { pi.appendEntry("agent-hub-tool-catalog-error", { reason: "compaction_restore", error: error instanceof Error ? error.message : String(error) }); } catch {} },
|
|
2090
|
+
});
|
|
2091
|
+
if (result) latestToolCatalogDelta = result.delta;
|
|
2092
|
+
});
|
|
2093
|
+
pi.on("input", async (event, ctx) => {
|
|
2094
|
+
// Only user-owned input is task prose. Extension-generated input is not a task revision.
|
|
2095
|
+
if (event.source !== "extension" && typeof event.text === "string" && event.text.trim()) hubTaskText = event.text;
|
|
2096
|
+
return pressureLifecycle.input(event, ctx);
|
|
2097
|
+
});
|
|
2098
|
+
|
|
2099
|
+
// ── Session Start ────────────────────────────
|
|
2100
|
+
|
|
2101
|
+
let sessionOverrides: ReturnType<typeof parseAgentTeamOverrides> | undefined;
|
|
2102
|
+
let sessionSoloMode = false;
|
|
2103
|
+
const monitorSession = createMonitorSession({
|
|
2104
|
+
pi,
|
|
2105
|
+
getBridge: () => monitorBridge, setBridge: value => { monitorBridge = value; },
|
|
2106
|
+
getLifecycle: () => monitorLifecycle, setLifecycle: value => { monitorLifecycle = value; },
|
|
2107
|
+
setHubId: value => { monitorHubId = value; },
|
|
2108
|
+
getOwnerId: () => monitorOwnerId, setOwnerId: value => { monitorOwnerId = value; },
|
|
2109
|
+
queueDepth: () => inboundQueue.size,
|
|
2110
|
+
});
|
|
2111
|
+
registerSessionOrchestration(pi, {
|
|
2112
|
+
resetSession: (_ctx) => resetHubSession(_ctx, {
|
|
2113
|
+
registerVersion: registerVersionStatus, resetPressure: pressureLifecycle.reset,
|
|
2114
|
+
clearRosterRecovery: workModePolicy.clearRosterRecovery, captureBaselineTools: () => { baselineTools = pi.getActiveTools(); },
|
|
2115
|
+
resetAccessApproval: accessApprovalRouter.reset,
|
|
2116
|
+
terminateResearch: () => { for (const st of researchStates.values()) if (st.proc && st.status === "running") { st.killedByOperator = true; st.proc.kill("SIGTERM"); } },
|
|
2117
|
+
resetResearch: researchRuntime.reset, resetHistory: executionHistory.reset,
|
|
2118
|
+
resetBudgets: () => { hubCapture.reset(); hubTaskText = undefined; proactiveRuntime = null; proactiveConfig = null; proactiveHubDeliveries = 0; taskClock = createTaskClock(); turnBudgetAskUserWaitMs = 0; turnContinuationCount = 0; taskContinuationCount = 0; budgetRecovery.reset(); noProgress.prepareSessionRestore(); resetUnknownToolCounterForCurrentTask(); toolCatalogRuntime.restore(catalogSnapshot(getWorkMode(), [])); latestToolCatalogDelta = null; },
|
|
2119
|
+
clearWidgets: _ctx => { fleetUiGeneration++; fleetActions?.reset(); gridUI.dispose(); },
|
|
2120
|
+
closeDelegationWatchers: () => { for (const st of agentStates.values()) { st.delegationsWatcher?.close(); st.delegationsWatcher = undefined; } },
|
|
2121
|
+
resetSessionState: ctx => { delegatedTokens = 0; hubSpawnedPeers.clear(); widgetCtx = ctx; contextWindow = ctx.model?.contextWindow || 0; gridUI.reset(); },
|
|
2122
|
+
resolveSafety: cwd => Boolean(safetyHarnessPath = resolveSafetyHarness(cwd)), resolveDelegate: cwd => { delegateExtPath = resolveDelegateExtension(cwd); },
|
|
2123
|
+
}),
|
|
2124
|
+
restartMonitor: _ctx => monitorSession.restart(_ctx),
|
|
2125
|
+
initializeComs: async (_ctx) => {
|
|
2126
|
+
// ── Embedded coms init ──
|
|
2127
|
+
// Always refresh the ctx the coms handlers use. Bind the endpoint + register
|
|
2128
|
+
// in the pool exactly once per process (guard on comsReady), so a /new session
|
|
2129
|
+
// keeps the same peer identity rather than leaking a second socket. On any
|
|
2130
|
+
// failure we degrade: comsReady stays false and the coms_* tools are withheld.
|
|
2131
|
+
hubStateCtx.setCurrentContext(_ctx);
|
|
2132
|
+
sessionSoloMode = pi.getFlag("solo") === true;
|
|
2133
|
+
if (!comsReady && !sessionSoloMode) {
|
|
2134
|
+
try {
|
|
2135
|
+
identity = await coms.connect({ ctx: _ctx, defaultNamePrefix: "hub", defaultPurpose: "agent-hub dispatcher" });
|
|
2136
|
+
comsReady = true;
|
|
2137
|
+
try {
|
|
2138
|
+
_ctx.ui.setStatus("coms", `📡 ${identity.name}@${identity.project}`);
|
|
2139
|
+
} catch { /* hasUI may be false — non-fatal */ }
|
|
2140
|
+
} catch (err) {
|
|
2141
|
+
comsReady = false;
|
|
2142
|
+
try { _ctx.ui?.notify?.(`📡 coms: init failed — ${err instanceof Error ? err.message : String(err)} (coms tools disabled)`, "error"); } catch { /* ignore */ }
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
},
|
|
2146
|
+
initializeExemptions: (_ctx) => {
|
|
2147
|
+
try {
|
|
2148
|
+
const config = loadProactiveConfig(_ctx.cwd || process.cwd());
|
|
2149
|
+
if (isCaptureEnabled(config)) proactiveConfig = config;
|
|
2150
|
+
} catch { /* invalid config fails closed */ }
|
|
2151
|
+
// ── Damage-control shared exemptions file ──
|
|
2152
|
+
// One per hub session (solo mode included). Exporting the path on our own
|
|
2153
|
+
// process.env lets the co-loaded damage-control-continue mirror /af-allow
|
|
2154
|
+
// session grants into the same file the spawned children read.
|
|
2155
|
+
if (!exemptionsFile) {
|
|
2156
|
+
hubStateCtx.setExemptionsFile(exemptionsFilePath(identity?.session_id ?? `hub-solo-${process.pid}`));
|
|
2157
|
+
process.env[EXEMPTIONS_FILE_ENV] = exemptionsFile!;
|
|
2158
|
+
}
|
|
2159
|
+
},
|
|
2160
|
+
loadAgents: (_ctx) => {
|
|
2161
|
+
// Allocate a fresh namespace; shared legacy files belong to prior/live sessions.
|
|
2162
|
+
sessionOverrides = parseAgentTeamOverrides(_ctx.cwd);
|
|
2163
|
+
runHistoryKeep = sessionOverrides.runHistoryKeep;
|
|
2164
|
+
|
|
2165
|
+
loadAgents(_ctx.cwd);
|
|
2166
|
+
// Composition follows applyOverrides: approved roots and the shared service do not exist yet.
|
|
2167
|
+
|
|
2168
|
+
// Surface non-fatal persona frontmatter warnings (skipped subagents roles,
|
|
2169
|
+
// bad delegate_depth) once per session.
|
|
2170
|
+
const fmWarnings = allAgentDefs.flatMap(d => (d.warnings || []).map(w => `${d.name}: ${w}`));
|
|
2171
|
+
if (fmWarnings.length > 0) {
|
|
2172
|
+
_ctx.ui.notify(`Persona frontmatter warnings:\n${fmWarnings.join("\n")}`, "warning");
|
|
2173
|
+
}
|
|
2174
|
+
if (!delegateExtPath && allAgentDefs.some(d => d.subagents)) {
|
|
2175
|
+
_ctx.ui.notify(
|
|
2176
|
+
"delegate.ts not found next to agent-hub — `subagents:` declarations are inert (specialists dispatch without a delegate tool).",
|
|
2177
|
+
"warning",
|
|
2178
|
+
);
|
|
2179
|
+
}
|
|
2180
|
+
},
|
|
2181
|
+
applyOverrides: (_ctx) => {
|
|
2182
|
+
if (!sessionOverrides) throw new Error("session_start applyOverrides ran before loadAgents");
|
|
2183
|
+
watchdogSystem1 = disposeWatchdogSystem1Session(watchdogSystem1);
|
|
2184
|
+
communicationStore.dispose();
|
|
2185
|
+
triageRuntime?.dispose(); triageRuntime = null;
|
|
2186
|
+
try { watchdogActivity?.dispose(); } catch { /* trace disposal must not block the session */ }
|
|
2187
|
+
// Stable for a real session across snapshot replacement; G2 must not split one session into artificial samples.
|
|
2188
|
+
watchdogActivity = sessionDir ? createWatchdogActivity({ directory: `${sessionDir}/artifacts/watchdog`, sessionId: path.basename(sessionDir) }) : null;
|
|
2189
|
+
watchdogSystem1 = createWatchdogSystem1Session({ ...readWatchdogSystem1Snapshot({
|
|
2190
|
+
cwd: _ctx.cwd,
|
|
2191
|
+
configuredMode: sessionOverrides.watchdogSystem1Mode,
|
|
2192
|
+
watchdogSetting: sessionOverrides.watchdogSetting,
|
|
2193
|
+
env: process.env,
|
|
2194
|
+
warnings: sessionOverrides.warnings,
|
|
2195
|
+
}), wrapService: service => communicationStore.wrap(service, { provider: "typesafe", model: "jev-1.13.0" }) });
|
|
2196
|
+
let triageConfig = null;
|
|
2197
|
+
try { triageConfig = parseTriageConfig(JSON.parse(fs.readFileSync(path.join(_ctx.cwd, ".ai/dispatch-triage.json"), "utf8"))); } catch { /* absent/invalid is off */ }
|
|
2198
|
+
triageRuntime = createTriageRuntime({ config: triageConfig, service: watchdogSystem1?.sharedService,
|
|
2199
|
+
current: input => triageInput(input.task,input.scope,input.language,input.domain),
|
|
2200
|
+
trace: event => pi.appendEntry("agent-hub-triage", event),
|
|
2201
|
+
});
|
|
2202
|
+
applySessionOverrides(_ctx, sessionOverrides, {
|
|
2203
|
+
setLanguage: value => { userLanguage = value; },
|
|
2204
|
+
setReconTimeout: value => { reconSearchTimeoutMs = value; }, setBudgetOverrides: value => { budgetOverrides = value; },
|
|
2205
|
+
setWatchdog: (setting, judge) => { watchdogSetting = setting; watchdogJudgeModel = judge; },
|
|
2206
|
+
resetTurnCounts: () => { turnDispatchCount = 0; turnResearchCount = 0; }, resetTaskWindow: () => resetTaskWindow(null), updateModeStatus,
|
|
2207
|
+
setProjectRules: value => { projectRulesDirs = value; }, setProjectDocs: value => { projectDocsPaths = value; },
|
|
2208
|
+
resetModelPolicy: () => {modelPolicy.reset();profileActivation.reset();applyWorkModeTools();}, getModelProfileErrors: () => modelProfileErrors, getAgentDefs: () => allAgentDefs, getModelProfiles: () => modelProfiles,
|
|
2209
|
+
deleteModelProfile: name => { delete modelProfiles[name]; }, allowedModels,
|
|
2210
|
+
getDispatchPolicyWarnings: () => dispatchPolicyWarnings, setResearchPersonas: value => { researchPersonas = value; },
|
|
2211
|
+
});
|
|
2212
|
+
if (proactiveConfig && sessionDir) {
|
|
2213
|
+
try { proactiveRuntime = composeHubProactive({ config: proactiveConfig, root: _ctx.cwd, sessionDir,
|
|
2214
|
+
rulesRoots: projectRulesDirs, service: watchdogSystem1?.sharedService, capture: hubCapture, onChange: updateWidget }); }
|
|
2215
|
+
catch { proactiveRuntime = null; proactiveConfig = null; } // unavailable composition never reports reviewed
|
|
2216
|
+
}
|
|
2217
|
+
},
|
|
2218
|
+
restoreRoster: (_ctx) => {
|
|
2219
|
+
// Explicit CLI selection wins; otherwise restore only the canonical team name
|
|
2220
|
+
// and re-resolve it against current teams.yaml/persona files. An explicit
|
|
2221
|
+
// Operator work mode suppresses an ambient persisted roster unless --agent-team
|
|
2222
|
+
// was also supplied.
|
|
2223
|
+
agentStates.clear();
|
|
2224
|
+
activeTeamName = "";
|
|
2225
|
+
comsMissNotified.clear();
|
|
2226
|
+
recomputeGrid();
|
|
2227
|
+
const sessionEntries = _ctx.sessionManager.getEntries();
|
|
2228
|
+
processState = latestProcessState(sessionEntries);
|
|
2229
|
+
noProgress.restore(sessionEntries);
|
|
2230
|
+
const persistedCatalog = latestPersistedToolCatalog(sessionEntries);
|
|
2231
|
+
if (persistedCatalog) toolCatalogRuntime.restore(persistedCatalog);
|
|
2232
|
+
const persistedUnknownTools = latestPersistedUnknownToolCounter(sessionEntries);
|
|
2233
|
+
if (persistedUnknownTools) unknownToolCounter = restoreUnknownToolCounter(persistedUnknownTools, { limit: 3 });
|
|
2234
|
+
const explicitWorkMode = pi.getFlag("work-mode");
|
|
2235
|
+
const explicitRoster = pi.getFlag("agent-team");
|
|
2236
|
+
const hasExplicitRoster = typeof explicitRoster === "string" && explicitRoster.trim() !== "";
|
|
2237
|
+
const startupRoster = resolveSessionRoster({
|
|
2238
|
+
teams,
|
|
2239
|
+
entries: sessionEntries,
|
|
2240
|
+
explicitRoster,
|
|
2241
|
+
availablePersonas: allAgentDefs.map(def => def.name),
|
|
2242
|
+
includePersisted: !(explicitWorkMode === "operator" && !hasExplicitRoster),
|
|
2243
|
+
});
|
|
2244
|
+
workModePolicy.setRestoredWorkMode(resolveSessionWorkMode({
|
|
2245
|
+
entries: sessionEntries,
|
|
2246
|
+
explicitWorkMode,
|
|
2247
|
+
hasExplicitRoster: startupRoster.source === "explicit",
|
|
2248
|
+
}));
|
|
2249
|
+
if (startupRoster.roster) {
|
|
2250
|
+
activateTeam(startupRoster.roster.name);
|
|
2251
|
+
persistActiveRoster();
|
|
2252
|
+
}
|
|
2253
|
+
const rosterRecoveryRequired = orchestratorNeedsRoster(getWorkMode(), agentStates.size);
|
|
2254
|
+
const rosterRecoveryDiagnostic = rosterRecoveryRequired
|
|
2255
|
+
? startupRoster.diagnostic || "Persisted orchestrator work mode has no native roster."
|
|
2256
|
+
: "";
|
|
2257
|
+
workModePolicy.setRosterRecovery(rosterRecoveryRequired, rosterRecoveryDiagnostic);
|
|
2258
|
+
if (startupRoster.diagnostic) {
|
|
2259
|
+
_ctx.ui.notify(
|
|
2260
|
+
`${startupRoster.diagnostic} ${rosterRecoveryRequired ? "Model input is blocked until you select /af-agents-team, restart with --agent-team <name>, or switch explicitly with --work-mode operator." : "Continuing without that roster."}`,
|
|
2261
|
+
rosterRecoveryRequired ? "error" : "warning",
|
|
2262
|
+
);
|
|
2263
|
+
} else if (rosterRecoveryRequired) {
|
|
2264
|
+
_ctx.ui.notify(
|
|
2265
|
+
`${rosterRecoveryDiagnostic} Model input is blocked until you select /af-agents-team, restart with --agent-team <name>, or switch explicitly with --work-mode operator.`,
|
|
2266
|
+
"error",
|
|
2267
|
+
);
|
|
2268
|
+
}
|
|
2269
|
+
},
|
|
2270
|
+
resolveCapabilities: async (_ctx) => {
|
|
2271
|
+
// Probe for `ask_user` (registered by the `pi-ask-user` companion package
|
|
2272
|
+
// when installed). Action methods like getAllTools are runtime-only, so
|
|
2273
|
+
// this MUST happen at session_start, not at extension load.
|
|
2274
|
+
askUserAvailable = pi.getAllTools().some(t => t.name === "ask_user");
|
|
2275
|
+
|
|
2276
|
+
// Fleet tools are available only inside a herdr pane with a live server.
|
|
2277
|
+
// The work mode policy adds gated groups without activating unavailable tools.
|
|
2278
|
+
herdrFleetReady = herdrPaneId() !== null && (await herdrAvailable()) !== null;
|
|
2279
|
+
const persistedCapabilities = latestPersistedCapabilityState(_ctx.sessionManager.getEntries());
|
|
2280
|
+
workModePolicy.restoreCapabilities({ taskPacks: persistedCapabilities?.taskPacks ?? [], provisional: persistedCapabilities?.provisional ?? [], confirmation: persistedCapabilities?.confirmation ?? {} });
|
|
2281
|
+
resolveIncomingCapabilities("");
|
|
2282
|
+
applyWorkModeTools();
|
|
2283
|
+
if (pressureLifecycle.observe(_ctx, "session_start") === "compact-now") {
|
|
2284
|
+
setTimeout(() => pressureLifecycle.runCompaction(_ctx, "session_start"), 0);
|
|
2285
|
+
}
|
|
2286
|
+
workModePolicy.updateStatus(_ctx);
|
|
2287
|
+
},
|
|
2288
|
+
notifyStartup: (_ctx) => {
|
|
2289
|
+
_ctx.ui.setStatus("agent-team", `Native roster: ${activeTeamName || "(none)"} (${agentStates.size})`);
|
|
2290
|
+
const members = Array.from(agentStates.values()).map(s => displayName(s.def.name)).join(", ");
|
|
2291
|
+
const askUserLabel = askUserAvailable
|
|
2292
|
+
? "available (via pi-ask-user)"
|
|
2293
|
+
: "NOT AVAILABLE — run `pi install npm:pi-ask-user`";
|
|
2294
|
+
const comsLabel = comsReady && identity
|
|
2295
|
+
? `📡 ${identity.name}@${identity.project} — peers via coms_list; /af-handoff <peer> to delegate`
|
|
2296
|
+
: sessionSoloMode
|
|
2297
|
+
? "off (--solo: fixed specialists + research only)"
|
|
2298
|
+
: "off (endpoint bind failed — coms tools disabled)";
|
|
2299
|
+
const fleetLabel = herdrFleetReady
|
|
2300
|
+
? "herdr — spawn/read/close panes + notify (herdr_* tools active)"
|
|
2301
|
+
: "off (not inside a herdr pane, or no herdr server)";
|
|
2302
|
+
const comsPreferred = Object.entries(dispatchPolicy.substitutions)
|
|
2303
|
+
.filter(([, s]) => s.prefer === "coms")
|
|
2304
|
+
.map(([n]) => n);
|
|
2305
|
+
const dispatchLabel = dispatchPolicy.default === "coms"
|
|
2306
|
+
? "coms default — any member with a live same-name pool peer is served by it (/af-dispatch-policy)"
|
|
2307
|
+
: comsPreferred.length > 0
|
|
2308
|
+
? `coms-preferred: ${comsPreferred.join(", ")} (live peer wins, /af-dispatch-policy for status)`
|
|
2309
|
+
: "all native (no substitutions in .pi/agents/dispatch-policy.yaml)";
|
|
2310
|
+
_ctx.ui.notify(buildSessionStartNotice({
|
|
2311
|
+
workMode: getWorkMode(),
|
|
2312
|
+
activeTeamName,
|
|
2313
|
+
agentCount: agentStates.size,
|
|
2314
|
+
members,
|
|
2315
|
+
dispatchLabel,
|
|
2316
|
+
userLanguage,
|
|
2317
|
+
askUserLabel,
|
|
2318
|
+
comsLabel,
|
|
2319
|
+
fleetLabel,
|
|
2320
|
+
}), "info");
|
|
2321
|
+
},
|
|
2322
|
+
updateWidget: (_ctx) => {
|
|
2323
|
+
updateWidget();
|
|
2324
|
+
},
|
|
2325
|
+
installFooter: (_ctx) => {
|
|
2326
|
+
_ctx.ui.setFooter(createSessionFooter({
|
|
2327
|
+
ctx: _ctx,
|
|
2328
|
+
version: HARNESS_VERSION ?? "unknown",
|
|
2329
|
+
getModel: () => _ctx.model?.id || "no-model",
|
|
2330
|
+
getThinkingLevel: () => pi.getThinkingLevel?.() ?? undefined,
|
|
2331
|
+
thinkingSuffix,
|
|
2332
|
+
getHint: () => composeFleetFooterHint(compactWorkMode(getWorkMode())),
|
|
2333
|
+
renderLeft: renderHubFooterLeft,
|
|
2334
|
+
truncateToWidth,
|
|
2335
|
+
visibleWidth,
|
|
2336
|
+
}));
|
|
2337
|
+
},
|
|
2338
|
+
}, {
|
|
2339
|
+
finishEvidence: () => { if (sessionDir) closeEvidenceSession(sessionDir); },
|
|
2340
|
+
shutdownComs: () => { unregisterQuestions(); return coms.shutdown(); }, shutdownMonitor: () => monitorSession.shutdown(),
|
|
2341
|
+
removeExemptions: () => {
|
|
2342
|
+
if (!exemptionsFile) return;
|
|
2343
|
+
try { fs.unlinkSync(exemptionsFile); } catch {}
|
|
2344
|
+
hubStateCtx.setExemptionsFile(null);
|
|
2345
|
+
},
|
|
2346
|
+
terminateChildren: () => {
|
|
2347
|
+
hubCapture.reset(); proactiveRuntime = null;
|
|
2348
|
+
watchdogSystem1 = disposeWatchdogSystem1Session(watchdogSystem1);
|
|
2349
|
+
communicationStore.dispose();
|
|
2350
|
+
triageRuntime?.dispose(); triageRuntime = null;
|
|
2351
|
+
try { watchdogActivity?.dispose(); } catch { /* trace disposal must not block shutdown */ }
|
|
2352
|
+
watchdogActivity = null;
|
|
2353
|
+
for (const st of [...agentStates.values(), ...researchStates.values()]) {
|
|
2354
|
+
fenceOperatorCancel(st);
|
|
2355
|
+
if (st.proc && st.status === "running") try { st.killedByOperator = true; st.proc.kill("SIGTERM"); } catch {}
|
|
2356
|
+
}
|
|
2357
|
+
},
|
|
2358
|
+
clearPoolWidget: () => {
|
|
2359
|
+
gridUI.dispose();
|
|
2360
|
+
if (currentCtx?.hasUI) try { currentCtx.ui.setWidget("coms-pool", undefined); } catch {}
|
|
2361
|
+
},
|
|
2362
|
+
});
|
|
2363
|
+
|
|
2364
|
+
// Ordered end-turn peer response remains after session-start registration.
|
|
2365
|
+
pi.on("agent_end", async (_event, ctx) => {
|
|
2366
|
+
toolCatalogRuntime.endTurn();
|
|
2367
|
+
await turnHandlers.agentEnd(ctx);
|
|
2368
|
+
});
|
|
2369
|
+
|
|
2370
|
+
}
|