harnery 0.34.1 → 0.36.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 +30 -5
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +124 -94
- package/dist/commands/agents.d.ts +37 -6
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +466 -371
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +10 -10
- package/dist/commands/browse-session.d.ts.map +1 -1
- package/dist/commands/browse-session.js +12 -0
- package/dist/commands/browse.d.ts +1 -1
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +31 -6
- package/dist/commands/conversations.d.ts +10 -0
- package/dist/commands/conversations.d.ts.map +1 -0
- package/dist/commands/conversations.js +201 -0
- package/dist/commands/decision.d.ts.map +1 -1
- package/dist/commands/decision.js +2 -2
- package/dist/commands/deinit.d.ts.map +1 -1
- package/dist/commands/deinit.js +5 -0
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +13 -2
- package/dist/commands/doctor.d.ts +5 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +51 -7
- package/dist/commands/events.d.ts.map +1 -1
- package/dist/commands/events.js +18 -1
- package/dist/commands/fetch.js +6 -5
- package/dist/commands/files.d.ts +22 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +113 -0
- package/dist/commands/governor.js +14 -12
- package/dist/commands/inbox.d.ts +5 -0
- package/dist/commands/inbox.d.ts.map +1 -0
- package/dist/commands/inbox.js +57 -0
- package/dist/commands/init.d.ts +4 -5
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +63 -13
- package/dist/commands/ledger-v3.d.ts.map +1 -1
- package/dist/commands/ledger-v3.js +347 -1
- package/dist/commands/logs.d.ts +4 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +169 -0
- package/dist/commands/messages.d.ts +5 -0
- package/dist/commands/messages.d.ts.map +1 -0
- package/dist/commands/messages.js +45 -0
- package/dist/commands/outline.d.ts +1 -1
- package/dist/commands/outline.d.ts.map +1 -1
- package/dist/commands/outline.js +2 -2
- package/dist/commands/presence.d.ts.map +1 -1
- package/dist/commands/presence.js +2 -2
- package/dist/commands/read.d.ts +1 -1
- package/dist/commands/read.d.ts.map +1 -1
- package/dist/commands/read.js +2 -2
- package/dist/commands/semantic.d.ts +4 -0
- package/dist/commands/semantic.d.ts.map +1 -0
- package/dist/commands/semantic.js +199 -0
- package/dist/commands/storage.d.ts +4 -0
- package/dist/commands/storage.d.ts.map +1 -0
- package/dist/commands/storage.js +238 -0
- package/dist/commands/tunnel.d.ts +5 -1
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +44 -31
- package/dist/commands/web.d.ts +3 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +84 -7
- package/dist/commands/work.js +3 -3
- package/dist/commands/workflow.js +13 -13
- package/dist/core/adapters/profiles.d.ts +1 -1
- package/dist/core/agents/canonical-emit.d.ts +3 -0
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +12 -0
- package/dist/core/agents/claim-path.d.ts +11 -0
- package/dist/core/agents/claim-path.d.ts.map +1 -0
- package/dist/core/agents/claim-path.js +22 -0
- package/dist/core/agents/cli.js +209 -39
- package/dist/core/agents/coord-client.d.ts +29 -3
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +88 -9
- package/dist/core/agents/live-authority-v3.d.ts +47 -1
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +245 -13
- package/dist/core/agents/live-lifecycle-v3.js +9 -4
- package/dist/core/agents/live-observation-v3.d.ts.map +1 -1
- package/dist/core/agents/live-observation-v3.js +8 -3
- package/dist/core/agents/render/prompt-context.d.ts +9 -3
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +36 -17
- package/dist/core/agents/rules/stop-hook.d.ts +2 -0
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +115 -22
- package/dist/core/agents/rules/verdict.d.ts +1 -0
- package/dist/core/agents/rules/verdict.d.ts.map +1 -1
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +4 -0
- package/dist/core/agents/session-finalization-state-v3.js +1 -1
- package/dist/core/agents/session-finalizer-v3.js +5 -1
- package/dist/core/agents/session-name-display.d.ts +1 -0
- package/dist/core/agents/session-name-display.d.ts.map +1 -1
- package/dist/core/agents/session-name-display.js +8 -1
- package/dist/core/agents/state/activity-log.d.ts +3 -0
- package/dist/core/agents/state/activity-log.d.ts.map +1 -1
- package/dist/core/agents/state/activity-log.js +6 -3
- package/dist/core/agents/state/heartbeat-reader.d.ts +46 -0
- package/dist/core/agents/state/heartbeat-reader.d.ts.map +1 -0
- package/dist/core/agents/state/heartbeat-reader.js +25 -0
- package/dist/core/agents/state/heartbeat-writer.d.ts +9 -48
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +34 -34
- package/dist/core/agents/state/live-coordination-view.d.ts +6 -8
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.js +16 -67
- package/dist/core/agents/state/live-coordination-writer.d.ts +12 -0
- package/dist/core/agents/state/live-coordination-writer.d.ts.map +1 -0
- package/dist/core/agents/state/live-coordination-writer.js +92 -0
- package/dist/core/agents/state/names.d.ts +9 -1
- package/dist/core/agents/state/names.d.ts.map +1 -1
- package/dist/core/agents/state/names.js +190 -182
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +23 -5
- package/dist/core/artifacts/constants.d.ts +5 -0
- package/dist/core/artifacts/constants.d.ts.map +1 -0
- package/dist/core/artifacts/constants.js +4 -0
- package/dist/core/artifacts/index.d.ts +24 -3
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +96 -8
- package/dist/core/config.d.ts +62 -4
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +98 -4
- package/dist/core/conversations/archive.d.ts +49 -0
- package/dist/core/conversations/archive.d.ts.map +1 -0
- package/dist/core/conversations/archive.js +136 -0
- package/dist/core/conversations/catalog.d.ts +10 -0
- package/dist/core/conversations/catalog.d.ts.map +1 -0
- package/dist/core/conversations/catalog.js +72 -0
- package/dist/core/conversations/context-pack.d.ts +6 -0
- package/dist/core/conversations/context-pack.d.ts.map +1 -0
- package/dist/core/conversations/context-pack.js +60 -0
- package/dist/core/conversations/contract.d.ts +155 -0
- package/dist/core/conversations/contract.d.ts.map +1 -0
- package/dist/core/conversations/contract.js +1 -0
- package/dist/core/conversations/evaluation.d.ts +16 -0
- package/dist/core/conversations/evaluation.d.ts.map +1 -0
- package/dist/core/conversations/evaluation.js +9 -0
- package/dist/core/conversations/index.d.ts +10 -0
- package/dist/core/conversations/index.d.ts.map +1 -0
- package/dist/core/conversations/index.js +9 -0
- package/dist/core/conversations/lifecycle.d.ts +28 -0
- package/dist/core/conversations/lifecycle.d.ts.map +1 -0
- package/dist/core/conversations/lifecycle.js +29 -0
- package/dist/core/conversations/normalize.d.ts +14 -0
- package/dist/core/conversations/normalize.d.ts.map +1 -0
- package/dist/core/conversations/normalize.js +82 -0
- package/dist/core/conversations/query.d.ts +8 -0
- package/dist/core/conversations/query.d.ts.map +1 -0
- package/dist/core/conversations/query.js +280 -0
- package/dist/core/conversations/search-index.d.ts +9 -0
- package/dist/core/conversations/search-index.d.ts.map +1 -0
- package/dist/core/conversations/search-index.js +29 -0
- package/dist/core/events/legacy-storage/canary.d.ts +18 -0
- package/dist/core/events/legacy-storage/canary.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/canary.js +150 -0
- package/dist/core/events/legacy-storage/fence.d.ts +15 -0
- package/dist/core/events/legacy-storage/fence.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/fence.js +115 -0
- package/dist/core/events/legacy-storage/index.d.ts +6 -0
- package/dist/core/events/legacy-storage/index.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/index.js +5 -0
- package/dist/core/events/legacy-storage/inventory.d.ts +10 -0
- package/dist/core/events/legacy-storage/inventory.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/inventory.js +40 -0
- package/dist/core/events/legacy-storage/manifest.d.ts +23 -0
- package/dist/core/events/legacy-storage/manifest.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/manifest.js +108 -0
- package/dist/core/events/legacy-storage/reader.d.ts +15 -0
- package/dist/core/events/legacy-storage/reader.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/reader.js +154 -0
- package/dist/core/events/v3/authority-outbox.d.ts +7 -2
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
- package/dist/core/events/v3/authority-outbox.js +16 -3
- package/dist/core/events/v3/base-contract.d.ts +851 -16
- package/dist/core/events/v3/base-contract.d.ts.map +1 -1
- package/dist/core/events/v3/base-contract.js +50 -7
- package/dist/core/events/v3/bootstrap.d.ts +39 -0
- package/dist/core/events/v3/bootstrap.d.ts.map +1 -1
- package/dist/core/events/v3/bootstrap.js +167 -3
- package/dist/core/events/v3/capabilities.d.ts +11 -0
- package/dist/core/events/v3/capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/capabilities.js +26 -3
- package/dist/core/events/v3/control-witness.d.ts +44 -0
- package/dist/core/events/v3/control-witness.d.ts.map +1 -0
- package/dist/core/events/v3/control-witness.js +233 -0
- package/dist/core/events/v3/control-writer.d.ts +4 -0
- package/dist/core/events/v3/control-writer.d.ts.map +1 -0
- package/dist/core/events/v3/control-writer.js +16 -0
- package/dist/core/events/v3/control.d.ts +8 -2
- package/dist/core/events/v3/control.d.ts.map +1 -1
- package/dist/core/events/v3/control.js +46 -18
- package/dist/core/events/v3/coordination-transaction-recovery.d.ts +42 -0
- package/dist/core/events/v3/coordination-transaction-recovery.d.ts.map +1 -0
- package/dist/core/events/v3/coordination-transaction-recovery.js +342 -0
- package/dist/core/events/v3/coordination-view.d.ts.map +1 -1
- package/dist/core/events/v3/coordination-view.js +16 -1
- package/dist/core/events/v3/generated.d.ts +1 -1
- package/dist/core/events/v3/generated.js +1 -1
- package/dist/core/events/v3/index.d.ts +8 -5
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +7 -4
- package/dist/core/events/v3/latency.d.ts +31 -1
- package/dist/core/events/v3/latency.d.ts.map +1 -1
- package/dist/core/events/v3/latency.js +127 -3
- package/dist/core/events/v3/live-route-observer.d.ts +31 -0
- package/dist/core/events/v3/live-route-observer.d.ts.map +1 -0
- package/dist/core/events/v3/live-route-observer.js +58 -0
- package/dist/core/events/v3/live-routing.d.ts +42 -20
- package/dist/core/events/v3/live-routing.d.ts.map +1 -1
- package/dist/core/events/v3/live-routing.js +153 -41
- package/dist/core/events/v3/producers/command-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/command-recorder.js +10 -1
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +11 -1
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/coordination-recorder.js +90 -13
- package/dist/core/events/v3/producers/diagnostic-summaries.d.ts +129 -0
- package/dist/core/events/v3/producers/diagnostic-summaries.d.ts.map +1 -0
- package/dist/core/events/v3/producers/diagnostic-summaries.js +499 -0
- package/dist/core/events/v3/producers/hook-base.d.ts +17 -1
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
- package/dist/core/events/v3/producers/hook-base.js +83 -2
- package/dist/core/events/v3/producers/intake.d.ts +13 -0
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
- package/dist/core/events/v3/producers/intake.js +36 -2
- package/dist/core/events/v3/producers/producer-state-observer.d.ts +8 -0
- package/dist/core/events/v3/producers/producer-state-observer.d.ts.map +1 -0
- package/dist/core/events/v3/producers/producer-state-observer.js +45 -0
- package/dist/core/events/v3/producers/recorder.d.ts +117 -1
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +992 -27
- package/dist/core/events/v3/reader.d.ts +51 -0
- package/dist/core/events/v3/reader.d.ts.map +1 -1
- package/dist/core/events/v3/reader.js +181 -1
- package/dist/core/events/v3/rotation-config.d.ts +9 -0
- package/dist/core/events/v3/rotation-config.d.ts.map +1 -0
- package/dist/core/events/v3/rotation-config.js +91 -0
- package/dist/core/events/v3/runtime-build.d.ts +11 -0
- package/dist/core/events/v3/runtime-build.d.ts.map +1 -0
- package/dist/core/events/v3/runtime-build.js +39 -0
- package/dist/core/events/v3/runtime-identity.d.ts +5 -0
- package/dist/core/events/v3/runtime-identity.d.ts.map +1 -0
- package/dist/core/events/v3/runtime-identity.js +18 -0
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts +52 -0
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts.map +1 -0
- package/dist/core/events/v3/runtime-telemetry-capabilities.js +54 -0
- package/dist/core/events/v3/support-storage/classify.d.ts +46 -0
- package/dist/core/events/v3/support-storage/classify.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/classify.js +149 -0
- package/dist/core/events/v3/support-storage/eligibility.d.ts +29 -0
- package/dist/core/events/v3/support-storage/eligibility.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/eligibility.js +35 -0
- package/dist/core/events/v3/support-storage/index.d.ts +10 -0
- package/dist/core/events/v3/support-storage/index.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/index.js +9 -0
- package/dist/core/events/v3/support-storage/inventory.d.ts +30 -0
- package/dist/core/events/v3/support-storage/inventory.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/inventory.js +94 -0
- package/dist/core/events/v3/support-storage/logical-authority.d.ts +14 -0
- package/dist/core/events/v3/support-storage/logical-authority.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/logical-authority.js +104 -0
- package/dist/core/events/v3/support-storage/maintenance.d.ts +98 -0
- package/dist/core/events/v3/support-storage/maintenance.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/maintenance.js +352 -0
- package/dist/core/events/v3/support-storage/pack-contract.d.ts +59 -0
- package/dist/core/events/v3/support-storage/pack-contract.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/pack-contract.js +249 -0
- package/dist/core/events/v3/support-storage/pack-reader.d.ts +34 -0
- package/dist/core/events/v3/support-storage/pack-reader.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/pack-reader.js +258 -0
- package/dist/core/events/v3/support-storage/pack-writer.d.ts +30 -0
- package/dist/core/events/v3/support-storage/pack-writer.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/pack-writer.js +268 -0
- package/dist/core/events/v3/support-storage/recovery.d.ts +15 -0
- package/dist/core/events/v3/support-storage/recovery.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/recovery.js +22 -0
- package/dist/core/events/v3/turn-telemetry.d.ts +21 -6
- package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -1
- package/dist/core/events/v3/turn-telemetry.js +32 -2
- package/dist/core/events/v3/writer.d.ts +13 -1
- package/dist/core/events/v3/writer.d.ts.map +1 -1
- package/dist/core/events/v3/writer.js +126 -12
- package/dist/core/governor/plan-read.d.ts.map +1 -1
- package/dist/core/governor/plan-read.js +5 -21
- package/dist/core/governor/planning.js +6 -8
- package/dist/core/governor/service-read.d.ts +12 -0
- package/dist/core/governor/service-read.d.ts.map +1 -1
- package/dist/core/governor/service-read.js +266 -2
- package/dist/core/governor/service.d.ts +1 -0
- package/dist/core/governor/service.d.ts.map +1 -1
- package/dist/core/governor/service.js +53 -18
- package/dist/core/guard/evidence-v3.d.ts.map +1 -1
- package/dist/core/guard/evidence-v3.js +2 -0
- package/dist/core/hooks/adapter/events.d.ts.map +1 -1
- package/dist/core/hooks/adapter/events.js +1 -0
- package/dist/core/hooks/adapter/output.d.ts +4 -2
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +13 -5
- package/dist/core/hooks/adapter/parse.d.ts +3 -0
- package/dist/core/hooks/adapter/parse.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.js +14 -0
- package/dist/core/hooks/adapter/runtime-telemetry.d.ts +142 -0
- package/dist/core/hooks/adapter/runtime-telemetry.d.ts.map +1 -0
- package/dist/core/hooks/adapter/runtime-telemetry.js +869 -0
- package/dist/core/hooks/cli.js +318 -61
- package/dist/core/hooks/effects/image-capture.d.ts +1 -1
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +4 -2
- package/dist/core/hooks/remediation-cap.d.ts +39 -0
- package/dist/core/hooks/remediation-cap.d.ts.map +1 -0
- package/dist/core/hooks/remediation-cap.js +63 -0
- package/dist/core/hooks/resolve/coord-root.d.ts +22 -9
- package/dist/core/hooks/resolve/coord-root.d.ts.map +1 -1
- package/dist/core/hooks/resolve/coord-root.js +92 -11
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +5 -0
- package/dist/core/hooks/resolve/transcript.d.ts +33 -9
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +33 -10
- package/dist/core/inbox/contract.d.ts +64 -0
- package/dist/core/inbox/contract.d.ts.map +1 -0
- package/dist/core/inbox/contract.js +13 -0
- package/dist/core/inbox/index.d.ts +5 -0
- package/dist/core/inbox/index.d.ts.map +1 -0
- package/dist/core/inbox/index.js +4 -0
- package/dist/core/inbox/lifecycle.d.ts +22 -0
- package/dist/core/inbox/lifecycle.d.ts.map +1 -0
- package/dist/core/inbox/lifecycle.js +41 -0
- package/dist/core/inbox/service.d.ts +36 -0
- package/dist/core/inbox/service.d.ts.map +1 -0
- package/dist/core/inbox/service.js +210 -0
- package/dist/core/inbox/watcher.d.ts +7 -0
- package/dist/core/inbox/watcher.d.ts.map +1 -0
- package/dist/core/inbox/watcher.js +26 -0
- package/dist/core/presence/codec-digest.d.ts.map +1 -1
- package/dist/core/presence/codec-digest.js +14 -3
- package/dist/core/presence/relay-client.d.ts +1 -0
- package/dist/core/presence/relay-client.d.ts.map +1 -1
- package/dist/core/presence/relay-client.js +52 -8
- package/dist/core/semantic/adapters.d.ts +37 -0
- package/dist/core/semantic/adapters.d.ts.map +1 -0
- package/dist/core/semantic/adapters.js +360 -0
- package/dist/core/semantic/contract.d.ts +1072 -0
- package/dist/core/semantic/contract.d.ts.map +1 -0
- package/dist/core/semantic/contract.js +331 -0
- package/dist/core/semantic/evidence.d.ts +11 -0
- package/dist/core/semantic/evidence.d.ts.map +1 -0
- package/dist/core/semantic/evidence.js +262 -0
- package/dist/core/semantic/index.d.ts +14 -0
- package/dist/core/semantic/index.d.ts.map +1 -0
- package/dist/core/semantic/index.js +13 -0
- package/dist/core/semantic/once.d.ts +38 -0
- package/dist/core/semantic/once.d.ts.map +1 -0
- package/dist/core/semantic/once.js +364 -0
- package/dist/core/semantic/prompt.d.ts +12 -0
- package/dist/core/semantic/prompt.d.ts.map +1 -0
- package/dist/core/semantic/prompt.js +83 -0
- package/dist/core/semantic/review.d.ts +144 -0
- package/dist/core/semantic/review.d.ts.map +1 -0
- package/dist/core/semantic/review.js +544 -0
- package/dist/core/semantic/routes.d.ts +10 -0
- package/dist/core/semantic/routes.d.ts.map +1 -0
- package/dist/core/semantic/routes.js +21 -0
- package/dist/core/semantic/scheduler.d.ts +27 -0
- package/dist/core/semantic/scheduler.d.ts.map +1 -0
- package/dist/core/semantic/scheduler.js +91 -0
- package/dist/core/semantic/service-status.d.ts +51 -0
- package/dist/core/semantic/service-status.d.ts.map +1 -0
- package/dist/core/semantic/service-status.js +140 -0
- package/dist/core/semantic/service.d.ts +52 -0
- package/dist/core/semantic/service.d.ts.map +1 -0
- package/dist/core/semantic/service.js +559 -0
- package/dist/core/semantic/soak.d.ts +75 -0
- package/dist/core/semantic/soak.d.ts.map +1 -0
- package/dist/core/semantic/soak.js +476 -0
- package/dist/core/semantic/storage.d.ts +81 -0
- package/dist/core/semantic/storage.d.ts.map +1 -0
- package/dist/core/semantic/storage.js +180 -0
- package/dist/core/semantic/usage.d.ts +43 -0
- package/dist/core/semantic/usage.d.ts.map +1 -0
- package/dist/core/semantic/usage.js +193 -0
- package/dist/core/semantic/validate.d.ts +18 -0
- package/dist/core/semantic/validate.d.ts.map +1 -0
- package/dist/core/semantic/validate.js +207 -0
- package/dist/core/storage/buffer.d.ts +28 -0
- package/dist/core/storage/buffer.d.ts.map +1 -0
- package/dist/core/storage/buffer.js +101 -0
- package/dist/core/storage/builtins.d.ts +3 -0
- package/dist/core/storage/builtins.d.ts.map +1 -0
- package/dist/core/storage/builtins.js +683 -0
- package/dist/core/storage/catalog.d.ts +19 -0
- package/dist/core/storage/catalog.d.ts.map +1 -0
- package/dist/core/storage/catalog.js +365 -0
- package/dist/core/storage/config.d.ts +16 -0
- package/dist/core/storage/config.d.ts.map +1 -0
- package/dist/core/storage/config.js +311 -0
- package/dist/core/storage/contract.d.ts +275 -0
- package/dist/core/storage/contract.d.ts.map +1 -0
- package/dist/core/storage/contract.js +3 -0
- package/dist/core/storage/durable-history.d.ts +36 -0
- package/dist/core/storage/durable-history.d.ts.map +1 -0
- package/dist/core/storage/durable-history.js +606 -0
- package/dist/core/storage/health.d.ts +4 -0
- package/dist/core/storage/health.d.ts.map +1 -0
- package/dist/core/storage/health.js +65 -0
- package/dist/core/storage/index.d.ts +16 -0
- package/dist/core/storage/index.d.ts.map +1 -0
- package/dist/core/storage/index.js +15 -0
- package/dist/core/storage/inventory.d.ts +25 -0
- package/dist/core/storage/inventory.d.ts.map +1 -0
- package/dist/core/storage/inventory.js +666 -0
- package/dist/core/storage/jsonl.d.ts +52 -0
- package/dist/core/storage/jsonl.d.ts.map +1 -0
- package/dist/core/storage/jsonl.js +156 -0
- package/dist/core/storage/log-retention.d.ts +52 -0
- package/dist/core/storage/log-retention.d.ts.map +1 -0
- package/dist/core/storage/log-retention.js +419 -0
- package/dist/core/storage/logger.d.ts +82 -0
- package/dist/core/storage/logger.d.ts.map +1 -0
- package/dist/core/storage/logger.js +411 -0
- package/dist/core/storage/maintenance-providers.d.ts +26 -0
- package/dist/core/storage/maintenance-providers.d.ts.map +1 -0
- package/dist/core/storage/maintenance-providers.js +141 -0
- package/dist/core/storage/maintenance.d.ts +125 -0
- package/dist/core/storage/maintenance.d.ts.map +1 -0
- package/dist/core/storage/maintenance.js +609 -0
- package/dist/core/storage/metrics.d.ts +60 -0
- package/dist/core/storage/metrics.d.ts.map +1 -0
- package/dist/core/storage/metrics.js +134 -0
- package/dist/core/storage/policy.d.ts +7 -0
- package/dist/core/storage/policy.d.ts.map +1 -0
- package/dist/core/storage/policy.js +110 -0
- package/dist/core/storage/process-log.d.ts +38 -0
- package/dist/core/storage/process-log.d.ts.map +1 -0
- package/dist/core/storage/process-log.js +165 -0
- package/dist/core/storage/query.d.ts +34 -0
- package/dist/core/storage/query.d.ts.map +1 -0
- package/dist/core/storage/query.js +295 -0
- package/dist/core/storage/receipts.d.ts +23 -0
- package/dist/core/storage/receipts.d.ts.map +1 -0
- package/dist/core/storage/receipts.js +117 -0
- package/dist/core/storage/segments.d.ts +84 -0
- package/dist/core/storage/segments.d.ts.map +1 -0
- package/dist/core/storage/segments.js +542 -0
- package/dist/core/storage/sink-graph.d.ts +65 -0
- package/dist/core/storage/sink-graph.d.ts.map +1 -0
- package/dist/core/storage/sink-graph.js +213 -0
- package/dist/core/storage/storm-control.d.ts +23 -0
- package/dist/core/storage/storm-control.d.ts.map +1 -0
- package/dist/core/storage/storm-control.js +59 -0
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +10 -14
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/lazy-commands.d.ts +26 -0
- package/dist/lazy-commands.d.ts.map +1 -0
- package/dist/lazy-commands.js +210 -0
- package/dist/lib/browser/client.d.ts +11 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +13 -0
- package/dist/lib/browser/index.d.ts +1 -0
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/standalone-html.d.ts +25 -0
- package/dist/lib/browser/standalone-html.d.ts.map +1 -0
- package/dist/lib/browser/standalone-html.js +284 -0
- package/dist/lib/docs-lint.d.ts +2 -0
- package/dist/lib/docs-lint.d.ts.map +1 -1
- package/dist/lib/docs-lint.js +45 -80
- package/dist/lib/docs-metadata-audit.d.ts +3 -0
- package/dist/lib/docs-metadata-audit.d.ts.map +1 -1
- package/dist/lib/docs-metadata-audit.js +13 -23
- package/dist/lib/docs-metadata-sync.d.ts +1 -0
- package/dist/lib/docs-metadata-sync.d.ts.map +1 -1
- package/dist/lib/docs-metadata-sync.js +28 -10
- package/dist/lib/docs-repository-view.d.ts +22 -0
- package/dist/lib/docs-repository-view.d.ts.map +1 -0
- package/dist/lib/docs-repository-view.js +185 -0
- package/dist/lib/http/client.d.ts +11 -5
- package/dist/lib/http/client.d.ts.map +1 -1
- package/dist/lib/http/client.js +22 -4
- package/dist/lib/http/index.d.ts +1 -1
- package/dist/lib/http/index.d.ts.map +1 -1
- package/dist/lib/http/index.js +1 -1
- package/dist/lib/indexer-exclusions.d.ts +27 -0
- package/dist/lib/indexer-exclusions.d.ts.map +1 -0
- package/dist/lib/indexer-exclusions.js +176 -0
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +1 -0
- package/dist/lib/instructions/templates.d.ts +2 -0
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +149 -4
- package/dist/lib/local-file-url.d.ts +9 -0
- package/dist/lib/local-file-url.d.ts.map +1 -0
- package/dist/lib/local-file-url.js +20 -0
- package/dist/lib/web-performance.d.ts +118 -0
- package/dist/lib/web-performance.d.ts.map +1 -0
- package/dist/lib/web-performance.js +192 -0
- package/package.json +34 -2
- package/schemas/config.schema.json +58 -0
- package/schemas/event-v3.schema.json +3073 -581
- package/src/commander.ts +462 -93
- package/src/commands/agents.ts +617 -355
- package/src/commands/backup.ts +18 -14
- package/src/commands/browse-session.ts +12 -0
- package/src/commands/browse.ts +31 -9
- package/src/commands/conversations.ts +279 -0
- package/src/commands/decision.ts +8 -2
- package/src/commands/deinit.ts +6 -0
- package/src/commands/docs.ts +25 -6
- package/src/commands/doctor.ts +75 -9
- package/src/commands/events.ts +21 -1
- package/src/commands/fetch.ts +7 -6
- package/src/commands/files.ts +143 -0
- package/src/commands/governor.ts +13 -12
- package/src/commands/inbox.ts +61 -0
- package/src/commands/init.ts +78 -16
- package/src/commands/ledger-v3.ts +421 -1
- package/src/commands/logs.ts +224 -0
- package/src/commands/messages.ts +61 -0
- package/src/commands/outline.ts +6 -2
- package/src/commands/presence.ts +7 -2
- package/src/commands/read.ts +6 -2
- package/src/commands/semantic.ts +244 -0
- package/src/commands/storage.ts +310 -0
- package/src/commands/tunnel.ts +66 -52
- package/src/commands/web.ts +92 -7
- package/src/commands/work.ts +3 -3
- package/src/commands/workflow.ts +13 -13
- package/src/core/agents/canonical-emit.ts +15 -0
- package/src/core/agents/claim-path.ts +23 -0
- package/src/core/agents/cli.ts +259 -53
- package/src/core/agents/coord-client.ts +92 -8
- package/src/core/agents/live-authority-v3.ts +342 -14
- package/src/core/agents/live-lifecycle-v3.ts +14 -4
- package/src/core/agents/live-observation-v3.ts +13 -3
- package/src/core/agents/render/prompt-context.ts +40 -16
- package/src/core/agents/rules/stop-hook.ts +129 -25
- package/src/core/agents/rules/verdict.ts +1 -0
- package/src/core/agents/session-events.ts +4 -0
- package/src/core/agents/session-finalization-state-v3.ts +1 -1
- package/src/core/agents/session-finalizer-v3.ts +4 -1
- package/src/core/agents/session-name-display.ts +9 -1
- package/src/core/agents/state/activity-log.ts +7 -2
- package/src/core/agents/state/heartbeat-reader.ts +69 -0
- package/src/core/agents/state/heartbeat-writer.ts +47 -84
- package/src/core/agents/state/live-coordination-view.ts +17 -81
- package/src/core/agents/state/live-coordination-writer.ts +141 -0
- package/src/core/agents/state/names.ts +190 -182
- package/src/core/agents/state/stale-sweep.ts +25 -5
- package/src/core/artifacts/constants.ts +4 -0
- package/src/core/artifacts/index.ts +113 -8
- package/src/core/config.ts +126 -5
- package/src/core/conversations/archive.ts +237 -0
- package/src/core/conversations/catalog.ts +79 -0
- package/src/core/conversations/context-pack.ts +72 -0
- package/src/core/conversations/contract.ts +178 -0
- package/src/core/conversations/evaluation.ts +30 -0
- package/src/core/conversations/index.ts +9 -0
- package/src/core/conversations/lifecycle.ts +63 -0
- package/src/core/conversations/normalize.ts +105 -0
- package/src/core/conversations/query.ts +318 -0
- package/src/core/conversations/search-index.ts +48 -0
- package/src/core/events/legacy-storage/canary.ts +177 -0
- package/src/core/events/legacy-storage/fence.ts +129 -0
- package/src/core/events/legacy-storage/index.ts +5 -0
- package/src/core/events/legacy-storage/inventory.ts +51 -0
- package/src/core/events/legacy-storage/manifest.ts +136 -0
- package/src/core/events/legacy-storage/reader.ts +178 -0
- package/src/core/events/v3/authority-outbox.ts +22 -1
- package/src/core/events/v3/base-contract.ts +56 -7
- package/src/core/events/v3/bootstrap.ts +195 -2
- package/src/core/events/v3/capabilities.ts +37 -3
- package/src/core/events/v3/control-witness.ts +339 -0
- package/src/core/events/v3/control-writer.ts +16 -0
- package/src/core/events/v3/control.ts +54 -18
- package/src/core/events/v3/coordination-transaction-recovery.ts +477 -0
- package/src/core/events/v3/coordination-view.ts +17 -1
- package/src/core/events/v3/generated.ts +1 -1
- package/src/core/events/v3/index.ts +26 -2
- package/src/core/events/v3/latency.ts +213 -2
- package/src/core/events/v3/live-route-observer.ts +80 -0
- package/src/core/events/v3/live-routing.ts +182 -45
- package/src/core/events/v3/producers/command-recorder.ts +10 -1
- package/src/core/events/v3/producers/coordination-recorder.ts +112 -15
- package/src/core/events/v3/producers/diagnostic-summaries.ts +593 -0
- package/src/core/events/v3/producers/hook-base.ts +116 -2
- package/src/core/events/v3/producers/intake.ts +48 -2
- package/src/core/events/v3/producers/producer-state-observer.ts +52 -0
- package/src/core/events/v3/producers/recorder.ts +1403 -30
- package/src/core/events/v3/reader.ts +243 -2
- package/src/core/events/v3/rotation-config.ts +98 -0
- package/src/core/events/v3/runtime-build.ts +41 -0
- package/src/core/events/v3/runtime-identity.ts +16 -0
- package/src/core/events/v3/runtime-telemetry-capabilities.ts +143 -0
- package/src/core/events/v3/support-storage/classify.ts +209 -0
- package/src/core/events/v3/support-storage/eligibility.ts +58 -0
- package/src/core/events/v3/support-storage/index.ts +9 -0
- package/src/core/events/v3/support-storage/inventory.ts +135 -0
- package/src/core/events/v3/support-storage/logical-authority.ts +117 -0
- package/src/core/events/v3/support-storage/maintenance.ts +501 -0
- package/src/core/events/v3/support-storage/pack-contract.ts +337 -0
- package/src/core/events/v3/support-storage/pack-reader.ts +346 -0
- package/src/core/events/v3/support-storage/pack-writer.ts +352 -0
- package/src/core/events/v3/support-storage/recovery.ts +43 -0
- package/src/core/events/v3/turn-telemetry.ts +66 -5
- package/src/core/events/v3/writer.ts +168 -16
- package/src/core/governor/plan-read.ts +5 -18
- package/src/core/governor/planning.ts +5 -8
- package/src/core/governor/service-read.ts +320 -2
- package/src/core/governor/service.ts +49 -22
- package/src/core/guard/evidence-v3.ts +1 -0
- package/src/core/hooks/adapter/events.ts +1 -0
- package/src/core/hooks/adapter/output.ts +12 -5
- package/src/core/hooks/adapter/parse.ts +16 -0
- package/src/core/hooks/adapter/runtime-telemetry.ts +1200 -0
- package/src/core/hooks/cli.ts +342 -64
- package/src/core/hooks/effects/image-capture.ts +4 -1
- package/src/core/hooks/remediation-cap.ts +83 -0
- package/src/core/hooks/resolve/coord-root.ts +91 -11
- package/src/core/hooks/resolve/owner.ts +4 -0
- package/src/core/hooks/resolve/transcript.ts +55 -11
- package/src/core/inbox/contract.ts +81 -0
- package/src/core/inbox/index.ts +4 -0
- package/src/core/inbox/lifecycle.ts +104 -0
- package/src/core/inbox/service.ts +305 -0
- package/src/core/inbox/watcher.ts +36 -0
- package/src/core/presence/codec-digest.ts +15 -9
- package/src/core/presence/relay-client.ts +55 -7
- package/src/core/semantic/adapters.ts +452 -0
- package/src/core/semantic/contract.ts +430 -0
- package/src/core/semantic/evidence.ts +336 -0
- package/src/core/semantic/index.ts +201 -0
- package/src/core/semantic/once.ts +496 -0
- package/src/core/semantic/prompt.ts +96 -0
- package/src/core/semantic/review.ts +803 -0
- package/src/core/semantic/routes.ts +30 -0
- package/src/core/semantic/scheduler.ts +151 -0
- package/src/core/semantic/service-status.ts +212 -0
- package/src/core/semantic/service.ts +681 -0
- package/src/core/semantic/soak.ts +638 -0
- package/src/core/semantic/storage.ts +300 -0
- package/src/core/semantic/usage.ts +272 -0
- package/src/core/semantic/validate.ts +243 -0
- package/src/core/storage/buffer.ts +124 -0
- package/src/core/storage/builtins.ts +916 -0
- package/src/core/storage/catalog.ts +467 -0
- package/src/core/storage/config.ts +423 -0
- package/src/core/storage/contract.ts +342 -0
- package/src/core/storage/durable-history.ts +738 -0
- package/src/core/storage/health.ts +76 -0
- package/src/core/storage/index.ts +15 -0
- package/src/core/storage/inventory.ts +859 -0
- package/src/core/storage/jsonl.ts +213 -0
- package/src/core/storage/log-retention.ts +555 -0
- package/src/core/storage/logger.ts +546 -0
- package/src/core/storage/maintenance-providers.ts +200 -0
- package/src/core/storage/maintenance.ts +929 -0
- package/src/core/storage/metrics.ts +199 -0
- package/src/core/storage/policy.ts +141 -0
- package/src/core/storage/process-log.ts +203 -0
- package/src/core/storage/query.ts +360 -0
- package/src/core/storage/receipts.ts +162 -0
- package/src/core/storage/segments.ts +721 -0
- package/src/core/storage/sink-graph.ts +343 -0
- package/src/core/storage/storm-control.ts +91 -0
- package/src/core/work/state.ts +12 -21
- package/src/core/workflow/live-session-v3.ts +2 -4
- package/src/index.ts +2 -0
- package/src/lazy-commands.ts +294 -0
- package/src/lib/browser/client.ts +21 -0
- package/src/lib/browser/index.ts +4 -0
- package/src/lib/browser/standalone-html.ts +312 -0
- package/src/lib/docs-lint.ts +58 -77
- package/src/lib/docs-metadata-audit.ts +26 -21
- package/src/lib/docs-metadata-sync.ts +32 -9
- package/src/lib/docs-repository-view.ts +220 -0
- package/src/lib/http/client.ts +44 -8
- package/src/lib/http/index.ts +6 -1
- package/src/lib/indexer-exclusions.ts +173 -0
- package/src/lib/instructions/apply.ts +1 -0
- package/src/lib/instructions/templates.ts +154 -4
- package/src/lib/local-file-url.ts +31 -0
- package/src/lib/web-performance.ts +335 -0
package/src/core/hooks/cli.ts
CHANGED
|
@@ -17,29 +17,34 @@
|
|
|
17
17
|
* adapter flow.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { spawnSync } from "node:child_process";
|
|
20
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
21
21
|
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
22
22
|
import { dirname, join } from "node:path";
|
|
23
23
|
import { coordEnv } from "../../lib/env.ts";
|
|
24
24
|
import { buildInstructionBundle } from "../../lib/instructions/bundle.ts";
|
|
25
25
|
import type { Adapter } from "../adapter.ts";
|
|
26
26
|
import { coordBinPath } from "../agents/coord-bin.ts";
|
|
27
|
+
import { resolveCoordRoot } from "../agents/coord-client.ts";
|
|
27
28
|
import {
|
|
28
29
|
type ClaimFinalizationDecision,
|
|
29
30
|
type ClaimFinalizationDescriptor,
|
|
30
31
|
classifyWriteClaimFinalization,
|
|
31
32
|
formatWriteClaimFinalizationDenial,
|
|
32
33
|
} from "../agents/finalization.ts";
|
|
34
|
+
import { restoreLiveCoordinationStateAfterEpochV3 } from "../agents/live-authority-v3.ts";
|
|
33
35
|
import { evaluateStopHook, STOP_REMEDIATION_MARKER } from "../agents/rules/stop-hook.ts";
|
|
34
36
|
import {
|
|
35
37
|
assistantTextStartsWithSessionNameBlock,
|
|
36
38
|
isSessionNameRemediationCommand,
|
|
37
39
|
sessionNameDisplayInstruction,
|
|
38
40
|
sessionNameDisplayPending,
|
|
41
|
+
sessionNameDisplayRecoveryInstruction,
|
|
39
42
|
toolResponseMintedSessionName,
|
|
40
43
|
} from "../agents/session-name-display.ts";
|
|
41
|
-
import {
|
|
44
|
+
import type { Heartbeat } from "../agents/state/heartbeat-reader.ts";
|
|
45
|
+
import { readHeartbeat, stampSessionNameSeen } from "../agents/state/heartbeat-writer.ts";
|
|
42
46
|
import { readLiveCoordinationRow } from "../agents/state/live-coordination-view.ts";
|
|
47
|
+
import { ensureLiveCoordinationHeartbeat } from "../agents/state/live-coordination-writer.ts";
|
|
43
48
|
import { writePidmapRow } from "../agents/state/pidmap.ts";
|
|
44
49
|
import { agentsRequireGitFinalization, resolveBinName } from "../config.ts";
|
|
45
50
|
import {
|
|
@@ -54,11 +59,15 @@ import {
|
|
|
54
59
|
} from "../context/index.ts";
|
|
55
60
|
import { tryWriteLiveDisplayV3 } from "../events/v3/live-feed.ts";
|
|
56
61
|
import {
|
|
62
|
+
liveHookSignalDefersDrainV3,
|
|
63
|
+
reconcileLivePendingRuntimeContextV3,
|
|
64
|
+
recordLiveDelegatedChildSessionV3,
|
|
57
65
|
recordLiveHookSignalV3,
|
|
58
66
|
resolveLiveEventLedgerRouteV3,
|
|
59
67
|
} from "../events/v3/live-routing.ts";
|
|
60
68
|
import { captureSpanClockV3 } from "../events/v3/span-state.ts";
|
|
61
|
-
import { fetchPresence } from "../presence/index.ts";
|
|
69
|
+
import { ensureRelayDaemon, fetchPresence, publishPresence } from "../presence/index.ts";
|
|
70
|
+
import { closeProcessLoggers, legacyLogFields, processLogger } from "../storage/logger.ts";
|
|
62
71
|
import { stableScopeId } from "../workflow/scope-id.ts";
|
|
63
72
|
import { detectAdapter, shouldSkipHookAdapter } from "./adapter/detect.ts";
|
|
64
73
|
import {
|
|
@@ -69,6 +78,7 @@ import {
|
|
|
69
78
|
type ParsedPayload,
|
|
70
79
|
parsePayload,
|
|
71
80
|
} from "./adapter/parse.ts";
|
|
81
|
+
import { discoverCodexSessionTranscript } from "./adapter/runtime-telemetry.ts";
|
|
72
82
|
import {
|
|
73
83
|
codexWslFileLinkTelemetry,
|
|
74
84
|
inspectCodexWslBridge,
|
|
@@ -91,15 +101,14 @@ import {
|
|
|
91
101
|
import { toolInputHash, toolTargetHash } from "./events/input-hash.ts";
|
|
92
102
|
import { canonicalize } from "./guard-path.ts";
|
|
93
103
|
import { adapterPidFromEnv, parsePsChainLine, selectAnchorPid } from "./resolve/anchor.ts";
|
|
94
|
-
import { findCoordRoot } from "./resolve/coord-root.ts";
|
|
95
104
|
import { extractIntentComment, resolveIntent } from "./resolve/intent.ts";
|
|
96
105
|
import { resolveOwner } from "./resolve/owner.ts";
|
|
97
106
|
import {
|
|
98
107
|
inspectSessionNameDisplayImmediately,
|
|
99
|
-
|
|
108
|
+
scanAssistantStatusBoxPresent,
|
|
100
109
|
scanSessionNameDisplayedImmediately,
|
|
101
110
|
scanStatusBoxPresent,
|
|
102
|
-
|
|
111
|
+
scanTranscriptRuntime,
|
|
103
112
|
} from "./resolve/transcript.ts";
|
|
104
113
|
import { sessionNamePresence } from "./session-name-presence.ts";
|
|
105
114
|
import { unsafeCrossShellReason } from "./unsafe-cross-shell.ts";
|
|
@@ -127,6 +136,11 @@ function parseArgv(argv: string[]): Argv {
|
|
|
127
136
|
return out;
|
|
128
137
|
}
|
|
129
138
|
|
|
139
|
+
function extraArg(extra: string[], name: string): string | undefined {
|
|
140
|
+
const index = extra.indexOf(name);
|
|
141
|
+
return index >= 0 ? extra[index + 1] : undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
130
144
|
async function readStdin(): Promise<string> {
|
|
131
145
|
if (process.stdin.isTTY) return "";
|
|
132
146
|
try {
|
|
@@ -152,6 +166,14 @@ function childEnv(coordRoot: string): NodeJS.ProcessEnv {
|
|
|
152
166
|
}
|
|
153
167
|
|
|
154
168
|
function appendDebug(coordRoot: string, entry: Record<string, unknown>): void {
|
|
169
|
+
if (coordEnv("SHARED_LOGS") !== "0") {
|
|
170
|
+
try {
|
|
171
|
+
processLogger(coordRoot, "agent-hook").debug("agent_hook.diagnostic", legacyLogFields(entry));
|
|
172
|
+
return;
|
|
173
|
+
} catch {
|
|
174
|
+
/* fall through to the rollback writer */
|
|
175
|
+
}
|
|
176
|
+
}
|
|
155
177
|
const path = join(coordRoot, ".harnery", "debug", "agent-hook.ndjson");
|
|
156
178
|
try {
|
|
157
179
|
mkdirSync(dirname(path), { recursive: true });
|
|
@@ -163,6 +185,18 @@ function appendDebug(coordRoot: string, entry: Record<string, unknown>): void {
|
|
|
163
185
|
|
|
164
186
|
function logError(coordRoot: string | null, err: unknown, context: Record<string, unknown>): void {
|
|
165
187
|
if (!coordRoot) return;
|
|
188
|
+
if (coordEnv("SHARED_LOGS") !== "0") {
|
|
189
|
+
try {
|
|
190
|
+
processLogger(coordRoot, "agent-hook").error(
|
|
191
|
+
"agent_hook.error",
|
|
192
|
+
legacyLogFields(context),
|
|
193
|
+
err,
|
|
194
|
+
);
|
|
195
|
+
return;
|
|
196
|
+
} catch {
|
|
197
|
+
/* fall through to the rollback writer */
|
|
198
|
+
}
|
|
199
|
+
}
|
|
166
200
|
const path = join(coordRoot, ".harnery", "debug", "agent-hook.errors.ndjson");
|
|
167
201
|
try {
|
|
168
202
|
mkdirSync(dirname(path), { recursive: true });
|
|
@@ -312,7 +346,7 @@ function buildEventData(
|
|
|
312
346
|
// Claude Code's SessionStart payload omits `model` (Codex + Cursor
|
|
313
347
|
// supply it). Fall back to the transcript, populated on `resume`, and
|
|
314
348
|
// backfilled later by `turn.completed` for a fresh startup session.
|
|
315
|
-
model: p?.model ??
|
|
349
|
+
model: p?.model ?? scanTranscriptRuntime(p?.transcript_path)?.model,
|
|
316
350
|
pid: adapterPid,
|
|
317
351
|
source: p?.source,
|
|
318
352
|
platform: adapterPlatform,
|
|
@@ -379,7 +413,7 @@ function buildEventData(
|
|
|
379
413
|
// Backfill the model for adapters that omit it at session.started
|
|
380
414
|
// (Claude Code). The transcript is populated with assistant turns by
|
|
381
415
|
// Stop-hook time, so this resolves even for fresh `startup` sessions.
|
|
382
|
-
model: p?.model ??
|
|
416
|
+
model: p?.model ?? scanTranscriptRuntime(p?.transcript_path)?.model,
|
|
383
417
|
// Phase 2: tool_call_count + text_length aren't cheaply available
|
|
384
418
|
// from the Stop payload alone (they'd require a transcript scan that
|
|
385
419
|
// races with the JSONL flush). Emit `-1` / `0` sentinels and let
|
|
@@ -394,25 +428,29 @@ function buildEventData(
|
|
|
394
428
|
// (the previous path passed those via the no-history fail-open).
|
|
395
429
|
status_box_present:
|
|
396
430
|
scanStatusBoxPresent(p?.transcript_path) || lastAssistantMessage.includes("┌─ agent-"),
|
|
397
|
-
//
|
|
431
|
+
// Assistant-text evidence for the rule-2/3 detector: the loose scan above
|
|
398
432
|
// matches the box prefix ANYWHERE in the transcript tail, including
|
|
399
433
|
// the tool_result row the status command itself writes, so it can
|
|
400
434
|
// report a paste that never happened. The strict variant counts
|
|
401
435
|
// assistant text only (same window, same scanner as the session-name
|
|
402
|
-
// detection).
|
|
403
|
-
//
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
lastAssistantMessage.includes("┌─ agent-"),
|
|
436
|
+
// detection). The Stop verdict enforces this field; the loose field is
|
|
437
|
+
// retained as diagnostic telemetry for the measured detector divergence.
|
|
438
|
+
status_box_present_strict: scanAssistantStatusBoxPresent(
|
|
439
|
+
p?.transcript_path,
|
|
440
|
+
lastAssistantMessage,
|
|
441
|
+
),
|
|
409
442
|
// Whether the session's suggested name is satisfied as of this turn,
|
|
410
443
|
// and which name that refers to. Reported on every stop while a name
|
|
411
444
|
// exists (the stop-hook.session_name verdict reads it per turn); the
|
|
412
445
|
// transcript scan itself stops once the name has been sighted.
|
|
413
446
|
...sessionNamePresence(ctx.coordRoot, ctx.instanceId, (name) =>
|
|
414
447
|
scanSessionNameDisplayedImmediately(
|
|
415
|
-
|
|
448
|
+
// Codex stops carry no transcript_path; discover the rollout by
|
|
449
|
+
// session id so the naming ritual can verify and stamp there too.
|
|
450
|
+
p?.transcript_path ??
|
|
451
|
+
(ctx.adapter === "codex"
|
|
452
|
+
? discoverCodexSessionTranscript(p?.session_id ?? ctx.instanceId)
|
|
453
|
+
: undefined),
|
|
416
454
|
name,
|
|
417
455
|
assistantTextStartsWithSessionNameBlock,
|
|
418
456
|
),
|
|
@@ -428,7 +466,8 @@ function buildEventData(
|
|
|
428
466
|
// Subagents inherit parent's name via the resolve-name session_id path
|
|
429
467
|
// (agent-coord/state/names.ts → kind=transient). Use the call ID as the
|
|
430
468
|
// instance_id input; assignName falls through to transient.
|
|
431
|
-
const
|
|
469
|
+
const childInstanceId = subagentCallId ?? ctx.instanceId;
|
|
470
|
+
const assigned = assignNameViaAgentCoord(ctx.coordRoot, childInstanceId, "subagent");
|
|
432
471
|
return {
|
|
433
472
|
agent_type:
|
|
434
473
|
(p?.raw.agent_type as string | undefined) ??
|
|
@@ -437,7 +476,7 @@ function buildEventData(
|
|
|
437
476
|
prompt_summary: p?.raw.prompt_summary as string | undefined,
|
|
438
477
|
name: assigned?.name,
|
|
439
478
|
kind: "subagent",
|
|
440
|
-
agent_id:
|
|
479
|
+
agent_id: childInstanceId,
|
|
441
480
|
subagent_call_id: subagentCallId,
|
|
442
481
|
parent_session_id: p?.parent_session_id,
|
|
443
482
|
};
|
|
@@ -571,7 +610,7 @@ async function main(): Promise<number> {
|
|
|
571
610
|
// `--adapter cursor` dispatch of the same payload carries the session.
|
|
572
611
|
if (shouldSkipHookAdapter(adapter, raw)) {
|
|
573
612
|
if (coordEnv("AGENT_COORD_OFF") !== "1") {
|
|
574
|
-
const coordRoot =
|
|
613
|
+
const coordRoot = resolveCoordRoot(process.cwd());
|
|
575
614
|
if (coordRoot) {
|
|
576
615
|
appendDebug(coordRoot, {
|
|
577
616
|
ts: new Date().toISOString(),
|
|
@@ -596,16 +635,27 @@ async function main(): Promise<number> {
|
|
|
596
635
|
if (adapter === "claude-code" && eventName) {
|
|
597
636
|
const s = soundForEvent(eventName);
|
|
598
637
|
if (s) {
|
|
599
|
-
const repoRoot =
|
|
638
|
+
const repoRoot = resolveCoordRoot(process.cwd());
|
|
600
639
|
if (repoRoot) {
|
|
601
640
|
let sid = "";
|
|
641
|
+
let stopContinuation = false;
|
|
602
642
|
try {
|
|
603
|
-
const j = JSON.parse(raw) as {
|
|
643
|
+
const j = JSON.parse(raw) as {
|
|
644
|
+
session_id?: string;
|
|
645
|
+
conversation_id?: string;
|
|
646
|
+
stop_hook_active?: boolean;
|
|
647
|
+
};
|
|
604
648
|
sid = j.session_id ?? j.conversation_id ?? "";
|
|
649
|
+
// A stop with stop_hook_active is a remediation continuation of a
|
|
650
|
+
// turn that already chimed; replaying the sound on every bounce
|
|
651
|
+
// turns a blocked-stop loop into a repeating alarm.
|
|
652
|
+
stopContinuation = eventName === "stop" && j.stop_hook_active === true;
|
|
605
653
|
} catch {
|
|
606
654
|
// non-JSON payload: play unkeyed (rate-limit just won't dedup)
|
|
607
655
|
}
|
|
608
|
-
|
|
656
|
+
if (!stopContinuation) {
|
|
657
|
+
playSound(repoRoot, s.sound, sid, s.maxPlays);
|
|
658
|
+
}
|
|
609
659
|
}
|
|
610
660
|
}
|
|
611
661
|
}
|
|
@@ -616,8 +666,11 @@ async function main(): Promise<number> {
|
|
|
616
666
|
// bypass during incident triage.
|
|
617
667
|
if (coordEnv("AGENT_COORD_OFF") === "1") return 0;
|
|
618
668
|
|
|
619
|
-
const coordRoot =
|
|
669
|
+
const coordRoot = resolveCoordRoot(process.cwd());
|
|
620
670
|
if (!coordRoot) return 0;
|
|
671
|
+
if (eventName === "runtime-context-retry") {
|
|
672
|
+
return runRuntimeContextRetryWorker(coordRoot, adapter, extra);
|
|
673
|
+
}
|
|
621
674
|
const ledgerRoute = resolveLiveEventLedgerRouteV3(coordRoot);
|
|
622
675
|
|
|
623
676
|
// Always log a breadcrumb, useful when an event_type maps to null or owner
|
|
@@ -639,6 +692,30 @@ async function main(): Promise<number> {
|
|
|
639
692
|
return 0;
|
|
640
693
|
}
|
|
641
694
|
|
|
695
|
+
// Cursor's preToolUse `agent_message` is only the current narration before
|
|
696
|
+
// that tool. It is not a transcript and therefore cannot prove that an
|
|
697
|
+
// earlier assistant response omitted the required session-name block.
|
|
698
|
+
// afterAgentResponse is the one native boundary that carries the completed
|
|
699
|
+
// assistant text, so stamp a positive sighting here without retaining or
|
|
700
|
+
// emitting the response body into V3.
|
|
701
|
+
if (adapter === "cursor" && eventName === "after-agent-response") {
|
|
702
|
+
const payload = parsePayload(raw, adapter);
|
|
703
|
+
const owner = resolveOwner({ payload: payload?.raw ?? null, coordRoot });
|
|
704
|
+
if (!owner) {
|
|
705
|
+
appendDebug(coordRoot, { ...debugBase, skipped: "no-owner-resolved" });
|
|
706
|
+
return 0;
|
|
707
|
+
}
|
|
708
|
+
const name = sessionNameDisplayPending(readLiveCoordinationRow(coordRoot, owner.instance_id));
|
|
709
|
+
const text = typeof payload?.raw.text === "string" ? payload.raw.text : "";
|
|
710
|
+
if (name && assistantTextStartsWithSessionNameBlock(text, name)) {
|
|
711
|
+
stampSessionNameSeen(coordRoot, owner.instance_id, name);
|
|
712
|
+
appendDebug(coordRoot, { ...debugBase, effect: "session-name-display-stamped" });
|
|
713
|
+
} else {
|
|
714
|
+
appendDebug(coordRoot, { ...debugBase, skipped: "no-session-name-sighting" });
|
|
715
|
+
}
|
|
716
|
+
return 0;
|
|
717
|
+
}
|
|
718
|
+
|
|
642
719
|
const norm = normalizeEventName(eventName);
|
|
643
720
|
if (!norm) {
|
|
644
721
|
appendDebug(coordRoot, { ...debugBase, skipped: "non-canonical-event" });
|
|
@@ -660,6 +737,7 @@ async function main(): Promise<number> {
|
|
|
660
737
|
}
|
|
661
738
|
|
|
662
739
|
const sessionId = payload?.session_id ?? payload?.conversation_id ?? owner.instance_id;
|
|
740
|
+
const priorCoordination = readHeartbeat(coordRoot, owner.instance_id);
|
|
663
741
|
|
|
664
742
|
const data = buildEventData(norm.event_type, {
|
|
665
743
|
coordRoot,
|
|
@@ -706,6 +784,10 @@ async function main(): Promise<number> {
|
|
|
706
784
|
}
|
|
707
785
|
}
|
|
708
786
|
|
|
787
|
+
const deferV3Drain = liveHookSignalDefersDrainV3(
|
|
788
|
+
eventName,
|
|
789
|
+
coordEnv("EXPERIMENT_DEFER_V3_DRAIN"),
|
|
790
|
+
);
|
|
709
791
|
const v3Result = recordLiveHookSignalV3({
|
|
710
792
|
coordRoot,
|
|
711
793
|
route: ledgerRoute,
|
|
@@ -728,8 +810,26 @@ async function main(): Promise<number> {
|
|
|
728
810
|
monotonic_ns: hookClock.monotonic_ns,
|
|
729
811
|
...(stopRemediation ? { stop_remediation: true } : {}),
|
|
730
812
|
...(turnRitual ? { turn_ritual: turnRitual } : {}),
|
|
731
|
-
...(
|
|
813
|
+
...(deferV3Drain ? { defer_drain: true } : {}),
|
|
732
814
|
});
|
|
815
|
+
const recordedGenerationId =
|
|
816
|
+
v3Result && "event" in v3Result && "generation_id" in v3Result.event.scope
|
|
817
|
+
? (v3Result.event.scope.generation_id as `gen_${string}`)
|
|
818
|
+
: undefined;
|
|
819
|
+
if (v3Result?.state === "recorded" || v3Result?.state === "already_started") {
|
|
820
|
+
try {
|
|
821
|
+
restoreLiveCoordinationStateAfterEpochV3({
|
|
822
|
+
coordRoot,
|
|
823
|
+
owner: owner.instance_id,
|
|
824
|
+
nativeSessionId: sessionId,
|
|
825
|
+
adapter,
|
|
826
|
+
prior: priorCoordination,
|
|
827
|
+
currentGenerationId: recordedGenerationId,
|
|
828
|
+
});
|
|
829
|
+
} catch (error) {
|
|
830
|
+
logError(coordRoot, error, { phase: "epoch-coordination-restore" });
|
|
831
|
+
}
|
|
832
|
+
}
|
|
733
833
|
const v3EventId =
|
|
734
834
|
v3Result && "event" in v3Result
|
|
735
835
|
? v3Result.event.event_id
|
|
@@ -737,9 +837,39 @@ async function main(): Promise<number> {
|
|
|
737
837
|
? v3Result.event_id
|
|
738
838
|
: undefined;
|
|
739
839
|
|
|
840
|
+
if (
|
|
841
|
+
norm.event_type === "agent.started" &&
|
|
842
|
+
payload &&
|
|
843
|
+
v3Result?.state === "recorded" &&
|
|
844
|
+
v3Result.event.event_type === "agent.started"
|
|
845
|
+
) {
|
|
846
|
+
try {
|
|
847
|
+
const childResult = recordLiveDelegatedChildSessionV3({
|
|
848
|
+
coordRoot,
|
|
849
|
+
route: ledgerRoute,
|
|
850
|
+
parentEvent: v3Result.event,
|
|
851
|
+
payload,
|
|
852
|
+
adapter,
|
|
853
|
+
...(adapter === "codex" && isWslUncPath(payload.cwd)
|
|
854
|
+
? { bridge: "codex-wsl" as const }
|
|
855
|
+
: {}),
|
|
856
|
+
monotonic_ns: hookClock.monotonic_ns,
|
|
857
|
+
});
|
|
858
|
+
const nativeChild = payload.subagent_id ?? payload.agent_id;
|
|
859
|
+
if (
|
|
860
|
+
nativeChild &&
|
|
861
|
+
(childResult.state === "recorded" || childResult.state === "already_started")
|
|
862
|
+
) {
|
|
863
|
+
ensureLiveCoordinationHeartbeat(coordRoot, nativeChild, sessionId, adapter, payload.model);
|
|
864
|
+
}
|
|
865
|
+
} catch (err) {
|
|
866
|
+
logError(coordRoot, err, { phase: "subagent-child-session-start" });
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
740
870
|
if (v3Result?.state === "recorded" && capturedImages.length > 0) {
|
|
741
871
|
try {
|
|
742
|
-
recordImageArtifactsV3(coordRoot, v3Result.event, capturedImages);
|
|
872
|
+
recordImageArtifactsV3(coordRoot, v3Result.event, capturedImages, ledgerRoute.genesis_id);
|
|
743
873
|
} catch (err) {
|
|
744
874
|
logError(coordRoot, err, { phase: "image-artifact-observation" });
|
|
745
875
|
}
|
|
@@ -833,6 +963,36 @@ async function main(): Promise<number> {
|
|
|
833
963
|
// session-start additionalContext inside emitSessionStartSystemMessage.
|
|
834
964
|
if (adapter === "claude-code") journalJanitor(coordRoot);
|
|
835
965
|
imageJanitor(coordRoot);
|
|
966
|
+
// Session start is the only caller of the artifact janitor and the storage
|
|
967
|
+
// maintenance pass, so both load here instead of on every tool call.
|
|
968
|
+
const { autoCleanArtifacts } = await import("../artifacts/index.ts");
|
|
969
|
+
const { createAutomaticMaintenanceComposition, runAutomaticMaintenancePass } = await import(
|
|
970
|
+
"../storage/maintenance-providers.ts"
|
|
971
|
+
);
|
|
972
|
+
// Effect: throttled daily sweep of expired artifact workspaces (guarded,
|
|
973
|
+
// managed-expired only; see autoCleanArtifacts). Best-effort like every
|
|
974
|
+
// janitor here: a failure logs and never blocks session start.
|
|
975
|
+
try {
|
|
976
|
+
autoCleanArtifacts(coordRoot);
|
|
977
|
+
} catch (err) {
|
|
978
|
+
logError(coordRoot, err, { phase: "artifact-auto-clean" });
|
|
979
|
+
}
|
|
980
|
+
// Plan one bounded, claim-first global slice from cached pressure only.
|
|
981
|
+
// Existing owner janitors above remain the only active executors until
|
|
982
|
+
// each provider receives a separate production activation.
|
|
983
|
+
try {
|
|
984
|
+
await runAutomaticMaintenancePass(
|
|
985
|
+
createAutomaticMaintenanceComposition(coordRoot, {
|
|
986
|
+
journal: () => {
|
|
987
|
+
if (adapter === "claude-code") journalJanitor(coordRoot);
|
|
988
|
+
},
|
|
989
|
+
images: () => imageJanitor(coordRoot),
|
|
990
|
+
artifacts: () => autoCleanArtifacts(coordRoot),
|
|
991
|
+
}),
|
|
992
|
+
);
|
|
993
|
+
} catch (err) {
|
|
994
|
+
logError(coordRoot, err, { phase: "storage-maintenance-auto" });
|
|
995
|
+
}
|
|
836
996
|
let recovery: PreparedContextRecovery | null = null;
|
|
837
997
|
if (payload?.source === "compact") {
|
|
838
998
|
try {
|
|
@@ -864,10 +1024,13 @@ async function main(): Promise<number> {
|
|
|
864
1024
|
} catch (err) {
|
|
865
1025
|
logError(coordRoot, err, { phase: "session-start-systemMessage" });
|
|
866
1026
|
}
|
|
867
|
-
//
|
|
868
|
-
// disposable heartbeat cache.
|
|
1027
|
+
// Cross-machine presence is derived from the authority-safe V3 projection,
|
|
1028
|
+
// not the disposable heartbeat cache. Announce this session, pull peers,
|
|
1029
|
+
// and keep the optional live relay connected.
|
|
869
1030
|
try {
|
|
1031
|
+
publishPresence(coordRoot);
|
|
870
1032
|
fetchPresence(coordRoot);
|
|
1033
|
+
ensureRelayDaemon(coordRoot);
|
|
871
1034
|
} catch (err) {
|
|
872
1035
|
logError(coordRoot, err, { phase: "session-start-presence" });
|
|
873
1036
|
}
|
|
@@ -887,13 +1050,21 @@ async function main(): Promise<number> {
|
|
|
887
1050
|
journalArchive(coordRoot, owner.instance_id);
|
|
888
1051
|
runSessionSyncExtension(coordRoot, true);
|
|
889
1052
|
}
|
|
1053
|
+
// Publish the post-cleanup V3 projection so remote machines see this
|
|
1054
|
+
// session disappear without waiting for the stale window.
|
|
1055
|
+
try {
|
|
1056
|
+
publishPresence(coordRoot);
|
|
1057
|
+
} catch (err) {
|
|
1058
|
+
logError(coordRoot, err, { phase: "session-end-presence" });
|
|
1059
|
+
}
|
|
890
1060
|
}
|
|
891
1061
|
|
|
892
|
-
// Phase 8: SubagentStart:
|
|
893
|
-
//
|
|
894
|
-
//
|
|
1062
|
+
// Phase 8: SubagentStart: the child generation was opened above from the
|
|
1063
|
+
// native delegation identity. Refresh its disposable projection, log the
|
|
1064
|
+
// lifecycle event, and emit a context message announcing the subagent.
|
|
895
1065
|
if (norm.event_type === "agent.started") {
|
|
896
1066
|
try {
|
|
1067
|
+
const childInstanceId = (data.agent_id as string | undefined) ?? owner.instance_id;
|
|
897
1068
|
const agentCoordBin = coordBinPath("agent-coord", coordRoot) ?? "";
|
|
898
1069
|
if (existsSync(agentCoordBin)) {
|
|
899
1070
|
spawnSync(agentCoordBin, ["project"], {
|
|
@@ -905,14 +1076,14 @@ async function main(): Promise<number> {
|
|
|
905
1076
|
agentCoordBin,
|
|
906
1077
|
[
|
|
907
1078
|
"log",
|
|
908
|
-
`SUBAGENT_START agent_type=${(data.agent_type as string) ?? "unknown"} agent_id=${
|
|
1079
|
+
`SUBAGENT_START agent_type=${(data.agent_type as string) ?? "unknown"} agent_id=${childInstanceId.slice(0, 8)} platform=${adapterPlatform(adapter)}`,
|
|
909
1080
|
"--instance",
|
|
910
|
-
|
|
1081
|
+
childInstanceId,
|
|
911
1082
|
],
|
|
912
1083
|
{ encoding: "utf8", timeout: 2000, env: childEnv(coordRoot) },
|
|
913
1084
|
);
|
|
914
1085
|
}
|
|
915
|
-
emitSubagentStartContext(coordRoot,
|
|
1086
|
+
emitSubagentStartContext(coordRoot, childInstanceId, sessionId, data, adapter);
|
|
916
1087
|
} catch (err) {
|
|
917
1088
|
logError(coordRoot, err, { phase: "subagent-start-project" });
|
|
918
1089
|
}
|
|
@@ -921,20 +1092,23 @@ async function main(): Promise<number> {
|
|
|
921
1092
|
// Phase 8: SubagentStop: delete subagent heartbeat + log.
|
|
922
1093
|
if (norm.event_type === "agent.completed") {
|
|
923
1094
|
try {
|
|
924
|
-
|
|
1095
|
+
const childInstanceId = payload?.subagent_id ?? payload?.agent_id ?? owner.instance_id;
|
|
1096
|
+
cleanupSessionEnd(coordRoot, childInstanceId, (data.reason as string) ?? "unknown");
|
|
925
1097
|
const agentCoordBin = coordBinPath("agent-coord", coordRoot) ?? "";
|
|
926
1098
|
if (existsSync(agentCoordBin)) {
|
|
927
1099
|
spawnSync(
|
|
928
1100
|
agentCoordBin,
|
|
929
1101
|
[
|
|
930
1102
|
"log",
|
|
931
|
-
`SUBAGENT_STOP agent_id=${
|
|
1103
|
+
`SUBAGENT_STOP agent_id=${childInstanceId.slice(0, 8)} platform=${adapterPlatform(adapter)}`,
|
|
932
1104
|
"--instance",
|
|
933
|
-
|
|
1105
|
+
childInstanceId,
|
|
934
1106
|
],
|
|
935
1107
|
{ encoding: "utf8", timeout: 2000, env: childEnv(coordRoot) },
|
|
936
1108
|
);
|
|
937
1109
|
}
|
|
1110
|
+
const { reconcileSessionFinalizationV3 } = await import("../agents/session-finalizer-v3.ts");
|
|
1111
|
+
reconcileSessionFinalizationV3(coordRoot, { archive_observations: [] });
|
|
938
1112
|
} catch (err) {
|
|
939
1113
|
logError(coordRoot, err, { phase: "subagent-stop-cleanup" });
|
|
940
1114
|
}
|
|
@@ -1001,6 +1175,16 @@ async function main(): Promise<number> {
|
|
|
1001
1175
|
runSessionSyncExtension(coordRoot, false);
|
|
1002
1176
|
}
|
|
1003
1177
|
|
|
1178
|
+
// Publish after the canonical turn event has landed so the blob carries
|
|
1179
|
+
// current task, activity, and claim state. Re-ensure the relay here because
|
|
1180
|
+
// its daemon intentionally exits when a machine has no live sessions.
|
|
1181
|
+
try {
|
|
1182
|
+
publishPresence(coordRoot);
|
|
1183
|
+
ensureRelayDaemon(coordRoot);
|
|
1184
|
+
} catch (err) {
|
|
1185
|
+
logError(coordRoot, err, { phase: "stop-presence" });
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1004
1188
|
// Stop verdict (V3 ritual + task/status gate). Direct in-process call: the
|
|
1005
1189
|
// rule lives in Harnery. agent-hook already emitted this turn.completed
|
|
1006
1190
|
// with privacy-safe ritual observations, so the evidence is in the stream.
|
|
@@ -1009,16 +1193,39 @@ async function main(): Promise<number> {
|
|
|
1009
1193
|
instance_id: owner.instance_id,
|
|
1010
1194
|
session_id: sessionId,
|
|
1011
1195
|
adapter,
|
|
1196
|
+
stop_hook_active: payload?.stop_hook_active === true,
|
|
1197
|
+
status_box_present_strict: data.status_box_present_strict === true,
|
|
1012
1198
|
bypass: coordEnv("AGENT_COORD_BYPASS_STOP") === "1",
|
|
1013
1199
|
workflow_child: coordEnv("WORKFLOW_CHILD") === "1",
|
|
1014
1200
|
});
|
|
1015
1201
|
if (!verdict.allow) {
|
|
1016
|
-
//
|
|
1017
|
-
//
|
|
1018
|
-
// `
|
|
1019
|
-
//
|
|
1020
|
-
|
|
1021
|
-
|
|
1202
|
+
// Backstop for sessions whose evidence can never land (e.g. a headless
|
|
1203
|
+
// child whose status command resolves to a different owner): after
|
|
1204
|
+
// `cap` consecutive blocked stops in one cycle, allow the stop instead
|
|
1205
|
+
// of bouncing the model forever. Cycle boundaries come from the
|
|
1206
|
+
// adapter's continuation flag, so adapters without one are unaffected.
|
|
1207
|
+
const { recordRemediationBlock } = await import("./remediation-cap.ts");
|
|
1208
|
+
const remediation = recordRemediationBlock(sessionId, payload?.stop_hook_active === true);
|
|
1209
|
+
if (remediation.exceeded) {
|
|
1210
|
+
appendDebug(coordRoot, {
|
|
1211
|
+
...debugBase,
|
|
1212
|
+
skipped: "stop-remediation-cap-exhausted",
|
|
1213
|
+
blocked_rule: verdict.rule,
|
|
1214
|
+
blocked_count: remediation.count,
|
|
1215
|
+
session_id: sessionId,
|
|
1216
|
+
remediation_cycle_anchor: verdict.remediation_cycle_anchor,
|
|
1217
|
+
});
|
|
1218
|
+
} else {
|
|
1219
|
+
// Adapter-aware enforcement channel: Claude Code honors exit-2 + stderr
|
|
1220
|
+
// as a turn block; Cursor ignores exit codes and re-prompts only via a
|
|
1221
|
+
// `followup_message` it auto-submits. Codex returned observe-only above.
|
|
1222
|
+
// emitStopBlock writes the right shape and returns the exit code to use.
|
|
1223
|
+
const { emitStopBlock } = await import("./adapter/output.ts");
|
|
1224
|
+
return emitStopBlock(adapter, verdict, coordRoot);
|
|
1225
|
+
}
|
|
1226
|
+
} else {
|
|
1227
|
+
const { clearRemediationCount } = await import("./remediation-cap.ts");
|
|
1228
|
+
clearRemediationCount(sessionId);
|
|
1022
1229
|
}
|
|
1023
1230
|
|
|
1024
1231
|
// An explicit end requested from inside this turn cannot be authoritative
|
|
@@ -1035,6 +1242,7 @@ async function main(): Promise<number> {
|
|
|
1035
1242
|
} catch (err) {
|
|
1036
1243
|
logError(coordRoot, err, { phase: "stop-explicit-session-finalization" });
|
|
1037
1244
|
}
|
|
1245
|
+
if (adapter === "codex") scheduleCodexRuntimeContextRetry(coordRoot, sessionId);
|
|
1038
1246
|
}
|
|
1039
1247
|
|
|
1040
1248
|
// Phase 7: PreToolUse: heartbeat + pid-map self-heal on every tool call.
|
|
@@ -1063,14 +1271,18 @@ async function main(): Promise<number> {
|
|
|
1063
1271
|
// runs before a name exists; every later tool waits until the exact block
|
|
1064
1272
|
// is the first assistant text after the mint result. Cursor supplies
|
|
1065
1273
|
// agent_message directly; Claude Code and Codex are resolved from their
|
|
1066
|
-
// JSONL transcripts.
|
|
1067
|
-
//
|
|
1274
|
+
// JSONL transcripts. Cursor's current narration can provide positive
|
|
1275
|
+
// evidence, but cannot disprove an earlier response; afterAgentResponse
|
|
1276
|
+
// stamps that durable sighting. Later commentary must not erase an
|
|
1277
|
+
// already-correct display, and unavailable evidence must not deadlock
|
|
1278
|
+
// every tool.
|
|
1068
1279
|
try {
|
|
1069
1280
|
const displayAllowed = await enforcePendingSessionNameDisplay(
|
|
1070
1281
|
coordRoot,
|
|
1071
1282
|
owner.instance_id,
|
|
1072
1283
|
adapter,
|
|
1073
1284
|
payload,
|
|
1285
|
+
generationBoundHeartbeat(readHeartbeat(coordRoot, owner.instance_id), recordedGenerationId),
|
|
1074
1286
|
);
|
|
1075
1287
|
if (!displayAllowed) return 0;
|
|
1076
1288
|
} catch (err) {
|
|
@@ -1147,27 +1359,77 @@ async function main(): Promise<number> {
|
|
|
1147
1359
|
return 0;
|
|
1148
1360
|
}
|
|
1149
1361
|
|
|
1362
|
+
function scheduleCodexRuntimeContextRetry(coordRoot: string, nativeSessionId: string): void {
|
|
1363
|
+
const modulePath = process.argv[1];
|
|
1364
|
+
if (!modulePath) return;
|
|
1365
|
+
try {
|
|
1366
|
+
const child = spawn(
|
|
1367
|
+
process.execPath,
|
|
1368
|
+
[modulePath, "runtime-context-retry", "--adapter", "codex", "--session-id", nativeSessionId],
|
|
1369
|
+
{
|
|
1370
|
+
cwd: coordRoot,
|
|
1371
|
+
detached: true,
|
|
1372
|
+
stdio: "ignore",
|
|
1373
|
+
env: childEnv(coordRoot),
|
|
1374
|
+
},
|
|
1375
|
+
);
|
|
1376
|
+
child.unref();
|
|
1377
|
+
} catch (err) {
|
|
1378
|
+
logError(coordRoot, err, { phase: "runtime-context-retry-spawn" });
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
async function runRuntimeContextRetryWorker(
|
|
1383
|
+
coordRoot: string,
|
|
1384
|
+
adapter: Adapter | null,
|
|
1385
|
+
extra: string[],
|
|
1386
|
+
): Promise<number> {
|
|
1387
|
+
const nativeSessionId = extraArg(extra, "--session-id");
|
|
1388
|
+
if (adapter !== "codex" || !nativeSessionId) return 0;
|
|
1389
|
+
for (const [index, delayMs] of [400, 1_000].entries()) {
|
|
1390
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
1391
|
+
const route = resolveLiveEventLedgerRouteV3(coordRoot);
|
|
1392
|
+
if (route.state !== "v3") return 0;
|
|
1393
|
+
const result = reconcileLivePendingRuntimeContextV3({
|
|
1394
|
+
coordRoot,
|
|
1395
|
+
route,
|
|
1396
|
+
nativeSessionId,
|
|
1397
|
+
finalAttempt: index === 1,
|
|
1398
|
+
});
|
|
1399
|
+
if (result.state !== "pending" && result.state !== "busy") return 0;
|
|
1400
|
+
}
|
|
1401
|
+
return 0;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1150
1404
|
async function enforcePendingSessionNameDisplay(
|
|
1151
1405
|
coordRoot: string,
|
|
1152
1406
|
instanceId: string,
|
|
1153
1407
|
adapter: Adapter,
|
|
1154
1408
|
payload: ParsedPayload | null,
|
|
1409
|
+
coordination: Heartbeat | null,
|
|
1155
1410
|
): Promise<boolean> {
|
|
1156
|
-
const name = sessionNameDisplayPending(
|
|
1411
|
+
const name = sessionNameDisplayPending(coordination);
|
|
1157
1412
|
if (!name) return true;
|
|
1158
1413
|
|
|
1159
1414
|
const command = extractBashCommand(payload?.tool_name, payload?.tool_input);
|
|
1160
1415
|
if (isSessionNameRemediationCommand(command, resolveBinName(coordRoot))) return true;
|
|
1161
1416
|
|
|
1162
1417
|
const inspection =
|
|
1163
|
-
payload?.agent_message !== undefined
|
|
1418
|
+
adapter === "cursor" && payload?.agent_message !== undefined
|
|
1164
1419
|
? {
|
|
1165
1420
|
state: assistantTextStartsWithSessionNameBlock(payload.agent_message, name)
|
|
1166
1421
|
? ("present" as const)
|
|
1167
|
-
: ("
|
|
1422
|
+
: ("unavailable" as const),
|
|
1168
1423
|
}
|
|
1169
1424
|
: inspectSessionNameDisplayImmediately(
|
|
1170
|
-
|
|
1425
|
+
// Codex hook payloads omit transcript_path on every event, which
|
|
1426
|
+
// left this inspection permanently unavailable and the latch never
|
|
1427
|
+
// stamped. Discover the rollout by session id; the scan only runs
|
|
1428
|
+
// while a name is pending, so the latch closes after one success.
|
|
1429
|
+
payload?.transcript_path ??
|
|
1430
|
+
(adapter === "codex"
|
|
1431
|
+
? discoverCodexSessionTranscript(payload?.session_id ?? instanceId)
|
|
1432
|
+
: undefined),
|
|
1171
1433
|
name,
|
|
1172
1434
|
assistantTextStartsWithSessionNameBlock,
|
|
1173
1435
|
);
|
|
@@ -1177,20 +1439,26 @@ async function enforcePendingSessionNameDisplay(
|
|
|
1177
1439
|
}
|
|
1178
1440
|
|
|
1179
1441
|
if (inspection.state === "unavailable") {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
);
|
|
1442
|
+
// PostToolUse already delivered the exact block for this mint. An
|
|
1443
|
+
// unavailable transcript cannot become evidence, and repeating a generic
|
|
1444
|
+
// reminder on every tool creates an unbounded Codex loop. Keep the latch
|
|
1445
|
+
// honestly pending and fail open without another instruction. A later
|
|
1446
|
+
// readable transcript can still verify it.
|
|
1186
1447
|
return true;
|
|
1187
1448
|
}
|
|
1188
1449
|
|
|
1189
1450
|
const { emitDeny } = await import("./adapter/output.ts");
|
|
1190
|
-
emitDeny(adapter,
|
|
1451
|
+
emitDeny(adapter, sessionNameDisplayRecoveryInstruction(name, resolveBinName(coordRoot)));
|
|
1191
1452
|
return false;
|
|
1192
1453
|
}
|
|
1193
1454
|
|
|
1455
|
+
function generationBoundHeartbeat(
|
|
1456
|
+
heartbeat: Heartbeat | null,
|
|
1457
|
+
generationId: `gen_${string}` | undefined,
|
|
1458
|
+
): Heartbeat | null {
|
|
1459
|
+
return generationId && heartbeat?.v3_generation_id === generationId ? heartbeat : null;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1194
1462
|
async function runPreToolUseGuard(
|
|
1195
1463
|
coordRoot: string,
|
|
1196
1464
|
instanceId: string,
|
|
@@ -1538,16 +1806,22 @@ async function emitUserPromptSubmitSystemMessage(
|
|
|
1538
1806
|
// Every human-facing adapter gets the first-session naming reminder from
|
|
1539
1807
|
// the shared hook path. Cursor + Codex additionally get ongoing set-task
|
|
1540
1808
|
// staleness nudges; Claude Code enforces those via its Stop transcript.
|
|
1809
|
+
// Codex also gets the optional project-owned prompt reminder. Claude Code
|
|
1810
|
+
// already has native output-style reminders, so duplicating it would add
|
|
1811
|
+
// noise. Cursor's current beforeSubmitPrompt output can allow or block but
|
|
1812
|
+
// cannot inject model context; an Always Apply rule is its durable carrier.
|
|
1813
|
+
// Only the boolean route travels through argv, never the host's text.
|
|
1814
|
+
if (adapter === "codex") args.push("--host-prompt-reminder");
|
|
1541
1815
|
// Codex gets a fresh status-footer reminder on every prompt. Its Stop hook
|
|
1542
1816
|
// stays observe-only, so missing the footer never replaces the answer.
|
|
1543
|
-
// Claude Code
|
|
1544
|
-
//
|
|
1545
|
-
//
|
|
1817
|
+
// Claude Code gets a fresh per-turn ritual reminder: satisfying the
|
|
1818
|
+
// contract up front is far cheaper than the bounce-and-retry the Stop hook
|
|
1819
|
+
// otherwise forces. Cursor's beforeSubmitPrompt cannot inject context, so
|
|
1820
|
+
// its Stop follow-up remains the supported enforcement channel.
|
|
1546
1821
|
args.push("--session-name-nudge");
|
|
1547
1822
|
if (adapter === "cursor" || adapter === "codex") args.push("--task-nudge");
|
|
1548
1823
|
if (adapter === "codex") args.push("--status-footer-nudge");
|
|
1549
|
-
if (adapter === "claude-code"
|
|
1550
|
-
args.push("--turn-ritual-nudge", adapter);
|
|
1824
|
+
if (adapter === "claude-code") args.push("--turn-ritual-nudge", adapter);
|
|
1551
1825
|
const result = spawnSync(agentCoordBin, args, { encoding: "utf8", timeout: 3000 });
|
|
1552
1826
|
if (result.status === 0 && result.stdout) additionalContext = result.stdout.trim();
|
|
1553
1827
|
}
|
|
@@ -1712,11 +1986,15 @@ function completeRecoveryInjection(
|
|
|
1712
1986
|
}
|
|
1713
1987
|
|
|
1714
1988
|
main()
|
|
1715
|
-
.then((code) =>
|
|
1716
|
-
|
|
1717
|
-
|
|
1989
|
+
.then(async (code) => {
|
|
1990
|
+
await closeProcessLoggers();
|
|
1991
|
+
process.exit(code);
|
|
1992
|
+
})
|
|
1993
|
+
.catch(async (err) => {
|
|
1994
|
+
logError(resolveCoordRoot(process.cwd()), err, {
|
|
1718
1995
|
argv: process.argv.slice(2),
|
|
1719
1996
|
pid: process.pid,
|
|
1720
1997
|
});
|
|
1998
|
+
await closeProcessLoggers();
|
|
1721
1999
|
process.exit(0);
|
|
1722
2000
|
});
|