harnery 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +4 -0
- package/dist/commands/adapter.js +2 -2
- package/dist/commands/agents.d.ts +144 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +1220 -588
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +7 -6
- package/dist/commands/backup.d.ts +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +29 -16
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +234 -12
- package/dist/commands/checkpoint.d.ts.map +1 -1
- package/dist/commands/checkpoint.js +3 -2
- package/dist/commands/claude-desktop.d.ts +1 -1
- package/dist/commands/claude-desktop.d.ts.map +1 -1
- package/dist/commands/claude-desktop.js +3 -74
- package/dist/commands/context.js +1 -6
- package/dist/commands/decision.d.ts.map +1 -1
- package/dist/commands/decision.js +22 -38
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +91 -28
- package/dist/commands/doctor.js +10 -1
- package/dist/commands/events.d.ts +5 -0
- package/dist/commands/events.d.ts.map +1 -0
- package/dist/commands/events.js +189 -0
- package/dist/commands/governor.d.ts.map +1 -1
- package/dist/commands/governor.js +13 -4
- package/dist/commands/init.d.ts +9 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +223 -51
- package/dist/commands/journal.d.ts.map +1 -1
- package/dist/commands/journal.js +4 -13
- package/dist/commands/ledger-v3.d.ts +5 -0
- package/dist/commands/ledger-v3.d.ts.map +1 -0
- package/dist/commands/ledger-v3.js +91 -0
- package/dist/commands/presence.d.ts.map +1 -1
- package/dist/commands/presence.js +11 -5
- package/dist/commands/sync.d.ts +1 -1
- package/dist/commands/sync.js +1 -1
- package/dist/commands/web.d.ts +6 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +67 -7
- package/dist/commands/work.d.ts.map +1 -1
- package/dist/commands/work.js +22 -5
- package/dist/core/adapter.d.ts +5 -0
- package/dist/core/adapter.d.ts.map +1 -0
- package/dist/core/adapter.js +1 -0
- package/dist/core/adapters/attest.d.ts +5 -2
- package/dist/core/adapters/attest.d.ts.map +1 -1
- package/dist/core/adapters/attest.js +8 -3
- package/dist/core/adapters/profiles.d.ts +6 -6
- package/dist/core/adapters/profiles.d.ts.map +1 -1
- package/dist/core/adapters/profiles.js +4 -4
- package/dist/core/agents/canonical-emit.d.ts +17 -15
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +22 -22
- package/dist/core/agents/cli.js +207 -234
- package/dist/core/agents/codex-archive-v3.d.ts +14 -0
- package/dist/core/agents/codex-archive-v3.d.ts.map +1 -0
- package/dist/core/agents/codex-archive-v3.js +110 -0
- package/dist/core/agents/coord-client.d.ts +19 -81
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +65 -155
- package/dist/core/agents/finalization.d.ts +4 -1
- package/dist/core/agents/finalization.d.ts.map +1 -1
- package/dist/core/agents/finalization.js +89 -32
- package/dist/core/agents/index.d.ts +4 -5
- package/dist/core/agents/index.d.ts.map +1 -1
- package/dist/core/agents/index.js +4 -5
- package/dist/core/agents/live-authority-v3.d.ts +59 -0
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -0
- package/dist/core/agents/live-authority-v3.js +233 -0
- package/dist/core/agents/live-lifecycle-v3.d.ts +20 -0
- package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -0
- package/dist/core/agents/live-lifecycle-v3.js +91 -0
- package/dist/core/agents/live-observation-v3.d.ts +25 -0
- package/dist/core/agents/live-observation-v3.d.ts.map +1 -0
- package/dist/core/agents/live-observation-v3.js +157 -0
- package/dist/core/agents/render/prompt-context.d.ts +4 -4
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +23 -58
- package/dist/core/agents/render/session-context.d.ts +1 -1
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +8 -32
- package/dist/core/agents/rules/claim-conflict.d.ts +3 -3
- package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/claim-conflict.js +79 -127
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/commit-conflict.js +3 -18
- package/dist/core/agents/rules/stop-hook.d.ts +9 -50
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +193 -236
- package/dist/core/agents/session-events.d.ts +5 -7
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +127 -95
- package/dist/core/agents/session-finalization-state-v3.d.ts +30 -0
- package/dist/core/agents/session-finalization-state-v3.d.ts.map +1 -0
- package/dist/core/agents/session-finalization-state-v3.js +40 -0
- package/dist/core/agents/session-finalizer-v3.d.ts +107 -0
- package/dist/core/agents/session-finalizer-v3.d.ts.map +1 -0
- package/dist/core/agents/session-finalizer-v3.js +734 -0
- package/dist/core/agents/session-name-display.d.ts +40 -0
- package/dist/core/agents/session-name-display.d.ts.map +1 -0
- package/dist/core/agents/session-name-display.js +119 -0
- package/dist/core/agents/state/activity-log.d.ts +3 -3
- package/dist/core/agents/state/activity-log.d.ts.map +1 -1
- package/dist/core/agents/state/activity-log.js +7 -16
- package/dist/core/agents/state/heartbeat-writer.d.ts +23 -55
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +56 -228
- package/dist/core/agents/state/live-coordination-view.d.ts +31 -0
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -0
- package/dist/core/agents/state/live-coordination-view.js +209 -0
- package/dist/core/agents/state/session-state.d.ts +4 -3
- package/dist/core/agents/state/session-state.d.ts.map +1 -1
- package/dist/core/agents/state/session-state.js +18 -9
- package/dist/core/agents/state/stale-sweep.d.ts +1 -1
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +26 -15
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +5 -7
- package/dist/core/config.d.ts +33 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +98 -2
- package/dist/core/context/index.d.ts +1 -4
- package/dist/core/context/index.d.ts.map +1 -1
- package/dist/core/context/index.js +9 -9
- package/dist/core/events/span-parent.d.ts +15 -0
- package/dist/core/events/span-parent.d.ts.map +1 -0
- package/dist/core/events/span-parent.js +34 -0
- package/dist/core/events/v3/advance.d.ts +14 -0
- package/dist/core/events/v3/advance.d.ts.map +1 -0
- package/dist/core/events/v3/advance.js +134 -0
- package/dist/core/events/v3/authority-outbox.d.ts +78 -0
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -0
- package/dist/core/events/v3/authority-outbox.js +399 -0
- package/dist/core/events/v3/base-builder.d.ts +20 -0
- package/dist/core/events/v3/base-builder.d.ts.map +1 -0
- package/dist/core/events/v3/base-builder.js +29 -0
- package/dist/core/events/v3/base-contract.d.ts +7576 -0
- package/dist/core/events/v3/base-contract.d.ts.map +1 -0
- package/dist/core/events/v3/base-contract.js +647 -0
- package/dist/core/events/v3/bootstrap.d.ts +34 -0
- package/dist/core/events/v3/bootstrap.d.ts.map +1 -0
- package/dist/core/events/v3/bootstrap.js +175 -0
- package/dist/core/events/v3/builder.d.ts +20 -0
- package/dist/core/events/v3/builder.d.ts.map +1 -0
- package/dist/core/events/v3/builder.js +28 -0
- package/dist/core/events/v3/canonical.d.ts +31 -0
- package/dist/core/events/v3/canonical.d.ts.map +1 -0
- package/dist/core/events/v3/canonical.js +100 -0
- package/dist/core/events/v3/capabilities.d.ts +31 -0
- package/dist/core/events/v3/capabilities.d.ts.map +1 -0
- package/dist/core/events/v3/capabilities.js +107 -0
- package/dist/core/events/v3/capability-drift.d.ts +22 -0
- package/dist/core/events/v3/capability-drift.d.ts.map +1 -0
- package/dist/core/events/v3/capability-drift.js +134 -0
- package/dist/core/events/v3/catalog.d.ts +38 -0
- package/dist/core/events/v3/catalog.d.ts.map +1 -0
- package/dist/core/events/v3/catalog.js +135 -0
- package/dist/core/events/v3/clock-order.d.ts +34 -0
- package/dist/core/events/v3/clock-order.d.ts.map +1 -0
- package/dist/core/events/v3/clock-order.js +35 -0
- package/dist/core/events/v3/contract.d.ts +171 -0
- package/dist/core/events/v3/contract.d.ts.map +1 -0
- package/dist/core/events/v3/contract.js +180 -0
- package/dist/core/events/v3/control.d.ts +111 -0
- package/dist/core/events/v3/control.d.ts.map +1 -0
- package/dist/core/events/v3/control.js +419 -0
- package/dist/core/events/v3/coordination-view.d.ts +69 -0
- package/dist/core/events/v3/coordination-view.d.ts.map +1 -0
- package/dist/core/events/v3/coordination-view.js +119 -0
- package/dist/core/events/v3/economics.d.ts +77 -0
- package/dist/core/events/v3/economics.d.ts.map +1 -0
- package/dist/core/events/v3/economics.js +274 -0
- package/dist/core/events/v3/finalization-view.d.ts +26 -0
- package/dist/core/events/v3/finalization-view.d.ts.map +1 -0
- package/dist/core/events/v3/finalization-view.js +37 -0
- package/dist/core/events/v3/fingerprint-keys.d.ts +25 -0
- package/dist/core/events/v3/fingerprint-keys.d.ts.map +1 -0
- package/dist/core/events/v3/fingerprint-keys.js +217 -0
- package/dist/core/events/v3/generated.d.ts +4 -0
- package/dist/core/events/v3/generated.d.ts.map +1 -0
- package/dist/core/events/v3/generated.js +47 -0
- package/dist/core/events/v3/ids.d.ts +9 -0
- package/dist/core/events/v3/ids.d.ts.map +1 -0
- package/dist/core/events/v3/ids.js +25 -0
- package/dist/core/events/v3/index.d.ts +35 -0
- package/dist/core/events/v3/index.d.ts.map +1 -0
- package/dist/core/events/v3/index.js +33 -0
- package/dist/core/events/v3/latency.d.ts +63 -0
- package/dist/core/events/v3/latency.d.ts.map +1 -0
- package/dist/core/events/v3/latency.js +412 -0
- package/dist/core/events/v3/live-feed.d.ts +45 -0
- package/dist/core/events/v3/live-feed.d.ts.map +1 -0
- package/dist/core/events/v3/live-feed.js +246 -0
- package/dist/core/events/v3/live-observation.d.ts +35 -0
- package/dist/core/events/v3/live-observation.d.ts.map +1 -0
- package/dist/core/events/v3/live-observation.js +1 -0
- package/dist/core/events/v3/live-routing.d.ts +57 -0
- package/dist/core/events/v3/live-routing.d.ts.map +1 -0
- package/dist/core/events/v3/live-routing.js +107 -0
- package/dist/core/events/v3/producers/command-recorder.d.ts +67 -0
- package/dist/core/events/v3/producers/command-recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/command-recorder.js +477 -0
- package/dist/core/events/v3/producers/command.d.ts +50 -0
- package/dist/core/events/v3/producers/command.d.ts.map +1 -0
- package/dist/core/events/v3/producers/command.js +135 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +53 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/coordination-recorder.js +376 -0
- package/dist/core/events/v3/producers/coordination.d.ts +90 -0
- package/dist/core/events/v3/producers/coordination.d.ts.map +1 -0
- package/dist/core/events/v3/producers/coordination.js +229 -0
- package/dist/core/events/v3/producers/hook-base.d.ts +54 -0
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -0
- package/dist/core/events/v3/producers/hook-base.js +424 -0
- package/dist/core/events/v3/producers/hook.d.ts +29 -0
- package/dist/core/events/v3/producers/hook.d.ts.map +1 -0
- package/dist/core/events/v3/producers/hook.js +71 -0
- package/dist/core/events/v3/producers/intake.d.ts +65 -0
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -0
- package/dist/core/events/v3/producers/intake.js +244 -0
- package/dist/core/events/v3/producers/recorder.d.ts +240 -0
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/recorder.js +2176 -0
- package/dist/core/events/v3/projection.d.ts +101 -0
- package/dist/core/events/v3/projection.d.ts.map +1 -0
- package/dist/core/events/v3/projection.js +479 -0
- package/dist/core/events/v3/reader.d.ts +75 -0
- package/dist/core/events/v3/reader.d.ts.map +1 -0
- package/dist/core/events/v3/reader.js +778 -0
- package/dist/core/events/v3/recovery-record.d.ts +47 -0
- package/dist/core/events/v3/recovery-record.d.ts.map +1 -0
- package/dist/core/events/v3/recovery-record.js +167 -0
- package/dist/core/events/v3/recovery.d.ts +22 -0
- package/dist/core/events/v3/recovery.d.ts.map +1 -0
- package/dist/core/events/v3/recovery.js +227 -0
- package/dist/core/events/v3/span-state.d.ts +52 -0
- package/dist/core/events/v3/span-state.d.ts.map +1 -0
- package/dist/core/events/v3/span-state.js +142 -0
- package/dist/core/events/v3/targets.d.ts +23 -0
- package/dist/core/events/v3/targets.d.ts.map +1 -0
- package/dist/core/events/v3/targets.js +134 -0
- package/dist/core/events/v3/turn-telemetry.d.ts +41 -0
- package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -0
- package/dist/core/events/v3/turn-telemetry.js +168 -0
- package/dist/core/events/v3/validate.d.ts +9 -0
- package/dist/core/events/v3/validate.d.ts.map +1 -0
- package/dist/core/events/v3/validate.js +281 -0
- package/dist/core/events/v3/writer.d.ts +56 -0
- package/dist/core/events/v3/writer.d.ts.map +1 -0
- package/dist/core/events/v3/writer.js +335 -0
- package/dist/core/governor/index.d.ts +1 -1
- package/dist/core/governor/index.d.ts.map +1 -1
- package/dist/core/governor/index.js +1 -1
- package/dist/core/governor/plan-api.d.ts +2 -1
- package/dist/core/governor/plan-api.d.ts.map +1 -1
- package/dist/core/governor/plan-api.js +6 -3
- package/dist/core/governor/read.d.ts +1 -1
- package/dist/core/governor/read.d.ts.map +1 -1
- package/dist/core/governor/read.js +1 -1
- package/dist/core/governor/state.d.ts +9 -0
- package/dist/core/governor/state.d.ts.map +1 -1
- package/dist/core/governor/state.js +40 -3
- package/dist/core/guard/config.d.ts +5 -0
- package/dist/core/guard/config.d.ts.map +1 -0
- package/dist/core/guard/config.js +157 -0
- package/dist/core/guard/coordinator.d.ts +14 -0
- package/dist/core/guard/coordinator.d.ts.map +1 -0
- package/dist/core/guard/coordinator.js +173 -0
- package/dist/core/guard/evaluator.d.ts +4 -0
- package/dist/core/guard/evaluator.d.ts.map +1 -0
- package/dist/core/guard/evaluator.js +242 -0
- package/dist/core/guard/evidence-v3.d.ts +15 -0
- package/dist/core/guard/evidence-v3.d.ts.map +1 -0
- package/dist/core/guard/evidence-v3.js +171 -0
- package/dist/core/guard/index.d.ts +10 -0
- package/dist/core/guard/index.d.ts.map +1 -0
- package/dist/core/guard/index.js +6 -0
- package/dist/core/guard/live-source-v3.d.ts +40 -0
- package/dist/core/guard/live-source-v3.d.ts.map +1 -0
- package/dist/core/guard/live-source-v3.js +128 -0
- package/dist/core/guard/storage.d.ts +27 -0
- package/dist/core/guard/storage.d.ts.map +1 -0
- package/dist/core/guard/storage.js +140 -0
- package/dist/core/guard/types.d.ts +119 -0
- package/dist/core/guard/types.d.ts.map +1 -0
- package/dist/core/guard/types.js +1 -0
- package/dist/core/hooks/adapter/detect.d.ts +18 -1
- package/dist/core/hooks/adapter/detect.d.ts.map +1 -1
- package/dist/core/hooks/adapter/detect.js +29 -0
- package/dist/core/hooks/adapter/events.d.ts +7 -4
- package/dist/core/hooks/adapter/events.d.ts.map +1 -1
- package/dist/core/hooks/adapter/events.js +12 -4
- package/dist/core/hooks/adapter/output.d.ts +2 -2
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.d.ts +7 -4
- package/dist/core/hooks/adapter/parse.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.js +63 -25
- package/dist/core/hooks/adapter/wiring.d.ts +30 -4
- package/dist/core/hooks/adapter/wiring.d.ts.map +1 -1
- package/dist/core/hooks/adapter/wiring.js +89 -11
- package/dist/core/hooks/cli.d.ts +1 -1
- package/dist/core/hooks/cli.js +305 -444
- package/dist/core/hooks/effects/image-capture.d.ts +20 -34
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +212 -221
- package/dist/core/hooks/effects/index.d.ts +1 -9
- package/dist/core/hooks/effects/index.d.ts.map +1 -1
- package/dist/core/hooks/effects/index.js +1 -24
- package/dist/core/hooks/events/input-hash.d.ts +7 -0
- package/dist/core/hooks/events/input-hash.d.ts.map +1 -0
- package/dist/core/hooks/events/input-hash.js +43 -0
- package/dist/core/hooks/index.d.ts +4 -3
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/index.js +2 -3
- package/dist/core/hooks/resolve/coord-root.d.ts +1 -1
- package/dist/core/hooks/resolve/coord-root.js +1 -1
- package/dist/core/hooks/resolve/owner.d.ts +16 -15
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +51 -42
- package/dist/core/hooks/resolve/transcript.d.ts +33 -3
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +155 -14
- package/dist/core/hooks/session-name-presence.d.ts +9 -10
- package/dist/core/hooks/session-name-presence.d.ts.map +1 -1
- package/dist/core/hooks/session-name-presence.js +15 -15
- package/dist/core/hooks/unsafe-cross-shell.d.ts +1 -1
- package/dist/core/hooks/unsafe-cross-shell.d.ts.map +1 -1
- package/dist/core/journal/index.d.ts +2 -2
- package/dist/core/journal/index.d.ts.map +1 -1
- package/dist/core/journal/index.js +9 -22
- package/dist/core/presence/blob.d.ts +4 -3
- package/dist/core/presence/blob.d.ts.map +1 -1
- package/dist/core/presence/blob.js +45 -44
- package/dist/core/presence/codec-digest.d.ts +29 -0
- package/dist/core/presence/codec-digest.d.ts.map +1 -0
- package/dist/core/presence/codec-digest.js +170 -0
- package/dist/core/presence/relay-client.d.ts +1 -1
- package/dist/core/presence/relay-client.d.ts.map +1 -1
- package/dist/core/presence/relay-client.js +5 -5
- package/dist/core/work/index.d.ts +1 -1
- package/dist/core/work/index.d.ts.map +1 -1
- package/dist/core/work/index.js +1 -1
- package/dist/core/work/read.d.ts +1 -1
- package/dist/core/work/read.d.ts.map +1 -1
- package/dist/core/work/read.js +1 -1
- package/dist/core/work/runner.d.ts.map +1 -1
- package/dist/core/work/runner.js +6 -0
- package/dist/core/work/state.d.ts +9 -0
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +17 -3
- package/dist/core/workflow/engine.js +24 -25
- package/dist/core/workflow/live-session-v3.d.ts +19 -0
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -0
- package/dist/core/workflow/live-session-v3.js +86 -0
- package/dist/core/workflow/scope-id.d.ts +3 -0
- package/dist/core/workflow/scope-id.d.ts.map +1 -0
- package/dist/core/workflow/scope-id.js +5 -0
- package/dist/core/workflow/workspaces/leases.d.ts +4 -0
- package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/leases.js +53 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/browser/client.d.ts +41 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +203 -0
- package/dist/lib/browser/critique.d.ts +28 -2
- package/dist/lib/browser/critique.d.ts.map +1 -1
- package/dist/lib/browser/critique.js +74 -18
- package/dist/lib/browser/geometry.d.ts +1 -1
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +130 -6
- package/dist/lib/browser/index.d.ts +3 -0
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +3 -0
- package/dist/lib/browser/qa-plan.d.ts +174 -0
- package/dist/lib/browser/qa-plan.d.ts.map +1 -0
- package/dist/lib/browser/qa-plan.js +321 -0
- package/dist/lib/browser/qa-reuse.d.ts +99 -0
- package/dist/lib/browser/qa-reuse.d.ts.map +1 -0
- package/dist/lib/browser/qa-reuse.js +222 -0
- package/dist/lib/browser/qa-snapshot.d.ts +64 -0
- package/dist/lib/browser/qa-snapshot.d.ts.map +1 -0
- package/dist/lib/browser/qa-snapshot.js +171 -0
- package/dist/lib/browser/runts.d.ts.map +1 -1
- package/dist/lib/browser/runts.js +22 -1
- package/dist/lib/browser/tiling.d.ts +71 -0
- package/dist/lib/browser/tiling.d.ts.map +1 -0
- package/dist/lib/browser/tiling.js +118 -0
- package/dist/lib/claude-desktop.d.ts +0 -47
- package/dist/lib/claude-desktop.d.ts.map +1 -1
- package/dist/lib/claude-desktop.js +1 -169
- package/dist/lib/context/index.d.ts +0 -3
- package/dist/lib/context/index.d.ts.map +1 -1
- package/dist/lib/context/index.js +20 -42
- package/dist/lib/council/index.d.ts +2 -2
- package/dist/lib/council/index.d.ts.map +1 -1
- package/dist/lib/council/index.js +9 -20
- package/dist/lib/docs-frontmatter.d.ts +1 -6
- package/dist/lib/docs-frontmatter.d.ts.map +1 -1
- package/dist/lib/docs-frontmatter.js +12 -78
- package/dist/lib/docs-index.d.ts +9 -0
- package/dist/lib/docs-index.d.ts.map +1 -1
- package/dist/lib/docs-index.js +32 -3
- package/dist/lib/docs-lint.d.ts.map +1 -1
- package/dist/lib/docs-lint.js +14 -30
- package/dist/lib/docs-metadata-audit.d.ts +19 -0
- package/dist/lib/docs-metadata-audit.d.ts.map +1 -0
- package/dist/lib/docs-metadata-audit.js +132 -0
- package/dist/lib/docs-metadata-managed.d.ts +23 -0
- package/dist/lib/docs-metadata-managed.d.ts.map +1 -0
- package/dist/lib/docs-metadata-managed.js +78 -0
- package/dist/lib/docs-metadata-sync.d.ts +20 -0
- package/dist/lib/docs-metadata-sync.d.ts.map +1 -0
- package/dist/lib/docs-metadata-sync.js +222 -0
- package/dist/lib/docs-metadata-v2-schema.d.ts +273 -0
- package/dist/lib/docs-metadata-v2-schema.d.ts.map +1 -0
- package/dist/lib/docs-metadata-v2-schema.js +134 -0
- package/dist/lib/docs-metadata-v2.d.ts +21 -0
- package/dist/lib/docs-metadata-v2.d.ts.map +1 -0
- package/dist/lib/docs-metadata-v2.js +424 -0
- package/dist/lib/docs-new.d.ts +11 -0
- package/dist/lib/docs-new.d.ts.map +1 -0
- package/dist/lib/docs-new.js +52 -0
- package/dist/lib/docs-sweep.d.ts.map +1 -1
- package/dist/lib/docs-sweep.js +45 -29
- package/dist/lib/headless/index.d.ts +98 -0
- package/dist/lib/headless/index.d.ts.map +1 -0
- package/dist/lib/headless/index.js +211 -0
- package/dist/lib/identities/assume.d.ts +4 -4
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +52 -68
- package/dist/lib/instructions/apply.d.ts +5 -4
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +32 -20
- package/dist/lib/instructions/bundle.d.ts +1 -1
- package/dist/lib/instructions/bundle.d.ts.map +1 -1
- package/dist/lib/instructions/bundle.js +1 -1
- package/dist/lib/instructions/splice.d.ts +0 -1
- package/dist/lib/instructions/splice.d.ts.map +1 -1
- package/dist/lib/instructions/splice.js +22 -6
- package/dist/lib/instructions/templates.d.ts +7 -5
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +79 -9
- package/package.json +26 -5
- package/schemas/config.schema.json +120 -2
- package/schemas/docs-metadata-v2.schema.json +441 -0
- package/schemas/event-v3.schema.json +24472 -0
- package/src/commander.ts +4 -0
- package/src/commands/adapter.ts +2 -2
- package/src/commands/agents.ts +1512 -592
- package/src/commands/artifacts.ts +7 -6
- package/src/commands/backup.ts +29 -21
- package/src/commands/browse.ts +349 -8
- package/src/commands/checkpoint.ts +4 -3
- package/src/commands/claude-desktop.ts +2 -101
- package/src/commands/context.ts +1 -6
- package/src/commands/decision.ts +27 -44
- package/src/commands/docs.ts +100 -33
- package/src/commands/doctor.ts +14 -1
- package/src/commands/events.ts +256 -0
- package/src/commands/governor.ts +18 -4
- package/src/commands/init.ts +253 -57
- package/src/commands/instructions.ts +1 -1
- package/src/commands/journal.ts +4 -13
- package/src/commands/ledger-v3.ts +111 -0
- package/src/commands/presence.ts +11 -10
- package/src/commands/sync.ts +1 -1
- package/src/commands/web.ts +67 -8
- package/src/commands/work.ts +28 -5
- package/src/core/adapter.ts +5 -0
- package/src/core/adapters/attest.ts +8 -3
- package/src/core/adapters/profiles.ts +4 -6
- package/src/core/agents/canonical-emit.ts +34 -25
- package/src/core/agents/cli.ts +236 -262
- package/src/core/agents/codex-archive-v3.ts +138 -0
- package/src/core/agents/coord-client.ts +75 -188
- package/src/core/agents/finalization.ts +120 -38
- package/src/core/agents/index.ts +4 -5
- package/src/core/agents/live-authority-v3.ts +375 -0
- package/src/core/agents/live-lifecycle-v3.ts +140 -0
- package/src/core/agents/live-observation-v3.ts +216 -0
- package/src/core/agents/render/prompt-context.ts +29 -60
- package/src/core/agents/render/session-context.ts +10 -31
- package/src/core/agents/rules/claim-conflict.ts +85 -126
- package/src/core/agents/rules/commit-conflict.ts +3 -14
- package/src/core/agents/rules/stop-hook.ts +239 -293
- package/src/core/agents/session-events.ts +137 -104
- package/src/core/agents/session-finalization-state-v3.ts +90 -0
- package/src/core/agents/session-finalizer-v3.ts +953 -0
- package/src/core/agents/session-name-display.ts +149 -0
- package/src/core/agents/state/activity-log.ts +6 -14
- package/src/core/agents/state/heartbeat-writer.ts +82 -277
- package/src/core/agents/state/live-coordination-view.ts +290 -0
- package/src/core/agents/state/session-state.ts +24 -12
- package/src/core/agents/state/stale-sweep.ts +40 -17
- package/src/core/artifacts/index.ts +4 -5
- package/src/core/config.ts +148 -3
- package/src/core/context/index.ts +9 -17
- package/src/core/events/span-parent.ts +46 -0
- package/src/core/events/v3/advance.ts +168 -0
- package/src/core/events/v3/authority-outbox.ts +548 -0
- package/src/core/events/v3/base-builder.ts +60 -0
- package/src/core/events/v3/base-contract.ts +882 -0
- package/src/core/events/v3/bootstrap.ts +226 -0
- package/src/core/events/v3/builder.ts +59 -0
- package/src/core/events/v3/canonical.ts +153 -0
- package/src/core/events/v3/capabilities.ts +171 -0
- package/src/core/events/v3/capability-drift.ts +177 -0
- package/src/core/events/v3/catalog.ts +202 -0
- package/src/core/events/v3/clock-order.ts +41 -0
- package/src/core/events/v3/contract.ts +365 -0
- package/src/core/events/v3/control.ts +576 -0
- package/src/core/events/v3/coordination-view.ts +193 -0
- package/src/core/events/v3/economics.ts +384 -0
- package/src/core/events/v3/finalization-view.ts +67 -0
- package/src/core/events/v3/fingerprint-keys.ts +260 -0
- package/src/core/events/v3/generated.ts +48 -0
- package/src/core/events/v3/ids.ts +33 -0
- package/src/core/events/v3/index.ts +322 -0
- package/src/core/events/v3/latency.ts +551 -0
- package/src/core/events/v3/live-feed.ts +319 -0
- package/src/core/events/v3/live-observation.ts +39 -0
- package/src/core/events/v3/live-routing.ts +135 -0
- package/src/core/events/v3/producers/command-recorder.ts +631 -0
- package/src/core/events/v3/producers/command.ts +201 -0
- package/src/core/events/v3/producers/coordination-recorder.ts +538 -0
- package/src/core/events/v3/producers/coordination.ts +355 -0
- package/src/core/events/v3/producers/hook-base.ts +578 -0
- package/src/core/events/v3/producers/hook.ts +119 -0
- package/src/core/events/v3/producers/intake.ts +319 -0
- package/src/core/events/v3/producers/recorder.ts +2805 -0
- package/src/core/events/v3/projection.ts +653 -0
- package/src/core/events/v3/reader.ts +1127 -0
- package/src/core/events/v3/recovery-record.ts +244 -0
- package/src/core/events/v3/recovery.ts +271 -0
- package/src/core/events/v3/span-state.ts +187 -0
- package/src/core/events/v3/targets.ts +182 -0
- package/src/core/events/v3/turn-telemetry.ts +259 -0
- package/src/core/events/v3/validate.ts +361 -0
- package/src/core/events/v3/writer.ts +419 -0
- package/src/core/governor/index.ts +3 -0
- package/src/core/governor/plan-api.ts +10 -2
- package/src/core/governor/read.ts +3 -0
- package/src/core/governor/state.ts +52 -5
- package/src/core/guard/config.ts +206 -0
- package/src/core/guard/coordinator.ts +227 -0
- package/src/core/guard/evaluator.ts +343 -0
- package/src/core/guard/evidence-v3.ts +227 -0
- package/src/core/guard/index.ts +35 -0
- package/src/core/guard/live-source-v3.ts +204 -0
- package/src/core/guard/storage.ts +188 -0
- package/src/core/guard/types.ts +152 -0
- package/src/core/hooks/adapter/detect.ts +28 -1
- package/src/core/hooks/adapter/events.ts +14 -6
- package/src/core/hooks/adapter/output.ts +7 -2
- package/src/core/hooks/adapter/parse.ts +80 -38
- package/src/core/hooks/adapter/wiring.ts +119 -13
- package/src/core/hooks/cli.ts +351 -466
- package/src/core/hooks/effects/image-capture.ts +228 -238
- package/src/core/hooks/effects/index.ts +1 -36
- package/src/core/hooks/events/input-hash.ts +47 -0
- package/src/core/hooks/index.ts +4 -11
- package/src/core/hooks/resolve/coord-root.ts +1 -1
- package/src/core/hooks/resolve/owner.ts +52 -45
- package/src/core/hooks/resolve/transcript.ts +165 -14
- package/src/core/hooks/session-name-presence.ts +14 -15
- package/src/core/hooks/unsafe-cross-shell.ts +1 -1
- package/src/core/journal/index.ts +15 -22
- package/src/core/presence/blob.ts +48 -41
- package/src/core/presence/codec-digest.ts +215 -0
- package/src/core/presence/relay-client.ts +5 -5
- package/src/core/work/index.ts +3 -0
- package/src/core/work/read.ts +3 -0
- package/src/core/work/runner.ts +6 -0
- package/src/core/work/state.ts +27 -3
- package/src/core/workflow/engine.ts +24 -24
- package/src/core/workflow/live-session-v3.ts +126 -0
- package/src/core/workflow/scope-id.ts +6 -0
- package/src/core/workflow/workspaces/leases.ts +56 -19
- package/src/index.ts +1 -1
- package/src/lib/browser/client.ts +230 -0
- package/src/lib/browser/critique.ts +104 -27
- package/src/lib/browser/geometry.ts +143 -14
- package/src/lib/browser/index.ts +34 -0
- package/src/lib/browser/qa-plan.ts +501 -0
- package/src/lib/browser/qa-reuse.ts +306 -0
- package/src/lib/browser/qa-snapshot.ts +223 -0
- package/src/lib/browser/runts.ts +27 -2
- package/src/lib/browser/tiling.ts +164 -0
- package/src/lib/claude-desktop.ts +1 -232
- package/src/lib/context/index.ts +22 -46
- package/src/lib/council/index.ts +9 -21
- package/src/lib/docs-frontmatter.ts +8 -79
- package/src/lib/docs-index.ts +33 -3
- package/src/lib/docs-lint.ts +15 -29
- package/src/lib/docs-metadata-audit.ts +166 -0
- package/src/lib/docs-metadata-managed.ts +83 -0
- package/src/lib/docs-metadata-sync.ts +262 -0
- package/src/lib/docs-metadata-v2-schema.ts +138 -0
- package/src/lib/docs-metadata-v2.ts +646 -0
- package/src/lib/docs-new.ts +63 -0
- package/src/lib/docs-sweep.ts +42 -28
- package/src/lib/headless/index.ts +287 -0
- package/src/lib/identities/assume.ts +67 -86
- package/src/lib/instructions/apply.ts +33 -20
- package/src/lib/instructions/bundle.ts +2 -2
- package/src/lib/instructions/splice.ts +21 -7
- package/src/lib/instructions/templates.ts +85 -13
- package/dist/core/agents/cli-emit.d.ts +0 -27
- package/dist/core/agents/cli-emit.d.ts.map +0 -1
- package/dist/core/agents/cli-emit.js +0 -57
- package/dist/core/agents/codex-replay.d.ts +0 -29
- package/dist/core/agents/codex-replay.d.ts.map +0 -1
- package/dist/core/agents/codex-replay.js +0 -138
- package/dist/core/agents/events/consume.d.ts +0 -82
- package/dist/core/agents/events/consume.d.ts.map +0 -1
- package/dist/core/agents/events/consume.js +0 -195
- package/dist/core/agents/events/emit.d.ts +0 -42
- package/dist/core/agents/events/emit.d.ts.map +0 -1
- package/dist/core/agents/events/emit.js +0 -75
- package/dist/core/agents/events/ulid.d.ts +0 -11
- package/dist/core/agents/events/ulid.d.ts.map +0 -1
- package/dist/core/agents/events/ulid.js +0 -47
- package/dist/core/agents/state/heartbeat-projector.d.ts +0 -76
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +0 -1
- package/dist/core/agents/state/heartbeat-projector.js +0 -581
- package/dist/core/hooks/events/emit.d.ts +0 -31
- package/dist/core/hooks/events/emit.d.ts.map +0 -1
- package/dist/core/hooks/events/emit.js +0 -93
- package/dist/core/hooks/events/rotate.d.ts +0 -43
- package/dist/core/hooks/events/rotate.d.ts.map +0 -1
- package/dist/core/hooks/events/rotate.js +0 -142
- package/dist/core/hooks/events/schema.d.ts +0 -341
- package/dist/core/hooks/events/schema.d.ts.map +0 -1
- package/dist/core/hooks/events/schema.js +0 -12
- package/dist/core/hooks/events/ulid.d.ts +0 -10
- package/dist/core/hooks/events/ulid.d.ts.map +0 -1
- package/dist/core/hooks/events/ulid.js +0 -47
- package/dist/lib/docs-frontmatter-migrate.d.ts +0 -33
- package/dist/lib/docs-frontmatter-migrate.d.ts.map +0 -1
- package/dist/lib/docs-frontmatter-migrate.js +0 -364
- package/src/core/agents/cli-emit.ts +0 -64
- package/src/core/agents/codex-replay.ts +0 -163
- package/src/core/agents/events/consume.ts +0 -254
- package/src/core/agents/events/emit.ts +0 -115
- package/src/core/agents/events/ulid.ts +0 -51
- package/src/core/agents/state/heartbeat-projector.ts +0 -645
- package/src/core/hooks/events/emit.ts +0 -125
- package/src/core/hooks/events/rotate.ts +0 -151
- package/src/core/hooks/events/schema.ts +0 -582
- package/src/core/hooks/events/ulid.ts +0 -51
- package/src/lib/docs-frontmatter-migrate.ts +0 -427
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Canonical JSON for hashing adapter input before any event-payload clamp. */
|
|
2
|
+
export declare function canonicalToolInput(value: unknown): string;
|
|
3
|
+
/** Exact-input digest used by the report-only run-quality evaluator. */
|
|
4
|
+
export declare function toolInputHash(toolName: string, input: unknown): string;
|
|
5
|
+
/** Hash a semantic target without persisting its path, URL, or query. */
|
|
6
|
+
export declare function toolTargetHash(toolName: string, input: unknown): string | undefined;
|
|
7
|
+
//# sourceMappingURL=input-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-hash.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/events/input-hash.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEzD;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAMtE;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAgBnF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
/** Canonical JSON for hashing adapter input before any event-payload clamp. */
|
|
3
|
+
export function canonicalToolInput(value) {
|
|
4
|
+
return JSON.stringify(canonicalize(value));
|
|
5
|
+
}
|
|
6
|
+
/** Exact-input digest used by the report-only run-quality evaluator. */
|
|
7
|
+
export function toolInputHash(toolName, input) {
|
|
8
|
+
return createHash("sha256")
|
|
9
|
+
.update(toolName)
|
|
10
|
+
.update("\n")
|
|
11
|
+
.update(canonicalToolInput(input))
|
|
12
|
+
.digest("hex");
|
|
13
|
+
}
|
|
14
|
+
/** Hash a semantic target without persisting its path, URL, or query. */
|
|
15
|
+
export function toolTargetHash(toolName, input) {
|
|
16
|
+
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
17
|
+
return undefined;
|
|
18
|
+
const record = input;
|
|
19
|
+
const target = record.file_path ??
|
|
20
|
+
record.path ??
|
|
21
|
+
record.target ??
|
|
22
|
+
record.url ??
|
|
23
|
+
record.notebook_path ??
|
|
24
|
+
record.pattern;
|
|
25
|
+
if (target === undefined)
|
|
26
|
+
return undefined;
|
|
27
|
+
return createHash("sha256")
|
|
28
|
+
.update(toolName)
|
|
29
|
+
.update("\n")
|
|
30
|
+
.update(canonicalToolInput(target))
|
|
31
|
+
.digest("hex");
|
|
32
|
+
}
|
|
33
|
+
function canonicalize(value) {
|
|
34
|
+
if (Array.isArray(value))
|
|
35
|
+
return value.map(canonicalize);
|
|
36
|
+
if (value && typeof value === "object") {
|
|
37
|
+
const record = value;
|
|
38
|
+
return Object.fromEntries(Object.keys(record)
|
|
39
|
+
.sort()
|
|
40
|
+
.map((key) => [key, canonicalize(record[key])]));
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
@@ -1,8 +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
|
-
export {
|
|
6
|
+
export type { Adapter } from "../adapter.js";
|
|
7
|
+
export type { EventV3 as Event } from "../events/v3/contract.js";
|
|
8
|
+
export { EventV3Schema } from "../events/v3/contract.js";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/core/hooks/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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
|
-
export {
|
|
6
|
+
export { EventV3Schema } from "../events/v3/contract.js";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* different roots. They used to: this walked up from `CLAUDE_PROJECT_DIR` or
|
|
6
6
|
* cwd while the CLI's `monorepoRoot()` asked git for the superproject first, so
|
|
7
7
|
* with a shell inside a submodule that carries its own `.harnery/`, the CLI's
|
|
8
|
-
* `
|
|
8
|
+
* `coord.status_observed` landed in a stream this side never read and rule 1/3
|
|
9
9
|
* blocked every turn.
|
|
10
10
|
*
|
|
11
11
|
* Resolution precedence (see `resolveCoordRoot` for the full rationale):
|
|
@@ -6,7 +6,7 @@ import { resolveCoordRoot } from "../../agents/coord-client.js";
|
|
|
6
6
|
* different roots. They used to: this walked up from `CLAUDE_PROJECT_DIR` or
|
|
7
7
|
* cwd while the CLI's `monorepoRoot()` asked git for the superproject first, so
|
|
8
8
|
* with a shell inside a submodule that carries its own `.harnery/`, the CLI's
|
|
9
|
-
* `
|
|
9
|
+
* `coord.status_observed` landed in a stream this side never read and rule 1/3
|
|
10
10
|
* blocked every turn.
|
|
11
11
|
*
|
|
12
12
|
* Resolution precedence (see `resolveCoordRoot` for the full rationale):
|
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Precedence:
|
|
5
5
|
*
|
|
6
|
-
* 1.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `
|
|
11
|
-
*
|
|
12
|
-
*
|
|
6
|
+
* 1. Hook payload fields. Current live V3 authority breaks ties: a live
|
|
7
|
+
* child wins when it belongs to the payload session, otherwise the live
|
|
8
|
+
* session/conversation wins over a stale adapter `agent_id`. With no live
|
|
9
|
+
* evidence, the legacy `agent_id` → `subagent_id` → `session_id` →
|
|
10
|
+
* `conversation_id` order remains the startup fallback.
|
|
11
|
+
* 2. `HARNERY_AGENT_COORD_OWNER` outside bridge mode. Bridge-marked children
|
|
12
|
+
* ignore this unvalidated override.
|
|
13
|
+
* 3. Adapter-exported session identity matched to one live V3 generation.
|
|
14
|
+
* This is the only payload-free identity accepted in bridge mode.
|
|
15
|
+
* 4. PID-map lookup at `.harnery/pid-map/<pid>` for our own pid, then ppid
|
|
13
16
|
* chain (up to 20 hops).
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* one place the pid walk can never land. Validated so a garbage value
|
|
19
|
-
* cannot fabricate an identity.
|
|
17
|
+
*
|
|
18
|
+
* Bridge-marked children fail closed after tier 3. A connector crosses a
|
|
19
|
+
* process-tree boundary, so pid ancestry and singleton state are not evidence
|
|
20
|
+
* of its logical session.
|
|
20
21
|
*
|
|
21
22
|
* Returns null when nothing resolves. Callers must treat null as "no owner"
|
|
22
23
|
* and skip the event (Phase 2 fail-safe; Phase 3 will mint a temporary owner
|
|
@@ -27,7 +28,7 @@ export declare function resolveOwner(opts: {
|
|
|
27
28
|
coordRoot: string;
|
|
28
29
|
}): {
|
|
29
30
|
instance_id: string;
|
|
30
|
-
source: "env" | "payload" | "
|
|
31
|
+
source: "env" | "payload" | "session_env" | "pidmap-self" | "pidmap-ancestor";
|
|
31
32
|
} | null;
|
|
32
33
|
/**
|
|
33
34
|
* Find the parent owner for a subagent invocation. The per-shell marker at
|
|
@@ -38,7 +39,7 @@ export declare function resolveOwner(opts: {
|
|
|
38
39
|
* cases. Phase 2 callers can pass through.
|
|
39
40
|
*/
|
|
40
41
|
export declare function readShellMarker(coordRoot: string, pid: number): string | null;
|
|
41
|
-
/** Read the
|
|
42
|
+
/** Read the V3-projected `agent_id` for an owner if it exists. */
|
|
42
43
|
export declare function readAgentIdForOwner(coordRoot: string, instanceId: string): string | null;
|
|
43
44
|
/** Diagnostic: list of pid-map entries (for debugging). */
|
|
44
45
|
export declare function listPidmap(coordRoot: string): Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owner.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/owner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"owner.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/owner.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,KAAK,GAAG,SAAS,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,CAAC;CAC/E,GAAG,IAAI,CA4EP;AA2BD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ7E;AAED,kEAAkE;AAClE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAExF;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBnF"}
|
|
@@ -2,44 +2,72 @@ 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.js";
|
|
5
|
+
import { resolveOwnerBySessionEnv } from "../../agents/coord-client.js";
|
|
6
|
+
import { readLiveCoordinationRow } from "../../agents/state/live-coordination-view.js";
|
|
5
7
|
import { checkPidToken } from "../../agents/state/proc-start.js";
|
|
6
8
|
/**
|
|
7
9
|
* Resolve the canonical `instance_id` for the current hook invocation.
|
|
8
10
|
*
|
|
9
11
|
* Precedence:
|
|
10
12
|
*
|
|
11
|
-
* 1.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* `
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* 1. Hook payload fields. Current live V3 authority breaks ties: a live
|
|
14
|
+
* child wins when it belongs to the payload session, otherwise the live
|
|
15
|
+
* session/conversation wins over a stale adapter `agent_id`. With no live
|
|
16
|
+
* evidence, the legacy `agent_id` → `subagent_id` → `session_id` →
|
|
17
|
+
* `conversation_id` order remains the startup fallback.
|
|
18
|
+
* 2. `HARNERY_AGENT_COORD_OWNER` outside bridge mode. Bridge-marked children
|
|
19
|
+
* ignore this unvalidated override.
|
|
20
|
+
* 3. Adapter-exported session identity matched to one live V3 generation.
|
|
21
|
+
* This is the only payload-free identity accepted in bridge mode.
|
|
22
|
+
* 4. PID-map lookup at `.harnery/pid-map/<pid>` for our own pid, then ppid
|
|
18
23
|
* chain (up to 20 hops).
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* one place the pid walk can never land. Validated so a garbage value
|
|
24
|
-
* cannot fabricate an identity.
|
|
24
|
+
*
|
|
25
|
+
* Bridge-marked children fail closed after tier 3. A connector crosses a
|
|
26
|
+
* process-tree boundary, so pid ancestry and singleton state are not evidence
|
|
27
|
+
* of its logical session.
|
|
25
28
|
*
|
|
26
29
|
* Returns null when nothing resolves. Callers must treat null as "no owner"
|
|
27
30
|
* and skip the event (Phase 2 fail-safe; Phase 3 will mint a temporary owner
|
|
28
31
|
* for orphan events).
|
|
29
32
|
*/
|
|
30
33
|
export function resolveOwner(opts) {
|
|
31
|
-
const env = coordEnv("AGENT_COORD_OWNER");
|
|
32
|
-
if (env && env.length > 0) {
|
|
33
|
-
return { instance_id: env, source: "env" };
|
|
34
|
-
}
|
|
35
34
|
if (opts.payload) {
|
|
35
|
+
const value = (key) => {
|
|
36
|
+
const candidate = opts.payload?.[key];
|
|
37
|
+
return typeof candidate === "string" && candidate.length > 0 ? candidate : undefined;
|
|
38
|
+
};
|
|
39
|
+
const childId = value("subagent_id") ?? value("agent_id");
|
|
40
|
+
const sessionId = value("session_id") ?? value("conversation_id");
|
|
41
|
+
const child = childId ? readLiveCoordinationRow(opts.coordRoot, childId) : null;
|
|
42
|
+
const session = sessionId ? readLiveCoordinationRow(opts.coordRoot, sessionId) : null;
|
|
43
|
+
if (child && sessionId && (child.kind === "subagent" || child.session_id === sessionId)) {
|
|
44
|
+
return { instance_id: childId, source: "payload" };
|
|
45
|
+
}
|
|
46
|
+
if (session)
|
|
47
|
+
return { instance_id: sessionId, source: "payload" };
|
|
48
|
+
if (child)
|
|
49
|
+
return { instance_id: childId, source: "payload" };
|
|
36
50
|
for (const key of ["agent_id", "subagent_id", "session_id", "conversation_id"]) {
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
return { instance_id:
|
|
40
|
-
}
|
|
51
|
+
const candidate = value(key);
|
|
52
|
+
if (candidate)
|
|
53
|
+
return { instance_id: candidate, source: "payload" };
|
|
41
54
|
}
|
|
42
55
|
}
|
|
56
|
+
const bridge = coordEnv("AGENT_COORD_BRIDGE")?.trim();
|
|
57
|
+
const env = coordEnv("AGENT_COORD_OWNER");
|
|
58
|
+
if (env && env.length > 0 && !bridge) {
|
|
59
|
+
return { instance_id: env, source: "env" };
|
|
60
|
+
}
|
|
61
|
+
// A Windows-hosted Codex task can replace its WSL process tree during a
|
|
62
|
+
// repository refresh. The forwarded native thread id survives that boundary
|
|
63
|
+
// and is safe only after joining to exactly one nonterminal V3 producer.
|
|
64
|
+
// Resolve it before the bridge fail-closed branch; never fall through to the
|
|
65
|
+
// old pid map when the join fails.
|
|
66
|
+
const sessionOwner = resolveOwnerBySessionEnv(opts.coordRoot);
|
|
67
|
+
if (sessionOwner)
|
|
68
|
+
return { instance_id: sessionOwner, source: "session_env" };
|
|
69
|
+
if (bridge)
|
|
70
|
+
return null;
|
|
43
71
|
// Pid-map ancestor walk. Start at own pid (the bash wrapper's bun child),
|
|
44
72
|
// walk up through ppids. The pid-map is stamped keyed by the adapter PID, so
|
|
45
73
|
// we'll usually find it 1-3 hops up.
|
|
@@ -77,15 +105,6 @@ export function resolveOwner(opts) {
|
|
|
77
105
|
hops++;
|
|
78
106
|
}
|
|
79
107
|
}
|
|
80
|
-
// Tier 4: Codex thread id, heartbeat-validated. Last because the pid map is
|
|
81
|
-
// more specific when it answers — an inherited env var can outlive the
|
|
82
|
-
// process tree it described, a live pid-map row cannot.
|
|
83
|
-
const codexThreadId = process.env.CODEX_THREAD_ID?.trim();
|
|
84
|
-
if (codexThreadId &&
|
|
85
|
-
/^[A-Za-z0-9-]+$/.test(codexThreadId) &&
|
|
86
|
-
existsSync(join(opts.coordRoot, ".harnery", "active", `${codexThreadId}.json`))) {
|
|
87
|
-
return { instance_id: codexThreadId, source: "codex-env" };
|
|
88
|
-
}
|
|
89
108
|
return null;
|
|
90
109
|
}
|
|
91
110
|
function readPpid(pid) {
|
|
@@ -135,19 +154,9 @@ export function readShellMarker(coordRoot, pid) {
|
|
|
135
154
|
return null;
|
|
136
155
|
}
|
|
137
156
|
}
|
|
138
|
-
/** Read the
|
|
157
|
+
/** Read the V3-projected `agent_id` for an owner if it exists. */
|
|
139
158
|
export function readAgentIdForOwner(coordRoot, instanceId) {
|
|
140
|
-
|
|
141
|
-
if (!existsSync(path))
|
|
142
|
-
return null;
|
|
143
|
-
try {
|
|
144
|
-
const body = readFileSync(path, "utf8");
|
|
145
|
-
const data = JSON.parse(body);
|
|
146
|
-
return data.agent_id ?? null;
|
|
147
|
-
}
|
|
148
|
-
catch {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
159
|
+
return readLiveCoordinationRow(coordRoot, instanceId)?.agent_id ?? null;
|
|
151
160
|
}
|
|
152
161
|
/** Diagnostic: list of pid-map entries (for debugging). */
|
|
153
162
|
export function listPidmap(coordRoot) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Scan a CC-style JSONL transcript for the `┌─ agent-` status-box prefix in
|
|
3
|
-
* the most-recent assistant turn. Used by `turn.
|
|
3
|
+
* the most-recent assistant turn. Used by `turn.completed` events to populate
|
|
4
4
|
* `status_box_present`.
|
|
5
5
|
*
|
|
6
6
|
* Cheap by default: caps the read at 256KB tailed from the file, since the
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
export declare function scanStatusBoxPresent(transcriptPath: string | undefined): boolean;
|
|
13
13
|
/**
|
|
14
14
|
* Scan a CC-style JSONL transcript for a needle in ASSISTANT message text
|
|
15
|
-
* blocks only. Used by `turn.
|
|
15
|
+
* blocks only. Used by `turn.completed` to detect the suggested session name in the
|
|
16
16
|
* reply.
|
|
17
17
|
*
|
|
18
18
|
* The row filter is load-bearing: the transcript tail also carries the needle
|
|
@@ -25,11 +25,41 @@ export declare function scanStatusBoxPresent(transcriptPath: string | undefined)
|
|
|
25
25
|
* truncated JSON row, which the per-line parse guard skips.
|
|
26
26
|
*/
|
|
27
27
|
export declare function scanAssistantTextIncludes(transcriptPath: string | undefined, needle: string): boolean;
|
|
28
|
+
/** Most recent user-visible assistant text across Claude Code and Codex JSONL. */
|
|
29
|
+
export declare function scanLatestAssistantText(transcriptPath: string | undefined): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Verify that the first assistant message after the set-task result begins
|
|
32
|
+
* with the exact session-name block. This is the Stop-time fallback for a
|
|
33
|
+
* correctly displayed name followed by no further tool call. A name printed
|
|
34
|
+
* after later work does not pass.
|
|
35
|
+
*/
|
|
36
|
+
export declare function scanSessionNameDisplayedImmediately(transcriptPath: string | undefined, name: string, startsWithBlock: (text: string, expectedName: string) => boolean): boolean;
|
|
37
|
+
export type SessionNameDisplayInspection = {
|
|
38
|
+
state: "present";
|
|
39
|
+
} | {
|
|
40
|
+
state: "absent";
|
|
41
|
+
} | {
|
|
42
|
+
state: "unavailable";
|
|
43
|
+
reason: "missing_transcript" | "transcript_not_ready";
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Inspect the ordered post-mint reply without conflating a malformed display
|
|
47
|
+
* with an unreadable transcript. PreToolUse can enforce the former, while the
|
|
48
|
+
* latter must remain an honest unsupported observation instead of deadlocking
|
|
49
|
+
* every tool behind evidence the adapter has not persisted yet.
|
|
50
|
+
*/
|
|
51
|
+
export declare function inspectSessionNameDisplayImmediately(transcriptPath: string | undefined, name: string, startsWithBlock: (text: string, expectedName: string) => boolean): SessionNameDisplayInspection;
|
|
52
|
+
/**
|
|
53
|
+
* Resolve a transcript path at the adapter boundary. Windows-native Codex can
|
|
54
|
+
* send `C:\...` while the managed hook executes inside WSL, where the same
|
|
55
|
+
* file is mounted at `/mnt/c/...`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function transcriptPathCandidates(transcriptPath: string | undefined): string[];
|
|
28
58
|
/**
|
|
29
59
|
* Resolve the agent's model from a CC-style JSONL transcript by reading the
|
|
30
60
|
* most-recent assistant message's `message.model`. Claude Code's SessionStart
|
|
31
61
|
* payload omits `model` (Codex + Cursor supply it directly), so this is the
|
|
32
|
-
* fallback that lets `session.
|
|
62
|
+
* fallback that lets `session.started` / `turn.completed` populate the cache's
|
|
33
63
|
* model field once the transcript has at least one assistant turn.
|
|
34
64
|
*
|
|
35
65
|
* Tail-reads the same 256KB window as the status-box scan and walks lines from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/transcript.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/transcript.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAQhF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,MAAM,EAAE,MAAM,GACb,OAAO,CAiCT;AAED,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAgB9F;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CACjD,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,OAAO,GAC/D,OAAO,CAIT;AAED,MAAM,MAAM,4BAA4B,GACpC;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GACpB;IAAE,KAAK,EAAE,QAAQ,CAAA;CAAE,GACnB;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,oBAAoB,GAAG,sBAAsB,CAAA;CAAE,CAAC;AAEpF;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,OAAO,GAC/D,4BAA4B,CAsB9B;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAUrF;AAwDD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAuB1F;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAkDpB"}
|
|
@@ -2,7 +2,7 @@ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
|
2
2
|
import { basename, dirname, join } from "node:path";
|
|
3
3
|
/**
|
|
4
4
|
* Scan a CC-style JSONL transcript for the `┌─ agent-` status-box prefix in
|
|
5
|
-
* the most-recent assistant turn. Used by `turn.
|
|
5
|
+
* the most-recent assistant turn. Used by `turn.completed` events to populate
|
|
6
6
|
* `status_box_present`.
|
|
7
7
|
*
|
|
8
8
|
* Cheap by default: caps the read at 256KB tailed from the file, since the
|
|
@@ -12,9 +12,10 @@ import { basename, dirname, join } from "node:path";
|
|
|
12
12
|
* and Phase 5 verdict path catches the race via a single retry.
|
|
13
13
|
*/
|
|
14
14
|
export function scanStatusBoxPresent(transcriptPath) {
|
|
15
|
-
|
|
15
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
16
|
+
if (!readablePath)
|
|
16
17
|
return false;
|
|
17
|
-
const text = tailText(
|
|
18
|
+
const text = tailText(readablePath);
|
|
18
19
|
if (text === undefined)
|
|
19
20
|
return false;
|
|
20
21
|
// The box is rendered as a text content block by the assistant; we look
|
|
@@ -23,7 +24,7 @@ export function scanStatusBoxPresent(transcriptPath) {
|
|
|
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
|
|
@@ -36,9 +37,12 @@ export function scanStatusBoxPresent(transcriptPath) {
|
|
|
36
37
|
* truncated JSON row, which the per-line parse guard skips.
|
|
37
38
|
*/
|
|
38
39
|
export function scanAssistantTextIncludes(transcriptPath, needle) {
|
|
39
|
-
if (!
|
|
40
|
+
if (!needle)
|
|
40
41
|
return false;
|
|
41
|
-
const
|
|
42
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
43
|
+
if (!readablePath)
|
|
44
|
+
return false;
|
|
45
|
+
const text = tailText(readablePath);
|
|
42
46
|
if (!text)
|
|
43
47
|
return false;
|
|
44
48
|
for (const line of text.split("\n")) {
|
|
@@ -72,11 +76,144 @@ export function scanAssistantTextIncludes(transcriptPath, needle) {
|
|
|
72
76
|
}
|
|
73
77
|
return false;
|
|
74
78
|
}
|
|
79
|
+
/** Most recent user-visible assistant text across Claude Code and Codex JSONL. */
|
|
80
|
+
export function scanLatestAssistantText(transcriptPath) {
|
|
81
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
82
|
+
if (!readablePath)
|
|
83
|
+
return undefined;
|
|
84
|
+
const text = tailText(readablePath);
|
|
85
|
+
if (!text)
|
|
86
|
+
return undefined;
|
|
87
|
+
const lines = text.split("\n");
|
|
88
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
89
|
+
const row = parseTranscriptRow(lines[i]);
|
|
90
|
+
if (!row)
|
|
91
|
+
continue;
|
|
92
|
+
const assistantText = assistantTextFromRow(row);
|
|
93
|
+
// Claude Code appends the current tool_use-only assistant row before
|
|
94
|
+
// PreToolUse fires. Skip rows with no user-visible text so the immediately
|
|
95
|
+
// preceding fenced block remains discoverable.
|
|
96
|
+
if (assistantText !== null && assistantText.trim().length > 0)
|
|
97
|
+
return assistantText;
|
|
98
|
+
}
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Verify that the first assistant message after the set-task result begins
|
|
103
|
+
* with the exact session-name block. This is the Stop-time fallback for a
|
|
104
|
+
* correctly displayed name followed by no further tool call. A name printed
|
|
105
|
+
* after later work does not pass.
|
|
106
|
+
*/
|
|
107
|
+
export function scanSessionNameDisplayedImmediately(transcriptPath, name, startsWithBlock) {
|
|
108
|
+
return (inspectSessionNameDisplayImmediately(transcriptPath, name, startsWithBlock).state === "present");
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Inspect the ordered post-mint reply without conflating a malformed display
|
|
112
|
+
* with an unreadable transcript. PreToolUse can enforce the former, while the
|
|
113
|
+
* latter must remain an honest unsupported observation instead of deadlocking
|
|
114
|
+
* every tool behind evidence the adapter has not persisted yet.
|
|
115
|
+
*/
|
|
116
|
+
export function inspectSessionNameDisplayImmediately(transcriptPath, name, startsWithBlock) {
|
|
117
|
+
if (!name)
|
|
118
|
+
return { state: "absent" };
|
|
119
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
120
|
+
if (!readablePath)
|
|
121
|
+
return { state: "unavailable", reason: "missing_transcript" };
|
|
122
|
+
const text = tailText(readablePath);
|
|
123
|
+
if (!text)
|
|
124
|
+
return { state: "unavailable", reason: "transcript_not_ready" };
|
|
125
|
+
let sawMintResult = false;
|
|
126
|
+
for (const line of text.split("\n")) {
|
|
127
|
+
if (!sawMintResult) {
|
|
128
|
+
if (line.includes(name) && line.includes("suggested_session_name"))
|
|
129
|
+
sawMintResult = true;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const row = parseTranscriptRow(line);
|
|
133
|
+
if (!row)
|
|
134
|
+
continue;
|
|
135
|
+
const assistantText = assistantTextFromRow(row);
|
|
136
|
+
if (assistantText !== null) {
|
|
137
|
+
return { state: startsWithBlock(assistantText, name) ? "present" : "absent" };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return sawMintResult
|
|
141
|
+
? { state: "unavailable", reason: "transcript_not_ready" }
|
|
142
|
+
: { state: "absent" };
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Resolve a transcript path at the adapter boundary. Windows-native Codex can
|
|
146
|
+
* send `C:\...` while the managed hook executes inside WSL, where the same
|
|
147
|
+
* file is mounted at `/mnt/c/...`.
|
|
148
|
+
*/
|
|
149
|
+
export function transcriptPathCandidates(transcriptPath) {
|
|
150
|
+
if (!transcriptPath)
|
|
151
|
+
return [];
|
|
152
|
+
const candidates = [transcriptPath];
|
|
153
|
+
const windowsDrive = /^([A-Za-z]):[\\/](.*)$/.exec(transcriptPath);
|
|
154
|
+
if (windowsDrive) {
|
|
155
|
+
candidates.push(`/mnt/${windowsDrive[1].toLowerCase()}/${windowsDrive[2].replaceAll("\\", "/")}`);
|
|
156
|
+
}
|
|
157
|
+
return [...new Set(candidates)];
|
|
158
|
+
}
|
|
159
|
+
function resolveTranscriptPath(transcriptPath) {
|
|
160
|
+
return transcriptPathCandidates(transcriptPath).find((candidate) => existsSync(candidate));
|
|
161
|
+
}
|
|
162
|
+
function parseTranscriptRow(line) {
|
|
163
|
+
if (!line?.trim())
|
|
164
|
+
return null;
|
|
165
|
+
try {
|
|
166
|
+
const row = JSON.parse(line);
|
|
167
|
+
return typeof row === "object" && row !== null ? row : null;
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/** null means this row is not an assistant message; an empty string is one with no text. */
|
|
174
|
+
function assistantTextFromRow(row) {
|
|
175
|
+
if (row.type === "assistant") {
|
|
176
|
+
const message = objectValue(row.message);
|
|
177
|
+
return textFromContent(message?.content);
|
|
178
|
+
}
|
|
179
|
+
if (row.type === "response_item") {
|
|
180
|
+
const payload = objectValue(row.payload);
|
|
181
|
+
if (payload?.type !== "message" || payload.role !== "assistant")
|
|
182
|
+
return null;
|
|
183
|
+
return textFromContent(payload.content);
|
|
184
|
+
}
|
|
185
|
+
if (row.type === "event_msg") {
|
|
186
|
+
const payload = objectValue(row.payload);
|
|
187
|
+
if (payload?.type !== "agent_message")
|
|
188
|
+
return null;
|
|
189
|
+
return typeof payload.message === "string" ? payload.message : "";
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
function objectValue(value) {
|
|
194
|
+
return typeof value === "object" && value !== null ? value : null;
|
|
195
|
+
}
|
|
196
|
+
function textFromContent(content) {
|
|
197
|
+
if (typeof content === "string")
|
|
198
|
+
return content;
|
|
199
|
+
if (!Array.isArray(content))
|
|
200
|
+
return "";
|
|
201
|
+
const parts = [];
|
|
202
|
+
for (const block of content) {
|
|
203
|
+
const value = objectValue(block);
|
|
204
|
+
if (!value)
|
|
205
|
+
continue;
|
|
206
|
+
if ((value.type === "text" || value.type === "output_text") && typeof value.text === "string") {
|
|
207
|
+
parts.push(value.text);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return parts.join("\n");
|
|
211
|
+
}
|
|
75
212
|
/**
|
|
76
213
|
* Resolve the agent's model from a CC-style JSONL transcript by reading the
|
|
77
214
|
* most-recent assistant message's `message.model`. Claude Code's SessionStart
|
|
78
215
|
* payload omits `model` (Codex + Cursor supply it directly), so this is the
|
|
79
|
-
* fallback that lets `session.
|
|
216
|
+
* fallback that lets `session.started` / `turn.completed` populate the cache's
|
|
80
217
|
* model field once the transcript has at least one assistant turn.
|
|
81
218
|
*
|
|
82
219
|
* Tail-reads the same 256KB window as the status-box scan and walks lines from
|
|
@@ -85,9 +222,10 @@ export function scanAssistantTextIncludes(transcriptPath, needle) {
|
|
|
85
222
|
* transcript is missing/empty (e.g. a fresh session's first SessionStart).
|
|
86
223
|
*/
|
|
87
224
|
export function scanTranscriptModel(transcriptPath) {
|
|
88
|
-
|
|
225
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
226
|
+
if (!readablePath)
|
|
89
227
|
return undefined;
|
|
90
|
-
const text = tailText(
|
|
228
|
+
const text = tailText(readablePath);
|
|
91
229
|
if (!text)
|
|
92
230
|
return undefined;
|
|
93
231
|
const lines = text.split("\n");
|
|
@@ -143,17 +281,20 @@ const FORK_SAMPLE_SIZE = 24;
|
|
|
143
281
|
*/
|
|
144
282
|
export function detectForkParent(transcriptPath, sessionId) {
|
|
145
283
|
try {
|
|
146
|
-
if (!
|
|
284
|
+
if (!sessionId)
|
|
285
|
+
return undefined;
|
|
286
|
+
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
287
|
+
if (!readablePath)
|
|
147
288
|
return undefined;
|
|
148
|
-
if (statSync(
|
|
289
|
+
if (statSync(readablePath).size > FORK_SCAN_MAX_BYTES)
|
|
149
290
|
return undefined;
|
|
150
|
-
const own = readFileSync(
|
|
291
|
+
const own = readFileSync(readablePath, "utf8");
|
|
151
292
|
const uuids = messageUuids(own);
|
|
152
293
|
if (uuids.length === 0)
|
|
153
294
|
return undefined;
|
|
154
295
|
const sample = sampleEvenly(uuids, FORK_SAMPLE_SIZE);
|
|
155
|
-
const dir = dirname(
|
|
156
|
-
const ownFile = basename(
|
|
296
|
+
const dir = dirname(readablePath);
|
|
297
|
+
const ownFile = basename(readablePath);
|
|
157
298
|
let best = null;
|
|
158
299
|
for (const file of readdirSync(dir)) {
|
|
159
300
|
if (file === ownFile || !SESSION_FILE_RE.test(file))
|
|
@@ -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
|
|
@@ -26,5 +25,5 @@ export interface SessionNamePresence {
|
|
|
26
25
|
session_name_present?: boolean;
|
|
27
26
|
session_name_present_for?: string;
|
|
28
27
|
}
|
|
29
|
-
export declare function sessionNamePresence(coordRoot: string, instanceId: string,
|
|
28
|
+
export declare function sessionNamePresence(coordRoot: string, instanceId: string, scanAssistantText: (name: string) => boolean): SessionNamePresence;
|
|
30
29
|
//# sourceMappingURL=session-name-presence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-name-presence.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/session-name-presence.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session-name-presence.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/session-name-presence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,MAAM,WAAW,mBAAmB;IAClC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAC3C,mBAAmB,CAcrB"}
|