harnery 0.36.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commander.d.ts +9 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +10 -1
- package/dist/commands/admission.d.ts +21 -0
- package/dist/commands/admission.d.ts.map +1 -0
- package/dist/commands/admission.js +565 -0
- package/dist/commands/agents.d.ts +7 -0
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +148 -47
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +73 -2
- package/dist/commands/browse-ai.d.ts +2 -2
- package/dist/commands/browse-ai.d.ts.map +1 -1
- package/dist/commands/browse-ai.js +6 -4
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +360 -21
- package/dist/commands/diagnostics.d.ts +4 -0
- package/dist/commands/diagnostics.d.ts.map +1 -0
- package/dist/commands/diagnostics.js +229 -0
- package/dist/commands/fetch.js +1 -0
- package/dist/commands/files.d.ts +12 -0
- package/dist/commands/files.d.ts.map +1 -1
- package/dist/commands/files.js +54 -1
- package/dist/commands/governor.d.ts.map +1 -1
- package/dist/commands/governor.js +4 -0
- package/dist/commands/ledger-v3.d.ts.map +1 -1
- package/dist/commands/ledger-v3.js +71 -2
- package/dist/commands/qa-record.d.ts +144 -0
- package/dist/commands/qa-record.d.ts.map +1 -0
- package/dist/commands/qa-record.js +0 -0
- package/dist/commands/qa-run.d.ts +8 -0
- package/dist/commands/qa-run.d.ts.map +1 -0
- package/dist/commands/qa-run.js +396 -0
- package/dist/commands/qa-status.d.ts +71 -0
- package/dist/commands/qa-status.d.ts.map +1 -0
- package/dist/commands/qa-status.js +490 -0
- package/dist/commands/qa-verify.d.ts +40 -0
- package/dist/commands/qa-verify.d.ts.map +1 -0
- package/dist/commands/qa-verify.js +180 -0
- package/dist/commands/resources.d.ts +4 -0
- package/dist/commands/resources.d.ts.map +1 -0
- package/dist/commands/resources.js +29 -0
- package/dist/commands/review-pack.d.ts +4 -0
- package/dist/commands/review-pack.d.ts.map +1 -0
- package/dist/commands/review-pack.js +1001 -0
- package/dist/commands/supervisor.d.ts +4 -0
- package/dist/commands/supervisor.d.ts.map +1 -0
- package/dist/commands/supervisor.js +101 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +17 -0
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +4 -0
- package/dist/core/agents/cli.js +7 -3
- package/dist/core/agents/health.d.ts +17 -0
- package/dist/core/agents/health.d.ts.map +1 -0
- package/dist/core/agents/health.js +109 -0
- package/dist/core/agents/mailbox.d.ts +92 -0
- package/dist/core/agents/mailbox.d.ts.map +1 -0
- package/dist/core/agents/mailbox.js +325 -0
- package/dist/core/agents/qa-signal.d.ts +111 -0
- package/dist/core/agents/qa-signal.d.ts.map +1 -0
- package/dist/core/agents/qa-signal.js +231 -0
- package/dist/core/agents/reconcile-coordination-v3.d.ts +44 -0
- package/dist/core/agents/reconcile-coordination-v3.d.ts.map +1 -0
- package/dist/core/agents/reconcile-coordination-v3.js +58 -0
- package/dist/core/agents/render/prompt-context.d.ts +5 -0
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +34 -13
- package/dist/core/agents/render/session-context.d.ts +8 -0
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +34 -3
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/commit-conflict.js +50 -1
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +6 -10
- package/dist/core/agents/session-finalizer-v3.js +4 -1
- package/dist/core/agents/session-name-display.d.ts +20 -5
- package/dist/core/agents/session-name-display.d.ts.map +1 -1
- package/dist/core/agents/session-name-display.js +67 -7
- package/dist/core/agents/state/heartbeat-reader.d.ts +7 -0
- package/dist/core/agents/state/heartbeat-reader.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.d.ts +11 -0
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +17 -0
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.js +1 -0
- package/dist/core/agents/state/live-coordination-writer.js +5 -0
- package/dist/core/artifacts/constants.d.ts +1 -1
- package/dist/core/artifacts/constants.js +1 -1
- package/dist/core/artifacts/index.d.ts +82 -6
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +410 -15
- package/dist/core/config.d.ts +20 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +59 -0
- package/dist/core/diagnostics/advice.d.ts +9 -0
- package/dist/core/diagnostics/advice.d.ts.map +1 -0
- package/dist/core/diagnostics/advice.js +112 -0
- package/dist/core/diagnostics/bundle.d.ts +51 -0
- package/dist/core/diagnostics/bundle.d.ts.map +1 -0
- package/dist/core/diagnostics/bundle.js +968 -0
- package/dist/core/diagnostics/comparison.d.ts +5 -0
- package/dist/core/diagnostics/comparison.d.ts.map +1 -0
- package/dist/core/diagnostics/comparison.js +444 -0
- package/dist/core/diagnostics/contract.d.ts +245 -0
- package/dist/core/diagnostics/contract.d.ts.map +1 -0
- package/dist/core/diagnostics/contract.js +18 -0
- package/dist/core/diagnostics/identity.d.ts +3 -0
- package/dist/core/diagnostics/identity.d.ts.map +1 -0
- package/dist/core/diagnostics/identity.js +10 -0
- package/dist/core/diagnostics/index.d.ts +8 -0
- package/dist/core/diagnostics/index.d.ts.map +1 -0
- package/dist/core/diagnostics/index.js +7 -0
- package/dist/core/diagnostics/replay.d.ts +8 -0
- package/dist/core/diagnostics/replay.d.ts.map +1 -0
- package/dist/core/diagnostics/replay.js +213 -0
- package/dist/core/diagnostics/sanitize.d.ts +9 -0
- package/dist/core/diagnostics/sanitize.d.ts.map +1 -0
- package/dist/core/diagnostics/sanitize.js +84 -0
- package/dist/core/events/legacy-storage/compression.d.ts +13 -0
- package/dist/core/events/legacy-storage/compression.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/compression.js +107 -0
- package/dist/core/events/legacy-storage/index.d.ts +1 -0
- package/dist/core/events/legacy-storage/index.d.ts.map +1 -1
- package/dist/core/events/legacy-storage/index.js +1 -0
- package/dist/core/events/v3/archive-retention.d.ts +33 -0
- package/dist/core/events/v3/archive-retention.d.ts.map +1 -0
- package/dist/core/events/v3/archive-retention.js +195 -0
- package/dist/core/events/v3/bootstrap.d.ts.map +1 -1
- package/dist/core/events/v3/bootstrap.js +10 -0
- package/dist/core/events/v3/capabilities.d.ts +1 -1
- package/dist/core/events/v3/capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/capabilities.js +1 -0
- package/dist/core/events/v3/coordination-view.d.ts +3 -0
- package/dist/core/events/v3/coordination-view.d.ts.map +1 -1
- package/dist/core/events/v3/coordination-view.js +69 -8
- package/dist/core/events/v3/index.d.ts +1 -0
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +1 -0
- package/dist/core/events/v3/live-routing.d.ts.map +1 -1
- package/dist/core/events/v3/live-routing.js +1 -0
- package/dist/core/events/v3/producers/hook-base.d.ts +1 -1
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
- package/dist/core/events/v3/producers/hook-base.js +13 -2
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
- package/dist/core/events/v3/producers/intake.js +10 -2
- package/dist/core/events/v3/producers/recorder.d.ts +39 -0
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +350 -17
- package/dist/core/hooks/adapter/output.d.ts +8 -0
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +11 -1
- package/dist/core/hooks/cli.js +303 -219
- package/dist/core/hooks/health.d.ts +59 -0
- package/dist/core/hooks/health.d.ts.map +1 -0
- package/dist/core/hooks/health.js +84 -0
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +10 -3
- package/dist/core/hooks/session-name-presence.d.ts.map +1 -1
- package/dist/core/hooks/session-name-presence.js +4 -1
- package/dist/core/qa-artifacts.d.ts +20 -0
- package/dist/core/qa-artifacts.d.ts.map +1 -0
- package/dist/core/qa-artifacts.js +110 -0
- package/dist/core/resources/contract.d.ts +96 -0
- package/dist/core/resources/contract.d.ts.map +1 -0
- package/dist/core/resources/contract.js +2 -0
- package/dist/core/resources/index.d.ts +6 -0
- package/dist/core/resources/index.d.ts.map +1 -0
- package/dist/core/resources/index.js +5 -0
- package/dist/core/resources/sampler.d.ts +34 -0
- package/dist/core/resources/sampler.d.ts.map +1 -0
- package/dist/core/resources/sampler.js +458 -0
- package/dist/core/resources/service-status.d.ts +3 -0
- package/dist/core/resources/service-status.d.ts.map +1 -0
- package/dist/core/resources/service-status.js +48 -0
- package/dist/core/resources/service.d.ts +26 -0
- package/dist/core/resources/service.d.ts.map +1 -0
- package/dist/core/resources/service.js +292 -0
- package/dist/core/resources/storage.d.ts +13 -0
- package/dist/core/resources/storage.d.ts.map +1 -0
- package/dist/core/resources/storage.js +30 -0
- package/dist/core/storage/atomic-json.d.ts +3 -0
- package/dist/core/storage/atomic-json.d.ts.map +1 -0
- package/dist/core/storage/atomic-json.js +15 -0
- package/dist/core/storage/builtins.d.ts.map +1 -1
- package/dist/core/storage/builtins.js +45 -6
- package/dist/core/storage/logger.d.ts +2 -0
- package/dist/core/storage/logger.d.ts.map +1 -1
- package/dist/core/storage/logger.js +2 -0
- package/dist/core/storage/query.d.ts +14 -0
- package/dist/core/storage/query.d.ts.map +1 -1
- package/dist/core/storage/query.js +51 -0
- package/dist/core/supervisor/activity.d.ts +4 -0
- package/dist/core/supervisor/activity.d.ts.map +1 -0
- package/dist/core/supervisor/activity.js +141 -0
- package/dist/core/supervisor/contract.d.ts +268 -0
- package/dist/core/supervisor/contract.d.ts.map +1 -0
- package/dist/core/supervisor/contract.js +35 -0
- package/dist/core/supervisor/explanations.d.ts +4 -0
- package/dist/core/supervisor/explanations.d.ts.map +1 -0
- package/dist/core/supervisor/explanations.js +71 -0
- package/dist/core/supervisor/findings.d.ts +20 -0
- package/dist/core/supervisor/findings.d.ts.map +1 -0
- package/dist/core/supervisor/findings.js +399 -0
- package/dist/core/supervisor/history.d.ts +9 -0
- package/dist/core/supervisor/history.d.ts.map +1 -0
- package/dist/core/supervisor/history.js +46 -0
- package/dist/core/supervisor/hook-health-alerts.d.ts +14 -0
- package/dist/core/supervisor/hook-health-alerts.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health-alerts.js +70 -0
- package/dist/core/supervisor/hook-health-storage.d.ts +5 -0
- package/dist/core/supervisor/hook-health-storage.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health-storage.js +24 -0
- package/dist/core/supervisor/hook-health.d.ts +72 -0
- package/dist/core/supervisor/hook-health.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health.js +203 -0
- package/dist/core/supervisor/hooks.d.ts +10 -0
- package/dist/core/supervisor/hooks.d.ts.map +1 -0
- package/dist/core/supervisor/hooks.js +28 -0
- package/dist/core/supervisor/index.d.ts +15 -0
- package/dist/core/supervisor/index.d.ts.map +1 -0
- package/dist/core/supervisor/index.js +14 -0
- package/dist/core/supervisor/log-feed.d.ts +9 -0
- package/dist/core/supervisor/log-feed.d.ts.map +1 -0
- package/dist/core/supervisor/log-feed.js +103 -0
- package/dist/core/supervisor/service.d.ts +29 -0
- package/dist/core/supervisor/service.d.ts.map +1 -0
- package/dist/core/supervisor/service.js +450 -0
- package/dist/core/supervisor/services.d.ts +11 -0
- package/dist/core/supervisor/services.d.ts.map +1 -0
- package/dist/core/supervisor/services.js +155 -0
- package/dist/core/supervisor/status.d.ts +3 -0
- package/dist/core/supervisor/status.d.ts.map +1 -0
- package/dist/core/supervisor/status.js +48 -0
- package/dist/core/supervisor/storage.d.ts +30 -0
- package/dist/core/supervisor/storage.d.ts.map +1 -0
- package/dist/core/supervisor/storage.js +73 -0
- package/dist/core/supervisor/timeline.d.ts +3 -0
- package/dist/core/supervisor/timeline.d.ts.map +1 -0
- package/dist/core/supervisor/timeline.js +87 -0
- package/dist/core/workflow/admission.d.ts +23 -0
- package/dist/core/workflow/admission.d.ts.map +1 -0
- package/dist/core/workflow/admission.js +136 -0
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +77 -2
- package/dist/core/workflow/index.d.ts +3 -2
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +2 -1
- package/dist/core/workflow/proof.d.ts +2 -1
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +39 -1
- package/dist/core/workflow/run-state.d.ts +3 -2
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +8 -1
- package/dist/core/workflow/types.d.ts +33 -1
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/types.js +2 -1
- package/dist/lib/admission.d.ts +71 -0
- package/dist/lib/admission.d.ts.map +1 -0
- package/dist/lib/admission.js +264 -0
- package/dist/lib/agent-browser/client.d.ts +1 -1
- package/dist/lib/agent-browser/client.d.ts.map +1 -1
- package/dist/lib/agent-browser/client.js +1 -5
- package/dist/lib/browser/capture-fidelity.d.ts +39 -0
- package/dist/lib/browser/capture-fidelity.d.ts.map +1 -0
- package/dist/lib/browser/capture-fidelity.js +84 -0
- package/dist/lib/browser/client.d.ts +46 -1
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +168 -9
- package/dist/lib/browser/critique.d.ts +38 -1
- package/dist/lib/browser/critique.d.ts.map +1 -1
- package/dist/lib/browser/critique.js +34 -6
- package/dist/lib/browser/index.d.ts +5 -1
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +4 -0
- package/dist/lib/browser/page-review-judge.d.ts +64 -0
- package/dist/lib/browser/page-review-judge.d.ts.map +1 -0
- package/dist/lib/browser/page-review-judge.js +270 -0
- package/dist/lib/browser/page-review-pack.d.ts +613 -0
- package/dist/lib/browser/page-review-pack.d.ts.map +1 -0
- package/dist/lib/browser/page-review-pack.js +1751 -0
- package/dist/lib/browser/qa-run-contracts.d.ts +377 -0
- package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -0
- package/dist/lib/browser/qa-run-contracts.js +361 -0
- package/dist/lib/browser/qa-run.d.ts +141 -0
- package/dist/lib/browser/qa-run.d.ts.map +1 -0
- package/dist/lib/browser/qa-run.js +1283 -0
- package/dist/lib/browser/request-diagnostics.d.ts +13 -0
- package/dist/lib/browser/request-diagnostics.d.ts.map +1 -0
- package/dist/lib/browser/request-diagnostics.js +18 -0
- package/dist/lib/browser/tiling.d.ts +19 -0
- package/dist/lib/browser/tiling.d.ts.map +1 -1
- package/dist/lib/browser/tiling.js +28 -0
- package/dist/lib/cookies/client.d.ts +9 -0
- package/dist/lib/cookies/client.d.ts.map +1 -1
- package/dist/lib/cookies/client.js +197 -44
- package/dist/lib/cookies/extra.d.ts +18 -0
- package/dist/lib/cookies/extra.d.ts.map +1 -0
- package/dist/lib/cookies/extra.js +14 -0
- package/dist/lib/cookies/index.d.ts +2 -1
- package/dist/lib/cookies/index.d.ts.map +1 -1
- package/dist/lib/cookies/index.js +2 -1
- package/dist/lib/coord-root-id.d.ts +9 -0
- package/dist/lib/coord-root-id.d.ts.map +1 -0
- package/dist/lib/coord-root-id.js +17 -0
- package/dist/lib/durable-job.d.ts +124 -0
- package/dist/lib/durable-job.d.ts.map +1 -0
- package/dist/lib/durable-job.js +296 -0
- package/dist/lib/http/client.d.ts +7 -1
- package/dist/lib/http/client.d.ts.map +1 -1
- package/dist/lib/http/client.js +2 -0
- package/dist/lib/instructions/apply.d.ts +3 -1
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +74 -3
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +11 -2
- package/package.json +19 -2
- package/src/commander.ts +75 -1
- package/src/commands/admission.ts +699 -0
- package/src/commands/agents.ts +189 -50
- package/src/commands/artifacts.ts +132 -18
- package/src/commands/browse-ai.ts +10 -5
- package/src/commands/browse.ts +496 -20
- package/src/commands/diagnostics.ts +271 -0
- package/src/commands/fetch.ts +1 -0
- package/src/commands/files.ts +102 -2
- package/src/commands/governor.ts +8 -0
- package/src/commands/ledger-v3.ts +82 -0
- package/src/commands/qa-record.ts +682 -0
- package/src/commands/qa-run.ts +503 -0
- package/src/commands/qa-status.ts +608 -0
- package/src/commands/qa-verify.ts +238 -0
- package/src/commands/resources.ts +38 -0
- package/src/commands/review-pack.ts +1281 -0
- package/src/commands/supervisor.ts +141 -0
- package/src/commands/web.ts +19 -0
- package/src/commands/workflow.ts +8 -0
- package/src/core/agents/cli.ts +7 -3
- package/src/core/agents/health.ts +142 -0
- package/src/core/agents/mailbox.ts +373 -0
- package/src/core/agents/qa-signal.ts +261 -0
- package/src/core/agents/reconcile-coordination-v3.ts +77 -0
- package/src/core/agents/render/prompt-context.ts +42 -12
- package/src/core/agents/render/session-context.ts +37 -3
- package/src/core/agents/rules/commit-conflict.ts +58 -1
- package/src/core/agents/rules/stop-hook.ts +6 -12
- package/src/core/agents/session-finalizer-v3.ts +4 -1
- package/src/core/agents/session-name-display.ts +78 -7
- package/src/core/agents/state/heartbeat-reader.ts +7 -0
- package/src/core/agents/state/heartbeat-writer.ts +23 -0
- package/src/core/agents/state/live-coordination-view.ts +1 -0
- package/src/core/agents/state/live-coordination-writer.ts +5 -0
- package/src/core/artifacts/constants.ts +1 -1
- package/src/core/artifacts/index.ts +565 -30
- package/src/core/config.ts +134 -2
- package/src/core/diagnostics/advice.ts +147 -0
- package/src/core/diagnostics/bundle.ts +1250 -0
- package/src/core/diagnostics/comparison.ts +565 -0
- package/src/core/diagnostics/contract.ts +311 -0
- package/src/core/diagnostics/identity.ts +11 -0
- package/src/core/diagnostics/index.ts +7 -0
- package/src/core/diagnostics/replay.ts +314 -0
- package/src/core/diagnostics/sanitize.ts +97 -0
- package/src/core/events/legacy-storage/compression.ts +130 -0
- package/src/core/events/legacy-storage/index.ts +1 -0
- package/src/core/events/v3/archive-retention.ts +251 -0
- package/src/core/events/v3/bootstrap.ts +10 -0
- package/src/core/events/v3/capabilities.ts +2 -0
- package/src/core/events/v3/coordination-view.ts +100 -11
- package/src/core/events/v3/index.ts +9 -0
- package/src/core/events/v3/live-routing.ts +1 -0
- package/src/core/events/v3/producers/hook-base.ts +14 -2
- package/src/core/events/v3/producers/intake.ts +10 -2
- package/src/core/events/v3/producers/recorder.ts +420 -17
- package/src/core/hooks/adapter/output.ts +12 -1
- package/src/core/hooks/cli.ts +332 -247
- package/src/core/hooks/health.ts +146 -0
- package/src/core/hooks/resolve/transcript.ts +10 -3
- package/src/core/hooks/session-name-presence.ts +6 -1
- package/src/core/qa-artifacts.ts +126 -0
- package/src/core/resources/contract.ts +105 -0
- package/src/core/resources/index.ts +5 -0
- package/src/core/resources/sampler.ts +590 -0
- package/src/core/resources/service-status.ts +62 -0
- package/src/core/resources/service.ts +337 -0
- package/src/core/resources/storage.ts +44 -0
- package/src/core/storage/atomic-json.ts +15 -0
- package/src/core/storage/builtins.ts +62 -6
- package/src/core/storage/logger.ts +2 -0
- package/src/core/storage/query.ts +58 -0
- package/src/core/supervisor/activity.ts +193 -0
- package/src/core/supervisor/contract.ts +312 -0
- package/src/core/supervisor/explanations.ts +104 -0
- package/src/core/supervisor/findings.ts +788 -0
- package/src/core/supervisor/history.ts +61 -0
- package/src/core/supervisor/hook-health-alerts.ts +108 -0
- package/src/core/supervisor/hook-health-storage.ts +25 -0
- package/src/core/supervisor/hook-health.ts +301 -0
- package/src/core/supervisor/hooks.ts +35 -0
- package/src/core/supervisor/index.ts +14 -0
- package/src/core/supervisor/log-feed.ts +131 -0
- package/src/core/supervisor/service.ts +511 -0
- package/src/core/supervisor/services.ts +203 -0
- package/src/core/supervisor/status.ts +59 -0
- package/src/core/supervisor/storage.ts +126 -0
- package/src/core/supervisor/timeline.ts +133 -0
- package/src/core/workflow/admission.ts +215 -0
- package/src/core/workflow/engine.ts +93 -1
- package/src/core/workflow/index.ts +10 -0
- package/src/core/workflow/proof.ts +54 -1
- package/src/core/workflow/run-state.ts +13 -1
- package/src/core/workflow/types.ts +39 -1
- package/src/lib/admission.ts +347 -0
- package/src/lib/agent-browser/client.ts +2 -10
- package/src/lib/browser/capture-fidelity.ts +98 -0
- package/src/lib/browser/client.ts +212 -10
- package/src/lib/browser/critique.ts +62 -7
- package/src/lib/browser/index.ts +65 -0
- package/src/lib/browser/page-review-judge.ts +360 -0
- package/src/lib/browser/page-review-pack.ts +2384 -0
- package/src/lib/browser/qa-run-contracts.ts +743 -0
- package/src/lib/browser/qa-run.ts +1462 -0
- package/src/lib/browser/request-diagnostics.ts +27 -0
- package/src/lib/browser/tiling.ts +32 -0
- package/src/lib/cookies/client.ts +228 -42
- package/src/lib/cookies/extra.ts +28 -0
- package/src/lib/cookies/index.ts +2 -0
- package/src/lib/coord-root-id.ts +23 -0
- package/src/lib/durable-job.ts +407 -0
- package/src/lib/http/client.ts +13 -1
- package/src/lib/instructions/apply.ts +81 -2
- package/src/lib/instructions/templates.ts +11 -2
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ResourceSnapshot } from "../resources/contract.ts";
|
|
2
|
+
import {
|
|
3
|
+
SUPERVISOR_HISTORY_SCHEMA_VERSION,
|
|
4
|
+
type SupervisorHistory,
|
|
5
|
+
type SupervisorHistoryPoint,
|
|
6
|
+
} from "./contract.ts";
|
|
7
|
+
|
|
8
|
+
export const SUPERVISOR_HISTORY_INTERVAL_MS = 10_000;
|
|
9
|
+
export const SUPERVISOR_HISTORY_MAX_POINTS = 90;
|
|
10
|
+
|
|
11
|
+
export function updateSupervisorHistory(
|
|
12
|
+
previous: SupervisorHistory | undefined,
|
|
13
|
+
resource: ResourceSnapshot,
|
|
14
|
+
): { history: SupervisorHistory; changed: boolean } {
|
|
15
|
+
const prior = validHistory(previous) ? previous.points : [];
|
|
16
|
+
const lastAt = prior.length > 0 ? Date.parse(prior[prior.length - 1]!.sampled_at) : Number.NaN;
|
|
17
|
+
const sampledAt = Date.parse(resource.sampled_at);
|
|
18
|
+
if (
|
|
19
|
+
Number.isFinite(lastAt) &&
|
|
20
|
+
Number.isFinite(sampledAt) &&
|
|
21
|
+
sampledAt - lastAt < SUPERVISOR_HISTORY_INTERVAL_MS
|
|
22
|
+
) {
|
|
23
|
+
return {
|
|
24
|
+
history: {
|
|
25
|
+
schema_version: SUPERVISOR_HISTORY_SCHEMA_VERSION,
|
|
26
|
+
interval_ms: SUPERVISOR_HISTORY_INTERVAL_MS,
|
|
27
|
+
max_points: SUPERVISOR_HISTORY_MAX_POINTS,
|
|
28
|
+
points: prior,
|
|
29
|
+
},
|
|
30
|
+
changed: false,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const point: SupervisorHistoryPoint = {
|
|
34
|
+
sampled_at: resource.sampled_at,
|
|
35
|
+
machine: {
|
|
36
|
+
cpu_percent: resource.machine.cpu_percent,
|
|
37
|
+
memory_percent: resource.machine.memory_percent,
|
|
38
|
+
memory_used_bytes: resource.machine.memory_used_bytes,
|
|
39
|
+
swap_used_bytes: resource.machine.swap_used_bytes,
|
|
40
|
+
process_count: resource.machine.process_count,
|
|
41
|
+
},
|
|
42
|
+
groups: resource.groups.map((group) => ({ ...group, root_pids: [...group.root_pids] })),
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
history: {
|
|
46
|
+
schema_version: SUPERVISOR_HISTORY_SCHEMA_VERSION,
|
|
47
|
+
interval_ms: SUPERVISOR_HISTORY_INTERVAL_MS,
|
|
48
|
+
max_points: SUPERVISOR_HISTORY_MAX_POINTS,
|
|
49
|
+
points: [...prior, point].slice(-SUPERVISOR_HISTORY_MAX_POINTS),
|
|
50
|
+
},
|
|
51
|
+
changed: true,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function validHistory(value: SupervisorHistory | undefined): value is SupervisorHistory {
|
|
56
|
+
return (
|
|
57
|
+
value?.schema_version === SUPERVISOR_HISTORY_SCHEMA_VERSION &&
|
|
58
|
+
Array.isArray(value.points) &&
|
|
59
|
+
value.points.length <= SUPERVISOR_HISTORY_MAX_POINTS
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { SupervisorFindingEvidence, SupervisorFindingSeverity } from "./contract.ts";
|
|
2
|
+
import {
|
|
3
|
+
type CompletedHookHealth,
|
|
4
|
+
type HookHealthAggregate,
|
|
5
|
+
SUPERVISOR_HIGH_COMPLETED_HOOK_RSS_BYTES,
|
|
6
|
+
SUPERVISOR_HOOK_RETRY_CLUSTER_COUNT,
|
|
7
|
+
SUPERVISOR_SLOW_COMPLETED_HOOK_MS,
|
|
8
|
+
type SupervisorHookHealth,
|
|
9
|
+
} from "./hook-health.ts";
|
|
10
|
+
|
|
11
|
+
export interface HookHealthAlert {
|
|
12
|
+
finding_kind:
|
|
13
|
+
| "hook.execution-degraded"
|
|
14
|
+
| "hook.execution-slow"
|
|
15
|
+
| "hook.memory-heavy"
|
|
16
|
+
| "hook.retry-cluster";
|
|
17
|
+
severity: SupervisorFindingSeverity;
|
|
18
|
+
scope_id: string;
|
|
19
|
+
summary: string;
|
|
20
|
+
observed_value: number;
|
|
21
|
+
unit: SupervisorFindingEvidence["unit"];
|
|
22
|
+
source: CompletedHookHealth;
|
|
23
|
+
owner_id?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function evaluateHookHealthAlerts(health: SupervisorHookHealth): readonly HookHealthAlert[] {
|
|
27
|
+
if (health.capability.state === "unavailable") return [];
|
|
28
|
+
const alerts: HookHealthAlert[] = [];
|
|
29
|
+
for (const aggregate of health.aggregates) {
|
|
30
|
+
const receipts = health.recent.filter(
|
|
31
|
+
(receipt) => `${receipt.adapter}:${receipt.hook_name}` === aggregate.key,
|
|
32
|
+
);
|
|
33
|
+
const problem = receipts.find(
|
|
34
|
+
(receipt) => receipt.outcome === "faulted" || receipt.outcome === "degraded",
|
|
35
|
+
);
|
|
36
|
+
if (problem) alerts.push(problemAlert(aggregate, problem));
|
|
37
|
+
const slow = maxReceipt(receipts, (receipt) => receipt.duration_ms);
|
|
38
|
+
if (slow && slow.duration_ms >= SUPERVISOR_SLOW_COMPLETED_HOOK_MS) {
|
|
39
|
+
alerts.push({
|
|
40
|
+
finding_kind: "hook.execution-slow",
|
|
41
|
+
severity: "warning",
|
|
42
|
+
scope_id: aggregate.key,
|
|
43
|
+
summary: `${aggregate.hook_name} completed in ${slow.duration_ms} milliseconds.`,
|
|
44
|
+
observed_value: slow.duration_ms,
|
|
45
|
+
unit: "milliseconds",
|
|
46
|
+
source: slow,
|
|
47
|
+
...(slow.owner_id ? { owner_id: slow.owner_id } : {}),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const heavy = maxReceipt(receipts, (receipt) => receipt.rss_end_bytes);
|
|
51
|
+
if (heavy && heavy.rss_end_bytes >= SUPERVISOR_HIGH_COMPLETED_HOOK_RSS_BYTES) {
|
|
52
|
+
alerts.push({
|
|
53
|
+
finding_kind: "hook.memory-heavy",
|
|
54
|
+
severity: "warning",
|
|
55
|
+
scope_id: aggregate.key,
|
|
56
|
+
summary: `${aggregate.hook_name} completed with ${heavy.rss_end_bytes} resident bytes.`,
|
|
57
|
+
observed_value: heavy.rss_end_bytes,
|
|
58
|
+
unit: "bytes",
|
|
59
|
+
source: heavy,
|
|
60
|
+
...(heavy.owner_id ? { owner_id: heavy.owner_id } : {}),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (health.summary.retry_count >= SUPERVISOR_HOOK_RETRY_CLUSTER_COUNT) {
|
|
65
|
+
const latestRetry = health.recent.find((receipt) => receipt.retry_worker);
|
|
66
|
+
if (latestRetry) {
|
|
67
|
+
alerts.push({
|
|
68
|
+
finding_kind: "hook.retry-cluster",
|
|
69
|
+
severity: "warning",
|
|
70
|
+
scope_id: `${latestRetry.adapter}:runtime-context-retry`,
|
|
71
|
+
summary: `${health.summary.retry_count} hook retry workers ran inside five minutes.`,
|
|
72
|
+
observed_value: health.summary.retry_count,
|
|
73
|
+
unit: "count",
|
|
74
|
+
source: latestRetry,
|
|
75
|
+
...(latestRetry.owner_id ? { owner_id: latestRetry.owner_id } : {}),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return alerts.slice(0, 12);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function problemAlert(
|
|
83
|
+
aggregate: HookHealthAggregate,
|
|
84
|
+
receipt: CompletedHookHealth,
|
|
85
|
+
): HookHealthAlert {
|
|
86
|
+
const severity: SupervisorFindingSeverity =
|
|
87
|
+
receipt.outcome === "faulted" ? "critical" : "warning";
|
|
88
|
+
return {
|
|
89
|
+
finding_kind: "hook.execution-degraded",
|
|
90
|
+
severity,
|
|
91
|
+
scope_id: aggregate.key,
|
|
92
|
+
summary: `${aggregate.hook_name} completed with internal outcome ${receipt.outcome}.`,
|
|
93
|
+
observed_value: aggregate.degraded_count + aggregate.faulted_count,
|
|
94
|
+
unit: "count",
|
|
95
|
+
source: receipt,
|
|
96
|
+
...(receipt.owner_id ? { owner_id: receipt.owner_id } : {}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function maxReceipt(
|
|
101
|
+
receipts: readonly CompletedHookHealth[],
|
|
102
|
+
value: (receipt: CompletedHookHealth) => number,
|
|
103
|
+
): CompletedHookHealth | undefined {
|
|
104
|
+
return receipts.reduce<CompletedHookHealth | undefined>(
|
|
105
|
+
(current, receipt) => (!current || value(receipt) > value(current) ? receipt : current),
|
|
106
|
+
undefined,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { writePrivateJsonAtomic } from "../storage/atomic-json.ts";
|
|
4
|
+
import { SUPERVISOR_HOOK_HEALTH_SCHEMA_VERSION, type SupervisorHookHealth } from "./hook-health.ts";
|
|
5
|
+
|
|
6
|
+
export function supervisorHookHealthPath(coordRoot: string): string {
|
|
7
|
+
return join(resolve(coordRoot), ".harnery", "supervisor", "hook-health.json");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function writeSupervisorHookHealth(coordRoot: string, value: SupervisorHookHealth): void {
|
|
11
|
+
writePrivateJsonAtomic(supervisorHookHealthPath(coordRoot), value);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function readSupervisorHookHealth(coordRoot: string): SupervisorHookHealth | undefined {
|
|
15
|
+
const path = supervisorHookHealthPath(coordRoot);
|
|
16
|
+
if (!existsSync(path)) return undefined;
|
|
17
|
+
try {
|
|
18
|
+
const value = JSON.parse(readFileSync(path, "utf8")) as Partial<SupervisorHookHealth>;
|
|
19
|
+
return value?.schema_version === SUPERVISOR_HOOK_HEALTH_SCHEMA_VERSION
|
|
20
|
+
? (value as SupervisorHookHealth)
|
|
21
|
+
: undefined;
|
|
22
|
+
} catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HOOK_HEALTH_EVENT,
|
|
3
|
+
HOOK_HEALTH_RECEIPT_VERSION,
|
|
4
|
+
type HookHealthOutcome,
|
|
5
|
+
} from "../hooks/health.ts";
|
|
6
|
+
import type { HarneryLogRecordV1 } from "../storage/jsonl.ts";
|
|
7
|
+
import type { SupervisorLogFeed } from "./contract.ts";
|
|
8
|
+
|
|
9
|
+
export const SUPERVISOR_HOOK_HEALTH_SCHEMA_VERSION = 1 as const;
|
|
10
|
+
export const SUPERVISOR_HOOK_HEALTH_RECENT_LIMIT = 50;
|
|
11
|
+
export const SUPERVISOR_HOOK_HEALTH_AGGREGATE_LIMIT = 40;
|
|
12
|
+
export const SUPERVISOR_SLOW_COMPLETED_HOOK_MS = 30_000;
|
|
13
|
+
export const SUPERVISOR_HIGH_COMPLETED_HOOK_RSS_BYTES = 512 * 1024 * 1024;
|
|
14
|
+
export const SUPERVISOR_HOOK_RETRY_CLUSTER_COUNT = 3;
|
|
15
|
+
export const SUPERVISOR_HOOK_RETRY_CLUSTER_WINDOW_MS = 5 * 60_000;
|
|
16
|
+
|
|
17
|
+
export interface CompletedHookHealth {
|
|
18
|
+
id: string;
|
|
19
|
+
observed_at: string;
|
|
20
|
+
hook_name: string;
|
|
21
|
+
adapter: "claude-code" | "codex" | "cursor" | "unknown";
|
|
22
|
+
outcome: HookHealthOutcome;
|
|
23
|
+
duration_ms: number;
|
|
24
|
+
rss_start_bytes: number;
|
|
25
|
+
rss_end_bytes: number;
|
|
26
|
+
rss_delta_bytes: number;
|
|
27
|
+
retry_worker: boolean;
|
|
28
|
+
error_count: number;
|
|
29
|
+
error_phases: readonly string[];
|
|
30
|
+
payload_bytes: number;
|
|
31
|
+
pid: number;
|
|
32
|
+
owner_id?: string;
|
|
33
|
+
skipped_reason?: string;
|
|
34
|
+
v3_state?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface HookHealthAggregate {
|
|
38
|
+
key: string;
|
|
39
|
+
hook_name: string;
|
|
40
|
+
adapter: CompletedHookHealth["adapter"];
|
|
41
|
+
invocation_count: number;
|
|
42
|
+
completed_count: number;
|
|
43
|
+
skipped_count: number;
|
|
44
|
+
degraded_count: number;
|
|
45
|
+
faulted_count: number;
|
|
46
|
+
retry_count: number;
|
|
47
|
+
duration_p50_ms: number;
|
|
48
|
+
duration_p95_ms: number;
|
|
49
|
+
duration_max_ms: number;
|
|
50
|
+
rss_end_max_bytes: number;
|
|
51
|
+
rss_delta_max_bytes: number;
|
|
52
|
+
latest_observed_at: string;
|
|
53
|
+
owner_ids: readonly string[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface SupervisorHookHealth {
|
|
57
|
+
schema_version: typeof SUPERVISOR_HOOK_HEALTH_SCHEMA_VERSION;
|
|
58
|
+
captured_at: string;
|
|
59
|
+
capability: {
|
|
60
|
+
source_kind: "hook.terminal-log";
|
|
61
|
+
state: "supported" | "partial" | "unavailable";
|
|
62
|
+
reason?: string;
|
|
63
|
+
};
|
|
64
|
+
source_record_count: number;
|
|
65
|
+
malformed_record_count: number;
|
|
66
|
+
truncated: boolean;
|
|
67
|
+
summary: {
|
|
68
|
+
invocation_count: number;
|
|
69
|
+
degraded_count: number;
|
|
70
|
+
faulted_count: number;
|
|
71
|
+
slow_count: number;
|
|
72
|
+
high_memory_count: number;
|
|
73
|
+
retry_count: number;
|
|
74
|
+
};
|
|
75
|
+
aggregates: readonly HookHealthAggregate[];
|
|
76
|
+
recent: readonly CompletedHookHealth[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function projectHookHealth(feed: SupervisorLogFeed, now = new Date()): SupervisorHookHealth {
|
|
80
|
+
const lane = feed.lanes.find((candidate) => candidate.family_id === "agent-hook-debug-log");
|
|
81
|
+
if (!lane) return unavailable(now, "hook-log-family-not-visible");
|
|
82
|
+
if (lane.error) return unavailable(now, "hook-log-family-unavailable");
|
|
83
|
+
|
|
84
|
+
const parsed: CompletedHookHealth[] = [];
|
|
85
|
+
let malformed = 0;
|
|
86
|
+
for (const record of lane.records) {
|
|
87
|
+
if (record.event !== HOOK_HEALTH_EVENT) continue;
|
|
88
|
+
const receipt = parseCompletedHookHealth(record);
|
|
89
|
+
if (receipt) parsed.push(receipt);
|
|
90
|
+
else malformed += 1;
|
|
91
|
+
}
|
|
92
|
+
parsed.sort((left, right) => Date.parse(right.observed_at) - Date.parse(left.observed_at));
|
|
93
|
+
const recent = parsed.slice(0, SUPERVISOR_HOOK_HEALTH_RECENT_LIMIT);
|
|
94
|
+
const aggregates = aggregateHookHealth(parsed).slice(0, SUPERVISOR_HOOK_HEALTH_AGGREGATE_LIMIT);
|
|
95
|
+
const retryCutoff = now.getTime() - SUPERVISOR_HOOK_RETRY_CLUSTER_WINDOW_MS;
|
|
96
|
+
return {
|
|
97
|
+
schema_version: SUPERVISOR_HOOK_HEALTH_SCHEMA_VERSION,
|
|
98
|
+
captured_at: now.toISOString(),
|
|
99
|
+
capability: {
|
|
100
|
+
source_kind: "hook.terminal-log",
|
|
101
|
+
state: lane.truncated || malformed > 0 ? "partial" : "supported",
|
|
102
|
+
...(lane.truncated
|
|
103
|
+
? { reason: "bounded-log-window-truncated" }
|
|
104
|
+
: malformed > 0
|
|
105
|
+
? { reason: "malformed-terminal-records-ignored" }
|
|
106
|
+
: {}),
|
|
107
|
+
},
|
|
108
|
+
source_record_count: parsed.length,
|
|
109
|
+
malformed_record_count: malformed,
|
|
110
|
+
truncated: lane.truncated || parsed.length > SUPERVISOR_HOOK_HEALTH_RECENT_LIMIT,
|
|
111
|
+
summary: {
|
|
112
|
+
invocation_count: parsed.length,
|
|
113
|
+
degraded_count: parsed.filter((receipt) => receipt.outcome === "degraded").length,
|
|
114
|
+
faulted_count: parsed.filter((receipt) => receipt.outcome === "faulted").length,
|
|
115
|
+
slow_count: parsed.filter(
|
|
116
|
+
(receipt) => receipt.duration_ms >= SUPERVISOR_SLOW_COMPLETED_HOOK_MS,
|
|
117
|
+
).length,
|
|
118
|
+
high_memory_count: parsed.filter(
|
|
119
|
+
(receipt) => receipt.rss_end_bytes >= SUPERVISOR_HIGH_COMPLETED_HOOK_RSS_BYTES,
|
|
120
|
+
).length,
|
|
121
|
+
retry_count: parsed.filter(
|
|
122
|
+
(receipt) => receipt.retry_worker && Date.parse(receipt.observed_at) >= retryCutoff,
|
|
123
|
+
).length,
|
|
124
|
+
},
|
|
125
|
+
aggregates,
|
|
126
|
+
recent,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function parseCompletedHookHealth(
|
|
131
|
+
record: HarneryLogRecordV1,
|
|
132
|
+
): CompletedHookHealth | undefined {
|
|
133
|
+
if (
|
|
134
|
+
record.kind !== "record" ||
|
|
135
|
+
record.component_id !== "agent-hook" ||
|
|
136
|
+
record.event !== HOOK_HEALTH_EVENT ||
|
|
137
|
+
record.fields.receipt_version !== HOOK_HEALTH_RECEIPT_VERSION ||
|
|
138
|
+
record.fields.exit_contract !== "always-zero" ||
|
|
139
|
+
record.fields.exit_code !== 0
|
|
140
|
+
) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
const hookName = token(record.fields.hook_name);
|
|
144
|
+
const adapter = adapterValue(record.fields.adapter);
|
|
145
|
+
const outcome = outcomeValue(record.fields.outcome);
|
|
146
|
+
const duration = integer(record.fields.duration_ms);
|
|
147
|
+
const rssStart = integer(record.fields.rss_start_bytes);
|
|
148
|
+
const rssEnd = integer(record.fields.rss_end_bytes);
|
|
149
|
+
const rssDelta = signedInteger(record.fields.rss_delta_bytes);
|
|
150
|
+
const payloadBytes = integer(record.fields.payload_bytes);
|
|
151
|
+
const pid = integer(record.fields.pid);
|
|
152
|
+
const errorCount = integer(record.fields.error_count);
|
|
153
|
+
const retryWorker = record.fields.retry_worker;
|
|
154
|
+
const errorPhases = tokenArray(record.fields.error_phases);
|
|
155
|
+
if (
|
|
156
|
+
!hookName ||
|
|
157
|
+
!adapter ||
|
|
158
|
+
!outcome ||
|
|
159
|
+
duration === undefined ||
|
|
160
|
+
rssStart === undefined ||
|
|
161
|
+
rssEnd === undefined ||
|
|
162
|
+
rssDelta === undefined ||
|
|
163
|
+
payloadBytes === undefined ||
|
|
164
|
+
pid === undefined ||
|
|
165
|
+
errorCount === undefined ||
|
|
166
|
+
typeof retryWorker !== "boolean" ||
|
|
167
|
+
!errorPhases ||
|
|
168
|
+
!Number.isFinite(Date.parse(record.emitted_at))
|
|
169
|
+
) {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
id: `${record.writer_id}:${record.writer_seq}`,
|
|
174
|
+
observed_at: record.emitted_at,
|
|
175
|
+
hook_name: hookName,
|
|
176
|
+
adapter,
|
|
177
|
+
outcome,
|
|
178
|
+
duration_ms: duration,
|
|
179
|
+
rss_start_bytes: rssStart,
|
|
180
|
+
rss_end_bytes: rssEnd,
|
|
181
|
+
rss_delta_bytes: rssDelta,
|
|
182
|
+
retry_worker: retryWorker,
|
|
183
|
+
error_count: errorCount,
|
|
184
|
+
error_phases: errorPhases,
|
|
185
|
+
payload_bytes: payloadBytes,
|
|
186
|
+
pid,
|
|
187
|
+
...optionalToken("owner_id", record.fields.owner_id),
|
|
188
|
+
...optionalToken("skipped_reason", record.fields.skipped_reason),
|
|
189
|
+
...optionalToken("v3_state", record.fields.v3_state),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function aggregateHookHealth(receipts: readonly CompletedHookHealth[]): HookHealthAggregate[] {
|
|
194
|
+
const grouped = new Map<string, CompletedHookHealth[]>();
|
|
195
|
+
for (const receipt of receipts) {
|
|
196
|
+
const key = `${receipt.adapter}:${receipt.hook_name}`;
|
|
197
|
+
const group = grouped.get(key) ?? [];
|
|
198
|
+
group.push(receipt);
|
|
199
|
+
grouped.set(key, group);
|
|
200
|
+
}
|
|
201
|
+
return [...grouped.entries()]
|
|
202
|
+
.map(([key, group]) => {
|
|
203
|
+
const durations = group.map((receipt) => receipt.duration_ms).sort((a, b) => a - b);
|
|
204
|
+
return {
|
|
205
|
+
key,
|
|
206
|
+
hook_name: group[0]!.hook_name,
|
|
207
|
+
adapter: group[0]!.adapter,
|
|
208
|
+
invocation_count: group.length,
|
|
209
|
+
completed_count: countOutcome(group, "completed"),
|
|
210
|
+
skipped_count: countOutcome(group, "skipped"),
|
|
211
|
+
degraded_count: countOutcome(group, "degraded"),
|
|
212
|
+
faulted_count: countOutcome(group, "faulted"),
|
|
213
|
+
retry_count: group.filter((receipt) => receipt.retry_worker).length,
|
|
214
|
+
duration_p50_ms: percentile(durations, 0.5),
|
|
215
|
+
duration_p95_ms: percentile(durations, 0.95),
|
|
216
|
+
duration_max_ms: durations.at(-1) ?? 0,
|
|
217
|
+
rss_end_max_bytes: Math.max(...group.map((receipt) => receipt.rss_end_bytes)),
|
|
218
|
+
rss_delta_max_bytes: Math.max(...group.map((receipt) => receipt.rss_delta_bytes)),
|
|
219
|
+
latest_observed_at: group[0]!.observed_at,
|
|
220
|
+
owner_ids: [...new Set(group.flatMap((receipt) => receipt.owner_id ?? []))].slice(0, 8),
|
|
221
|
+
};
|
|
222
|
+
})
|
|
223
|
+
.sort(
|
|
224
|
+
(left, right) =>
|
|
225
|
+
Date.parse(right.latest_observed_at) - Date.parse(left.latest_observed_at) ||
|
|
226
|
+
left.key.localeCompare(right.key),
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function countOutcome(
|
|
231
|
+
receipts: readonly CompletedHookHealth[],
|
|
232
|
+
outcome: HookHealthOutcome,
|
|
233
|
+
): number {
|
|
234
|
+
return receipts.filter((receipt) => receipt.outcome === outcome).length;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function percentile(sorted: readonly number[], fraction: number): number {
|
|
238
|
+
if (sorted.length === 0) return 0;
|
|
239
|
+
return sorted[Math.min(sorted.length - 1, Math.max(0, Math.ceil(sorted.length * fraction) - 1))]!;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function unavailable(now: Date, reason: string): SupervisorHookHealth {
|
|
243
|
+
return {
|
|
244
|
+
schema_version: SUPERVISOR_HOOK_HEALTH_SCHEMA_VERSION,
|
|
245
|
+
captured_at: now.toISOString(),
|
|
246
|
+
capability: { source_kind: "hook.terminal-log", state: "unavailable", reason },
|
|
247
|
+
source_record_count: 0,
|
|
248
|
+
malformed_record_count: 0,
|
|
249
|
+
truncated: false,
|
|
250
|
+
summary: {
|
|
251
|
+
invocation_count: 0,
|
|
252
|
+
degraded_count: 0,
|
|
253
|
+
faulted_count: 0,
|
|
254
|
+
slow_count: 0,
|
|
255
|
+
high_memory_count: 0,
|
|
256
|
+
retry_count: 0,
|
|
257
|
+
},
|
|
258
|
+
aggregates: [],
|
|
259
|
+
recent: [],
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function token(value: unknown): string | undefined {
|
|
264
|
+
return typeof value === "string" && /^[a-zA-Z0-9][a-zA-Z0-9._:/+-]{0,127}$/.test(value)
|
|
265
|
+
? value
|
|
266
|
+
: undefined;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function adapterValue(value: unknown): CompletedHookHealth["adapter"] | undefined {
|
|
270
|
+
return value === "claude-code" || value === "codex" || value === "cursor" || value === "unknown"
|
|
271
|
+
? value
|
|
272
|
+
: undefined;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function outcomeValue(value: unknown): HookHealthOutcome | undefined {
|
|
276
|
+
return value === "completed" || value === "skipped" || value === "degraded" || value === "faulted"
|
|
277
|
+
? value
|
|
278
|
+
: undefined;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function integer(value: unknown): number | undefined {
|
|
282
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : undefined;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function signedInteger(value: unknown): number | undefined {
|
|
286
|
+
return typeof value === "number" && Number.isSafeInteger(value) ? value : undefined;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function tokenArray(value: unknown): readonly string[] | undefined {
|
|
290
|
+
return Array.isArray(value) && value.length <= 8 && value.every((item) => token(item))
|
|
291
|
+
? (value as string[])
|
|
292
|
+
: undefined;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function optionalToken<Key extends "owner_id" | "skipped_reason" | "v3_state">(
|
|
296
|
+
key: Key,
|
|
297
|
+
value: unknown,
|
|
298
|
+
): Partial<Record<Key, string>> {
|
|
299
|
+
const parsed = token(value);
|
|
300
|
+
return parsed ? ({ [key]: parsed } as Partial<Record<Key, string>>) : {};
|
|
301
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ResourceSnapshot } from "../resources/contract.ts";
|
|
2
|
+
import type { ObservedHookHealth } from "./contract.ts";
|
|
3
|
+
|
|
4
|
+
export const SUPERVISOR_LONG_HOOK_SECONDS = 120;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Command text may label a process only after PID ancestry proved its agent
|
|
8
|
+
* owner. It never establishes ownership by itself.
|
|
9
|
+
*/
|
|
10
|
+
export function collectHookHealth(resource: ResourceSnapshot): ObservedHookHealth[] {
|
|
11
|
+
return resource.processes
|
|
12
|
+
.filter(
|
|
13
|
+
(row) =>
|
|
14
|
+
row.owner_kind === "agent" &&
|
|
15
|
+
row.owner_id !== null &&
|
|
16
|
+
exactHookEntrypoint(row.name, row.command),
|
|
17
|
+
)
|
|
18
|
+
.map((row) => ({
|
|
19
|
+
pid: row.pid,
|
|
20
|
+
owner_id: row.owner_id!,
|
|
21
|
+
state: row.state,
|
|
22
|
+
age_seconds: row.age_seconds,
|
|
23
|
+
cpu_percent: row.cpu_percent,
|
|
24
|
+
rss_bytes: row.rss_bytes,
|
|
25
|
+
command: row.command,
|
|
26
|
+
long_running: row.age_seconds >= SUPERVISOR_LONG_HOOK_SECONDS,
|
|
27
|
+
evidence: "validated-owner-and-exact-entrypoint" as const,
|
|
28
|
+
}))
|
|
29
|
+
.sort((left, right) => right.age_seconds - left.age_seconds || left.pid - right.pid);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function exactHookEntrypoint(name: string, command: string): boolean {
|
|
33
|
+
if (name === "agent-hook" || name === "agent-hook.exe") return true;
|
|
34
|
+
return /(?:^|[\\/\s])agent-hook(?:\.exe)?(?:\s|$)/.test(command);
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./contract.ts";
|
|
2
|
+
export * from "./explanations.ts";
|
|
3
|
+
export * from "./findings.ts";
|
|
4
|
+
export * from "./history.ts";
|
|
5
|
+
export * from "./hook-health.ts";
|
|
6
|
+
export * from "./hook-health-alerts.ts";
|
|
7
|
+
export * from "./hook-health-storage.ts";
|
|
8
|
+
export * from "./hooks.ts";
|
|
9
|
+
export * from "./log-feed.ts";
|
|
10
|
+
export * from "./service.ts";
|
|
11
|
+
export * from "./services.ts";
|
|
12
|
+
export * from "./status.ts";
|
|
13
|
+
export * from "./storage.ts";
|
|
14
|
+
export * from "./timeline.ts";
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { createStorageCatalog } from "../storage/catalog.ts";
|
|
2
|
+
import {
|
|
3
|
+
HARNERY_STRUCTURED_LOG_PROVIDER_ID,
|
|
4
|
+
type HarneryRegisteredStorageFamily,
|
|
5
|
+
} from "../storage/contract.ts";
|
|
6
|
+
import type { HarneryLogRecordV1 } from "../storage/jsonl.ts";
|
|
7
|
+
import {
|
|
8
|
+
type HarneryLogFollowCursor,
|
|
9
|
+
readLogFollow,
|
|
10
|
+
readRecentActiveLogs,
|
|
11
|
+
rotationFollowCursor,
|
|
12
|
+
} from "../storage/query.ts";
|
|
13
|
+
import {
|
|
14
|
+
SUPERVISOR_LOG_FEED_SCHEMA_VERSION,
|
|
15
|
+
type SupervisorLogFeed,
|
|
16
|
+
type SupervisorLogLane,
|
|
17
|
+
} from "./contract.ts";
|
|
18
|
+
|
|
19
|
+
const MAX_RECORDS_PER_FAMILY = 100;
|
|
20
|
+
const MAX_SEED_BYTES_PER_FAMILY = 256 * 1024;
|
|
21
|
+
const MAX_FOLLOW_BYTES_PER_FAMILY = 64 * 1024;
|
|
22
|
+
|
|
23
|
+
interface LaneState {
|
|
24
|
+
family: HarneryRegisteredStorageFamily;
|
|
25
|
+
cursor: HarneryLogFollowCursor;
|
|
26
|
+
records: HarneryLogRecordV1[];
|
|
27
|
+
truncated: boolean;
|
|
28
|
+
error?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class SupervisorLogCollector {
|
|
32
|
+
readonly #lanes: LaneState[];
|
|
33
|
+
#sequence = 0;
|
|
34
|
+
|
|
35
|
+
constructor(coordRoot: string) {
|
|
36
|
+
const catalog = createStorageCatalog({ coord_root: coordRoot, project_root: coordRoot });
|
|
37
|
+
this.#lanes = catalog.families.filter(isStructuredLogFamily).map((family) => seedLane(family));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async collect(now = new Date()): Promise<SupervisorLogFeed> {
|
|
41
|
+
let changed = this.#sequence === 0;
|
|
42
|
+
for (const lane of this.#lanes) {
|
|
43
|
+
try {
|
|
44
|
+
const followed = await readLogFollow(lane.family, lane.cursor, MAX_FOLLOW_BYTES_PER_FAMILY);
|
|
45
|
+
lane.cursor = followed.cursor;
|
|
46
|
+
if (followed.records.length > 0 || followed.rotated || followed.history_expired) {
|
|
47
|
+
const merged = dedupe([...lane.records, ...followed.records]);
|
|
48
|
+
lane.records = merged.slice(-MAX_RECORDS_PER_FAMILY);
|
|
49
|
+
lane.truncated =
|
|
50
|
+
lane.truncated || followed.history_expired || merged.length > MAX_RECORDS_PER_FAMILY;
|
|
51
|
+
changed = true;
|
|
52
|
+
}
|
|
53
|
+
if (lane.error) changed = true;
|
|
54
|
+
lane.error = undefined;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
const next = error instanceof Error ? error.message : String(error);
|
|
57
|
+
if (next !== lane.error) changed = true;
|
|
58
|
+
lane.error = next;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (changed) this.#sequence += 1;
|
|
62
|
+
const lanes: SupervisorLogLane[] = this.#lanes
|
|
63
|
+
.map((lane) => ({
|
|
64
|
+
family_id: lane.family.id,
|
|
65
|
+
owner: lane.family.owner,
|
|
66
|
+
storage_class: lane.family.storage_class as "operational-log" | "debug-log",
|
|
67
|
+
records: lane.records,
|
|
68
|
+
truncated: lane.truncated,
|
|
69
|
+
...(lane.error ? { error: lane.error } : {}),
|
|
70
|
+
}))
|
|
71
|
+
.sort((left, right) => {
|
|
72
|
+
const activeDelta = Number(right.records.length > 0) - Number(left.records.length > 0);
|
|
73
|
+
return activeDelta || left.family_id.localeCompare(right.family_id);
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
schema_version: SUPERVISOR_LOG_FEED_SCHEMA_VERSION,
|
|
77
|
+
captured_at: now.toISOString(),
|
|
78
|
+
sequence: this.#sequence,
|
|
79
|
+
lanes,
|
|
80
|
+
total_records: lanes.reduce((sum, lane) => sum + lane.records.length, 0),
|
|
81
|
+
unavailable_families: lanes.filter((lane) => lane.error).length,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function recentSupervisorLogs(feed: SupervisorLogFeed, limit = 20): HarneryLogRecordV1[] {
|
|
87
|
+
return feed.lanes
|
|
88
|
+
.flatMap((lane) => lane.records)
|
|
89
|
+
.sort((left, right) => Date.parse(left.emitted_at) - Date.parse(right.emitted_at))
|
|
90
|
+
.slice(-Math.max(0, limit));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function seedLane(family: HarneryRegisteredStorageFamily): LaneState {
|
|
94
|
+
try {
|
|
95
|
+
const seed = readRecentActiveLogs(family, {
|
|
96
|
+
max_records: MAX_RECORDS_PER_FAMILY,
|
|
97
|
+
max_bytes: MAX_SEED_BYTES_PER_FAMILY,
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
family,
|
|
101
|
+
cursor: rotationFollowCursor(family),
|
|
102
|
+
records: [...seed.records],
|
|
103
|
+
truncated: seed.truncated,
|
|
104
|
+
};
|
|
105
|
+
} catch (error) {
|
|
106
|
+
return {
|
|
107
|
+
family,
|
|
108
|
+
cursor: rotationFollowCursor(family),
|
|
109
|
+
records: [],
|
|
110
|
+
truncated: false,
|
|
111
|
+
error: error instanceof Error ? error.message : String(error),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function isStructuredLogFamily(family: HarneryRegisteredStorageFamily): boolean {
|
|
117
|
+
return (
|
|
118
|
+
(family.storage_class === "operational-log" || family.storage_class === "debug-log") &&
|
|
119
|
+
family.provider.provider_id === HARNERY_STRUCTURED_LOG_PROVIDER_ID
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function dedupe(records: readonly HarneryLogRecordV1[]): HarneryLogRecordV1[] {
|
|
124
|
+
const keyed = new Map<string, HarneryLogRecordV1>();
|
|
125
|
+
for (const record of records) {
|
|
126
|
+
keyed.set(`${record.family_id}:${record.writer_id}:${record.writer_seq}`, record);
|
|
127
|
+
}
|
|
128
|
+
return [...keyed.values()].sort(
|
|
129
|
+
(left, right) => Date.parse(left.emitted_at) - Date.parse(right.emitted_at),
|
|
130
|
+
);
|
|
131
|
+
}
|