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,407 @@
|
|
|
1
|
+
// Durable job records: a small on-disk representation of "a job that outlives
|
|
2
|
+
// the client that launched it". A supervisor process owns the record; a client
|
|
3
|
+
// only reads it. A bridge drop, a closed terminal, or a killed client
|
|
4
|
+
// therefore interrupts the *view* of the job, never the job itself.
|
|
5
|
+
//
|
|
6
|
+
// Layout, under a caller-supplied base directory:
|
|
7
|
+
//
|
|
8
|
+
// <base>/jobs/<job_id>/job.json immutable description (argv, cwd, resource)
|
|
9
|
+
// <base>/jobs/<job_id>/status.json mutable state, rewritten atomically
|
|
10
|
+
// <base>/jobs/<job_id>/job.log merged child stdout + stderr
|
|
11
|
+
//
|
|
12
|
+
// Classification is fail-closed, mirroring qa-status: liveness is proven by the
|
|
13
|
+
// PID, never assumed from the status document. A non-terminal state whose PID
|
|
14
|
+
// is dead classifies as "dead", never as "running".
|
|
15
|
+
//
|
|
16
|
+
// Toolkit tier: this module must not import src/core (layering check).
|
|
17
|
+
|
|
18
|
+
import { randomUUID } from "node:crypto";
|
|
19
|
+
import {
|
|
20
|
+
existsSync,
|
|
21
|
+
mkdirSync,
|
|
22
|
+
readdirSync,
|
|
23
|
+
readFileSync,
|
|
24
|
+
renameSync,
|
|
25
|
+
writeFileSync,
|
|
26
|
+
} from "node:fs";
|
|
27
|
+
import { join, resolve } from "node:path";
|
|
28
|
+
|
|
29
|
+
export const DURABLE_JOB_SCHEMA_VERSION = 1;
|
|
30
|
+
|
|
31
|
+
/** How often the supervisor rewrites status.json while a job runs. */
|
|
32
|
+
export const DURABLE_JOB_HEARTBEAT_MS = 15_000;
|
|
33
|
+
|
|
34
|
+
/** A running job whose heartbeat is older than this earns a staleness warning,
|
|
35
|
+
* but stays "running" while its PID is alive. */
|
|
36
|
+
export const DURABLE_JOB_HEARTBEAT_STALE_MS = 120_000;
|
|
37
|
+
|
|
38
|
+
export const DURABLE_JOB_DOCUMENT_FILENAME = "job.json";
|
|
39
|
+
export const DURABLE_JOB_STATUS_FILENAME = "status.json";
|
|
40
|
+
export const DURABLE_JOB_LOG_FILENAME = "job.log";
|
|
41
|
+
|
|
42
|
+
const JOBS_DIRNAME = "jobs";
|
|
43
|
+
|
|
44
|
+
/** States a supervisor writes. "completed" is the only terminal one. */
|
|
45
|
+
export type DurableJobState = "launching" | "queued" | "running" | "completed";
|
|
46
|
+
|
|
47
|
+
/** States a reader can observe. "dead" is derived, never written. */
|
|
48
|
+
export type DurableJobObservedState = DurableJobState | "dead";
|
|
49
|
+
|
|
50
|
+
const WRITTEN_STATES = new Set<string>(["launching", "queued", "running", "completed"]);
|
|
51
|
+
|
|
52
|
+
export interface DurableJobDocument {
|
|
53
|
+
schema_version: number;
|
|
54
|
+
job_id: string;
|
|
55
|
+
/** Admission resource the job queues on. */
|
|
56
|
+
resource: string;
|
|
57
|
+
/** Concurrent holders allowed on that resource. */
|
|
58
|
+
capacity: number;
|
|
59
|
+
/** Human-readable description shown in listings. */
|
|
60
|
+
label: string;
|
|
61
|
+
/** Argument vector of the wrapped command; argv[0] is the executable. */
|
|
62
|
+
argv: string[];
|
|
63
|
+
/** Directory the wrapped command runs in. */
|
|
64
|
+
cwd: string;
|
|
65
|
+
created_at: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface DurableJobStatus {
|
|
69
|
+
schema_version: number;
|
|
70
|
+
job_id: string;
|
|
71
|
+
/** PID of the supervisor, not of the wrapped command. */
|
|
72
|
+
pid: number;
|
|
73
|
+
state: DurableJobState;
|
|
74
|
+
started_at: string;
|
|
75
|
+
updated_at: string;
|
|
76
|
+
/** Present while the supervisor waits for an admission slot. */
|
|
77
|
+
queue?: { resource: string; waiting_since: string };
|
|
78
|
+
exit_code?: number | null;
|
|
79
|
+
signal?: string | null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface DurableJobReport {
|
|
83
|
+
state: DurableJobObservedState;
|
|
84
|
+
/** The job reached "completed"; exit_code and signal are final. */
|
|
85
|
+
terminal: boolean;
|
|
86
|
+
job_id: string | null;
|
|
87
|
+
pid: number | null;
|
|
88
|
+
resource: string | null;
|
|
89
|
+
label: string | null;
|
|
90
|
+
argv: string[] | null;
|
|
91
|
+
exit_code: number | null;
|
|
92
|
+
signal: string | null;
|
|
93
|
+
created_at: string | null;
|
|
94
|
+
started_at: string | null;
|
|
95
|
+
updated_at: string | null;
|
|
96
|
+
/** now minus status.updated_at; null without a parseable heartbeat. */
|
|
97
|
+
heartbeat_age_ms: number | null;
|
|
98
|
+
queue?: { resource: string; waiting_since: string };
|
|
99
|
+
job_dir: string;
|
|
100
|
+
log_path: string;
|
|
101
|
+
warnings: string[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface DurableJobDeps {
|
|
105
|
+
/** PID liveness probe (injectable for tests). Default: process.kill(pid, 0). */
|
|
106
|
+
pidAlive?: (pid: number) => boolean;
|
|
107
|
+
/** Evaluation instant in epoch milliseconds. Default: Date.now(). */
|
|
108
|
+
now?: () => number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type DurableJobClassification =
|
|
112
|
+
| { ok: true; report: DurableJobReport }
|
|
113
|
+
| { ok: false; error: string };
|
|
114
|
+
|
|
115
|
+
export interface DurableJobListEntry {
|
|
116
|
+
job_id: string;
|
|
117
|
+
job_dir: string;
|
|
118
|
+
created_at: string | null;
|
|
119
|
+
document: DurableJobDocument | null;
|
|
120
|
+
report: DurableJobReport | null;
|
|
121
|
+
/** Set when the directory exists but its status document is unusable. */
|
|
122
|
+
error?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
126
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Default PID liveness probe. EPERM counts as alive; only ESRCH is dead. */
|
|
130
|
+
function defaultPidAlive(pid: number): boolean {
|
|
131
|
+
try {
|
|
132
|
+
process.kill(pid, 0);
|
|
133
|
+
return true;
|
|
134
|
+
} catch (err: unknown) {
|
|
135
|
+
return (err as NodeJS.ErrnoException).code !== "ESRCH";
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Directory holding every job record under a base directory. */
|
|
140
|
+
export function jobsRoot(base: string): string {
|
|
141
|
+
return join(resolve(base), JOBS_DIRNAME);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Directory of one job record. Does not create it. */
|
|
145
|
+
export function jobDirFor(base: string, jobId: string): string {
|
|
146
|
+
return join(jobsRoot(base), jobId);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Create (idempotently) the directory for one job and return its path. */
|
|
150
|
+
export function createJobDir(base: string, jobId: string): string {
|
|
151
|
+
const dir = jobDirFor(base, jobId);
|
|
152
|
+
mkdirSync(dir, { recursive: true });
|
|
153
|
+
return dir;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function jobLogPath(jobDir: string): string {
|
|
157
|
+
return join(resolve(jobDir), DURABLE_JOB_LOG_FILENAME);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function writeAtomic(path: string, body: string): void {
|
|
161
|
+
const tmp = `${path}.${randomUUID().slice(0, 8)}.tmp`;
|
|
162
|
+
writeFileSync(tmp, body);
|
|
163
|
+
renameSync(tmp, path);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Write the immutable job description. */
|
|
167
|
+
export function writeJobDocument(jobDir: string, document: DurableJobDocument): void {
|
|
168
|
+
writeAtomic(
|
|
169
|
+
join(resolve(jobDir), DURABLE_JOB_DOCUMENT_FILENAME),
|
|
170
|
+
`${JSON.stringify(document, null, 2)}\n`,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Replace the status document atomically, so a reader never sees a torn file. */
|
|
175
|
+
export function writeJobStatus(jobDir: string, status: DurableJobStatus): void {
|
|
176
|
+
writeAtomic(
|
|
177
|
+
join(resolve(jobDir), DURABLE_JOB_STATUS_FILENAME),
|
|
178
|
+
`${JSON.stringify(status, null, 2)}\n`,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function readJson(path: string): unknown {
|
|
183
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Read the job description, or null when it is missing or unusable. */
|
|
187
|
+
export function readJobDocument(jobDir: string): DurableJobDocument | null {
|
|
188
|
+
const path = join(resolve(jobDir), DURABLE_JOB_DOCUMENT_FILENAME);
|
|
189
|
+
let parsed: unknown;
|
|
190
|
+
try {
|
|
191
|
+
parsed = readJson(path);
|
|
192
|
+
} catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
if (!isRecord(parsed)) return null;
|
|
196
|
+
if (typeof parsed.job_id !== "string") return null;
|
|
197
|
+
return {
|
|
198
|
+
schema_version:
|
|
199
|
+
typeof parsed.schema_version === "number"
|
|
200
|
+
? parsed.schema_version
|
|
201
|
+
: DURABLE_JOB_SCHEMA_VERSION,
|
|
202
|
+
job_id: parsed.job_id,
|
|
203
|
+
resource: typeof parsed.resource === "string" ? parsed.resource : "",
|
|
204
|
+
capacity: typeof parsed.capacity === "number" ? parsed.capacity : 1,
|
|
205
|
+
label: typeof parsed.label === "string" ? parsed.label : "",
|
|
206
|
+
argv: Array.isArray(parsed.argv)
|
|
207
|
+
? parsed.argv.filter((a): a is string => typeof a === "string")
|
|
208
|
+
: [],
|
|
209
|
+
cwd: typeof parsed.cwd === "string" ? parsed.cwd : "",
|
|
210
|
+
created_at: typeof parsed.created_at === "string" ? parsed.created_at : "",
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Read the status document, or null when it is missing or unusable. */
|
|
215
|
+
export function readJobStatus(jobDir: string): DurableJobStatus | null {
|
|
216
|
+
const path = join(resolve(jobDir), DURABLE_JOB_STATUS_FILENAME);
|
|
217
|
+
let parsed: unknown;
|
|
218
|
+
try {
|
|
219
|
+
parsed = readJson(path);
|
|
220
|
+
} catch {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
if (!isRecord(parsed)) return null;
|
|
224
|
+
if (typeof parsed.job_id !== "string") return null;
|
|
225
|
+
if (typeof parsed.state !== "string" || !WRITTEN_STATES.has(parsed.state)) return null;
|
|
226
|
+
const queue = parsed.queue;
|
|
227
|
+
return {
|
|
228
|
+
schema_version:
|
|
229
|
+
typeof parsed.schema_version === "number"
|
|
230
|
+
? parsed.schema_version
|
|
231
|
+
: DURABLE_JOB_SCHEMA_VERSION,
|
|
232
|
+
job_id: parsed.job_id,
|
|
233
|
+
pid: typeof parsed.pid === "number" ? parsed.pid : 0,
|
|
234
|
+
state: parsed.state as DurableJobState,
|
|
235
|
+
started_at: typeof parsed.started_at === "string" ? parsed.started_at : "",
|
|
236
|
+
updated_at: typeof parsed.updated_at === "string" ? parsed.updated_at : "",
|
|
237
|
+
...(isRecord(queue) &&
|
|
238
|
+
typeof queue.resource === "string" &&
|
|
239
|
+
typeof queue.waiting_since === "string"
|
|
240
|
+
? { queue: { resource: queue.resource, waiting_since: queue.waiting_since } }
|
|
241
|
+
: {}),
|
|
242
|
+
...(typeof parsed.exit_code === "number" || parsed.exit_code === null
|
|
243
|
+
? { exit_code: parsed.exit_code as number | null }
|
|
244
|
+
: {}),
|
|
245
|
+
...(typeof parsed.signal === "string" || parsed.signal === null
|
|
246
|
+
? { signal: parsed.signal as string | null }
|
|
247
|
+
: {}),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Classify one job directory, fail-closed. "completed" is terminal and carries
|
|
253
|
+
* the wrapped command's exit code. Any other written state is trusted only
|
|
254
|
+
* while the supervisor PID is alive; otherwise the job is "dead" — the record
|
|
255
|
+
* outlived the process that owned it.
|
|
256
|
+
*/
|
|
257
|
+
export function classifyJob(jobDir: string, deps: DurableJobDeps = {}): DurableJobClassification {
|
|
258
|
+
const isAlive = deps.pidAlive ?? defaultPidAlive;
|
|
259
|
+
const nowMs = deps.now ? deps.now() : Date.now();
|
|
260
|
+
const abs = resolve(jobDir);
|
|
261
|
+
if (!existsSync(abs)) return { ok: false, error: `no such job directory: ${abs}` };
|
|
262
|
+
|
|
263
|
+
const statusPath = join(abs, DURABLE_JOB_STATUS_FILENAME);
|
|
264
|
+
if (!existsSync(statusPath)) {
|
|
265
|
+
return {
|
|
266
|
+
ok: false,
|
|
267
|
+
error: `${abs} carries no ${DURABLE_JOB_STATUS_FILENAME}: not a job directory`,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
const status = readJobStatus(abs);
|
|
271
|
+
if (!status) {
|
|
272
|
+
return { ok: false, error: `${statusPath} is not a readable job status document` };
|
|
273
|
+
}
|
|
274
|
+
const document = readJobDocument(abs);
|
|
275
|
+
|
|
276
|
+
let heartbeatAgeMs: number | null = null;
|
|
277
|
+
const updatedMs = Date.parse(status.updated_at);
|
|
278
|
+
if (!Number.isNaN(updatedMs)) heartbeatAgeMs = Math.max(0, nowMs - updatedMs);
|
|
279
|
+
|
|
280
|
+
const base = {
|
|
281
|
+
job_id: status.job_id,
|
|
282
|
+
pid: status.pid > 0 ? status.pid : null,
|
|
283
|
+
resource: document?.resource ?? null,
|
|
284
|
+
label: document?.label ?? null,
|
|
285
|
+
argv: document?.argv ?? null,
|
|
286
|
+
created_at: document?.created_at ?? null,
|
|
287
|
+
started_at: status.started_at || null,
|
|
288
|
+
updated_at: status.updated_at || null,
|
|
289
|
+
heartbeat_age_ms: heartbeatAgeMs,
|
|
290
|
+
job_dir: abs,
|
|
291
|
+
log_path: jobLogPath(abs),
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
if (status.state === "completed") {
|
|
295
|
+
return {
|
|
296
|
+
ok: true,
|
|
297
|
+
report: {
|
|
298
|
+
...base,
|
|
299
|
+
state: "completed",
|
|
300
|
+
terminal: true,
|
|
301
|
+
exit_code: status.exit_code ?? null,
|
|
302
|
+
signal: status.signal ?? null,
|
|
303
|
+
warnings: [],
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (!(status.pid > 0 && isAlive(status.pid))) {
|
|
309
|
+
return {
|
|
310
|
+
ok: true,
|
|
311
|
+
report: {
|
|
312
|
+
...base,
|
|
313
|
+
state: "dead",
|
|
314
|
+
terminal: false,
|
|
315
|
+
exit_code: null,
|
|
316
|
+
signal: null,
|
|
317
|
+
...(status.queue ? { queue: status.queue } : {}),
|
|
318
|
+
warnings: [],
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const warnings: string[] = [];
|
|
324
|
+
if (
|
|
325
|
+
status.state === "running" &&
|
|
326
|
+
heartbeatAgeMs !== null &&
|
|
327
|
+
heartbeatAgeMs > DURABLE_JOB_HEARTBEAT_STALE_MS
|
|
328
|
+
) {
|
|
329
|
+
warnings.push(
|
|
330
|
+
`heartbeat stale: last update ${Math.round(heartbeatAgeMs / 1000)}s ago ` +
|
|
331
|
+
`(threshold ${DURABLE_JOB_HEARTBEAT_STALE_MS / 1000}s), but pid ${status.pid} is alive`,
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
ok: true,
|
|
336
|
+
report: {
|
|
337
|
+
...base,
|
|
338
|
+
state: status.state,
|
|
339
|
+
terminal: false,
|
|
340
|
+
exit_code: null,
|
|
341
|
+
signal: null,
|
|
342
|
+
...(status.queue ? { queue: status.queue } : {}),
|
|
343
|
+
warnings,
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Every job record under a base directory, newest first. Ordering keys on the
|
|
350
|
+
* description's created_at, falling back to the status document's started_at,
|
|
351
|
+
* then to the directory name, so a record missing its description still lists.
|
|
352
|
+
*/
|
|
353
|
+
export function listJobs(base: string, deps: DurableJobDeps = {}): DurableJobListEntry[] {
|
|
354
|
+
const root = jobsRoot(base);
|
|
355
|
+
let names: string[];
|
|
356
|
+
try {
|
|
357
|
+
names = readdirSync(root, { withFileTypes: true })
|
|
358
|
+
.filter((entry) => entry.isDirectory())
|
|
359
|
+
.map((entry) => entry.name);
|
|
360
|
+
} catch {
|
|
361
|
+
return [];
|
|
362
|
+
}
|
|
363
|
+
const entries: { entry: DurableJobListEntry; sortKey: number }[] = [];
|
|
364
|
+
for (const name of names) {
|
|
365
|
+
const dir = join(root, name);
|
|
366
|
+
const document = readJobDocument(dir);
|
|
367
|
+
const classified = classifyJob(dir, deps);
|
|
368
|
+
const createdAt =
|
|
369
|
+
document?.created_at || (classified.ok ? classified.report.started_at : null) || null;
|
|
370
|
+
const parsed = createdAt !== null ? Date.parse(createdAt) : Number.NaN;
|
|
371
|
+
entries.push({
|
|
372
|
+
entry: {
|
|
373
|
+
job_id: document?.job_id ?? name,
|
|
374
|
+
job_dir: dir,
|
|
375
|
+
created_at: createdAt,
|
|
376
|
+
document,
|
|
377
|
+
report: classified.ok ? classified.report : null,
|
|
378
|
+
...(classified.ok ? {} : { error: classified.error }),
|
|
379
|
+
},
|
|
380
|
+
sortKey: Number.isNaN(parsed) ? 0 : parsed,
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
entries.sort((a, b) => {
|
|
384
|
+
if (b.sortKey !== a.sortKey) return b.sortKey - a.sortKey;
|
|
385
|
+
return b.entry.job_id.localeCompare(a.entry.job_id);
|
|
386
|
+
});
|
|
387
|
+
return entries.map((item) => item.entry);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** Describe a job's outcome as a process exit code: the wrapped command's own
|
|
391
|
+
* code, 1 when it died on a signal, 4 when the record is dead. */
|
|
392
|
+
export function jobExitCode(report: DurableJobReport): number {
|
|
393
|
+
if (report.state === "dead") return 4;
|
|
394
|
+
if (!report.terminal) return 5;
|
|
395
|
+
if (report.signal !== null) return 1;
|
|
396
|
+
return report.exit_code ?? 1;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Format a duration the way the status commands do. */
|
|
400
|
+
export function formatJobAge(ms: number): string {
|
|
401
|
+
const totalSeconds = Math.max(0, Math.round(ms / 1000));
|
|
402
|
+
if (totalSeconds < 60) return `${totalSeconds}s`;
|
|
403
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
404
|
+
if (minutes < 60) return `${minutes}m ${totalSeconds % 60}s`;
|
|
405
|
+
const hours = Math.floor(minutes / 60);
|
|
406
|
+
return `${hours}h ${minutes % 60}m`;
|
|
407
|
+
}
|
package/src/lib/http/client.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
applyExtraCookies,
|
|
3
|
+
type Cookie,
|
|
4
|
+
type CookieJar,
|
|
5
|
+
type ExtraCookies,
|
|
6
|
+
} from "../cookies/index.ts";
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* Simple cookie-aware HTTP client.
|
|
@@ -39,6 +44,12 @@ export interface FetchOptions<TResponseType extends FetchResponseType = "text">
|
|
|
39
44
|
* only land when the key isn't already set.
|
|
40
45
|
*/
|
|
41
46
|
extraHeaders?: (url: string) => Record<string, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Optional callback that returns extra cookies to persist into `jar`
|
|
49
|
+
* before the Cookie header is built. Ignored when no jar is passed
|
|
50
|
+
* (`--no-cookies`). Must stay synchronous.
|
|
51
|
+
*/
|
|
52
|
+
extraCookies?: ExtraCookies;
|
|
42
53
|
/** Response body representation. Default `text`; use `bytes` for lossless file output. */
|
|
43
54
|
responseType?: TResponseType;
|
|
44
55
|
}
|
|
@@ -72,6 +83,7 @@ export async function fetchWithJar<TResponseType extends FetchResponseType = "te
|
|
|
72
83
|
const headers: Record<string, string> = { ...(opts.headers ?? {}) };
|
|
73
84
|
|
|
74
85
|
if (opts.jar) {
|
|
86
|
+
applyExtraCookies(url, opts.jar, opts.extraCookies);
|
|
75
87
|
const cookieHeader = opts.jar.header(url);
|
|
76
88
|
if (cookieHeader && !headers.Cookie && !headers.cookie) {
|
|
77
89
|
headers.Cookie = cookieHeader;
|
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
* writes, and deletes so init/deinit stay thin and this stays integration-
|
|
8
8
|
* testable against a temp dir.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* Three files, one dir:
|
|
11
11
|
* - `AGENTS.md` — the always-on orientation block (a managed region; the
|
|
12
12
|
* consumer owns the rest of the file).
|
|
13
13
|
* - `CLAUDE.md` — claude-code only; Claude Code reads CLAUDE.md, not AGENTS.md,
|
|
14
14
|
* so a fresh consumer gets a CLAUDE.md whose managed region imports
|
|
15
15
|
* `@AGENTS.md`. A CLAUDE.md that already imports AGENTS.md or already carries
|
|
16
16
|
* the block (a host that generates CLAUDE.md from AGENTS.md) is left alone.
|
|
17
|
+
* - `.cursor/rules/harnery-turn-ritual.mdc` — cursor only; an Always Apply
|
|
18
|
+
* rule that makes the Stop-enforced status footer visible in reply text.
|
|
17
19
|
* - `<adapter-skill-dir>/<skill>/SKILL.md` — fully-owned files, honoring
|
|
18
20
|
* `skills.exclude` in `.harnery/config.jsonc`. Claude Code uses
|
|
19
21
|
* `.claude/skills/`; Cursor and Codex use `.agents/skills/`.
|
|
@@ -29,7 +31,7 @@ import {
|
|
|
29
31
|
writeFileSync,
|
|
30
32
|
} from "node:fs";
|
|
31
33
|
import { dirname, join } from "node:path";
|
|
32
|
-
import { stripJsonComments } from "../../core/config.ts";
|
|
34
|
+
import { endOfTurnStatusCommand, stripJsonComments } from "../../core/config.ts";
|
|
33
35
|
import { readHostAddendum } from "./host-addendum.ts";
|
|
34
36
|
import {
|
|
35
37
|
checkOwnedSkill,
|
|
@@ -37,6 +39,7 @@ import {
|
|
|
37
39
|
isOwnedFile,
|
|
38
40
|
type ManagedStatus,
|
|
39
41
|
removeRegion,
|
|
42
|
+
shortHash,
|
|
40
43
|
spliceRegion,
|
|
41
44
|
} from "./splice.ts";
|
|
42
45
|
import {
|
|
@@ -50,6 +53,7 @@ import {
|
|
|
50
53
|
|
|
51
54
|
const AGENTS_FILE = "AGENTS.md";
|
|
52
55
|
const CLAUDE_FILE = "CLAUDE.md";
|
|
56
|
+
const CURSOR_RULE_FILE = join(".cursor", "rules", "harnery-turn-ritual.mdc");
|
|
53
57
|
const ADAPTER_SKILLS_DIR: Readonly<Record<string, string>> = {
|
|
54
58
|
"claude-code": join(".claude", "skills"),
|
|
55
59
|
cursor: join(".agents", "skills"),
|
|
@@ -71,6 +75,39 @@ function skillBody(render: (bin: string) => string, binName: string): string {
|
|
|
71
75
|
return content.slice(content.indexOf("-->") + 3).trim();
|
|
72
76
|
}
|
|
73
77
|
|
|
78
|
+
function cursorRuleBody(projectRoot: string, binName: string): string {
|
|
79
|
+
const statusCommand = endOfTurnStatusCommand(projectRoot);
|
|
80
|
+
return [
|
|
81
|
+
"# Harnery turn ritual",
|
|
82
|
+
"",
|
|
83
|
+
"On every turn that uses tools:",
|
|
84
|
+
"",
|
|
85
|
+
`1. Run \`${binName} agents set-task "<short focus>"\` during the turn, even when the focus is unchanged.`,
|
|
86
|
+
`2. Make \`${statusCommand}\` your final tool call.`,
|
|
87
|
+
"3. Append that command's stdout verbatim in a fenced code block at the bottom of the same substantive reply.",
|
|
88
|
+
"",
|
|
89
|
+
"Cursor Stop enforces all three signals. A missing signal produces one follow-up that names every repair needed.",
|
|
90
|
+
].join("\n");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function cursorRuleContent(projectRoot: string, binName: string): string {
|
|
94
|
+
const body = cursorRuleBody(projectRoot, binName);
|
|
95
|
+
const marker =
|
|
96
|
+
`<!-- harnery:generated cursor-turn-ritual v=${shortHash(body)}; machine-owned; ` +
|
|
97
|
+
`regenerated by \`${binName} init\`, removed by \`${binName} deinit\`. ` +
|
|
98
|
+
"Edit the harnery template, not this file. -->";
|
|
99
|
+
return [
|
|
100
|
+
"---",
|
|
101
|
+
"description: Harnery end-of-turn coordination ritual",
|
|
102
|
+
"alwaysApply: true",
|
|
103
|
+
"---",
|
|
104
|
+
marker,
|
|
105
|
+
"",
|
|
106
|
+
body,
|
|
107
|
+
"",
|
|
108
|
+
].join("\n");
|
|
109
|
+
}
|
|
110
|
+
|
|
74
111
|
/** Read `skills.exclude` from `.harnery/config.jsonc` (absent/unparseable → none). */
|
|
75
112
|
export function readSkillsExclude(projectRoot: string): Set<string> {
|
|
76
113
|
const p = join(projectRoot, ".harnery", "config.jsonc");
|
|
@@ -203,6 +240,27 @@ export function applyInstructions(projectRoot: string, opts: ApplyOpts): ApplyRe
|
|
|
203
240
|
}
|
|
204
241
|
}
|
|
205
242
|
|
|
243
|
+
// ── Cursor Always Apply rule ────────────────────────────────────────────
|
|
244
|
+
if (opts.adapter === "cursor") {
|
|
245
|
+
const rulePath = join(projectRoot, CURSOR_RULE_FILE);
|
|
246
|
+
const content = cursorRuleContent(projectRoot, opts.binName);
|
|
247
|
+
const before = existsSync(rulePath) ? readFileSync(rulePath, "utf8") : null;
|
|
248
|
+
if (before === content) {
|
|
249
|
+
actions.push(`· ${CURSOR_RULE_FILE} already current`);
|
|
250
|
+
} else if (before !== null && !isOwnedFile(before)) {
|
|
251
|
+
warnings.push(`left ${CURSOR_RULE_FILE} (hand-edited; no harnery ownership marker)`);
|
|
252
|
+
} else {
|
|
253
|
+
if (!opts.dryRun) {
|
|
254
|
+
mkdirSync(dirname(rulePath), { recursive: true });
|
|
255
|
+
writeFileSync(rulePath, content);
|
|
256
|
+
}
|
|
257
|
+
const fresh = before === null;
|
|
258
|
+
actions.push(
|
|
259
|
+
`${fresh ? "+" : "~"} ${verbed(fresh ? "write" : "update", fresh ? "wrote" : "updated")} ${CURSOR_RULE_FILE}`,
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
206
264
|
// ── shipped skills ───────────────────────────────────────────────────────
|
|
207
265
|
if (skillsDir) {
|
|
208
266
|
const exclude = readSkillsExclude(projectRoot);
|
|
@@ -301,6 +359,18 @@ export function removeInstructions(projectRoot: string, opts: RemoveOpts): Apply
|
|
|
301
359
|
}
|
|
302
360
|
}
|
|
303
361
|
|
|
362
|
+
if (opts.adapter === "cursor") {
|
|
363
|
+
const rulePath = join(projectRoot, CURSOR_RULE_FILE);
|
|
364
|
+
if (existsSync(rulePath)) {
|
|
365
|
+
if (!isOwnedFile(readFileSync(rulePath, "utf8"))) {
|
|
366
|
+
warnings.push(`left ${CURSOR_RULE_FILE} (hand-edited; no harnery ownership marker)`);
|
|
367
|
+
} else {
|
|
368
|
+
if (!opts.dryRun) rmSync(rulePath);
|
|
369
|
+
actions.push(`+ ${opts.dryRun ? "would delete" : "deleted"} ${CURSOR_RULE_FILE}`);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
304
374
|
// ── shipped skills ───────────────────────────────────────────────────────
|
|
305
375
|
if (skillsDir) {
|
|
306
376
|
for (const skill of SKILLS) {
|
|
@@ -384,6 +454,15 @@ export function checkInstructions(
|
|
|
384
454
|
note(`skill ${skill.id}`, checkOwnedSkill(c, skillBody(skill.render, opts.binName)));
|
|
385
455
|
}
|
|
386
456
|
}
|
|
457
|
+
|
|
458
|
+
if (opts.adapter === "cursor") {
|
|
459
|
+
const rulePath = join(projectRoot, CURSOR_RULE_FILE);
|
|
460
|
+
const content = existsSync(rulePath) ? readFileSync(rulePath, "utf8") : "";
|
|
461
|
+
note(
|
|
462
|
+
`${CURSOR_RULE_FILE} rule`,
|
|
463
|
+
checkOwnedSkill(content, cursorRuleBody(projectRoot, opts.binName)),
|
|
464
|
+
);
|
|
465
|
+
}
|
|
387
466
|
} catch (err) {
|
|
388
467
|
errored = true;
|
|
389
468
|
issues.push(`error reading instructions state: ${(err as Error).message}`);
|
|
@@ -135,6 +135,12 @@ coordination ledger (\`.harnery/ledgers/v3/\`). Lead a shell command with a
|
|
|
135
135
|
carries a reason instead of \`(no intent)\`; the [tool-intent
|
|
136
136
|
guide](https://harnery.com/guides/tool-intent/) owns the details.
|
|
137
137
|
|
|
138
|
+
**Messaging another agent.** \`${b} agents ping <name> "<message>"\` reaches an
|
|
139
|
+
agent by name whether or not they are running: a live agent sees it on their next
|
|
140
|
+
prompt, and a dormant name holds it until a session of that name next starts.
|
|
141
|
+
Send it as your first and only step. Do not check who is live first, and do not
|
|
142
|
+
hunt for somewhere else to leave it. Only a never-used name is refused.
|
|
143
|
+
|
|
138
144
|
**Journal.** \`${b} journal add <category> "<text>"\` (category = ${journalCats})
|
|
139
145
|
leaves breadcrumbs that survive context compaction;
|
|
140
146
|
\`${b} journal read\` reads yours, \`${b} journal read --name <peer>\` reads a peer's.
|
|
@@ -276,10 +282,13 @@ auto-route into contribute.
|
|
|
276
282
|
## Create (\`create <objective>\`)
|
|
277
283
|
|
|
278
284
|
The web UI is the member + steward picker; don't create from the CLI (that skips
|
|
279
|
-
the steward choice).
|
|
285
|
+
the steward choice). Read the dashboard base URL from the active Harnery web
|
|
286
|
+
status or start output, which resolves the project's configured \`web.port\`.
|
|
287
|
+
Append the URL-encoded objective to this path; never assume a port or reuse a
|
|
288
|
+
dashboard URL from another project:
|
|
280
289
|
|
|
281
290
|
\`\`\`
|
|
282
|
-
|
|
291
|
+
<configured-dashboard-base-url>/councils/new?objective=<encoded>
|
|
283
292
|
\`\`\`
|
|
284
293
|
|
|
285
294
|
If the dev server isn't up, start it with \`${b} web up\`.
|