harnery 0.33.0 → 0.34.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.map +1 -1
- package/dist/commander.js +4 -0
- package/dist/commands/adapter.js +2 -2
- package/dist/commands/agents.d.ts +144 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +1220 -588
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +7 -6
- package/dist/commands/backup.d.ts +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +29 -16
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +234 -12
- package/dist/commands/checkpoint.d.ts.map +1 -1
- package/dist/commands/checkpoint.js +3 -2
- package/dist/commands/claude-desktop.d.ts +1 -1
- package/dist/commands/claude-desktop.d.ts.map +1 -1
- package/dist/commands/claude-desktop.js +3 -74
- package/dist/commands/context.js +1 -6
- package/dist/commands/decision.d.ts.map +1 -1
- package/dist/commands/decision.js +22 -38
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +91 -28
- package/dist/commands/doctor.js +10 -1
- package/dist/commands/events.d.ts +5 -0
- package/dist/commands/events.d.ts.map +1 -0
- package/dist/commands/events.js +189 -0
- package/dist/commands/governor.d.ts.map +1 -1
- package/dist/commands/governor.js +13 -4
- package/dist/commands/init.d.ts +9 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +223 -51
- package/dist/commands/journal.d.ts.map +1 -1
- package/dist/commands/journal.js +4 -13
- package/dist/commands/ledger-v3.d.ts +5 -0
- package/dist/commands/ledger-v3.d.ts.map +1 -0
- package/dist/commands/ledger-v3.js +91 -0
- package/dist/commands/presence.d.ts.map +1 -1
- package/dist/commands/presence.js +11 -5
- package/dist/commands/sync.d.ts +1 -1
- package/dist/commands/sync.js +1 -1
- package/dist/commands/web.d.ts +6 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +67 -7
- package/dist/commands/work.d.ts.map +1 -1
- package/dist/commands/work.js +22 -5
- package/dist/core/adapter.d.ts +5 -0
- package/dist/core/adapter.d.ts.map +1 -0
- package/dist/core/adapter.js +1 -0
- package/dist/core/adapters/attest.d.ts +5 -2
- package/dist/core/adapters/attest.d.ts.map +1 -1
- package/dist/core/adapters/attest.js +8 -3
- package/dist/core/adapters/profiles.d.ts +6 -6
- package/dist/core/adapters/profiles.d.ts.map +1 -1
- package/dist/core/adapters/profiles.js +4 -4
- package/dist/core/agents/canonical-emit.d.ts +17 -15
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +22 -22
- package/dist/core/agents/cli.js +207 -234
- package/dist/core/agents/codex-archive-v3.d.ts +14 -0
- package/dist/core/agents/codex-archive-v3.d.ts.map +1 -0
- package/dist/core/agents/codex-archive-v3.js +110 -0
- package/dist/core/agents/coord-client.d.ts +19 -81
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +65 -155
- package/dist/core/agents/finalization.d.ts +4 -1
- package/dist/core/agents/finalization.d.ts.map +1 -1
- package/dist/core/agents/finalization.js +89 -32
- package/dist/core/agents/index.d.ts +4 -5
- package/dist/core/agents/index.d.ts.map +1 -1
- package/dist/core/agents/index.js +4 -5
- package/dist/core/agents/live-authority-v3.d.ts +59 -0
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -0
- package/dist/core/agents/live-authority-v3.js +233 -0
- package/dist/core/agents/live-lifecycle-v3.d.ts +20 -0
- package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -0
- package/dist/core/agents/live-lifecycle-v3.js +91 -0
- package/dist/core/agents/live-observation-v3.d.ts +25 -0
- package/dist/core/agents/live-observation-v3.d.ts.map +1 -0
- package/dist/core/agents/live-observation-v3.js +157 -0
- package/dist/core/agents/render/prompt-context.d.ts +4 -4
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +23 -58
- package/dist/core/agents/render/session-context.d.ts +1 -1
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +8 -32
- package/dist/core/agents/rules/claim-conflict.d.ts +3 -3
- package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/claim-conflict.js +79 -127
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/commit-conflict.js +3 -18
- package/dist/core/agents/rules/stop-hook.d.ts +9 -50
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +193 -236
- package/dist/core/agents/session-events.d.ts +5 -7
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +127 -95
- package/dist/core/agents/session-finalization-state-v3.d.ts +30 -0
- package/dist/core/agents/session-finalization-state-v3.d.ts.map +1 -0
- package/dist/core/agents/session-finalization-state-v3.js +40 -0
- package/dist/core/agents/session-finalizer-v3.d.ts +107 -0
- package/dist/core/agents/session-finalizer-v3.d.ts.map +1 -0
- package/dist/core/agents/session-finalizer-v3.js +734 -0
- package/dist/core/agents/session-name-display.d.ts +40 -0
- package/dist/core/agents/session-name-display.d.ts.map +1 -0
- package/dist/core/agents/session-name-display.js +119 -0
- package/dist/core/agents/state/activity-log.d.ts +3 -3
- package/dist/core/agents/state/activity-log.d.ts.map +1 -1
- package/dist/core/agents/state/activity-log.js +7 -16
- package/dist/core/agents/state/heartbeat-writer.d.ts +23 -55
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +56 -228
- package/dist/core/agents/state/live-coordination-view.d.ts +31 -0
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -0
- package/dist/core/agents/state/live-coordination-view.js +209 -0
- package/dist/core/agents/state/session-state.d.ts +4 -3
- package/dist/core/agents/state/session-state.d.ts.map +1 -1
- package/dist/core/agents/state/session-state.js +18 -9
- package/dist/core/agents/state/stale-sweep.d.ts +1 -1
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +26 -15
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +5 -7
- package/dist/core/config.d.ts +33 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +98 -2
- package/dist/core/context/index.d.ts +1 -4
- package/dist/core/context/index.d.ts.map +1 -1
- package/dist/core/context/index.js +9 -9
- package/dist/core/events/span-parent.d.ts +15 -0
- package/dist/core/events/span-parent.d.ts.map +1 -0
- package/dist/core/events/span-parent.js +34 -0
- package/dist/core/events/v3/advance.d.ts +14 -0
- package/dist/core/events/v3/advance.d.ts.map +1 -0
- package/dist/core/events/v3/advance.js +134 -0
- package/dist/core/events/v3/authority-outbox.d.ts +78 -0
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -0
- package/dist/core/events/v3/authority-outbox.js +399 -0
- package/dist/core/events/v3/base-builder.d.ts +20 -0
- package/dist/core/events/v3/base-builder.d.ts.map +1 -0
- package/dist/core/events/v3/base-builder.js +29 -0
- package/dist/core/events/v3/base-contract.d.ts +7576 -0
- package/dist/core/events/v3/base-contract.d.ts.map +1 -0
- package/dist/core/events/v3/base-contract.js +647 -0
- package/dist/core/events/v3/bootstrap.d.ts +34 -0
- package/dist/core/events/v3/bootstrap.d.ts.map +1 -0
- package/dist/core/events/v3/bootstrap.js +175 -0
- package/dist/core/events/v3/builder.d.ts +20 -0
- package/dist/core/events/v3/builder.d.ts.map +1 -0
- package/dist/core/events/v3/builder.js +28 -0
- package/dist/core/events/v3/canonical.d.ts +31 -0
- package/dist/core/events/v3/canonical.d.ts.map +1 -0
- package/dist/core/events/v3/canonical.js +100 -0
- package/dist/core/events/v3/capabilities.d.ts +31 -0
- package/dist/core/events/v3/capabilities.d.ts.map +1 -0
- package/dist/core/events/v3/capabilities.js +107 -0
- package/dist/core/events/v3/capability-drift.d.ts +22 -0
- package/dist/core/events/v3/capability-drift.d.ts.map +1 -0
- package/dist/core/events/v3/capability-drift.js +134 -0
- package/dist/core/events/v3/catalog.d.ts +38 -0
- package/dist/core/events/v3/catalog.d.ts.map +1 -0
- package/dist/core/events/v3/catalog.js +135 -0
- package/dist/core/events/v3/clock-order.d.ts +34 -0
- package/dist/core/events/v3/clock-order.d.ts.map +1 -0
- package/dist/core/events/v3/clock-order.js +35 -0
- package/dist/core/events/v3/contract.d.ts +171 -0
- package/dist/core/events/v3/contract.d.ts.map +1 -0
- package/dist/core/events/v3/contract.js +180 -0
- package/dist/core/events/v3/control.d.ts +111 -0
- package/dist/core/events/v3/control.d.ts.map +1 -0
- package/dist/core/events/v3/control.js +419 -0
- package/dist/core/events/v3/coordination-view.d.ts +69 -0
- package/dist/core/events/v3/coordination-view.d.ts.map +1 -0
- package/dist/core/events/v3/coordination-view.js +119 -0
- package/dist/core/events/v3/economics.d.ts +77 -0
- package/dist/core/events/v3/economics.d.ts.map +1 -0
- package/dist/core/events/v3/economics.js +274 -0
- package/dist/core/events/v3/finalization-view.d.ts +26 -0
- package/dist/core/events/v3/finalization-view.d.ts.map +1 -0
- package/dist/core/events/v3/finalization-view.js +37 -0
- package/dist/core/events/v3/fingerprint-keys.d.ts +25 -0
- package/dist/core/events/v3/fingerprint-keys.d.ts.map +1 -0
- package/dist/core/events/v3/fingerprint-keys.js +217 -0
- package/dist/core/events/v3/generated.d.ts +4 -0
- package/dist/core/events/v3/generated.d.ts.map +1 -0
- package/dist/core/events/v3/generated.js +47 -0
- package/dist/core/events/v3/ids.d.ts +9 -0
- package/dist/core/events/v3/ids.d.ts.map +1 -0
- package/dist/core/events/v3/ids.js +25 -0
- package/dist/core/events/v3/index.d.ts +35 -0
- package/dist/core/events/v3/index.d.ts.map +1 -0
- package/dist/core/events/v3/index.js +33 -0
- package/dist/core/events/v3/latency.d.ts +63 -0
- package/dist/core/events/v3/latency.d.ts.map +1 -0
- package/dist/core/events/v3/latency.js +412 -0
- package/dist/core/events/v3/live-feed.d.ts +45 -0
- package/dist/core/events/v3/live-feed.d.ts.map +1 -0
- package/dist/core/events/v3/live-feed.js +246 -0
- package/dist/core/events/v3/live-observation.d.ts +35 -0
- package/dist/core/events/v3/live-observation.d.ts.map +1 -0
- package/dist/core/events/v3/live-observation.js +1 -0
- package/dist/core/events/v3/live-routing.d.ts +57 -0
- package/dist/core/events/v3/live-routing.d.ts.map +1 -0
- package/dist/core/events/v3/live-routing.js +107 -0
- package/dist/core/events/v3/producers/command-recorder.d.ts +67 -0
- package/dist/core/events/v3/producers/command-recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/command-recorder.js +477 -0
- package/dist/core/events/v3/producers/command.d.ts +50 -0
- package/dist/core/events/v3/producers/command.d.ts.map +1 -0
- package/dist/core/events/v3/producers/command.js +135 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +53 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/coordination-recorder.js +376 -0
- package/dist/core/events/v3/producers/coordination.d.ts +90 -0
- package/dist/core/events/v3/producers/coordination.d.ts.map +1 -0
- package/dist/core/events/v3/producers/coordination.js +229 -0
- package/dist/core/events/v3/producers/hook-base.d.ts +54 -0
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -0
- package/dist/core/events/v3/producers/hook-base.js +424 -0
- package/dist/core/events/v3/producers/hook.d.ts +29 -0
- package/dist/core/events/v3/producers/hook.d.ts.map +1 -0
- package/dist/core/events/v3/producers/hook.js +71 -0
- package/dist/core/events/v3/producers/intake.d.ts +65 -0
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -0
- package/dist/core/events/v3/producers/intake.js +244 -0
- package/dist/core/events/v3/producers/recorder.d.ts +240 -0
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/recorder.js +2176 -0
- package/dist/core/events/v3/projection.d.ts +101 -0
- package/dist/core/events/v3/projection.d.ts.map +1 -0
- package/dist/core/events/v3/projection.js +479 -0
- package/dist/core/events/v3/reader.d.ts +75 -0
- package/dist/core/events/v3/reader.d.ts.map +1 -0
- package/dist/core/events/v3/reader.js +778 -0
- package/dist/core/events/v3/recovery-record.d.ts +47 -0
- package/dist/core/events/v3/recovery-record.d.ts.map +1 -0
- package/dist/core/events/v3/recovery-record.js +167 -0
- package/dist/core/events/v3/recovery.d.ts +22 -0
- package/dist/core/events/v3/recovery.d.ts.map +1 -0
- package/dist/core/events/v3/recovery.js +227 -0
- package/dist/core/events/v3/span-state.d.ts +52 -0
- package/dist/core/events/v3/span-state.d.ts.map +1 -0
- package/dist/core/events/v3/span-state.js +142 -0
- package/dist/core/events/v3/targets.d.ts +23 -0
- package/dist/core/events/v3/targets.d.ts.map +1 -0
- package/dist/core/events/v3/targets.js +134 -0
- package/dist/core/events/v3/turn-telemetry.d.ts +41 -0
- package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -0
- package/dist/core/events/v3/turn-telemetry.js +168 -0
- package/dist/core/events/v3/validate.d.ts +9 -0
- package/dist/core/events/v3/validate.d.ts.map +1 -0
- package/dist/core/events/v3/validate.js +281 -0
- package/dist/core/events/v3/writer.d.ts +56 -0
- package/dist/core/events/v3/writer.d.ts.map +1 -0
- package/dist/core/events/v3/writer.js +335 -0
- package/dist/core/governor/index.d.ts +1 -1
- package/dist/core/governor/index.d.ts.map +1 -1
- package/dist/core/governor/index.js +1 -1
- package/dist/core/governor/plan-api.d.ts +2 -1
- package/dist/core/governor/plan-api.d.ts.map +1 -1
- package/dist/core/governor/plan-api.js +6 -3
- package/dist/core/governor/read.d.ts +1 -1
- package/dist/core/governor/read.d.ts.map +1 -1
- package/dist/core/governor/read.js +1 -1
- package/dist/core/governor/state.d.ts +9 -0
- package/dist/core/governor/state.d.ts.map +1 -1
- package/dist/core/governor/state.js +40 -3
- package/dist/core/guard/config.d.ts +5 -0
- package/dist/core/guard/config.d.ts.map +1 -0
- package/dist/core/guard/config.js +157 -0
- package/dist/core/guard/coordinator.d.ts +14 -0
- package/dist/core/guard/coordinator.d.ts.map +1 -0
- package/dist/core/guard/coordinator.js +173 -0
- package/dist/core/guard/evaluator.d.ts +4 -0
- package/dist/core/guard/evaluator.d.ts.map +1 -0
- package/dist/core/guard/evaluator.js +242 -0
- package/dist/core/guard/evidence-v3.d.ts +15 -0
- package/dist/core/guard/evidence-v3.d.ts.map +1 -0
- package/dist/core/guard/evidence-v3.js +171 -0
- package/dist/core/guard/index.d.ts +10 -0
- package/dist/core/guard/index.d.ts.map +1 -0
- package/dist/core/guard/index.js +6 -0
- package/dist/core/guard/live-source-v3.d.ts +40 -0
- package/dist/core/guard/live-source-v3.d.ts.map +1 -0
- package/dist/core/guard/live-source-v3.js +128 -0
- package/dist/core/guard/storage.d.ts +27 -0
- package/dist/core/guard/storage.d.ts.map +1 -0
- package/dist/core/guard/storage.js +140 -0
- package/dist/core/guard/types.d.ts +119 -0
- package/dist/core/guard/types.d.ts.map +1 -0
- package/dist/core/guard/types.js +1 -0
- package/dist/core/hooks/adapter/detect.d.ts +18 -1
- package/dist/core/hooks/adapter/detect.d.ts.map +1 -1
- package/dist/core/hooks/adapter/detect.js +29 -0
- package/dist/core/hooks/adapter/events.d.ts +7 -4
- package/dist/core/hooks/adapter/events.d.ts.map +1 -1
- package/dist/core/hooks/adapter/events.js +12 -4
- package/dist/core/hooks/adapter/output.d.ts +2 -2
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.d.ts +7 -4
- package/dist/core/hooks/adapter/parse.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.js +63 -25
- package/dist/core/hooks/adapter/wiring.d.ts +30 -4
- package/dist/core/hooks/adapter/wiring.d.ts.map +1 -1
- package/dist/core/hooks/adapter/wiring.js +89 -11
- package/dist/core/hooks/cli.d.ts +1 -1
- package/dist/core/hooks/cli.js +305 -444
- package/dist/core/hooks/effects/image-capture.d.ts +20 -34
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +212 -221
- package/dist/core/hooks/effects/index.d.ts +1 -9
- package/dist/core/hooks/effects/index.d.ts.map +1 -1
- package/dist/core/hooks/effects/index.js +1 -24
- package/dist/core/hooks/events/input-hash.d.ts +7 -0
- package/dist/core/hooks/events/input-hash.d.ts.map +1 -0
- package/dist/core/hooks/events/input-hash.js +43 -0
- package/dist/core/hooks/index.d.ts +4 -3
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/index.js +2 -3
- package/dist/core/hooks/resolve/coord-root.d.ts +1 -1
- package/dist/core/hooks/resolve/coord-root.js +1 -1
- package/dist/core/hooks/resolve/owner.d.ts +16 -15
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +51 -42
- package/dist/core/hooks/resolve/transcript.d.ts +33 -3
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +155 -14
- package/dist/core/hooks/session-name-presence.d.ts +9 -10
- package/dist/core/hooks/session-name-presence.d.ts.map +1 -1
- package/dist/core/hooks/session-name-presence.js +15 -15
- package/dist/core/hooks/unsafe-cross-shell.d.ts +1 -1
- package/dist/core/hooks/unsafe-cross-shell.d.ts.map +1 -1
- package/dist/core/journal/index.d.ts +2 -2
- package/dist/core/journal/index.d.ts.map +1 -1
- package/dist/core/journal/index.js +9 -22
- package/dist/core/presence/blob.d.ts +4 -3
- package/dist/core/presence/blob.d.ts.map +1 -1
- package/dist/core/presence/blob.js +45 -44
- package/dist/core/presence/codec-digest.d.ts +29 -0
- package/dist/core/presence/codec-digest.d.ts.map +1 -0
- package/dist/core/presence/codec-digest.js +170 -0
- package/dist/core/presence/relay-client.d.ts +1 -1
- package/dist/core/presence/relay-client.d.ts.map +1 -1
- package/dist/core/presence/relay-client.js +5 -5
- package/dist/core/work/index.d.ts +1 -1
- package/dist/core/work/index.d.ts.map +1 -1
- package/dist/core/work/index.js +1 -1
- package/dist/core/work/read.d.ts +1 -1
- package/dist/core/work/read.d.ts.map +1 -1
- package/dist/core/work/read.js +1 -1
- package/dist/core/work/runner.d.ts.map +1 -1
- package/dist/core/work/runner.js +6 -0
- package/dist/core/work/state.d.ts +9 -0
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +17 -3
- package/dist/core/workflow/engine.js +24 -25
- package/dist/core/workflow/live-session-v3.d.ts +19 -0
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -0
- package/dist/core/workflow/live-session-v3.js +86 -0
- package/dist/core/workflow/scope-id.d.ts +3 -0
- package/dist/core/workflow/scope-id.d.ts.map +1 -0
- package/dist/core/workflow/scope-id.js +5 -0
- package/dist/core/workflow/workspaces/leases.d.ts +4 -0
- package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/leases.js +53 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/browser/client.d.ts +41 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +203 -0
- package/dist/lib/browser/critique.d.ts +28 -2
- package/dist/lib/browser/critique.d.ts.map +1 -1
- package/dist/lib/browser/critique.js +74 -18
- package/dist/lib/browser/geometry.d.ts +1 -1
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +130 -6
- package/dist/lib/browser/index.d.ts +3 -0
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +3 -0
- package/dist/lib/browser/qa-plan.d.ts +174 -0
- package/dist/lib/browser/qa-plan.d.ts.map +1 -0
- package/dist/lib/browser/qa-plan.js +321 -0
- package/dist/lib/browser/qa-reuse.d.ts +99 -0
- package/dist/lib/browser/qa-reuse.d.ts.map +1 -0
- package/dist/lib/browser/qa-reuse.js +222 -0
- package/dist/lib/browser/qa-snapshot.d.ts +64 -0
- package/dist/lib/browser/qa-snapshot.d.ts.map +1 -0
- package/dist/lib/browser/qa-snapshot.js +171 -0
- package/dist/lib/browser/runts.d.ts.map +1 -1
- package/dist/lib/browser/runts.js +22 -1
- package/dist/lib/browser/tiling.d.ts +71 -0
- package/dist/lib/browser/tiling.d.ts.map +1 -0
- package/dist/lib/browser/tiling.js +118 -0
- package/dist/lib/claude-desktop.d.ts +0 -47
- package/dist/lib/claude-desktop.d.ts.map +1 -1
- package/dist/lib/claude-desktop.js +1 -169
- package/dist/lib/context/index.d.ts +0 -3
- package/dist/lib/context/index.d.ts.map +1 -1
- package/dist/lib/context/index.js +20 -42
- package/dist/lib/council/index.d.ts +2 -2
- package/dist/lib/council/index.d.ts.map +1 -1
- package/dist/lib/council/index.js +9 -20
- package/dist/lib/docs-frontmatter.d.ts +1 -6
- package/dist/lib/docs-frontmatter.d.ts.map +1 -1
- package/dist/lib/docs-frontmatter.js +12 -78
- package/dist/lib/docs-index.d.ts +9 -0
- package/dist/lib/docs-index.d.ts.map +1 -1
- package/dist/lib/docs-index.js +32 -3
- package/dist/lib/docs-lint.d.ts.map +1 -1
- package/dist/lib/docs-lint.js +14 -30
- package/dist/lib/docs-metadata-audit.d.ts +19 -0
- package/dist/lib/docs-metadata-audit.d.ts.map +1 -0
- package/dist/lib/docs-metadata-audit.js +132 -0
- package/dist/lib/docs-metadata-managed.d.ts +23 -0
- package/dist/lib/docs-metadata-managed.d.ts.map +1 -0
- package/dist/lib/docs-metadata-managed.js +78 -0
- package/dist/lib/docs-metadata-sync.d.ts +20 -0
- package/dist/lib/docs-metadata-sync.d.ts.map +1 -0
- package/dist/lib/docs-metadata-sync.js +222 -0
- package/dist/lib/docs-metadata-v2-schema.d.ts +273 -0
- package/dist/lib/docs-metadata-v2-schema.d.ts.map +1 -0
- package/dist/lib/docs-metadata-v2-schema.js +134 -0
- package/dist/lib/docs-metadata-v2.d.ts +21 -0
- package/dist/lib/docs-metadata-v2.d.ts.map +1 -0
- package/dist/lib/docs-metadata-v2.js +424 -0
- package/dist/lib/docs-new.d.ts +11 -0
- package/dist/lib/docs-new.d.ts.map +1 -0
- package/dist/lib/docs-new.js +52 -0
- package/dist/lib/docs-sweep.d.ts.map +1 -1
- package/dist/lib/docs-sweep.js +45 -29
- package/dist/lib/headless/index.d.ts +98 -0
- package/dist/lib/headless/index.d.ts.map +1 -0
- package/dist/lib/headless/index.js +211 -0
- package/dist/lib/identities/assume.d.ts +4 -4
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +52 -68
- package/dist/lib/instructions/apply.d.ts +5 -4
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +32 -20
- package/dist/lib/instructions/bundle.d.ts +1 -1
- package/dist/lib/instructions/bundle.d.ts.map +1 -1
- package/dist/lib/instructions/bundle.js +1 -1
- package/dist/lib/instructions/splice.d.ts +0 -1
- package/dist/lib/instructions/splice.d.ts.map +1 -1
- package/dist/lib/instructions/splice.js +22 -6
- package/dist/lib/instructions/templates.d.ts +7 -5
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +79 -9
- package/package.json +26 -5
- package/schemas/config.schema.json +120 -2
- package/schemas/docs-metadata-v2.schema.json +441 -0
- package/schemas/event-v3.schema.json +24472 -0
- package/src/commander.ts +4 -0
- package/src/commands/adapter.ts +2 -2
- package/src/commands/agents.ts +1512 -592
- package/src/commands/artifacts.ts +7 -6
- package/src/commands/backup.ts +29 -21
- package/src/commands/browse.ts +349 -8
- package/src/commands/checkpoint.ts +4 -3
- package/src/commands/claude-desktop.ts +2 -101
- package/src/commands/context.ts +1 -6
- package/src/commands/decision.ts +27 -44
- package/src/commands/docs.ts +100 -33
- package/src/commands/doctor.ts +14 -1
- package/src/commands/events.ts +256 -0
- package/src/commands/governor.ts +18 -4
- package/src/commands/init.ts +253 -57
- package/src/commands/instructions.ts +1 -1
- package/src/commands/journal.ts +4 -13
- package/src/commands/ledger-v3.ts +111 -0
- package/src/commands/presence.ts +11 -10
- package/src/commands/sync.ts +1 -1
- package/src/commands/web.ts +67 -8
- package/src/commands/work.ts +28 -5
- package/src/core/adapter.ts +5 -0
- package/src/core/adapters/attest.ts +8 -3
- package/src/core/adapters/profiles.ts +4 -6
- package/src/core/agents/canonical-emit.ts +34 -25
- package/src/core/agents/cli.ts +236 -262
- package/src/core/agents/codex-archive-v3.ts +138 -0
- package/src/core/agents/coord-client.ts +75 -188
- package/src/core/agents/finalization.ts +120 -38
- package/src/core/agents/index.ts +4 -5
- package/src/core/agents/live-authority-v3.ts +375 -0
- package/src/core/agents/live-lifecycle-v3.ts +140 -0
- package/src/core/agents/live-observation-v3.ts +216 -0
- package/src/core/agents/render/prompt-context.ts +29 -60
- package/src/core/agents/render/session-context.ts +10 -31
- package/src/core/agents/rules/claim-conflict.ts +85 -126
- package/src/core/agents/rules/commit-conflict.ts +3 -14
- package/src/core/agents/rules/stop-hook.ts +239 -293
- package/src/core/agents/session-events.ts +137 -104
- package/src/core/agents/session-finalization-state-v3.ts +90 -0
- package/src/core/agents/session-finalizer-v3.ts +953 -0
- package/src/core/agents/session-name-display.ts +149 -0
- package/src/core/agents/state/activity-log.ts +6 -14
- package/src/core/agents/state/heartbeat-writer.ts +82 -277
- package/src/core/agents/state/live-coordination-view.ts +290 -0
- package/src/core/agents/state/session-state.ts +24 -12
- package/src/core/agents/state/stale-sweep.ts +40 -17
- package/src/core/artifacts/index.ts +4 -5
- package/src/core/config.ts +148 -3
- package/src/core/context/index.ts +9 -17
- package/src/core/events/span-parent.ts +46 -0
- package/src/core/events/v3/advance.ts +168 -0
- package/src/core/events/v3/authority-outbox.ts +548 -0
- package/src/core/events/v3/base-builder.ts +60 -0
- package/src/core/events/v3/base-contract.ts +882 -0
- package/src/core/events/v3/bootstrap.ts +226 -0
- package/src/core/events/v3/builder.ts +59 -0
- package/src/core/events/v3/canonical.ts +153 -0
- package/src/core/events/v3/capabilities.ts +171 -0
- package/src/core/events/v3/capability-drift.ts +177 -0
- package/src/core/events/v3/catalog.ts +202 -0
- package/src/core/events/v3/clock-order.ts +41 -0
- package/src/core/events/v3/contract.ts +365 -0
- package/src/core/events/v3/control.ts +576 -0
- package/src/core/events/v3/coordination-view.ts +193 -0
- package/src/core/events/v3/economics.ts +384 -0
- package/src/core/events/v3/finalization-view.ts +67 -0
- package/src/core/events/v3/fingerprint-keys.ts +260 -0
- package/src/core/events/v3/generated.ts +48 -0
- package/src/core/events/v3/ids.ts +33 -0
- package/src/core/events/v3/index.ts +322 -0
- package/src/core/events/v3/latency.ts +551 -0
- package/src/core/events/v3/live-feed.ts +319 -0
- package/src/core/events/v3/live-observation.ts +39 -0
- package/src/core/events/v3/live-routing.ts +135 -0
- package/src/core/events/v3/producers/command-recorder.ts +631 -0
- package/src/core/events/v3/producers/command.ts +201 -0
- package/src/core/events/v3/producers/coordination-recorder.ts +538 -0
- package/src/core/events/v3/producers/coordination.ts +355 -0
- package/src/core/events/v3/producers/hook-base.ts +578 -0
- package/src/core/events/v3/producers/hook.ts +119 -0
- package/src/core/events/v3/producers/intake.ts +319 -0
- package/src/core/events/v3/producers/recorder.ts +2805 -0
- package/src/core/events/v3/projection.ts +653 -0
- package/src/core/events/v3/reader.ts +1127 -0
- package/src/core/events/v3/recovery-record.ts +244 -0
- package/src/core/events/v3/recovery.ts +271 -0
- package/src/core/events/v3/span-state.ts +187 -0
- package/src/core/events/v3/targets.ts +182 -0
- package/src/core/events/v3/turn-telemetry.ts +259 -0
- package/src/core/events/v3/validate.ts +361 -0
- package/src/core/events/v3/writer.ts +419 -0
- package/src/core/governor/index.ts +3 -0
- package/src/core/governor/plan-api.ts +10 -2
- package/src/core/governor/read.ts +3 -0
- package/src/core/governor/state.ts +52 -5
- package/src/core/guard/config.ts +206 -0
- package/src/core/guard/coordinator.ts +227 -0
- package/src/core/guard/evaluator.ts +343 -0
- package/src/core/guard/evidence-v3.ts +227 -0
- package/src/core/guard/index.ts +35 -0
- package/src/core/guard/live-source-v3.ts +204 -0
- package/src/core/guard/storage.ts +188 -0
- package/src/core/guard/types.ts +152 -0
- package/src/core/hooks/adapter/detect.ts +28 -1
- package/src/core/hooks/adapter/events.ts +14 -6
- package/src/core/hooks/adapter/output.ts +7 -2
- package/src/core/hooks/adapter/parse.ts +80 -38
- package/src/core/hooks/adapter/wiring.ts +119 -13
- package/src/core/hooks/cli.ts +351 -466
- package/src/core/hooks/effects/image-capture.ts +228 -238
- package/src/core/hooks/effects/index.ts +1 -36
- package/src/core/hooks/events/input-hash.ts +47 -0
- package/src/core/hooks/index.ts +4 -11
- package/src/core/hooks/resolve/coord-root.ts +1 -1
- package/src/core/hooks/resolve/owner.ts +52 -45
- package/src/core/hooks/resolve/transcript.ts +165 -14
- package/src/core/hooks/session-name-presence.ts +14 -15
- package/src/core/hooks/unsafe-cross-shell.ts +1 -1
- package/src/core/journal/index.ts +15 -22
- package/src/core/presence/blob.ts +48 -41
- package/src/core/presence/codec-digest.ts +215 -0
- package/src/core/presence/relay-client.ts +5 -5
- package/src/core/work/index.ts +3 -0
- package/src/core/work/read.ts +3 -0
- package/src/core/work/runner.ts +6 -0
- package/src/core/work/state.ts +27 -3
- package/src/core/workflow/engine.ts +24 -24
- package/src/core/workflow/live-session-v3.ts +126 -0
- package/src/core/workflow/scope-id.ts +6 -0
- package/src/core/workflow/workspaces/leases.ts +56 -19
- package/src/index.ts +1 -1
- package/src/lib/browser/client.ts +230 -0
- package/src/lib/browser/critique.ts +104 -27
- package/src/lib/browser/geometry.ts +143 -14
- package/src/lib/browser/index.ts +34 -0
- package/src/lib/browser/qa-plan.ts +501 -0
- package/src/lib/browser/qa-reuse.ts +306 -0
- package/src/lib/browser/qa-snapshot.ts +223 -0
- package/src/lib/browser/runts.ts +27 -2
- package/src/lib/browser/tiling.ts +164 -0
- package/src/lib/claude-desktop.ts +1 -232
- package/src/lib/context/index.ts +22 -46
- package/src/lib/council/index.ts +9 -21
- package/src/lib/docs-frontmatter.ts +8 -79
- package/src/lib/docs-index.ts +33 -3
- package/src/lib/docs-lint.ts +15 -29
- package/src/lib/docs-metadata-audit.ts +166 -0
- package/src/lib/docs-metadata-managed.ts +83 -0
- package/src/lib/docs-metadata-sync.ts +262 -0
- package/src/lib/docs-metadata-v2-schema.ts +138 -0
- package/src/lib/docs-metadata-v2.ts +646 -0
- package/src/lib/docs-new.ts +63 -0
- package/src/lib/docs-sweep.ts +42 -28
- package/src/lib/headless/index.ts +287 -0
- package/src/lib/identities/assume.ts +67 -86
- package/src/lib/instructions/apply.ts +33 -20
- package/src/lib/instructions/bundle.ts +2 -2
- package/src/lib/instructions/splice.ts +21 -7
- package/src/lib/instructions/templates.ts +85 -13
- package/dist/core/agents/cli-emit.d.ts +0 -27
- package/dist/core/agents/cli-emit.d.ts.map +0 -1
- package/dist/core/agents/cli-emit.js +0 -57
- package/dist/core/agents/codex-replay.d.ts +0 -29
- package/dist/core/agents/codex-replay.d.ts.map +0 -1
- package/dist/core/agents/codex-replay.js +0 -138
- package/dist/core/agents/events/consume.d.ts +0 -82
- package/dist/core/agents/events/consume.d.ts.map +0 -1
- package/dist/core/agents/events/consume.js +0 -195
- package/dist/core/agents/events/emit.d.ts +0 -42
- package/dist/core/agents/events/emit.d.ts.map +0 -1
- package/dist/core/agents/events/emit.js +0 -75
- package/dist/core/agents/events/ulid.d.ts +0 -11
- package/dist/core/agents/events/ulid.d.ts.map +0 -1
- package/dist/core/agents/events/ulid.js +0 -47
- package/dist/core/agents/state/heartbeat-projector.d.ts +0 -76
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +0 -1
- package/dist/core/agents/state/heartbeat-projector.js +0 -581
- package/dist/core/hooks/events/emit.d.ts +0 -31
- package/dist/core/hooks/events/emit.d.ts.map +0 -1
- package/dist/core/hooks/events/emit.js +0 -93
- package/dist/core/hooks/events/rotate.d.ts +0 -43
- package/dist/core/hooks/events/rotate.d.ts.map +0 -1
- package/dist/core/hooks/events/rotate.js +0 -142
- package/dist/core/hooks/events/schema.d.ts +0 -341
- package/dist/core/hooks/events/schema.d.ts.map +0 -1
- package/dist/core/hooks/events/schema.js +0 -12
- package/dist/core/hooks/events/ulid.d.ts +0 -10
- package/dist/core/hooks/events/ulid.d.ts.map +0 -1
- package/dist/core/hooks/events/ulid.js +0 -47
- package/dist/lib/docs-frontmatter-migrate.d.ts +0 -33
- package/dist/lib/docs-frontmatter-migrate.d.ts.map +0 -1
- package/dist/lib/docs-frontmatter-migrate.js +0 -364
- package/src/core/agents/cli-emit.ts +0 -64
- package/src/core/agents/codex-replay.ts +0 -163
- package/src/core/agents/events/consume.ts +0 -254
- package/src/core/agents/events/emit.ts +0 -115
- package/src/core/agents/events/ulid.ts +0 -51
- package/src/core/agents/state/heartbeat-projector.ts +0 -645
- package/src/core/hooks/events/emit.ts +0 -125
- package/src/core/hooks/events/rotate.ts +0 -151
- package/src/core/hooks/events/schema.ts +0 -582
- package/src/core/hooks/events/ulid.ts +0 -51
- package/src/lib/docs-frontmatter-migrate.ts +0 -427
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type EventV3,
|
|
3
|
+
type ReadLedgerV3Result,
|
|
4
|
+
readEventV3ControlState,
|
|
5
|
+
readLedgerV3,
|
|
6
|
+
reduceSafetyProjectionV3,
|
|
7
|
+
} from "../events/v3/index.ts";
|
|
8
|
+
import {
|
|
9
|
+
isRunQualityCorpusCategoryV3,
|
|
10
|
+
normalizeRunQualityEventV3,
|
|
11
|
+
normalizeRunQualityPairingV3,
|
|
12
|
+
} from "./evidence-v3.ts";
|
|
13
|
+
import type {
|
|
14
|
+
RunQualityCorpusCategoryV3,
|
|
15
|
+
RunQualityEvidenceEvent,
|
|
16
|
+
RunQualityRoleWait,
|
|
17
|
+
} from "./types.ts";
|
|
18
|
+
|
|
19
|
+
export type RunQualityLiveEpochStateV3 = "candidate" | "active";
|
|
20
|
+
|
|
21
|
+
export interface RunQualityLiveGenerationV3 {
|
|
22
|
+
instance_id: string;
|
|
23
|
+
session_id: string;
|
|
24
|
+
generation_id: string;
|
|
25
|
+
adapter: string;
|
|
26
|
+
events: RunQualityEvidenceEvent[];
|
|
27
|
+
corpus_categories: RunQualityCorpusCategoryV3[];
|
|
28
|
+
role_wait: RunQualityRoleWait;
|
|
29
|
+
evidence: {
|
|
30
|
+
first_event_id?: string;
|
|
31
|
+
last_event_id?: string;
|
|
32
|
+
window_started_at?: string;
|
|
33
|
+
window_ended_at?: string;
|
|
34
|
+
segment: string;
|
|
35
|
+
truncated: boolean;
|
|
36
|
+
};
|
|
37
|
+
sufficient_history: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface RunQualityLiveSourceV3 {
|
|
41
|
+
contract_major: 3;
|
|
42
|
+
genesis_id: string;
|
|
43
|
+
epoch_state: RunQualityLiveEpochStateV3;
|
|
44
|
+
generations: RunQualityLiveGenerationV3[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class RunQualityLiveSourceV3Error extends Error {
|
|
48
|
+
constructor(
|
|
49
|
+
public readonly code: "control_not_ready" | "ledger_integrity_failure",
|
|
50
|
+
public readonly details: string[],
|
|
51
|
+
) {
|
|
52
|
+
super(`run_quality_live_v3:${code}:${details.join(",")}`);
|
|
53
|
+
this.name = "RunQualityLiveSourceV3Error";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Read live advisory inputs from the validated V3 ledger. Candidate epochs are
|
|
59
|
+
* observable here for rehearsal, but corpus eligibility remains active-only.
|
|
60
|
+
*/
|
|
61
|
+
export function readRunQualityLiveSourceV3(
|
|
62
|
+
coordRoot: string,
|
|
63
|
+
now: Date = new Date(),
|
|
64
|
+
): RunQualityLiveSourceV3 {
|
|
65
|
+
const control = readEventV3ControlState(coordRoot);
|
|
66
|
+
if (control.state !== "candidate" && control.state !== "active") {
|
|
67
|
+
throw new RunQualityLiveSourceV3Error("control_not_ready", [
|
|
68
|
+
control.state,
|
|
69
|
+
"reason" in control ? control.reason : "unknown",
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
return projectRunQualityLiveSourceV3(
|
|
73
|
+
readLedgerV3(coordRoot),
|
|
74
|
+
control.genesis.event.payload.genesis_id,
|
|
75
|
+
control.state,
|
|
76
|
+
now,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Pure projection used by the live coordinator and replay-equivalence tests. */
|
|
81
|
+
export function projectRunQualityLiveSourceV3(
|
|
82
|
+
read: ReadLedgerV3Result,
|
|
83
|
+
genesisId: string,
|
|
84
|
+
epochState: RunQualityLiveEpochStateV3,
|
|
85
|
+
now: Date,
|
|
86
|
+
): RunQualityLiveSourceV3 {
|
|
87
|
+
if (!read.complete) {
|
|
88
|
+
throw new RunQualityLiveSourceV3Error("ledger_integrity_failure", [
|
|
89
|
+
...new Set(read.diagnostics.map(({ code }) => code)),
|
|
90
|
+
]);
|
|
91
|
+
}
|
|
92
|
+
const safety = reduceSafetyProjectionV3(read);
|
|
93
|
+
const generations: RunQualityLiveGenerationV3[] = [];
|
|
94
|
+
for (const state of Object.values(safety.generations)) {
|
|
95
|
+
if (state.phase !== "live") continue;
|
|
96
|
+
const positioned = read.events.filter(
|
|
97
|
+
({ event }) =>
|
|
98
|
+
"generation_id" in event.scope && event.scope.generation_id === state.generation_id,
|
|
99
|
+
);
|
|
100
|
+
const started = positioned.find(({ event }) => event.event_type === "session.started")?.event;
|
|
101
|
+
if (started?.event_type !== "session.started") continue;
|
|
102
|
+
const prior = new Map<string, EventV3>();
|
|
103
|
+
const evidenceEvents: RunQualityEvidenceEvent[] = [];
|
|
104
|
+
const corpusCategories = new Set<RunQualityCorpusCategoryV3>();
|
|
105
|
+
for (const { event } of positioned) {
|
|
106
|
+
for (const normalized of normalizeRunQualityEventV3(event, prior)) {
|
|
107
|
+
if (isRunQualityCorpusCategoryV3(normalized.kind)) corpusCategories.add(normalized.kind);
|
|
108
|
+
else evidenceEvents.push(normalized);
|
|
109
|
+
}
|
|
110
|
+
prior.set(event.event_id, event);
|
|
111
|
+
}
|
|
112
|
+
for (const marker of normalizeRunQualityPairingV3(positioned.map(({ event }) => event))) {
|
|
113
|
+
if (isRunQualityCorpusCategoryV3(marker.kind)) corpusCategories.add(marker.kind);
|
|
114
|
+
}
|
|
115
|
+
const first = evidenceEvents[0];
|
|
116
|
+
const last = evidenceEvents.at(-1);
|
|
117
|
+
const lastPosition = positioned.at(-1)?.position;
|
|
118
|
+
const diagnostic = safety.diagnostics.some(
|
|
119
|
+
(entry) => entry.generation_id === state.generation_id && entry.authority_blocking,
|
|
120
|
+
);
|
|
121
|
+
generations.push({
|
|
122
|
+
instance_id: state.instance_id,
|
|
123
|
+
session_id: state.session_id,
|
|
124
|
+
generation_id: state.generation_id,
|
|
125
|
+
adapter: observedAdapter(started),
|
|
126
|
+
events: evidenceEvents,
|
|
127
|
+
corpus_categories: [...corpusCategories].sort(),
|
|
128
|
+
role_wait: roleWait(state.waits, state.started_at, now),
|
|
129
|
+
evidence: {
|
|
130
|
+
first_event_id: first?.event_id,
|
|
131
|
+
last_event_id: last?.event_id,
|
|
132
|
+
window_started_at: first?.ts,
|
|
133
|
+
window_ended_at: last?.ts,
|
|
134
|
+
segment: `v3:${lastPosition?.segment_ordinal ?? 0}`,
|
|
135
|
+
truncated: diagnostic,
|
|
136
|
+
},
|
|
137
|
+
sufficient_history: !diagnostic,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
generations.sort((left, right) => left.generation_id.localeCompare(right.generation_id));
|
|
141
|
+
return { contract_major: 3, genesis_id: genesisId, epoch_state: epochState, generations };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function observedAdapter(event: Extract<EventV3, { event_type: "session.started" }>): string {
|
|
145
|
+
const adapter = event.payload.runtime_attestation.adapter;
|
|
146
|
+
return adapter.state === "observed" ? adapter.value.id : "unknown";
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function roleWait(
|
|
150
|
+
waits: Record<
|
|
151
|
+
string,
|
|
152
|
+
{
|
|
153
|
+
wait_id: string;
|
|
154
|
+
kind: string;
|
|
155
|
+
started_at: string;
|
|
156
|
+
wake_at?: string;
|
|
157
|
+
}
|
|
158
|
+
>,
|
|
159
|
+
generationStartedAt: string,
|
|
160
|
+
now: Date,
|
|
161
|
+
): RunQualityRoleWait {
|
|
162
|
+
const current = Object.values(waits).sort((left, right) =>
|
|
163
|
+
left.started_at.localeCompare(right.started_at),
|
|
164
|
+
);
|
|
165
|
+
if (current.length === 0) {
|
|
166
|
+
return {
|
|
167
|
+
role: "agent",
|
|
168
|
+
wait_kind: "none",
|
|
169
|
+
source: "event_v3",
|
|
170
|
+
observed_at: generationStartedAt,
|
|
171
|
+
fresh: false,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const latest = current.at(-1)!;
|
|
175
|
+
const scheduledExpired =
|
|
176
|
+
latest.kind === "scheduled" &&
|
|
177
|
+
latest.wake_at !== undefined &&
|
|
178
|
+
Date.parse(latest.wake_at) <= now.getTime();
|
|
179
|
+
return {
|
|
180
|
+
role: "agent",
|
|
181
|
+
wait_kind: current.length > 1 ? "unknown" : waitKind(latest.kind),
|
|
182
|
+
source: "event_v3",
|
|
183
|
+
observed_at: latest.started_at,
|
|
184
|
+
fresh: !scheduledExpired,
|
|
185
|
+
record_id: latest.wait_id,
|
|
186
|
+
wake_at: latest.wake_at,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function waitKind(kind: string): RunQualityRoleWait["wait_kind"] {
|
|
191
|
+
switch (kind) {
|
|
192
|
+
case "operator_input":
|
|
193
|
+
return "needs_input";
|
|
194
|
+
case "decision":
|
|
195
|
+
return "decision";
|
|
196
|
+
case "permission":
|
|
197
|
+
case "approval":
|
|
198
|
+
return "approval";
|
|
199
|
+
case "scheduled":
|
|
200
|
+
return "scheduled";
|
|
201
|
+
default:
|
|
202
|
+
return "unknown";
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import {
|
|
3
|
+
closeSync,
|
|
4
|
+
existsSync,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
openSync,
|
|
7
|
+
readdirSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
renameSync,
|
|
10
|
+
statSync,
|
|
11
|
+
unlinkSync,
|
|
12
|
+
writeFileSync,
|
|
13
|
+
} from "node:fs";
|
|
14
|
+
import { dirname, join } from "node:path";
|
|
15
|
+
import type { RunQualitySnapshot } from "./types.ts";
|
|
16
|
+
|
|
17
|
+
export interface GuardCursor {
|
|
18
|
+
schema_version: 1;
|
|
19
|
+
segment: string;
|
|
20
|
+
last_event_id?: string;
|
|
21
|
+
next_eligible_at: string;
|
|
22
|
+
config_digest: string;
|
|
23
|
+
updated_at: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface EvaluationLock {
|
|
27
|
+
pid: number;
|
|
28
|
+
acquired_at: string;
|
|
29
|
+
nonce: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function guardDir(coordRoot: string): string {
|
|
33
|
+
return join(coordRoot, ".harnery", "guard");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function snapshotPath(coordRoot: string, instanceId: string): string {
|
|
37
|
+
return join(guardDir(coordRoot), `${instanceId}.json`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function readRunQualitySnapshot(
|
|
41
|
+
coordRoot: string,
|
|
42
|
+
instanceId: string,
|
|
43
|
+
): RunQualitySnapshot | null {
|
|
44
|
+
return readBoundedJson<RunQualitySnapshot>(snapshotPath(coordRoot, instanceId), 1024 * 1024);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function readFreshRunQualitySnapshot(
|
|
48
|
+
coordRoot: string,
|
|
49
|
+
instanceId: string,
|
|
50
|
+
now: Date = new Date(),
|
|
51
|
+
): RunQualitySnapshot | null {
|
|
52
|
+
const snapshot = readRunQualitySnapshot(coordRoot, instanceId);
|
|
53
|
+
return snapshot && Date.parse(snapshot.expires_at) > now.getTime() ? snapshot : null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function readGuardCursor(coordRoot: string): GuardCursor | null {
|
|
57
|
+
return readBoundedJson<GuardCursor>(join(guardDir(coordRoot), "cursor.json"), 64 * 1024);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function writeGuardCursor(coordRoot: string, cursor: GuardCursor, nonce: string): void {
|
|
61
|
+
writeAtomicJson(join(guardDir(coordRoot), "cursor.json"), cursor, nonce, () =>
|
|
62
|
+
evaluationLockOwned(coordRoot, nonce),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function writeRunQualitySnapshot(
|
|
67
|
+
coordRoot: string,
|
|
68
|
+
snapshot: RunQualitySnapshot,
|
|
69
|
+
nonce: string,
|
|
70
|
+
): void {
|
|
71
|
+
writeAtomicJson(snapshotPath(coordRoot, snapshot.instance_id), snapshot, nonce, () =>
|
|
72
|
+
evaluationLockOwned(coordRoot, nonce),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function acquireEvaluationLock(
|
|
77
|
+
coordRoot: string,
|
|
78
|
+
now: Date,
|
|
79
|
+
staleSeconds: number,
|
|
80
|
+
): EvaluationLock | null {
|
|
81
|
+
const path = join(guardDir(coordRoot), "evaluate.lock");
|
|
82
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
83
|
+
const lock: EvaluationLock = {
|
|
84
|
+
pid: process.pid,
|
|
85
|
+
acquired_at: now.toISOString(),
|
|
86
|
+
nonce: randomUUID(),
|
|
87
|
+
};
|
|
88
|
+
if (createExclusive(path, lock)) return lock;
|
|
89
|
+
const existing = readBoundedJson<EvaluationLock>(path, 16 * 1024);
|
|
90
|
+
const age = existing
|
|
91
|
+
? now.getTime() - Date.parse(existing.acquired_at)
|
|
92
|
+
: Number.POSITIVE_INFINITY;
|
|
93
|
+
if (existing && processAlive(existing.pid) && age <= staleSeconds * 1000) return null;
|
|
94
|
+
try {
|
|
95
|
+
unlinkSync(path);
|
|
96
|
+
} catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return createExclusive(path, lock) ? lock : null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function evaluationLockOwned(coordRoot: string, nonce: string): boolean {
|
|
103
|
+
return (
|
|
104
|
+
readBoundedJson<EvaluationLock>(join(guardDir(coordRoot), "evaluate.lock"), 16 * 1024)
|
|
105
|
+
?.nonce === nonce
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function releaseEvaluationLock(coordRoot: string, nonce: string): void {
|
|
110
|
+
const path = join(guardDir(coordRoot), "evaluate.lock");
|
|
111
|
+
if (!evaluationLockOwned(coordRoot, nonce)) return;
|
|
112
|
+
try {
|
|
113
|
+
unlinkSync(path);
|
|
114
|
+
} catch {
|
|
115
|
+
// A replacement owner won the race; nonce ownership already prevents removal.
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function cleanupOrphanSnapshots(coordRoot: string, liveIds: Set<string>): void {
|
|
120
|
+
const dir = guardDir(coordRoot);
|
|
121
|
+
if (!existsSync(dir)) return;
|
|
122
|
+
for (const name of readdirSync(dir)) {
|
|
123
|
+
if (!name.endsWith(".json") || name === "cursor.json" || name === "config-invalid.json")
|
|
124
|
+
continue;
|
|
125
|
+
const instanceId = name.slice(0, -5);
|
|
126
|
+
if (liveIds.has(instanceId)) continue;
|
|
127
|
+
try {
|
|
128
|
+
unlinkSync(join(dir, name));
|
|
129
|
+
} catch {
|
|
130
|
+
// Cleanup is advisory and retries on the next evaluation.
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function writeAtomicJson(
|
|
136
|
+
path: string,
|
|
137
|
+
value: unknown,
|
|
138
|
+
nonce: string,
|
|
139
|
+
beforeRename?: () => boolean,
|
|
140
|
+
): void {
|
|
141
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
142
|
+
const temporary = `${path}.tmp-${process.pid}-${nonce}`;
|
|
143
|
+
try {
|
|
144
|
+
writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`, {
|
|
145
|
+
encoding: "utf8",
|
|
146
|
+
mode: 0o600,
|
|
147
|
+
});
|
|
148
|
+
if (beforeRename && !beforeRename()) throw new Error("run_quality_lock_stolen");
|
|
149
|
+
renameSync(temporary, path);
|
|
150
|
+
} finally {
|
|
151
|
+
if (existsSync(temporary)) unlinkSync(temporary);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function createExclusive(path: string, value: EvaluationLock): boolean {
|
|
156
|
+
let fd: number | undefined;
|
|
157
|
+
try {
|
|
158
|
+
fd = openSync(path, "wx", 0o600);
|
|
159
|
+
writeFileSync(fd, `${JSON.stringify(value)}\n`, "utf8");
|
|
160
|
+
return true;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
|
|
163
|
+
return false;
|
|
164
|
+
} finally {
|
|
165
|
+
if (fd !== undefined) closeSync(fd);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function processAlive(pid: number): boolean {
|
|
170
|
+
if (!Number.isSafeInteger(pid) || pid < 1) return false;
|
|
171
|
+
try {
|
|
172
|
+
process.kill(pid, 0);
|
|
173
|
+
return true;
|
|
174
|
+
} catch (error) {
|
|
175
|
+
return (error as NodeJS.ErrnoException).code === "EPERM";
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function readBoundedJson<T>(path: string, maxBytes: number): T | null {
|
|
180
|
+
if (!existsSync(path)) return null;
|
|
181
|
+
try {
|
|
182
|
+
const size = statSync(path).size;
|
|
183
|
+
if (size <= 0 || size > maxBytes) return null;
|
|
184
|
+
return JSON.parse(readFileSync(path, "utf8")) as T;
|
|
185
|
+
} catch {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export const RUN_QUALITY_SCHEMA_VERSION = 1 as const;
|
|
2
|
+
|
|
3
|
+
export type RunQualityMode = "off" | "shadow" | "report";
|
|
4
|
+
export type RunQualityStatus = "unknown" | "healthy" | "attention" | "critical";
|
|
5
|
+
export type RunQualitySignalState = "inactive" | "active" | "unknown" | "suppressed";
|
|
6
|
+
export type RunQualityWaitKind =
|
|
7
|
+
| "none"
|
|
8
|
+
| "needs_input"
|
|
9
|
+
| "decision"
|
|
10
|
+
| "approval"
|
|
11
|
+
| "scheduled"
|
|
12
|
+
| "unknown";
|
|
13
|
+
|
|
14
|
+
export interface RunQualityThresholds {
|
|
15
|
+
repeated_tool_calls: number;
|
|
16
|
+
consecutive_failures: number;
|
|
17
|
+
context_growth_per_minute: number;
|
|
18
|
+
compaction_grace_seconds: number;
|
|
19
|
+
no_progress_evaluations: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RunQualityConfig {
|
|
23
|
+
mode: RunQualityMode;
|
|
24
|
+
evaluation_interval_seconds: number;
|
|
25
|
+
snapshot_ttl_seconds: number;
|
|
26
|
+
max_tail_bytes: number;
|
|
27
|
+
evaluation_timeout_seconds: number;
|
|
28
|
+
lock_stale_seconds: number;
|
|
29
|
+
supervised_roots_per_sweep: number;
|
|
30
|
+
thresholds: RunQualityThresholds;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface RunQualityConfigResult {
|
|
34
|
+
config: RunQualityConfig | null;
|
|
35
|
+
digest: string;
|
|
36
|
+
valid: boolean;
|
|
37
|
+
requested_mode: RunQualityMode;
|
|
38
|
+
reason_codes: string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface RunQualityRoleWait {
|
|
42
|
+
role: string;
|
|
43
|
+
wait_kind: RunQualityWaitKind;
|
|
44
|
+
source: string;
|
|
45
|
+
observed_at: string;
|
|
46
|
+
fresh: boolean;
|
|
47
|
+
record_id?: string;
|
|
48
|
+
wake_at?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type RunQualityEvidenceKind =
|
|
52
|
+
| "tool_call"
|
|
53
|
+
| "tool_success"
|
|
54
|
+
| "tool_failure"
|
|
55
|
+
| "tool_pairing_incomplete"
|
|
56
|
+
| "command_pairing_incomplete"
|
|
57
|
+
| "recovered_terminal"
|
|
58
|
+
| "context_sample"
|
|
59
|
+
| "progress"
|
|
60
|
+
| "compaction_started"
|
|
61
|
+
| "compaction_completed";
|
|
62
|
+
|
|
63
|
+
export type RunQualityCorpusCategoryV3 = Extract<
|
|
64
|
+
RunQualityEvidenceKind,
|
|
65
|
+
"tool_pairing_incomplete" | "command_pairing_incomplete" | "recovered_terminal"
|
|
66
|
+
>;
|
|
67
|
+
|
|
68
|
+
export interface RunQualityEvidenceEvent {
|
|
69
|
+
event_id: string;
|
|
70
|
+
ts: string;
|
|
71
|
+
kind: RunQualityEvidenceKind;
|
|
72
|
+
input_hash?: string;
|
|
73
|
+
target_hash?: string;
|
|
74
|
+
used_tokens?: number;
|
|
75
|
+
confidence?: "exact" | "reported" | "estimated";
|
|
76
|
+
telemetry_source?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface RunQualitySignal {
|
|
80
|
+
id:
|
|
81
|
+
| "repeated_tool_calls"
|
|
82
|
+
| "consecutive_failures"
|
|
83
|
+
| "context_growth"
|
|
84
|
+
| "target_stagnation"
|
|
85
|
+
| "no_progress"
|
|
86
|
+
| "compaction_grace";
|
|
87
|
+
state: RunQualitySignalState;
|
|
88
|
+
severity: "none" | "attention" | "critical";
|
|
89
|
+
count: number;
|
|
90
|
+
reason_code: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface RunQualityEvaluatorState {
|
|
94
|
+
repeated_hash?: string;
|
|
95
|
+
repeated_count: number;
|
|
96
|
+
exact_hash_seen: boolean;
|
|
97
|
+
missing_hash_seen: boolean;
|
|
98
|
+
target_hash?: string;
|
|
99
|
+
target_streak: number;
|
|
100
|
+
target_hash_seen: boolean;
|
|
101
|
+
failure_streak: number;
|
|
102
|
+
work_since_progress: number;
|
|
103
|
+
last_context?: { used_tokens: number; ts: string };
|
|
104
|
+
context_growth_per_minute?: number;
|
|
105
|
+
no_progress_epochs: number;
|
|
106
|
+
no_progress_deadline_epochs: number;
|
|
107
|
+
compaction_grace_until?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface RunQualitySnapshot {
|
|
111
|
+
schema_version: typeof RUN_QUALITY_SCHEMA_VERSION;
|
|
112
|
+
instance_id: string;
|
|
113
|
+
session_id: string;
|
|
114
|
+
session_generation: string;
|
|
115
|
+
adapter: string;
|
|
116
|
+
config_digest: string;
|
|
117
|
+
mode: Exclude<RunQualityMode, "off">;
|
|
118
|
+
status: RunQualityStatus;
|
|
119
|
+
previous_status: RunQualityStatus;
|
|
120
|
+
evaluated_at: string;
|
|
121
|
+
next_eligible_at: string;
|
|
122
|
+
expires_at: string;
|
|
123
|
+
evidence: {
|
|
124
|
+
first_event_id?: string;
|
|
125
|
+
last_event_id?: string;
|
|
126
|
+
window_started_at?: string;
|
|
127
|
+
window_ended_at?: string;
|
|
128
|
+
segment: string;
|
|
129
|
+
truncated: boolean;
|
|
130
|
+
};
|
|
131
|
+
signals: RunQualitySignal[];
|
|
132
|
+
role_wait: RunQualityRoleWait;
|
|
133
|
+
state: RunQualityEvaluatorState;
|
|
134
|
+
epoch: "evidence" | "deadline" | "read";
|
|
135
|
+
reason: "evidence" | "deadline" | "config_changed" | "insufficient_evidence";
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface EvaluateRunQualityInput {
|
|
139
|
+
instance_id: string;
|
|
140
|
+
session_id: string;
|
|
141
|
+
session_generation: string;
|
|
142
|
+
adapter: string;
|
|
143
|
+
now: string;
|
|
144
|
+
config: RunQualityConfig;
|
|
145
|
+
config_digest: string;
|
|
146
|
+
events: RunQualityEvidenceEvent[];
|
|
147
|
+
previous?: RunQualitySnapshot;
|
|
148
|
+
role_wait: RunQualityRoleWait;
|
|
149
|
+
evidence: RunQualitySnapshot["evidence"];
|
|
150
|
+
sufficient_history: boolean;
|
|
151
|
+
live: boolean;
|
|
152
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { coordEnv } from "../../../lib/env.ts";
|
|
2
|
-
import type { Adapter } from "
|
|
2
|
+
import type { Adapter } from "../../adapter.ts";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Resolve the adapter firing the hook. The dispatcher binary is always
|
|
@@ -24,3 +24,30 @@ function validate(v: string | undefined): Adapter | null {
|
|
|
24
24
|
if (v === "claude-code" || v === "cursor" || v === "codex") return v;
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* On a host wired for multiple adapters, Cursor also executes the Claude Code
|
|
30
|
+
* project hooks, piping them the same payload as its own hooks. Recording that
|
|
31
|
+
* stray `--adapter claude-code` dispatch mints a twin generation for the same
|
|
32
|
+
* instance (plus a stream of missing_session_start diagnostics), so the hook
|
|
33
|
+
* CLI skips it entirely.
|
|
34
|
+
*
|
|
35
|
+
* Detection reads the payload, not the environment: every hook payload Cursor
|
|
36
|
+
* emits carries a top-level `cursor_version` string (its dispatch envelope),
|
|
37
|
+
* and no Claude Code payload does. Environment sniffing cannot make this call
|
|
38
|
+
* in either direction — Cursor's own hook processes do not carry CURSOR_AGENT
|
|
39
|
+
* (only its agent tool shells do), and a genuine Claude Code session nested
|
|
40
|
+
* under a Cursor agent shell inherits Cursor-flavored variables it must not
|
|
41
|
+
* be skipped for. The check is the top-level key only: a Claude Code payload
|
|
42
|
+
* whose tool_input merely mentions the string must not match.
|
|
43
|
+
*/
|
|
44
|
+
export function shouldSkipHookAdapter(adapter: Adapter | null, rawPayload: string): boolean {
|
|
45
|
+
if (adapter !== "claude-code") return false;
|
|
46
|
+
if (!rawPayload || rawPayload.trim().length === 0) return false;
|
|
47
|
+
try {
|
|
48
|
+
const json = JSON.parse(rawPayload) as Record<string, unknown>;
|
|
49
|
+
return typeof json.cursor_version === "string" && json.cursor_version.length > 0;
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* Codex `.codex/hooks.json`).
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
export type { Adapter as AdapterId } from "
|
|
12
|
+
export type { Adapter as AdapterId } from "../../adapter.ts";
|
|
13
13
|
|
|
14
|
-
import type { Adapter as AdapterId } from "
|
|
14
|
+
import type { Adapter as AdapterId } from "../../adapter.ts";
|
|
15
15
|
|
|
16
16
|
export interface HookEvent {
|
|
17
17
|
/** Key under the adapter settings file's `hooks` map (e.g. `SessionStart`, `preToolUse`). */
|
|
@@ -55,6 +55,7 @@ export interface AdapterSpec {
|
|
|
55
55
|
export const CLAUDE_CODE_EVENTS: HookEvent[] = [
|
|
56
56
|
{ settingsKey: "SessionStart", subcommand: "session-start" },
|
|
57
57
|
{ settingsKey: "UserPromptSubmit", subcommand: "user-prompt-submit" },
|
|
58
|
+
{ settingsKey: "PermissionRequest", subcommand: "permission-request" },
|
|
58
59
|
{ settingsKey: "Stop", subcommand: "stop" },
|
|
59
60
|
{ settingsKey: "StopFailure", subcommand: "stop-failure" },
|
|
60
61
|
{ settingsKey: "SessionEnd", subcommand: "session-end" },
|
|
@@ -64,22 +65,28 @@ export const CLAUDE_CODE_EVENTS: HookEvent[] = [
|
|
|
64
65
|
{ settingsKey: "PostToolUse", subcommand: "post-tool-use" },
|
|
65
66
|
{ settingsKey: "PostToolUseFailure", subcommand: "post-tool-use-failure" },
|
|
66
67
|
{ settingsKey: "PreCompact", subcommand: "pre-compact" },
|
|
68
|
+
{ settingsKey: "PostCompact", subcommand: "post-compact" },
|
|
67
69
|
];
|
|
68
70
|
|
|
69
71
|
/**
|
|
70
72
|
* Cursor: `.cursor/hooks.json`. camelCase event keys; flat `{ command }` entries;
|
|
71
|
-
* no `StopFailure` event
|
|
73
|
+
* no `StopFailure` event. Generic tool hooks remain useful in the IDE, while
|
|
74
|
+
* shell-specific hooks are also installed because remote/CLI modes do not
|
|
75
|
+
* dispatch generic tool hooks consistently. V3 deduplicates overlapping shell
|
|
76
|
+
* deliveries by a private command fingerprint.
|
|
72
77
|
*/
|
|
73
78
|
export const CURSOR_EVENTS: HookEvent[] = [
|
|
74
79
|
{ settingsKey: "sessionStart", subcommand: "session-start" },
|
|
75
80
|
{ settingsKey: "sessionEnd", subcommand: "session-end" },
|
|
76
81
|
{ settingsKey: "preToolUse", subcommand: "pre-tool-use" },
|
|
77
|
-
{ settingsKey: "beforeShellExecution", subcommand: "before-shell-execution" },
|
|
78
82
|
{ settingsKey: "postToolUse", subcommand: "post-tool-use" },
|
|
79
83
|
{ settingsKey: "postToolUseFailure", subcommand: "post-tool-use-failure" },
|
|
84
|
+
{ settingsKey: "beforeShellExecution", subcommand: "before-shell-execution" },
|
|
85
|
+
{ settingsKey: "afterShellExecution", subcommand: "after-shell-execution" },
|
|
80
86
|
{ settingsKey: "subagentStart", subcommand: "sub-agent-start" },
|
|
81
87
|
{ settingsKey: "subagentStop", subcommand: "sub-agent-stop" },
|
|
82
88
|
{ settingsKey: "beforeSubmitPrompt", subcommand: "user-prompt-submit" },
|
|
89
|
+
{ settingsKey: "preCompact", subcommand: "pre-compact" },
|
|
83
90
|
{ settingsKey: "stop", subcommand: "stop" },
|
|
84
91
|
];
|
|
85
92
|
|
|
@@ -95,16 +102,16 @@ export const CODEX_EVENTS: HookEvent[] = [
|
|
|
95
102
|
{ settingsKey: "PreCompact", subcommand: "pre-compact" },
|
|
96
103
|
{ settingsKey: "PostCompact", subcommand: "post-compact" },
|
|
97
104
|
{ settingsKey: "Stop", subcommand: "stop" },
|
|
105
|
+
{ settingsKey: "SessionEnd", subcommand: "session-end" },
|
|
98
106
|
];
|
|
99
107
|
|
|
100
108
|
/** Entries written by harnery before Codex adopted a strict native hook schema. */
|
|
101
109
|
export const LEGACY_CODEX_EVENTS: HookEvent[] = [
|
|
102
|
-
{ settingsKey: "SessionEnd", subcommand: "session-end" },
|
|
103
110
|
{ settingsKey: "PostToolUseFailure", subcommand: "post-tool-use-failure" },
|
|
104
111
|
{ settingsKey: "StopFailure", subcommand: "stop-failure" },
|
|
105
112
|
];
|
|
106
113
|
|
|
107
|
-
/** Every hook key accepted by Codex
|
|
114
|
+
/** Every hook key accepted by Codex's current native hook schema. */
|
|
108
115
|
export const CODEX_ALLOWED_EVENT_KEYS = [
|
|
109
116
|
"SessionStart",
|
|
110
117
|
"PreToolUse",
|
|
@@ -116,6 +123,7 @@ export const CODEX_ALLOWED_EVENT_KEYS = [
|
|
|
116
123
|
"SubagentStart",
|
|
117
124
|
"SubagentStop",
|
|
118
125
|
"Stop",
|
|
126
|
+
"SessionEnd",
|
|
119
127
|
];
|
|
120
128
|
|
|
121
129
|
/** Every supported adapter, fully wireable by `harn init`. */
|
|
@@ -18,11 +18,16 @@
|
|
|
18
18
|
* fire-and-forget. Empty text → no-op (no JSON written).
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
import type { Adapter } from "../../adapter.ts";
|
|
21
22
|
import { STOP_REMEDIATION_MARKER } from "../../agents/rules/stop-hook.ts";
|
|
22
23
|
import { endOfTurnStatusCommand, resolveBinName } from "../../config.ts";
|
|
23
|
-
import type { Adapter } from "../events/schema.ts";
|
|
24
24
|
|
|
25
|
-
export type SystemEvent =
|
|
25
|
+
export type SystemEvent =
|
|
26
|
+
| "SessionStart"
|
|
27
|
+
| "UserPromptSubmit"
|
|
28
|
+
| "SubagentStart"
|
|
29
|
+
| "PreToolUse"
|
|
30
|
+
| "PostToolUse";
|
|
26
31
|
|
|
27
32
|
/** Emit a context-injection (peer table, wiring check, council pending, …). */
|
|
28
33
|
export function emitContext(adapter: Adapter, event: SystemEvent, text: string): void {
|