@chankov/agent-fleet 1.0.1 → 1.0.2
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/extensions/package-lock.json +77 -45
- package/.pi/harnesses/agent-hub/README.md +109 -18
- package/.pi/harnesses/agent-hub/budget-continuation.ts +73 -0
- package/.pi/harnesses/agent-hub/capability-confirmation.ts +47 -0
- package/.pi/harnesses/agent-hub/capability-packs.ts +180 -0
- package/.pi/harnesses/agent-hub/context-budget-snapshot.ts +105 -0
- package/.pi/harnesses/agent-hub/context-pressure.ts +191 -0
- package/.pi/harnesses/agent-hub/hub-state-audit.js +18 -0
- package/.pi/harnesses/agent-hub/index.ts +988 -422
- package/.pi/harnesses/agent-hub/package.json +1 -1
- package/.pi/harnesses/agent-hub/posture.ts +72 -17
- package/.pi/harnesses/agent-hub/run-budget.js +12 -13
- package/.pi/harnesses/agent-hub/spawn.ts +14 -2
- package/.pi/harnesses/ask-user-remote/index.ts +59 -4
- package/.pi/harnesses/coms/package.json +1 -1
- package/.pi/harnesses/damage-control-continue/package.json +1 -1
- package/.pi/harnesses/lib/context-budget-child-prompt.ts +179 -0
- package/.pi/harnesses/lib/context-budget-hub-prompt.ts +116 -0
- package/.pi/harnesses/lib/context-budget-view.ts +107 -0
- package/.pi/harnesses/lib/context-budget.ts +114 -0
- package/.pi/harnesses/lib/fleet-detail-view.ts +92 -2
- package/.pi/harnesses/package-lock.json +73 -80
- package/.versions/1.0.2/.pi/agents/dispatch-policy.yaml +32 -0
- package/.versions/1.0.2/.pi/agents/model-profiles.yaml +27 -0
- package/.versions/1.0.2/.pi/agents/peers.yaml +142 -0
- package/.versions/1.0.2/.pi/agents/teams.yaml +41 -0
- package/.versions/1.0.2/.pi/damage-control-rules.yaml +297 -0
- package/.versions/1.0.2/.pi/extensions/agent-fleet-update-check/README.md +57 -0
- package/.versions/1.0.2/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
- package/.versions/1.0.2/.pi/extensions/agent-fleet-update-check/package.json +6 -0
- package/.versions/1.0.2/.pi/extensions/btw/README.md +120 -0
- package/.versions/1.0.2/.pi/extensions/btw/index.ts +914 -0
- package/.versions/1.0.2/.pi/extensions/btw/package.json +6 -0
- package/.versions/1.0.2/.pi/extensions/btw/state.js +179 -0
- package/.versions/1.0.2/.pi/extensions/chrome-devtools-mcp/README.md +55 -0
- package/.versions/1.0.2/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
- package/.versions/1.0.2/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.versions/1.0.2/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.versions/1.0.2/.pi/extensions/compact-and-continue/index.ts +120 -0
- package/.versions/1.0.2/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.versions/1.0.2/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.versions/1.0.2/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.versions/1.0.2/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.versions/1.0.2/.pi/extensions/package-lock.json +1175 -0
- package/.versions/1.0.2/.pi/extensions/package.json +9 -0
- package/.versions/1.0.2/.pi/extensions/pi-voice-stt/README.md +205 -0
- package/.versions/1.0.2/.pi/extensions/pi-voice-stt/config.ts +198 -0
- package/.versions/1.0.2/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
- package/.versions/1.0.2/.pi/extensions/pi-voice-stt/index.ts +248 -0
- package/.versions/1.0.2/.pi/extensions/pi-voice-stt/package.json +6 -0
- package/.versions/1.0.2/.pi/extensions/pi-voice-stt/providers.ts +214 -0
- package/.versions/1.0.2/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/README.md +1156 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/access-approval.ts +135 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/artifacts.js +146 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/backend-policy.js +174 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/budget-continuation.ts +73 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/capability-confirmation.ts +47 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/capability-packs.ts +180 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/context-budget-snapshot.ts +105 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/context-pressure.ts +191 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/context-window.js +106 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/delegate.ts +435 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/docs-lane.js +122 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/drift-watchdog.js +211 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/external-blocker.js +85 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/footer.ts +35 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/helpers.ts +266 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/hub-state-audit.js +73 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/index.ts +9909 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/monitor-session-bridge.ts +266 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/package.json +7 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/peer-spawn-plan.ts +116 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/posture.ts +158 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/research-retention.js +34 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/return-contract.js +293 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/return-extract.js +75 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/review-findings.js +102 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/run-budget.js +539 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/run-namespace.js +87 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/scope-gate.js +103 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/session-health.js +110 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/spawn.ts +366 -0
- package/.versions/1.0.2/.pi/harnesses/agent-hub/version.ts +42 -0
- package/.versions/1.0.2/.pi/harnesses/ask-user-remote/README.md +53 -0
- package/.versions/1.0.2/.pi/harnesses/ask-user-remote/index.ts +532 -0
- package/.versions/1.0.2/.pi/harnesses/ask-user-remote/race-core.js +106 -0
- package/.versions/1.0.2/.pi/harnesses/coms/README.md +100 -0
- package/.versions/1.0.2/.pi/harnesses/coms/index.ts +1767 -0
- package/.versions/1.0.2/.pi/harnesses/coms/package.json +7 -0
- package/.versions/1.0.2/.pi/harnesses/coms/version.ts +42 -0
- package/.versions/1.0.2/.pi/harnesses/damage-control-continue/README.md +124 -0
- package/.versions/1.0.2/.pi/harnesses/damage-control-continue/index.ts +536 -0
- package/.versions/1.0.2/.pi/harnesses/damage-control-continue/package.json +7 -0
- package/.versions/1.0.2/.pi/harnesses/damage-control-continue/version.ts +42 -0
- package/.versions/1.0.2/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
- package/.versions/1.0.2/.pi/harnesses/lib/context-budget-child-prompt.ts +179 -0
- package/.versions/1.0.2/.pi/harnesses/lib/context-budget-hub-prompt.ts +116 -0
- package/.versions/1.0.2/.pi/harnesses/lib/context-budget-view.ts +107 -0
- package/.versions/1.0.2/.pi/harnesses/lib/context-budget.ts +114 -0
- package/.versions/1.0.2/.pi/harnesses/lib/damage-control-shared.ts +197 -0
- package/.versions/1.0.2/.pi/harnesses/lib/fixtures/context-budget-profiles.json +11 -0
- package/.versions/1.0.2/.pi/harnesses/lib/fixtures/hub-prompt-operator.legacy.txt +73 -0
- package/.versions/1.0.2/.pi/harnesses/lib/fixtures/hub-prompt-orchestrator.legacy.txt +73 -0
- package/.versions/1.0.2/.pi/harnesses/lib/fleet-dashboard-ops.ts +155 -0
- package/.versions/1.0.2/.pi/harnesses/lib/fleet-dashboard-view.ts +140 -0
- package/.versions/1.0.2/.pi/harnesses/lib/fleet-detail-view.ts +133 -0
- package/.versions/1.0.2/.pi/harnesses/lib/fleet-overlay.ts +26 -0
- package/.versions/1.0.2/.pi/harnesses/lib/fleet-panel.ts +34 -0
- package/.versions/1.0.2/.pi/harnesses/lib/fleet-read-model.ts +131 -0
- package/.versions/1.0.2/.pi/harnesses/lib/fleet-selection.ts +24 -0
- package/.versions/1.0.2/.pi/harnesses/lib/herdr-client.ts +472 -0
- package/.versions/1.0.2/.pi/harnesses/lib/herdr-presence.ts +399 -0
- package/.versions/1.0.2/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
- package/.versions/1.0.2/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
- package/.versions/1.0.2/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
- package/.versions/1.0.2/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
- package/.versions/1.0.2/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
- package/.versions/1.0.2/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
- package/.versions/1.0.2/.pi/harnesses/lib/spawned-peers.js +190 -0
- package/.versions/1.0.2/.pi/harnesses/package-lock.json +2039 -0
- package/.versions/1.0.2/.pi/harnesses/package.json +10 -0
- package/.versions/1.0.2/.pi/prompts/af-build.md +24 -0
- package/.versions/1.0.2/.pi/prompts/af-code-simplify.md +22 -0
- package/.versions/1.0.2/.pi/prompts/af-plan.md +16 -0
- package/.versions/1.0.2/.pi/prompts/af-review.md +16 -0
- package/.versions/1.0.2/.pi/prompts/af-set-hermes-telegram.md +15 -0
- package/.versions/1.0.2/.pi/prompts/af-set-hermes-watchdog.md +6 -0
- package/.versions/1.0.2/.pi/prompts/af-ship.md +17 -0
- package/.versions/1.0.2/.pi/prompts/af-spec.md +15 -0
- package/.versions/1.0.2/.pi/prompts/af-test.md +19 -0
- package/.versions/1.0.2/.pi/skills/bowser/SKILL.md +145 -0
- package/.versions/1.0.2/.version +1 -0
- package/.versions/1.0.2/agents/architect.md +24 -0
- package/.versions/1.0.2/agents/bowser.md +27 -0
- package/.versions/1.0.2/agents/builder.md +54 -0
- package/.versions/1.0.2/agents/code-reviewer.md +208 -0
- package/.versions/1.0.2/agents/deep-researcher.md +32 -0
- package/.versions/1.0.2/agents/documenter.md +18 -0
- package/.versions/1.0.2/agents/orchestrator.md +20 -0
- package/.versions/1.0.2/agents/plan-reviewer.md +83 -0
- package/.versions/1.0.2/agents/planner.md +70 -0
- package/.versions/1.0.2/agents/releaser.md +24 -0
- package/.versions/1.0.2/agents/researcher.md +28 -0
- package/.versions/1.0.2/agents/security-auditor.md +167 -0
- package/.versions/1.0.2/agents/test-engineer.md +153 -0
- package/.versions/1.0.2/agents/web-debugger.md +43 -0
- package/.versions/1.0.2/agents/web-performance-auditor.md +193 -0
- package/.versions/1.0.2/bin/catalog/harness-runtime-closure.json +38 -0
- package/.versions/1.0.2/codex/CONDUCTOR.md +148 -0
- package/.versions/1.0.2/docs/ARCHITECTURE.md +369 -0
- package/.versions/1.0.2/docs/agent-fleet-setup.md +468 -0
- package/.versions/1.0.2/docs/claude-code-coms-bridge.md +128 -0
- package/.versions/1.0.2/docs/codex-remote-conductor.md +170 -0
- package/.versions/1.0.2/docs/coms-hermes-bridge.md +189 -0
- package/.versions/1.0.2/docs/getting-started.md +98 -0
- package/.versions/1.0.2/docs/npm-install.md +292 -0
- package/.versions/1.0.2/docs/pi-extensions.md +439 -0
- package/.versions/1.0.2/docs/pi-setup.md +74 -0
- package/.versions/1.0.2/docs/skill-anatomy.md +150 -0
- package/.versions/1.0.2/hermes/README.md +347 -0
- package/.versions/1.0.2/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
- package/.versions/1.0.2/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
- package/.versions/1.0.2/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
- package/.versions/1.0.2/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
- package/.versions/1.0.2/hermes/gates/gate-o-capability.md +8 -0
- package/.versions/1.0.2/hermes/gates/gate-o-validator-fixtures.json +1 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
- package/.versions/1.0.2/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
- package/.versions/1.0.2/hermes/skills/hub-conductor/SKILL.md +84 -0
- package/.versions/1.0.2/hermes/skills/hub-liaison/SKILL.md +84 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/SKILL.md +76 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/manifest.json +1 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
- package/.versions/1.0.2/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
- package/.versions/1.0.2/hermes/watchdog-tests/__init__.py +0 -0
- package/.versions/1.0.2/hooks/coms-stop-hook.mjs +84 -0
- package/.versions/1.0.2/install-manifest.json +2745 -0
- package/.versions/1.0.2/justfile +272 -0
- package/.versions/1.0.2/manifest-meta.json +882 -0
- package/.versions/1.0.2/references/accessibility-checklist.md +160 -0
- package/.versions/1.0.2/references/definition-of-done.md +67 -0
- package/.versions/1.0.2/references/fleet-coordination-patterns.md +151 -0
- package/.versions/1.0.2/references/observability-checklist.md +91 -0
- package/.versions/1.0.2/references/orchestration-patterns.md +370 -0
- package/.versions/1.0.2/references/performance-checklist.md +153 -0
- package/.versions/1.0.2/references/prompting-patterns.md +380 -0
- package/.versions/1.0.2/references/security-checklist.md +179 -0
- package/.versions/1.0.2/references/testing-patterns.md +236 -0
- package/.versions/1.0.2/scripts/codex-conductor.ts +41 -0
- package/.versions/1.0.2/scripts/codex-remote-control.ts +167 -0
- package/.versions/1.0.2/scripts/coms-claude-bridge.ts +411 -0
- package/.versions/1.0.2/scripts/coms-cli.ts +484 -0
- package/.versions/1.0.2/scripts/coms-hermes-bridge.ts +413 -0
- package/.versions/1.0.2/scripts/fleet.ts +185 -0
- package/.versions/1.0.2/scripts/hermes-monitor-capability-runner.ts +25 -0
- package/.versions/1.0.2/scripts/hermes-monitor-scenario.ts +474 -0
- package/.versions/1.0.2/scripts/hermes-watchdog-capability-probe.ts +45 -0
- package/.versions/1.0.2/scripts/install-hermes-plugin.sh +180 -0
- package/.versions/1.0.2/scripts/lib/claude-bridge-core.ts +210 -0
- package/.versions/1.0.2/scripts/lib/codex-conductor.ts +88 -0
- package/.versions/1.0.2/scripts/lib/codex-remote-control.ts +480 -0
- package/.versions/1.0.2/scripts/lib/coms-envelope.ts +582 -0
- package/.versions/1.0.2/scripts/lib/fake-herdr-server.ts +88 -0
- package/.versions/1.0.2/scripts/lib/fleet-command.ts +266 -0
- package/.versions/1.0.2/scripts/lib/herdr-layout.ts +281 -0
- package/.versions/1.0.2/scripts/lib/hermes-bridge-core.ts +241 -0
- package/.versions/1.0.2/scripts/lib/hermes-monitor-events.ts +1 -0
- package/.versions/1.0.2/scripts/lib/hermes-monitor-herdr.ts +2 -0
- package/.versions/1.0.2/scripts/lib/hermes-monitor-model.ts +3 -0
- package/.versions/1.0.2/scripts/lib/hermes-monitor-registry.ts +2 -0
- package/.versions/1.0.2/scripts/lib/hermes-monitor-socket.ts +2 -0
- package/.versions/1.0.2/scripts/lib/hermes-monitor-store.ts +2 -0
- package/.versions/1.0.2/scripts/lib/monitor-env.ts +146 -0
- package/.versions/1.0.2/scripts/lib/peer-launch.ts +318 -0
- package/.versions/1.0.2/scripts/lib/persona-banner.ts +62 -0
- package/.versions/1.0.2/scripts/lib/spawn-stagger.ts +101 -0
- package/.versions/1.0.2/scripts/lib/team-project.ts +213 -0
- package/.versions/1.0.2/scripts/lib/team-snapshot.ts +147 -0
- package/.versions/1.0.2/scripts/peer-banner.ts +40 -0
- package/.versions/1.0.2/scripts/peer-launch.ts +259 -0
- package/.versions/1.0.2/scripts/team-snapshot.ts +237 -0
- package/.versions/1.0.2/scripts/team-up.ts +406 -0
- package/.versions/1.0.2/skills/_internal/grilling.md +11 -0
- package/.versions/1.0.2/skills/browser-testing-with-devtools/SKILL.md +351 -0
- package/.versions/1.0.2/skills/code-review-and-quality/SKILL.md +381 -0
- package/.versions/1.0.2/skills/compound-learning/SKILL.md +137 -0
- package/.versions/1.0.2/skills/context-engineering/SKILL.md +291 -0
- package/.versions/1.0.2/skills/deprecation-and-migration/SKILL.md +206 -0
- package/.versions/1.0.2/skills/designing-agents/SKILL.md +394 -0
- package/.versions/1.0.2/skills/designing-agents/pi-harness-authoring.md +222 -0
- package/.versions/1.0.2/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/1.0.2/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/.versions/1.0.2/skills/idea-refine/SKILL.md +182 -0
- package/.versions/1.0.2/skills/idea-refine/examples.md +238 -0
- package/.versions/1.0.2/skills/idea-refine/frameworks.md +99 -0
- package/.versions/1.0.2/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/1.0.2/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/1.0.2/skills/incremental-implementation/SKILL.md +287 -0
- package/.versions/1.0.2/skills/interview-me/SKILL.md +226 -0
- package/.versions/1.0.2/skills/orchestration-verification/SKILL.md +181 -0
- package/.versions/1.0.2/skills/peer-coms/SKILL.md +90 -0
- package/.versions/1.0.2/skills/performance-optimization/SKILL.md +350 -0
- package/.versions/1.0.2/skills/planning-and-task-breakdown/SKILL.md +254 -0
- package/.versions/1.0.2/skills/security-and-hardening/SKILL.md +461 -0
- package/.versions/1.0.2/skills/spec-driven-development/SKILL.md +257 -0
- package/.versions/1.0.2/skills/using-agent-skills/SKILL.md +199 -0
- package/.versions/1.0.2/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/LICENSE +21 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/README.md +11 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
- package/.versions/1.0.2/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
- package/CHANGELOG.md +9 -0
- package/README.md +4 -2
- package/agents/orchestrator.md +4 -56
- package/docs/ARCHITECTURE.md +48 -16
- package/docs/agent-fleet-setup.md +33 -2
- package/docs/pi-extensions.md +29 -2
- package/install-manifest.json +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
accessDecisionChoices,
|
|
3
|
+
accessRequestCacheKey,
|
|
4
|
+
appendExemptionToFile,
|
|
5
|
+
fileExemptionsFor,
|
|
6
|
+
type AccessDecision,
|
|
7
|
+
type AccessDecisionChoice,
|
|
8
|
+
type AccessRequest,
|
|
9
|
+
} from "../lib/damage-control-shared.ts";
|
|
10
|
+
|
|
11
|
+
type ApprovalContext = {
|
|
12
|
+
hasUI: boolean;
|
|
13
|
+
ui: {
|
|
14
|
+
notify(message: string, level?: string): void;
|
|
15
|
+
select(title: string, options: string[], settings: { timeout: number }): Promise<string | undefined>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type ReplySocket = {
|
|
20
|
+
write(chunk: string): unknown;
|
|
21
|
+
end(): unknown;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type AccessApprovalDeps = {
|
|
25
|
+
getContext(): ApprovalContext | null | undefined;
|
|
26
|
+
getExemptionsFile(): string | null | undefined;
|
|
27
|
+
appendLog(entry: Record<string, unknown>): void;
|
|
28
|
+
now(): string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function createAccessApprovalRouter(deps: AccessApprovalDeps) {
|
|
32
|
+
let askQueue: Promise<unknown> = Promise.resolve();
|
|
33
|
+
let generation = 0;
|
|
34
|
+
const denyCache = new Set<string>();
|
|
35
|
+
const pending = new Map<string, Promise<AccessDecisionChoice>>();
|
|
36
|
+
|
|
37
|
+
const respond = (socket: ReplySocket, msgId: string, decision: AccessDecisionChoice) => {
|
|
38
|
+
const reply: AccessDecision = { type: "access_decision", msg_id: msgId, decision };
|
|
39
|
+
try { socket.write(JSON.stringify(reply) + "\n"); } catch { /* child may have timed out */ }
|
|
40
|
+
try { socket.end(); } catch { /* ignore */ }
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const validRequest = (request: AccessRequest) =>
|
|
44
|
+
typeof request.pattern === "string" && request.pattern.length > 0 &&
|
|
45
|
+
(request.category === "zero_access" || request.category === "read_only" || request.category === "no_delete");
|
|
46
|
+
|
|
47
|
+
const decide = (request: AccessRequest): Promise<AccessDecisionChoice> => {
|
|
48
|
+
const agent = (typeof request.agent === "string" && request.agent) || request.sender_session || "unknown-agent";
|
|
49
|
+
const pattern = request.pattern;
|
|
50
|
+
const cacheKey = accessRequestCacheKey({ ...request, agent, pattern });
|
|
51
|
+
const exemptionsFile = deps.getExemptionsFile();
|
|
52
|
+
const requestGeneration = generation;
|
|
53
|
+
|
|
54
|
+
if (fileExemptionsFor(exemptionsFile ?? undefined, agent).some((entry) => entry.pattern === pattern)) {
|
|
55
|
+
return Promise.resolve("allow_all");
|
|
56
|
+
}
|
|
57
|
+
if (denyCache.has(cacheKey)) return Promise.resolve("deny");
|
|
58
|
+
const existing = pending.get(cacheKey);
|
|
59
|
+
if (existing) return existing;
|
|
60
|
+
|
|
61
|
+
const ask = askQueue.then(async (): Promise<AccessDecisionChoice> => {
|
|
62
|
+
if (requestGeneration !== generation) return "deny";
|
|
63
|
+
const ctx = deps.getContext();
|
|
64
|
+
if (!ctx?.hasUI) return "deny";
|
|
65
|
+
|
|
66
|
+
const labels = new Map<AccessDecisionChoice, string>([
|
|
67
|
+
["deny", "Deny (keep blocked)"],
|
|
68
|
+
["allow_once", "Allow once"],
|
|
69
|
+
["allow_agent", `Allow for ${agent} (this session)`],
|
|
70
|
+
["allow_all", "Allow for all agents (this session)"],
|
|
71
|
+
]);
|
|
72
|
+
const allowed = accessDecisionChoices(request.category);
|
|
73
|
+
const options = allowed.map((decision) => labels.get(decision)!);
|
|
74
|
+
ctx.ui.notify(
|
|
75
|
+
`🛡️ Access request from ${agent}: ${request.rule}\n tool: ${request.tool}\n attempted: ${String(request.invocation || "").slice(0, 200)}`,
|
|
76
|
+
"warning",
|
|
77
|
+
);
|
|
78
|
+
try {
|
|
79
|
+
const choice = await ctx.ui.select(
|
|
80
|
+
`🛡️ ${agent} requests access: ${pattern}`,
|
|
81
|
+
options,
|
|
82
|
+
{ timeout: 600_000 },
|
|
83
|
+
);
|
|
84
|
+
if (requestGeneration !== generation) return "deny";
|
|
85
|
+
const selected = allowed.find((decision) => labels.get(decision) === choice) ?? "deny";
|
|
86
|
+
if (selected === "deny" && choice === labels.get("deny")) denyCache.add(cacheKey);
|
|
87
|
+
return selected;
|
|
88
|
+
} catch {
|
|
89
|
+
return "deny";
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
askQueue = ask.catch(() => {});
|
|
94
|
+
pending.set(cacheKey, ask);
|
|
95
|
+
void ask.finally(() => pending.delete(cacheKey));
|
|
96
|
+
return ask;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
async handle(socket: ReplySocket, request: AccessRequest): Promise<void> {
|
|
101
|
+
if (!validRequest(request)) {
|
|
102
|
+
respond(socket, request.msg_id, "deny");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const agent = (typeof request.agent === "string" && request.agent) || request.sender_session || "unknown-agent";
|
|
106
|
+
const decision = await decide(request).catch((): AccessDecisionChoice => "deny");
|
|
107
|
+
const exemptionsFile = deps.getExemptionsFile();
|
|
108
|
+
if ((decision === "allow_agent" || decision === "allow_all") && exemptionsFile) {
|
|
109
|
+
try {
|
|
110
|
+
appendExemptionToFile(exemptionsFile, {
|
|
111
|
+
pattern: request.pattern,
|
|
112
|
+
scope: "session",
|
|
113
|
+
agent: decision === "allow_agent" ? agent : undefined,
|
|
114
|
+
grantedVia: "escalation",
|
|
115
|
+
grantedAt: deps.now(),
|
|
116
|
+
});
|
|
117
|
+
} catch { /* allow-once semantics still hold via the reply */ }
|
|
118
|
+
}
|
|
119
|
+
deps.appendLog({ action: `escalation_${decision}`, agent, pattern: request.pattern, tool: request.tool, rule: request.rule });
|
|
120
|
+
try {
|
|
121
|
+
deps.getContext()?.ui.notify(
|
|
122
|
+
`🛡️ Access ${decision === "deny" ? "denied" : `granted (${decision.replace(/_/g, " ")})`}: ${request.pattern} — ${agent}`,
|
|
123
|
+
decision === "deny" ? "warning" : "info",
|
|
124
|
+
);
|
|
125
|
+
} catch { /* ignore */ }
|
|
126
|
+
respond(socket, request.msg_id, decision);
|
|
127
|
+
},
|
|
128
|
+
reset() {
|
|
129
|
+
generation++;
|
|
130
|
+
askQueue = Promise.resolve();
|
|
131
|
+
denyCache.clear();
|
|
132
|
+
pending.clear();
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
2
|
+
|
|
3
|
+
// `failures` is deliberately its own kind, not a flavour of `returns`: a run
|
|
4
|
+
// that errored or timed out produced no specialist result, and storing its error
|
|
5
|
+
// text as a return is the most expensive artifact in the system — a 142-byte
|
|
6
|
+
// coms error stub written to returns/code-reviewer-run4.md cost a full dispatch
|
|
7
|
+
// investigating a review that had in fact succeeded, only its reply was lost.
|
|
8
|
+
export const ARTIFACT_KINDS = ["returns", "failures", "plans", "reviews", "inventories", "evidence"];
|
|
9
|
+
|
|
10
|
+
const SESSION_RELATIVE_PREFIXES = new Set(["artifacts", "findings", "delegations"]);
|
|
11
|
+
const PREVIEW_LIMIT = 180;
|
|
12
|
+
|
|
13
|
+
export function resolveArtifactPath(inputPath, options) {
|
|
14
|
+
const raw = String(inputPath || "").trim();
|
|
15
|
+
if (!raw) throw new Error("Artifact path must be a non-empty string");
|
|
16
|
+
if (/\0/.test(raw)) throw new Error(`Invalid artifact path ${JSON.stringify(raw)}`);
|
|
17
|
+
|
|
18
|
+
const repoDir = resolve(options.repoDir);
|
|
19
|
+
const sessionDir = resolve(options.sessionDir);
|
|
20
|
+
const artifactRoot = options.artifactRoot ? resolve(options.artifactRoot) : resolve(sessionDir, "artifacts");
|
|
21
|
+
const normalized = raw.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
22
|
+
|
|
23
|
+
const candidates = [];
|
|
24
|
+
if (isAbsolute(raw)) {
|
|
25
|
+
const absoluteTarget = resolve(raw);
|
|
26
|
+
if (isWithin(artifactRoot, absoluteTarget)) {
|
|
27
|
+
candidates.push({ root: artifactRoot, target: absoluteTarget, displayBase: artifactRoot, prefix: "artifacts" });
|
|
28
|
+
} else if (isWithin(sessionDir, absoluteTarget)) {
|
|
29
|
+
candidates.push({ root: sessionDir, target: absoluteTarget, displayBase: sessionDir, prefix: ".pi/agent-sessions" });
|
|
30
|
+
}
|
|
31
|
+
candidates.push({ root: repoDir, target: absoluteTarget, displayBase: repoDir, prefix: "" });
|
|
32
|
+
} else {
|
|
33
|
+
const first = normalized.split("/")[0];
|
|
34
|
+
if (first === "artifacts") {
|
|
35
|
+
candidates.push({ root: sessionDir, target: safeJoin(sessionDir, normalized), displayBase: artifactRoot, prefix: "artifacts" });
|
|
36
|
+
} else if (ARTIFACT_KINDS.includes(first)) {
|
|
37
|
+
candidates.push({ root: artifactRoot, target: safeJoin(artifactRoot, normalized), displayBase: artifactRoot, prefix: "artifacts" });
|
|
38
|
+
candidates.push({ root: repoDir, target: safeJoin(repoDir, normalized), displayBase: repoDir, prefix: "" });
|
|
39
|
+
} else if (SESSION_RELATIVE_PREFIXES.has(first)) {
|
|
40
|
+
candidates.push({ root: sessionDir, target: safeJoin(sessionDir, normalized), displayBase: sessionDir, prefix: ".pi/agent-sessions" });
|
|
41
|
+
} else {
|
|
42
|
+
candidates.push({ root: repoDir, target: safeJoin(repoDir, normalized), displayBase: repoDir, prefix: "" });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const valid = candidates.filter((candidate) => isWithin(candidate.root, candidate.target));
|
|
47
|
+
if (valid.length === 0) {
|
|
48
|
+
throw new Error(`Refusing artifact path outside repo/session: ${raw}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const exists = typeof options.exists === "function" ? options.exists : () => true;
|
|
52
|
+
const found = valid.find((candidate) => exists(candidate.target));
|
|
53
|
+
if (found) {
|
|
54
|
+
return {
|
|
55
|
+
input: raw,
|
|
56
|
+
path: found.target,
|
|
57
|
+
displayPath: displayPath(found.target, found.displayBase, found.prefix),
|
|
58
|
+
resolvedFromKind: null,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Nothing at the requested path. The hub writes EVERY auto-return under
|
|
63
|
+
// `returns/`, while the deliverable protocol teaches dispatchers that documents
|
|
64
|
+
// live in `artifacts/<kind>/` — so `reviews/code-reviewer-run1.md` is the
|
|
65
|
+
// natural and wrong guess for a file that is sitting in `returns/`. Look for
|
|
66
|
+
// the same name under the other kinds instead of reporting a missing file.
|
|
67
|
+
const requested = matchKindPath(normalized);
|
|
68
|
+
if (requested) {
|
|
69
|
+
const hits = ARTIFACT_KINDS
|
|
70
|
+
.filter((kind) => kind !== requested.kind)
|
|
71
|
+
.map((kind) => ({ kind, target: resolve(artifactRoot, `${kind}/${requested.rest}`) }))
|
|
72
|
+
.filter((candidate) => isWithin(artifactRoot, candidate.target) && exists(candidate.target));
|
|
73
|
+
if (hits.length === 1) {
|
|
74
|
+
return {
|
|
75
|
+
input: raw,
|
|
76
|
+
path: hits[0].target,
|
|
77
|
+
displayPath: displayPath(hits[0].target, artifactRoot, "artifacts"),
|
|
78
|
+
resolvedFromKind: hits[0].kind,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// Never guess between kinds: two files with the same name are two documents.
|
|
82
|
+
if (hits.length > 1) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Ambiguous artifact ${raw}: "${requested.rest}" exists under ${hits.map((h) => `${h.kind}/`).join(" and ")}. ` +
|
|
85
|
+
"Name the kind explicitly.",
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const picked = valid[0];
|
|
91
|
+
return {
|
|
92
|
+
input: raw,
|
|
93
|
+
path: picked.target,
|
|
94
|
+
displayPath: displayPath(picked.target, picked.displayBase, picked.prefix),
|
|
95
|
+
resolvedFromKind: null,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** `reviews/x.md` / `artifacts/reviews/x.md` → `{ kind: "reviews", rest: "x.md" }`. */
|
|
100
|
+
function matchKindPath(normalized) {
|
|
101
|
+
const parts = String(normalized || "").split("/").filter(Boolean);
|
|
102
|
+
const offset = parts[0] === "artifacts" ? 1 : 0;
|
|
103
|
+
const kind = parts[offset];
|
|
104
|
+
if (!ARTIFACT_KINDS.includes(kind)) return null;
|
|
105
|
+
const rest = parts.slice(offset + 1).join("/");
|
|
106
|
+
return rest ? { kind, rest } : null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function resolveArtifactPaths(paths, options) {
|
|
110
|
+
return (paths || []).map((p) => resolveArtifactPath(p, options));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function artifactPreviewFromText(text) {
|
|
114
|
+
const lines = String(text || "").split(/\r?\n/);
|
|
115
|
+
const heading = lines.map((line) => line.trim()).find((line) => /^#{1,6}\s+\S/.test(line));
|
|
116
|
+
if (heading) return truncate(heading.replace(/^#{1,6}\s+/, ""));
|
|
117
|
+
const first = lines.map((line) => line.trim()).find(Boolean);
|
|
118
|
+
return first ? truncate(first) : "(empty file)";
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function formatInputArtifactsSection(items) {
|
|
122
|
+
if (!items || items.length === 0) return "";
|
|
123
|
+
const lines = items.map((item) => `- ${item.displayPath || item.path} — ${item.preview || "(no preview)"}`);
|
|
124
|
+
return `\n\n## Input artifacts\nRead these files with your own read tool when needed. The dispatcher is passing paths plus a one-line preview only; file bodies are intentionally not inlined.\n${lines.join("\n")}`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function safeJoin(root, relativePath) {
|
|
128
|
+
const target = resolve(root, relativePath);
|
|
129
|
+
if (!isWithin(root, target)) throw new Error(`Refusing artifact path outside repo/session: ${relativePath}`);
|
|
130
|
+
return target;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function isWithin(root, target) {
|
|
134
|
+
const rel = relative(resolve(root), resolve(target));
|
|
135
|
+
return rel === "" || (!!rel && !rel.startsWith("..") && !isAbsolute(rel));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function displayPath(target, base, prefix) {
|
|
139
|
+
const rel = relative(resolve(base), resolve(target)).split(sep).join("/");
|
|
140
|
+
if (!prefix) return rel || ".";
|
|
141
|
+
return rel ? `${prefix}/${rel}` : prefix;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function truncate(value) {
|
|
145
|
+
return value.length > PREVIEW_LIMIT ? `${value.slice(0, PREVIEW_LIMIT - 1)}…` : value;
|
|
146
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Assertion-ledger contract — pure validation for the `set_assertions` tool.
|
|
2
|
+
//
|
|
3
|
+
// Two rules, both drawn from the post-mortem of the hub sessions that declared
|
|
4
|
+
// 30 assertions (GO1–GO5, A1–A25) in one call and then spent a dispatch plus an
|
|
5
|
+
// ASK_USER cycle answering "where were A9–A16 defined?":
|
|
6
|
+
//
|
|
7
|
+
// 1. Every assertion names its origin, so an id can always be traced back to
|
|
8
|
+
// the plan/spec line it came from. Refused when missing — a sourceless id
|
|
9
|
+
// is exactly the failure that cost the cycle.
|
|
10
|
+
// 2. The open ledger is capped at MAX_OPEN_ASSERTIONS per batch. Warned, not
|
|
11
|
+
// refused: a large task legitimately has many assertions, they just should
|
|
12
|
+
// not all be open at once. Declare the rest when their batch starts.
|
|
13
|
+
|
|
14
|
+
export const MAX_OPEN_ASSERTIONS = 8;
|
|
15
|
+
|
|
16
|
+
const str = (v) => String(v ?? "").trim();
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Validate + normalize one `set_assertions` batch.
|
|
20
|
+
* Returns { ok, refusal?, warning, assertions } — `assertions` is empty on a
|
|
21
|
+
* refusal so a rejected batch can never half-replace the live ledger.
|
|
22
|
+
*/
|
|
23
|
+
export function validateAssertionBatch(input) {
|
|
24
|
+
const batch = Array.isArray(input) ? input : [];
|
|
25
|
+
|
|
26
|
+
const sourceless = batch
|
|
27
|
+
.map((a, i) => (str(a?.source) === "" ? str(a?.id) || `#${i + 1}` : null))
|
|
28
|
+
.filter((label) => label !== null);
|
|
29
|
+
|
|
30
|
+
if (sourceless.length > 0) {
|
|
31
|
+
return {
|
|
32
|
+
ok: false,
|
|
33
|
+
refusal:
|
|
34
|
+
`Ledger unchanged: ${sourceless.length} assertion(s) declare no source — ${sourceless.join(", ")}. ` +
|
|
35
|
+
"Every assertion must name where it comes from (e.g. source: \"PLAN-x.md:585-595\", " +
|
|
36
|
+
"\"user request\", \"review finding F3\") so a specialist asked to prove it can read the origin " +
|
|
37
|
+
"instead of asking. Re-send the batch with a source on each.",
|
|
38
|
+
warning: null,
|
|
39
|
+
assertions: [],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const assertions = batch.map((a) => ({
|
|
44
|
+
id: str(a?.id),
|
|
45
|
+
tag: str(a?.tag),
|
|
46
|
+
text: str(a?.text),
|
|
47
|
+
source: str(a?.source),
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
const warning =
|
|
51
|
+
assertions.length > MAX_OPEN_ASSERTIONS
|
|
52
|
+
? `⚠ ${assertions.length} assertions are open at once (soft cap ${MAX_OPEN_ASSERTIONS}). ` +
|
|
53
|
+
"Keep this batch to the assertions the next dispatches actually prove and defer the rest — " +
|
|
54
|
+
"declare them with a fresh set_assertions when their batch starts. Accepted as-is."
|
|
55
|
+
: null;
|
|
56
|
+
|
|
57
|
+
return { ok: true, warning, assertions };
|
|
58
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// Dispatch backend policy — pure logic for routing dispatch_agent calls to a
|
|
2
|
+
// native pi subagent or a same-name coms peer (.pi/agents/dispatch-policy.yaml).
|
|
3
|
+
// Parsing + resolution only: no I/O, no pi imports, testable under node --test.
|
|
4
|
+
// The wiring (pool lookup, envelope send, fallback spawn) lives in index.ts.
|
|
5
|
+
|
|
6
|
+
const NAME_RE = /^[A-Za-z0-9_-]+$/;
|
|
7
|
+
const DEFAULT_GRACE_S = 30;
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_POLICY = Object.freeze({
|
|
10
|
+
default: "native",
|
|
11
|
+
grace_s: DEFAULT_GRACE_S,
|
|
12
|
+
substitutions: {},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function stripComment(line) {
|
|
16
|
+
// Values in this file never contain '#'; a minimal comment strip is enough.
|
|
17
|
+
const i = line.indexOf("#");
|
|
18
|
+
return i < 0 ? line : line.slice(0, i);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Minimal parser for the specific dispatch-policy.yaml shape:
|
|
22
|
+
// default: native | coms
|
|
23
|
+
// grace_s: <seconds>
|
|
24
|
+
// substitutions:
|
|
25
|
+
// <member>:
|
|
26
|
+
// prefer: native | coms
|
|
27
|
+
// fallback: native | none
|
|
28
|
+
// timeout_s: <seconds>
|
|
29
|
+
// Not a general YAML parser; tolerant of comments and blank lines only.
|
|
30
|
+
// Never throws: malformed input degrades to DEFAULT_POLICY pieces, with a
|
|
31
|
+
// warning per dropped construct so the hub can notify once.
|
|
32
|
+
export function parseDispatchPolicy(raw) {
|
|
33
|
+
const policy = { default: "native", grace_s: DEFAULT_GRACE_S, substitutions: {} };
|
|
34
|
+
const warnings = [];
|
|
35
|
+
if (typeof raw !== "string" || raw.trim() === "") return { policy, warnings };
|
|
36
|
+
|
|
37
|
+
let inSubstitutions = false;
|
|
38
|
+
let currentMember = null;
|
|
39
|
+
|
|
40
|
+
for (const rawLine of String(raw).split("\n")) {
|
|
41
|
+
const line = stripComment(rawLine.replace(/\s+$/, ""));
|
|
42
|
+
if (line.trim() === "") continue;
|
|
43
|
+
const indent = line.length - line.trimStart().length;
|
|
44
|
+
const content = line.trim();
|
|
45
|
+
const kv = content.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
|
|
46
|
+
if (!kv) {
|
|
47
|
+
warnings.push(`dispatch-policy: ignored unparseable line: ${content}`);
|
|
48
|
+
// Don't let fields after a broken member header leak into the previous member.
|
|
49
|
+
currentMember = null;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const [, key, value] = kv;
|
|
53
|
+
|
|
54
|
+
if (indent === 0) {
|
|
55
|
+
currentMember = null;
|
|
56
|
+
inSubstitutions = false;
|
|
57
|
+
if (key === "substitutions" && value === "") {
|
|
58
|
+
inSubstitutions = true;
|
|
59
|
+
} else if (key === "default") {
|
|
60
|
+
if (value === "native" || value === "coms") policy.default = value;
|
|
61
|
+
else warnings.push(`dispatch-policy: default must be native|coms, got "${value}"`);
|
|
62
|
+
} else if (key === "grace_s") {
|
|
63
|
+
const n = Number(value);
|
|
64
|
+
if (Number.isFinite(n) && n >= 0) policy.grace_s = Math.floor(n);
|
|
65
|
+
else warnings.push(`dispatch-policy: grace_s must be a non-negative number, got "${value}"`);
|
|
66
|
+
} else {
|
|
67
|
+
warnings.push(`dispatch-policy: unknown top-level key "${key}"`);
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!inSubstitutions) continue;
|
|
73
|
+
|
|
74
|
+
// Member header (one indent level, no value).
|
|
75
|
+
if (value === "") {
|
|
76
|
+
if (NAME_RE.test(key)) {
|
|
77
|
+
currentMember = key.toLowerCase();
|
|
78
|
+
policy.substitutions[currentMember] = { prefer: "coms", fallback: "native" };
|
|
79
|
+
} else {
|
|
80
|
+
warnings.push(`dispatch-policy: invalid member name "${key}"`);
|
|
81
|
+
currentMember = null;
|
|
82
|
+
}
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Member field (deeper indent, key: value).
|
|
87
|
+
if (!currentMember) {
|
|
88
|
+
warnings.push(`dispatch-policy: field "${key}" outside a member block`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const sub = policy.substitutions[currentMember];
|
|
92
|
+
if (key === "prefer") {
|
|
93
|
+
if (value === "native" || value === "coms") sub.prefer = value;
|
|
94
|
+
else warnings.push(`dispatch-policy: ${currentMember}.prefer must be native|coms, got "${value}"`);
|
|
95
|
+
} else if (key === "fallback") {
|
|
96
|
+
if (value === "native" || value === "none") sub.fallback = value;
|
|
97
|
+
else warnings.push(`dispatch-policy: ${currentMember}.fallback must be native|none, got "${value}"`);
|
|
98
|
+
} else if (key === "timeout_s") {
|
|
99
|
+
const n = Number(value);
|
|
100
|
+
if (Number.isFinite(n) && n > 0) sub.timeout_s = Math.floor(n);
|
|
101
|
+
else warnings.push(`dispatch-policy: ${currentMember}.timeout_s must be a positive number, got "${value}"`);
|
|
102
|
+
} else {
|
|
103
|
+
warnings.push(`dispatch-policy: unknown field "${key}" for member ${currentMember}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return { policy, warnings };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Decide the backend for one dispatch. Pure: the caller supplies the CURRENT
|
|
111
|
+
// live pool peer names (peersInScope() at dispatch time — hub and peers boot
|
|
112
|
+
// in parallel, so this must never be cached from team activation).
|
|
113
|
+
//
|
|
114
|
+
// Returns one of:
|
|
115
|
+
// { backend: "native" }
|
|
116
|
+
// { backend: "native", comsMissedNotice: "<member> prefers a coms peer ..." }
|
|
117
|
+
// { backend: "coms", peerName, timeout_s? } — peerName is the pool's exact spelling
|
|
118
|
+
// { backend: "await-coms", grace_s } — coms-required, peer not live yet: poll, then refuse
|
|
119
|
+
export function resolveDispatchBackend({ agentName, policy, livePeerNames, requestedBackend = "auto" }) {
|
|
120
|
+
if (!["auto", "native", "coms"].includes(requestedBackend)) {
|
|
121
|
+
return { backend: "invalid", requestedBackend };
|
|
122
|
+
}
|
|
123
|
+
if (requestedBackend === "native") return { backend: "native" };
|
|
124
|
+
|
|
125
|
+
const p = policy && typeof policy === "object" ? policy : DEFAULT_POLICY;
|
|
126
|
+
const name = String(agentName || "").toLowerCase();
|
|
127
|
+
const sub = (p.substitutions || {})[name];
|
|
128
|
+
const live = Array.isArray(livePeerNames) ? livePeerNames : [];
|
|
129
|
+
const match = live.find((n) => String(n).toLowerCase() === name);
|
|
130
|
+
|
|
131
|
+
if (requestedBackend === "coms") {
|
|
132
|
+
if (match === undefined) return { backend: "coms-unavailable" };
|
|
133
|
+
const out = { backend: "coms", peerName: String(match), explicit: true };
|
|
134
|
+
if (sub && sub.timeout_s) out.timeout_s = sub.timeout_s;
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const prefer = sub ? sub.prefer : p.default === "coms" ? "coms" : "native";
|
|
139
|
+
if (prefer !== "coms") return { backend: "native" };
|
|
140
|
+
if (match !== undefined) {
|
|
141
|
+
const out = { backend: "coms", peerName: String(match) };
|
|
142
|
+
if (sub && sub.timeout_s) out.timeout_s = sub.timeout_s;
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (sub && sub.fallback === "none") {
|
|
147
|
+
return { backend: "await-coms", grace_s: Number.isFinite(p.grace_s) ? p.grace_s : DEFAULT_GRACE_S };
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
backend: "native",
|
|
151
|
+
comsMissedNotice:
|
|
152
|
+
`${agentName}: prefers a coms peer but none named "${name}" is live in the pool — using the native subagent.`,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// The refusal returned when a coms-required member's peer never appeared
|
|
157
|
+
// within the grace window.
|
|
158
|
+
export function explicitComsRefusal(agentName) {
|
|
159
|
+
const name = String(agentName || "").toLowerCase();
|
|
160
|
+
return (
|
|
161
|
+
`"${agentName}" requested the explicit coms backend, but no live same-name peer ` +
|
|
162
|
+
`"${name}" is visible in this Hub's pool. Start it with herdr_spawn_peer (inside Herdr), ` +
|
|
163
|
+
"refresh /af-coms, or dispatch again with backend: native or backend: auto. No native subagent was started."
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function comsRequiredRefusal(agentName, graceS) {
|
|
168
|
+
return (
|
|
169
|
+
`"${agentName}" is configured as coms-required (fallback: none) but no live peer named ` +
|
|
170
|
+
`"${String(agentName).toLowerCase()}" appeared in the pool within ${graceS}s. ` +
|
|
171
|
+
"Start it with `just hub-team <team>` / `just team-up <team>`, widen the pool with /af-coms, " +
|
|
172
|
+
"or set `fallback: native` in .pi/agents/dispatch-policy.yaml."
|
|
173
|
+
);
|
|
174
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { turnActiveMs } from "./run-budget.js";
|
|
2
|
+
|
|
3
|
+
export type BudgetContinuationKind = "turn" | "task";
|
|
4
|
+
export type BudgetContinuationOutcome = "continue" | "stop";
|
|
5
|
+
|
|
6
|
+
export const BUDGET_CONTINUATION_MARKER = "agent-hub-budget-continuation";
|
|
7
|
+
|
|
8
|
+
export function budgetContinuationContext(kind: BudgetContinuationKind): string {
|
|
9
|
+
return `[[${BUDGET_CONTINUATION_MARKER}:${kind}]]`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function budgetContinuationKind(context: unknown): BudgetContinuationKind | null {
|
|
13
|
+
if (typeof context !== "string") return null;
|
|
14
|
+
const match = new RegExp(`\\[\\[${BUDGET_CONTINUATION_MARKER}:(turn|task)\\]\\]`).exec(context);
|
|
15
|
+
return (match?.[1] as BudgetContinuationKind | undefined) ?? null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Model-facing protocol appended to a budget refusal. */
|
|
19
|
+
export function budgetContinuationInstruction(message: string, kind: BudgetContinuationKind, userLanguage: string): string {
|
|
20
|
+
const scope = kind === "task" ? "same task with one additional task-budget window" : "same task with a fresh turn-budget window";
|
|
21
|
+
return `${message}\n\n` +
|
|
22
|
+
`Do not ask the human to type continue or run a slash command. Call ask_user exactly once, in ${userLanguage}, ` +
|
|
23
|
+
`to ask whether to continue the ${scope}. Put ${budgetContinuationContext(kind)} in the context, summarize ` +
|
|
24
|
+
`what is complete and what the next window will do, and provide exactly two single-select options in this order: ` +
|
|
25
|
+
`(1) Yes — continue, (2) No — stop. Set allowFreeform to false. The first option automatically renews the ` +
|
|
26
|
+
`${kind} budget; after that answer, continue directly in this tool loop without requesting another message. ` +
|
|
27
|
+
`The second option or cancellation stops.`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function optionTitle(option: unknown): string {
|
|
31
|
+
if (typeof option === "string") return option.trim();
|
|
32
|
+
if (!option || typeof option !== "object") return "";
|
|
33
|
+
const title = (option as { title?: unknown }).title;
|
|
34
|
+
return typeof title === "string" ? title.trim() : "";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function selectedAnswer(result: unknown): string {
|
|
38
|
+
const response = (result as { details?: { response?: unknown } } | null)?.details?.response;
|
|
39
|
+
const selections = (response as { selections?: unknown } | null)?.selections;
|
|
40
|
+
if (Array.isArray(selections) && typeof selections[0] === "string") return selections[0].trim();
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Interpret only a marked, ordered ask_user confirmation. The displayed labels
|
|
46
|
+
* may be translated: option 1 always means continue and every later option
|
|
47
|
+
* means stop. Cancellation is conservative and stops.
|
|
48
|
+
*/
|
|
49
|
+
export function budgetContinuationOutcome(
|
|
50
|
+
params: { context?: unknown; options?: unknown },
|
|
51
|
+
result: unknown,
|
|
52
|
+
): BudgetContinuationOutcome | null {
|
|
53
|
+
if (!budgetContinuationKind(params.context)) return null;
|
|
54
|
+
if ((result as { details?: { cancelled?: unknown } } | null)?.details?.cancelled === true) return "stop";
|
|
55
|
+
if (!Array.isArray(params.options) || params.options.length < 2) return null;
|
|
56
|
+
const options = params.options.map(optionTitle);
|
|
57
|
+
if (!options[0] || options.some(title => !title)) return null;
|
|
58
|
+
const selected = selectedAnswer(result);
|
|
59
|
+
if (!selected) return null;
|
|
60
|
+
const index = options.indexOf(selected);
|
|
61
|
+
if (index < 0) return null;
|
|
62
|
+
return index === 0 ? "continue" : "stop";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Active turn-budget time excludes both completed and currently-open asks. */
|
|
66
|
+
export function turnBudgetActiveMs(
|
|
67
|
+
turnStartedAt: number,
|
|
68
|
+
now: number,
|
|
69
|
+
completedAskWaitMs = 0,
|
|
70
|
+
openAskWaitMs = 0,
|
|
71
|
+
): number {
|
|
72
|
+
return turnActiveMs(turnStartedAt, now, Math.max(0, completedAskWaitMs) + Math.max(0, openAskWaitMs));
|
|
73
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CapabilityPack } from "./capability-packs.ts";
|
|
2
|
+
|
|
3
|
+
export type ConfirmableCapabilityPack = Exclude<CapabilityPack, "core" | "verification" | "compaction">;
|
|
4
|
+
export type CapabilityConfirmationStatus = "pending" | "promoted" | "declined";
|
|
5
|
+
export type CapabilityConfirmationState = Partial<Record<ConfirmableCapabilityPack, CapabilityConfirmationStatus>>;
|
|
6
|
+
|
|
7
|
+
export const CAPABILITY_CONFIRMATION_MARKER = "agent-hub-capability-confirmation";
|
|
8
|
+
|
|
9
|
+
export function capabilityConfirmationContext(pack: ConfirmableCapabilityPack): string {
|
|
10
|
+
return `[[${CAPABILITY_CONFIRMATION_MARKER}:${pack}]]`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function capabilityConfirmationPack(context: unknown): ConfirmableCapabilityPack | null {
|
|
14
|
+
if (typeof context !== "string") return null;
|
|
15
|
+
const match = new RegExp(`\\[\\[${CAPABILITY_CONFIRMATION_MARKER}:(fleet|peer|workspace)\\]\\]`).exec(context);
|
|
16
|
+
return (match?.[1] as ConfirmableCapabilityPack | undefined) ?? null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function capabilityConfirmationQuestion(pack: ConfirmableCapabilityPack): { question: string; context: string; options: string[] } {
|
|
20
|
+
return {
|
|
21
|
+
question: `Use the provisional ${pack} capability for this task?`,
|
|
22
|
+
context: `${capabilityConfirmationContext(pack)} Confirm before its first side effect.`,
|
|
23
|
+
options: ["Confirm", "Reject", "Cancel"],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function confirmationOutcome(result: unknown): "promoted" | "declined" | null {
|
|
28
|
+
const value = result as { details?: { cancelled?: unknown; response?: unknown } } | null;
|
|
29
|
+
if (value?.details?.cancelled === true) return "declined";
|
|
30
|
+
const response = value?.details?.response;
|
|
31
|
+
const answer = Array.isArray((response as { selections?: unknown })?.selections)
|
|
32
|
+
? (response as { selections: unknown[] }).selections.join(" ")
|
|
33
|
+
: typeof (response as { text?: unknown })?.text === "string"
|
|
34
|
+
? (response as { text: string }).text
|
|
35
|
+
: typeof response === "string" ? response : "";
|
|
36
|
+
if (/^\s*confirm\s*$/i.test(answer)) return "promoted";
|
|
37
|
+
if (/^\s*(reject|cancel)\s*$/i.test(answer)) return "declined";
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function confirmationGate(state: CapabilityConfirmationState, pack: ConfirmableCapabilityPack, provisional: boolean): { allowed: true } | { allowed: false; status: "ask" | "pending" | "declined"; message: string } {
|
|
42
|
+
const status = state[pack];
|
|
43
|
+
if (status === "declined") return { allowed: false, status: "declined", message: `provisional ${pack} capability was declined for this task; do not perform this side effect.` };
|
|
44
|
+
if (status === "promoted" || !provisional) return { allowed: true };
|
|
45
|
+
if (status === "pending") return { allowed: false, status: "pending", message: `provisional ${pack} capability awaits its single human confirmation; do not repeat the question or side effect.` };
|
|
46
|
+
return { allowed: false, status: "ask", message: `provisional ${pack} capability requires one human confirmation before this side effect; call ask_user with ${JSON.stringify(capabilityConfirmationQuestion(pack))}.` };
|
|
47
|
+
}
|