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,290 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync,
|
|
3
|
+
mkdirSync,
|
|
4
|
+
readdirSync,
|
|
5
|
+
readFileSync,
|
|
6
|
+
renameSync,
|
|
7
|
+
writeFileSync,
|
|
8
|
+
} from "node:fs";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
import type { Adapter } from "../../adapter.ts";
|
|
11
|
+
import {
|
|
12
|
+
type CoordinationGenerationViewV3,
|
|
13
|
+
type CoordinationViewV3,
|
|
14
|
+
readCoordinationViewV3,
|
|
15
|
+
requireAuthoritySafeCoordinationViewV3,
|
|
16
|
+
} from "../../events/v3/coordination-view.ts";
|
|
17
|
+
import {
|
|
18
|
+
liveInstanceIdV3,
|
|
19
|
+
nativeInstanceIdV3,
|
|
20
|
+
resolveLiveEventLedgerRouteV3,
|
|
21
|
+
} from "../../events/v3/live-routing.ts";
|
|
22
|
+
import { type Heartbeat, readHeartbeat } from "./heartbeat-writer.ts";
|
|
23
|
+
import { resolveName } from "./names.ts";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Heartbeat files are disposable V3 caches. These bindings prevent a stale
|
|
27
|
+
* row from a prior generation from being mistaken for current authority.
|
|
28
|
+
*/
|
|
29
|
+
export interface V3HeartbeatMaterialization extends Heartbeat {
|
|
30
|
+
schema_version: 2;
|
|
31
|
+
v3_instance_id: `inst_${string}`;
|
|
32
|
+
v3_generation_id: `gen_${string}`;
|
|
33
|
+
v3_projection_event_id: string;
|
|
34
|
+
v3_task_state: "set" | "cleared";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Read the live coordination rows through the hard-cut ledger route. */
|
|
38
|
+
export function readLiveCoordinationRows(coordRoot: string): V3HeartbeatMaterialization[] {
|
|
39
|
+
const route = resolveLiveEventLedgerRouteV3(coordRoot);
|
|
40
|
+
if (route.state === "blocked") return [];
|
|
41
|
+
let view: CoordinationViewV3;
|
|
42
|
+
try {
|
|
43
|
+
view = requireAuthoritySafeCoordinationViewV3(readCoordinationViewV3(coordRoot));
|
|
44
|
+
} catch {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const caches = readV3Caches(coordRoot);
|
|
48
|
+
const byGeneration = new Map(
|
|
49
|
+
Object.values(view.instances).map((generation) => [generation.generation_id, generation]),
|
|
50
|
+
);
|
|
51
|
+
return Object.values(view.instances)
|
|
52
|
+
.filter((generation) => generation.authority_eligible)
|
|
53
|
+
.map((generation) => {
|
|
54
|
+
const parent = generation.parent_generation_id
|
|
55
|
+
? byGeneration.get(generation.parent_generation_id)
|
|
56
|
+
: undefined;
|
|
57
|
+
return projectHeartbeatV3(
|
|
58
|
+
coordRoot,
|
|
59
|
+
generation,
|
|
60
|
+
matchingCache(caches, generation),
|
|
61
|
+
undefined,
|
|
62
|
+
parent,
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Read one current row from the authority-safe V3 projection. */
|
|
68
|
+
export function readLiveCoordinationRow(
|
|
69
|
+
coordRoot: string,
|
|
70
|
+
nativeInstanceId: string,
|
|
71
|
+
): V3HeartbeatMaterialization | null {
|
|
72
|
+
const route = resolveLiveEventLedgerRouteV3(coordRoot);
|
|
73
|
+
if (route.state === "blocked") return null;
|
|
74
|
+
try {
|
|
75
|
+
const view = requireAuthoritySafeCoordinationViewV3(readCoordinationViewV3(coordRoot));
|
|
76
|
+
const generation = view.instances[liveInstanceIdV3(nativeInstanceId)];
|
|
77
|
+
if (!generation?.authority_eligible) return null;
|
|
78
|
+
const cache = readHeartbeat(coordRoot, nativeInstanceId);
|
|
79
|
+
const parent = generation.parent_generation_id
|
|
80
|
+
? Object.values(view.instances).find(
|
|
81
|
+
(candidate) => candidate.generation_id === generation.parent_generation_id,
|
|
82
|
+
)
|
|
83
|
+
: undefined;
|
|
84
|
+
return projectHeartbeatV3(
|
|
85
|
+
coordRoot,
|
|
86
|
+
generation,
|
|
87
|
+
isCurrentCache(cache, generation) ? cache : undefined,
|
|
88
|
+
nativeInstanceId,
|
|
89
|
+
parent,
|
|
90
|
+
);
|
|
91
|
+
} catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Resolve the adapter from the current authority-safe V3 generation. A live
|
|
98
|
+
* V3 generation is stronger evidence than a missing or stale heartbeat, so
|
|
99
|
+
* callers must never substitute another adapter when this function succeeds.
|
|
100
|
+
*/
|
|
101
|
+
export function liveCoordinationAdapterV3(
|
|
102
|
+
coordRoot: string,
|
|
103
|
+
nativeInstanceId: string,
|
|
104
|
+
): Adapter | null {
|
|
105
|
+
const route = resolveLiveEventLedgerRouteV3(coordRoot);
|
|
106
|
+
if (route.state === "blocked") throw new Error(`event_v3_coordination_view:${route.reason}`);
|
|
107
|
+
const view = requireAuthoritySafeCoordinationViewV3(readCoordinationViewV3(coordRoot));
|
|
108
|
+
const generation = view.instances[liveInstanceIdV3(nativeInstanceId)];
|
|
109
|
+
if (!generation?.authority_eligible) return null;
|
|
110
|
+
const adapter = observedAdapter(generation);
|
|
111
|
+
if (!isAdapter(adapter)) {
|
|
112
|
+
throw new Error("event_v3_coordination_view:adapter_not_observed");
|
|
113
|
+
}
|
|
114
|
+
return adapter;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Ensure the current V3 generation has a mutation target. The resulting file
|
|
119
|
+
* is explicitly generation-bound and disposable: V3 remains the source of
|
|
120
|
+
* truth, while the cache gives the crash-safe authority outbox an atomic local
|
|
121
|
+
* state to reconcile.
|
|
122
|
+
*/
|
|
123
|
+
export function ensureLiveCoordinationHeartbeat(
|
|
124
|
+
coordRoot: string,
|
|
125
|
+
nativeInstanceId: string,
|
|
126
|
+
nativeSessionId: string,
|
|
127
|
+
_adapter: Adapter,
|
|
128
|
+
model?: string,
|
|
129
|
+
): Heartbeat | null {
|
|
130
|
+
const route = resolveLiveEventLedgerRouteV3(coordRoot);
|
|
131
|
+
if (route.state === "blocked") throw new Error(`event_v3_coordination_view:${route.reason}`);
|
|
132
|
+
const view = requireAuthoritySafeCoordinationViewV3(readCoordinationViewV3(coordRoot));
|
|
133
|
+
const generation = view.instances[liveInstanceIdV3(nativeInstanceId)];
|
|
134
|
+
if (!generation?.authority_eligible) return null;
|
|
135
|
+
const generationAdapter = observedAdapter(generation);
|
|
136
|
+
if (!isAdapter(generationAdapter)) {
|
|
137
|
+
throw new Error("event_v3_coordination_view:adapter_not_observed");
|
|
138
|
+
}
|
|
139
|
+
const current = readHeartbeat(coordRoot, nativeInstanceId);
|
|
140
|
+
if (isCurrentCache(current, generation) && current.platform === generationAdapter) return current;
|
|
141
|
+
|
|
142
|
+
const resolved = resolveName(coordRoot, nativeInstanceId, nativeSessionId);
|
|
143
|
+
const projected = projectHeartbeatV3(coordRoot, generation, undefined, nativeInstanceId);
|
|
144
|
+
const materialized: V3HeartbeatMaterialization = {
|
|
145
|
+
...projected,
|
|
146
|
+
schema_version: 2,
|
|
147
|
+
instance_id: nativeInstanceId,
|
|
148
|
+
session_id: nativeSessionId,
|
|
149
|
+
name: resolved?.name ?? "",
|
|
150
|
+
kind: resolved?.kind ?? projected.kind,
|
|
151
|
+
agent_id: resolved?.agent_id ?? (resolved?.kind === "subagent" ? nativeInstanceId : ""),
|
|
152
|
+
model: projected.model ?? model ?? "",
|
|
153
|
+
platform: generationAdapter,
|
|
154
|
+
v3_instance_id: generation.instance_id as `inst_${string}`,
|
|
155
|
+
v3_generation_id: generation.generation_id as `gen_${string}`,
|
|
156
|
+
v3_projection_event_id: generation.last_event_id,
|
|
157
|
+
v3_task_state: generation.task_state === "set" ? "set" : "cleared",
|
|
158
|
+
};
|
|
159
|
+
writeHeartbeatCache(coordRoot, nativeInstanceId, materialized);
|
|
160
|
+
return materialized;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function readCacheRows(coordRoot: string): Heartbeat[] {
|
|
164
|
+
const dir = join(coordRoot, ".harnery", "active");
|
|
165
|
+
if (!existsSync(dir)) return [];
|
|
166
|
+
const rows: Heartbeat[] = [];
|
|
167
|
+
for (const file of readdirSync(dir)) {
|
|
168
|
+
if (!file.endsWith(".json")) continue;
|
|
169
|
+
try {
|
|
170
|
+
rows.push(JSON.parse(readFileSync(join(dir, file), "utf8")) as Heartbeat);
|
|
171
|
+
} catch {
|
|
172
|
+
// A partial heartbeat is ignored exactly as before.
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return rows;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function readV3Caches(coordRoot: string): Heartbeat[] {
|
|
179
|
+
return readCacheRows(coordRoot).filter(
|
|
180
|
+
(row) => row.schema_version === 2 && typeof row.v3_generation_id === "string",
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function matchingCache(
|
|
185
|
+
caches: Heartbeat[],
|
|
186
|
+
generation: CoordinationGenerationViewV3,
|
|
187
|
+
): Heartbeat | undefined {
|
|
188
|
+
return caches.find((cache) => isCurrentCache(cache, generation));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function isCurrentCache(
|
|
192
|
+
cache: Heartbeat | null | undefined,
|
|
193
|
+
generation: CoordinationGenerationViewV3,
|
|
194
|
+
): cache is Heartbeat {
|
|
195
|
+
return (
|
|
196
|
+
cache?.schema_version === 2 &&
|
|
197
|
+
cache.v3_instance_id === generation.instance_id &&
|
|
198
|
+
cache.v3_generation_id === generation.generation_id
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function projectHeartbeatV3(
|
|
203
|
+
coordRoot: string,
|
|
204
|
+
generation: CoordinationGenerationViewV3,
|
|
205
|
+
cache: Heartbeat | undefined,
|
|
206
|
+
nativeInstanceId: string | undefined,
|
|
207
|
+
parent?: CoordinationGenerationViewV3,
|
|
208
|
+
): V3HeartbeatMaterialization {
|
|
209
|
+
const adapter = observedAdapter(generation) ?? cache?.platform ?? "unknown";
|
|
210
|
+
const model = observedModel(generation) ?? cache?.model ?? "";
|
|
211
|
+
const instanceId =
|
|
212
|
+
nativeInstanceId ?? cache?.instance_id ?? nativeInstanceIdV3(generation.instance_id);
|
|
213
|
+
const durableIdentity = resolveName(
|
|
214
|
+
coordRoot,
|
|
215
|
+
instanceId,
|
|
216
|
+
cache?.session_id ?? generation.session_id,
|
|
217
|
+
);
|
|
218
|
+
const taskIsSet = generation.task_state === "set";
|
|
219
|
+
const lifecycle = isLifecycleState(generation.lifecycle_state)
|
|
220
|
+
? generation.lifecycle_state
|
|
221
|
+
: "active";
|
|
222
|
+
return {
|
|
223
|
+
schema_version: 2,
|
|
224
|
+
instance_id: instanceId,
|
|
225
|
+
session_id: parent?.session_id ?? generation.session_id,
|
|
226
|
+
native_session_id: cache?.session_id,
|
|
227
|
+
name: cache?.name || durableIdentity?.name,
|
|
228
|
+
kind:
|
|
229
|
+
cache?.kind ??
|
|
230
|
+
durableIdentity?.kind ??
|
|
231
|
+
(generation.parent_generation_id || generation.delegation_id
|
|
232
|
+
? "subagent"
|
|
233
|
+
: generation.workflow_id
|
|
234
|
+
? "workflow-child"
|
|
235
|
+
: "session"),
|
|
236
|
+
agent_id: cache?.agent_id ?? durableIdentity?.agent_id,
|
|
237
|
+
model,
|
|
238
|
+
platform: adapter,
|
|
239
|
+
started_at: generation.started_at,
|
|
240
|
+
last_heartbeat: generation.last_observed_at,
|
|
241
|
+
files_touched: generation.files_touched,
|
|
242
|
+
...(taskIsSet && cache?.task ? { task: cache.task } : {}),
|
|
243
|
+
task_updated_at: taskIsSet ? cache?.task_updated_at : null,
|
|
244
|
+
activity: generation.activity === "terminal" ? "idle" : generation.activity,
|
|
245
|
+
activity_updated_at: generation.last_observed_at,
|
|
246
|
+
activity_source: "event-v3-coordination-view",
|
|
247
|
+
task_state: lifecycle,
|
|
248
|
+
task_state_updated_at: generation.lifecycle_state_updated_at,
|
|
249
|
+
task_state_reason: lifecycle === "blocked" ? cache?.task_state_reason : undefined,
|
|
250
|
+
suggested_session_name: cache?.suggested_session_name,
|
|
251
|
+
session_name_seen_at: cache?.session_name_seen_at,
|
|
252
|
+
session_name_seen_for: cache?.session_name_seen_for,
|
|
253
|
+
workflow_run_id: generation.run_id,
|
|
254
|
+
workflow_agent_id: generation.workflow_agent_id,
|
|
255
|
+
parent_instance_id: parent ? nativeInstanceIdV3(parent.instance_id) : undefined,
|
|
256
|
+
v3_instance_id: generation.instance_id as `inst_${string}`,
|
|
257
|
+
v3_generation_id: generation.generation_id as `gen_${string}`,
|
|
258
|
+
v3_projection_event_id: generation.last_event_id,
|
|
259
|
+
v3_task_state: taskIsSet ? "set" : "cleared",
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function observedAdapter(generation: CoordinationGenerationViewV3): string | undefined {
|
|
264
|
+
const observation = generation.runtime_attestation.adapter;
|
|
265
|
+
return observation.state === "observed" ? observation.value.id : undefined;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function isAdapter(value: string | undefined): value is Adapter {
|
|
269
|
+
return value === "claude-code" || value === "cursor" || value === "codex";
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function observedModel(generation: CoordinationGenerationViewV3): string | undefined {
|
|
273
|
+
const observation = generation.runtime_attestation.model;
|
|
274
|
+
return observation.state === "observed" ? observation.value.id : undefined;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function isLifecycleState(value: string | undefined): value is "active" | "blocked" | "done" {
|
|
278
|
+
return value === "active" || value === "blocked" || value === "done";
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function writeHeartbeatCache(coordRoot: string, instanceId: string, heartbeat: Heartbeat): void {
|
|
282
|
+
if (!/^[a-zA-Z0-9._-]{1,128}$/.test(instanceId)) {
|
|
283
|
+
throw new Error("instance_id is unsafe for heartbeat materialization");
|
|
284
|
+
}
|
|
285
|
+
const path = join(coordRoot, ".harnery", "active", `${instanceId}.json`);
|
|
286
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
287
|
+
const temporary = `${path}.tmp.${process.pid}`;
|
|
288
|
+
writeFileSync(temporary, JSON.stringify(heartbeat, null, 2), "utf8");
|
|
289
|
+
renameSync(temporary, path);
|
|
290
|
+
}
|
|
@@ -4,7 +4,7 @@ export type AgentActivity = "unknown" | "working" | "needs_input" | "idle";
|
|
|
4
4
|
/** Whether the declared task remains open. Activity never changes this axis. */
|
|
5
5
|
export type TaskState = "active" | "blocked" | "done";
|
|
6
6
|
|
|
7
|
-
/** Raw fields stored in
|
|
7
|
+
/** Raw fields stored in the disposable V3 coordination cache and rebuilt from canonical events. */
|
|
8
8
|
export interface SessionStateFields {
|
|
9
9
|
activity?: AgentActivity;
|
|
10
10
|
activity_updated_at?: string;
|
|
@@ -26,14 +26,18 @@ export interface SessionStateSelector {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface SessionStateEvidenceEvent {
|
|
29
|
-
event_type:
|
|
29
|
+
event_type: EventTypeV3;
|
|
30
30
|
ts: string;
|
|
31
|
-
|
|
31
|
+
payload?: Record<string, unknown>;
|
|
32
32
|
instance_id?: string;
|
|
33
33
|
session_id?: string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const TERMINAL_ACTIVITY_EVENTS = new Set([
|
|
36
|
+
const TERMINAL_ACTIVITY_EVENTS: ReadonlySet<EventTypeV3> = new Set([
|
|
37
|
+
"session.ended",
|
|
38
|
+
"agent.completed",
|
|
39
|
+
"turn.completed",
|
|
40
|
+
]);
|
|
37
41
|
|
|
38
42
|
/**
|
|
39
43
|
* Apply one canonical event to the two independent state axes.
|
|
@@ -49,14 +53,20 @@ export function applySessionStateEvent(
|
|
|
49
53
|
): SessionStateFields {
|
|
50
54
|
const next: SessionStateFields = { ...current };
|
|
51
55
|
|
|
52
|
-
if (
|
|
56
|
+
if (
|
|
57
|
+
event.event_type === "session.started" ||
|
|
58
|
+
event.event_type === "session.resumed" ||
|
|
59
|
+
event.event_type === "agent.started"
|
|
60
|
+
) {
|
|
53
61
|
setActivity(next, "idle", event);
|
|
54
|
-
} else if (event.event_type === "
|
|
62
|
+
} else if (event.event_type === "turn.started" || event.event_type === "tool.requested") {
|
|
55
63
|
setActivity(next, "working", event);
|
|
56
|
-
} else if (event.event_type === "
|
|
64
|
+
} else if (event.event_type === "wait.started") {
|
|
57
65
|
setActivity(next, "needs_input", event);
|
|
66
|
+
} else if (event.event_type === "wait.ended") {
|
|
67
|
+
setActivity(next, "working", event);
|
|
58
68
|
} else if (
|
|
59
|
-
event.event_type === "command.
|
|
69
|
+
event.event_type === "command.started" &&
|
|
60
70
|
(current.activity === "working" || current.activity === "needs_input")
|
|
61
71
|
) {
|
|
62
72
|
setActivity(next, "working", event);
|
|
@@ -64,13 +74,13 @@ export function applySessionStateEvent(
|
|
|
64
74
|
setActivity(next, "idle", event);
|
|
65
75
|
}
|
|
66
76
|
|
|
67
|
-
if (event.event_type === "
|
|
68
|
-
const
|
|
69
|
-
const state = field(
|
|
77
|
+
if (event.event_type === "coord.lifecycle_changed") {
|
|
78
|
+
const payload = event.payload ?? {};
|
|
79
|
+
const state = field(payload, "new_state");
|
|
70
80
|
if (state === "active" || state === "blocked" || state === "done") {
|
|
71
81
|
next.task_state = state;
|
|
72
82
|
next.task_state_updated_at = event.ts;
|
|
73
|
-
const reason = field(
|
|
83
|
+
const reason = field(payload, "reason");
|
|
74
84
|
if (typeof reason === "string" && reason.length > 0) {
|
|
75
85
|
next.task_state_reason = reason;
|
|
76
86
|
} else {
|
|
@@ -129,3 +139,5 @@ function timestamp(event: SessionStateEvidenceEvent): number {
|
|
|
129
139
|
function field(data: Record<string, unknown>, key: string): unknown {
|
|
130
140
|
return data[key];
|
|
131
141
|
}
|
|
142
|
+
|
|
143
|
+
import type { EventTypeV3 } from "../../events/v3/contract.ts";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Stale-sweep: prune dead heartbeats + orphaned pid-map + .last-peer-hash
|
|
3
3
|
* files.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Runs after session.started to clean up crashed-peer detritus before the new
|
|
6
6
|
* session's UX layer reads peer state.
|
|
7
7
|
*
|
|
8
8
|
* Freshness threshold defaults to 600s; configurable via the
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { existsSync, readdirSync, readFileSync, statSync, unlinkSync } from "node:fs";
|
|
14
14
|
import { join } from "node:path";
|
|
15
15
|
import { coordFreshnessSeconds } from "../../config.ts";
|
|
16
|
-
import {
|
|
16
|
+
import { recordLiveSweepObservationV3 } from "../live-lifecycle-v3.ts";
|
|
17
17
|
|
|
18
18
|
/** platform → adapter, for the swept-event envelope (mirrors heartbeat-writer's adapterOf). */
|
|
19
19
|
function adapterFromPlatform(platform: unknown): "claude-code" | "cursor" | "codex" {
|
|
@@ -22,7 +22,7 @@ function adapterFromPlatform(platform: unknown): "claude-code" | "cursor" | "cod
|
|
|
22
22
|
return "claude-code";
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/**
|
|
25
|
+
/** Record the sweep before deleting authority state. V3 ambiguity fails closed. */
|
|
26
26
|
function emitSwept(
|
|
27
27
|
coordRoot: string,
|
|
28
28
|
instanceId: string,
|
|
@@ -30,19 +30,24 @@ function emitSwept(
|
|
|
30
30
|
sessionId: string,
|
|
31
31
|
reason: "stale" | "unparseable" | "missing_ts",
|
|
32
32
|
ageSecs?: number,
|
|
33
|
-
):
|
|
33
|
+
): boolean {
|
|
34
34
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
recordLiveSweepObservationV3({
|
|
36
|
+
coordRoot,
|
|
37
|
+
owner: instanceId,
|
|
38
|
+
nativeSessionId: sessionId,
|
|
39
39
|
adapter,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
observation:
|
|
41
|
+
reason === "stale"
|
|
42
|
+
? "stale_heartbeat"
|
|
43
|
+
: reason === "unparseable"
|
|
44
|
+
? "unparseable_heartbeat"
|
|
45
|
+
: "missing_timestamp",
|
|
46
|
+
ageMs: Math.max(0, (ageSecs ?? 0) * 1_000),
|
|
47
|
+
});
|
|
48
|
+
return true;
|
|
44
49
|
} catch {
|
|
45
|
-
|
|
50
|
+
return false;
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
|
|
@@ -68,7 +73,7 @@ export function staleSweep(coordRoot: string): {
|
|
|
68
73
|
const nowSec = Math.floor(Date.now() / 1000);
|
|
69
74
|
const cutoff = nowSec - freshness;
|
|
70
75
|
|
|
71
|
-
// 1. Prune stale
|
|
76
|
+
// 1. Prune stale rows from the disposable V3 coordination cache.
|
|
72
77
|
//
|
|
73
78
|
// Two deletion regimes, deliberately asymmetric:
|
|
74
79
|
// • Valid JSON with an OLD last_heartbeat → the legitimate dead/idle-agent
|
|
@@ -105,9 +110,14 @@ export function staleSweep(coordRoot: string): {
|
|
|
105
110
|
// Unparseable: only reap if the file itself is mtime-old.
|
|
106
111
|
if (mtimeSecs(path) < cutoff) {
|
|
107
112
|
try {
|
|
113
|
+
const ageSecs = nowSec - mtimeSecs(path);
|
|
114
|
+
if (
|
|
115
|
+
!emitSwept(coordRoot, idFromFile, "claude-code", idFromFile, "unparseable", ageSecs)
|
|
116
|
+
) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
108
119
|
unlinkSync(path);
|
|
109
120
|
heartbeatsRemoved.push(f);
|
|
110
|
-
emitSwept(coordRoot, idFromFile, "claude-code", idFromFile, "unparseable");
|
|
111
121
|
} catch {
|
|
112
122
|
/* swallow */
|
|
113
123
|
}
|
|
@@ -125,9 +135,20 @@ export function staleSweep(coordRoot: string): {
|
|
|
125
135
|
if (!parsed.last_heartbeat || !Number.isFinite(ts)) {
|
|
126
136
|
// No / NaN last_heartbeat: can't trust content; gate on mtime.
|
|
127
137
|
if (mtimeSecs(path) < cutoff) {
|
|
138
|
+
if (
|
|
139
|
+
!emitSwept(
|
|
140
|
+
coordRoot,
|
|
141
|
+
instanceId,
|
|
142
|
+
adapter,
|
|
143
|
+
sessionId,
|
|
144
|
+
"missing_ts",
|
|
145
|
+
nowSec - mtimeSecs(path),
|
|
146
|
+
)
|
|
147
|
+
) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
128
150
|
unlinkSync(path);
|
|
129
151
|
heartbeatsRemoved.push(f);
|
|
130
|
-
emitSwept(coordRoot, instanceId, adapter, sessionId, "missing_ts");
|
|
131
152
|
} else if (parsed.instance_id) {
|
|
132
153
|
liveInstanceIds.add(parsed.instance_id);
|
|
133
154
|
}
|
|
@@ -136,9 +157,11 @@ export function staleSweep(coordRoot: string): {
|
|
|
136
157
|
|
|
137
158
|
if (ts < cutoff) {
|
|
138
159
|
// Legitimate stale prune (valid timestamp, past the freshness cutoff).
|
|
160
|
+
if (!emitSwept(coordRoot, instanceId, adapter, sessionId, "stale", nowSec - ts)) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
139
163
|
unlinkSync(path);
|
|
140
164
|
heartbeatsRemoved.push(f);
|
|
141
|
-
emitSwept(coordRoot, instanceId, adapter, sessionId, "stale", nowSec - ts);
|
|
142
165
|
continue;
|
|
143
166
|
}
|
|
144
167
|
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
writeFileSync,
|
|
23
23
|
} from "node:fs";
|
|
24
24
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
25
|
+
import { readLiveCoordinationRow } from "../agents/state/live-coordination-view.ts";
|
|
25
26
|
import { artifactDefaultRetentionDays } from "../config.ts";
|
|
26
27
|
|
|
27
28
|
export const ARTIFACTS_DIR = join(".harnery", "artifacts");
|
|
@@ -437,12 +438,10 @@ function ownerLiveness(
|
|
|
437
438
|
now: Date,
|
|
438
439
|
freshnessSeconds: number,
|
|
439
440
|
): "live" | "stale" | "unknown" {
|
|
440
|
-
const path = join(repoRoot, ".harnery", "active", `${instanceId}.json`);
|
|
441
|
-
if (!existsSync(path)) return "stale";
|
|
442
441
|
try {
|
|
443
|
-
const
|
|
444
|
-
if (
|
|
445
|
-
const ts = Date.parse(
|
|
442
|
+
const row = readLiveCoordinationRow(repoRoot, instanceId);
|
|
443
|
+
if (!row) return "stale";
|
|
444
|
+
const ts = Date.parse(row.last_heartbeat);
|
|
446
445
|
if (!Number.isFinite(ts)) return "unknown";
|
|
447
446
|
return now.getTime() - ts <= freshnessSeconds * 1000 ? "live" : "stale";
|
|
448
447
|
} catch {
|