@chankov/agent-fleet 0.0.6 → 0.0.7
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/.claude/commands/set-hermes-watchdog.md +6 -0
- package/.opencode/commands/af-set-hermes-watchdog.md +6 -0
- package/.pi/harnesses/agent-hub/README.md +75 -16
- package/.pi/harnesses/agent-hub/artifacts.js +56 -2
- package/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
- package/.pi/harnesses/agent-hub/context-window.js +106 -0
- package/.pi/harnesses/agent-hub/delegate.ts +58 -9
- package/.pi/harnesses/agent-hub/drift-watchdog.js +54 -8
- package/.pi/harnesses/agent-hub/helpers.ts +34 -0
- package/.pi/harnesses/agent-hub/index.ts +723 -159
- package/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
- package/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
- package/.pi/harnesses/agent-hub/monitor-lifecycle.ts +2 -2
- package/.pi/harnesses/agent-hub/monitor-session-bridge.ts +257 -11
- package/.pi/harnesses/agent-hub/package.json +1 -1
- package/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
- package/.pi/harnesses/agent-hub/return-contract.js +78 -0
- package/.pi/harnesses/agent-hub/return-extract.js +75 -0
- package/.pi/harnesses/agent-hub/run-budget.js +29 -3
- package/.pi/harnesses/agent-hub/session-health.js +110 -0
- package/.pi/harnesses/agent-hub/spawn.ts +109 -1
- package/.pi/harnesses/agent-hub/spawned-peers.js +74 -0
- package/.pi/harnesses/coms/README.md +4 -3
- package/.pi/harnesses/coms/index.ts +80 -58
- package/.pi/harnesses/coms/package.json +1 -1
- package/.pi/harnesses/damage-control-continue/package.json +1 -1
- package/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
- package/.pi/harnesses/lib/herdr-client.ts +7 -2
- package/.pi/harnesses/lib/herdr-presence.ts +141 -30
- package/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
- package/.pi/harnesses/lib/hermes-monitor-model.ts +9 -0
- package/.pi/harnesses/lib/hermes-monitor-registry.ts +1 -1
- package/.pi/harnesses/lib/hermes-monitor-socket.ts +47 -2
- package/.pi/prompts/af-set-hermes-watchdog.md +6 -0
- package/.versions/0.0.7/.claude/commands/build.md +44 -0
- package/.versions/0.0.7/.claude/commands/code-simplify.md +22 -0
- package/.versions/0.0.7/.claude/commands/design-agent.md +14 -0
- package/.versions/0.0.7/.claude/commands/doctor-agent-fleet.md +17 -0
- package/.versions/0.0.7/.claude/commands/orchestrate.md +112 -0
- package/.versions/0.0.7/.claude/commands/plan.md +16 -0
- package/.versions/0.0.7/.claude/commands/prime.md +22 -0
- package/.versions/0.0.7/.claude/commands/review.md +16 -0
- package/.versions/0.0.7/.claude/commands/set-hermes-telegram.md +15 -0
- package/.versions/0.0.7/.claude/commands/set-hermes-watchdog.md +6 -0
- package/.versions/0.0.7/.claude/commands/setup-agent-fleet.md +25 -0
- package/.versions/0.0.7/.claude/commands/ship.md +72 -0
- package/.versions/0.0.7/.claude/commands/spec.md +15 -0
- package/.versions/0.0.7/.claude/commands/test.md +19 -0
- package/.versions/0.0.7/.claude/commands/webperf.md +32 -0
- package/.versions/0.0.7/.claude/orchestrate-teams.yaml +24 -0
- package/.versions/0.0.7/.opencode/commands/af-build.md +17 -0
- package/.versions/0.0.7/.opencode/commands/af-code-simplify.md +16 -0
- package/.versions/0.0.7/.opencode/commands/af-compound.md +16 -0
- package/.versions/0.0.7/.opencode/commands/af-design-agent.md +15 -0
- package/.versions/0.0.7/.opencode/commands/af-doctor-agent-fleet.md +17 -0
- package/.versions/0.0.7/.opencode/commands/af-orchestrate.md +112 -0
- package/.versions/0.0.7/.opencode/commands/af-plan.md +16 -0
- package/.versions/0.0.7/.opencode/commands/af-prime.md +22 -0
- package/.versions/0.0.7/.opencode/commands/af-review.md +15 -0
- package/.versions/0.0.7/.opencode/commands/af-set-hermes-telegram.md +15 -0
- package/.versions/0.0.7/.opencode/commands/af-set-hermes-watchdog.md +6 -0
- package/.versions/0.0.7/.opencode/commands/af-setup-agent-fleet.md +15 -0
- package/.versions/0.0.7/.opencode/commands/af-ship.md +16 -0
- package/.versions/0.0.7/.opencode/commands/af-spec.md +16 -0
- package/.versions/0.0.7/.opencode/commands/af-test.md +21 -0
- package/.versions/0.0.7/.opencode/commands/af-webperf.md +32 -0
- package/.versions/0.0.7/.opencode/orchestrate-teams.yaml +24 -0
- package/.versions/0.0.7/.pi/agents/dispatch-policy.yaml +32 -0
- package/.versions/0.0.7/.pi/agents/model-profiles.yaml +20 -0
- package/.versions/0.0.7/.pi/agents/peers.yaml +146 -0
- package/.versions/0.0.7/.pi/agents/teams.yaml +39 -0
- package/.versions/0.0.7/.pi/damage-control-rules.yaml +297 -0
- package/.versions/0.0.7/.pi/extensions/agent-fleet-update-check/README.md +58 -0
- package/.versions/0.0.7/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
- package/.versions/0.0.7/.pi/extensions/agent-fleet-update-check/package.json +6 -0
- package/.versions/0.0.7/.pi/extensions/btw/README.md +118 -0
- package/.versions/0.0.7/.pi/extensions/btw/index.ts +917 -0
- package/.versions/0.0.7/.pi/extensions/btw/package.json +6 -0
- package/.versions/0.0.7/.pi/extensions/btw/state.js +179 -0
- package/.versions/0.0.7/.pi/extensions/chrome-devtools-mcp/README.md +58 -0
- package/.versions/0.0.7/.pi/extensions/chrome-devtools-mcp/index.ts +93 -0
- package/.versions/0.0.7/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.versions/0.0.7/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.versions/0.0.7/.pi/extensions/compact-and-continue/index.ts +120 -0
- package/.versions/0.0.7/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.versions/0.0.7/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.versions/0.0.7/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.versions/0.0.7/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.versions/0.0.7/.pi/extensions/package-lock.json +1143 -0
- package/.versions/0.0.7/.pi/extensions/package.json +9 -0
- package/.versions/0.0.7/.pi/extensions/pi-voice-stt/README.md +201 -0
- package/.versions/0.0.7/.pi/extensions/pi-voice-stt/config.ts +198 -0
- package/.versions/0.0.7/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
- package/.versions/0.0.7/.pi/extensions/pi-voice-stt/index.ts +248 -0
- package/.versions/0.0.7/.pi/extensions/pi-voice-stt/package.json +6 -0
- package/.versions/0.0.7/.pi/extensions/pi-voice-stt/providers.ts +214 -0
- package/.versions/0.0.7/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/README.md +857 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/access-approval.ts +135 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/artifacts.js +146 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/assertion-ledger.js +58 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/backend-policy.js +153 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/context-window.js +106 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/delegate.ts +435 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/drift-watchdog.js +211 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/footer.ts +29 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/helpers.ts +248 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/index.ts +8609 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/monitor-invoke-journal.ts +131 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/monitor-invoke.ts +92 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/monitor-session-bridge.ts +257 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/package.json +7 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/provider-semaphore.js +138 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/research-retention.js +34 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/return-contract.js +293 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/return-extract.js +75 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/run-budget.js +181 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/scope-gate.js +103 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/session-health.js +110 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/spawn.ts +354 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/spawned-peers.js +74 -0
- package/.versions/0.0.7/.pi/harnesses/agent-hub/version.ts +18 -0
- package/.versions/0.0.7/.pi/harnesses/ask-user-remote/README.md +19 -0
- package/.versions/0.0.7/.pi/harnesses/ask-user-remote/index.ts +321 -0
- package/.versions/0.0.7/.pi/harnesses/ask-user-remote/race-core.js +106 -0
- package/.versions/0.0.7/.pi/harnesses/coms/README.md +93 -0
- package/.versions/0.0.7/.pi/harnesses/coms/index.ts +1767 -0
- package/.versions/0.0.7/.pi/harnesses/coms/package.json +7 -0
- package/.versions/0.0.7/.pi/harnesses/coms/version.ts +18 -0
- package/.versions/0.0.7/.pi/harnesses/damage-control-continue/README.md +117 -0
- package/.versions/0.0.7/.pi/harnesses/damage-control-continue/index.ts +536 -0
- package/.versions/0.0.7/.pi/harnesses/damage-control-continue/package.json +7 -0
- package/.versions/0.0.7/.pi/harnesses/damage-control-continue/version.ts +18 -0
- package/.versions/0.0.7/.pi/harnesses/lib/coms-registry-entry.ts +94 -0
- package/.versions/0.0.7/.pi/harnesses/lib/damage-control-shared.ts +197 -0
- package/.versions/0.0.7/.pi/harnesses/lib/herdr-client.ts +463 -0
- package/.versions/0.0.7/.pi/harnesses/lib/herdr-presence.ts +399 -0
- package/.versions/0.0.7/.pi/harnesses/lib/hermes-monitor-events.ts +136 -0
- package/.versions/0.0.7/.pi/harnesses/lib/hermes-monitor-herdr.ts +28 -0
- package/.versions/0.0.7/.pi/harnesses/lib/hermes-monitor-model.ts +18 -0
- package/.versions/0.0.7/.pi/harnesses/lib/hermes-monitor-registry.ts +6 -0
- package/.versions/0.0.7/.pi/harnesses/lib/hermes-monitor-socket.ts +163 -0
- package/.versions/0.0.7/.pi/harnesses/lib/hermes-monitor-store.ts +31 -0
- package/.versions/0.0.7/.pi/harnesses/package-lock.json +35 -0
- package/.versions/0.0.7/.pi/harnesses/package.json +9 -0
- package/.versions/0.0.7/.pi/prompts/af-build.md +24 -0
- package/.versions/0.0.7/.pi/prompts/af-code-simplify.md +22 -0
- package/.versions/0.0.7/.pi/prompts/af-doctor-agent-fleet.md +15 -0
- package/.versions/0.0.7/.pi/prompts/af-plan.md +16 -0
- package/.versions/0.0.7/.pi/prompts/af-review.md +16 -0
- package/.versions/0.0.7/.pi/prompts/af-set-hermes-telegram.md +15 -0
- package/.versions/0.0.7/.pi/prompts/af-set-hermes-watchdog.md +6 -0
- package/.versions/0.0.7/.pi/prompts/af-setup-agent-fleet.md +27 -0
- package/.versions/0.0.7/.pi/prompts/af-ship.md +17 -0
- package/.versions/0.0.7/.pi/prompts/af-spec.md +15 -0
- package/.versions/0.0.7/.pi/prompts/af-test.md +19 -0
- package/.versions/0.0.7/.pi/skills/bowser/SKILL.md +145 -0
- package/.versions/0.0.7/.version +1 -0
- package/.versions/0.0.7/agents/architect.md +23 -0
- package/.versions/0.0.7/agents/bowser.md +26 -0
- package/.versions/0.0.7/agents/builder.md +53 -0
- package/.versions/0.0.7/agents/code-reviewer.md +205 -0
- package/.versions/0.0.7/agents/deep-researcher.md +31 -0
- package/.versions/0.0.7/agents/documenter.md +18 -0
- package/.versions/0.0.7/agents/orchestrator.md +65 -0
- package/.versions/0.0.7/agents/plan-reviewer.md +60 -0
- package/.versions/0.0.7/agents/planner.md +69 -0
- package/.versions/0.0.7/agents/releaser.md +24 -0
- package/.versions/0.0.7/agents/researcher.md +28 -0
- package/.versions/0.0.7/agents/security-auditor.md +166 -0
- package/.versions/0.0.7/agents/test-engineer.md +151 -0
- package/.versions/0.0.7/agents/web-debugger.md +42 -0
- package/.versions/0.0.7/agents/web-performance-auditor.md +192 -0
- package/.versions/0.0.7/codex/CONDUCTOR.md +148 -0
- package/.versions/0.0.7/docs/ARCHITECTURE.md +262 -0
- package/.versions/0.0.7/docs/agent-fleet-setup.md +366 -0
- package/.versions/0.0.7/docs/claude-code-coms-bridge.md +109 -0
- package/.versions/0.0.7/docs/codex-remote-conductor.md +170 -0
- package/.versions/0.0.7/docs/coms-hermes-bridge.md +189 -0
- package/.versions/0.0.7/docs/getting-started.md +231 -0
- package/.versions/0.0.7/docs/npm-install.md +337 -0
- package/.versions/0.0.7/docs/opencode-setup.md +249 -0
- package/.versions/0.0.7/docs/pi-extensions.md +293 -0
- package/.versions/0.0.7/docs/pi-setup.md +476 -0
- package/.versions/0.0.7/docs/skill-anatomy.md +150 -0
- package/.versions/0.0.7/hermes/README.md +347 -0
- package/.versions/0.0.7/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
- package/.versions/0.0.7/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
- package/.versions/0.0.7/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
- package/.versions/0.0.7/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
- package/.versions/0.0.7/hermes/gates/gate-o-capability.md +8 -0
- package/.versions/0.0.7/hermes/gates/gate-o-validator-fixtures.json +1 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
- package/.versions/0.0.7/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
- package/.versions/0.0.7/hermes/skills/hub-conductor/SKILL.md +84 -0
- package/.versions/0.0.7/hermes/skills/hub-liaison/SKILL.md +84 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/SKILL.md +76 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/manifest.json +1 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
- package/.versions/0.0.7/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
- package/.versions/0.0.7/hermes/watchdog-tests/__init__.py +0 -0
- package/.versions/0.0.7/hooks/SIMPLIFY-IGNORE.md +90 -0
- package/.versions/0.0.7/hooks/coms-stop-hook.mjs +84 -0
- package/.versions/0.0.7/hooks/hooks.json +14 -0
- package/.versions/0.0.7/hooks/session-start.sh +74 -0
- package/.versions/0.0.7/hooks/simplify-ignore.sh +302 -0
- package/.versions/0.0.7/justfile +245 -0
- package/.versions/0.0.7/references/accessibility-checklist.md +160 -0
- package/.versions/0.0.7/references/definition-of-done.md +67 -0
- package/.versions/0.0.7/references/fleet-coordination-patterns.md +151 -0
- package/.versions/0.0.7/references/observability-checklist.md +91 -0
- package/.versions/0.0.7/references/orchestration-patterns.md +370 -0
- package/.versions/0.0.7/references/performance-checklist.md +153 -0
- package/.versions/0.0.7/references/prompting-patterns.md +380 -0
- package/.versions/0.0.7/references/security-checklist.md +179 -0
- package/.versions/0.0.7/references/testing-patterns.md +236 -0
- package/.versions/0.0.7/scripts/codex-conductor.ts +41 -0
- package/.versions/0.0.7/scripts/codex-remote-control.ts +167 -0
- package/.versions/0.0.7/scripts/coms-claude-bridge.ts +401 -0
- package/.versions/0.0.7/scripts/coms-cli.ts +484 -0
- package/.versions/0.0.7/scripts/coms-hermes-bridge.ts +413 -0
- package/.versions/0.0.7/scripts/fleet.ts +149 -0
- package/.versions/0.0.7/scripts/hermes-monitor-capability-runner.ts +25 -0
- package/.versions/0.0.7/scripts/hermes-monitor-scenario.ts +474 -0
- package/.versions/0.0.7/scripts/hermes-watchdog-capability-probe.ts +45 -0
- package/.versions/0.0.7/scripts/install-hermes-plugin.sh +180 -0
- package/.versions/0.0.7/scripts/lib/claude-bridge-core.ts +165 -0
- package/.versions/0.0.7/scripts/lib/codex-conductor.ts +88 -0
- package/.versions/0.0.7/scripts/lib/codex-remote-control.ts +480 -0
- package/.versions/0.0.7/scripts/lib/coms-envelope.ts +582 -0
- package/.versions/0.0.7/scripts/lib/fake-herdr-server.ts +88 -0
- package/.versions/0.0.7/scripts/lib/fleet-command.ts +109 -0
- package/.versions/0.0.7/scripts/lib/herdr-layout.ts +263 -0
- package/.versions/0.0.7/scripts/lib/hermes-bridge-core.ts +241 -0
- package/.versions/0.0.7/scripts/lib/hermes-monitor-events.ts +1 -0
- package/.versions/0.0.7/scripts/lib/hermes-monitor-herdr.ts +2 -0
- package/.versions/0.0.7/scripts/lib/hermes-monitor-model.ts +3 -0
- package/.versions/0.0.7/scripts/lib/hermes-monitor-registry.ts +2 -0
- package/.versions/0.0.7/scripts/lib/hermes-monitor-socket.ts +2 -0
- package/.versions/0.0.7/scripts/lib/hermes-monitor-store.ts +2 -0
- package/.versions/0.0.7/scripts/lib/monitor-env.ts +120 -0
- package/.versions/0.0.7/scripts/lib/persona-banner.ts +62 -0
- package/.versions/0.0.7/scripts/lib/spawn-stagger.ts +101 -0
- package/.versions/0.0.7/scripts/lib/team-project.ts +191 -0
- package/.versions/0.0.7/scripts/lib/team-snapshot.ts +147 -0
- package/.versions/0.0.7/scripts/peer-banner.ts +40 -0
- package/.versions/0.0.7/scripts/team-snapshot.ts +237 -0
- package/.versions/0.0.7/scripts/team-up.ts +360 -0
- package/.versions/0.0.7/skills/_internal/grilling.md +11 -0
- package/.versions/0.0.7/skills/browser-testing-with-devtools/SKILL.md +352 -0
- package/.versions/0.0.7/skills/code-review-and-quality/SKILL.md +381 -0
- package/.versions/0.0.7/skills/compound-learning/SKILL.md +137 -0
- package/.versions/0.0.7/skills/context-engineering/SKILL.md +291 -0
- package/.versions/0.0.7/skills/deprecation-and-migration/SKILL.md +206 -0
- package/.versions/0.0.7/skills/designing-agents/SKILL.md +394 -0
- package/.versions/0.0.7/skills/designing-agents/pi-harness-authoring.md +222 -0
- package/.versions/0.0.7/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/0.0.7/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/.versions/0.0.7/skills/guided-workspace-setup/SKILL.md +544 -0
- package/.versions/0.0.7/skills/guided-workspace-setup/companion-manifest.json +35 -0
- package/.versions/0.0.7/skills/idea-refine/SKILL.md +182 -0
- package/.versions/0.0.7/skills/idea-refine/examples.md +238 -0
- package/.versions/0.0.7/skills/idea-refine/frameworks.md +99 -0
- package/.versions/0.0.7/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/0.0.7/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/0.0.7/skills/incremental-implementation/SKILL.md +287 -0
- package/.versions/0.0.7/skills/interview-me/SKILL.md +226 -0
- package/.versions/0.0.7/skills/orchestration-verification/SKILL.md +181 -0
- package/.versions/0.0.7/skills/peer-coms/SKILL.md +90 -0
- package/.versions/0.0.7/skills/performance-optimization/SKILL.md +350 -0
- package/.versions/0.0.7/skills/planning-and-task-breakdown/SKILL.md +236 -0
- package/.versions/0.0.7/skills/security-and-hardening/SKILL.md +461 -0
- package/.versions/0.0.7/skills/spec-driven-development/SKILL.md +245 -0
- package/.versions/0.0.7/skills/using-agent-skills/SKILL.md +199 -0
- package/.versions/0.0.7/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/LICENSE +21 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/README.md +11 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
- package/.versions/0.0.7/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
- package/CHANGELOG.md +134 -0
- package/README.md +175 -18
- package/agents/code-reviewer.md +2 -2
- package/agents/orchestrator.md +11 -0
- package/agents/plan-reviewer.md +1 -1
- package/agents/planner.md +1 -1
- package/agents/security-auditor.md +1 -1
- package/bin/cli.js +40 -1
- package/bin/lib/hermes-profile-artifact.js +144 -0
- package/bin/lib/set-hermes-watchdog.js +173 -0
- package/bin/set-hermes-watchdog.js +26 -0
- package/docs/ARCHITECTURE.md +64 -12
- package/docs/agent-fleet-setup.md +2 -2
- package/docs/claude-code-coms-bridge.md +7 -1
- package/docs/coms-hermes-bridge.md +10 -0
- package/docs/getting-started.md +48 -0
- package/docs/hermes-watchdog-supervisor.md +140 -0
- package/hermes/README.md +135 -19
- package/hermes/desktop-plugins/agent-fleet-herdr/plugin.js +1291 -0
- package/hermes/desktop-plugins/agent-fleet-herdr/presentation.js +672 -0
- package/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
- package/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
- package/hermes/plugins/agent-fleet-herdr/dashboard/activity.py +770 -0
- package/hermes/plugins/agent-fleet-herdr/dashboard/coms_registry.py +134 -0
- package/hermes/plugins/agent-fleet-herdr/dashboard/coms_send.py +350 -0
- package/hermes/plugins/agent-fleet-herdr/dashboard/herdr_source.py +193 -0
- package/hermes/plugins/agent-fleet-herdr/dashboard/manifest.json +4 -0
- package/hermes/plugins/agent-fleet-herdr/dashboard/plugin_api.py +444 -0
- package/hermes/plugins/agent-fleet-herdr/dashboard/sessions.py +205 -0
- package/hermes/plugins/agent-fleet-herdr/dashboard/tasks.py +300 -0
- package/hermes/plugins/agent-fleet-herdr/dashboard/watch.py +819 -0
- package/hermes/plugins/agent-fleet-herdr/plugin.yaml +8 -0
- package/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +139 -0
- package/hermes/plugins/agent-fleet-monitor/dashboard/dist/index.js +10 -0
- package/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
- package/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
- package/hermes/skills/hub-watchdog/SKILL.md +76 -0
- package/hermes/skills/hub-watchdog/manifest.json +1 -0
- package/hermes/skills/hub-watchdog/scripts/watchdog.py +249 -0
- package/hermes/skills/hub-watchdog/scripts/watchdog_actions.py +124 -0
- package/hermes/skills/hub-watchdog/scripts/watchdog_contract.py +76 -0
- package/hermes/skills/hub-watchdog/scripts/watchdog_delivery.py +10 -0
- package/hermes/skills/hub-watchdog/scripts/watchdog_engine.py +128 -0
- package/hermes/skills/hub-watchdog/scripts/watchdog_judgment.py +41 -0
- package/hermes/skills/hub-watchdog/scripts/watchdog_recovery.py +103 -0
- package/hermes/skills/hub-watchdog/scripts/watchdog_state.py +163 -0
- package/hermes/skills/hub-watchdog/scripts/watchdog_transport.py +138 -0
- package/hooks/coms-stop-hook.mjs +12 -1
- package/package.json +11 -2
- package/scripts/coms-claude-bridge.ts +154 -39
- package/scripts/fleet.ts +9 -1
- package/scripts/hermes-watchdog-capability-probe.ts +45 -0
- package/scripts/lib/claude-bridge-core.ts +65 -0
- package/scripts/lib/coms-envelope.ts +44 -1
- package/scripts/lib/hermes-monitor-events.ts +1 -0
- package/scripts/lib/monitor-env.ts +120 -0
- package/scripts/team-snapshot.ts +1 -1
- package/scripts/team-up.ts +10 -1
- package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-cap.test.py +0 -15
- package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-discovery.test.py +0 -19
- package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-envelope.test.py +0 -13
- package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-forged-owner.test.py +0 -11
- package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-lease-list.test.py +0 -9
- package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-multihub.test.py +0 -17
- package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-output.test.py +0 -34
- package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter.test.py +0 -39
- package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/plugin-api-validation.test.py +0 -12
- package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/review-live-wiring.red.test.py +0 -22
- package/.versions/0.0.5/hermes/plugins/agent-fleet-monitor/dashboard/adapter-cap.test.py +0 -15
- package/.versions/0.0.5/hermes/plugins/agent-fleet-monitor/dashboard/adapter-discovery.test.py +0 -19
- package/.versions/0.0.5/hermes/plugins/agent-fleet-monitor/dashboard/adapter-envelope.test.py +0 -13
- package/.versions/0.0.5/hermes/plugins/agent-fleet-monitor/dashboard/adapter-forged-owner.test.py +0 -11
- package/.versions/0.0.5/hermes/plugins/agent-fleet-monitor/dashboard/adapter-lease-list.test.py +0 -9
- package/.versions/0.0.5/hermes/plugins/agent-fleet-monitor/dashboard/adapter-multihub.test.py +0 -17
- package/.versions/0.0.5/hermes/plugins/agent-fleet-monitor/dashboard/adapter-output.test.py +0 -34
- package/.versions/0.0.5/hermes/plugins/agent-fleet-monitor/dashboard/adapter.test.py +0 -39
- package/.versions/0.0.5/hermes/plugins/agent-fleet-monitor/dashboard/plugin-api-validation.test.py +0 -12
- package/.versions/0.0.5/hermes/plugins/agent-fleet-monitor/dashboard/review-live-wiring.red.test.py +0 -22
- package/.versions/0.0.6/hermes/plugins/agent-fleet-monitor/dashboard/adapter-cap.test.py +0 -15
- package/.versions/0.0.6/hermes/plugins/agent-fleet-monitor/dashboard/adapter-discovery.test.py +0 -19
- package/.versions/0.0.6/hermes/plugins/agent-fleet-monitor/dashboard/adapter-envelope.test.py +0 -13
- package/.versions/0.0.6/hermes/plugins/agent-fleet-monitor/dashboard/adapter-forged-owner.test.py +0 -11
- package/.versions/0.0.6/hermes/plugins/agent-fleet-monitor/dashboard/adapter-lease-list.test.py +0 -9
- package/.versions/0.0.6/hermes/plugins/agent-fleet-monitor/dashboard/adapter-multihub.test.py +0 -17
- package/.versions/0.0.6/hermes/plugins/agent-fleet-monitor/dashboard/adapter-output.test.py +0 -34
- package/.versions/0.0.6/hermes/plugins/agent-fleet-monitor/dashboard/adapter.test.py +0 -39
- package/.versions/0.0.6/hermes/plugins/agent-fleet-monitor/dashboard/plugin-api-validation.test.py +0 -12
- package/.versions/0.0.6/hermes/plugins/agent-fleet-monitor/dashboard/review-live-wiring.red.test.py +0 -22
|
@@ -11,11 +11,21 @@
|
|
|
11
11
|
// pane (herdr has no wildcard for that topic — spike finding). When the
|
|
12
12
|
// tracked pane set changes, the stream is torn down and resubscribed.
|
|
13
13
|
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
14
|
+
// Two wire dialects for the same idea — "this pane is coms peer X":
|
|
15
|
+
//
|
|
16
|
+
// tokens (herdr >= 0.7.4) `tokens: { coms, proj, ctx, q }` on
|
|
17
|
+
// pane.report_metadata. Values are uncapped, so the
|
|
18
|
+
// peer name arrives whole and the PROJECT travels
|
|
19
|
+
// with it — which is what makes the join a real key
|
|
20
|
+
// (two projects may each run an `orchestrator`).
|
|
21
|
+
// custom_status (<= 0.7.3) a single 32-char-capped string,
|
|
22
|
+
// `<name> <pct>% q<depth>`, name FIRST so a
|
|
23
|
+
// truncated tail still leaves the identity readable.
|
|
24
|
+
//
|
|
25
|
+
// herdr 0.7.4 dropped `custom_status` from PaneReportMetadataParams entirely,
|
|
26
|
+
// which made every report fail — silently, because report() swallows errors.
|
|
27
|
+
// So: tokens first, one latched fallback to the legacy string, and an onError
|
|
28
|
+
// hook so a dialect mismatch is never invisible again.
|
|
19
29
|
//
|
|
20
30
|
// Pure module: no pi imports; erasable-TS; testable under node --test.
|
|
21
31
|
|
|
@@ -46,7 +56,32 @@ export async function herdrPresenceAvailable(
|
|
|
46
56
|
return (await herdrAvailable(opts)) !== null;
|
|
47
57
|
}
|
|
48
58
|
|
|
49
|
-
//
|
|
59
|
+
// What a pane advertises about the coms peer occupying it.
|
|
60
|
+
export interface PeerPresence {
|
|
61
|
+
name: string;
|
|
62
|
+
// The coms project. Optional only because the legacy dialect cannot carry
|
|
63
|
+
// it; always pass it when you have it — without it, two projects running a
|
|
64
|
+
// peer of the same name are indistinguishable to any watcher.
|
|
65
|
+
project?: string | null;
|
|
66
|
+
contextUsedPct: number;
|
|
67
|
+
queueDepth: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Token keys must match herdr's `^[A-Za-z0-9_-]{1,32}$`; at most 16 per pane.
|
|
71
|
+
// `ctx`/`q` are for human eyes in the sidebar — the registry entry carries the
|
|
72
|
+
// authoritative numbers — so they are formatted, not raw.
|
|
73
|
+
export function peerTokens(presence: PeerPresence): Record<string, string> {
|
|
74
|
+
const tokens: Record<string, string> = {
|
|
75
|
+
coms: presence.name,
|
|
76
|
+
ctx: `${Math.round(presence.contextUsedPct)}%`,
|
|
77
|
+
q: `q${presence.queueDepth}`,
|
|
78
|
+
};
|
|
79
|
+
if (presence.project) tokens.proj = presence.project;
|
|
80
|
+
return tokens;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Legacy dialect: `<name> <pct>% q<depth>` truncated to the 32-char server cap,
|
|
84
|
+
// name first. The project does not fit and is therefore not carried.
|
|
50
85
|
export function formatPeerStatus(name: string, contextUsedPct: number, queueDepth: number): string {
|
|
51
86
|
const s = `${name} ${Math.round(contextUsedPct)}% q${queueDepth}`;
|
|
52
87
|
return s.length <= CUSTOM_STATUS_MAX ? s : s.slice(0, CUSTOM_STATUS_MAX);
|
|
@@ -61,6 +96,27 @@ export function parsePeerName(customStatus: string | undefined | null): string |
|
|
|
61
96
|
return name || null;
|
|
62
97
|
}
|
|
63
98
|
|
|
99
|
+
// The one place that knows how to read a peer identity off a herdr pane,
|
|
100
|
+
// whichever dialect wrote it. `agent.rename` also puts a name on a pane, but
|
|
101
|
+
// that one is human-assigned and not necessarily a coms peer, so it is the last
|
|
102
|
+
// resort rather than the first.
|
|
103
|
+
export function peerNameFrom(agent: HerdrAgentInfo | undefined | null): string | null {
|
|
104
|
+
if (!agent) return null;
|
|
105
|
+
const token = agent.tokens?.coms;
|
|
106
|
+
if (typeof token === "string" && token.trim()) return token.trim();
|
|
107
|
+
const legacy = parsePeerName(agent.custom_status);
|
|
108
|
+
if (legacy) return legacy;
|
|
109
|
+
const named = agent.name;
|
|
110
|
+
return typeof named === "string" && named.trim() ? named.trim() : null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// The coms project a pane advertises, or null when the writer could not carry
|
|
114
|
+
// one (legacy dialect). Null means "unscoped", never "the default project".
|
|
115
|
+
export function peerProjectFrom(agent: HerdrAgentInfo | undefined | null): string | null {
|
|
116
|
+
const token = agent?.tokens?.proj;
|
|
117
|
+
return typeof token === "string" && token.trim() ? token.trim() : null;
|
|
118
|
+
}
|
|
119
|
+
|
|
64
120
|
export type PresenceState = "idle" | "working" | "blocked" | "unknown";
|
|
65
121
|
|
|
66
122
|
export interface HerdrPresenceOptions extends HerdrClientOptions {
|
|
@@ -70,8 +126,14 @@ export interface HerdrPresenceOptions extends HerdrClientOptions {
|
|
|
70
126
|
source: string;
|
|
71
127
|
// Detected-agent label shown in the sidebar; pi peers report "pi".
|
|
72
128
|
agentLabel?: string;
|
|
129
|
+
// Called the first time an annotation dialect is rejected, and again if the
|
|
130
|
+
// fallback is rejected too. Presence stays best-effort, but a herdr that no
|
|
131
|
+
// longer speaks our wire format must not be able to hide.
|
|
132
|
+
onError?: (err: Error, dialect: AnnotationDialect) => void;
|
|
73
133
|
}
|
|
74
134
|
|
|
135
|
+
export type AnnotationDialect = "tokens" | "custom_status";
|
|
136
|
+
|
|
75
137
|
// Reports this agent's state into its herdr pane. All calls are best-effort:
|
|
76
138
|
// presence must never break the session, so errors resolve false.
|
|
77
139
|
//
|
|
@@ -79,46 +141,91 @@ export interface HerdrPresenceOptions extends HerdrClientOptions {
|
|
|
79
141
|
// state and covers panes herdr's built-in detection does NOT recognize; for
|
|
80
142
|
// recognized panes (pi has a detection manifest) that call is accepted but
|
|
81
143
|
// IGNORED — detection holds agent authority — so pane.report_metadata carries
|
|
82
|
-
// the
|
|
83
|
-
//
|
|
144
|
+
// the peer annotation that detection cannot provide.
|
|
145
|
+
//
|
|
146
|
+
// The annotation dialect is negotiated by trying and latching, not by version
|
|
147
|
+
// sniffing: `herdr --version` is a string we would have to keep a table for,
|
|
148
|
+
// while a rejected request is the actual answer to the actual question.
|
|
84
149
|
export class HerdrPresence {
|
|
85
150
|
private opts: HerdrPresenceOptions;
|
|
151
|
+
private dialect: AnnotationDialect | null = null;
|
|
152
|
+
private reported = new Set<AnnotationDialect>();
|
|
86
153
|
|
|
87
154
|
constructor(opts: HerdrPresenceOptions) {
|
|
88
155
|
this.opts = opts;
|
|
89
156
|
}
|
|
90
157
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
158
|
+
// Which dialect this pane's herdr accepted, once known. Exposed for
|
|
159
|
+
// diagnostics (the coms audit log records it) — never a branch condition
|
|
160
|
+
// anywhere but here.
|
|
161
|
+
acceptedDialect(): AnnotationDialect | null {
|
|
162
|
+
return this.dialect;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private noteError(err: Error, dialect: AnnotationDialect): void {
|
|
166
|
+
if (this.reported.has(dialect)) return;
|
|
167
|
+
this.reported.add(dialect);
|
|
95
168
|
try {
|
|
96
|
-
|
|
97
|
-
{ pane_id: this.opts.paneId, source: this.opts.source, agent, state, custom_status: status },
|
|
98
|
-
this.opts,
|
|
99
|
-
);
|
|
100
|
-
ok = true;
|
|
169
|
+
this.opts.onError?.(err, dialect);
|
|
101
170
|
} catch {
|
|
102
|
-
//
|
|
171
|
+
// a broken reporter must not break presence
|
|
103
172
|
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private async writeAnnotation(presence: PeerPresence, agent: string, dialect: AnnotationDialect): Promise<boolean> {
|
|
176
|
+
const base = {
|
|
177
|
+
pane_id: this.opts.paneId,
|
|
178
|
+
source: this.opts.source,
|
|
179
|
+
agent,
|
|
180
|
+
// Expire if this reporter dies without releasing: a bit over two
|
|
181
|
+
// keepalive cycles keeps the annotation fresh-or-gone.
|
|
182
|
+
ttl_ms: 90_000,
|
|
183
|
+
};
|
|
184
|
+
const params =
|
|
185
|
+
dialect === "tokens"
|
|
186
|
+
? { ...base, tokens: peerTokens(presence) }
|
|
187
|
+
: {
|
|
188
|
+
...base,
|
|
189
|
+
custom_status: formatPeerStatus(presence.name, presence.contextUsedPct, presence.queueDepth),
|
|
190
|
+
};
|
|
104
191
|
try {
|
|
105
|
-
await herdr.paneReportMetadata(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
192
|
+
await herdr.paneReportMetadata(params, this.opts);
|
|
193
|
+
this.dialect = dialect;
|
|
194
|
+
return true;
|
|
195
|
+
} catch (err) {
|
|
196
|
+
this.noteError(err as Error, dialect);
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// The identity half of presence on its own: "this pane is coms peer X",
|
|
202
|
+
// with no claim about what the agent is doing. Callers whose pane state is
|
|
203
|
+
// owned by someone else use this instead of report() — the Claude bridge
|
|
204
|
+
// reads `agent_status` back as its own turn-completion signal, so a state
|
|
205
|
+
// it reported itself would poison the loop that polls it.
|
|
206
|
+
async annotate(presence: PeerPresence): Promise<boolean> {
|
|
207
|
+
const agent = this.opts.agentLabel ?? "pi";
|
|
208
|
+
// Once a dialect has worked, stop probing: a retry per report would put
|
|
209
|
+
// a guaranteed-failing request on the wire every 30s forever.
|
|
210
|
+
const order: AnnotationDialect[] = this.dialect ? [this.dialect] : ["tokens", "custom_status"];
|
|
211
|
+
for (const dialect of order) {
|
|
212
|
+
if (await this.writeAnnotation(presence, agent, dialect)) return true;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async report(state: PresenceState, presence: PeerPresence): Promise<boolean> {
|
|
218
|
+
let ok = false;
|
|
219
|
+
try {
|
|
220
|
+
await herdr.paneReportAgent(
|
|
221
|
+
{ pane_id: this.opts.paneId, source: this.opts.source, agent: this.opts.agentLabel ?? "pi", state },
|
|
115
222
|
this.opts,
|
|
116
223
|
);
|
|
117
224
|
ok = true;
|
|
118
225
|
} catch {
|
|
119
|
-
//
|
|
226
|
+
// fall through — the annotation may still land
|
|
120
227
|
}
|
|
121
|
-
return ok;
|
|
228
|
+
return (await this.annotate(presence)) || ok;
|
|
122
229
|
}
|
|
123
230
|
|
|
124
231
|
async release(): Promise<void> {
|
|
@@ -137,6 +244,10 @@ export interface HerdrAgentInfo {
|
|
|
137
244
|
pane_id: string;
|
|
138
245
|
agent?: string;
|
|
139
246
|
agent_status?: string;
|
|
247
|
+
// herdr >= 0.7.4
|
|
248
|
+
tokens?: Record<string, string>;
|
|
249
|
+
name?: string;
|
|
250
|
+
// herdr <= 0.7.3
|
|
140
251
|
custom_status?: string;
|
|
141
252
|
workspace_id?: string;
|
|
142
253
|
[key: string]: unknown;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import * as crypto from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { validateMonitorEvent } from "./hermes-monitor-model.ts";
|
|
6
|
+
|
|
7
|
+
export const EVENT_RETENTION_MS = 24 * 60 * 60 * 1000;
|
|
8
|
+
export const EVENT_RETENTION_MAX = 4096;
|
|
9
|
+
|
|
10
|
+
function mode(file: string): number { return fs.statSync(file).mode & 0o777; }
|
|
11
|
+
|
|
12
|
+
function safeFile(file: string): void {
|
|
13
|
+
if (!path.isAbsolute(file)) throw new Error("event journal path must be absolute");
|
|
14
|
+
const directory = path.dirname(file);
|
|
15
|
+
if (fs.existsSync(directory) && (fs.lstatSync(directory).isSymbolicLink() || mode(directory) !== 0o700)) throw new Error("event journal directory is unsafe");
|
|
16
|
+
fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
17
|
+
fs.chmodSync(directory, 0o700);
|
|
18
|
+
if (!fs.existsSync(file)) return;
|
|
19
|
+
const stat = fs.lstatSync(file);
|
|
20
|
+
if (stat.isSymbolicLink() || !stat.isFile() || mode(file) !== 0o600) throw new Error("event journal is unsafe");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Persist only the monitor-event contract; arbitrary extra fields are never journaled. */
|
|
24
|
+
function safeEvent(value: unknown): any {
|
|
25
|
+
const valid = validateMonitorEvent(value);
|
|
26
|
+
if (!valid) return null;
|
|
27
|
+
const event: any = {
|
|
28
|
+
schema: valid.schema, schemaVersion: valid.schemaVersion, eventId: valid.eventId,
|
|
29
|
+
eventSequence: valid.eventSequence, profileKey: valid.profileKey, hubInstanceId: valid.hubInstanceId,
|
|
30
|
+
ownerId: valid.ownerId, occurredAt: valid.occurredAt, kind: valid.kind, materialKey: valid.materialKey,
|
|
31
|
+
};
|
|
32
|
+
if (valid.task) {
|
|
33
|
+
event.task = { id: valid.task.id, generation: valid.task.generation };
|
|
34
|
+
for (const key of ["parentId", "specialist", "fromState", "toState", "outputSequence"])
|
|
35
|
+
if (valid.task[key] !== undefined) event.task[key] = valid.task[key];
|
|
36
|
+
}
|
|
37
|
+
return event;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class MonitorEventJournal {
|
|
41
|
+
private readonly file: string;
|
|
42
|
+
private readonly now: () => Date;
|
|
43
|
+
private events: any[] = [];
|
|
44
|
+
private sequence = 0;
|
|
45
|
+
private waiters = new Set<{ afterSequence: number; limit: number; resolve: (value: any) => void; timer: NodeJS.Timeout }>();
|
|
46
|
+
|
|
47
|
+
constructor(options: { file: string; now?: () => Date }) {
|
|
48
|
+
this.file = options.file;
|
|
49
|
+
this.now = options.now ?? (() => new Date());
|
|
50
|
+
safeFile(this.file);
|
|
51
|
+
this.load();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private load(): void {
|
|
55
|
+
if (!fs.existsSync(this.file)) return;
|
|
56
|
+
const body = fs.readFileSync(this.file, "utf8");
|
|
57
|
+
if (!body) return;
|
|
58
|
+
const lines = body.split("\n");
|
|
59
|
+
if (lines.at(-1) === "") lines.pop();
|
|
60
|
+
for (const line of lines) {
|
|
61
|
+
let event: any;
|
|
62
|
+
try { event = safeEvent(JSON.parse(line)); } catch { throw new Error("event journal is torn or corrupt"); }
|
|
63
|
+
if (!event) throw new Error("event journal is unsafe");
|
|
64
|
+
if (!this.events.length) this.sequence = event.eventSequence - 1;
|
|
65
|
+
if (event.eventSequence !== this.sequence + 1) throw new Error("event journal is unsafe");
|
|
66
|
+
this.events.push(event);
|
|
67
|
+
this.sequence = event.eventSequence;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
append(value: unknown): any {
|
|
72
|
+
const event = safeEvent(value);
|
|
73
|
+
if (!event || event.eventSequence !== this.sequence + 1) throw new Error("invalid event sequence");
|
|
74
|
+
const fd = fs.openSync(this.file, "a", 0o600);
|
|
75
|
+
try {
|
|
76
|
+
fs.writeSync(fd, `${JSON.stringify(event)}\n`);
|
|
77
|
+
fs.fsyncSync(fd);
|
|
78
|
+
} finally {
|
|
79
|
+
fs.closeSync(fd);
|
|
80
|
+
}
|
|
81
|
+
fs.chmodSync(this.file, 0o600);
|
|
82
|
+
this.events.push(event);
|
|
83
|
+
this.sequence = event.eventSequence;
|
|
84
|
+
this.resolveWaiters();
|
|
85
|
+
this.prune();
|
|
86
|
+
return event;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private prune(): void {
|
|
90
|
+
const cutoff = this.now().getTime() - EVENT_RETENTION_MS;
|
|
91
|
+
const retained = this.events.filter(event => Date.parse(event.occurredAt) >= cutoff).slice(-EVENT_RETENTION_MAX);
|
|
92
|
+
if (retained.length === this.events.length) return;
|
|
93
|
+
const temporary = `${this.file}.${process.pid}.${crypto.randomBytes(4).toString("hex")}.tmp`;
|
|
94
|
+
const fd = fs.openSync(temporary, "wx", 0o600);
|
|
95
|
+
try {
|
|
96
|
+
fs.writeSync(fd, retained.map(event => JSON.stringify(event)).join("\n") + (retained.length ? "\n" : ""));
|
|
97
|
+
fs.fsyncSync(fd);
|
|
98
|
+
} finally { fs.closeSync(fd); }
|
|
99
|
+
fs.renameSync(temporary, this.file);
|
|
100
|
+
const directoryFd = fs.openSync(path.dirname(this.file), "r");
|
|
101
|
+
try { fs.fsyncSync(directoryFd); } finally { fs.closeSync(directoryFd); }
|
|
102
|
+
this.events = retained;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private result(afterSequence: number, limit: number, timedOut = false): any {
|
|
106
|
+
const firstAvailableSequence = this.events[0]?.eventSequence ?? this.sequence + 1;
|
|
107
|
+
if (afterSequence < firstAvailableSequence - 1) return { error: "cursor_too_old", snapshotRequired: true, firstAvailableSequence, latestSequence: this.sequence };
|
|
108
|
+
return { firstAvailableSequence, latestSequence: this.sequence, items: this.events.filter(event => event.eventSequence > afterSequence).slice(0, limit), timedOut };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
replay(afterSequence: number, limit: number, waitMs = 0, signal?: AbortSignal): any | Promise<any> {
|
|
112
|
+
if (!Number.isInteger(afterSequence) || !Number.isInteger(limit) || limit < 1 || limit > 100 || !Number.isInteger(waitMs) || waitMs < 0 || waitMs > 25_000) throw new Error("invalid cursor");
|
|
113
|
+
const immediate = this.result(afterSequence, limit);
|
|
114
|
+
if (immediate.error || immediate.items.length || waitMs === 0) return immediate;
|
|
115
|
+
return new Promise(resolve => {
|
|
116
|
+
const waiter: any = { afterSequence, limit, resolve, timer: setTimeout(() => this.removeWaiter(waiter, true), waitMs) };
|
|
117
|
+
this.waiters.add(waiter);
|
|
118
|
+
if (signal?.aborted) { this.removeWaiter(waiter, false); return; }
|
|
119
|
+
signal?.addEventListener("abort", () => this.removeWaiter(waiter, false), { once: true });
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
cancelWaiter(waiter: unknown): void { this.removeWaiter(waiter as any, false); }
|
|
124
|
+
private removeWaiter(waiter: any, timedOut: boolean): void {
|
|
125
|
+
if (!this.waiters.delete(waiter)) return;
|
|
126
|
+
clearTimeout(waiter.timer);
|
|
127
|
+
waiter.resolve(this.result(waiter.afterSequence, waiter.limit, timedOut));
|
|
128
|
+
}
|
|
129
|
+
private resolveWaiters(): void {
|
|
130
|
+
for (const waiter of [...this.waiters]) {
|
|
131
|
+
const result = this.result(waiter.afterSequence, waiter.limit);
|
|
132
|
+
if (result.error || result.items.length) this.removeWaiter(waiter, false);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
latestSequence(): number { return this.sequence; }
|
|
136
|
+
}
|
|
@@ -7,3 +7,12 @@ function requireStableIdentity(id:string,generation:number){if(!id)throw Error("
|
|
|
7
7
|
export function createParentTask(input:CreateParentTaskInput):MonitorTask{requireStableIdentity(input.id,input.generation);if(!input.hubInstanceId||!input.checkoutId)throw Error("parent correlation is required");return{id:input.id,generation:input.generation,kind:"parent",state:"starting",hubInstanceId:input.hubInstanceId,checkoutId:input.checkoutId,...owner(input)};}
|
|
8
8
|
export function createChildTask(input:CreateChildTaskInput):MonitorTask{requireStableIdentity(input.id,input.generation);if(!input.parentId||!Number.isInteger(input.parentGeneration)||input.parentGeneration<1||!input.specialist)throw Error("child hierarchy is required");return{id:input.id,generation:input.generation,kind:"child",state:"starting",parentId:input.parentId,parentGeneration:input.parentGeneration,specialist:input.specialist,...(input.workspaceId?{workspaceId:input.workspaceId}:{}),...(input.hubPaneId?{hubPaneId:input.hubPaneId}:{}),...owner(input)};}
|
|
9
9
|
export function transitionTask(task:MonitorTask,state:MonitorTaskState):MonitorTask{if(TERMINAL_TASK_STATES.has(task.state))throw Error(`terminal task ${task.id} cannot mutate`);if(state==="starting")throw Error("tasks cannot transition back to starting");return{...task,state};}export function continueTask(task:MonitorTask):MonitorTask{if(task.state!=="blocked")throw Error(`only blocked task ${task.id} can continue`);return{...task,generation:task.generation+1,state:"starting"};}
|
|
10
|
+
|
|
11
|
+
export const MONITOR_EVENT_SCHEMA="agent-fleet.monitor-event" as const;
|
|
12
|
+
export const MONITOR_EVENT_KINDS=new Set(["hub.turn_started","hub.turn_completed","hub.queue_depth_changed","hub.capability_changed","task.started","task.state_changed","task.output_advanced","task.late_event","task.generation_superseded","owner.lease_changed","owner.recovering","owner.orphaned","action.requested","action.accepted","action.rejected","action.completed"]);
|
|
13
|
+
export const MONITOR_INVOKE_ACTIONS=new Set(["request_status","request_verification","narrow_scope","request_research","request_specialist"]);
|
|
14
|
+
const id=(v:unknown,max=128)=>typeof v==="string"&&v.length>0&&v.length<=max&&/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(v);
|
|
15
|
+
const positive=(v:unknown)=>Number.isInteger(v)&&(v as number)>0&&(v as number)<=1_000_000_000;
|
|
16
|
+
export function normalizeIngressTaskState(value:unknown):MonitorTaskState|null{return value==="done"?"completed":typeof value==="string"&&(["starting","running","cancelling","completed","blocked","failed","cancelled","orphaned","recovering"] as string[]).includes(value)?value as MonitorTaskState:null;}
|
|
17
|
+
export function validateMonitorEvent(value:unknown):any|null{const v=value as any;if(!v||v.schema!==MONITOR_EVENT_SCHEMA||v.schemaVersion!==1||!id(v.eventId)||!positive(v.eventSequence)||!id(v.profileKey,80)||!id(v.hubInstanceId)||!id(v.ownerId)||typeof v.occurredAt!=="string"||Number.isNaN(Date.parse(v.occurredAt))||!MONITOR_EVENT_KINDS.has(v.kind)||!id(v.materialKey,256))return null;if(v.task!==undefined){if(!v.task||!id(v.task.id)||!positive(v.task.generation)||(v.task.outputSequence!==undefined&&(!Number.isInteger(v.task.outputSequence)||v.task.outputSequence<0))||(v.task.toState!==undefined&&normalizeIngressTaskState(v.task.toState)!==v.task.toState))return null;}return structuredClone(v);}
|
|
18
|
+
export function validateMonitorInvoke(value:unknown):any|null{const v=value as any;if(!v||!id(v.requestId)||!id(v.taskId)||!positive(v.generation)||!MONITOR_INVOKE_ACTIONS.has(v.action)||!v.parameters||typeof v.parameters!=="object"||!v.basis||v.basis.judgment!=="confirmed"||typeof v.basis.deviation!=="string"||v.basis.deviation.length>64)return null;const p=v.parameters;if(Object.keys(p).some(k=>!["assertionIds","evidenceEventIds","instruction"].includes(k))||!Array.isArray(p.assertionIds)||p.assertionIds.length>20||!Array.isArray(p.evidenceEventIds)||p.evidenceEventIds.length>20||p.assertionIds.some((x:unknown)=>!id(x,64))||p.evidenceEventIds.some((x:unknown)=>!id(x,128))||(p.instruction!==undefined&&(typeof p.instruction!=="string"||p.instruction.length>1024)))return null;return structuredClone(v);}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as crypto from "node:crypto"; import * as fs from "node:fs"; import * as path from "node:path";
|
|
2
|
-
export interface MonitorRegistration {profileKey:string;namespacePath:string;socketPath:string;socketDir:string;token:string;namespaceMode:number;tokenMode:number;discoveryPath:string;snapshot():unknown;cancel?(r:{taskId:string;generation:number}):unknown|Promise<unknown>;output?(r:{taskId:string;generation:number;afterSequence:number}):unknown|Promise<unknown>;cleanup():void;renew():void;leaseMs:number;ownerId?:string;leaseExpiresAt?:string;}
|
|
2
|
+
export interface MonitorRegistration {profileKey:string;namespacePath:string;socketPath:string;socketDir:string;token:string;namespaceMode:number;tokenMode:number;discoveryPath:string;snapshot():unknown;cancel?(r:{taskId:string;generation:number}):unknown|Promise<unknown>;output?(r:{taskId:string;generation:number;afterSequence:number}):unknown|Promise<unknown>;events?(r:{afterSequence:number;limit:number;waitMs:number}):unknown|Promise<unknown>;invoke?(r:unknown):unknown|Promise<unknown>;cleanup():void;renew():void;leaseMs:number;ownerId?:string;leaseExpiresAt?:string;}
|
|
3
3
|
export interface MonitorRegistryOptions {runtimeDir:string;now?:()=>Date;pid?:number;leaseMs?:number;beforeRenewPublish?:()=>void;} export interface RegisterMonitorInput {profilePath:string;profileId?:string;hubInstanceId:string;snapshot:()=>unknown;}
|
|
4
4
|
const D=0o700,F=0o600;const validDiscovery=(d:any)=>typeof d?.owner==="string"&&/^[0-9a-f-]{36}$/i.test(d.owner)&&typeof d.token==="string"&&/^token-[0-9a-f-]{36}$/i.test(d.token)&&typeof d.socket==="string"&&/^@runtime\/s\/[a-f0-9]+\/s$/.test(d.socket)&&typeof d.lease?.hub==="string"&&/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(d.lease.hub)&&Number.isInteger(d.lease?.pid)&&d.lease.pid>0&&typeof d.lease?.startedAt==="string"&&!Number.isNaN(Date.parse(d.lease.startedAt))&&typeof d.lease?.expiresAt==="string"&&!Number.isNaN(Date.parse(d.lease.expiresAt));const mode=(p:string)=>fs.statSync(p).mode&0o777;function dir(p:string){if(!path.isAbsolute(p))throw Error("monitor runtime directory must be absolute");fs.mkdirSync(p,{recursive:true,mode:D});if(fs.lstatSync(p).isSymbolicLink())throw Error("monitor runtime directory must not be a symlink");fs.chmodSync(p,D);}export function canonicalMonitorProfileId(id:string){if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(id)||id.includes(".."))throw Error("monitor profile id is unsafe");return crypto.createHash("sha256").update(id).digest("hex");}function profile(p:string,id?:string){if(id)return canonicalMonitorProfileId(id);const real=fs.realpathSync(p);if(!fs.statSync(real).isDirectory())throw Error("monitor profile path must be a directory");return crypto.createHash("sha256").update(real).digest("hex");}function hub(id:string){if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(id)||id.includes(".."))throw Error("hub instance id is unsafe");return crypto.createHash("sha256").update(id).digest("hex");}function atomic(p:string,s:string){const t=`${p}.${process.pid}.${crypto.randomBytes(4).toString("hex")}.tmp`;fs.writeFileSync(t,s,{mode:F,flag:"wx"});fs.chmodSync(t,F);fs.renameSync(t,p);}
|
|
5
5
|
export class MonitorRegistry {private runtimeDir:string;private now:()=>Date;private pid:number;private leaseMs:number;private beforeRenewPublish?:()=>void;constructor(o:MonitorRegistryOptions){this.runtimeDir=o.runtimeDir;this.now=o.now??(()=>new Date());this.pid=o.pid??process.pid;this.leaseMs=o.leaseMs??30_000;this.beforeRenewPublish=o.beforeRenewPublish;dir(this.runtimeDir);}register(input:RegisterMonitorInput):MonitorRegistration{const key=profile(input.profilePath,input.profileId),h=hub(input.hubInstanceId),ns=path.join(this.runtimeDir,key,h);dir(path.join(this.runtimeDir,key));dir(ns);for(const file of fs.readdirSync(ns).filter(x=>x.startsWith("discovery-"))){const discoveryPath=path.join(ns,file);try{const d=JSON.parse(fs.readFileSync(discoveryPath,"utf8"));if(!validDiscovery(d)||d.token!==`token-${d.owner}`||d.socket!==`@runtime/s/${crypto.createHash("sha256").update(`${key}:${h}:${d.owner}`).digest("hex").slice(0,32)}/s`)throw new Error("monitor discovery metadata is malformed");if(new Date(d.lease?.expiresAt).getTime()>this.now().getTime()){const error:any=Error("monitor namespace is owned by an active lease");error.leaseExpiresAt=d.lease.expiresAt;throw error;}const tokenName=d.token;if(typeof tokenName==="string"&&/^token-[0-9a-f-]+$/.test(tokenName))try{fs.unlinkSync(path.join(ns,tokenName))}catch(e:any){if(e?.code!=="ENOENT")throw e;}fs.unlinkSync(discoveryPath);const socket=typeof d.socket==="string"?d.socket:"";if(socket.startsWith("@runtime/s/")&&socket.endsWith("/s")){const socketDir=path.join(this.runtimeDir,socket.slice("@runtime/".length,-2));if(socketDir.startsWith(path.join(this.runtimeDir,"s")+path.sep))try{fs.rmSync(socketDir,{recursive:true,force:true})}catch{}}}catch(e:any){if(/active lease|malformed/.test(String(e)))throw e;if(e instanceof SyntaxError||e instanceof TypeError||e instanceof RangeError)throw new Error("monitor discovery metadata is malformed");}}
|
|
@@ -14,6 +14,8 @@ export const MAX_TASK_ID_LENGTH = 128;
|
|
|
14
14
|
export const MAX_AFTER_SEQUENCE = 1_000_000_000;
|
|
15
15
|
/** 2 MiB covers the 256 KiB retained UTF-8 output after worst-case JSON escaping plus its envelope. */
|
|
16
16
|
export const MAX_OUTPUT_RESPONSE_BYTES = 2 * 1024 * 1024;
|
|
17
|
+
export const MAX_EVENT_WAITERS = 8;
|
|
18
|
+
export const MAX_EVENT_WAIT_MS = 25_000;
|
|
17
19
|
|
|
18
20
|
interface SnapshotRequest {
|
|
19
21
|
type: "snapshot";
|
|
@@ -42,13 +44,20 @@ export class MonitorSocketServer {
|
|
|
42
44
|
private readonly registration: MonitorRegistration;
|
|
43
45
|
private readonly server: net.Server;
|
|
44
46
|
private connections = 0;
|
|
47
|
+
private eventWaiters = 0;
|
|
48
|
+
private readonly sockets = new Set<net.Socket>();
|
|
45
49
|
|
|
46
50
|
constructor(registration: MonitorRegistration) {
|
|
47
51
|
this.registration = registration;
|
|
48
|
-
|
|
52
|
+
// Consumers are documented to half-close after writing their single frame.
|
|
53
|
+
// Without allowHalfOpen the runtime would end our writable side on that FIN,
|
|
54
|
+
// silently dropping any response that settles later than the current turn —
|
|
55
|
+
// every long-poll `events` reply, and any cancel that waits on a real exit.
|
|
56
|
+
this.server = net.createServer({ allowHalfOpen: true }, (socket) => {
|
|
49
57
|
if (this.connections >= MAX_SOCKET_CONNECTIONS) { socket.destroy(); return; }
|
|
50
58
|
this.connections += 1;
|
|
51
|
-
|
|
59
|
+
this.sockets.add(socket);
|
|
60
|
+
socket.once("close", () => { this.connections -= 1; this.sockets.delete(socket); });
|
|
52
61
|
this.handle(socket);
|
|
53
62
|
});
|
|
54
63
|
}
|
|
@@ -68,6 +77,7 @@ export class MonitorSocketServer {
|
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
async close(): Promise<void> {
|
|
80
|
+
for (const socket of this.sockets) socket.destroy();
|
|
71
81
|
await new Promise<void>((resolve, reject) => this.server.close((error) => error ? reject(error) : resolve()));
|
|
72
82
|
this.assertOwnedSocketPath(); try { fs.unlinkSync(this.registration.socketPath); } catch (error: any) { if (error?.code !== "ENOENT") throw error; }
|
|
73
83
|
}
|
|
@@ -77,6 +87,9 @@ export class MonitorSocketServer {
|
|
|
77
87
|
}
|
|
78
88
|
|
|
79
89
|
private handle(socket: net.Socket): void {
|
|
90
|
+
// A long-poll callback may settle after its peer disconnects. Keep that
|
|
91
|
+
// late write local to this connection instead of emitting an unhandled error.
|
|
92
|
+
socket.on("error", () => {});
|
|
80
93
|
let buffer = "";
|
|
81
94
|
let handled = false;
|
|
82
95
|
const deadline = setTimeout(() => { if (!handled) socket.destroy(); }, PARTIAL_FRAME_TIMEOUT_MS);
|
|
@@ -94,6 +107,38 @@ export class MonitorSocketServer {
|
|
|
94
107
|
clearTimeout(deadline);
|
|
95
108
|
let value: { type?: string; token?: string; taskId?: string; generation?: number };
|
|
96
109
|
try { value = JSON.parse(buffer.slice(0, newline)) as typeof value; } catch { socket.destroy(); return; }
|
|
110
|
+
if (value.type === "events") {
|
|
111
|
+
if (!authorized(String(value.token ?? ""), this.registration.token)) { socket.end(JSON.stringify({ ok: false, error: "unauthorized" }) + "\n"); return; }
|
|
112
|
+
const afterSequence=(value as any).afterSequence, limit=(value as any).limit, waitMs=(value as any).waitMs;
|
|
113
|
+
if (!this.registration.events || !Number.isInteger(afterSequence) || afterSequence < 0 || afterSequence > MAX_AFTER_SEQUENCE || !Number.isInteger(limit) || limit < 1 || limit > 100 || !Number.isInteger(waitMs) || waitMs < 0 || waitMs > MAX_EVENT_WAIT_MS) { socket.destroy(); return; }
|
|
114
|
+
if (waitMs > 0 && this.eventWaiters >= MAX_EVENT_WAITERS) { socket.end(JSON.stringify({ ok: false, error: "too_many_waiters" }) + "\n"); return; }
|
|
115
|
+
let waiterReleased = false;
|
|
116
|
+
const releaseWaiter = () => {
|
|
117
|
+
if (waitMs > 0 && !waiterReleased) { waiterReleased = true; this.eventWaiters--; }
|
|
118
|
+
};
|
|
119
|
+
const abort = new AbortController();
|
|
120
|
+
if (waitMs > 0) {
|
|
121
|
+
this.eventWaiters++;
|
|
122
|
+
// Release on FIN as well as close: with allowHalfOpen a gone peer is
|
|
123
|
+
// otherwise indistinguishable from a live one, and a parked waiter
|
|
124
|
+
// would hold a slot for the full wait window. A client that wants to
|
|
125
|
+
// park on a long poll keeps its write side open (as the watcher does);
|
|
126
|
+
// one that half-closes gets an immediate bounded reply instead.
|
|
127
|
+
const release = () => { abort.abort(); releaseWaiter(); };
|
|
128
|
+
socket.once("close", release);
|
|
129
|
+
socket.once("end", release);
|
|
130
|
+
}
|
|
131
|
+
Promise.resolve().then(()=>this.registration.events!({afterSequence,limit,waitMs,signal:abort.signal})).then((events:any)=>{
|
|
132
|
+
if (events?.error === "cursor_too_old") socket.end(JSON.stringify({ ok: false, error: "cursor_too_old", snapshotRequired: true, firstAvailableSequence: events.firstAvailableSequence, latestSequence: events.latestSequence }) + "\n");
|
|
133
|
+
else socket.end(JSON.stringify({ok:true,events})+"\n");
|
|
134
|
+
}).catch(()=>socket.end(JSON.stringify({ok:false,error:"monitor_unavailable"})+"\n")).finally(releaseWaiter); return;
|
|
135
|
+
}
|
|
136
|
+
if (value.type === "invoke") {
|
|
137
|
+
if (!authorized(String(value.token ?? ""), this.registration.token)) { socket.end(JSON.stringify({ ok: false, error: "unauthorized" }) + "\n"); return; }
|
|
138
|
+
if (!this.registration.invoke) { socket.end(JSON.stringify({ ok: false, error: "unsupported" }) + "\n"); return; }
|
|
139
|
+
const request={...(value as any)}; delete (request as any).token; delete (request as any).type;
|
|
140
|
+
Promise.resolve().then(()=>this.registration.invoke!(request)).then(result=>socket.end(JSON.stringify({ok:true,result})+"\n")).catch(()=>socket.end(JSON.stringify({ok:false,error:"monitor_unavailable"})+"\n")); return;
|
|
141
|
+
}
|
|
97
142
|
if (value.type === "output") {
|
|
98
143
|
if (!authorized(String(value.token ?? ""), this.registration.token)) { socket.end(JSON.stringify({ ok: false, error: "unauthorized" }) + "\n"); return; }
|
|
99
144
|
if (!this.registration.output || (value as any).afterSequence === undefined || !validTaskRequest(value.taskId, value.generation, (value as any).afterSequence)) { socket.destroy(); return; }
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Inspect or safely install the fail-closed Hermes watchdog
|
|
3
|
+
argument-hint: "<status|install|update|uninstall> [--profile NAME] [--force] [--dry-run]"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Before any non-`status` write, ask the user to confirm the exact profile and whether `--force` is intended. Run only the packaged deterministic controller. It never starts, stops, restarts, or kills Hermes or a watcher; it preserves watchdog config and journals. Gate O has no genuine reviewed live proof of origin routing, so do not initiate a watch or claim delivery, out-of-turn updates, steering, or surgical recovery.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Implement tasks incrementally — build, test, verify, commit. Add "auto" to run the whole plan in one approved pass.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Invoke the agent-fleet:incremental-implementation skill alongside agent-fleet:test-driven-development.
|
|
6
|
+
|
|
7
|
+
## Modes
|
|
8
|
+
|
|
9
|
+
- **`/build`** — implement the *next* pending task, then stop (careful, one slice at a time).
|
|
10
|
+
- **`/build auto`** — generate the plan if needed, get a single approval, then implement *every* task without stopping between them.
|
|
11
|
+
|
|
12
|
+
`$ARGUMENTS` selects the mode. Treat `auto` (canonical) or `all` as autonomous mode; anything else (or empty) is the default single-task mode. Note: autonomous mode is not faster *per task* — it runs the same test-driven loop — it only removes the human stepping *between* tasks.
|
|
13
|
+
|
|
14
|
+
## Default: one task
|
|
15
|
+
|
|
16
|
+
Pick the next pending task from the plan. Then:
|
|
17
|
+
|
|
18
|
+
1. Read the task's acceptance criteria
|
|
19
|
+
2. Load relevant context (existing code, patterns, types)
|
|
20
|
+
3. Write a failing test for the expected behavior (RED)
|
|
21
|
+
4. Implement the minimum code to pass the test (GREEN)
|
|
22
|
+
5. Run the full test suite to check for regressions
|
|
23
|
+
6. Run the build to verify compilation
|
|
24
|
+
7. Commit with a descriptive message
|
|
25
|
+
8. Mark the task complete and stop
|
|
26
|
+
|
|
27
|
+
## Autonomous: the whole plan (`/build auto`)
|
|
28
|
+
|
|
29
|
+
Use this once a spec exists and you want to collapse plan + build into one run. It removes the manual stepping between tasks — **not** the verification. Every task still earns a passing test and its own commit.
|
|
30
|
+
|
|
31
|
+
1. **Require a spec.** Look only for a spec at a known path: `SPEC.md` at the repo root, `docs/SPEC.md`, or a file under `spec/`. A README or arbitrary doc does **not** count. If none exists, stop and tell the user to run `/spec` first — do not invent requirements.
|
|
32
|
+
2. **Establish a clean baseline.** Run `git status --porcelain`. If there are uncommitted changes outside the expected planning artifacts (`SPEC.md`, `docs/SPEC.md`, `spec/*`, `tasks/plan.md`, `tasks/todo.md`), stop and ask the user to commit, stash, or confirm how to handle them. Autonomous per-task commits must not absorb unrelated local work, or the clean-rollback guarantee breaks.
|
|
33
|
+
3. **Plan if needed.** If there is no `tasks/plan.md`, invoke agent-fleet:planning-and-task-breakdown to generate one.
|
|
34
|
+
4. **Single checkpoint.** Present the full plan and wait for an unambiguous affirmative (e.g. "approve", "go", "yes"). Treat hedged responses ("looks reasonable", "I guess") as **not** approved. This is the only human gate — after approval, run autonomously. If you generated `tasks/plan.md`, commit it as a single preparatory commit now so it doesn't bleed into the first task's commit.
|
|
35
|
+
5. **Execute every task in dependency order.** Use each task's declared dependencies; if they aren't explicit, execute in the order the plan lists them. For each task, run the full default loop above (RED → GREEN → regression → build → commit → mark complete). Stage only the files that task touched plus its task-status update — never `git add -A` blindly — and make one commit per task so any point is a clean rollback.
|
|
36
|
+
6. **Stop and ask the user** (do not push through) when:
|
|
37
|
+
- a test can't be made to pass or the build breaks without an obvious fix → follow agent-fleet:debugging-and-error-recovery
|
|
38
|
+
- the spec is ambiguous, or a task needs a decision the spec doesn't cover
|
|
39
|
+
- a task is high-risk or irreversible — auth/permission changes, destructive data migrations, payments, deletions, deploys, anything touching secrets, **or anything you can't undo with `git revert`** → follow agent-fleet:doubt-driven-development and get explicit sign-off before continuing
|
|
40
|
+
|
|
41
|
+
After the user resolves a blocker, they re-invoke `/build auto` — it resumes from the next pending task.
|
|
42
|
+
7. **Summarize at the end:** tasks completed, tests added, commits made, and anything skipped, flagged, or left for the user.
|
|
43
|
+
|
|
44
|
+
If any step fails, follow the agent-fleet:debugging-and-error-recovery skill.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Simplify code for clarity and maintainability — reduce complexity without changing behavior
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Invoke the agent-fleet:code-simplification skill.
|
|
6
|
+
|
|
7
|
+
Simplify recently changed code (or the specified scope) while preserving exact behavior:
|
|
8
|
+
|
|
9
|
+
1. Read CLAUDE.md and study project conventions
|
|
10
|
+
2. Identify the target code — recent changes unless a broader scope is specified
|
|
11
|
+
3. Understand the code's purpose, callers, edge cases, and test coverage before touching it
|
|
12
|
+
4. Scan for simplification opportunities:
|
|
13
|
+
- Deep nesting → guard clauses or extracted helpers
|
|
14
|
+
- Long functions → split by responsibility
|
|
15
|
+
- Nested ternaries → if/else or switch
|
|
16
|
+
- Generic names → descriptive names
|
|
17
|
+
- Duplicated logic → shared functions
|
|
18
|
+
- Dead code → remove after confirming
|
|
19
|
+
5. Apply each simplification incrementally — run tests after each change
|
|
20
|
+
6. Verify all tests pass, the build succeeds, and the diff is clean
|
|
21
|
+
|
|
22
|
+
If tests fail after a simplification, revert that change and reconsider. Use `code-review-and-quality` to review the result.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Design and write a new agent persona (agents/), workflow skill (skills/), or pi harness (.pi/harnesses/)
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Invoke the agent-fleet:designing-agents skill.
|
|
6
|
+
|
|
7
|
+
Begin by understanding what the user wants to author:
|
|
8
|
+
1. Is this a **persona** (a role/lens the agent adopts, e.g. a reviewer or auditor), a **skill** (a repeatable workflow with gated steps and verification), or a **pi harness** (a TypeScript pi extension that reshapes the session — footer, tool-call gate, new command, or orchestrator)?
|
|
9
|
+
2. The one-sentence purpose and when it should be invoked
|
|
10
|
+
3. The framework or steps — dimensions evaluated (persona), ordered workflow (skill), or session surface and events hooked (harness)
|
|
11
|
+
4. Explicit non-goals and scope limits
|
|
12
|
+
5. Output shape — what a typical invocation should produce
|
|
13
|
+
|
|
14
|
+
Then scan the target location (`agents/`, `skills/`, or `.pi/harnesses/`) for overlap, draft the artifact using the matching template — four-block persona structure, the section order from `docs/skill-anatomy.md`, or the harness pattern in `skills/designing-agents/pi-harness-authoring.md` — verify the draft against `references/prompting-patterns.md`, and confirm with the user before writing the file(s).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Scan agent-fleet install targets for broken symlinks, stale persona references, and overrides-file problems, then offer repairs
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Invoke the Doctor scan from the `agent-fleet:guided-workspace-setup` skill — Step 5 (the preflight scan) — without running the rest of the install flow. Use this when the user wants the repair pass on its own; the full `/setup-agent-fleet` flow runs the same scan automatically as soon as it detects prior install state.
|
|
6
|
+
|
|
7
|
+
Walk every install-target directory the chosen coding agent uses (`agents/`, `.claude/agents/`, `.opencode/agent/` (+ legacy `.opencode/agents/`), `.pi/agents/`, `.claude/skills/`, `.opencode/skills/`, `.pi/skills/`, `.agents/skills`, `.claude/commands/`, `.opencode/commands/`, `.pi/prompts/`, `.claude/references/`, `.claude/hooks/`). For each broken symlink, resolve where it pointed, look for a canonical replacement in the source `agents/` and `skills/` trees, and offer to repair or delete (persona links under `.claude/agents/` and `.opencode/agent(s)/` are repaired by regenerating a transformed copy via `transform-persona`, not by re-symlinking the raw source). Common stale names from the pre-merge persona layout: `reviewer` → `code-reviewer`, `red-team` → `security-auditor`.
|
|
8
|
+
|
|
9
|
+
Also flag and offer to rewrite any remaining YAML configs (`teams.yaml`, `peers.yaml`, etc.) that still reference removed persona names.
|
|
10
|
+
|
|
11
|
+
Also flag malformed peer entries in `.pi/agents/peers.yaml`: field lines (`persona:`, `model:`, ...) that sit under a team heading before any `- name: ...` list item. The team-up launcher's minimal parser silently drops such lines, so the peer never spawns and nothing errors — the usual cause is a `- name:` line lost in an edit. These findings are advisory only: report them with the missing `- name: <peer>` suggestion, never rewrite the file.
|
|
12
|
+
|
|
13
|
+
Also validate `.ai/agent-fleet-overrides.md` when it exists, against the schema in `docs/agent-fleet-setup.md`: unknown sections, unknown keys in known sections, invalid values for the mechanically parsed `agent-hub` keys, missing `rules:` folders and `docs:` entry points, and `## env` `required:` names that are neither set nor declared in the root `.env`. These findings are advisory only — report them with fix "edit by hand", never edit the overrides file.
|
|
14
|
+
|
|
15
|
+
Present the findings per the skill's Step 1 interaction contract: print a short text summary (counts per kind, advisory findings as report-only text), then ask one `AskUserQuestion` multi-select — *"Which fixes should I apply now?"* — each option titled `<path> — <issue>` with the proposed fix as its description, chunked at ≤ 4 options per question; an empty selection applies nothing.
|
|
16
|
+
|
|
17
|
+
Never overwrite a regular file — only act on symlinks whose target is missing. Report `repaired`, `deleted`, and `skipped` counts, and append a `## doctor-runs` line to `.ai/agent-fleet-setup.md` with the date, agent, phase (`standalone`), and counts.
|