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
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tiny ULID generator. Crockford-base32, 10-char timestamp (48-bit ms epoch)
|
|
3
|
-
* + 16-char random (80-bit). 26 chars total, monotonically-sortable.
|
|
4
|
-
*
|
|
5
|
-
* Library-free so the module stays dep-free (no `ulid` package). Quality is
|
|
6
|
-
* sufficient for event_id uniqueness: the kth event in a millisecond uses a
|
|
7
|
-
* fresh 80-bit random, collision probability negligible.
|
|
8
|
-
*/
|
|
9
|
-
const ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
10
|
-
export function ulid() {
|
|
11
|
-
const ts = encodeTime(Date.now());
|
|
12
|
-
const rnd = encodeRandom();
|
|
13
|
-
return ts + rnd;
|
|
14
|
-
}
|
|
15
|
-
function encodeTime(ms) {
|
|
16
|
-
let out = "";
|
|
17
|
-
let n = BigInt(ms);
|
|
18
|
-
const base = BigInt(32);
|
|
19
|
-
for (let i = 0; i < 10; i++) {
|
|
20
|
-
const mod = Number(n % base);
|
|
21
|
-
out = ALPHABET[mod] + out;
|
|
22
|
-
n = n / base;
|
|
23
|
-
}
|
|
24
|
-
return out;
|
|
25
|
-
}
|
|
26
|
-
function encodeRandom() {
|
|
27
|
-
const bytes = new Uint8Array(10);
|
|
28
|
-
crypto.getRandomValues(bytes);
|
|
29
|
-
// Map each pair of bytes to 3 alphabet chars (5 bits per char, 16 chars).
|
|
30
|
-
let out = "";
|
|
31
|
-
let buf = 0n;
|
|
32
|
-
let bits = 0;
|
|
33
|
-
for (const b of bytes) {
|
|
34
|
-
buf = (buf << 8n) | BigInt(b);
|
|
35
|
-
bits += 8;
|
|
36
|
-
while (bits >= 5) {
|
|
37
|
-
bits -= 5;
|
|
38
|
-
const idx = Number((buf >> BigInt(bits)) & 0x1fn);
|
|
39
|
-
out += ALPHABET[idx];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (bits > 0) {
|
|
43
|
-
const idx = Number((buf << BigInt(5 - bits)) & 0x1fn);
|
|
44
|
-
out += ALPHABET[idx];
|
|
45
|
-
}
|
|
46
|
-
return out.slice(0, 16);
|
|
47
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type DocKind } from "./docs-frontmatter.js";
|
|
2
|
-
export declare function initDocsMigrationContext(opts: {
|
|
3
|
-
repoRoot: string;
|
|
4
|
-
submodules: readonly string[];
|
|
5
|
-
}): void;
|
|
6
|
-
export interface FrontmatterMigrationOpts {
|
|
7
|
-
repo?: string;
|
|
8
|
-
apply?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export type FrontmatterMigrationStatus = "would-update" | "updated" | "skipped" | "error";
|
|
11
|
-
export interface FrontmatterMigrationRow {
|
|
12
|
-
repo: string;
|
|
13
|
-
path: string;
|
|
14
|
-
kind: DocKind;
|
|
15
|
-
status: FrontmatterMigrationStatus;
|
|
16
|
-
fields: string[];
|
|
17
|
-
message?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface FrontmatterConversion {
|
|
20
|
-
status: "convert" | "skipped" | "error";
|
|
21
|
-
content?: string;
|
|
22
|
-
fields: string[];
|
|
23
|
-
message?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Convert one lifecycle document without writing it.
|
|
27
|
-
*
|
|
28
|
-
* Only recognized bold fields in the opening block are removed. Narrative
|
|
29
|
-
* labels and bold examples deeper in the body are left byte-for-byte intact.
|
|
30
|
-
*/
|
|
31
|
-
export declare function convertLifecycleFrontmatter(content: string, kind: DocKind): FrontmatterConversion;
|
|
32
|
-
export declare function runFrontmatterMigration(opts: FrontmatterMigrationOpts): FrontmatterMigrationRow[];
|
|
33
|
-
//# sourceMappingURL=docs-frontmatter-migrate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"docs-frontmatter-migrate.d.ts","sourceRoot":"","sources":["../../src/lib/docs-frontmatter-migrate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAqC,MAAM,uBAAuB,CAAC;AAKxF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B,GAAG,IAAI,CAGP;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,0BAA0B,GAAG,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE1F,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,0BAA0B,CAAC;IACnC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAsKD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,qBAAqB,CAsHjG;AAoCD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,uBAAuB,EAAE,CA+DjG"}
|
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { dirname, join, relative, resolve } from "node:path";
|
|
3
|
-
import { dump as dumpYaml, JSON_SCHEMA } from "js-yaml";
|
|
4
|
-
import { normalizeStatus, parseFrontmatter } from "./docs-frontmatter.js";
|
|
5
|
-
let REPO_ROOT = "";
|
|
6
|
-
let SUBMODULES = [];
|
|
7
|
-
export function initDocsMigrationContext(opts) {
|
|
8
|
-
REPO_ROOT = opts.repoRoot;
|
|
9
|
-
SUBMODULES = opts.submodules;
|
|
10
|
-
}
|
|
11
|
-
const FIELD_KEYS = {
|
|
12
|
-
status: "status",
|
|
13
|
-
date: "date",
|
|
14
|
-
"last updated": "last_updated",
|
|
15
|
-
"date identified": "date",
|
|
16
|
-
"date resolved": "resolved",
|
|
17
|
-
"date fixed": "resolved",
|
|
18
|
-
prerequisites: "prerequisites",
|
|
19
|
-
severity: "severity",
|
|
20
|
-
resolved: "resolved",
|
|
21
|
-
affected: "affected",
|
|
22
|
-
impact: "affected",
|
|
23
|
-
owner: "owner",
|
|
24
|
-
continues: "continues",
|
|
25
|
-
"what you're picking up": "synopsis",
|
|
26
|
-
};
|
|
27
|
-
const FIELD_ORDER = [
|
|
28
|
-
"status",
|
|
29
|
-
"date",
|
|
30
|
-
"last_updated",
|
|
31
|
-
"status_note",
|
|
32
|
-
"prerequisites",
|
|
33
|
-
"owner",
|
|
34
|
-
"severity",
|
|
35
|
-
"resolved",
|
|
36
|
-
"affected",
|
|
37
|
-
"continues",
|
|
38
|
-
"synopsis",
|
|
39
|
-
];
|
|
40
|
-
function normalizeLabel(label) {
|
|
41
|
-
return label.trim().toLowerCase();
|
|
42
|
-
}
|
|
43
|
-
function openingFields(body) {
|
|
44
|
-
const lines = body.split("\n");
|
|
45
|
-
const fields = [];
|
|
46
|
-
for (let index = 0; index < Math.min(lines.length, 40); index++) {
|
|
47
|
-
const line = lines[index];
|
|
48
|
-
if (/^##\s+/.test(line) || (index > 0 && /^---\s*$/.test(line)))
|
|
49
|
-
break;
|
|
50
|
-
const match = line.match(/^\*\*([^*]+):\*\*\s*(.*)$/) ?? line.match(/^\*\*([^*]+)\*\*:\s*(.*)$/);
|
|
51
|
-
if (!match)
|
|
52
|
-
continue;
|
|
53
|
-
const label = normalizeLabel(match[1]);
|
|
54
|
-
if (!(label in FIELD_KEYS))
|
|
55
|
-
continue;
|
|
56
|
-
fields.push({ index, label, value: match[2].trim() });
|
|
57
|
-
}
|
|
58
|
-
return fields;
|
|
59
|
-
}
|
|
60
|
-
function cleanNote(value) {
|
|
61
|
-
let note = value.trim().replace(/^[-–—\s]+/, "");
|
|
62
|
-
if (note.startsWith("(") && note.endsWith(")"))
|
|
63
|
-
note = note.slice(1, -1);
|
|
64
|
-
return note
|
|
65
|
-
.replace(/\*\*/g, "")
|
|
66
|
-
.replace(/^[*_`]+|[*_`]+$/g, "")
|
|
67
|
-
.trim();
|
|
68
|
-
}
|
|
69
|
-
function cleanStatusToken(value) {
|
|
70
|
-
return value.trim().replace(/^[*_`]+|[*_`]+$/g, "");
|
|
71
|
-
}
|
|
72
|
-
function splitStatus(raw, kind) {
|
|
73
|
-
const clean = raw.replace(/^[^\p{L}\p{N}]+/u, "").trim();
|
|
74
|
-
if (!clean)
|
|
75
|
-
return { error: "empty status value" };
|
|
76
|
-
const separator = clean.match(/\s+[-–—]\s+|\s*\(/);
|
|
77
|
-
if (separator?.index != null) {
|
|
78
|
-
const token = cleanStatusToken(clean.slice(0, separator.index));
|
|
79
|
-
const normalized = normalizeStatus(token, kind);
|
|
80
|
-
if (normalized) {
|
|
81
|
-
const note = cleanNote(clean.slice(separator.index));
|
|
82
|
-
return { status: normalized, ...(note ? { note } : {}) };
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const whole = normalizeStatus(cleanStatusToken(clean), kind);
|
|
86
|
-
if (whole)
|
|
87
|
-
return { status: whole };
|
|
88
|
-
const words = clean.split(/\s+/);
|
|
89
|
-
for (const count of [1, 2, 3]) {
|
|
90
|
-
if (words.length <= count)
|
|
91
|
-
continue;
|
|
92
|
-
const token = cleanStatusToken(words.slice(0, count).join(" "));
|
|
93
|
-
const normalized = normalizeStatus(token, kind);
|
|
94
|
-
if (!normalized)
|
|
95
|
-
continue;
|
|
96
|
-
const note = cleanNote(words.slice(count).join(" "));
|
|
97
|
-
return { status: normalized, ...(note ? { note } : {}) };
|
|
98
|
-
}
|
|
99
|
-
return { error: `unsupported ${kind} status '${raw}'` };
|
|
100
|
-
}
|
|
101
|
-
function leadingDate(raw) {
|
|
102
|
-
const match = raw.match(/^(\d{4}-\d{2}-\d{2})(.*)$/);
|
|
103
|
-
if (!match)
|
|
104
|
-
return { value: raw };
|
|
105
|
-
const note = cleanNote(match[2]);
|
|
106
|
-
return { value: match[1], ...(note ? { note } : {}) };
|
|
107
|
-
}
|
|
108
|
-
function splitSeverity(raw) {
|
|
109
|
-
const plain = raw.replace(/\*\*/g, "").trim();
|
|
110
|
-
const leading = plain.match(/^(low|medium|high|critical)\b(.*)$/i);
|
|
111
|
-
if (leading) {
|
|
112
|
-
const note = cleanNote(leading[2]);
|
|
113
|
-
return {
|
|
114
|
-
severity: leading[1].toLowerCase(),
|
|
115
|
-
...(note ? { note } : {}),
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
const severity = /\bcritical\b/i.test(plain)
|
|
119
|
-
? "critical"
|
|
120
|
-
: /\bhigh\b/i.test(plain)
|
|
121
|
-
? "high"
|
|
122
|
-
: /\b(?:medium|moderate)\b/i.test(plain)
|
|
123
|
-
? "medium"
|
|
124
|
-
: /\blow\b/i.test(plain)
|
|
125
|
-
? "low"
|
|
126
|
-
: null;
|
|
127
|
-
if (!severity)
|
|
128
|
-
return { error: `unsupported severity '${raw}'` };
|
|
129
|
-
return { severity, note: plain };
|
|
130
|
-
}
|
|
131
|
-
function serializeFields(fields) {
|
|
132
|
-
return FIELD_ORDER.filter((key) => Object.hasOwn(fields, key))
|
|
133
|
-
.map((key) => dumpYaml({ [key]: fields[key] }, {
|
|
134
|
-
schema: JSON_SCHEMA,
|
|
135
|
-
noRefs: true,
|
|
136
|
-
lineWidth: -1,
|
|
137
|
-
sortKeys: false,
|
|
138
|
-
}).trimEnd())
|
|
139
|
-
.join("\n");
|
|
140
|
-
}
|
|
141
|
-
function mergeStatusNote(existing, notes) {
|
|
142
|
-
const parts = [
|
|
143
|
-
...(typeof existing === "string" && existing.trim() ? [existing.trim()] : []),
|
|
144
|
-
...notes.filter(Boolean),
|
|
145
|
-
];
|
|
146
|
-
return parts.length > 0 ? parts.join("; ") : undefined;
|
|
147
|
-
}
|
|
148
|
-
function valuesEqual(left, right) {
|
|
149
|
-
return JSON.stringify(left) === JSON.stringify(right);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Convert one lifecycle document without writing it.
|
|
153
|
-
*
|
|
154
|
-
* Only recognized bold fields in the opening block are removed. Narrative
|
|
155
|
-
* labels and bold examples deeper in the body are left byte-for-byte intact.
|
|
156
|
-
*/
|
|
157
|
-
export function convertLifecycleFrontmatter(content, kind) {
|
|
158
|
-
const parsed = parseFrontmatter(content);
|
|
159
|
-
const boldFields = openingFields(parsed.body);
|
|
160
|
-
const statusFields = boldFields.filter((field) => field.label === "status");
|
|
161
|
-
const hasYamlStatus = typeof parsed.data.status === "string" && parsed.data.status.trim();
|
|
162
|
-
if (statusFields.length === 0 && !hasYamlStatus) {
|
|
163
|
-
const variant = parsed.body
|
|
164
|
-
.split("\n")
|
|
165
|
-
.slice(0, 40)
|
|
166
|
-
.find((line) => /^\*\*Status/i.test(line));
|
|
167
|
-
return {
|
|
168
|
-
status: variant ? "error" : "skipped",
|
|
169
|
-
fields: [],
|
|
170
|
-
message: variant ? `unsupported bold status shape '${variant.trim()}'` : "no opening status",
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
if (statusFields.length === 0 && hasYamlStatus && boldFields.length === 0) {
|
|
174
|
-
return {
|
|
175
|
-
status: "skipped",
|
|
176
|
-
fields: [],
|
|
177
|
-
message: "already has YAML status",
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
if (statusFields.length > 1) {
|
|
181
|
-
return {
|
|
182
|
-
status: "error",
|
|
183
|
-
fields: [],
|
|
184
|
-
message: "multiple opening Status fields",
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
const migrated = {};
|
|
188
|
-
const notes = [];
|
|
189
|
-
const remove = new Set();
|
|
190
|
-
const hasOpeningDate = boldFields.some((field) => field.label === "date");
|
|
191
|
-
for (const field of boldFields) {
|
|
192
|
-
const key = FIELD_KEYS[field.label];
|
|
193
|
-
let value = field.value;
|
|
194
|
-
if (key === "status") {
|
|
195
|
-
const split = splitStatus(field.value, kind);
|
|
196
|
-
if ("error" in split)
|
|
197
|
-
return { status: "error", fields: [], message: split.error };
|
|
198
|
-
value = split.status;
|
|
199
|
-
if (split.note &&
|
|
200
|
-
/^\d{4}-\d{2}-\d{2}$/.test(split.note) &&
|
|
201
|
-
kind === "plan" &&
|
|
202
|
-
split.status === "proposed" &&
|
|
203
|
-
!hasOpeningDate &&
|
|
204
|
-
!Object.hasOwn(parsed.data, "date")) {
|
|
205
|
-
migrated.date = split.note;
|
|
206
|
-
}
|
|
207
|
-
else if (split.note) {
|
|
208
|
-
notes.push(split.note);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
else if (key === "date" || key === "last_updated" || key === "resolved") {
|
|
212
|
-
const date = leadingDate(field.value);
|
|
213
|
-
value = date.value;
|
|
214
|
-
if (date.note)
|
|
215
|
-
notes.push(`${key}: ${date.note}`);
|
|
216
|
-
}
|
|
217
|
-
else if (key === "prerequisites" && field.value.toLowerCase() === "none") {
|
|
218
|
-
value = [];
|
|
219
|
-
}
|
|
220
|
-
else if (key === "severity") {
|
|
221
|
-
const severity = splitSeverity(field.value);
|
|
222
|
-
if ("error" in severity) {
|
|
223
|
-
return { status: "error", fields: [], message: severity.error };
|
|
224
|
-
}
|
|
225
|
-
value = severity.severity;
|
|
226
|
-
if (severity.note)
|
|
227
|
-
notes.push(`severity: ${severity.note}`);
|
|
228
|
-
}
|
|
229
|
-
if (Object.hasOwn(migrated, key)) {
|
|
230
|
-
return {
|
|
231
|
-
status: "error",
|
|
232
|
-
fields: [],
|
|
233
|
-
message: `multiple opening '${field.label}' fields`,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
if (Object.hasOwn(parsed.data, key)) {
|
|
237
|
-
if (!valuesEqual(parsed.data[key], value)) {
|
|
238
|
-
return {
|
|
239
|
-
status: "error",
|
|
240
|
-
fields: [],
|
|
241
|
-
message: `YAML '${key}' conflicts with bold '${field.label}'`,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
migrated[key] = value;
|
|
247
|
-
}
|
|
248
|
-
remove.add(field.index);
|
|
249
|
-
}
|
|
250
|
-
const statusNote = mergeStatusNote(parsed.data.status_note, notes);
|
|
251
|
-
if (notes.length > 0 && Object.hasOwn(parsed.data, "status_note")) {
|
|
252
|
-
return {
|
|
253
|
-
status: "error",
|
|
254
|
-
fields: [],
|
|
255
|
-
message: "YAML 'status_note' conflicts with migrated metadata notes",
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
if (statusNote) {
|
|
259
|
-
migrated.status_note = statusNote;
|
|
260
|
-
}
|
|
261
|
-
const body = parsed.body
|
|
262
|
-
.split("\n")
|
|
263
|
-
.filter((_, index) => !remove.has(index))
|
|
264
|
-
.join("\n")
|
|
265
|
-
.replace(/^\n+/, "");
|
|
266
|
-
const newFields = serializeFields(migrated);
|
|
267
|
-
const yaml = parsed.raw ? `${parsed.raw.trimEnd()}\n${newFields}`.trim() : newFields;
|
|
268
|
-
const next = `---\n${yaml}\n---\n\n${body}`;
|
|
269
|
-
return {
|
|
270
|
-
status: "convert",
|
|
271
|
-
content: next,
|
|
272
|
-
fields: Object.keys(migrated),
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
function walkMarkdown(dir) {
|
|
276
|
-
if (!existsSync(dir))
|
|
277
|
-
return [];
|
|
278
|
-
const files = [];
|
|
279
|
-
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
280
|
-
const path = join(dir, entry.name);
|
|
281
|
-
if (entry.isDirectory())
|
|
282
|
-
files.push(...walkMarkdown(path));
|
|
283
|
-
else if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
284
|
-
files.push(path);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
return files;
|
|
288
|
-
}
|
|
289
|
-
function lifecycleFiles(repoPath) {
|
|
290
|
-
const kinds = [
|
|
291
|
-
{ dir: "plans", kind: "plan" },
|
|
292
|
-
{ dir: "issues", kind: "issue" },
|
|
293
|
-
{ dir: "handoffs", kind: "handoff" },
|
|
294
|
-
];
|
|
295
|
-
return kinds.flatMap(({ dir, kind }) => walkMarkdown(join(repoPath, "docs", dir)).map((path) => ({ path, kind })));
|
|
296
|
-
}
|
|
297
|
-
function isInitializedRepo(path) {
|
|
298
|
-
return existsSync(join(path, ".git"));
|
|
299
|
-
}
|
|
300
|
-
function writeAtomic(path, content) {
|
|
301
|
-
const temp = join(dirname(path), `.${Date.now()}-${process.pid}.frontmatter.tmp`);
|
|
302
|
-
writeFileSync(temp, content, "utf8");
|
|
303
|
-
renameSync(temp, path);
|
|
304
|
-
}
|
|
305
|
-
export function runFrontmatterMigration(opts) {
|
|
306
|
-
const targets = [
|
|
307
|
-
{ name: "(root)", path: REPO_ROOT },
|
|
308
|
-
...SUBMODULES.map((name) => ({ name, path: resolve(REPO_ROOT, name) })).filter((target) => isInitializedRepo(target.path)),
|
|
309
|
-
];
|
|
310
|
-
const filter = opts.repo === "." ? "(root)" : opts.repo;
|
|
311
|
-
const selected = filter ? targets.filter((target) => target.name === filter) : targets;
|
|
312
|
-
if (filter && selected.length === 0)
|
|
313
|
-
throw new Error(`Unknown repository: ${opts.repo}`);
|
|
314
|
-
const rows = [];
|
|
315
|
-
const pending = [];
|
|
316
|
-
for (const target of selected) {
|
|
317
|
-
for (const file of lifecycleFiles(target.path)) {
|
|
318
|
-
const displayPath = relative(REPO_ROOT, file.path);
|
|
319
|
-
let content;
|
|
320
|
-
try {
|
|
321
|
-
content = readFileSync(file.path, "utf8");
|
|
322
|
-
}
|
|
323
|
-
catch {
|
|
324
|
-
rows.push({
|
|
325
|
-
repo: target.name,
|
|
326
|
-
path: displayPath,
|
|
327
|
-
kind: file.kind,
|
|
328
|
-
status: "error",
|
|
329
|
-
fields: [],
|
|
330
|
-
message: "unable to read file",
|
|
331
|
-
});
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
|
-
const conversion = convertLifecycleFrontmatter(content, file.kind);
|
|
335
|
-
if (conversion.status === "error" || conversion.status === "skipped") {
|
|
336
|
-
rows.push({
|
|
337
|
-
repo: target.name,
|
|
338
|
-
path: displayPath,
|
|
339
|
-
kind: file.kind,
|
|
340
|
-
status: conversion.status,
|
|
341
|
-
fields: conversion.fields,
|
|
342
|
-
message: conversion.message,
|
|
343
|
-
});
|
|
344
|
-
continue;
|
|
345
|
-
}
|
|
346
|
-
const row = {
|
|
347
|
-
repo: target.name,
|
|
348
|
-
path: displayPath,
|
|
349
|
-
kind: file.kind,
|
|
350
|
-
status: "would-update",
|
|
351
|
-
fields: conversion.fields,
|
|
352
|
-
};
|
|
353
|
-
rows.push(row);
|
|
354
|
-
pending.push({ row, path: file.path, content: conversion.content });
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (opts.apply && !rows.some((row) => row.status === "error")) {
|
|
358
|
-
for (const item of pending) {
|
|
359
|
-
writeAtomic(item.path, item.content);
|
|
360
|
-
item.row.status = "updated";
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
return rows.sort((a, b) => a.path.localeCompare(b.path));
|
|
364
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI-side canonical event emission helper. Importable from any CLI surface
|
|
3
|
-
* to emit-then-project in one call.
|
|
4
|
-
*
|
|
5
|
-
* Pattern: every state-changing CLI command appends its event first, then
|
|
6
|
-
* runs the projector synchronously for the affected owner.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { type EmitInput, type Envelope, emit } from "./events/emit.ts";
|
|
10
|
-
import { findCoordRoot } from "./paths.ts";
|
|
11
|
-
import { projectHeartbeats } from "./state/heartbeat-projector.ts";
|
|
12
|
-
|
|
13
|
-
export interface EmitAndProjectResult {
|
|
14
|
-
envelope: Envelope;
|
|
15
|
-
projected: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Emit a canonical event AND synchronously project it into the owner's v2
|
|
20
|
-
* heartbeat. Idempotent on event_id: replays don't double-apply.
|
|
21
|
-
*
|
|
22
|
-
* Returns the emitted envelope so callers can inspect / log.
|
|
23
|
-
*
|
|
24
|
-
* Soft-fails on any internal error: never throws into the caller, because
|
|
25
|
-
* this runs inside operator-facing CLI commands and a corrupt events.ndjson
|
|
26
|
-
* line shouldn't break `agents set-task`.
|
|
27
|
-
*/
|
|
28
|
-
export function emitAndProject(
|
|
29
|
-
input: EmitInput,
|
|
30
|
-
opts: { coordRoot?: string; skipProject?: boolean } = {},
|
|
31
|
-
): EmitAndProjectResult | null {
|
|
32
|
-
const root = opts.coordRoot ?? findCoordRoot();
|
|
33
|
-
if (!root) return null;
|
|
34
|
-
try {
|
|
35
|
-
const envelope = emit(root, input);
|
|
36
|
-
let projected = false;
|
|
37
|
-
if (!opts.skipProject) {
|
|
38
|
-
try {
|
|
39
|
-
projectHeartbeats(root, [
|
|
40
|
-
{
|
|
41
|
-
schema_version: envelope.schema_version,
|
|
42
|
-
event_id: envelope.event_id,
|
|
43
|
-
event_type: envelope.event_type,
|
|
44
|
-
ts: envelope.ts,
|
|
45
|
-
instance_id: envelope.instance_id,
|
|
46
|
-
session_id: envelope.session_id,
|
|
47
|
-
parent_session_id: envelope.parent_session_id,
|
|
48
|
-
turn_id: envelope.turn_id,
|
|
49
|
-
parent_turn_id: envelope.parent_turn_id,
|
|
50
|
-
adapter: envelope.adapter,
|
|
51
|
-
source: envelope.source,
|
|
52
|
-
data: envelope.data,
|
|
53
|
-
},
|
|
54
|
-
]);
|
|
55
|
-
projected = true;
|
|
56
|
-
} catch {
|
|
57
|
-
/* projector failure is non-fatal; next agent-coord project run catches up */
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return { envelope, projected };
|
|
61
|
-
} catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex JSONL → canonical event replay.
|
|
3
|
-
*
|
|
4
|
-
* Production codex sessions emit canonical events from each `harn` invocation
|
|
5
|
-
* via the in-process session-tee middleware (which calls `agent-coord
|
|
6
|
-
* emit-event` for state.task_set / state.status_checked). But the codex
|
|
7
|
-
* adapter itself doesn't wire agent-hook on preToolUse, so user_prompt.submit
|
|
8
|
-
* + tool.pre_use + turn.stop aren't emitted live.
|
|
9
|
-
*
|
|
10
|
-
* This module parses the Codex JSONL transcript at stop time and emits the
|
|
11
|
-
* missing canonical events so the verdict has a complete turn-window view.
|
|
12
|
-
*
|
|
13
|
-
* Scope: just the events the stop-hook verdict reads: user_prompt.submit,
|
|
14
|
-
* tool.pre_use (for exec_command function calls), state.status_checked
|
|
15
|
-
* (when the cmd contains `<bin> agents status`), state.task_set (when the cmd
|
|
16
|
-
* contains `<bin> agents set-task`), turn.stop (with status_box_present derived
|
|
17
|
-
* from the last_assistant_message).
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
21
|
-
import { emit } from "./events/emit.ts";
|
|
22
|
-
|
|
23
|
-
interface CodexEntry {
|
|
24
|
-
timestamp?: string;
|
|
25
|
-
type?: string;
|
|
26
|
-
payload?: {
|
|
27
|
-
type?: string;
|
|
28
|
-
message?: string;
|
|
29
|
-
name?: string;
|
|
30
|
-
arguments?: string;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const STATUS_BOX_PREFIX = "┌─ agent-";
|
|
35
|
-
|
|
36
|
-
export interface CodexReplayOpts {
|
|
37
|
-
coordRoot: string;
|
|
38
|
-
sessionId: string;
|
|
39
|
-
instanceId: string;
|
|
40
|
-
jsonlPath: string;
|
|
41
|
-
lastAssistantMessage?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function replayCodexJsonl(opts: CodexReplayOpts): { emitted: number } {
|
|
45
|
-
const { coordRoot, sessionId, instanceId, jsonlPath, lastAssistantMessage } = opts;
|
|
46
|
-
if (!existsSync(jsonlPath)) return { emitted: 0 };
|
|
47
|
-
|
|
48
|
-
let raw: string;
|
|
49
|
-
try {
|
|
50
|
-
raw = readFileSync(jsonlPath, "utf8");
|
|
51
|
-
} catch {
|
|
52
|
-
return { emitted: 0 };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let emitted = 0;
|
|
56
|
-
const lines = raw.split("\n");
|
|
57
|
-
|
|
58
|
-
for (const line of lines) {
|
|
59
|
-
if (!line.trim()) continue;
|
|
60
|
-
let entry: CodexEntry;
|
|
61
|
-
try {
|
|
62
|
-
entry = JSON.parse(line) as CodexEntry;
|
|
63
|
-
} catch {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
const ts = entry.timestamp;
|
|
67
|
-
const t = entry.type;
|
|
68
|
-
|
|
69
|
-
if (t === "event_msg" && entry.payload?.type === "user_message") {
|
|
70
|
-
emit(coordRoot, {
|
|
71
|
-
event_type: "user_prompt.submit",
|
|
72
|
-
instance_id: instanceId,
|
|
73
|
-
session_id: sessionId,
|
|
74
|
-
adapter: "codex",
|
|
75
|
-
ts,
|
|
76
|
-
data: {
|
|
77
|
-
prompt_text: clamp(entry.payload.message ?? "", 4000),
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
emitted += 1;
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (t === "response_item" && entry.payload?.type === "function_call") {
|
|
85
|
-
const name = entry.payload.name ?? "";
|
|
86
|
-
let cmd = "";
|
|
87
|
-
if (entry.payload.arguments) {
|
|
88
|
-
try {
|
|
89
|
-
const parsed = JSON.parse(entry.payload.arguments) as { cmd?: string };
|
|
90
|
-
cmd = parsed.cmd ?? "";
|
|
91
|
-
} catch {
|
|
92
|
-
/* skip */
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// Emit tool.pre_use for every function call.
|
|
96
|
-
emit(coordRoot, {
|
|
97
|
-
event_type: "tool.pre_use",
|
|
98
|
-
instance_id: instanceId,
|
|
99
|
-
session_id: sessionId,
|
|
100
|
-
adapter: "codex",
|
|
101
|
-
ts,
|
|
102
|
-
data: {
|
|
103
|
-
tool_name: name === "exec_command" ? "Bash" : name,
|
|
104
|
-
tool_input: JSON.stringify({ command: cmd }),
|
|
105
|
-
intent: "",
|
|
106
|
-
intent_source: "codex-replay",
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
emitted += 1;
|
|
110
|
-
|
|
111
|
-
// Match `<bin> agents status` / `<bin> agents set-task`, bin-agnostic, so
|
|
112
|
-
// it works for harn or any host CLI that composes harnery (a consumer's own
|
|
113
|
-
// binary). Wrapped invocations (cd && <bin> ...; PATH=... <bin> ...) pass
|
|
114
|
-
// because we scan the whole cmd string and anchor on the token before `agents`.
|
|
115
|
-
if (/(^|\s|;|&&)[\w./-]+\s+agents\s+status(\b|$)/.test(cmd)) {
|
|
116
|
-
emit(coordRoot, {
|
|
117
|
-
event_type: "state.status_checked",
|
|
118
|
-
instance_id: instanceId,
|
|
119
|
-
session_id: sessionId,
|
|
120
|
-
adapter: "codex",
|
|
121
|
-
ts,
|
|
122
|
-
data: { source: "codex-replay" },
|
|
123
|
-
});
|
|
124
|
-
emitted += 1;
|
|
125
|
-
}
|
|
126
|
-
if (/(^|\s|;|&&)[\w./-]+\s+agents\s+set-task(\b|$)/.test(cmd)) {
|
|
127
|
-
emit(coordRoot, {
|
|
128
|
-
event_type: "state.task_set",
|
|
129
|
-
instance_id: instanceId,
|
|
130
|
-
session_id: sessionId,
|
|
131
|
-
adapter: "codex",
|
|
132
|
-
ts,
|
|
133
|
-
data: { source: "codex-replay" },
|
|
134
|
-
});
|
|
135
|
-
emitted += 1;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Finally, emit turn.stop with status_box_present derived from the last
|
|
141
|
-
// assistant message (codex's stop payload carries the assistant text
|
|
142
|
-
// directly, unlike CC which only has transcript_path).
|
|
143
|
-
const boxPresent = !!lastAssistantMessage && lastAssistantMessage.includes(STATUS_BOX_PREFIX);
|
|
144
|
-
emit(coordRoot, {
|
|
145
|
-
event_type: "turn.stop",
|
|
146
|
-
instance_id: instanceId,
|
|
147
|
-
session_id: sessionId,
|
|
148
|
-
adapter: "codex",
|
|
149
|
-
data: {
|
|
150
|
-
status_box_present: boxPresent,
|
|
151
|
-
tool_call_count: -1,
|
|
152
|
-
text_length: lastAssistantMessage?.length ?? 0,
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
emitted += 1;
|
|
156
|
-
|
|
157
|
-
return { emitted };
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function clamp(s: string, max: number): string {
|
|
161
|
-
if (s.length <= max) return s;
|
|
162
|
-
return s.slice(0, max);
|
|
163
|
-
}
|