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,126 @@
|
|
|
1
|
+
import type { Adapter } from "../adapter.ts";
|
|
2
|
+
import { recordLiveTaskChangeV3 } from "../agents/live-authority-v3.ts";
|
|
3
|
+
import { endSessionExplicitV3 } from "../agents/session-finalizer-v3.ts";
|
|
4
|
+
import {
|
|
5
|
+
clearCoordinationCache,
|
|
6
|
+
type Heartbeat,
|
|
7
|
+
setIdentityCache,
|
|
8
|
+
} from "../agents/state/heartbeat-writer.ts";
|
|
9
|
+
import {
|
|
10
|
+
ensureLiveCoordinationHeartbeat,
|
|
11
|
+
readLiveCoordinationRow,
|
|
12
|
+
} from "../agents/state/live-coordination-view.ts";
|
|
13
|
+
import { ensureEventLedgerV3 } from "../events/v3/bootstrap.ts";
|
|
14
|
+
import {
|
|
15
|
+
recordLiveHookSignalV3,
|
|
16
|
+
resolveLiveEventLedgerRouteV3,
|
|
17
|
+
} from "../events/v3/live-routing.ts";
|
|
18
|
+
import { stableScopeId } from "./scope-id.ts";
|
|
19
|
+
|
|
20
|
+
export interface WorkflowChildSessionV3Input {
|
|
21
|
+
coordRoot: string;
|
|
22
|
+
instanceId: string;
|
|
23
|
+
runId: string;
|
|
24
|
+
agentId: string;
|
|
25
|
+
sessionId?: string;
|
|
26
|
+
adapter?: string;
|
|
27
|
+
label?: string;
|
|
28
|
+
model?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Start a headless workflow child through the same canonical V3 producer as native hooks. */
|
|
32
|
+
export function startWorkflowChildSessionV3(input: WorkflowChildSessionV3Input): Heartbeat {
|
|
33
|
+
const adapter = workflowAdapter(input.adapter);
|
|
34
|
+
const sessionId = input.sessionId ?? input.instanceId;
|
|
35
|
+
const route = requireV3Route(input.coordRoot);
|
|
36
|
+
const result = recordLiveHookSignalV3({
|
|
37
|
+
coordRoot: input.coordRoot,
|
|
38
|
+
route,
|
|
39
|
+
eventName: "session-start",
|
|
40
|
+
adapter,
|
|
41
|
+
instanceId: input.instanceId,
|
|
42
|
+
run_id: stableScopeId("run", input.runId),
|
|
43
|
+
workflow_id: stableScopeId("wf", input.runId),
|
|
44
|
+
workflow_agent_id: input.agentId,
|
|
45
|
+
payload: {
|
|
46
|
+
session_id: sessionId,
|
|
47
|
+
model: input.model,
|
|
48
|
+
source: "workflow-engine",
|
|
49
|
+
raw: {},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
if (result.state !== "recorded" && result.state !== "already_started") {
|
|
53
|
+
throw new Error(`workflow_child_v3_start_failed:${result.state}`);
|
|
54
|
+
}
|
|
55
|
+
const cache = ensureLiveCoordinationHeartbeat(
|
|
56
|
+
input.coordRoot,
|
|
57
|
+
input.instanceId,
|
|
58
|
+
sessionId,
|
|
59
|
+
adapter,
|
|
60
|
+
input.model,
|
|
61
|
+
);
|
|
62
|
+
if (!cache) throw new Error("workflow_child_v3_cache_missing");
|
|
63
|
+
if (input.label) {
|
|
64
|
+
recordLiveTaskChangeV3({
|
|
65
|
+
coordRoot: input.coordRoot,
|
|
66
|
+
owner: input.instanceId,
|
|
67
|
+
nativeSessionId: sessionId,
|
|
68
|
+
adapter,
|
|
69
|
+
task: input.label,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (
|
|
73
|
+
!setIdentityCache(
|
|
74
|
+
input.coordRoot,
|
|
75
|
+
input.instanceId,
|
|
76
|
+
input.label ?? input.agentId,
|
|
77
|
+
input.agentId,
|
|
78
|
+
)
|
|
79
|
+
) {
|
|
80
|
+
throw new Error("workflow_child_v3_identity_cache_failed");
|
|
81
|
+
}
|
|
82
|
+
const projected = readLiveCoordinationRow(input.coordRoot, input.instanceId);
|
|
83
|
+
if (!projected) throw new Error("workflow_child_v3_projection_missing");
|
|
84
|
+
return projected;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Record the authoritative terminal before removing the disposable coordination cache. */
|
|
88
|
+
export function endWorkflowChildSessionV3(
|
|
89
|
+
input: WorkflowChildSessionV3Input & { cleanExit: boolean },
|
|
90
|
+
): void {
|
|
91
|
+
requireV3Route(input.coordRoot);
|
|
92
|
+
const row = readLiveCoordinationRow(input.coordRoot, input.instanceId);
|
|
93
|
+
if (!row?.v3_instance_id || !row.v3_generation_id) {
|
|
94
|
+
throw new Error("workflow_child_v3_generation_missing");
|
|
95
|
+
}
|
|
96
|
+
const result = endSessionExplicitV3({
|
|
97
|
+
coordRoot: input.coordRoot,
|
|
98
|
+
instance_id: row.v3_instance_id,
|
|
99
|
+
generation_id: row.v3_generation_id,
|
|
100
|
+
coordination_finalized: true,
|
|
101
|
+
outcome: input.cleanExit ? "succeeded" : "failed",
|
|
102
|
+
});
|
|
103
|
+
if (result.state !== "recorded" && result.state !== "already_ended") {
|
|
104
|
+
throw new Error(
|
|
105
|
+
`workflow_child_v3_end_failed:${result.state}${"reason" in result ? `:${result.reason}` : ""}`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
clearCoordinationCache(input.coordRoot, input.instanceId);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function requireV3Route(coordRoot: string) {
|
|
112
|
+
let route = resolveLiveEventLedgerRouteV3(coordRoot);
|
|
113
|
+
if (route.state === "blocked" && route.reason === "v3_not_initialized") {
|
|
114
|
+
ensureEventLedgerV3(coordRoot, "harnery-workflow-v3-universal");
|
|
115
|
+
route = resolveLiveEventLedgerRouteV3(coordRoot);
|
|
116
|
+
}
|
|
117
|
+
if (route.state === "blocked") throw new Error(`workflow_child_v3_gate:${route.reason}`);
|
|
118
|
+
return route;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function workflowAdapter(adapter: string | undefined): Adapter {
|
|
122
|
+
if (adapter === "codex" || adapter === "cursor" || adapter === "claude-code") return adapter;
|
|
123
|
+
return "claude-code";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { stableScopeId } from "./scope-id.ts";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
/** Stable opaque scope identity for a workflow run. Pure and safe for read-only consumers. */
|
|
4
|
+
export function stableScopeId<P extends "run" | "wf">(prefix: P, value: string): `${P}_${string}` {
|
|
5
|
+
return `${prefix}_${createHash("sha256").update(value.normalize("NFC")).digest("hex")}`;
|
|
6
|
+
}
|
|
@@ -18,6 +18,7 @@ import { hostname } from "node:os";
|
|
|
18
18
|
import { basename, dirname, join, resolve } from "node:path";
|
|
19
19
|
|
|
20
20
|
const MAX_LEASE_BYTES = 8 * 1024;
|
|
21
|
+
const MAX_CONTENTION_OBSERVATION_ATTEMPTS = 8;
|
|
21
22
|
const SAFE_COMPONENT = /^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/;
|
|
22
23
|
|
|
23
24
|
export interface NoClobberLeaseOwner {
|
|
@@ -49,6 +50,10 @@ export interface AcquireNoClobberLeaseInput {
|
|
|
49
50
|
now?: () => number;
|
|
50
51
|
pid?: number;
|
|
51
52
|
host?: string;
|
|
53
|
+
/** Fault-injection hook immediately before the lease directory is created. */
|
|
54
|
+
onLeaseDirectoryCreate?: () => void;
|
|
55
|
+
/** Fault-injection hook after contention is observed and before owner inspection. */
|
|
56
|
+
onContention?: () => void;
|
|
52
57
|
onRecoveryStep?: (step: LeaseRecoveryStep) => void;
|
|
53
58
|
}
|
|
54
59
|
|
|
@@ -74,7 +79,7 @@ interface RecoveryClaim {
|
|
|
74
79
|
export function acquireNoClobberLease(input: AcquireNoClobberLeaseInput): NoClobberLease {
|
|
75
80
|
validateInput(input);
|
|
76
81
|
const leaseDir = resolve(input.path);
|
|
77
|
-
ensureLeaseDirectory(leaseDir);
|
|
82
|
+
ensureLeaseDirectory(leaseDir, input.onLeaseDirectoryCreate);
|
|
78
83
|
|
|
79
84
|
const now = input.now ?? Date.now;
|
|
80
85
|
const created = now();
|
|
@@ -105,20 +110,32 @@ export function acquireNoClobberLease(input: AcquireNoClobberLeaseInput): NoClob
|
|
|
105
110
|
reclaimAbandonedRecovery(leaseDir, recoveryPath, input, now());
|
|
106
111
|
}
|
|
107
112
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
let observed: ReturnType<typeof readOwner> | undefined;
|
|
114
|
+
for (let attempt = 0; attempt < MAX_CONTENTION_OBSERVATION_ATTEMPTS; attempt += 1) {
|
|
115
|
+
try {
|
|
116
|
+
linkSync(ownerPath, currentPath);
|
|
117
|
+
fsyncDirectory(leaseDir);
|
|
118
|
+
assertExactOwner(currentPath, ownerPath, ownerBytes, owner);
|
|
119
|
+
if (existsSync(recoveryPath)) {
|
|
120
|
+
unlinkExactCurrent(currentPath, ownerPath);
|
|
121
|
+
throw new Error(`lease ${input.scope} recovery is already in progress`);
|
|
122
|
+
}
|
|
123
|
+
return leaseHandle(leaseDir, ownerPath, ownerBytes, owner);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
|
|
115
126
|
}
|
|
116
|
-
return leaseHandle(leaseDir, ownerPath, ownerBytes, owner);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
|
|
119
|
-
}
|
|
120
127
|
|
|
121
|
-
|
|
128
|
+
input.onContention?.();
|
|
129
|
+
try {
|
|
130
|
+
observed = readOwner(currentPath);
|
|
131
|
+
break;
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (observed === undefined) {
|
|
137
|
+
throw new Error(`lease ${input.scope} changed repeatedly during contention`);
|
|
138
|
+
}
|
|
122
139
|
if (leaseIsLive(observed.owner, now(), input.staleAfterMs)) {
|
|
123
140
|
throw new Error(`lease ${input.scope} is held by a live or unexpired owner`);
|
|
124
141
|
}
|
|
@@ -184,13 +201,20 @@ function validateInput(input: AcquireNoClobberLeaseInput): void {
|
|
|
184
201
|
}
|
|
185
202
|
}
|
|
186
203
|
|
|
187
|
-
function ensureLeaseDirectory(leaseDir: string): void {
|
|
204
|
+
function ensureLeaseDirectory(leaseDir: string, onCreate?: () => void): void {
|
|
188
205
|
mkdirSync(dirname(leaseDir), { recursive: true, mode: 0o700 });
|
|
189
|
-
|
|
206
|
+
let created = false;
|
|
207
|
+
onCreate?.();
|
|
208
|
+
try {
|
|
209
|
+
mkdirSync(leaseDir, { mode: 0o700 });
|
|
210
|
+
created = true;
|
|
211
|
+
} catch (error) {
|
|
212
|
+
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
|
|
213
|
+
}
|
|
214
|
+
if (!lstatSync(leaseDir).isDirectory()) {
|
|
190
215
|
throw new Error(`lease path is not a directory: ${leaseDir}`);
|
|
191
216
|
}
|
|
192
|
-
if (
|
|
193
|
-
mkdirSync(leaseDir, { mode: 0o700 });
|
|
217
|
+
if (created) {
|
|
194
218
|
fsyncDirectory(dirname(leaseDir));
|
|
195
219
|
}
|
|
196
220
|
}
|
|
@@ -377,10 +401,23 @@ function readOwner(path: string): { owner: NoClobberLeaseOwner; bytes: string }
|
|
|
377
401
|
if (!stat.isFile() || stat.isSymbolicLink()) throw new Error("lease owner is not a plain file");
|
|
378
402
|
size = stat.size;
|
|
379
403
|
} catch (error) {
|
|
380
|
-
|
|
404
|
+
const inspectionError = new Error(
|
|
405
|
+
`lease owner cannot be inspected: ${(error as Error).message}`,
|
|
406
|
+
) as NodeJS.ErrnoException;
|
|
407
|
+
inspectionError.code = (error as NodeJS.ErrnoException).code;
|
|
408
|
+
throw inspectionError;
|
|
381
409
|
}
|
|
382
410
|
if (size <= 0 || size > MAX_LEASE_BYTES) throw new Error("lease owner bytes are invalid");
|
|
383
|
-
|
|
411
|
+
let bytes: string;
|
|
412
|
+
try {
|
|
413
|
+
bytes = readFileSync(path, "utf8");
|
|
414
|
+
} catch (error) {
|
|
415
|
+
const inspectionError = new Error(
|
|
416
|
+
`lease owner cannot be read: ${(error as Error).message}`,
|
|
417
|
+
) as NodeJS.ErrnoException;
|
|
418
|
+
inspectionError.code = (error as NodeJS.ErrnoException).code;
|
|
419
|
+
throw inspectionError;
|
|
420
|
+
}
|
|
384
421
|
let value: unknown;
|
|
385
422
|
try {
|
|
386
423
|
value = JSON.parse(bytes);
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Examples of intended consumption:
|
|
6
6
|
* import { createHarneryProgram } from 'harnery'; // CLI composition
|
|
7
7
|
* import { evaluateClaim } from 'harnery/core/agents'; // verdict rule directly
|
|
8
|
-
* import type {
|
|
8
|
+
* import type { EventV3 } from 'harnery/core/events/v3'; // canonical schema types
|
|
9
9
|
*
|
|
10
10
|
* Heavy modules (web UI, hook scripts) are not re-exported from here; they're
|
|
11
11
|
* reachable via their own subpath entries in package.json#exports.
|
|
@@ -626,6 +626,236 @@ export class Browser {
|
|
|
626
626
|
}, selector);
|
|
627
627
|
}
|
|
628
628
|
|
|
629
|
+
/**
|
|
630
|
+
* Extract the page's visual atoms for content-aware tiling (tiling.ts):
|
|
631
|
+
* text line boxes (one per rendered line, so a cut between the lines of a
|
|
632
|
+
* paragraph is legal), replaced/intrinsically-visual elements, and small
|
|
633
|
+
* bordered boxes (cards, callouts — height-capped so section wrappers
|
|
634
|
+
* don't count). Coordinates are document-space CSS px.
|
|
635
|
+
*/
|
|
636
|
+
async visualAtoms(): Promise<
|
|
637
|
+
Array<{ kind: "text-line" | "replaced" | "box"; top: number; bottom: number }>
|
|
638
|
+
> {
|
|
639
|
+
return await this.currentPage.evaluate(() => {
|
|
640
|
+
const atoms: Array<{ kind: "text-line" | "replaced" | "box"; top: number; bottom: number }> =
|
|
641
|
+
[];
|
|
642
|
+
const sy = window.scrollY;
|
|
643
|
+
|
|
644
|
+
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
|
|
645
|
+
let node: Node | null = walker.nextNode();
|
|
646
|
+
while (node) {
|
|
647
|
+
if (node.textContent && node.textContent.trim().length > 0) {
|
|
648
|
+
const range = document.createRange();
|
|
649
|
+
range.selectNodeContents(node);
|
|
650
|
+
for (const r of Array.from(range.getClientRects())) {
|
|
651
|
+
if (r.height > 0 && r.width > 0) {
|
|
652
|
+
atoms.push({ kind: "text-line", top: r.top + sy, bottom: r.bottom + sy });
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
node = walker.nextNode();
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
for (const el of Array.from(
|
|
660
|
+
document.querySelectorAll("img, svg, canvas, video, input, button, select, textarea, hr"),
|
|
661
|
+
)) {
|
|
662
|
+
// Children of an inline <svg> are covered by the root svg's rect.
|
|
663
|
+
if (el instanceof SVGElement && el.ownerSVGElement) continue;
|
|
664
|
+
const r = el.getBoundingClientRect();
|
|
665
|
+
if (r.height > 0 && r.width > 0) {
|
|
666
|
+
atoms.push({ kind: "replaced", top: r.top + sy, bottom: r.bottom + sy });
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
for (const el of Array.from(document.body.querySelectorAll("*"))) {
|
|
671
|
+
if (el instanceof SVGElement) continue;
|
|
672
|
+
const cs = getComputedStyle(el);
|
|
673
|
+
const hasEdge =
|
|
674
|
+
(Number.parseFloat(cs.borderTopWidth) > 0 && cs.borderTopStyle !== "none") ||
|
|
675
|
+
Number.parseFloat(cs.borderRadius) > 0;
|
|
676
|
+
if (!hasEdge) continue;
|
|
677
|
+
const r = el.getBoundingClientRect();
|
|
678
|
+
if (r.height > 0 && r.height <= 600 && r.width > 0) {
|
|
679
|
+
atoms.push({ kind: "box", top: r.top + sy, bottom: r.bottom + sy });
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
return atoms;
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Capture the page's QA signature for diff-aware classification
|
|
689
|
+
* (qa-plan.ts): a structural fingerprint per element (path, tag, canonical
|
|
690
|
+
* attributes, direct-text digest, nearest stable-ancestor anchor) plus
|
|
691
|
+
* applied-stylesheet digests. DOM equality alone never proves a change is
|
|
692
|
+
* text-only — a one-line edit to a linked stylesheet changes zero DOM bytes
|
|
693
|
+
* and every pixel — so external sheet text is fetched and digested too; an
|
|
694
|
+
* unreadable sheet records digest "unavailable" and the classifier widens.
|
|
695
|
+
*/
|
|
696
|
+
async qaSignature(): Promise<{
|
|
697
|
+
nodes: Array<{
|
|
698
|
+
path: string;
|
|
699
|
+
tag: string;
|
|
700
|
+
attrs: string;
|
|
701
|
+
text?: string;
|
|
702
|
+
visual?: string;
|
|
703
|
+
anchor?: { selector: string; path: string };
|
|
704
|
+
}>;
|
|
705
|
+
stylesheets: Array<{ key: string; kind: "external" | "inline"; digest: string }>;
|
|
706
|
+
domHtml: string;
|
|
707
|
+
truncated: boolean;
|
|
708
|
+
}> {
|
|
709
|
+
return await this.currentPage.evaluate(async () => {
|
|
710
|
+
const MAX_NODES = 20_000;
|
|
711
|
+
const fnv = (text: string): string => {
|
|
712
|
+
let hash = 0x811c9dc5;
|
|
713
|
+
for (let i = 0; i < text.length; i++) {
|
|
714
|
+
hash ^= text.charCodeAt(i);
|
|
715
|
+
hash = Math.imul(hash, 0x01000193);
|
|
716
|
+
}
|
|
717
|
+
return `${(hash >>> 0).toString(16).padStart(8, "0")}-${text.length}`;
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
// Anchor uniqueness prepass: an id or data-qa-scope value that appears
|
|
721
|
+
// more than once is not a stable anchor.
|
|
722
|
+
const idCount = new Map<string, number>();
|
|
723
|
+
for (const el of Array.from(document.querySelectorAll("[id]"))) {
|
|
724
|
+
idCount.set(el.id, (idCount.get(el.id) ?? 0) + 1);
|
|
725
|
+
}
|
|
726
|
+
const scopeCount = new Map<string, number>();
|
|
727
|
+
for (const el of Array.from(document.querySelectorAll("[data-qa-scope]"))) {
|
|
728
|
+
const v = el.getAttribute("data-qa-scope") ?? "";
|
|
729
|
+
scopeCount.set(v, (scopeCount.get(v) ?? 0) + 1);
|
|
730
|
+
}
|
|
731
|
+
const anchorFor = (el: Element): string | null => {
|
|
732
|
+
if (el.id && idCount.get(el.id) === 1) return `#${CSS.escape(el.id)}`;
|
|
733
|
+
const scope = el.getAttribute("data-qa-scope");
|
|
734
|
+
if (scope && scopeCount.get(scope) === 1) {
|
|
735
|
+
return `[data-qa-scope="${CSS.escape(scope)}"]`;
|
|
736
|
+
}
|
|
737
|
+
return null;
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
const SKIP = new Set(["SCRIPT", "NOSCRIPT", "TEMPLATE", "STYLE", "LINK", "META"]);
|
|
741
|
+
// Leaves whose subtree is fingerprinted as one opaque unit (mirrors the
|
|
742
|
+
// replaced-element treatment in visual atoms).
|
|
743
|
+
const LEAF = new Set(["SVG", "CANVAS", "VIDEO", "IFRAME", "OBJECT"]);
|
|
744
|
+
const nodes: Array<{
|
|
745
|
+
path: string;
|
|
746
|
+
tag: string;
|
|
747
|
+
attrs: string;
|
|
748
|
+
text?: string;
|
|
749
|
+
visual?: string;
|
|
750
|
+
anchor?: { selector: string; path: string };
|
|
751
|
+
}> = [];
|
|
752
|
+
let truncated = false;
|
|
753
|
+
|
|
754
|
+
const visit = (
|
|
755
|
+
el: Element,
|
|
756
|
+
path: string,
|
|
757
|
+
anchor: { selector: string; path: string } | undefined,
|
|
758
|
+
): void => {
|
|
759
|
+
if (nodes.length >= MAX_NODES) {
|
|
760
|
+
truncated = true;
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
const tag = el.tagName.toLowerCase();
|
|
764
|
+
const attrs = el
|
|
765
|
+
.getAttributeNames()
|
|
766
|
+
.sort()
|
|
767
|
+
.map((name) => `${name}=${el.getAttribute(name) ?? ""}`)
|
|
768
|
+
.join("\x1f");
|
|
769
|
+
const isLeaf = LEAF.has(el.tagName.toUpperCase());
|
|
770
|
+
let text: string | undefined;
|
|
771
|
+
let visual: string | undefined;
|
|
772
|
+
if (isLeaf) {
|
|
773
|
+
if (el instanceof HTMLCanvasElement) {
|
|
774
|
+
try {
|
|
775
|
+
visual = fnv(el.toDataURL("image/png"));
|
|
776
|
+
} catch {
|
|
777
|
+
visual = "unavailable";
|
|
778
|
+
}
|
|
779
|
+
} else {
|
|
780
|
+
visual = fnv(el.innerHTML);
|
|
781
|
+
}
|
|
782
|
+
} else {
|
|
783
|
+
let direct = "";
|
|
784
|
+
for (const child of Array.from(el.childNodes)) {
|
|
785
|
+
if (child.nodeType === Node.TEXT_NODE) direct += child.textContent ?? "";
|
|
786
|
+
}
|
|
787
|
+
const normalized = direct.replace(/\s+/g, " ").trim();
|
|
788
|
+
if (normalized) text = fnv(normalized);
|
|
789
|
+
}
|
|
790
|
+
nodes.push({
|
|
791
|
+
path,
|
|
792
|
+
tag,
|
|
793
|
+
attrs,
|
|
794
|
+
...(text !== undefined ? { text } : {}),
|
|
795
|
+
...(visual !== undefined ? { visual } : {}),
|
|
796
|
+
...(anchor ? { anchor } : {}),
|
|
797
|
+
});
|
|
798
|
+
if (isLeaf) return;
|
|
799
|
+
const own = anchorFor(el);
|
|
800
|
+
const childAnchor = own ? { selector: own, path } : anchor;
|
|
801
|
+
let index = 0;
|
|
802
|
+
for (const child of Array.from(el.children)) {
|
|
803
|
+
if (SKIP.has(child.tagName.toUpperCase())) continue;
|
|
804
|
+
visit(child, `${path}>${child.tagName.toLowerCase()}:${index}`, childAnchor);
|
|
805
|
+
index++;
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
if (document.body) visit(document.body, "body", undefined);
|
|
809
|
+
|
|
810
|
+
const stylesheets: Array<{ key: string; kind: "external" | "inline"; digest: string }> = [];
|
|
811
|
+
let inlineIdx = 0;
|
|
812
|
+
for (const sheet of Array.from(document.styleSheets)) {
|
|
813
|
+
const href = sheet.href;
|
|
814
|
+
const key = href ?? `inline:${inlineIdx}`;
|
|
815
|
+
if (!href) inlineIdx++;
|
|
816
|
+
let digest = "unavailable";
|
|
817
|
+
try {
|
|
818
|
+
digest = fnv(
|
|
819
|
+
Array.from(sheet.cssRules)
|
|
820
|
+
.map((rule) => rule.cssText)
|
|
821
|
+
.join("\n"),
|
|
822
|
+
);
|
|
823
|
+
} catch {
|
|
824
|
+
// Cross-origin: cssRules throws. Fetch the sheet text instead; a
|
|
825
|
+
// CORS-blocked fetch leaves the digest "unavailable" on purpose.
|
|
826
|
+
if (href) {
|
|
827
|
+
try {
|
|
828
|
+
const res = await fetch(href);
|
|
829
|
+
if (res.ok) digest = fnv(await res.text());
|
|
830
|
+
} catch {
|
|
831
|
+
/* stays unavailable */
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
stylesheets.push({ key, kind: href ? "external" : "inline", digest });
|
|
836
|
+
}
|
|
837
|
+
let adoptedIdx = 0;
|
|
838
|
+
for (const sheet of document.adoptedStyleSheets ?? []) {
|
|
839
|
+
try {
|
|
840
|
+
stylesheets.push({
|
|
841
|
+
key: `adopted:${adoptedIdx}`,
|
|
842
|
+
kind: "inline",
|
|
843
|
+
digest: fnv(
|
|
844
|
+
Array.from(sheet.cssRules)
|
|
845
|
+
.map((rule) => rule.cssText)
|
|
846
|
+
.join("\n"),
|
|
847
|
+
),
|
|
848
|
+
});
|
|
849
|
+
} catch {
|
|
850
|
+
stylesheets.push({ key: `adopted:${adoptedIdx}`, kind: "inline", digest: "unavailable" });
|
|
851
|
+
}
|
|
852
|
+
adoptedIdx++;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
return { nodes, stylesheets, domHtml: document.documentElement.outerHTML, truncated };
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
|
|
629
859
|
/**
|
|
630
860
|
* Capture a full-page screenshot from an explicit capture viewport and
|
|
631
861
|
* evaluate the caller's final evidence expression immediately before the
|