harnery 0.32.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/README.md +2 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +7 -1
- 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 +1408 -565
- 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 +2 -2
- package/dist/commands/claude-desktop.d.ts.map +1 -1
- package/dist/commands/claude-desktop.js +2 -2
- 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.d.ts +4 -2
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +55 -7
- 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 +10 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +233 -51
- package/dist/commands/instructions.d.ts +4 -0
- package/dist/commands/instructions.d.ts.map +1 -0
- package/dist/commands/instructions.js +100 -0
- 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 +15 -6
- 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 +27 -25
- package/dist/core/agents/cli.js +212 -235
- 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 -70
- 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 +5 -5
- package/dist/core/agents/index.d.ts.map +1 -1
- package/dist/core/agents/index.js +5 -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 +10 -4
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +61 -55
- 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 +15 -33
- 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 +29 -46
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +59 -199
- 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 +45 -0
- package/dist/core/agents/state/session-state.d.ts.map +1 -0
- package/dist/core/agents/state/session-state.js +90 -0
- 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 +13 -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 +64 -24
- 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 +345 -400
- package/dist/core/hooks/codex-authorization.d.ts +30 -0
- package/dist/core/hooks/codex-authorization.d.ts.map +1 -0
- package/dist/core/hooks/codex-authorization.js +199 -0
- 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 +8 -3
- package/dist/core/presence/blob.d.ts.map +1 -1
- package/dist/core/presence/blob.js +54 -41
- 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/index.js +15 -1
- 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/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 +33 -0
- package/dist/lib/instructions/bundle.d.ts.map +1 -0
- package/dist/lib/instructions/bundle.js +149 -0
- 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 +27 -6
- 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 +7 -1
- package/src/commands/adapter.ts +2 -2
- package/src/commands/agents.ts +1737 -570
- 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 +7 -5
- 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 +73 -8
- package/src/commands/events.ts +256 -0
- package/src/commands/governor.ts +18 -4
- package/src/commands/init.ts +264 -57
- package/src/commands/instructions.ts +129 -0
- package/src/commands/journal.ts +4 -13
- package/src/commands/ledger-v3.ts +111 -0
- package/src/commands/presence.ts +18 -11
- 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 +39 -28
- package/src/core/agents/cli.ts +242 -263
- package/src/core/agents/codex-archive-v3.ts +138 -0
- package/src/core/agents/coord-client.ts +75 -177
- package/src/core/agents/finalization.ts +120 -38
- package/src/core/agents/index.ts +5 -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 +89 -55
- package/src/core/agents/render/session-context.ts +23 -32
- 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 +98 -242
- package/src/core/agents/state/live-coordination-view.ts +290 -0
- package/src/core/agents/state/session-state.ts +143 -0
- 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 +15 -6
- package/src/core/hooks/adapter/output.ts +7 -2
- package/src/core/hooks/adapter/parse.ts +81 -36
- package/src/core/hooks/adapter/wiring.ts +119 -13
- package/src/core/hooks/cli.ts +398 -422
- package/src/core/hooks/codex-authorization.ts +253 -0
- 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 +63 -38
- package/src/core/presence/codec-digest.ts +215 -0
- package/src/core/presence/index.ts +18 -1
- 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/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 +199 -0
- 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 -65
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +0 -1
- package/dist/core/agents/state/heartbeat-projector.js +0 -527
- 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 -312
- 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 -582
- 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 -538
- package/src/core/hooks/events/ulid.ts +0 -51
- package/src/lib/docs-frontmatter-migrate.ts +0 -427
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import {
|
|
3
|
+
chmodSync,
|
|
4
|
+
closeSync,
|
|
5
|
+
existsSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
openSync,
|
|
8
|
+
readdirSync,
|
|
9
|
+
readFileSync,
|
|
10
|
+
rmSync,
|
|
11
|
+
statSync,
|
|
12
|
+
writeSync,
|
|
13
|
+
} from "node:fs";
|
|
14
|
+
import { basename, join, resolve } from "node:path";
|
|
15
|
+
|
|
16
|
+
const DEFAULT_TTL_MS = 15 * 60 * 1_000;
|
|
17
|
+
const HARD_MAX_TTL_MS = 60 * 60 * 1_000;
|
|
18
|
+
const MAX_INTENT_CHARS = 240;
|
|
19
|
+
const MAX_TARGET_LABELS = 16;
|
|
20
|
+
const MAX_TARGET_CHARS = 160;
|
|
21
|
+
const MAX_ROW_BYTES = 8 * 1_024;
|
|
22
|
+
const GENERATION_PATTERN =
|
|
23
|
+
/^gen_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
24
|
+
const EVENT_PATTERN = /^evt_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
25
|
+
const EXECUTABLE_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._+-]{0,63}$/;
|
|
26
|
+
const TARGET_PATTERN = /^[a-zA-Z0-9._@+-]+(?:\/[a-zA-Z0-9._@+ -]+)*$/;
|
|
27
|
+
|
|
28
|
+
export const EVENT_V3_LIVE_RELATIVE_ROOT = ".harnery/live/v3" as const;
|
|
29
|
+
|
|
30
|
+
export interface LiveDisplayInputV3 {
|
|
31
|
+
generation_id: string;
|
|
32
|
+
event_id: string;
|
|
33
|
+
executable?: string;
|
|
34
|
+
intent_display?: string;
|
|
35
|
+
target_labels?: string[];
|
|
36
|
+
ttl_ms?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface LiveDisplayRowV3 {
|
|
40
|
+
format: "harnery-event-v3-live-display";
|
|
41
|
+
format_version: 1;
|
|
42
|
+
row_id: `live_${string}`;
|
|
43
|
+
generation_id: string;
|
|
44
|
+
event_id: string;
|
|
45
|
+
written_at: string;
|
|
46
|
+
expires_at: string;
|
|
47
|
+
executable?: string;
|
|
48
|
+
intent_display?: string;
|
|
49
|
+
target_labels?: string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface LiveDisplayJanitorResultV3 {
|
|
53
|
+
scanned: number;
|
|
54
|
+
removed: number;
|
|
55
|
+
retained: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Append one best-effort operator-display row. The narrow input shape has no
|
|
60
|
+
* fields for prompts, argv, tool input, output, exception bodies, or messages.
|
|
61
|
+
*/
|
|
62
|
+
export function writeLiveDisplayV3(
|
|
63
|
+
coordRoot: string,
|
|
64
|
+
input: LiveDisplayInputV3,
|
|
65
|
+
now: () => Date = () => new Date(),
|
|
66
|
+
): LiveDisplayRowV3 {
|
|
67
|
+
assertLiveIds(input.generation_id, input.event_id);
|
|
68
|
+
const ttlMs = input.ttl_ms ?? DEFAULT_TTL_MS;
|
|
69
|
+
if (!Number.isSafeInteger(ttlMs) || ttlMs <= 0 || ttlMs > HARD_MAX_TTL_MS) {
|
|
70
|
+
throw new Error("V3 live-display TTL must be between 1 ms and 1 hour");
|
|
71
|
+
}
|
|
72
|
+
if (input.executable !== undefined && !EXECUTABLE_PATTERN.test(input.executable)) {
|
|
73
|
+
throw new Error("V3 live-display executable is invalid");
|
|
74
|
+
}
|
|
75
|
+
const writtenAt = now();
|
|
76
|
+
const intentDisplay = safeIntentDisplayV3(input.intent_display);
|
|
77
|
+
const targetLabels = safeTargetLabels(input.target_labels);
|
|
78
|
+
const row: LiveDisplayRowV3 = {
|
|
79
|
+
format: "harnery-event-v3-live-display",
|
|
80
|
+
format_version: 1,
|
|
81
|
+
row_id: `live_${randomUUID()}`,
|
|
82
|
+
generation_id: input.generation_id,
|
|
83
|
+
event_id: input.event_id,
|
|
84
|
+
written_at: writtenAt.toISOString(),
|
|
85
|
+
expires_at: new Date(writtenAt.getTime() + ttlMs).toISOString(),
|
|
86
|
+
...(input.executable ? { executable: input.executable } : {}),
|
|
87
|
+
...(intentDisplay ? { intent_display: intentDisplay } : {}),
|
|
88
|
+
...(targetLabels.length > 0 ? { target_labels: targetLabels } : {}),
|
|
89
|
+
};
|
|
90
|
+
const serialized = `${JSON.stringify(row)}\n`;
|
|
91
|
+
if (Buffer.byteLength(serialized, "utf8") > MAX_ROW_BYTES) {
|
|
92
|
+
throw new Error("V3 live-display row exceeds its bounded size");
|
|
93
|
+
}
|
|
94
|
+
const root = liveRoot(coordRoot);
|
|
95
|
+
mkdirSync(root, { recursive: true, mode: 0o700 });
|
|
96
|
+
chmodSync(root, 0o700);
|
|
97
|
+
const path = join(root, `${input.generation_id}.ndjson`);
|
|
98
|
+
const fd = openSync(path, "a", 0o600);
|
|
99
|
+
try {
|
|
100
|
+
writeSync(fd, serialized, undefined, "utf8");
|
|
101
|
+
} finally {
|
|
102
|
+
closeSync(fd);
|
|
103
|
+
}
|
|
104
|
+
chmodSync(path, 0o600);
|
|
105
|
+
return row;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Best-effort overlay write for producers. Never throws: the live feed is
|
|
110
|
+
* presentation-only and must not fail a durable ledger append.
|
|
111
|
+
*/
|
|
112
|
+
export function tryWriteLiveDisplayV3(
|
|
113
|
+
coordRoot: string,
|
|
114
|
+
input: LiveDisplayInputV3,
|
|
115
|
+
now: () => Date = () => new Date(),
|
|
116
|
+
): LiveDisplayRowV3 | undefined {
|
|
117
|
+
try {
|
|
118
|
+
return writeLiveDisplayV3(coordRoot, input, now);
|
|
119
|
+
} catch {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Return every unexpired live-display row across generations. */
|
|
125
|
+
export function listLiveDisplayV3(
|
|
126
|
+
coordRoot: string,
|
|
127
|
+
now: () => Date = () => new Date(),
|
|
128
|
+
): LiveDisplayRowV3[] {
|
|
129
|
+
const root = liveRoot(coordRoot);
|
|
130
|
+
if (!existsSync(root)) return [];
|
|
131
|
+
const rows: LiveDisplayRowV3[] = [];
|
|
132
|
+
for (const name of readdirSync(root)) {
|
|
133
|
+
if (!name.endsWith(".ndjson")) continue;
|
|
134
|
+
const generationId = name.slice(0, -".ndjson".length);
|
|
135
|
+
if (!GENERATION_PATTERN.test(generationId)) continue;
|
|
136
|
+
rows.push(...readLiveDisplayV3(coordRoot, generationId, now));
|
|
137
|
+
}
|
|
138
|
+
return rows;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Return only unexpired, structurally valid rows. Expiry is enforced before cleanup. */
|
|
142
|
+
export function readLiveDisplayV3(
|
|
143
|
+
coordRoot: string,
|
|
144
|
+
generationId: string,
|
|
145
|
+
now: () => Date = () => new Date(),
|
|
146
|
+
): LiveDisplayRowV3[] {
|
|
147
|
+
if (!GENERATION_PATTERN.test(generationId))
|
|
148
|
+
throw new Error("V3 live-display generation ID is invalid");
|
|
149
|
+
const path = join(liveRoot(coordRoot), `${generationId}.ndjson`);
|
|
150
|
+
if (!existsSync(path)) return [];
|
|
151
|
+
const nowMs = now().getTime();
|
|
152
|
+
return readFileSync(path, "utf8")
|
|
153
|
+
.split("\n")
|
|
154
|
+
.filter(Boolean)
|
|
155
|
+
.flatMap((frame) => {
|
|
156
|
+
try {
|
|
157
|
+
const row = validateLiveRow(JSON.parse(frame));
|
|
158
|
+
const writtenMs = Date.parse(row.written_at);
|
|
159
|
+
const expiresMs = Date.parse(row.expires_at);
|
|
160
|
+
if (expiresMs <= nowMs || writtenMs + HARD_MAX_TTL_MS <= nowMs) return [];
|
|
161
|
+
return [row];
|
|
162
|
+
} catch {
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Remove fully expired generation files; malformed residue is bounded by the hard maximum. */
|
|
169
|
+
export function janitorLiveDisplayV3(
|
|
170
|
+
coordRoot: string,
|
|
171
|
+
now: () => Date = () => new Date(),
|
|
172
|
+
): LiveDisplayJanitorResultV3 {
|
|
173
|
+
const root = liveRoot(coordRoot);
|
|
174
|
+
if (!existsSync(root)) return { scanned: 0, removed: 0, retained: 0 };
|
|
175
|
+
const nowMs = now().getTime();
|
|
176
|
+
let scanned = 0;
|
|
177
|
+
let removed = 0;
|
|
178
|
+
let retained = 0;
|
|
179
|
+
for (const name of readdirSync(root)) {
|
|
180
|
+
if (!name.endsWith(".ndjson")) continue;
|
|
181
|
+
scanned += 1;
|
|
182
|
+
const path = join(root, basename(name));
|
|
183
|
+
const visible = GENERATION_PATTERN.test(name.slice(0, -".ndjson".length))
|
|
184
|
+
? readLiveDisplayV3(coordRoot, name.slice(0, -".ndjson".length), now)
|
|
185
|
+
: [];
|
|
186
|
+
const hardExpired = statSync(path).mtimeMs + HARD_MAX_TTL_MS <= nowMs;
|
|
187
|
+
if (visible.length === 0 || hardExpired) {
|
|
188
|
+
rmSync(path, { force: true });
|
|
189
|
+
removed += 1;
|
|
190
|
+
} else {
|
|
191
|
+
retained += 1;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return { scanned, removed, retained };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Conservative allowlist scrubber: uncertainty omits the display instead of partially rendering it. */
|
|
198
|
+
export function safeIntentDisplayV3(value: string | undefined): string | undefined {
|
|
199
|
+
if (value === undefined) return undefined;
|
|
200
|
+
const normalized = value.normalize("NFC").replace(/\s+/g, " ").trim();
|
|
201
|
+
if (normalized.length === 0 || normalized.length > MAX_INTENT_CHARS) return undefined;
|
|
202
|
+
if (
|
|
203
|
+
[...normalized].some((character) => {
|
|
204
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
205
|
+
return codePoint < 32 || codePoint === 127;
|
|
206
|
+
})
|
|
207
|
+
) {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
if (
|
|
211
|
+
/\b(?:password|passwd|secret|token|api[_-]?key|authorization|cookie)\s*[:=]/i.test(normalized)
|
|
212
|
+
) {
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
if (
|
|
216
|
+
/\b(?:sk-[a-z0-9_-]{8,}|gh[pousr]_[a-z0-9]{8,}|xox[baprs]-|AKIA[A-Z0-9]{12}|AIza[\w-]{12,})/i.test(
|
|
217
|
+
normalized,
|
|
218
|
+
)
|
|
219
|
+
) {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
if (
|
|
223
|
+
/-----BEGIN [A-Z ]+PRIVATE KEY-----|\beyJ[A-Za-z0-9_-]{12,}\.[A-Za-z0-9_-]{8,}/.test(normalized)
|
|
224
|
+
) {
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
if (/\b[A-Za-z0-9_+/=-]{32,}\b/.test(normalized)) return undefined;
|
|
228
|
+
if (/\b[\w.+-]+@[\w.-]+\.[A-Za-z]{2,}\b/.test(normalized)) return undefined;
|
|
229
|
+
if (/(?:^|\s)(?:\/[A-Za-z]|[A-Za-z]:\\|\\\\|\/\/wsl)/.test(normalized)) return undefined;
|
|
230
|
+
if (/[`]|\$\(|&&|\|\||(?:^|\s)--[a-z]/.test(normalized)) return undefined;
|
|
231
|
+
return normalized;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function safeTargetLabels(values: string[] | undefined): string[] {
|
|
235
|
+
if (!values || values.length > MAX_TARGET_LABELS) return [];
|
|
236
|
+
const safe = values
|
|
237
|
+
.map((value) => value.normalize("NFC").trim())
|
|
238
|
+
.filter(
|
|
239
|
+
(value) =>
|
|
240
|
+
value.length > 0 &&
|
|
241
|
+
value.length <= MAX_TARGET_CHARS &&
|
|
242
|
+
TARGET_PATTERN.test(value) &&
|
|
243
|
+
!value.startsWith("/") &&
|
|
244
|
+
!value.split("/").includes("..") &&
|
|
245
|
+
safeIntentDisplayV3(value) !== undefined,
|
|
246
|
+
);
|
|
247
|
+
return [...new Set(safe)];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function validateLiveRow(value: unknown): LiveDisplayRowV3 {
|
|
251
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
252
|
+
throw new Error("invalid live-display row");
|
|
253
|
+
}
|
|
254
|
+
const row = value as Record<string, unknown>;
|
|
255
|
+
const allowed = new Set([
|
|
256
|
+
"format",
|
|
257
|
+
"format_version",
|
|
258
|
+
"row_id",
|
|
259
|
+
"generation_id",
|
|
260
|
+
"event_id",
|
|
261
|
+
"written_at",
|
|
262
|
+
"expires_at",
|
|
263
|
+
"executable",
|
|
264
|
+
"intent_display",
|
|
265
|
+
"target_labels",
|
|
266
|
+
]);
|
|
267
|
+
if (Object.keys(row).some((key) => !allowed.has(key)))
|
|
268
|
+
throw new Error("invalid live-display row");
|
|
269
|
+
if (
|
|
270
|
+
row.format !== "harnery-event-v3-live-display" ||
|
|
271
|
+
row.format_version !== 1 ||
|
|
272
|
+
typeof row.row_id !== "string" ||
|
|
273
|
+
!/^live_[0-9a-f-]{36}$/.test(row.row_id) ||
|
|
274
|
+
typeof row.generation_id !== "string" ||
|
|
275
|
+
typeof row.event_id !== "string" ||
|
|
276
|
+
typeof row.written_at !== "string" ||
|
|
277
|
+
typeof row.expires_at !== "string"
|
|
278
|
+
) {
|
|
279
|
+
throw new Error("invalid live-display row");
|
|
280
|
+
}
|
|
281
|
+
assertLiveIds(row.generation_id, row.event_id);
|
|
282
|
+
if (typeof row.executable === "string" && !EXECUTABLE_PATTERN.test(row.executable)) {
|
|
283
|
+
throw new Error("invalid live-display row");
|
|
284
|
+
}
|
|
285
|
+
if (
|
|
286
|
+
typeof row.intent_display === "string" &&
|
|
287
|
+
safeIntentDisplayV3(row.intent_display) !== row.intent_display
|
|
288
|
+
) {
|
|
289
|
+
throw new Error("invalid live-display row");
|
|
290
|
+
}
|
|
291
|
+
if (
|
|
292
|
+
row.target_labels !== undefined &&
|
|
293
|
+
(!Array.isArray(row.target_labels) ||
|
|
294
|
+
safeTargetLabels(row.target_labels as string[]).length !== row.target_labels.length)
|
|
295
|
+
) {
|
|
296
|
+
throw new Error("invalid live-display row");
|
|
297
|
+
}
|
|
298
|
+
const writtenMs = Date.parse(row.written_at);
|
|
299
|
+
const expiresMs = Date.parse(row.expires_at);
|
|
300
|
+
if (
|
|
301
|
+
Number.isNaN(writtenMs) ||
|
|
302
|
+
Number.isNaN(expiresMs) ||
|
|
303
|
+
expiresMs <= writtenMs ||
|
|
304
|
+
expiresMs - writtenMs > HARD_MAX_TTL_MS
|
|
305
|
+
) {
|
|
306
|
+
throw new Error("invalid live-display row");
|
|
307
|
+
}
|
|
308
|
+
return row as unknown as LiveDisplayRowV3;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function assertLiveIds(generationId: string, eventId: string): void {
|
|
312
|
+
if (!GENERATION_PATTERN.test(generationId) || !EVENT_PATTERN.test(eventId)) {
|
|
313
|
+
throw new Error("V3 live-display identity is invalid");
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function liveRoot(coordRoot: string): string {
|
|
318
|
+
return join(resolve(coordRoot), EVENT_V3_LIVE_RELATIVE_ROOT);
|
|
319
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Privacy-bounded coordination observations accepted by live V3 emitters.
|
|
3
|
+
*
|
|
4
|
+
* This is a dependency-free shared contract so downstream mirrors can type
|
|
5
|
+
* their emit surfaces without importing the authority implementation.
|
|
6
|
+
*/
|
|
7
|
+
export type LiveCoordinationObservationV3 =
|
|
8
|
+
| {
|
|
9
|
+
event_type: "coord.status_observed";
|
|
10
|
+
status: string;
|
|
11
|
+
subject?: string;
|
|
12
|
+
}
|
|
13
|
+
| {
|
|
14
|
+
event_type: "coord.presence_changed";
|
|
15
|
+
prior_state?: string;
|
|
16
|
+
new_state: string;
|
|
17
|
+
reason: string;
|
|
18
|
+
}
|
|
19
|
+
| {
|
|
20
|
+
event_type: "coord.message_observed";
|
|
21
|
+
message_id?: string;
|
|
22
|
+
direction: "sent" | "received";
|
|
23
|
+
body: string;
|
|
24
|
+
subject?: string;
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
event_type: "council.state_changed";
|
|
28
|
+
council_id: string;
|
|
29
|
+
prior_state?: string;
|
|
30
|
+
new_state: string;
|
|
31
|
+
record: unknown;
|
|
32
|
+
}
|
|
33
|
+
| {
|
|
34
|
+
event_type: "decision.state_changed";
|
|
35
|
+
decision_id: string;
|
|
36
|
+
prior_state?: string;
|
|
37
|
+
new_state: string;
|
|
38
|
+
record: unknown;
|
|
39
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import type { Adapter } from "../../adapter.ts";
|
|
3
|
+
import type { ParsedPayload } from "../../hooks/adapter/parse.ts";
|
|
4
|
+
import {
|
|
5
|
+
type EventV3WriteMode,
|
|
6
|
+
readEventV3ControlState,
|
|
7
|
+
repairEventV3ControlPair,
|
|
8
|
+
} from "./control.ts";
|
|
9
|
+
import type { HookSignalV3 } from "./producers/hook.ts";
|
|
10
|
+
import type { TurnRitualEvidenceV3 } from "./producers/hook-base.ts";
|
|
11
|
+
import { type RecordHookSignalV3Result, recordHookSignalV3 } from "./producers/recorder.ts";
|
|
12
|
+
|
|
13
|
+
export const LIVE_HOOK_V3_PRODUCER_ID = "prd_agent-hook" as const;
|
|
14
|
+
export const LIVE_COMMAND_V3_PRODUCER_ID = "prd_session-tee" as const;
|
|
15
|
+
|
|
16
|
+
export type LiveEventLedgerRouteV3 =
|
|
17
|
+
| { state: "v3"; mode: EventV3WriteMode; build_id: `build_${string}` }
|
|
18
|
+
| { state: "blocked"; reason: string };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Resolve the V3-only ledger route. A root without an initialized V3 control
|
|
22
|
+
* packet is blocked; no producer or consumer may fall back to an older ledger.
|
|
23
|
+
* Manifest-first crashes are repaired from the immutable packet and every
|
|
24
|
+
* other invalid state closes the writer gate.
|
|
25
|
+
*/
|
|
26
|
+
export function resolveLiveEventLedgerRouteV3(coordRoot: string): LiveEventLedgerRouteV3 {
|
|
27
|
+
let control = readEventV3ControlState(coordRoot);
|
|
28
|
+
if (control.state === "closed") return { state: "blocked", reason: "v3_not_initialized" };
|
|
29
|
+
if (control.state === "repairable") control = repairEventV3ControlPair(coordRoot);
|
|
30
|
+
if (control.state !== "candidate" && control.state !== "active") {
|
|
31
|
+
return { state: "blocked", reason: `${control.state}:${control.reason}` };
|
|
32
|
+
}
|
|
33
|
+
const buildId = liveEventV3BuildId(control.genesis.profile.harnery_commit);
|
|
34
|
+
if (!control.genesis.profile.producer_build_ids.includes(buildId)) {
|
|
35
|
+
return { state: "blocked", reason: "live_producer_build_not_approved" };
|
|
36
|
+
}
|
|
37
|
+
return { state: "v3", mode: control.state, build_id: buildId };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function liveEventV3BuildId(harneryCommit: string): `build_${string}` {
|
|
41
|
+
const exact = harneryCommit.normalize("NFC");
|
|
42
|
+
if (/^[a-zA-Z0-9._-]{1,120}$/.test(exact)) return `build_${exact}`;
|
|
43
|
+
return `build_${createHash("sha256").update(exact).digest("hex")}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function liveInstanceIdV3(instanceId: string): `inst_${string}` {
|
|
47
|
+
if (/^inst_[a-zA-Z0-9._-]{1,128}$/.test(instanceId)) return instanceId as `inst_${string}`;
|
|
48
|
+
if (/^[a-zA-Z0-9._-]{1,128}$/.test(instanceId)) return `inst_${instanceId}`;
|
|
49
|
+
return `inst_${createHash("sha256").update(instanceId.normalize("NFC")).digest("hex")}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The adapter-native id a canonical `inst_*` id carries, for display and for
|
|
54
|
+
* joins against native-keyed records. Only the direct prefix form round-trips:
|
|
55
|
+
* a hashed id has no recoverable native form and is returned unchanged, so
|
|
56
|
+
* never treat this as a guaranteed inverse of `liveInstanceIdV3`.
|
|
57
|
+
*/
|
|
58
|
+
export function nativeInstanceIdV3(instanceId: string): string {
|
|
59
|
+
return instanceId.startsWith("inst_") ? instanceId.slice("inst_".length) : instanceId;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function hookSignalV3(eventName: string): HookSignalV3 | undefined {
|
|
63
|
+
switch (eventName) {
|
|
64
|
+
case "session-start":
|
|
65
|
+
case "session-end":
|
|
66
|
+
case "user-prompt-submit":
|
|
67
|
+
case "stop":
|
|
68
|
+
case "stop-failure":
|
|
69
|
+
case "pre-tool-use":
|
|
70
|
+
case "post-tool-use":
|
|
71
|
+
case "post-tool-use-failure":
|
|
72
|
+
case "permission-request":
|
|
73
|
+
case "sub-agent-start":
|
|
74
|
+
case "sub-agent-stop":
|
|
75
|
+
case "pre-compact":
|
|
76
|
+
case "post-compact":
|
|
77
|
+
return eventName;
|
|
78
|
+
case "before-shell-execution":
|
|
79
|
+
return "pre-tool-use";
|
|
80
|
+
case "after-shell-execution":
|
|
81
|
+
return "post-tool-use";
|
|
82
|
+
default:
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function recordLiveHookSignalV3(input: {
|
|
88
|
+
coordRoot: string;
|
|
89
|
+
route: Extract<LiveEventLedgerRouteV3, { state: "v3" }>;
|
|
90
|
+
eventName: string;
|
|
91
|
+
payload: ParsedPayload | null;
|
|
92
|
+
adapter: Adapter;
|
|
93
|
+
instanceId: string;
|
|
94
|
+
run_id?: `run_${string}`;
|
|
95
|
+
workflow_id?: `wf_${string}`;
|
|
96
|
+
workflow_agent_id?: string;
|
|
97
|
+
bridge?: "codex-wsl";
|
|
98
|
+
monotonic_ns?: string;
|
|
99
|
+
hook_name?: string;
|
|
100
|
+
hook_duration_ms?: number;
|
|
101
|
+
stop_remediation?: boolean;
|
|
102
|
+
turn_ritual?: TurnRitualEvidenceV3;
|
|
103
|
+
defer_drain?: boolean;
|
|
104
|
+
}): RecordHookSignalV3Result | { state: "ignored" } {
|
|
105
|
+
const signal = hookSignalV3(input.eventName);
|
|
106
|
+
if (!signal) return { state: "ignored" };
|
|
107
|
+
return recordHookSignalV3({
|
|
108
|
+
coordRoot: input.coordRoot,
|
|
109
|
+
mode: input.route.mode,
|
|
110
|
+
signal,
|
|
111
|
+
payload: input.payload ?? { raw: {} },
|
|
112
|
+
adapter: input.adapter,
|
|
113
|
+
instance_id: liveInstanceIdV3(input.instanceId),
|
|
114
|
+
run_id: input.run_id,
|
|
115
|
+
workflow_id: input.workflow_id,
|
|
116
|
+
workflow_agent_id: input.workflow_agent_id,
|
|
117
|
+
producer_id: LIVE_HOOK_V3_PRODUCER_ID,
|
|
118
|
+
build_id: input.route.build_id,
|
|
119
|
+
platform: livePlatformV3(),
|
|
120
|
+
...(input.bridge ? { bridge: input.bridge } : {}),
|
|
121
|
+
monotonic_ns: input.monotonic_ns,
|
|
122
|
+
hook_name: input.hook_name,
|
|
123
|
+
hook_duration_ms: input.hook_duration_ms,
|
|
124
|
+
stop_remediation: input.stop_remediation,
|
|
125
|
+
turn_ritual: input.turn_ritual,
|
|
126
|
+
...(input.defer_drain ? { writerOptions: { deferDrain: true } } : {}),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function livePlatformV3(): "linux" | "windows" | "macos" | "unknown" {
|
|
131
|
+
if (process.platform === "linux") return "linux";
|
|
132
|
+
if (process.platform === "win32") return "windows";
|
|
133
|
+
if (process.platform === "darwin") return "macos";
|
|
134
|
+
return "unknown";
|
|
135
|
+
}
|