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
package/src/core/hooks/index.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* agent-hooks library exports.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* resolvers, and emit helpers ship in Phase 2.
|
|
4
|
+
* Public hook types for the canonical V3 ledger.
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type EventEnvelope,
|
|
12
|
-
type EventType,
|
|
13
|
-
type RedactionMarker,
|
|
14
|
-
SCHEMA_VERSION,
|
|
15
|
-
type Source,
|
|
16
|
-
} from "./events/schema.ts";
|
|
7
|
+
export type { Adapter } from "../adapter.ts";
|
|
8
|
+
export type { EventV3 as Event } from "../events/v3/contract.ts";
|
|
9
|
+
export { EventV3Schema } from "../events/v3/contract.ts";
|
|
@@ -7,7 +7,7 @@ import { resolveCoordRoot } from "../../agents/coord-client.ts";
|
|
|
7
7
|
* different roots. They used to: this walked up from `CLAUDE_PROJECT_DIR` or
|
|
8
8
|
* cwd while the CLI's `monorepoRoot()` asked git for the superproject first, so
|
|
9
9
|
* with a shell inside a submodule that carries its own `.harnery/`, the CLI's
|
|
10
|
-
* `
|
|
10
|
+
* `coord.status_observed` landed in a stream this side never read and rule 1/3
|
|
11
11
|
* blocked every turn.
|
|
12
12
|
*
|
|
13
13
|
* Resolution precedence (see `resolveCoordRoot` for the full rationale):
|
|
@@ -2,6 +2,8 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { coordEnv } from "../../../lib/env.ts";
|
|
5
|
+
import { resolveOwnerBySessionEnv } from "../../agents/coord-client.ts";
|
|
6
|
+
import { readLiveCoordinationRow } from "../../agents/state/live-coordination-view.ts";
|
|
5
7
|
import { checkPidToken } from "../../agents/state/proc-start.ts";
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -9,20 +11,21 @@ import { checkPidToken } from "../../agents/state/proc-start.ts";
|
|
|
9
11
|
*
|
|
10
12
|
* Precedence:
|
|
11
13
|
*
|
|
12
|
-
* 1.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* `
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* 1. Hook payload fields. Current live V3 authority breaks ties: a live
|
|
15
|
+
* child wins when it belongs to the payload session, otherwise the live
|
|
16
|
+
* session/conversation wins over a stale adapter `agent_id`. With no live
|
|
17
|
+
* evidence, the legacy `agent_id` → `subagent_id` → `session_id` →
|
|
18
|
+
* `conversation_id` order remains the startup fallback.
|
|
19
|
+
* 2. `HARNERY_AGENT_COORD_OWNER` outside bridge mode. Bridge-marked children
|
|
20
|
+
* ignore this unvalidated override.
|
|
21
|
+
* 3. Adapter-exported session identity matched to one live V3 generation.
|
|
22
|
+
* This is the only payload-free identity accepted in bridge mode.
|
|
23
|
+
* 4. PID-map lookup at `.harnery/pid-map/<pid>` for our own pid, then ppid
|
|
19
24
|
* chain (up to 20 hops).
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* one place the pid walk can never land. Validated so a garbage value
|
|
25
|
-
* cannot fabricate an identity.
|
|
25
|
+
*
|
|
26
|
+
* Bridge-marked children fail closed after tier 3. A connector crosses a
|
|
27
|
+
* process-tree boundary, so pid ancestry and singleton state are not evidence
|
|
28
|
+
* of its logical session.
|
|
26
29
|
*
|
|
27
30
|
* Returns null when nothing resolves. Callers must treat null as "no owner"
|
|
28
31
|
* and skip the event (Phase 2 fail-safe; Phase 3 will mint a temporary owner
|
|
@@ -33,22 +36,46 @@ export function resolveOwner(opts: {
|
|
|
33
36
|
coordRoot: string;
|
|
34
37
|
}): {
|
|
35
38
|
instance_id: string;
|
|
36
|
-
source: "env" | "payload" | "
|
|
39
|
+
source: "env" | "payload" | "session_env" | "pidmap-self" | "pidmap-ancestor";
|
|
37
40
|
} | null {
|
|
38
|
-
const env = coordEnv("AGENT_COORD_OWNER");
|
|
39
|
-
if (env && env.length > 0) {
|
|
40
|
-
return { instance_id: env, source: "env" };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
41
|
if (opts.payload) {
|
|
42
|
+
const value = (key: "agent_id" | "subagent_id" | "session_id" | "conversation_id") => {
|
|
43
|
+
const candidate = opts.payload?.[key];
|
|
44
|
+
return typeof candidate === "string" && candidate.length > 0 ? candidate : undefined;
|
|
45
|
+
};
|
|
46
|
+
const childId = value("subagent_id") ?? value("agent_id");
|
|
47
|
+
const sessionId = value("session_id") ?? value("conversation_id");
|
|
48
|
+
const child = childId ? readLiveCoordinationRow(opts.coordRoot, childId) : null;
|
|
49
|
+
const session = sessionId ? readLiveCoordinationRow(opts.coordRoot, sessionId) : null;
|
|
50
|
+
|
|
51
|
+
if (child && sessionId && (child.kind === "subagent" || child.session_id === sessionId)) {
|
|
52
|
+
return { instance_id: childId!, source: "payload" };
|
|
53
|
+
}
|
|
54
|
+
if (session) return { instance_id: sessionId!, source: "payload" };
|
|
55
|
+
if (child) return { instance_id: childId!, source: "payload" };
|
|
56
|
+
|
|
44
57
|
for (const key of ["agent_id", "subagent_id", "session_id", "conversation_id"] as const) {
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
return { instance_id: v, source: "payload" };
|
|
48
|
-
}
|
|
58
|
+
const candidate = value(key);
|
|
59
|
+
if (candidate) return { instance_id: candidate, source: "payload" };
|
|
49
60
|
}
|
|
50
61
|
}
|
|
51
62
|
|
|
63
|
+
const bridge = coordEnv("AGENT_COORD_BRIDGE")?.trim();
|
|
64
|
+
const env = coordEnv("AGENT_COORD_OWNER");
|
|
65
|
+
if (env && env.length > 0 && !bridge) {
|
|
66
|
+
return { instance_id: env, source: "env" };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// A Windows-hosted Codex task can replace its WSL process tree during a
|
|
70
|
+
// repository refresh. The forwarded native thread id survives that boundary
|
|
71
|
+
// and is safe only after joining to exactly one nonterminal V3 producer.
|
|
72
|
+
// Resolve it before the bridge fail-closed branch; never fall through to the
|
|
73
|
+
// old pid map when the join fails.
|
|
74
|
+
const sessionOwner = resolveOwnerBySessionEnv(opts.coordRoot);
|
|
75
|
+
if (sessionOwner) return { instance_id: sessionOwner, source: "session_env" };
|
|
76
|
+
|
|
77
|
+
if (bridge) return null;
|
|
78
|
+
|
|
52
79
|
// Pid-map ancestor walk. Start at own pid (the bash wrapper's bun child),
|
|
53
80
|
// walk up through ppids. The pid-map is stamped keyed by the adapter PID, so
|
|
54
81
|
// we'll usually find it 1-3 hops up.
|
|
@@ -85,18 +112,6 @@ export function resolveOwner(opts: {
|
|
|
85
112
|
}
|
|
86
113
|
}
|
|
87
114
|
|
|
88
|
-
// Tier 4: Codex thread id, heartbeat-validated. Last because the pid map is
|
|
89
|
-
// more specific when it answers — an inherited env var can outlive the
|
|
90
|
-
// process tree it described, a live pid-map row cannot.
|
|
91
|
-
const codexThreadId = process.env.CODEX_THREAD_ID?.trim();
|
|
92
|
-
if (
|
|
93
|
-
codexThreadId &&
|
|
94
|
-
/^[A-Za-z0-9-]+$/.test(codexThreadId) &&
|
|
95
|
-
existsSync(join(opts.coordRoot, ".harnery", "active", `${codexThreadId}.json`))
|
|
96
|
-
) {
|
|
97
|
-
return { instance_id: codexThreadId, source: "codex-env" };
|
|
98
|
-
}
|
|
99
|
-
|
|
100
115
|
return null;
|
|
101
116
|
}
|
|
102
117
|
|
|
@@ -143,17 +158,9 @@ export function readShellMarker(coordRoot: string, pid: number): string | null {
|
|
|
143
158
|
}
|
|
144
159
|
}
|
|
145
160
|
|
|
146
|
-
/** Read the
|
|
161
|
+
/** Read the V3-projected `agent_id` for an owner if it exists. */
|
|
147
162
|
export function readAgentIdForOwner(coordRoot: string, instanceId: string): string | null {
|
|
148
|
-
|
|
149
|
-
if (!existsSync(path)) return null;
|
|
150
|
-
try {
|
|
151
|
-
const body = readFileSync(path, "utf8");
|
|
152
|
-
const data = JSON.parse(body) as { agent_id?: string };
|
|
153
|
-
return data.agent_id ?? null;
|
|
154
|
-
} catch {
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
163
|
+
return readLiveCoordinationRow(coordRoot, instanceId)?.agent_id ?? null;
|
|
157
164
|
}
|
|
158
165
|
|
|
159
166
|
/** Diagnostic: list of pid-map entries (for debugging). */
|
|
@@ -3,7 +3,7 @@ import { basename, dirname, join } from "node:path";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Scan a CC-style JSONL transcript for the `┌─ agent-` status-box prefix in
|
|
6
|
-
* the most-recent assistant turn. Used by `turn.
|
|
6
|
+
* the most-recent assistant turn. Used by `turn.completed` events to populate
|
|
7
7
|
* `status_box_present`.
|
|
8
8
|
*
|
|
9
9
|
* Cheap by default: caps the read at 256KB tailed from the file, since the
|
|
@@ -13,8 +13,9 @@ import { basename, dirname, join } from "node:path";
|
|
|
13
13
|
* and Phase 5 verdict path catches the race via a single retry.
|
|
14
14
|
*/
|
|
15
15
|
export function scanStatusBoxPresent(transcriptPath: string | undefined): boolean {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
17
|
+
if (!readablePath) return false;
|
|
18
|
+
const text = tailText(readablePath);
|
|
18
19
|
if (text === undefined) return false;
|
|
19
20
|
// The box is rendered as a text content block by the assistant; we look
|
|
20
21
|
// for the prefix on any line of the trailing window.
|
|
@@ -23,7 +24,7 @@ export function scanStatusBoxPresent(transcriptPath: string | undefined): boolea
|
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Scan a CC-style JSONL transcript for a needle in ASSISTANT message text
|
|
26
|
-
* blocks only. Used by `turn.
|
|
27
|
+
* blocks only. Used by `turn.completed` to detect the suggested session name in the
|
|
27
28
|
* reply.
|
|
28
29
|
*
|
|
29
30
|
* The row filter is load-bearing: the transcript tail also carries the needle
|
|
@@ -39,8 +40,10 @@ export function scanAssistantTextIncludes(
|
|
|
39
40
|
transcriptPath: string | undefined,
|
|
40
41
|
needle: string,
|
|
41
42
|
): boolean {
|
|
42
|
-
if (!
|
|
43
|
-
const
|
|
43
|
+
if (!needle) return false;
|
|
44
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
45
|
+
if (!readablePath) return false;
|
|
46
|
+
const text = tailText(readablePath);
|
|
44
47
|
if (!text) return false;
|
|
45
48
|
for (const line of text.split("\n")) {
|
|
46
49
|
// Cheap gate before parsing: most lines don't contain the needle at all.
|
|
@@ -71,11 +74,156 @@ export function scanAssistantTextIncludes(
|
|
|
71
74
|
return false;
|
|
72
75
|
}
|
|
73
76
|
|
|
77
|
+
/** Most recent user-visible assistant text across Claude Code and Codex JSONL. */
|
|
78
|
+
export function scanLatestAssistantText(transcriptPath: string | undefined): string | undefined {
|
|
79
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
80
|
+
if (!readablePath) return undefined;
|
|
81
|
+
const text = tailText(readablePath);
|
|
82
|
+
if (!text) return undefined;
|
|
83
|
+
const lines = text.split("\n");
|
|
84
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
85
|
+
const row = parseTranscriptRow(lines[i]);
|
|
86
|
+
if (!row) continue;
|
|
87
|
+
const assistantText = assistantTextFromRow(row);
|
|
88
|
+
// Claude Code appends the current tool_use-only assistant row before
|
|
89
|
+
// PreToolUse fires. Skip rows with no user-visible text so the immediately
|
|
90
|
+
// preceding fenced block remains discoverable.
|
|
91
|
+
if (assistantText !== null && assistantText.trim().length > 0) return assistantText;
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Verify that the first assistant message after the set-task result begins
|
|
98
|
+
* with the exact session-name block. This is the Stop-time fallback for a
|
|
99
|
+
* correctly displayed name followed by no further tool call. A name printed
|
|
100
|
+
* after later work does not pass.
|
|
101
|
+
*/
|
|
102
|
+
export function scanSessionNameDisplayedImmediately(
|
|
103
|
+
transcriptPath: string | undefined,
|
|
104
|
+
name: string,
|
|
105
|
+
startsWithBlock: (text: string, expectedName: string) => boolean,
|
|
106
|
+
): boolean {
|
|
107
|
+
return (
|
|
108
|
+
inspectSessionNameDisplayImmediately(transcriptPath, name, startsWithBlock).state === "present"
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type SessionNameDisplayInspection =
|
|
113
|
+
| { state: "present" }
|
|
114
|
+
| { state: "absent" }
|
|
115
|
+
| { state: "unavailable"; reason: "missing_transcript" | "transcript_not_ready" };
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Inspect the ordered post-mint reply without conflating a malformed display
|
|
119
|
+
* with an unreadable transcript. PreToolUse can enforce the former, while the
|
|
120
|
+
* latter must remain an honest unsupported observation instead of deadlocking
|
|
121
|
+
* every tool behind evidence the adapter has not persisted yet.
|
|
122
|
+
*/
|
|
123
|
+
export function inspectSessionNameDisplayImmediately(
|
|
124
|
+
transcriptPath: string | undefined,
|
|
125
|
+
name: string,
|
|
126
|
+
startsWithBlock: (text: string, expectedName: string) => boolean,
|
|
127
|
+
): SessionNameDisplayInspection {
|
|
128
|
+
if (!name) return { state: "absent" };
|
|
129
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
130
|
+
if (!readablePath) return { state: "unavailable", reason: "missing_transcript" };
|
|
131
|
+
const text = tailText(readablePath);
|
|
132
|
+
if (!text) return { state: "unavailable", reason: "transcript_not_ready" };
|
|
133
|
+
let sawMintResult = false;
|
|
134
|
+
for (const line of text.split("\n")) {
|
|
135
|
+
if (!sawMintResult) {
|
|
136
|
+
if (line.includes(name) && line.includes("suggested_session_name")) sawMintResult = true;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const row = parseTranscriptRow(line);
|
|
140
|
+
if (!row) continue;
|
|
141
|
+
const assistantText = assistantTextFromRow(row);
|
|
142
|
+
if (assistantText !== null) {
|
|
143
|
+
return { state: startsWithBlock(assistantText, name) ? "present" : "absent" };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return sawMintResult
|
|
147
|
+
? { state: "unavailable", reason: "transcript_not_ready" }
|
|
148
|
+
: { state: "absent" };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Resolve a transcript path at the adapter boundary. Windows-native Codex can
|
|
153
|
+
* send `C:\...` while the managed hook executes inside WSL, where the same
|
|
154
|
+
* file is mounted at `/mnt/c/...`.
|
|
155
|
+
*/
|
|
156
|
+
export function transcriptPathCandidates(transcriptPath: string | undefined): string[] {
|
|
157
|
+
if (!transcriptPath) return [];
|
|
158
|
+
const candidates = [transcriptPath];
|
|
159
|
+
const windowsDrive = /^([A-Za-z]):[\\/](.*)$/.exec(transcriptPath);
|
|
160
|
+
if (windowsDrive) {
|
|
161
|
+
candidates.push(
|
|
162
|
+
`/mnt/${windowsDrive[1]!.toLowerCase()}/${windowsDrive[2]!.replaceAll("\\", "/")}`,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
return [...new Set(candidates)];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function resolveTranscriptPath(transcriptPath: string | undefined): string | undefined {
|
|
169
|
+
return transcriptPathCandidates(transcriptPath).find((candidate) => existsSync(candidate));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function parseTranscriptRow(line: string | undefined): Record<string, unknown> | null {
|
|
173
|
+
if (!line?.trim()) return null;
|
|
174
|
+
try {
|
|
175
|
+
const row = JSON.parse(line) as unknown;
|
|
176
|
+
return typeof row === "object" && row !== null ? (row as Record<string, unknown>) : null;
|
|
177
|
+
} catch {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** null means this row is not an assistant message; an empty string is one with no text. */
|
|
183
|
+
function assistantTextFromRow(row: Record<string, unknown>): string | null {
|
|
184
|
+
if (row.type === "assistant") {
|
|
185
|
+
const message = objectValue(row.message);
|
|
186
|
+
return textFromContent(message?.content);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (row.type === "response_item") {
|
|
190
|
+
const payload = objectValue(row.payload);
|
|
191
|
+
if (payload?.type !== "message" || payload.role !== "assistant") return null;
|
|
192
|
+
return textFromContent(payload.content);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (row.type === "event_msg") {
|
|
196
|
+
const payload = objectValue(row.payload);
|
|
197
|
+
if (payload?.type !== "agent_message") return null;
|
|
198
|
+
return typeof payload.message === "string" ? payload.message : "";
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function objectValue(value: unknown): Record<string, unknown> | null {
|
|
205
|
+
return typeof value === "object" && value !== null ? (value as Record<string, unknown>) : null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function textFromContent(content: unknown): string {
|
|
209
|
+
if (typeof content === "string") return content;
|
|
210
|
+
if (!Array.isArray(content)) return "";
|
|
211
|
+
const parts: string[] = [];
|
|
212
|
+
for (const block of content) {
|
|
213
|
+
const value = objectValue(block);
|
|
214
|
+
if (!value) continue;
|
|
215
|
+
if ((value.type === "text" || value.type === "output_text") && typeof value.text === "string") {
|
|
216
|
+
parts.push(value.text);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return parts.join("\n");
|
|
220
|
+
}
|
|
221
|
+
|
|
74
222
|
/**
|
|
75
223
|
* Resolve the agent's model from a CC-style JSONL transcript by reading the
|
|
76
224
|
* most-recent assistant message's `message.model`. Claude Code's SessionStart
|
|
77
225
|
* payload omits `model` (Codex + Cursor supply it directly), so this is the
|
|
78
|
-
* fallback that lets `session.
|
|
226
|
+
* fallback that lets `session.started` / `turn.completed` populate the cache's
|
|
79
227
|
* model field once the transcript has at least one assistant turn.
|
|
80
228
|
*
|
|
81
229
|
* Tail-reads the same 256KB window as the status-box scan and walks lines from
|
|
@@ -84,8 +232,9 @@ export function scanAssistantTextIncludes(
|
|
|
84
232
|
* transcript is missing/empty (e.g. a fresh session's first SessionStart).
|
|
85
233
|
*/
|
|
86
234
|
export function scanTranscriptModel(transcriptPath: string | undefined): string | undefined {
|
|
87
|
-
|
|
88
|
-
|
|
235
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
236
|
+
if (!readablePath) return undefined;
|
|
237
|
+
const text = tailText(readablePath);
|
|
89
238
|
if (!text) return undefined;
|
|
90
239
|
const lines = text.split("\n");
|
|
91
240
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
@@ -146,15 +295,17 @@ export function detectForkParent(
|
|
|
146
295
|
sessionId: string,
|
|
147
296
|
): string | undefined {
|
|
148
297
|
try {
|
|
149
|
-
if (!
|
|
150
|
-
|
|
151
|
-
|
|
298
|
+
if (!sessionId) return undefined;
|
|
299
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
300
|
+
if (!readablePath) return undefined;
|
|
301
|
+
if (statSync(readablePath).size > FORK_SCAN_MAX_BYTES) return undefined;
|
|
302
|
+
const own = readFileSync(readablePath, "utf8");
|
|
152
303
|
const uuids = messageUuids(own);
|
|
153
304
|
if (uuids.length === 0) return undefined;
|
|
154
305
|
const sample = sampleEvenly(uuids, FORK_SAMPLE_SIZE);
|
|
155
306
|
|
|
156
|
-
const dir = dirname(
|
|
157
|
-
const ownFile = basename(
|
|
307
|
+
const dir = dirname(readablePath);
|
|
308
|
+
const ownFile = basename(readablePath);
|
|
158
309
|
let best: { id: string; score: number; rows: number; mtimeMs: number } | null = null;
|
|
159
310
|
for (const file of readdirSync(dir)) {
|
|
160
311
|
if (file === ownFile || !SESSION_FILE_RE.test(file)) continue;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Session-name presence for `turn.
|
|
2
|
+
* Session-name presence for `turn.completed`.
|
|
3
3
|
*
|
|
4
|
-
* While the
|
|
5
|
-
* naming ritual is satisfied: either
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* stops that arrive without a transcript.
|
|
4
|
+
* While the current V3 coordination row carries a `suggested_session_name`, report whether the
|
|
5
|
+
* naming ritual is satisfied: either the immediate post-mint assistant text
|
|
6
|
+
* showed the exact block, or an earlier PreToolUse already stamped it. The
|
|
7
|
+
* transcript callback must enforce ordering and block shape; a late final
|
|
8
|
+
* answer or a tool result must not count.
|
|
10
9
|
*
|
|
11
10
|
* Two properties the stop-hook naming rule depends on:
|
|
12
11
|
*
|
|
13
12
|
* 1. Once a name is satisfied, every later stop keeps reporting `true` rather
|
|
14
|
-
* than omitting the field. The rule wants an in-window `turn.
|
|
15
|
-
* `session_name_present: true`; omitting it after the
|
|
13
|
+
* than omitting the field. The rule wants an in-window `turn.completed` carrying
|
|
14
|
+
* `session_name_present: true`; omitting it after the coordination stamp meant
|
|
16
15
|
* nothing could ever re-emit the flag, so every subsequent reply blocked --
|
|
17
16
|
* including the replies reproducing the exact name the rule asked for.
|
|
18
17
|
* 2. The result names WHICH suggested name it covered, so a projector rebuild
|
|
@@ -23,7 +22,8 @@
|
|
|
23
22
|
* Never throws: coordination telemetry must not take down a hook.
|
|
24
23
|
*/
|
|
25
24
|
|
|
26
|
-
import {
|
|
25
|
+
import { stampSessionNameSeen } from "../agents/state/heartbeat-writer.ts";
|
|
26
|
+
import { readLiveCoordinationRow } from "../agents/state/live-coordination-view.ts";
|
|
27
27
|
|
|
28
28
|
export interface SessionNamePresence {
|
|
29
29
|
session_name_present?: boolean;
|
|
@@ -33,17 +33,16 @@ export interface SessionNamePresence {
|
|
|
33
33
|
export function sessionNamePresence(
|
|
34
34
|
coordRoot: string,
|
|
35
35
|
instanceId: string,
|
|
36
|
-
lastAssistantMessage: string,
|
|
37
36
|
scanAssistantText: (name: string) => boolean,
|
|
38
37
|
): SessionNamePresence {
|
|
39
38
|
try {
|
|
40
|
-
const
|
|
41
|
-
const name =
|
|
39
|
+
const row = readLiveCoordinationRow(coordRoot, instanceId);
|
|
40
|
+
const name = row?.suggested_session_name;
|
|
42
41
|
if (!name) return {};
|
|
43
|
-
if (
|
|
42
|
+
if (row?.session_name_seen_for === name) {
|
|
44
43
|
return { session_name_present: true, session_name_present_for: name };
|
|
45
44
|
}
|
|
46
|
-
const present = scanAssistantText(name)
|
|
45
|
+
const present = scanAssistantText(name);
|
|
47
46
|
if (present) stampSessionNameSeen(coordRoot, instanceId, name);
|
|
48
47
|
return { session_name_present: present, session_name_present_for: name };
|
|
49
48
|
} catch {
|
|
@@ -13,10 +13,13 @@ import { resolveMachineLabel } from "../../lib/machine.ts";
|
|
|
13
13
|
import {
|
|
14
14
|
assertSafeInstanceId,
|
|
15
15
|
monorepoRoot,
|
|
16
|
-
readHeartbeat,
|
|
17
16
|
resolveContainedFile,
|
|
18
17
|
resolveOwner,
|
|
19
18
|
} from "../agents/index.ts";
|
|
19
|
+
import {
|
|
20
|
+
readLiveCoordinationRow,
|
|
21
|
+
readLiveCoordinationRows,
|
|
22
|
+
} from "../agents/state/live-coordination-view.ts";
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* Agent journal: per-agent markdown journal at `.harnery/journal/<instance_id>.md`.
|
|
@@ -313,7 +316,8 @@ export function appendEntry(
|
|
|
313
316
|
category: JournalCategory,
|
|
314
317
|
body: string,
|
|
315
318
|
): JournalDoc {
|
|
316
|
-
const
|
|
319
|
+
const root = monorepoRoot();
|
|
320
|
+
const hb = root ? readLiveCoordinationRow(root, instanceId) : null;
|
|
317
321
|
const path = journalPath(instanceId);
|
|
318
322
|
let doc: JournalDoc;
|
|
319
323
|
if (existsSync(path)) {
|
|
@@ -412,14 +416,15 @@ export function pruneArchives(days = ARCHIVE_RETENTION_DAYS): number {
|
|
|
412
416
|
return deleted;
|
|
413
417
|
}
|
|
414
418
|
|
|
415
|
-
/** Sweep
|
|
419
|
+
/** Sweep journals whose corresponding authoritative V3 generation is gone. */
|
|
416
420
|
export function sweepOrphanJournals(): string[] {
|
|
417
421
|
const dir = journalDir();
|
|
422
|
+
const root = monorepoRoot();
|
|
418
423
|
const archived: string[] = [];
|
|
419
424
|
for (const f of readdirSync(dir)) {
|
|
420
425
|
if (!f.endsWith(".md")) continue;
|
|
421
426
|
const instanceId = f.replace(/\.md$/, "");
|
|
422
|
-
const hb =
|
|
427
|
+
const hb = root ? readLiveCoordinationRow(root, instanceId) : null;
|
|
423
428
|
if (!hb) {
|
|
424
429
|
const dest = archiveJournal(instanceId);
|
|
425
430
|
if (dest) archived.push(dest);
|
|
@@ -463,25 +468,13 @@ export function loadJournal(instanceId: string): JournalDoc | null {
|
|
|
463
468
|
return parseJournal(path, readFileSync(path, "utf8"));
|
|
464
469
|
}
|
|
465
470
|
|
|
466
|
-
/** Resolve an agent name
|
|
471
|
+
/** Resolve an agent name through the authority-safe V3 coordination projection. */
|
|
467
472
|
export function resolveOwnerByName(name: string): string | null {
|
|
468
473
|
const root = monorepoRoot();
|
|
469
474
|
if (!root) return null;
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
const hb = JSON.parse(readFileSync(resolve(activeDir, f), "utf8")) as {
|
|
476
|
-
instance_id?: string;
|
|
477
|
-
name?: string;
|
|
478
|
-
};
|
|
479
|
-
if ((hb.name ?? "").toLowerCase() === name.toLowerCase()) {
|
|
480
|
-
return hb.instance_id ?? null;
|
|
481
|
-
}
|
|
482
|
-
} catch {
|
|
483
|
-
// skip
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
return null;
|
|
475
|
+
return (
|
|
476
|
+
readLiveCoordinationRows(root).find(
|
|
477
|
+
(row) => (row.name ?? "").toLowerCase() === name.toLowerCase(),
|
|
478
|
+
)?.instance_id ?? null
|
|
479
|
+
);
|
|
487
480
|
}
|