@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,163 @@
|
|
|
1
|
+
import * as crypto from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as net from "node:net";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
|
|
6
|
+
import type { MonitorRegistration } from "./hermes-monitor-registry.ts";
|
|
7
|
+
|
|
8
|
+
export const MAX_SOCKET_FRAME_BYTES = 64 * 1024;
|
|
9
|
+
export const MAX_SNAPSHOT_BYTES = 256 * 1024;
|
|
10
|
+
export const MAX_CANCEL_RESPONSE_BYTES = 16 * 1024;
|
|
11
|
+
export const PARTIAL_FRAME_TIMEOUT_MS = 1000;
|
|
12
|
+
export const MAX_SOCKET_CONNECTIONS = 32;
|
|
13
|
+
export const MAX_TASK_ID_LENGTH = 128;
|
|
14
|
+
export const MAX_AFTER_SEQUENCE = 1_000_000_000;
|
|
15
|
+
/** 2 MiB covers the 256 KiB retained UTF-8 output after worst-case JSON escaping plus its envelope. */
|
|
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;
|
|
19
|
+
|
|
20
|
+
interface SnapshotRequest {
|
|
21
|
+
type: "snapshot";
|
|
22
|
+
token: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function authorized(actual: string, expected: string): boolean {
|
|
26
|
+
const actualBytes = Buffer.from(actual);
|
|
27
|
+
const expectedBytes = Buffer.from(expected);
|
|
28
|
+
return actualBytes.length === expectedBytes.length && crypto.timingSafeEqual(actualBytes, expectedBytes);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function validTaskRequest(taskId: unknown, generation: unknown, afterSequence?: unknown): boolean { return typeof taskId === "string" && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(taskId) && taskId.length <= MAX_TASK_ID_LENGTH && Number.isInteger(generation) && (generation as number) >= 1 && (afterSequence === undefined || (Number.isInteger(afterSequence) && (afterSequence as number) >= 0 && (afterSequence as number) <= MAX_AFTER_SEQUENCE)); }
|
|
32
|
+
|
|
33
|
+
function parseRequest(frame: string): SnapshotRequest | null {
|
|
34
|
+
try {
|
|
35
|
+
const value = JSON.parse(frame) as Partial<SnapshotRequest>;
|
|
36
|
+
if (value.type !== "snapshot" || typeof value.token !== "string") return null;
|
|
37
|
+
return { type: "snapshot", token: value.token };
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class MonitorSocketServer {
|
|
44
|
+
private readonly registration: MonitorRegistration;
|
|
45
|
+
private readonly server: net.Server;
|
|
46
|
+
private connections = 0;
|
|
47
|
+
private eventWaiters = 0;
|
|
48
|
+
private readonly sockets = new Set<net.Socket>();
|
|
49
|
+
|
|
50
|
+
constructor(registration: MonitorRegistration) {
|
|
51
|
+
this.registration = registration;
|
|
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) => {
|
|
57
|
+
if (this.connections >= MAX_SOCKET_CONNECTIONS) { socket.destroy(); return; }
|
|
58
|
+
this.connections += 1;
|
|
59
|
+
this.sockets.add(socket);
|
|
60
|
+
socket.once("close", () => { this.connections -= 1; this.sockets.delete(socket); });
|
|
61
|
+
this.handle(socket);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private assertOwnedSocketPath(): void {
|
|
66
|
+
if (!this.registration.socketDir || path.resolve(this.registration.socketPath) !== path.join(path.resolve(this.registration.socketDir), "s")) throw new Error("monitor socket path is not registry-owned");
|
|
67
|
+
if (fs.lstatSync(this.registration.socketDir).isSymbolicLink() || (fs.statSync(this.registration.socketDir).mode & 0o777) !== 0o700) throw new Error("monitor socket directory is unsafe");
|
|
68
|
+
}
|
|
69
|
+
private async removeVerifiedStaleSocket(): Promise<void> {
|
|
70
|
+
this.assertOwnedSocketPath(); if (!fs.existsSync(this.registration.socketPath)) return;
|
|
71
|
+
const active=await new Promise<boolean>(resolve=>{const probe=net.createConnection(this.registration.socketPath);probe.once("connect",()=>{probe.destroy();resolve(true);});probe.once("error",()=>resolve(false));});
|
|
72
|
+
if (active) throw new Error("monitor socket is already active");
|
|
73
|
+
if (fs.lstatSync(this.registration.socketPath).isSymbolicLink()) throw new Error("monitor socket must not be a symlink"); fs.unlinkSync(this.registration.socketPath);
|
|
74
|
+
}
|
|
75
|
+
async listen(): Promise<void> {
|
|
76
|
+
await this.removeVerifiedStaleSocket(); return new Promise((resolve, reject) => { this.server.once("error", reject); this.server.listen(this.registration.socketPath, () => { this.server.off("error", reject); fs.chmodSync(this.registration.socketPath, 0o600); resolve(); }); });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async close(): Promise<void> {
|
|
80
|
+
for (const socket of this.sockets) socket.destroy();
|
|
81
|
+
await new Promise<void>((resolve, reject) => this.server.close((error) => error ? reject(error) : resolve()));
|
|
82
|
+
this.assertOwnedSocketPath(); try { fs.unlinkSync(this.registration.socketPath); } catch (error: any) { if (error?.code !== "ENOENT") throw error; }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
mode(): number {
|
|
86
|
+
return fs.statSync(this.registration.socketPath).mode & 0o777;
|
|
87
|
+
}
|
|
88
|
+
|
|
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", () => {});
|
|
93
|
+
let buffer = "";
|
|
94
|
+
let handled = false;
|
|
95
|
+
const deadline = setTimeout(() => { if (!handled) socket.destroy(); }, PARTIAL_FRAME_TIMEOUT_MS);
|
|
96
|
+
socket.on("data", (chunk) => {
|
|
97
|
+
if (handled) return;
|
|
98
|
+
buffer += chunk.toString("utf8");
|
|
99
|
+
if (Buffer.byteLength(buffer, "utf8") > MAX_SOCKET_FRAME_BYTES) {
|
|
100
|
+
socket.destroy();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const newline = buffer.indexOf("\n");
|
|
104
|
+
if (newline < 0) return;
|
|
105
|
+
handled = true;
|
|
106
|
+
const request = parseRequest(buffer.slice(0, newline));
|
|
107
|
+
clearTimeout(deadline);
|
|
108
|
+
let value: { type?: string; token?: string; taskId?: string; generation?: number };
|
|
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
|
+
}
|
|
142
|
+
if (value.type === "output") {
|
|
143
|
+
if (!authorized(String(value.token ?? ""), this.registration.token)) { socket.end(JSON.stringify({ ok: false, error: "unauthorized" }) + "\n"); return; }
|
|
144
|
+
if (!this.registration.output || (value as any).afterSequence === undefined || !validTaskRequest(value.taskId, value.generation, (value as any).afterSequence)) { socket.destroy(); return; }
|
|
145
|
+
Promise.resolve().then(()=>this.registration.output!({ taskId: value.taskId!, generation: value.generation!, afterSequence: (value as any).afterSequence })).then((output) => { const body=JSON.stringify({ ok:true, output }); if(Buffer.byteLength(body)>MAX_OUTPUT_RESPONSE_BYTES) socket.end(JSON.stringify({ok:false,error:"response_too_large"})+"\n"); else socket.end(body+"\n"); }).catch(()=>socket.end(JSON.stringify({ok:false,error:"monitor_unavailable"})+"\n")); return;
|
|
146
|
+
}
|
|
147
|
+
if (value.type === "cancel") {
|
|
148
|
+
if (!authorized(String(value.token ?? ""), this.registration.token)) { socket.end(JSON.stringify({ ok: false, error: "unauthorized" }) + "\n"); return; }
|
|
149
|
+
if (!this.registration.cancel || !validTaskRequest(value.taskId, value.generation)) { socket.destroy(); return; }
|
|
150
|
+
Promise.resolve().then(()=>this.registration.cancel!({ taskId: value.taskId!, generation: value.generation! })).then((result) => { const body=JSON.stringify({ ok: true, result }); if (Buffer.byteLength(body, "utf8") > MAX_CANCEL_RESPONSE_BYTES) socket.end(JSON.stringify({ok:false,error:"response_too_large"})+"\n"); else socket.end(body + "\n"); }).catch(()=>socket.end(JSON.stringify({ok:false,error:"monitor_unavailable"})+"\n")); return;
|
|
151
|
+
}
|
|
152
|
+
if (!request || !authorized(request.token, this.registration.token)) {
|
|
153
|
+
if (request) socket.end(JSON.stringify({ ok: false, error: "unauthorized" }) + "\n");
|
|
154
|
+
else socket.destroy();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
try { const response = JSON.stringify({ ok: true, snapshot: this.registration.snapshot() }); if (Buffer.byteLength(response, "utf8") > MAX_SNAPSHOT_BYTES) socket.end(JSON.stringify({ok:false,error:"response_too_large"})+"\n"); else socket.end(response + "\n"); } catch { socket.end(JSON.stringify({ok:false,error:"monitor_unavailable"})+"\n"); }
|
|
158
|
+
});
|
|
159
|
+
socket.on("end", () => {
|
|
160
|
+
if (!handled) socket.destroy();
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createChildTask, createParentTask, type CreateChildTaskInput, type CreateParentTaskInput, type MonitorTask } from "./hermes-monitor-model.ts";
|
|
2
|
+
export const MAX_OUTPUT_BYTES=256*1024;
|
|
3
|
+
export const MONITOR_RETENTION_MS=7*24*60*60*1000;
|
|
4
|
+
export const MONITOR_RETENTION_MAX=200;
|
|
5
|
+
const terminal=new Set(["completed","blocked","failed","cancelled","orphaned","done"]);
|
|
6
|
+
const active=(state:string)=>state==="starting"||state==="running"||state==="cancelling"||state==="recovering";
|
|
7
|
+
export function pruneMonitorTasks<T extends {state:string;updatedAt?:string}>(options:{now:Date;tasks:T[]}):T[]{const cutoff=options.now.getTime()-MONITOR_RETENTION_MS;const running=options.tasks.filter(t=>active(t.state));const terminalTasks=options.tasks.filter(t=>!active(t.state)&&(!t.updatedAt||new Date(t.updatedAt).getTime()>=cutoff)).sort((a,b)=>new Date(a.updatedAt??0).getTime()-new Date(b.updatedAt??0).getTime()).slice(-MONITOR_RETENTION_MAX);return [...running,...terminalTasks];}
|
|
8
|
+
export interface MonitorOutput{text:string;sequence:number;firstSequence:number;truncated:boolean}
|
|
9
|
+
interface StoredOutput{chunks:{sequence:number;text:string}[];sequence:number;truncated:boolean}
|
|
10
|
+
interface StoredTask{task:MonitorTask;output:StoredOutput;createdAt:string;updatedAt:string}
|
|
11
|
+
function suffix(text:string,limit:number){let bytes=0;const chars:string[]=[];for(const char of Array.from(text).reverse()){const size=Buffer.byteLength(char);if(bytes+size>limit)break;chars.push(char);bytes+=size;}return chars.reverse().join("");}
|
|
12
|
+
|
|
13
|
+
export class MonitorStore {
|
|
14
|
+
private readonly tasks=new Map<string,StoredTask>(); private readonly now:()=>Date;
|
|
15
|
+
constructor(options:{now?:()=>Date}={}){this.now=options.now??(()=>new Date());}
|
|
16
|
+
private key(id:string,generation:number){return `${id}:${generation}`;} private stamp(){return this.now().toISOString();}
|
|
17
|
+
createParent(input:CreateParentTaskInput){return this.add(createParentTask(input));}
|
|
18
|
+
createChild(input:CreateChildTaskInput){if(![...this.tasks.values()].some(s=>s.task.id===input.parentId&&s.task.generation===input.parentGeneration&&s.task.kind==="parent"))throw new Error(`parent task ${input.parentId} was not found`);return this.add(createChildTask(input));}
|
|
19
|
+
patch(id:string,generation:number,values:any){const stored=this.require(id,generation);Object.assign(stored.task,values);stored.updatedAt=this.stamp();return stored.task;}
|
|
20
|
+
transition(id:string,generation:number,state:any){const stored=this.require(id,generation);if(terminal.has(stored.task.state))throw new Error("terminal transition");stored.task.state=state;stored.updatedAt=this.stamp();return stored.task;}
|
|
21
|
+
get(id:string,generation?:number){return generation===undefined?[...this.tasks.values()].find(s=>s.task.id===id)?.task:this.tasks.get(this.key(id,generation))?.task;}
|
|
22
|
+
appendPublicOutput(id:string,generation:number,text:string){const stored=this.require(id,generation);if(terminal.has(stored.task.state))throw new Error("terminal output");const sequence=stored.output.sequence+1, chunk=suffix(text,MAX_OUTPUT_BYTES),chunks=[...stored.output.chunks,{sequence,text:chunk}];let bytes=chunks.reduce((n,c)=>n+Buffer.byteLength(c.text),0),truncated=stored.output.truncated||bytes<Buffer.byteLength(text);while(bytes>MAX_OUTPUT_BYTES&&chunks.length>1){bytes-=Buffer.byteLength(chunks.shift()!.text);truncated=true;}stored.output={chunks,sequence,truncated};stored.updatedAt=this.stamp();return this.outputAfter(stored.output,0);}
|
|
23
|
+
readOutput(id:string,generation:number,afterSequence:number){return this.outputAfter(this.require(id,generation).output,afterSequence);}
|
|
24
|
+
snapshot(){return {tasks:[...this.tasks.values()].map(s=>this.publicTask(s))};} durableSnapshot(){return{tasks:[...this.tasks.values()].map(s=>({...this.publicTask(s),outputChunks:s.output.chunks.map(c=>({...c}),),outputLatestSequence:s.output.sequence,outputFirstSequence:s.output.chunks[0]?.sequence??0,outputTruncated:s.output.truncated}))};} restore(rows:any[]){for(const row of rows){const key=this.key(row.id,row.generation);if(this.tasks.has(key))continue;const output=row.output??"";this.tasks.set(key,{task:{...row},output:{chunks:Array.isArray(row.outputChunks)?row.outputChunks.map((c:any)=>({sequence:c.sequence,text:c.text})):output?[{sequence:row.outputSequence??1,text:output}]:[],sequence:row.outputLatestSequence??row.outputSequence??0,truncated:row.outputTruncated??!!row.truncated},createdAt:row.createdAt??this.stamp(),updatedAt:row.updatedAt??this.stamp()});}}
|
|
25
|
+
prune(now=this.now()){const cutoff=now.getTime()-MONITOR_RETENTION_MS;const values=[...this.tasks.values()];const protectedIds=new Set<string>();for(const s of values)if(active(s.task.state)){protectedIds.add(this.key(s.task.id,s.task.generation));if(s.task.parentId)for(const p of values)if(p.task.id===s.task.parentId)protectedIds.add(this.key(p.task.id,p.task.generation));for(const c of values)if(c.task.parentId===s.task.id)protectedIds.add(this.key(c.task.id,c.task.generation));}const candidates=values.filter(s=>!active(s.task.state)&&!protectedIds.has(this.key(s.task.id,s.task.generation))).sort((a,b)=>Date.parse(a.updatedAt)-Date.parse(b.updatedAt));const expired=candidates.filter(s=>Date.parse(s.updatedAt)<cutoff);for(const s of expired)this.tasks.delete(this.key(s.task.id,s.task.generation));const remaining=[...this.tasks.values()].filter(s=>!active(s.task.state)&&!protectedIds.has(this.key(s.task.id,s.task.generation))).sort((a,b)=>Date.parse(a.updatedAt)-Date.parse(b.updatedAt));while(remaining.length>MONITOR_RETENTION_MAX){const oldest=remaining.shift()!;this.tasks.delete(this.key(oldest.task.id,oldest.task.generation));}return this.snapshot();}
|
|
26
|
+
private add(task:MonitorTask){const key=this.key(task.id,task.generation);if(this.tasks.has(key))throw new Error(`task ${task.id} generation ${task.generation} already exists`);const stamp=this.stamp();this.tasks.set(key,{task,output:{chunks:[],sequence:0,truncated:false},createdAt:stamp,updatedAt:stamp});return task;}
|
|
27
|
+
private publicTask(s:StoredTask){const output=this.outputAfter(s.output,0);return {...s.task,createdAt:s.createdAt,updatedAt:s.updatedAt,outputSequence:output.sequence,firstSequence:output.firstSequence,truncated:output.truncated};}
|
|
28
|
+
private outputAfter(output:StoredOutput,after:number):MonitorOutput{return{text:output.chunks.filter(c=>c.sequence>after).map(c=>c.text).join(""),sequence:output.sequence,firstSequence:output.chunks[0]?.sequence??0,truncated:output.truncated};}
|
|
29
|
+
private require(id:string,generation:number){const stored=this.tasks.get(this.key(id,generation));if(!stored)throw new Error(`task ${id} generation ${generation} was not found`);return stored;}
|
|
30
|
+
}
|
|
31
|
+
export function createMonitorStore(options:{now:()=>Date}){const store=new MonitorStore(options);const baseSnapshot=store.snapshot.bind(store);return Object.assign(store,{snapshot(){const all=(baseSnapshot() as any).tasks;return{tasks:all.filter((t:any)=>t.kind==='parent').map((parent:any)=>({id:parent.id,generation:parent.generation,children:all.filter((child:any)=>child.parentId===parent.id).map((child:any)=>({id:child.id,generation:child.generation,state:child.state,workspaceId:child.workspaceId,hubPaneId:child.hubPaneId,outputSequence:child.outputSequence,updatedAt:child.updatedAt}))}))};}});}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// Spawned coms peers: pane launch, readiness policy and the never-addressed sweep.
|
|
2
|
+
//
|
|
3
|
+
// Lives in the SHARED harness lib, not under agent-hub: `just fleet peer`
|
|
4
|
+
// (scripts/peer-launch.ts) launches a single peer with the same pane plumbing
|
|
5
|
+
// and the same readiness timings, and the fleet scripts are installed into
|
|
6
|
+
// target projects that may not have selected the agent-hub harness at all.
|
|
7
|
+
//
|
|
8
|
+
// Root cause this encodes: `herdr_spawn_peer` launches a REUSABLE coms peer —
|
|
9
|
+
// it boots idle and waits for a `coms_send`. Spawning it delivers no work. One
|
|
10
|
+
// session spawned `repair-builder` and `final-test-worker`, sent all twelve of
|
|
11
|
+
// its messages to a third peer, and left two empty panes named like workers.
|
|
12
|
+
// The spawns were a sound reaction to a broken session; nothing told the
|
|
13
|
+
// dispatcher when the peers became addressable, and nothing noticed they never
|
|
14
|
+
// were addressed.
|
|
15
|
+
//
|
|
16
|
+
// Two answers: the spawn returns a readiness verdict instead of a bare pane id,
|
|
17
|
+
// and an unaddressed hub-spawned peer is named at the end of the session.
|
|
18
|
+
|
|
19
|
+
// Second root cause this encodes: herdr's `pane.split` takes NO command — a
|
|
20
|
+
// split always opens a plain interactive shell in `cwd`. The hub used to pass
|
|
21
|
+
// `command: argv` to it; herdr silently ignores unknown params, so every
|
|
22
|
+
// "spawned peer" was an empty shell pane with the right label, the tool
|
|
23
|
+
// reported success, and the peer never existed. `just fleet team` was
|
|
24
|
+
// unaffected because it launches through `layout.apply`, whose pane nodes DO
|
|
25
|
+
// carry an argv. A hub spawn is therefore three steps: split, wait for the
|
|
26
|
+
// pane's shell prompt, then type the command line.
|
|
27
|
+
|
|
28
|
+
/** Longest we wait for a spawned peer to register in the coms pool. */
|
|
29
|
+
export const PEER_READY_TIMEOUT_MS = 45_000;
|
|
30
|
+
|
|
31
|
+
/** Longest we wait for a freshly split pane to reach its shell prompt. */
|
|
32
|
+
export const PANE_PROMPT_TIMEOUT_MS = 10_000;
|
|
33
|
+
|
|
34
|
+
/** Poll interval while watching a new pane for its shell prompt, in ms. */
|
|
35
|
+
export const PANE_PROMPT_POLL_MS = 250;
|
|
36
|
+
|
|
37
|
+
/** Shell metacharacter-free values pass through unquoted; everything else is quoted. */
|
|
38
|
+
const BARE_ARG = /^[A-Za-z0-9._/,:=@%+-]+$/;
|
|
39
|
+
|
|
40
|
+
function shellQuote(arg) {
|
|
41
|
+
const s = String(arg ?? "");
|
|
42
|
+
if (s === "") return "''"; // positional placeholders must survive as empty args
|
|
43
|
+
if (BARE_ARG.test(s)) return s;
|
|
44
|
+
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* An argv (as built by peerCommand) turned into one line of shell input,
|
|
49
|
+
* newline included. Quoting matters for the empty positional placeholders the
|
|
50
|
+
* `just` recipes use to keep later positionals aligned — unquoted they would
|
|
51
|
+
* vanish and shift `--project` into the model slot.
|
|
52
|
+
*/
|
|
53
|
+
export function paneLaunchLine(argv) {
|
|
54
|
+
if (!Array.isArray(argv) || argv.length === 0) {
|
|
55
|
+
throw new Error("paneLaunchLine: empty argv");
|
|
56
|
+
}
|
|
57
|
+
return `${argv.map(shellQuote).join(" ")}\n`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Does this pane read end at an interactive shell prompt? Typing before the
|
|
62
|
+
* shell is up can drop the line, and herdr's own `agent.start` refuses a pane
|
|
63
|
+
* that is not at a prompt, so the spawn waits for one. Best-effort by design:
|
|
64
|
+
* the caller sends anyway once PANE_PROMPT_TIMEOUT_MS is spent.
|
|
65
|
+
*/
|
|
66
|
+
export function looksLikeShellPrompt(text) {
|
|
67
|
+
if (typeof text !== "string") return false;
|
|
68
|
+
const lines = text.replace(/\r/g, "").split("\n");
|
|
69
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") lines.pop();
|
|
70
|
+
if (lines.length === 0) return false;
|
|
71
|
+
return /[$#%>❯➜›]\s*$/.test(lines[lines.length - 1]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Launch an argv in a freshly split pane by typing it at the pane's shell.
|
|
76
|
+
* `client` is the herdr client (paneRead/paneSendText/paneSendKeys).
|
|
77
|
+
*
|
|
78
|
+
* Text and Enter go as separate calls on purpose: bash enables bracketed
|
|
79
|
+
* paste, where a newline inside sent text is inserted into the line editor
|
|
80
|
+
* instead of executing it. A pane that never shows a prompt still gets the
|
|
81
|
+
* command — the shell's input queue survives a slow banner — but the caller
|
|
82
|
+
* is told, because that is also what a pane whose shell died looks like.
|
|
83
|
+
*/
|
|
84
|
+
export async function launchPeerInPane(client, paneId, argv, opts = {}) {
|
|
85
|
+
const {
|
|
86
|
+
timeoutMs = PANE_PROMPT_TIMEOUT_MS,
|
|
87
|
+
pollMs = PANE_PROMPT_POLL_MS,
|
|
88
|
+
now = Date.now,
|
|
89
|
+
sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
90
|
+
} = opts;
|
|
91
|
+
const line = paneLaunchLine(argv).replace(/\n$/, "");
|
|
92
|
+
const started = now();
|
|
93
|
+
let promptSeen = false;
|
|
94
|
+
for (;;) {
|
|
95
|
+
try {
|
|
96
|
+
const { read } = await client.paneRead({ pane_id: paneId, lines: 5 });
|
|
97
|
+
if (looksLikeShellPrompt(read?.text ?? "")) {
|
|
98
|
+
promptSeen = true;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
} catch {
|
|
102
|
+
// Pane not readable yet; the timeout below bounds the wait.
|
|
103
|
+
}
|
|
104
|
+
if (now() - started >= timeoutMs) break;
|
|
105
|
+
await sleep(pollMs);
|
|
106
|
+
}
|
|
107
|
+
await client.paneSendText(paneId, line);
|
|
108
|
+
await client.paneSendKeys(paneId, ["enter"]);
|
|
109
|
+
return { promptSeen, waitedMs: now() - started };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Seconds a hub-spawned pi peer should sleep before launching (the justfile
|
|
114
|
+
* recipes honor it as AGENT_FLEET_SPAWN_DELAY). Same stale-OAuth lock race
|
|
115
|
+
* that staggers team spawns: the first peer refreshes the token, so only a
|
|
116
|
+
* sibling spawned inside the warm-up window has to wait. `needed` is
|
|
117
|
+
* oauthNeedsWarmup() re-read at each spawn — once the warmer lands a fresh
|
|
118
|
+
* token it goes false and nobody waits.
|
|
119
|
+
*/
|
|
120
|
+
export function spawnStaggerSeconds({ needed, lastSpawnAt, now, warmupSeconds }) {
|
|
121
|
+
if (!needed || !Number.isFinite(warmupSeconds) || warmupSeconds <= 0) return 0;
|
|
122
|
+
if (typeof lastSpawnAt !== "number" || !Number.isFinite(lastSpawnAt)) return 0;
|
|
123
|
+
if (now - lastSpawnAt >= warmupSeconds * 1000) return 0;
|
|
124
|
+
return warmupSeconds;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Poll backoff while waiting for registration, in ms; the last step repeats. */
|
|
128
|
+
export const PEER_READY_BACKOFF_MS = [250, 500, 1_000, 2_000, 3_000];
|
|
129
|
+
|
|
130
|
+
/** Backoff delay for the nth readiness poll (0-based); the last step repeats. */
|
|
131
|
+
export function peerReadyDelayMs(attempt) {
|
|
132
|
+
const i = Math.max(0, Math.min(Math.floor(attempt) || 0, PEER_READY_BACKOFF_MS.length - 1));
|
|
133
|
+
return PEER_READY_BACKOFF_MS[i];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The verdict a spawn reports back. `ready` means the peer is in the pool and
|
|
138
|
+
* `coms_send` will reach it; otherwise it is still booting and the caller is
|
|
139
|
+
* told how long we waited rather than being left to guess.
|
|
140
|
+
*/
|
|
141
|
+
export function peerReadyVerdict({ name, paneId, found, waitedMs, timeoutMs = PEER_READY_TIMEOUT_MS, paneTail }) {
|
|
142
|
+
if (found) {
|
|
143
|
+
return {
|
|
144
|
+
peer_ready: true,
|
|
145
|
+
peer_name: name,
|
|
146
|
+
pane_id: paneId,
|
|
147
|
+
waited_ms: waitedMs,
|
|
148
|
+
message:
|
|
149
|
+
`Peer "${name}" is ready in pane ${paneId} after ${Math.round(waitedMs / 1000)}s — ` +
|
|
150
|
+
`address it with coms_send(target: "${name}", ...). It boots idle and does no work until you send.`,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// A peer that missed the window is usually dead, not slow, so the verdict
|
|
154
|
+
// carries the pane's own last words instead of sending the caller off to
|
|
155
|
+
// run herdr_read_pane to find out.
|
|
156
|
+
const tail = typeof paneTail === "string" ? paneTail.trim() : "";
|
|
157
|
+
return {
|
|
158
|
+
peer_ready: false,
|
|
159
|
+
peer_name: name,
|
|
160
|
+
pane_id: paneId,
|
|
161
|
+
waited_ms: waitedMs,
|
|
162
|
+
pane_tail: tail || null,
|
|
163
|
+
message:
|
|
164
|
+
`Peer "${name}" did not register in the coms pool within ${Math.round(timeoutMs / 1000)}s — ` +
|
|
165
|
+
`assume it failed to start rather than that it is slow. Do not coms_send to it. ` +
|
|
166
|
+
`Check coms_list; if it never appears, close the pane with herdr_close_pane.` +
|
|
167
|
+
(tail ? `\n\nLast output of pane ${paneId}:\n${tail}` : ""),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Sweep report for peers this hub spawned. `entries` carry
|
|
173
|
+
* { name, paneId, addressed } — `addressed` is true once any coms_send targeted
|
|
174
|
+
* that peer. Returns null when every spawned peer got work (the common case).
|
|
175
|
+
*/
|
|
176
|
+
export function unaddressedPeerSweep(entries) {
|
|
177
|
+
const idle = (Array.isArray(entries) ? entries : []).filter((e) => e && !e.addressed);
|
|
178
|
+
if (idle.length === 0) return null;
|
|
179
|
+
const rows = idle.map((e) => ` ${e.name} (pane ${e.paneId ?? "?"}) — spawned, never sent to`);
|
|
180
|
+
return {
|
|
181
|
+
count: idle.length,
|
|
182
|
+
peers: idle.map((e) => ({ name: e.name, pane_id: e.paneId ?? null })),
|
|
183
|
+
message: [
|
|
184
|
+
`⚠ ${idle.length} hub-spawned peer(s) never received a message:`,
|
|
185
|
+
...rows,
|
|
186
|
+
"A spawned peer boots idle and waits — it is holding a pane and a model session for nothing.",
|
|
187
|
+
`Close them with herdr_close_pane (asks for your confirmation) or send them work.`,
|
|
188
|
+
].join("\n"),
|
|
189
|
+
};
|
|
190
|
+
}
|