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
|
@@ -1,581 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Heartbeat projector. Reads canonical events from the consumer and projects
|
|
3
|
-
* them into per-owner state files under `.harnery/active/<id>.json`, the same
|
|
4
|
-
* canonical location every reader (this library, hooks, the web UI, etc.)
|
|
5
|
-
* expects.
|
|
6
|
-
*
|
|
7
|
-
* Projection writes a single file, additively merged with any existing body
|
|
8
|
-
* so writes from sibling tools (e.g. `agent-coord set-task` that doesn't go
|
|
9
|
-
* through the canonical event stream) survive each projector run.
|
|
10
|
-
*/
|
|
11
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
12
|
-
import { dirname, join } from "node:path";
|
|
13
|
-
import { applySessionStateEvent } from "./session-state.js";
|
|
14
|
-
export function projectHeartbeats(coordRoot, events) {
|
|
15
|
-
const perOwner = {};
|
|
16
|
-
// Events that must NOT seed a heartbeat for an owner with no live file.
|
|
17
|
-
// Terminal lifecycle events (session.end / subagent.stop /
|
|
18
|
-
// health.heartbeat_swept) used to be the whole set — a stop without a
|
|
19
|
-
// matching start resurrected a nameless `agent-unknown` tombstone, and a
|
|
20
|
-
// lone health.heartbeat_swept re-created the file stale-sweep had just
|
|
21
|
-
// deleted (self-perpetuating zombie loop, same instance swept 18×).
|
|
22
|
-
//
|
|
23
|
-
// `claim.release` joins them: kill-heartbeat unlinks the file THEN emits
|
|
24
|
-
// claim.release for each held path so replay honors the drop. Projecting
|
|
25
|
-
// those releases alone used to seed a fresh heartbeat (name recovered from
|
|
26
|
-
// .name-history, last_heartbeat = release ts), undoing the kill. Side-effect
|
|
27
|
-
// events must never birth an owner.
|
|
28
|
-
const NEVER_SEED = new Set([
|
|
29
|
-
"session.end",
|
|
30
|
-
"subagent.stop",
|
|
31
|
-
"health.heartbeat_swept",
|
|
32
|
-
"claim.release",
|
|
33
|
-
]);
|
|
34
|
-
// Seed from any existing v2 files so a partial replay doesn't reset state.
|
|
35
|
-
for (const ev of events) {
|
|
36
|
-
if (!perOwner[ev.instance_id]) {
|
|
37
|
-
const existing = readExisting(coordRoot, ev.instance_id);
|
|
38
|
-
if (!existing && NEVER_SEED.has(ev.event_type))
|
|
39
|
-
continue;
|
|
40
|
-
perOwner[ev.instance_id] = existing ?? seed(ev, coordRoot);
|
|
41
|
-
}
|
|
42
|
-
apply(perOwner[ev.instance_id], ev, coordRoot);
|
|
43
|
-
}
|
|
44
|
-
const written = [];
|
|
45
|
-
for (const [instance_id, hb] of Object.entries(perOwner)) {
|
|
46
|
-
// Mid-batch terminal guard: the replay variant of the seed-time TERMINAL
|
|
47
|
-
// skip above. A drain that replays a COMPLETED run end-to-end (shared
|
|
48
|
-
// cursor lagging another consumer, replayAll) seeds from the start event,
|
|
49
|
-
// applies the whole history INCLUDING the terminal stop, then lands here
|
|
50
|
-
// and would re-create the heartbeat the end-hook already unlinked, a
|
|
51
|
-
// zombie that reads as a live agent for a full staleness window (observed:
|
|
52
|
-
// a finished subagent's heartbeat resurrected 4m after its stop by a
|
|
53
|
-
// sibling's spawn drain). `ended_at` is only ever set by apply() in this
|
|
54
|
-
// batch, it is not in writeHeartbeat's persisted allowlist, so it can't
|
|
55
|
-
// arrive from disk. If the batch saw the owner end and no heartbeat file
|
|
56
|
-
// exists now, there is nothing live to update: skip. An EXISTING file
|
|
57
|
-
// still gets the terminal write (tombstone semantics, locked by the
|
|
58
|
-
// "session.end on an EXISTING heartbeat still applies" test).
|
|
59
|
-
if (hb.ended_at && !existsSync(heartbeatPath(coordRoot, instance_id)))
|
|
60
|
-
continue;
|
|
61
|
-
writeHeartbeat(coordRoot, instance_id, hb);
|
|
62
|
-
written.push(instance_id);
|
|
63
|
-
}
|
|
64
|
-
return { written, perOwner };
|
|
65
|
-
}
|
|
66
|
-
function seed(ev, coordRoot) {
|
|
67
|
-
const nowIso = new Date().toISOString();
|
|
68
|
-
const hb = {
|
|
69
|
-
instance_id: ev.instance_id,
|
|
70
|
-
session_id: ev.session_id,
|
|
71
|
-
adapter: ev.adapter,
|
|
72
|
-
last_heartbeat: ev.ts,
|
|
73
|
-
last_event_id: ev.event_id,
|
|
74
|
-
events_applied: 0,
|
|
75
|
-
v2_meta: {
|
|
76
|
-
schema_version: 1,
|
|
77
|
-
first_seen: nowIso,
|
|
78
|
-
last_projected: nowIso,
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
// Recover identity from the durable `.name-history`. That file is written
|
|
82
|
-
// in-process at session.start / subagent.start time, BEFORE any projection,
|
|
83
|
-
// keyed by instance_id, surviving sweeps. Without this, seeding from a
|
|
84
|
-
// non-start event (a tool/turn whose start was never in a projected batch,
|
|
85
|
-
// e.g. the owner id resolved differently at start than later) produced a
|
|
86
|
-
// nameless `agent-unknown` heartbeat. Mirrors heartbeat-writer.healHeartbeat
|
|
87
|
-
// so BOTH heartbeat producers resolve identity the same way. Best-effort: a
|
|
88
|
-
// names.ts failure must never break projection (a past
|
|
89
|
-
// stop-projection crash that stalled the whole drain).
|
|
90
|
-
try {
|
|
91
|
-
const { resolveName } = require("./names.ts");
|
|
92
|
-
const resolved = resolveName(coordRoot, ev.instance_id, ev.session_id);
|
|
93
|
-
if (resolved) {
|
|
94
|
-
hb.name = resolved.name;
|
|
95
|
-
hb.kind = resolved.kind;
|
|
96
|
-
hb.agent_id =
|
|
97
|
-
resolved.agent_id ?? (resolved.kind === "subagent" ? ev.instance_id : undefined);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
/* name-history unavailable: seed stays nameless; sweep + render guards cope */
|
|
102
|
-
}
|
|
103
|
-
return hb;
|
|
104
|
-
}
|
|
105
|
-
function apply(hb, ev, coordRoot) {
|
|
106
|
-
// Sweep telemetry must not refresh liveness. apply() used to stamp
|
|
107
|
-
// last_heartbeat = ev.ts for every event, so a drain that replayed
|
|
108
|
-
// [session.start … tools … health.heartbeat_swept] wrote a heartbeat whose
|
|
109
|
-
// last_heartbeat was the swept ts — looking freshly alive for another
|
|
110
|
-
// freshness window, which the next sweep deleted-and-re-emitted. Record the
|
|
111
|
-
// event for audit (last_event_id / events_applied) but keep the prior
|
|
112
|
-
// liveness stamp; also set ended_at so the mid-batch write guard skips
|
|
113
|
-
// re-creating a file the sweep/kill already removed.
|
|
114
|
-
const isSweepTelemetry = ev.event_type === "health.heartbeat_swept";
|
|
115
|
-
if (!isSweepTelemetry) {
|
|
116
|
-
hb.last_heartbeat = ev.ts;
|
|
117
|
-
}
|
|
118
|
-
else if (!hb.last_heartbeat) {
|
|
119
|
-
hb.last_heartbeat = ev.ts;
|
|
120
|
-
}
|
|
121
|
-
hb.last_event_id = ev.event_id;
|
|
122
|
-
hb.events_applied += 1;
|
|
123
|
-
hb.v2_meta.last_projected = new Date().toISOString();
|
|
124
|
-
if (ev.turn_id)
|
|
125
|
-
hb.last_turn_id = ev.turn_id;
|
|
126
|
-
const sessionState = applySessionStateEvent(hb, ev);
|
|
127
|
-
hb.activity = sessionState.activity;
|
|
128
|
-
hb.activity_updated_at = sessionState.activity_updated_at;
|
|
129
|
-
hb.activity_source = sessionState.activity_source;
|
|
130
|
-
hb.task_state = sessionState.task_state;
|
|
131
|
-
hb.task_state_updated_at = sessionState.task_state_updated_at;
|
|
132
|
-
hb.task_state_reason = sessionState.task_state_reason;
|
|
133
|
-
const d = ev.data;
|
|
134
|
-
switch (ev.event_type) {
|
|
135
|
-
case "session.start":
|
|
136
|
-
hb.started_at = pickStr(d, "started_at") ?? ev.ts;
|
|
137
|
-
hb.adapter = ev.adapter;
|
|
138
|
-
{
|
|
139
|
-
const model = pickStr(d, "model");
|
|
140
|
-
if (model)
|
|
141
|
-
hb.model = model;
|
|
142
|
-
const instructionBundleId = pickStr(d, "instruction_bundle_id");
|
|
143
|
-
if (instructionBundleId)
|
|
144
|
-
hb.instruction_bundle_id = instructionBundleId;
|
|
145
|
-
const instructionSourceId = pickStr(d, "instruction_source_id");
|
|
146
|
-
if (instructionSourceId)
|
|
147
|
-
hb.instruction_source_id = instructionSourceId;
|
|
148
|
-
const instructionProfileRoot = pickStr(d, "instruction_profile_root");
|
|
149
|
-
if (instructionProfileRoot)
|
|
150
|
-
hb.instruction_profile_root = instructionProfileRoot;
|
|
151
|
-
const instructionComponentCount = pickNum(d, "instruction_component_count");
|
|
152
|
-
if (instructionComponentCount !== undefined) {
|
|
153
|
-
hb.instruction_component_count = instructionComponentCount;
|
|
154
|
-
}
|
|
155
|
-
const platform = pickStr(d, "platform") ?? adapterToPlatform(ev.adapter);
|
|
156
|
-
hb.platform = platform;
|
|
157
|
-
const name = pickStr(d, "name");
|
|
158
|
-
if (name)
|
|
159
|
-
hb.name = name;
|
|
160
|
-
const kind = pickStr(d, "kind");
|
|
161
|
-
if (kind === "session" || kind === "subagent" || kind === "transient") {
|
|
162
|
-
hb.kind = kind;
|
|
163
|
-
}
|
|
164
|
-
else if (!hb.kind) {
|
|
165
|
-
hb.kind = "session";
|
|
166
|
-
}
|
|
167
|
-
const agentId = pickStr(d, "agent_id");
|
|
168
|
-
if (agentId)
|
|
169
|
-
hb.agent_id = agentId;
|
|
170
|
-
const subagentCallId = pickStr(d, "subagent_call_id");
|
|
171
|
-
if (subagentCallId)
|
|
172
|
-
hb.subagent_call_id = subagentCallId;
|
|
173
|
-
const parentSession = pickStr(d, "parent_session_id");
|
|
174
|
-
if (parentSession)
|
|
175
|
-
hb.parent_session_id = parentSession;
|
|
176
|
-
const workflowRunId = pickStr(d, "workflow_run_id");
|
|
177
|
-
if (workflowRunId)
|
|
178
|
-
hb.workflow_run_id = workflowRunId;
|
|
179
|
-
const workflowAgentId = pickStr(d, "workflow_agent_id");
|
|
180
|
-
if (workflowAgentId)
|
|
181
|
-
hb.workflow_agent_id = workflowAgentId;
|
|
182
|
-
if (!hb.files_touched)
|
|
183
|
-
hb.files_touched = [];
|
|
184
|
-
}
|
|
185
|
-
break;
|
|
186
|
-
case "session.end":
|
|
187
|
-
hb.ended_at = pickStr(d, "ended_at") ?? ev.ts;
|
|
188
|
-
hb.clean_exit = pickBool(d, "clean_exit");
|
|
189
|
-
break;
|
|
190
|
-
case "health.heartbeat_swept":
|
|
191
|
-
hb.ended_at = ev.ts;
|
|
192
|
-
break;
|
|
193
|
-
case "subagent.start": {
|
|
194
|
-
const name = pickStr(d, "name");
|
|
195
|
-
if (name)
|
|
196
|
-
hb.name = name;
|
|
197
|
-
hb.kind = "subagent";
|
|
198
|
-
const parentSession = pickStr(d, "parent_session_id");
|
|
199
|
-
if (parentSession)
|
|
200
|
-
hb.parent_session_id = parentSession;
|
|
201
|
-
const subagentCallId = pickStr(d, "subagent_call_id");
|
|
202
|
-
if (subagentCallId)
|
|
203
|
-
hb.subagent_call_id = subagentCallId;
|
|
204
|
-
hb.agent_id = ev.instance_id;
|
|
205
|
-
hb.started_at = ev.ts;
|
|
206
|
-
if (!hb.files_touched)
|
|
207
|
-
hb.files_touched = [];
|
|
208
|
-
hb.platform = adapterToPlatform(ev.adapter);
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
case "subagent.stop":
|
|
212
|
-
hb.ended_at = pickStr(d, "ended_at") ?? ev.ts;
|
|
213
|
-
hb.clean_exit = pickBool(d, "clean_exit") ?? true;
|
|
214
|
-
break;
|
|
215
|
-
case "user_prompt.submit":
|
|
216
|
-
hb.last_user_prompt_at = ev.ts;
|
|
217
|
-
break;
|
|
218
|
-
case "turn.stop":
|
|
219
|
-
hb.last_turn_stop_at = ev.ts;
|
|
220
|
-
hb.last_turn_status_box_present = pickBool(d, "status_box_present");
|
|
221
|
-
// Rebuild fidelity for the naming ritual: the live stamp is written by
|
|
222
|
-
// the Stop hook (stampSessionNameSeen); reproduce it from the event so a
|
|
223
|
-
// full projector rebuild doesn't re-open a satisfied naming window.
|
|
224
|
-
if (d.session_name_present === true) {
|
|
225
|
-
hb.session_name_seen_at ??= ev.ts;
|
|
226
|
-
// Attribute the sighting to the name the scan actually covered. Reading
|
|
227
|
-
// the name current at this point in the replay instead re-attributed an
|
|
228
|
-
// old sighting to a re-minted name, which faked "already seen" for a
|
|
229
|
-
// name no reply had shown. An event without the field predates it, so
|
|
230
|
-
// leave the attribution unset and let the next stop re-scan.
|
|
231
|
-
hb.session_name_seen_for = pickStr(d, "session_name_present_for");
|
|
232
|
-
}
|
|
233
|
-
{
|
|
234
|
-
const summary = pickStr(d, "turn_summary");
|
|
235
|
-
if (summary) {
|
|
236
|
-
hb.turn_summary = summary;
|
|
237
|
-
hb.turn_summary_updated_at = ev.ts;
|
|
238
|
-
}
|
|
239
|
-
// Backfill model for adapters that omit it at session.start (Claude
|
|
240
|
-
// Code). The Stop hook resolves it from the transcript by this point;
|
|
241
|
-
// only set when present so we never clobber a known model.
|
|
242
|
-
const model = pickStr(d, "model");
|
|
243
|
-
if (model)
|
|
244
|
-
hb.model = model;
|
|
245
|
-
}
|
|
246
|
-
break;
|
|
247
|
-
case "tool.pre_use": {
|
|
248
|
-
const toolName = pickStr(d, "tool_name");
|
|
249
|
-
hb.last_tool = toolName;
|
|
250
|
-
hb.last_tool_target = extractTarget(d);
|
|
251
|
-
hb.last_tool_at = ev.ts;
|
|
252
|
-
const intent = pickStr(d, "intent");
|
|
253
|
-
if (intent && intent !== "(no intent)") {
|
|
254
|
-
hb.last_intent = intent;
|
|
255
|
-
hb.last_intent_source = pickStr(d, "intent_source");
|
|
256
|
-
}
|
|
257
|
-
// Project files_touched: Edit / Write / NotebookEdit add their target.
|
|
258
|
-
if (toolName === "Edit" || toolName === "Write" || toolName === "NotebookEdit") {
|
|
259
|
-
const target = extractFilePath(d);
|
|
260
|
-
if (target) {
|
|
261
|
-
// Canonicalize to repo-relative before storing: the claim guard
|
|
262
|
-
// writes canonical paths directly, so an absolute entry here would
|
|
263
|
-
// double-count the same file (inflated "N files" display) and
|
|
264
|
-
// defeat exact-match pruning on commit.
|
|
265
|
-
const canonical = target.startsWith(`${coordRoot}/`)
|
|
266
|
-
? target.slice(coordRoot.length + 1)
|
|
267
|
-
: target;
|
|
268
|
-
if (!hb.files_touched)
|
|
269
|
-
hb.files_touched = [];
|
|
270
|
-
if (!hb.files_touched.includes(canonical))
|
|
271
|
-
hb.files_touched.push(canonical);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
case "tool.post_use":
|
|
277
|
-
case "tool.post_use_failure":
|
|
278
|
-
hb.last_tool_at = ev.ts;
|
|
279
|
-
break;
|
|
280
|
-
case "state.task_set": {
|
|
281
|
-
const cleared = pickBool(d, "cleared");
|
|
282
|
-
const task = pickStr(d, "task");
|
|
283
|
-
if (cleared || !task) {
|
|
284
|
-
hb.task = undefined;
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
hb.task = task;
|
|
288
|
-
}
|
|
289
|
-
hb.task_updated_at = ev.ts;
|
|
290
|
-
// Rebuild fidelity: the naming call carries the name it produced.
|
|
291
|
-
const suggested = pickStr(d, "suggested_session_name");
|
|
292
|
-
if (suggested && !hb.suggested_session_name) {
|
|
293
|
-
hb.suggested_session_name = suggested;
|
|
294
|
-
}
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
case "state.task_state": {
|
|
298
|
-
const suggested = pickStr(d, "suggested_session_name");
|
|
299
|
-
if (suggested && suggested !== hb.suggested_session_name) {
|
|
300
|
-
// Older heartbeats predate session_name_seen_for. A lifecycle re-mint
|
|
301
|
-
// still needs a mismatch the prompt and Stop paths can enforce, so
|
|
302
|
-
// attribute the prior title before replacing it. Ordinary legacy
|
|
303
|
-
// heartbeats remain quiet until a real lifecycle event changes them.
|
|
304
|
-
if (!hb.session_name_seen_for && hb.suggested_session_name) {
|
|
305
|
-
hb.session_name_seen_for = hb.suggested_session_name;
|
|
306
|
-
}
|
|
307
|
-
hb.suggested_session_name = suggested;
|
|
308
|
-
}
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
case "state.status_checked":
|
|
312
|
-
hb.last_status_at = ev.ts;
|
|
313
|
-
break;
|
|
314
|
-
case "identity.assumed": {
|
|
315
|
-
const name = pickStr(d, "name");
|
|
316
|
-
const agentId = pickStr(d, "agent_id");
|
|
317
|
-
if (name)
|
|
318
|
-
hb.name = name;
|
|
319
|
-
if (agentId)
|
|
320
|
-
hb.agent_id = agentId;
|
|
321
|
-
break;
|
|
322
|
-
}
|
|
323
|
-
case "state.presence_change": {
|
|
324
|
-
const to = pickStr(d, "to");
|
|
325
|
-
if (to === "mobile" || to === "office")
|
|
326
|
-
hb.presence = to;
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
case "claim.acquire": {
|
|
330
|
-
const path = pickStr(d, "path");
|
|
331
|
-
const mode = pickStr(d, "mode");
|
|
332
|
-
if (path && mode === "write") {
|
|
333
|
-
const canonical = path.startsWith(`${coordRoot}/`)
|
|
334
|
-
? path.slice(coordRoot.length + 1)
|
|
335
|
-
: path;
|
|
336
|
-
if (!hb.files_touched)
|
|
337
|
-
hb.files_touched = [];
|
|
338
|
-
if (!hb.files_touched.includes(canonical))
|
|
339
|
-
hb.files_touched.push(canonical);
|
|
340
|
-
}
|
|
341
|
-
break;
|
|
342
|
-
}
|
|
343
|
-
case "claim.release": {
|
|
344
|
-
const path = pickStr(d, "path");
|
|
345
|
-
if (path && hb.files_touched) {
|
|
346
|
-
// files_touched holds a mix of absolute-under-coordRoot and canonical
|
|
347
|
-
// repo-relative entries (Edit events report absolute; release-claim
|
|
348
|
-
// canonicalizes to relative). Normalize both sides so a release
|
|
349
|
-
// subtracts regardless of form — an exact-string compare silently
|
|
350
|
-
// no-ops on the mismatch and the claim resurrects on the next replay.
|
|
351
|
-
const norm = (p) => p.startsWith(`${coordRoot}/`) ? p.slice(coordRoot.length + 1) : p;
|
|
352
|
-
const target = norm(path);
|
|
353
|
-
hb.files_touched = hb.files_touched.filter((p) => norm(p) !== target);
|
|
354
|
-
}
|
|
355
|
-
break;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
function adapterToPlatform(adapter) {
|
|
360
|
-
if (adapter === "claude-code")
|
|
361
|
-
return "claude-code";
|
|
362
|
-
if (adapter === "cursor")
|
|
363
|
-
return "cursor";
|
|
364
|
-
if (adapter === "codex")
|
|
365
|
-
return "codex";
|
|
366
|
-
return adapter;
|
|
367
|
-
}
|
|
368
|
-
function extractFilePath(data) {
|
|
369
|
-
const raw = data.tool_input;
|
|
370
|
-
if (typeof raw !== "string")
|
|
371
|
-
return undefined;
|
|
372
|
-
try {
|
|
373
|
-
const parsed = JSON.parse(raw);
|
|
374
|
-
return (pickStr(parsed, "file_path") ??
|
|
375
|
-
pickStr(parsed, "path") ??
|
|
376
|
-
pickStr(parsed, "notebook_path") ??
|
|
377
|
-
undefined);
|
|
378
|
-
}
|
|
379
|
-
catch {
|
|
380
|
-
return undefined;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
function extractTarget(data) {
|
|
384
|
-
// tool_input is stringified JSON in our envelope; try to parse and pull a
|
|
385
|
-
// common target field (file_path, path, command).
|
|
386
|
-
const raw = data.tool_input;
|
|
387
|
-
if (typeof raw !== "string")
|
|
388
|
-
return undefined;
|
|
389
|
-
try {
|
|
390
|
-
const parsed = JSON.parse(raw);
|
|
391
|
-
return (pickStr(parsed, "file_path") ??
|
|
392
|
-
pickStr(parsed, "path") ??
|
|
393
|
-
pickStr(parsed, "notebook_path") ??
|
|
394
|
-
cleanCommand(pickStr(parsed, "command")) ??
|
|
395
|
-
undefined);
|
|
396
|
-
}
|
|
397
|
-
catch {
|
|
398
|
-
return undefined;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* The repo mandates a `# intent: …` first-line comment on every Bash command,
|
|
403
|
-
* so a raw `command` payload starts with the intent prose, not the command.
|
|
404
|
-
* Stamping that into `last_tool_target` leaked the intent into the peer table
|
|
405
|
-
* and pushed the real command past the 60-char render slice. Skip leading
|
|
406
|
-
* comment-only lines so the target reflects what the agent is actually running.
|
|
407
|
-
*/
|
|
408
|
-
function cleanCommand(command) {
|
|
409
|
-
if (command === undefined)
|
|
410
|
-
return undefined;
|
|
411
|
-
for (const line of command.split("\n")) {
|
|
412
|
-
const trimmed = line.trim();
|
|
413
|
-
if (!trimmed || trimmed.startsWith("#"))
|
|
414
|
-
continue;
|
|
415
|
-
return trimmed;
|
|
416
|
-
}
|
|
417
|
-
// All-comment / degenerate: fall back to the trimmed whole.
|
|
418
|
-
return command.trim() || undefined;
|
|
419
|
-
}
|
|
420
|
-
function readExisting(coordRoot, instanceId) {
|
|
421
|
-
const path = heartbeatPath(coordRoot, instanceId);
|
|
422
|
-
if (!existsSync(path))
|
|
423
|
-
return null;
|
|
424
|
-
try {
|
|
425
|
-
const raw = JSON.parse(readFileSync(path, "utf8"));
|
|
426
|
-
return coerceV2Heartbeat(raw, instanceId);
|
|
427
|
-
}
|
|
428
|
-
catch {
|
|
429
|
-
return null;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Restore the projector-owned invariant fields on a heartbeat read from disk.
|
|
434
|
-
*
|
|
435
|
-
* The active-heartbeat file has multiple producers: the projector (seed/apply,
|
|
436
|
-
* which set `v2_meta` + `events_applied`) AND the writer layer
|
|
437
|
-
* (heartbeat-writer.ts: healHeartbeat, setTask, stampToolActivity, …), which
|
|
438
|
-
* only knows the v1 shape and omits both. readExisting previously `as`-cast the
|
|
439
|
-
* raw JSON straight to V2Heartbeat, so a body recreated by `healHeartbeat`
|
|
440
|
-
* (e.g. a pruned Cursor session) reached apply() without `v2_meta` →
|
|
441
|
-
* `hb.v2_meta.last_projected = …` threw (caught + logged ~200×/day, phase
|
|
442
|
-
* "stop-projection"), and without `events_applied` → `events_applied += 1`
|
|
443
|
-
* silently went NaN. The read boundary is where untyped JSON becomes a typed
|
|
444
|
-
* V2Heartbeat, so it's where the type's required-field invariant must be
|
|
445
|
-
* re-established, covering every malformed producer, not just one symptom.
|
|
446
|
-
*
|
|
447
|
-
* Note `v2_meta` is NOT in writeHeartbeat's persisted allowlist, so it never
|
|
448
|
-
* lands on disk; it's ephemeral per-drain bookkeeping, which means readExisting
|
|
449
|
-
* must re-coerce it on EVERY read of an already-seen owner (not only for
|
|
450
|
-
* heal-written bodies). `events_applied` IS persisted, so coercing it to 0 only
|
|
451
|
-
* matters for bodies a writer produced without the field (e.g. healHeartbeat).
|
|
452
|
-
*/
|
|
453
|
-
function coerceV2Heartbeat(raw, instanceId) {
|
|
454
|
-
const hb = raw;
|
|
455
|
-
if (!hb.instance_id)
|
|
456
|
-
hb.instance_id = instanceId;
|
|
457
|
-
if (typeof hb.events_applied !== "number" || Number.isNaN(hb.events_applied)) {
|
|
458
|
-
hb.events_applied = 0;
|
|
459
|
-
}
|
|
460
|
-
if (!hb.v2_meta) {
|
|
461
|
-
const nowIso = new Date().toISOString();
|
|
462
|
-
hb.v2_meta = {
|
|
463
|
-
schema_version: 1,
|
|
464
|
-
first_seen: hb.last_heartbeat ?? nowIso,
|
|
465
|
-
last_projected: nowIso,
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
return hb;
|
|
469
|
-
}
|
|
470
|
-
function writeHeartbeat(coordRoot, instanceId, hb) {
|
|
471
|
-
const path = heartbeatPath(coordRoot, instanceId);
|
|
472
|
-
try {
|
|
473
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
474
|
-
// Additive merge with existing body so writes from sibling tools (e.g.
|
|
475
|
-
// `agent-coord set-task` that doesn't go through the canonical event
|
|
476
|
-
// stream) survive each projector run. Projected fields win on conflict.
|
|
477
|
-
let existing = {};
|
|
478
|
-
if (existsSync(path)) {
|
|
479
|
-
try {
|
|
480
|
-
existing = JSON.parse(readFileSync(path, "utf8"));
|
|
481
|
-
}
|
|
482
|
-
catch {
|
|
483
|
-
/* skip merge */
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
const merged = {
|
|
487
|
-
schema_version: 1,
|
|
488
|
-
...existing,
|
|
489
|
-
instance_id: hb.instance_id,
|
|
490
|
-
session_id: hb.session_id,
|
|
491
|
-
last_heartbeat: hb.last_heartbeat,
|
|
492
|
-
last_event_id: hb.last_event_id,
|
|
493
|
-
events_applied: hb.events_applied,
|
|
494
|
-
};
|
|
495
|
-
setIfDefined(merged, "name", hb.name);
|
|
496
|
-
setIfDefined(merged, "kind", hb.kind);
|
|
497
|
-
setIfDefined(merged, "agent_id", hb.agent_id);
|
|
498
|
-
setIfDefined(merged, "subagent_call_id", hb.subagent_call_id);
|
|
499
|
-
setIfDefined(merged, "workflow_run_id", hb.workflow_run_id);
|
|
500
|
-
setIfDefined(merged, "workflow_agent_id", hb.workflow_agent_id);
|
|
501
|
-
setIfDefined(merged, "model", hb.model);
|
|
502
|
-
setIfDefined(merged, "instruction_bundle_id", hb.instruction_bundle_id);
|
|
503
|
-
setIfDefined(merged, "instruction_source_id", hb.instruction_source_id);
|
|
504
|
-
setIfDefined(merged, "instruction_profile_root", hb.instruction_profile_root);
|
|
505
|
-
setIfDefined(merged, "instruction_component_count", hb.instruction_component_count);
|
|
506
|
-
setIfDefined(merged, "platform", hb.platform);
|
|
507
|
-
setIfDefined(merged, "started_at", hb.started_at);
|
|
508
|
-
// files_touched is a required-array invariant for every reader
|
|
509
|
-
// (coord-reader.isHeartbeatShape, the web UI, stale-sweep). Seed paths that
|
|
510
|
-
// never hit a start event leave it undefined; default to [] so the writer
|
|
511
|
-
// can never emit a file that fails the reader's shape check. Belt to the
|
|
512
|
-
// TERMINAL guard's suspenders.
|
|
513
|
-
merged.files_touched = hb.files_touched ?? [];
|
|
514
|
-
setIfDefined(merged, "last_tool", hb.last_tool);
|
|
515
|
-
setIfDefined(merged, "last_tool_target", hb.last_tool_target);
|
|
516
|
-
setIfDefined(merged, "last_tool_at", hb.last_tool_at);
|
|
517
|
-
setIfDefined(merged, "task", hb.task);
|
|
518
|
-
setIfDefined(merged, "task_updated_at", hb.task_updated_at);
|
|
519
|
-
setIfDefined(merged, "activity", hb.activity);
|
|
520
|
-
setIfDefined(merged, "activity_updated_at", hb.activity_updated_at);
|
|
521
|
-
setIfDefined(merged, "activity_source", hb.activity_source);
|
|
522
|
-
setIfDefined(merged, "task_state", hb.task_state);
|
|
523
|
-
setIfDefined(merged, "task_state_updated_at", hb.task_state_updated_at);
|
|
524
|
-
if (hb.task_state_reason) {
|
|
525
|
-
merged.task_state_reason = hb.task_state_reason;
|
|
526
|
-
}
|
|
527
|
-
else if (hb.task_state) {
|
|
528
|
-
delete merged.task_state_reason;
|
|
529
|
-
}
|
|
530
|
-
setIfDefined(merged, "suggested_session_name", hb.suggested_session_name);
|
|
531
|
-
setIfDefined(merged, "session_name_seen_at", hb.session_name_seen_at);
|
|
532
|
-
if (hb.session_name_seen_for) {
|
|
533
|
-
merged.session_name_seen_for = hb.session_name_seen_for;
|
|
534
|
-
}
|
|
535
|
-
else {
|
|
536
|
-
// Unlike most projected fields, an absent attribution is meaningful: a
|
|
537
|
-
// legacy sighting cannot prove which suggested name it covered. Remove a
|
|
538
|
-
// stale value inherited through the additive merge so the next stop
|
|
539
|
-
// scans the current name instead of treating it as already satisfied.
|
|
540
|
-
delete merged.session_name_seen_for;
|
|
541
|
-
}
|
|
542
|
-
setIfDefined(merged, "last_status_at", hb.last_status_at);
|
|
543
|
-
setIfDefined(merged, "turn_summary", hb.turn_summary);
|
|
544
|
-
setIfDefined(merged, "turn_summary_updated_at", hb.turn_summary_updated_at);
|
|
545
|
-
setIfDefined(merged, "current_turn_id", hb.last_turn_id);
|
|
546
|
-
setIfDefined(merged, "parent_instance_id", hb.parent_session_id);
|
|
547
|
-
// Atomic temp+rename (same primitive as heartbeat-writer.ts:atomicWrite) so
|
|
548
|
-
// a concurrent reader (stale-sweep, `harn agents`, the web UI) never sees a
|
|
549
|
-
// half-written file. A plain in-place writeFileSync truncates-then-writes,
|
|
550
|
-
// exposing a partial-read window; stale-sweep deletes any heartbeat it
|
|
551
|
-
// fails to JSON.parse, so a partial read there would delete a live agent.
|
|
552
|
-
const tmp = `${path}.tmp.${process.pid}`;
|
|
553
|
-
writeFileSync(tmp, JSON.stringify(merged, null, 2), "utf8");
|
|
554
|
-
renameSync(tmp, path);
|
|
555
|
-
}
|
|
556
|
-
catch {
|
|
557
|
-
/* surfaced by caller via missing heartbeat file */
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
export function heartbeatPath(coordRoot, instanceId) {
|
|
561
|
-
return join(coordRoot, ".harnery", "active", `${instanceId}.json`);
|
|
562
|
-
}
|
|
563
|
-
/** Set a field only when value is defined (not null/undefined). Used by the
|
|
564
|
-
* additive merge so non-projected writes survive projector runs. */
|
|
565
|
-
function setIfDefined(target, key, value) {
|
|
566
|
-
if (value !== undefined && value !== null) {
|
|
567
|
-
target[key] = value;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
function pickStr(o, k) {
|
|
571
|
-
const v = o[k];
|
|
572
|
-
return typeof v === "string" && v.length > 0 ? v : undefined;
|
|
573
|
-
}
|
|
574
|
-
function pickBool(o, k) {
|
|
575
|
-
const v = o[k];
|
|
576
|
-
return typeof v === "boolean" ? v : undefined;
|
|
577
|
-
}
|
|
578
|
-
function pickNum(o, k) {
|
|
579
|
-
const v = o[k];
|
|
580
|
-
return typeof v === "number" && Number.isFinite(v) ? v : undefined;
|
|
581
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type Adapter, type EventEnvelope, type EventType, type Source } from "./schema.js";
|
|
2
|
-
export interface EmitInput<TType extends EventType, TData> {
|
|
3
|
-
event_type: TType;
|
|
4
|
-
instance_id: string;
|
|
5
|
-
session_id: string;
|
|
6
|
-
adapter: Adapter;
|
|
7
|
-
source?: Source;
|
|
8
|
-
parent_session_id?: string;
|
|
9
|
-
turn_id?: string;
|
|
10
|
-
parent_turn_id?: string;
|
|
11
|
-
ts?: string;
|
|
12
|
-
data: TData;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Build a canonical envelope around the caller's `data` payload. Pure;
|
|
16
|
-
* doesn't touch the filesystem. Useful for tests + replay fixtures.
|
|
17
|
-
*/
|
|
18
|
-
export declare function buildEnvelope<TType extends EventType, TData>(input: EmitInput<TType, TData>): EventEnvelope<TType, TData>;
|
|
19
|
-
/**
|
|
20
|
-
* Append one canonical event to `.harnery/events.ndjson` under a file lock.
|
|
21
|
-
* Append-only, one JSON object per line, lock-serialized.
|
|
22
|
-
*
|
|
23
|
-
* Synchronous because hooks are short-lived processes: we want the append to
|
|
24
|
-
* land before the binary exits, and async/await across a tiny write is just
|
|
25
|
-
* latency for no benefit.
|
|
26
|
-
*
|
|
27
|
-
* Returns the envelope so callers can chain off it (debug logs, post-emit
|
|
28
|
-
* verdict requests).
|
|
29
|
-
*/
|
|
30
|
-
export declare function emit<TType extends EventType, TData>(coordRoot: string, input: EmitInput<TType, TData>): EventEnvelope<TType, TData>;
|
|
31
|
-
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/events/emit.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,SAAS,EAEd,KAAK,MAAM,EACZ,MAAM,aAAa,CAAC;AAQrB,MAAM,WAAW,SAAS,CAAC,KAAK,SAAS,SAAS,EAAE,KAAK;IACvD,UAAU,EAAE,KAAK,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC;CACb;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,SAAS,SAAS,EAAE,KAAK,EAC1D,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,GAC7B,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAe7B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,KAAK,SAAS,SAAS,EAAE,KAAK,EACjD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,GAC7B,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAyC7B"}
|