harnery 0.35.0 → 0.37.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 +128 -96
- package/dist/commands/agents.d.ts +23 -3
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +464 -242
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +26 -1
- 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 +16 -4
- 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/deinit.d.ts.map +1 -1
- package/dist/commands/deinit.js +5 -0
- package/dist/commands/diagnostics.d.ts +4 -0
- package/dist/commands/diagnostics.d.ts.map +1 -0
- package/dist/commands/diagnostics.js +229 -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/fetch.js +6 -5
- package/dist/commands/files.d.ts +34 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +166 -0
- package/dist/commands/governor.d.ts.map +1 -1
- package/dist/commands/governor.js +18 -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 +417 -2
- 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/qa-run.d.ts +4 -0
- package/dist/commands/qa-run.d.ts.map +1 -0
- package/dist/commands/qa-run.js +141 -0
- 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/resources.d.ts +4 -0
- package/dist/commands/resources.d.ts.map +1 -0
- package/dist/commands/resources.js +29 -0
- package/dist/commands/semantic.d.ts.map +1 -1
- package/dist/commands/semantic.js +54 -2
- 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/supervisor.d.ts +4 -0
- package/dist/commands/supervisor.d.ts.map +1 -0
- package/dist/commands/supervisor.js +101 -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.d.ts.map +1 -1
- package/dist/commands/workflow.js +17 -13
- package/dist/core/adapters/profiles.d.ts +1 -1
- package/dist/core/agents/cli.js +215 -41
- package/dist/core/agents/health.d.ts +17 -0
- package/dist/core/agents/health.d.ts.map +1 -0
- package/dist/core/agents/health.js +109 -0
- 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 +244 -10
- package/dist/core/agents/live-lifecycle-v3.js +6 -1
- package/dist/core/agents/live-observation-v3.d.ts.map +1 -1
- package/dist/core/agents/live-observation-v3.js +6 -1
- package/dist/core/agents/mailbox.d.ts +92 -0
- package/dist/core/agents/mailbox.d.ts.map +1 -0
- package/dist/core/agents/mailbox.js +325 -0
- package/dist/core/agents/reconcile-coordination-v3.d.ts +44 -0
- package/dist/core/agents/reconcile-coordination-v3.d.ts.map +1 -0
- package/dist/core/agents/reconcile-coordination-v3.js +58 -0
- package/dist/core/agents/render/prompt-context.d.ts +14 -3
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +54 -16
- package/dist/core/agents/render/session-context.d.ts +8 -0
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +34 -3
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/commit-conflict.js +50 -1
- 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 +93 -16
- 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 +9 -2
- 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-writer.d.ts +6 -0
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +18 -0
- package/dist/core/agents/state/live-coordination-view.d.ts +5 -7
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.js +15 -90
- 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/artifacts/index.d.ts +47 -1
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +191 -6
- package/dist/core/config.d.ts +74 -4
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +141 -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/diagnostics/advice.d.ts +9 -0
- package/dist/core/diagnostics/advice.d.ts.map +1 -0
- package/dist/core/diagnostics/advice.js +112 -0
- package/dist/core/diagnostics/bundle.d.ts +35 -0
- package/dist/core/diagnostics/bundle.d.ts.map +1 -0
- package/dist/core/diagnostics/bundle.js +874 -0
- package/dist/core/diagnostics/comparison.d.ts +5 -0
- package/dist/core/diagnostics/comparison.d.ts.map +1 -0
- package/dist/core/diagnostics/comparison.js +444 -0
- package/dist/core/diagnostics/contract.d.ts +245 -0
- package/dist/core/diagnostics/contract.d.ts.map +1 -0
- package/dist/core/diagnostics/contract.js +18 -0
- package/dist/core/diagnostics/identity.d.ts +3 -0
- package/dist/core/diagnostics/identity.d.ts.map +1 -0
- package/dist/core/diagnostics/identity.js +10 -0
- package/dist/core/diagnostics/index.d.ts +8 -0
- package/dist/core/diagnostics/index.d.ts.map +1 -0
- package/dist/core/diagnostics/index.js +7 -0
- package/dist/core/diagnostics/replay.d.ts +8 -0
- package/dist/core/diagnostics/replay.d.ts.map +1 -0
- package/dist/core/diagnostics/replay.js +213 -0
- package/dist/core/diagnostics/sanitize.d.ts +9 -0
- package/dist/core/diagnostics/sanitize.d.ts.map +1 -0
- package/dist/core/diagnostics/sanitize.js +84 -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/compression.d.ts +13 -0
- package/dist/core/events/legacy-storage/compression.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/compression.js +107 -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 +7 -0
- package/dist/core/events/legacy-storage/index.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/index.js +6 -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/archive-retention.d.ts +33 -0
- package/dist/core/events/v3/archive-retention.d.ts.map +1 -0
- package/dist/core/events/v3/archive-retention.js +195 -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 +81 -41
- package/dist/core/events/v3/base-contract.d.ts.map +1 -1
- package/dist/core/events/v3/base-contract.js +17 -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 +1 -1
- package/dist/core/events/v3/capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/capabilities.js +4 -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 +5 -2
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +4 -1
- 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 +13 -21
- package/dist/core/events/v3/live-routing.d.ts.map +1 -1
- package/dist/core/events/v3/live-routing.js +46 -41
- 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 +76 -10
- 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 +1 -1
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
- package/dist/core/events/v3/producers/hook-base.js +14 -3
- package/dist/core/events/v3/producers/intake.d.ts +7 -0
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
- package/dist/core/events/v3/producers/intake.js +26 -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 +71 -1
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +441 -25
- 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 +6 -5
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/runtime-telemetry-capabilities.js +1 -1
- 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 +14 -8
- 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 +12 -2
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +23 -5
- package/dist/core/hooks/adapter/runtime-telemetry.d.ts +27 -4
- package/dist/core/hooks/adapter/runtime-telemetry.d.ts.map +1 -1
- package/dist/core/hooks/adapter/runtime-telemetry.js +307 -6
- package/dist/core/hooks/cli.js +380 -207
- 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/health.d.ts +59 -0
- package/dist/core/hooks/health.d.ts.map +1 -0
- package/dist/core/hooks/health.js +84 -0
- package/dist/core/hooks/remediation-cap.d.ts +8 -3
- package/dist/core/hooks/remediation-cap.d.ts.map +1 -1
- package/dist/core/hooks/remediation-cap.js +3 -11
- 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 +8 -0
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +11 -0
- 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/resources/contract.d.ts +90 -0
- package/dist/core/resources/contract.d.ts.map +1 -0
- package/dist/core/resources/contract.js +2 -0
- package/dist/core/resources/index.d.ts +6 -0
- package/dist/core/resources/index.d.ts.map +1 -0
- package/dist/core/resources/index.js +5 -0
- package/dist/core/resources/sampler.d.ts +27 -0
- package/dist/core/resources/sampler.d.ts.map +1 -0
- package/dist/core/resources/sampler.js +357 -0
- package/dist/core/resources/service-status.d.ts +3 -0
- package/dist/core/resources/service-status.d.ts.map +1 -0
- package/dist/core/resources/service-status.js +48 -0
- package/dist/core/resources/service.d.ts +26 -0
- package/dist/core/resources/service.d.ts.map +1 -0
- package/dist/core/resources/service.js +292 -0
- package/dist/core/resources/storage.d.ts +13 -0
- package/dist/core/resources/storage.d.ts.map +1 -0
- package/dist/core/resources/storage.js +30 -0
- package/dist/core/semantic/adapters.d.ts +11 -8
- package/dist/core/semantic/adapters.d.ts.map +1 -1
- package/dist/core/semantic/adapters.js +169 -31
- package/dist/core/semantic/contract.d.ts +532 -48
- package/dist/core/semantic/contract.d.ts.map +1 -1
- package/dist/core/semantic/contract.js +104 -3
- package/dist/core/semantic/index.d.ts +7 -3
- package/dist/core/semantic/index.d.ts.map +1 -1
- package/dist/core/semantic/index.js +7 -3
- package/dist/core/semantic/once.d.ts +6 -1
- package/dist/core/semantic/once.d.ts.map +1 -1
- package/dist/core/semantic/once.js +80 -9
- package/dist/core/semantic/prompt.d.ts.map +1 -1
- package/dist/core/semantic/prompt.js +14 -1
- 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 +14 -3
- package/dist/core/semantic/scheduler.d.ts.map +1 -1
- package/dist/core/semantic/scheduler.js +30 -6
- package/dist/core/semantic/service-status.d.ts +20 -0
- package/dist/core/semantic/service-status.d.ts.map +1 -1
- package/dist/core/semantic/service-status.js +60 -4
- package/dist/core/semantic/service.d.ts +1 -0
- package/dist/core/semantic/service.d.ts.map +1 -1
- package/dist/core/semantic/service.js +104 -15
- 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 +11 -1
- package/dist/core/semantic/storage.d.ts.map +1 -1
- package/dist/core/semantic/storage.js +4 -3
- 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 +3 -1
- package/dist/core/semantic/validate.d.ts.map +1 -1
- package/dist/core/semantic/validate.js +34 -1
- package/dist/core/storage/atomic-json.d.ts +3 -0
- package/dist/core/storage/atomic-json.d.ts.map +1 -0
- package/dist/core/storage/atomic-json.js +15 -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 +722 -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 +84 -0
- package/dist/core/storage/logger.d.ts.map +1 -0
- package/dist/core/storage/logger.js +413 -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 +48 -0
- package/dist/core/storage/query.d.ts.map +1 -0
- package/dist/core/storage/query.js +346 -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/supervisor/activity.d.ts +4 -0
- package/dist/core/supervisor/activity.d.ts.map +1 -0
- package/dist/core/supervisor/activity.js +141 -0
- package/dist/core/supervisor/contract.d.ts +268 -0
- package/dist/core/supervisor/contract.d.ts.map +1 -0
- package/dist/core/supervisor/contract.js +35 -0
- package/dist/core/supervisor/explanations.d.ts +4 -0
- package/dist/core/supervisor/explanations.d.ts.map +1 -0
- package/dist/core/supervisor/explanations.js +71 -0
- package/dist/core/supervisor/findings.d.ts +20 -0
- package/dist/core/supervisor/findings.d.ts.map +1 -0
- package/dist/core/supervisor/findings.js +399 -0
- package/dist/core/supervisor/history.d.ts +9 -0
- package/dist/core/supervisor/history.d.ts.map +1 -0
- package/dist/core/supervisor/history.js +46 -0
- package/dist/core/supervisor/hook-health-alerts.d.ts +14 -0
- package/dist/core/supervisor/hook-health-alerts.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health-alerts.js +70 -0
- package/dist/core/supervisor/hook-health-storage.d.ts +5 -0
- package/dist/core/supervisor/hook-health-storage.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health-storage.js +24 -0
- package/dist/core/supervisor/hook-health.d.ts +72 -0
- package/dist/core/supervisor/hook-health.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health.js +203 -0
- package/dist/core/supervisor/hooks.d.ts +10 -0
- package/dist/core/supervisor/hooks.d.ts.map +1 -0
- package/dist/core/supervisor/hooks.js +28 -0
- package/dist/core/supervisor/index.d.ts +15 -0
- package/dist/core/supervisor/index.d.ts.map +1 -0
- package/dist/core/supervisor/index.js +14 -0
- package/dist/core/supervisor/log-feed.d.ts +9 -0
- package/dist/core/supervisor/log-feed.d.ts.map +1 -0
- package/dist/core/supervisor/log-feed.js +103 -0
- package/dist/core/supervisor/service.d.ts +29 -0
- package/dist/core/supervisor/service.d.ts.map +1 -0
- package/dist/core/supervisor/service.js +450 -0
- package/dist/core/supervisor/services.d.ts +11 -0
- package/dist/core/supervisor/services.d.ts.map +1 -0
- package/dist/core/supervisor/services.js +155 -0
- package/dist/core/supervisor/status.d.ts +3 -0
- package/dist/core/supervisor/status.d.ts.map +1 -0
- package/dist/core/supervisor/status.js +48 -0
- package/dist/core/supervisor/storage.d.ts +30 -0
- package/dist/core/supervisor/storage.d.ts.map +1 -0
- package/dist/core/supervisor/storage.js +73 -0
- package/dist/core/supervisor/timeline.d.ts +3 -0
- package/dist/core/supervisor/timeline.d.ts.map +1 -0
- package/dist/core/supervisor/timeline.js +87 -0
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +10 -14
- package/dist/core/workflow/admission.d.ts +23 -0
- package/dist/core/workflow/admission.d.ts.map +1 -0
- package/dist/core/workflow/admission.js +136 -0
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +77 -2
- package/dist/core/workflow/index.d.ts +3 -2
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +2 -1
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +2 -1
- package/dist/core/workflow/proof.d.ts +2 -1
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +39 -1
- package/dist/core/workflow/run-state.d.ts +3 -2
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +8 -1
- package/dist/core/workflow/types.d.ts +33 -1
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/types.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 +5 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +1 -0
- package/dist/lib/browser/index.d.ts +2 -0
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +2 -0
- package/dist/lib/browser/qa-run-contracts.d.ts +173 -0
- package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -0
- package/dist/lib/browser/qa-run-contracts.js +226 -0
- package/dist/lib/browser/qa-run.d.ts +51 -0
- package/dist/lib/browser/qa-run.d.ts.map +1 -0
- package/dist/lib/browser/qa-run.js +684 -0
- package/dist/lib/coord-root-id.d.ts +9 -0
- package/dist/lib/coord-root-id.d.ts.map +1 -0
- package/dist/lib/coord-root-id.js +17 -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 +3 -1
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +74 -3
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +11 -0
- 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 +40 -2
- package/schemas/config.schema.json +58 -0
- package/schemas/event-v3.schema.json +324 -112
- package/src/commander.ts +488 -95
- package/src/commands/agents.ts +617 -237
- package/src/commands/artifacts.ts +40 -2
- package/src/commands/backup.ts +18 -14
- package/src/commands/browse-session.ts +12 -0
- package/src/commands/browse.ts +21 -7
- package/src/commands/conversations.ts +279 -0
- package/src/commands/deinit.ts +6 -0
- package/src/commands/diagnostics.ts +271 -0
- package/src/commands/docs.ts +25 -6
- package/src/commands/doctor.ts +75 -9
- package/src/commands/fetch.ts +7 -6
- package/src/commands/files.ts +243 -0
- package/src/commands/governor.ts +21 -12
- package/src/commands/inbox.ts +61 -0
- package/src/commands/init.ts +78 -16
- package/src/commands/ledger-v3.ts +503 -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/qa-run.ts +184 -0
- package/src/commands/read.ts +6 -2
- package/src/commands/resources.ts +38 -0
- package/src/commands/semantic.ts +66 -1
- package/src/commands/storage.ts +310 -0
- package/src/commands/supervisor.ts +141 -0
- package/src/commands/tunnel.ts +66 -52
- package/src/commands/web.ts +96 -7
- package/src/commands/work.ts +3 -3
- package/src/commands/workflow.ts +21 -13
- package/src/core/agents/cli.ts +265 -55
- package/src/core/agents/health.ts +142 -0
- package/src/core/agents/live-authority-v3.ts +341 -10
- package/src/core/agents/live-lifecycle-v3.ts +6 -1
- package/src/core/agents/live-observation-v3.ts +6 -1
- package/src/core/agents/mailbox.ts +373 -0
- package/src/core/agents/reconcile-coordination-v3.ts +77 -0
- package/src/core/agents/render/prompt-context.ts +66 -15
- package/src/core/agents/render/session-context.ts +37 -3
- package/src/core/agents/rules/commit-conflict.ts +58 -1
- package/src/core/agents/rules/stop-hook.ts +105 -20
- 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 +8 -2
- package/src/core/agents/state/activity-log.ts +7 -2
- package/src/core/agents/state/heartbeat-writer.ts +27 -0
- package/src/core/agents/state/live-coordination-view.ts +16 -105
- package/src/core/agents/state/live-coordination-writer.ts +141 -0
- package/src/core/artifacts/index.ts +260 -11
- package/src/core/config.ts +235 -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/diagnostics/advice.ts +147 -0
- package/src/core/diagnostics/bundle.ts +1142 -0
- package/src/core/diagnostics/comparison.ts +565 -0
- package/src/core/diagnostics/contract.ts +311 -0
- package/src/core/diagnostics/identity.ts +11 -0
- package/src/core/diagnostics/index.ts +7 -0
- package/src/core/diagnostics/replay.ts +314 -0
- package/src/core/diagnostics/sanitize.ts +97 -0
- package/src/core/events/legacy-storage/canary.ts +177 -0
- package/src/core/events/legacy-storage/compression.ts +130 -0
- package/src/core/events/legacy-storage/fence.ts +129 -0
- package/src/core/events/legacy-storage/index.ts +6 -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/archive-retention.ts +251 -0
- package/src/core/events/v3/authority-outbox.ts +22 -1
- package/src/core/events/v3/base-contract.ts +17 -7
- package/src/core/events/v3/bootstrap.ts +195 -2
- package/src/core/events/v3/capabilities.ts +5 -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 +14 -2
- package/src/core/events/v3/live-route-observer.ts +80 -0
- package/src/core/events/v3/live-routing.ts +65 -46
- package/src/core/events/v3/producers/coordination-recorder.ts +95 -10
- package/src/core/events/v3/producers/diagnostic-summaries.ts +593 -0
- package/src/core/events/v3/producers/hook-base.ts +15 -3
- package/src/core/events/v3/producers/intake.ts +31 -2
- package/src/core/events/v3/producers/producer-state-observer.ts +52 -0
- package/src/core/events/v3/producers/recorder.ts +681 -34
- 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 +14 -8
- 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 +58 -7
- 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 +23 -5
- package/src/core/hooks/adapter/runtime-telemetry.ts +408 -13
- package/src/core/hooks/cli.ts +404 -233
- package/src/core/hooks/effects/image-capture.ts +4 -1
- package/src/core/hooks/health.ts +146 -0
- package/src/core/hooks/remediation-cap.ts +12 -6
- 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 +18 -0
- 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/resources/contract.ts +98 -0
- package/src/core/resources/index.ts +5 -0
- package/src/core/resources/sampler.ts +458 -0
- package/src/core/resources/service-status.ts +62 -0
- package/src/core/resources/service.ts +337 -0
- package/src/core/resources/storage.ts +44 -0
- package/src/core/semantic/adapters.ts +200 -41
- package/src/core/semantic/contract.ts +135 -3
- package/src/core/semantic/index.ts +76 -2
- package/src/core/semantic/once.ts +93 -7
- package/src/core/semantic/prompt.ts +13 -1
- package/src/core/semantic/review.ts +803 -0
- package/src/core/semantic/routes.ts +30 -0
- package/src/core/semantic/scheduler.ts +49 -5
- package/src/core/semantic/service-status.ts +99 -5
- package/src/core/semantic/service.ts +116 -15
- package/src/core/semantic/soak.ts +638 -0
- package/src/core/semantic/storage.ts +20 -6
- package/src/core/semantic/usage.ts +272 -0
- package/src/core/semantic/validate.ts +31 -0
- package/src/core/storage/atomic-json.ts +15 -0
- package/src/core/storage/buffer.ts +124 -0
- package/src/core/storage/builtins.ts +972 -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 +548 -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 +418 -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/supervisor/activity.ts +193 -0
- package/src/core/supervisor/contract.ts +312 -0
- package/src/core/supervisor/explanations.ts +104 -0
- package/src/core/supervisor/findings.ts +788 -0
- package/src/core/supervisor/history.ts +61 -0
- package/src/core/supervisor/hook-health-alerts.ts +108 -0
- package/src/core/supervisor/hook-health-storage.ts +25 -0
- package/src/core/supervisor/hook-health.ts +301 -0
- package/src/core/supervisor/hooks.ts +35 -0
- package/src/core/supervisor/index.ts +14 -0
- package/src/core/supervisor/log-feed.ts +131 -0
- package/src/core/supervisor/service.ts +511 -0
- package/src/core/supervisor/services.ts +203 -0
- package/src/core/supervisor/status.ts +59 -0
- package/src/core/supervisor/storage.ts +126 -0
- package/src/core/supervisor/timeline.ts +133 -0
- package/src/core/work/state.ts +12 -21
- package/src/core/workflow/admission.ts +215 -0
- package/src/core/workflow/engine.ts +93 -1
- package/src/core/workflow/index.ts +10 -0
- package/src/core/workflow/live-session-v3.ts +2 -4
- package/src/core/workflow/proof.ts +54 -1
- package/src/core/workflow/run-state.ts +13 -1
- package/src/core/workflow/types.ts +39 -1
- package/src/index.ts +2 -0
- package/src/lazy-commands.ts +294 -0
- package/src/lib/browser/client.ts +6 -0
- package/src/lib/browser/index.ts +29 -0
- package/src/lib/browser/qa-run-contracts.ts +380 -0
- package/src/lib/browser/qa-run.ts +784 -0
- package/src/lib/coord-root-id.ts +23 -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 +81 -2
- package/src/lib/instructions/templates.ts +11 -0
- package/src/lib/local-file-url.ts +31 -0
- package/src/lib/web-performance.ts +335 -0
package/dist/core/hooks/cli.js
CHANGED
|
@@ -16,24 +16,28 @@
|
|
|
16
16
|
* `.harnery/debug/agent-hook.errors.ndjson` for audit but never break the
|
|
17
17
|
* adapter flow.
|
|
18
18
|
*/
|
|
19
|
-
import { spawnSync } from "node:child_process";
|
|
19
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
20
20
|
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
21
21
|
import { dirname, join } from "node:path";
|
|
22
22
|
import { coordEnv } from "../../lib/env.js";
|
|
23
23
|
import { buildInstructionBundle } from "../../lib/instructions/bundle.js";
|
|
24
|
-
import {
|
|
24
|
+
import { resolveCoordRoot } from "../agents/coord-client.js";
|
|
25
25
|
import { classifyWriteClaimFinalization, formatWriteClaimFinalizationDenial, } from "../agents/finalization.js";
|
|
26
|
+
import { recordLiveClaimChangeV3, restoreLiveCoordinationStateAfterEpochV3, } from "../agents/live-authority-v3.js";
|
|
26
27
|
import { evaluateStopHook, STOP_REMEDIATION_MARKER } from "../agents/rules/stop-hook.js";
|
|
27
28
|
import { assistantTextStartsWithSessionNameBlock, isSessionNameRemediationCommand, sessionNameDisplayInstruction, sessionNameDisplayPending, sessionNameDisplayRecoveryInstruction, toolResponseMintedSessionName, } from "../agents/session-name-display.js";
|
|
28
|
-
import { stampSessionNameSeen } from "../agents/state/heartbeat-writer.js";
|
|
29
|
-
import {
|
|
29
|
+
import { readHeartbeat, stampSessionNameSeen } from "../agents/state/heartbeat-writer.js";
|
|
30
|
+
import { readLiveCoordinationRow } from "../agents/state/live-coordination-view.js";
|
|
31
|
+
import { ensureLiveCoordinationHeartbeat } from "../agents/state/live-coordination-writer.js";
|
|
32
|
+
import { assignName } from "../agents/state/names.js";
|
|
30
33
|
import { writePidmapRow } from "../agents/state/pidmap.js";
|
|
31
34
|
import { agentsRequireGitFinalization, resolveBinName } from "../config.js";
|
|
32
35
|
import { checkpointContext, completeContextRecovery, extractContextSample, markContextCompactionCompleted, prepareContextRecovery, readContextState, recordContextSample, } from "../context/index.js";
|
|
33
36
|
import { tryWriteLiveDisplayV3 } from "../events/v3/live-feed.js";
|
|
34
|
-
import { liveHookSignalDefersDrainV3, recordLiveDelegatedChildSessionV3, recordLiveHookSignalV3, resolveLiveEventLedgerRouteV3, } from "../events/v3/live-routing.js";
|
|
37
|
+
import { liveHookSignalDefersDrainV3, reconcileLivePendingRuntimeContextV3, recordLiveDelegatedChildSessionV3, recordLiveHookSignalV3, resolveLiveEventLedgerRouteV3, } from "../events/v3/live-routing.js";
|
|
35
38
|
import { captureSpanClockV3 } from "../events/v3/span-state.js";
|
|
36
|
-
import { fetchPresence } from "../presence/index.js";
|
|
39
|
+
import { ensureRelayDaemon, fetchPresence, publishPresence } from "../presence/index.js";
|
|
40
|
+
import { closeProcessLoggers, legacyLogFields, processLogger } from "../storage/logger.js";
|
|
37
41
|
import { stableScopeId } from "../workflow/scope-id.js";
|
|
38
42
|
import { detectAdapter, shouldSkipHookAdapter } from "./adapter/detect.js";
|
|
39
43
|
import { extractBashCommand, extractToolDescription, normalizeEventName, parsePayload, } from "./adapter/parse.js";
|
|
@@ -42,13 +46,14 @@ import { codexWslFileLinkTelemetry, inspectCodexWslBridge, isWslUncPath, renderC
|
|
|
42
46
|
import { captureImages, detectPresence, imageJanitor, journalArchive, journalJanitor, journalRecoveryCue, playSound, recordImageArtifactsV3, resetSoundCounters, runSessionSyncExtension, soundForEvent, } from "./effects/index.js";
|
|
43
47
|
import { toolInputHash, toolTargetHash } from "./events/input-hash.js";
|
|
44
48
|
import { canonicalize } from "./guard-path.js";
|
|
49
|
+
import { beginHookHealth, observeHookDebug, observeHookError, writeHookHealthCompletion, } from "./health.js";
|
|
45
50
|
import { adapterPidFromEnv, parsePsChainLine, selectAnchorPid } from "./resolve/anchor.js";
|
|
46
|
-
import { findCoordRoot } from "./resolve/coord-root.js";
|
|
47
51
|
import { extractIntentComment, resolveIntent } from "./resolve/intent.js";
|
|
48
52
|
import { resolveOwner } from "./resolve/owner.js";
|
|
49
|
-
import { inspectSessionNameDisplayImmediately,
|
|
53
|
+
import { inspectSessionNameDisplayImmediately, scanAssistantStatusBoxPresent, scanSessionNameDisplayedImmediately, scanStatusBoxPresent, scanTranscriptRuntime, } from "./resolve/transcript.js";
|
|
50
54
|
import { sessionNamePresence } from "./session-name-presence.js";
|
|
51
55
|
import { unsafeCrossShellReason } from "./unsafe-cross-shell.js";
|
|
56
|
+
let hookHealthState;
|
|
52
57
|
function parseArgv(argv) {
|
|
53
58
|
const out = { eventName: null, extra: [] };
|
|
54
59
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -68,6 +73,10 @@ function parseArgv(argv) {
|
|
|
68
73
|
}
|
|
69
74
|
return out;
|
|
70
75
|
}
|
|
76
|
+
function extraArg(extra, name) {
|
|
77
|
+
const index = extra.indexOf(name);
|
|
78
|
+
return index >= 0 ? extra[index + 1] : undefined;
|
|
79
|
+
}
|
|
71
80
|
async function readStdin() {
|
|
72
81
|
if (process.stdin.isTTY)
|
|
73
82
|
return "";
|
|
@@ -83,16 +92,24 @@ async function readStdin() {
|
|
|
83
92
|
}
|
|
84
93
|
}
|
|
85
94
|
/**
|
|
86
|
-
* Env for
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* without the pin a child could write state to a different .harnery than the
|
|
90
|
-
* one this hook resolved.
|
|
95
|
+
* Env for a detached hook retry worker, with the coord root pinned. The hook
|
|
96
|
+
* may run with the session shell's cwd (inside a submodule or journal dir), so
|
|
97
|
+
* the worker must retain the root this process already resolved.
|
|
91
98
|
*/
|
|
92
99
|
function childEnv(coordRoot) {
|
|
93
100
|
return { ...process.env, HARNERY_COORD_ROOT_OVERRIDE: coordRoot };
|
|
94
101
|
}
|
|
95
102
|
function appendDebug(coordRoot, entry) {
|
|
103
|
+
observeHookDebug(hookHealthState, entry);
|
|
104
|
+
if (coordEnv("SHARED_LOGS") !== "0") {
|
|
105
|
+
try {
|
|
106
|
+
processLogger(coordRoot, "agent-hook").debug("agent_hook.diagnostic", legacyLogFields(entry));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
/* fall through to the rollback writer */
|
|
111
|
+
}
|
|
112
|
+
}
|
|
96
113
|
const path = join(coordRoot, ".harnery", "debug", "agent-hook.ndjson");
|
|
97
114
|
try {
|
|
98
115
|
mkdirSync(dirname(path), { recursive: true });
|
|
@@ -103,8 +120,18 @@ function appendDebug(coordRoot, entry) {
|
|
|
103
120
|
}
|
|
104
121
|
}
|
|
105
122
|
function logError(coordRoot, err, context) {
|
|
123
|
+
observeHookError(hookHealthState, context.phase);
|
|
106
124
|
if (!coordRoot)
|
|
107
125
|
return;
|
|
126
|
+
if (coordEnv("SHARED_LOGS") !== "0") {
|
|
127
|
+
try {
|
|
128
|
+
processLogger(coordRoot, "agent-hook").error("agent_hook.error", legacyLogFields(context), err);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
/* fall through to the rollback writer */
|
|
133
|
+
}
|
|
134
|
+
}
|
|
108
135
|
const path = join(coordRoot, ".harnery", "debug", "agent-hook.errors.ndjson");
|
|
109
136
|
try {
|
|
110
137
|
mkdirSync(dirname(path), { recursive: true });
|
|
@@ -120,33 +147,13 @@ function logError(coordRoot, err, context) {
|
|
|
120
147
|
}
|
|
121
148
|
}
|
|
122
149
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* session.started emission never breaks the adapter flow.
|
|
126
|
-
*
|
|
127
|
-
* Lives at agent-hooks side (not agent-coord) to keep emitter/consumer
|
|
128
|
-
* separation: we spawn rather than import.
|
|
150
|
+
* Mint or recover the hurricane-style name for this owner in-process. Returns
|
|
151
|
+
* null on any failure so session.started emission never breaks adapter flow.
|
|
129
152
|
*/
|
|
130
|
-
function
|
|
131
|
-
const binary = coordBinPath("agent-coord", coordRoot) ?? "";
|
|
132
|
-
if (!existsSync(binary))
|
|
133
|
-
return null;
|
|
153
|
+
function assignNameInProcess(coordRoot, instanceId, kind, forkedFrom) {
|
|
134
154
|
try {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
args.push("--forked-from", forkedFrom);
|
|
138
|
-
const result = spawnSync(binary, args, {
|
|
139
|
-
encoding: "utf8",
|
|
140
|
-
timeout: 2000,
|
|
141
|
-
env: childEnv(coordRoot),
|
|
142
|
-
});
|
|
143
|
-
if (result.status !== 0 || !result.stdout)
|
|
144
|
-
return null;
|
|
145
|
-
const parsed = JSON.parse(result.stdout.trim());
|
|
146
|
-
if (parsed.name && parsed.kind) {
|
|
147
|
-
return { name: parsed.name, kind: parsed.kind };
|
|
148
|
-
}
|
|
149
|
-
return null;
|
|
155
|
+
const name = assignName(coordRoot, instanceId, kind, forkedFrom ? { forkedFrom } : undefined);
|
|
156
|
+
return { name, kind };
|
|
150
157
|
}
|
|
151
158
|
catch {
|
|
152
159
|
return null;
|
|
@@ -202,9 +209,9 @@ function buildEventData(eventType, ctx) {
|
|
|
202
209
|
// tool.requested heal path instead. The forkedFrom plumbing below stays
|
|
203
210
|
// for adapters that DO report a parent at session start.
|
|
204
211
|
const forkedFrom = undefined;
|
|
205
|
-
// Assign (or recover) name + kind
|
|
212
|
+
// Assign (or recover) name + kind in-process. Idempotent: resume
|
|
206
213
|
// returns the original name; new owner consumes a counter slot.
|
|
207
|
-
const assigned =
|
|
214
|
+
const assigned = assignNameInProcess(ctx.coordRoot, ctx.instanceId, "session", forkedFrom);
|
|
208
215
|
// Write the adapter pid-map row so `harn agents whoami` ppid-walks find
|
|
209
216
|
// this owner. Prefer the payload pid (the actual claude binary), then the
|
|
210
217
|
// anchor walk (the `node` ancestor for Cursor, which has no payload pid),
|
|
@@ -268,7 +275,7 @@ function buildEventData(eventType, ctx) {
|
|
|
268
275
|
// a later SessionStart remains idempotent.
|
|
269
276
|
if (ctx.adapter === "cursor" &&
|
|
270
277
|
!readLiveCoordinationRow(ctx.coordRoot, ctx.instanceId)?.name) {
|
|
271
|
-
|
|
278
|
+
assignNameInProcess(ctx.coordRoot, ctx.instanceId, "session");
|
|
272
279
|
}
|
|
273
280
|
const prompt = p?.prompt ?? "";
|
|
274
281
|
const { value, truncated } = clampString(prompt, 4000);
|
|
@@ -304,8 +311,7 @@ function buildEventData(eventType, ctx) {
|
|
|
304
311
|
// assistant text only (same window, same scanner as the session-name
|
|
305
312
|
// detection). The Stop verdict enforces this field; the loose field is
|
|
306
313
|
// retained as diagnostic telemetry for the measured detector divergence.
|
|
307
|
-
status_box_present_strict:
|
|
308
|
-
lastAssistantMessage.includes("┌─ agent-"),
|
|
314
|
+
status_box_present_strict: scanAssistantStatusBoxPresent(p?.transcript_path, lastAssistantMessage),
|
|
309
315
|
// Whether the session's suggested name is satisfied as of this turn,
|
|
310
316
|
// and which name that refers to. Reported on every stop while a name
|
|
311
317
|
// exists (the stop-hook.session_name verdict reads it per turn); the
|
|
@@ -327,7 +333,7 @@ function buildEventData(eventType, ctx) {
|
|
|
327
333
|
// (agent-coord/state/names.ts → kind=transient). Use the call ID as the
|
|
328
334
|
// instance_id input; assignName falls through to transient.
|
|
329
335
|
const childInstanceId = subagentCallId ?? ctx.instanceId;
|
|
330
|
-
const assigned =
|
|
336
|
+
const assigned = assignNameInProcess(ctx.coordRoot, childInstanceId, "subagent");
|
|
331
337
|
return {
|
|
332
338
|
agent_type: p?.raw.agent_type ??
|
|
333
339
|
p?.raw.subagent_type ??
|
|
@@ -442,10 +448,18 @@ function numberField(value) {
|
|
|
442
448
|
}
|
|
443
449
|
async function main() {
|
|
444
450
|
const hookStartedAt = performance.now();
|
|
451
|
+
const hookStartedRss = process.memoryUsage().rss;
|
|
445
452
|
const hookClock = captureSpanClockV3();
|
|
446
453
|
const { eventName, extra } = parseArgv(process.argv.slice(2));
|
|
447
454
|
const adapter = detectAdapter(process.argv.slice(2));
|
|
448
455
|
const raw = await readStdin();
|
|
456
|
+
hookHealthState = beginHookHealth({
|
|
457
|
+
started_at_ms: hookStartedAt,
|
|
458
|
+
started_rss_bytes: hookStartedRss,
|
|
459
|
+
event_name: eventName,
|
|
460
|
+
adapter,
|
|
461
|
+
payload_bytes: raw.length,
|
|
462
|
+
});
|
|
449
463
|
// Cursor executes the Claude Code project hooks too on hosts wired for both
|
|
450
464
|
// adapters, piping them its own payload (identifiable by the top-level
|
|
451
465
|
// cursor_version envelope field). That stray `--adapter claude-code`
|
|
@@ -454,8 +468,9 @@ async function main() {
|
|
|
454
468
|
// `--adapter cursor` dispatch of the same payload carries the session.
|
|
455
469
|
if (shouldSkipHookAdapter(adapter, raw)) {
|
|
456
470
|
if (coordEnv("AGENT_COORD_OFF") !== "1") {
|
|
457
|
-
const coordRoot =
|
|
471
|
+
const coordRoot = resolveCoordRoot(process.cwd());
|
|
458
472
|
if (coordRoot) {
|
|
473
|
+
hookHealthState.coord_root = coordRoot;
|
|
459
474
|
appendDebug(coordRoot, {
|
|
460
475
|
ts: new Date().toISOString(),
|
|
461
476
|
event_name: eventName,
|
|
@@ -478,7 +493,7 @@ async function main() {
|
|
|
478
493
|
if (adapter === "claude-code" && eventName) {
|
|
479
494
|
const s = soundForEvent(eventName);
|
|
480
495
|
if (s) {
|
|
481
|
-
const repoRoot =
|
|
496
|
+
const repoRoot = resolveCoordRoot(process.cwd());
|
|
482
497
|
if (repoRoot) {
|
|
483
498
|
let sid = "";
|
|
484
499
|
let stopContinuation = false;
|
|
@@ -505,9 +520,13 @@ async function main() {
|
|
|
505
520
|
// bypass during incident triage.
|
|
506
521
|
if (coordEnv("AGENT_COORD_OFF") === "1")
|
|
507
522
|
return 0;
|
|
508
|
-
const coordRoot =
|
|
523
|
+
const coordRoot = resolveCoordRoot(process.cwd());
|
|
509
524
|
if (!coordRoot)
|
|
510
525
|
return 0;
|
|
526
|
+
hookHealthState.coord_root = coordRoot;
|
|
527
|
+
if (eventName === "runtime-context-retry") {
|
|
528
|
+
return runRuntimeContextRetryWorker(coordRoot, adapter, extra);
|
|
529
|
+
}
|
|
511
530
|
const ledgerRoute = resolveLiveEventLedgerRouteV3(coordRoot);
|
|
512
531
|
// Always log a breadcrumb, useful when an event_type maps to null or owner
|
|
513
532
|
// resolution fails. Stays cheap (one append) and self-prunes via repo log
|
|
@@ -526,6 +545,78 @@ async function main() {
|
|
|
526
545
|
appendDebug(coordRoot, { ...debugBase, skipped: "missing-event-or-adapter" });
|
|
527
546
|
return 0;
|
|
528
547
|
}
|
|
548
|
+
// Cursor's preToolUse `agent_message` is only the current narration before
|
|
549
|
+
// that tool. It is not a transcript and therefore cannot prove that an
|
|
550
|
+
// earlier assistant response omitted the required session-name block.
|
|
551
|
+
// afterAgentResponse is the one native boundary that carries the completed
|
|
552
|
+
// assistant text. Preserve only privacy-safe ritual booleans in the V3
|
|
553
|
+
// producer's open-turn state; Stop consumes them into the authoritative
|
|
554
|
+
// turn.completed event. The response body never enters V3 or heartbeat.
|
|
555
|
+
if (adapter === "cursor" && eventName === "after-agent-response") {
|
|
556
|
+
const payload = parsePayload(raw, adapter);
|
|
557
|
+
const owner = resolveOwner({ payload: payload?.raw ?? null, coordRoot });
|
|
558
|
+
if (!owner) {
|
|
559
|
+
appendDebug(coordRoot, { ...debugBase, skipped: "no-owner-resolved" });
|
|
560
|
+
return 0;
|
|
561
|
+
}
|
|
562
|
+
const name = sessionNameDisplayPending(readLiveCoordinationRow(coordRoot, owner.instance_id));
|
|
563
|
+
const text = typeof payload?.raw.text === "string" ? payload.raw.text : "";
|
|
564
|
+
if (name && assistantTextStartsWithSessionNameBlock(text, name)) {
|
|
565
|
+
stampSessionNameSeen(coordRoot, owner.instance_id, name);
|
|
566
|
+
appendDebug(coordRoot, { ...debugBase, effect: "session-name-display-stamped" });
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
appendDebug(coordRoot, { ...debugBase, skipped: "no-session-name-sighting" });
|
|
570
|
+
}
|
|
571
|
+
if (ledgerRoute.state === "blocked") {
|
|
572
|
+
appendDebug(coordRoot, {
|
|
573
|
+
...debugBase,
|
|
574
|
+
skipped: "v3-control-blocked",
|
|
575
|
+
reason: ledgerRoute.reason,
|
|
576
|
+
owner_source: owner.source,
|
|
577
|
+
});
|
|
578
|
+
return 0;
|
|
579
|
+
}
|
|
580
|
+
const statusBoxPresentStrict = scanAssistantStatusBoxPresent(undefined, text);
|
|
581
|
+
// The hook parser needs the completed reply long enough to scan it, but
|
|
582
|
+
// durable hook intake must never retain that body. Keep every other native
|
|
583
|
+
// field so turn correlation remains available to the producer.
|
|
584
|
+
const { text: _completedReply, ...privacySafeRaw } = payload?.raw ?? {};
|
|
585
|
+
const privacySafePayload = payload ? { ...payload, raw: privacySafeRaw } : null;
|
|
586
|
+
const v3Result = recordLiveHookSignalV3({
|
|
587
|
+
coordRoot,
|
|
588
|
+
route: ledgerRoute,
|
|
589
|
+
eventName,
|
|
590
|
+
payload: privacySafePayload,
|
|
591
|
+
adapter,
|
|
592
|
+
instanceId: owner.instance_id,
|
|
593
|
+
hook_name: eventName,
|
|
594
|
+
hook_duration_ms: Math.max(0, Math.floor(performance.now() - hookStartedAt)),
|
|
595
|
+
monotonic_ns: hookClock.monotonic_ns,
|
|
596
|
+
turn_ritual: {
|
|
597
|
+
status_box_present: statusBoxPresentStrict,
|
|
598
|
+
status_box_present_strict: statusBoxPresentStrict,
|
|
599
|
+
session_name_required: name !== undefined,
|
|
600
|
+
session_name_present: name ? assistantTextStartsWithSessionNameBlock(text, name) : false,
|
|
601
|
+
},
|
|
602
|
+
});
|
|
603
|
+
observeHookDebug(hookHealthState, { event_v3_state: v3Result.state });
|
|
604
|
+
appendDebug(coordRoot, {
|
|
605
|
+
...debugBase,
|
|
606
|
+
effect: "cursor-response-ritual-observed",
|
|
607
|
+
owner_source: owner.source,
|
|
608
|
+
event_v3_state: v3Result.state,
|
|
609
|
+
...(v3Result.state === "observed"
|
|
610
|
+
? {
|
|
611
|
+
generation_id: v3Result.generation_id,
|
|
612
|
+
turn_id: v3Result.turn_id,
|
|
613
|
+
response_observed_at: v3Result.observed_at,
|
|
614
|
+
status_box_present_strict: statusBoxPresentStrict,
|
|
615
|
+
}
|
|
616
|
+
: {}),
|
|
617
|
+
});
|
|
618
|
+
return 0;
|
|
619
|
+
}
|
|
529
620
|
const norm = normalizeEventName(eventName);
|
|
530
621
|
if (!norm) {
|
|
531
622
|
appendDebug(coordRoot, { ...debugBase, skipped: "non-canonical-event" });
|
|
@@ -544,7 +635,9 @@ async function main() {
|
|
|
544
635
|
});
|
|
545
636
|
return 0;
|
|
546
637
|
}
|
|
638
|
+
hookHealthState.owner_id = owner.instance_id;
|
|
547
639
|
const sessionId = payload?.session_id ?? payload?.conversation_id ?? owner.instance_id;
|
|
640
|
+
const priorCoordination = readHeartbeat(coordRoot, owner.instance_id);
|
|
548
641
|
const data = buildEventData(norm.event_type, {
|
|
549
642
|
coordRoot,
|
|
550
643
|
payload,
|
|
@@ -609,6 +702,27 @@ async function main() {
|
|
|
609
702
|
...(turnRitual ? { turn_ritual: turnRitual } : {}),
|
|
610
703
|
...(deferV3Drain ? { defer_drain: true } : {}),
|
|
611
704
|
});
|
|
705
|
+
observeHookDebug(hookHealthState, {
|
|
706
|
+
...(v3Result ? { event_v3_state: v3Result.state } : {}),
|
|
707
|
+
});
|
|
708
|
+
const recordedGenerationId = v3Result && "event" in v3Result && "generation_id" in v3Result.event.scope
|
|
709
|
+
? v3Result.event.scope.generation_id
|
|
710
|
+
: undefined;
|
|
711
|
+
if (v3Result?.state === "recorded" || v3Result?.state === "already_started") {
|
|
712
|
+
try {
|
|
713
|
+
restoreLiveCoordinationStateAfterEpochV3({
|
|
714
|
+
coordRoot,
|
|
715
|
+
owner: owner.instance_id,
|
|
716
|
+
nativeSessionId: sessionId,
|
|
717
|
+
adapter,
|
|
718
|
+
prior: priorCoordination,
|
|
719
|
+
currentGenerationId: recordedGenerationId,
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
catch (error) {
|
|
723
|
+
logError(coordRoot, error, { phase: "epoch-coordination-restore" });
|
|
724
|
+
}
|
|
725
|
+
}
|
|
612
726
|
const v3EventId = v3Result && "event" in v3Result
|
|
613
727
|
? v3Result.event.event_id
|
|
614
728
|
: v3Result && "event_id" in v3Result
|
|
@@ -642,7 +756,7 @@ async function main() {
|
|
|
642
756
|
}
|
|
643
757
|
if (v3Result?.state === "recorded" && capturedImages.length > 0) {
|
|
644
758
|
try {
|
|
645
|
-
recordImageArtifactsV3(coordRoot, v3Result.event, capturedImages);
|
|
759
|
+
recordImageArtifactsV3(coordRoot, v3Result.event, capturedImages, ledgerRoute.genesis_id);
|
|
646
760
|
}
|
|
647
761
|
catch (err) {
|
|
648
762
|
logError(coordRoot, err, { phase: "image-artifact-observation" });
|
|
@@ -733,6 +847,44 @@ async function main() {
|
|
|
733
847
|
if (adapter === "claude-code")
|
|
734
848
|
journalJanitor(coordRoot);
|
|
735
849
|
imageJanitor(coordRoot);
|
|
850
|
+
// Session start is the only caller of the artifact janitor and the storage
|
|
851
|
+
// maintenance pass, so both load here instead of on every tool call.
|
|
852
|
+
const { autoCleanArtifacts } = await import("../artifacts/index.js");
|
|
853
|
+
const { autoCleanEventV3Archives } = await import("../events/v3/archive-retention.js");
|
|
854
|
+
const { createAutomaticMaintenanceComposition, runAutomaticMaintenancePass } = await import("../storage/maintenance-providers.js");
|
|
855
|
+
// Effect: throttled daily sweep of expired artifact workspaces (guarded,
|
|
856
|
+
// managed-expired only; see autoCleanArtifacts). Best-effort like every
|
|
857
|
+
// janitor here: a failure logs and never blocks session start.
|
|
858
|
+
try {
|
|
859
|
+
autoCleanArtifacts(coordRoot);
|
|
860
|
+
}
|
|
861
|
+
catch (err) {
|
|
862
|
+
logError(coordRoot, err, { phase: "artifact-auto-clean" });
|
|
863
|
+
}
|
|
864
|
+
// Effect: apply the same daily throttle to closed V3 epochs. The newest
|
|
865
|
+
// recovery epochs remain protected by the archive retention policy.
|
|
866
|
+
try {
|
|
867
|
+
autoCleanEventV3Archives(coordRoot);
|
|
868
|
+
}
|
|
869
|
+
catch (err) {
|
|
870
|
+
logError(coordRoot, err, { phase: "event-v3-archive-auto-clean" });
|
|
871
|
+
}
|
|
872
|
+
// Plan one bounded, claim-first global slice from cached pressure only.
|
|
873
|
+
// Existing owner janitors above remain the only active executors until
|
|
874
|
+
// each provider receives a separate production activation.
|
|
875
|
+
try {
|
|
876
|
+
await runAutomaticMaintenancePass(createAutomaticMaintenanceComposition(coordRoot, {
|
|
877
|
+
journal: () => {
|
|
878
|
+
if (adapter === "claude-code")
|
|
879
|
+
journalJanitor(coordRoot);
|
|
880
|
+
},
|
|
881
|
+
images: () => imageJanitor(coordRoot),
|
|
882
|
+
artifacts: () => autoCleanArtifacts(coordRoot),
|
|
883
|
+
}));
|
|
884
|
+
}
|
|
885
|
+
catch (err) {
|
|
886
|
+
logError(coordRoot, err, { phase: "storage-maintenance-auto" });
|
|
887
|
+
}
|
|
736
888
|
let recovery = null;
|
|
737
889
|
if (payload?.source === "compact") {
|
|
738
890
|
try {
|
|
@@ -759,10 +911,13 @@ async function main() {
|
|
|
759
911
|
catch (err) {
|
|
760
912
|
logError(coordRoot, err, { phase: "session-start-systemMessage" });
|
|
761
913
|
}
|
|
762
|
-
//
|
|
763
|
-
// disposable heartbeat cache.
|
|
914
|
+
// Cross-machine presence is derived from the authority-safe V3 projection,
|
|
915
|
+
// not the disposable heartbeat cache. Announce this session, pull peers,
|
|
916
|
+
// and keep the optional live relay connected.
|
|
764
917
|
try {
|
|
918
|
+
publishPresence(coordRoot);
|
|
765
919
|
fetchPresence(coordRoot);
|
|
920
|
+
ensureRelayDaemon(coordRoot);
|
|
766
921
|
}
|
|
767
922
|
catch (err) {
|
|
768
923
|
logError(coordRoot, err, { phase: "session-start-presence" });
|
|
@@ -772,7 +927,7 @@ async function main() {
|
|
|
772
927
|
// agnostic since v0.5.0.
|
|
773
928
|
if (norm.event_type === "session.ended") {
|
|
774
929
|
try {
|
|
775
|
-
cleanupSessionEnd(coordRoot, owner.instance_id
|
|
930
|
+
cleanupSessionEnd(coordRoot, owner.instance_id);
|
|
776
931
|
}
|
|
777
932
|
catch (err) {
|
|
778
933
|
logError(coordRoot, err, { phase: "session-end-cleanup" });
|
|
@@ -783,6 +938,14 @@ async function main() {
|
|
|
783
938
|
journalArchive(coordRoot, owner.instance_id);
|
|
784
939
|
runSessionSyncExtension(coordRoot, true);
|
|
785
940
|
}
|
|
941
|
+
// Publish the post-cleanup V3 projection so remote machines see this
|
|
942
|
+
// session disappear without waiting for the stale window.
|
|
943
|
+
try {
|
|
944
|
+
publishPresence(coordRoot);
|
|
945
|
+
}
|
|
946
|
+
catch (err) {
|
|
947
|
+
logError(coordRoot, err, { phase: "session-end-presence" });
|
|
948
|
+
}
|
|
786
949
|
}
|
|
787
950
|
// Phase 8: SubagentStart: the child generation was opened above from the
|
|
788
951
|
// native delegation identity. Refresh its disposable projection, log the
|
|
@@ -790,40 +953,17 @@ async function main() {
|
|
|
790
953
|
if (norm.event_type === "agent.started") {
|
|
791
954
|
try {
|
|
792
955
|
const childInstanceId = data.agent_id ?? owner.instance_id;
|
|
793
|
-
|
|
794
|
-
if (existsSync(agentCoordBin)) {
|
|
795
|
-
spawnSync(agentCoordBin, ["project"], {
|
|
796
|
-
encoding: "utf8",
|
|
797
|
-
timeout: 3000,
|
|
798
|
-
env: childEnv(coordRoot),
|
|
799
|
-
});
|
|
800
|
-
spawnSync(agentCoordBin, [
|
|
801
|
-
"log",
|
|
802
|
-
`SUBAGENT_START agent_type=${data.agent_type ?? "unknown"} agent_id=${childInstanceId.slice(0, 8)} platform=${adapterPlatform(adapter)}`,
|
|
803
|
-
"--instance",
|
|
804
|
-
childInstanceId,
|
|
805
|
-
], { encoding: "utf8", timeout: 2000, env: childEnv(coordRoot) });
|
|
806
|
-
}
|
|
807
|
-
emitSubagentStartContext(coordRoot, childInstanceId, sessionId, data, adapter);
|
|
956
|
+
await emitSubagentStartContext(coordRoot, childInstanceId, sessionId, data, adapter);
|
|
808
957
|
}
|
|
809
958
|
catch (err) {
|
|
810
|
-
logError(coordRoot, err, { phase: "subagent-start-
|
|
959
|
+
logError(coordRoot, err, { phase: "subagent-start-context" });
|
|
811
960
|
}
|
|
812
961
|
}
|
|
813
962
|
// Phase 8: SubagentStop: delete subagent heartbeat + log.
|
|
814
963
|
if (norm.event_type === "agent.completed") {
|
|
815
964
|
try {
|
|
816
965
|
const childInstanceId = payload?.subagent_id ?? payload?.agent_id ?? owner.instance_id;
|
|
817
|
-
cleanupSessionEnd(coordRoot, childInstanceId
|
|
818
|
-
const agentCoordBin = coordBinPath("agent-coord", coordRoot) ?? "";
|
|
819
|
-
if (existsSync(agentCoordBin)) {
|
|
820
|
-
spawnSync(agentCoordBin, [
|
|
821
|
-
"log",
|
|
822
|
-
`SUBAGENT_STOP agent_id=${childInstanceId.slice(0, 8)} platform=${adapterPlatform(adapter)}`,
|
|
823
|
-
"--instance",
|
|
824
|
-
childInstanceId,
|
|
825
|
-
], { encoding: "utf8", timeout: 2000, env: childEnv(coordRoot) });
|
|
826
|
-
}
|
|
966
|
+
cleanupSessionEnd(coordRoot, childInstanceId);
|
|
827
967
|
const { reconcileSessionFinalizationV3 } = await import("../agents/session-finalizer-v3.js");
|
|
828
968
|
reconcileSessionFinalizationV3(coordRoot, { archive_observations: [] });
|
|
829
969
|
}
|
|
@@ -885,6 +1025,16 @@ async function main() {
|
|
|
885
1025
|
if (adapter === "claude-code") {
|
|
886
1026
|
runSessionSyncExtension(coordRoot, false);
|
|
887
1027
|
}
|
|
1028
|
+
// Publish after the canonical turn event has landed so the blob carries
|
|
1029
|
+
// current task, activity, and claim state. Re-ensure the relay here because
|
|
1030
|
+
// its daemon intentionally exits when a machine has no live sessions.
|
|
1031
|
+
try {
|
|
1032
|
+
publishPresence(coordRoot);
|
|
1033
|
+
ensureRelayDaemon(coordRoot);
|
|
1034
|
+
}
|
|
1035
|
+
catch (err) {
|
|
1036
|
+
logError(coordRoot, err, { phase: "stop-presence" });
|
|
1037
|
+
}
|
|
888
1038
|
// Stop verdict (V3 ritual + task/status gate). Direct in-process call: the
|
|
889
1039
|
// rule lives in Harnery. agent-hook already emitted this turn.completed
|
|
890
1040
|
// with privacy-safe ritual observations, so the evidence is in the stream.
|
|
@@ -893,6 +1043,8 @@ async function main() {
|
|
|
893
1043
|
instance_id: owner.instance_id,
|
|
894
1044
|
session_id: sessionId,
|
|
895
1045
|
adapter,
|
|
1046
|
+
stop_hook_active: payload?.stop_hook_active === true,
|
|
1047
|
+
status_box_present_strict: data.status_box_present_strict === true,
|
|
896
1048
|
bypass: coordEnv("AGENT_COORD_BYPASS_STOP") === "1",
|
|
897
1049
|
workflow_child: coordEnv("WORKFLOW_CHILD") === "1",
|
|
898
1050
|
});
|
|
@@ -902,13 +1054,16 @@ async function main() {
|
|
|
902
1054
|
// `cap` consecutive blocked stops in one cycle, allow the stop instead
|
|
903
1055
|
// of bouncing the model forever. Cycle boundaries come from the
|
|
904
1056
|
// adapter's continuation flag, so adapters without one are unaffected.
|
|
905
|
-
const {
|
|
906
|
-
|
|
1057
|
+
const { recordRemediationBlock } = await import("./remediation-cap.js");
|
|
1058
|
+
const remediation = recordRemediationBlock(sessionId, payload?.stop_hook_active === true);
|
|
1059
|
+
if (remediation.exceeded) {
|
|
907
1060
|
appendDebug(coordRoot, {
|
|
908
1061
|
...debugBase,
|
|
909
1062
|
skipped: "stop-remediation-cap-exhausted",
|
|
910
1063
|
blocked_rule: verdict.rule,
|
|
1064
|
+
blocked_count: remediation.count,
|
|
911
1065
|
session_id: sessionId,
|
|
1066
|
+
remediation_cycle_anchor: verdict.remediation_cycle_anchor,
|
|
912
1067
|
});
|
|
913
1068
|
}
|
|
914
1069
|
else {
|
|
@@ -937,6 +1092,8 @@ async function main() {
|
|
|
937
1092
|
catch (err) {
|
|
938
1093
|
logError(coordRoot, err, { phase: "stop-explicit-session-finalization" });
|
|
939
1094
|
}
|
|
1095
|
+
if (adapter === "codex")
|
|
1096
|
+
scheduleCodexRuntimeContextRetry(coordRoot, sessionId);
|
|
940
1097
|
}
|
|
941
1098
|
// Phase 7: PreToolUse: heartbeat + pid-map self-heal on every tool call.
|
|
942
1099
|
// Adapter-agnostic: both writes have the same shape regardless of who fired.
|
|
@@ -964,10 +1121,13 @@ async function main() {
|
|
|
964
1121
|
// runs before a name exists; every later tool waits until the exact block
|
|
965
1122
|
// is the first assistant text after the mint result. Cursor supplies
|
|
966
1123
|
// agent_message directly; Claude Code and Codex are resolved from their
|
|
967
|
-
// JSONL transcripts.
|
|
968
|
-
//
|
|
1124
|
+
// JSONL transcripts. Cursor's current narration can provide positive
|
|
1125
|
+
// evidence, but cannot disprove an earlier response; afterAgentResponse
|
|
1126
|
+
// stamps that durable sighting. Later commentary must not erase an
|
|
1127
|
+
// already-correct display, and unavailable evidence must not deadlock
|
|
1128
|
+
// every tool.
|
|
969
1129
|
try {
|
|
970
|
-
const displayAllowed = await enforcePendingSessionNameDisplay(coordRoot, owner.instance_id, adapter, payload);
|
|
1130
|
+
const displayAllowed = await enforcePendingSessionNameDisplay(coordRoot, owner.instance_id, adapter, payload, generationBoundHeartbeat(readHeartbeat(coordRoot, owner.instance_id), recordedGenerationId));
|
|
971
1131
|
if (!displayAllowed)
|
|
972
1132
|
return 0;
|
|
973
1133
|
}
|
|
@@ -1037,8 +1197,45 @@ async function main() {
|
|
|
1037
1197
|
}
|
|
1038
1198
|
return 0;
|
|
1039
1199
|
}
|
|
1040
|
-
|
|
1041
|
-
const
|
|
1200
|
+
function scheduleCodexRuntimeContextRetry(coordRoot, nativeSessionId) {
|
|
1201
|
+
const modulePath = process.argv[1];
|
|
1202
|
+
if (!modulePath)
|
|
1203
|
+
return;
|
|
1204
|
+
try {
|
|
1205
|
+
const child = spawn(process.execPath, [modulePath, "runtime-context-retry", "--adapter", "codex", "--session-id", nativeSessionId], {
|
|
1206
|
+
cwd: coordRoot,
|
|
1207
|
+
detached: true,
|
|
1208
|
+
stdio: "ignore",
|
|
1209
|
+
env: childEnv(coordRoot),
|
|
1210
|
+
});
|
|
1211
|
+
child.unref();
|
|
1212
|
+
}
|
|
1213
|
+
catch (err) {
|
|
1214
|
+
logError(coordRoot, err, { phase: "runtime-context-retry-spawn" });
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
async function runRuntimeContextRetryWorker(coordRoot, adapter, extra) {
|
|
1218
|
+
const nativeSessionId = extraArg(extra, "--session-id");
|
|
1219
|
+
if (adapter !== "codex" || !nativeSessionId)
|
|
1220
|
+
return 0;
|
|
1221
|
+
for (const [index, delayMs] of [400, 1_000].entries()) {
|
|
1222
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
1223
|
+
const route = resolveLiveEventLedgerRouteV3(coordRoot);
|
|
1224
|
+
if (route.state !== "v3")
|
|
1225
|
+
return 0;
|
|
1226
|
+
const result = reconcileLivePendingRuntimeContextV3({
|
|
1227
|
+
coordRoot,
|
|
1228
|
+
route,
|
|
1229
|
+
nativeSessionId,
|
|
1230
|
+
finalAttempt: index === 1,
|
|
1231
|
+
});
|
|
1232
|
+
if (result.state !== "pending" && result.state !== "busy")
|
|
1233
|
+
return 0;
|
|
1234
|
+
}
|
|
1235
|
+
return 0;
|
|
1236
|
+
}
|
|
1237
|
+
async function enforcePendingSessionNameDisplay(coordRoot, instanceId, adapter, payload, coordination) {
|
|
1238
|
+
const name = sessionNameDisplayPending(coordination);
|
|
1042
1239
|
if (!name)
|
|
1043
1240
|
return true;
|
|
1044
1241
|
const command = extractBashCommand(payload?.tool_name, payload?.tool_input);
|
|
@@ -1048,7 +1245,7 @@ async function enforcePendingSessionNameDisplay(coordRoot, instanceId, adapter,
|
|
|
1048
1245
|
? {
|
|
1049
1246
|
state: assistantTextStartsWithSessionNameBlock(payload.agent_message, name)
|
|
1050
1247
|
? "present"
|
|
1051
|
-
: "
|
|
1248
|
+
: "unavailable",
|
|
1052
1249
|
}
|
|
1053
1250
|
: inspectSessionNameDisplayImmediately(
|
|
1054
1251
|
// Codex hook payloads omit transcript_path on every event, which
|
|
@@ -1075,6 +1272,9 @@ async function enforcePendingSessionNameDisplay(coordRoot, instanceId, adapter,
|
|
|
1075
1272
|
emitDeny(adapter, sessionNameDisplayRecoveryInstruction(name, resolveBinName(coordRoot)));
|
|
1076
1273
|
return false;
|
|
1077
1274
|
}
|
|
1275
|
+
function generationBoundHeartbeat(heartbeat, generationId) {
|
|
1276
|
+
return generationId && heartbeat?.v3_generation_id === generationId ? heartbeat : null;
|
|
1277
|
+
}
|
|
1078
1278
|
async function runPreToolUseGuard(coordRoot, instanceId, sessionId, data, adapter) {
|
|
1079
1279
|
const toolName = data.tool_name ?? "";
|
|
1080
1280
|
const rawTargets = collectGuardTargets(toolName, data);
|
|
@@ -1103,40 +1303,19 @@ async function runPreToolUseGuard(coordRoot, instanceId, sessionId, data, adapte
|
|
|
1103
1303
|
}
|
|
1104
1304
|
if (targets.length === 0)
|
|
1105
1305
|
return true;
|
|
1106
|
-
const
|
|
1107
|
-
if (!existsSync(agentCoordBin)) {
|
|
1108
|
-
if (agentsRequireGitFinalization(coordRoot)) {
|
|
1109
|
-
const { emitDeny } = await import("./adapter/output.js");
|
|
1110
|
-
emitDeny(adapter, "Harnery denied the write before mutation because the claim coordinator is unavailable; repair the project's Harnery installation and retry.");
|
|
1111
|
-
return false;
|
|
1112
|
-
}
|
|
1113
|
-
return true;
|
|
1114
|
-
}
|
|
1306
|
+
const { evaluateClaim } = await import("../agents/rules/claim-conflict.js");
|
|
1115
1307
|
// For apply_patch (multi-file), collect siblings so the deny reason names
|
|
1116
1308
|
// them. For single-file tools the array has one entry.
|
|
1117
1309
|
for (const target of targets) {
|
|
1118
|
-
const verdictReq = JSON.stringify({
|
|
1119
|
-
rule: "claim",
|
|
1120
|
-
instance_id: instanceId,
|
|
1121
|
-
session_id: sessionId,
|
|
1122
|
-
path: target.path,
|
|
1123
|
-
});
|
|
1124
|
-
const result = spawnSync(agentCoordBin, ["verdict"], {
|
|
1125
|
-
input: verdictReq,
|
|
1126
|
-
encoding: "utf8",
|
|
1127
|
-
timeout: 3000,
|
|
1128
|
-
env: childEnv(coordRoot),
|
|
1129
|
-
});
|
|
1130
|
-
if (result.status !== 0 || !result.stdout)
|
|
1131
|
-
continue;
|
|
1132
|
-
let parsed = {};
|
|
1133
1310
|
try {
|
|
1134
|
-
parsed =
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1311
|
+
const parsed = evaluateClaim(coordRoot, {
|
|
1312
|
+
rule: "claim",
|
|
1313
|
+
instance_id: instanceId,
|
|
1314
|
+
session_id: sessionId,
|
|
1315
|
+
path: target.path,
|
|
1316
|
+
});
|
|
1317
|
+
if (parsed.allow !== false)
|
|
1318
|
+
continue;
|
|
1140
1319
|
let reason = parsed.reason ?? `Path ${target.path} is currently being edited by another agent.`;
|
|
1141
1320
|
if (targets.length > 1) {
|
|
1142
1321
|
const siblings = targets
|
|
@@ -1152,6 +1331,7 @@ async function runPreToolUseGuard(coordRoot, instanceId, sessionId, data, adapte
|
|
|
1152
1331
|
emitDeny(adapter, reason);
|
|
1153
1332
|
return false;
|
|
1154
1333
|
}
|
|
1334
|
+
catch { }
|
|
1155
1335
|
}
|
|
1156
1336
|
return true;
|
|
1157
1337
|
}
|
|
@@ -1350,16 +1530,23 @@ function releaseClaimOnFailure(coordRoot, instanceId, data, rawPayload) {
|
|
|
1350
1530
|
const row = readLiveCoordinationRow(coordRoot, instanceId);
|
|
1351
1531
|
if (!row?.files_touched?.includes(canonical))
|
|
1352
1532
|
return;
|
|
1353
|
-
const
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1533
|
+
const before = readHeartbeat(coordRoot, instanceId);
|
|
1534
|
+
try {
|
|
1535
|
+
recordLiveClaimChangeV3({
|
|
1536
|
+
coordRoot,
|
|
1537
|
+
owner: instanceId,
|
|
1538
|
+
nativeSessionId: before?.session_id ?? instanceId,
|
|
1539
|
+
adapter: adapterFromPlatform(before?.platform),
|
|
1540
|
+
operation: "released",
|
|
1541
|
+
path: canonical,
|
|
1542
|
+
access: "write",
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
catch {
|
|
1546
|
+
/* best-effort release must not break adapter flow */
|
|
1547
|
+
}
|
|
1361
1548
|
}
|
|
1362
|
-
function cleanupSessionEnd(coordRoot, instanceId
|
|
1549
|
+
function cleanupSessionEnd(coordRoot, instanceId) {
|
|
1363
1550
|
// Sweep pid-map entries pointing to this instance
|
|
1364
1551
|
const pidmapDir = join(coordRoot, ".harnery", "pid-map");
|
|
1365
1552
|
if (existsSync(pidmapDir)) {
|
|
@@ -1383,36 +1570,20 @@ function cleanupSessionEnd(coordRoot, instanceId, reason) {
|
|
|
1383
1570
|
/* swallow */
|
|
1384
1571
|
}
|
|
1385
1572
|
}
|
|
1386
|
-
// Activity log
|
|
1387
|
-
const agentCoordBin = coordBinPath("agent-coord", coordRoot) ?? "";
|
|
1388
|
-
if (existsSync(agentCoordBin)) {
|
|
1389
|
-
spawnSync(agentCoordBin, ["log", `SESSION_END reason=${reason}`, "--instance", instanceId], { encoding: "utf8", timeout: 2000 });
|
|
1390
|
-
}
|
|
1391
1573
|
}
|
|
1392
1574
|
async function emitUserPromptSubmitSystemMessage(coordRoot, instanceId, sessionId, adapter, workspaceCwd, recoveryBriefing = "") {
|
|
1393
|
-
const
|
|
1394
|
-
let additionalContext =
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
args.push("--session-name-nudge");
|
|
1406
|
-
if (adapter === "cursor" || adapter === "codex")
|
|
1407
|
-
args.push("--task-nudge");
|
|
1408
|
-
if (adapter === "codex")
|
|
1409
|
-
args.push("--status-footer-nudge");
|
|
1410
|
-
if (adapter === "claude-code" || adapter === "cursor")
|
|
1411
|
-
args.push("--turn-ritual-nudge", adapter);
|
|
1412
|
-
const result = spawnSync(agentCoordBin, args, { encoding: "utf8", timeout: 3000 });
|
|
1413
|
-
if (result.status === 0 && result.stdout)
|
|
1414
|
-
additionalContext = result.stdout.trim();
|
|
1415
|
-
}
|
|
1575
|
+
const { renderPromptContext } = await import("../agents/render/prompt-context.js");
|
|
1576
|
+
let additionalContext = renderPromptContext({
|
|
1577
|
+
coordRoot,
|
|
1578
|
+
instanceId,
|
|
1579
|
+
sessionId,
|
|
1580
|
+
adapter,
|
|
1581
|
+
sessionNameNudge: true,
|
|
1582
|
+
taskNudge: adapter === "cursor" || adapter === "codex",
|
|
1583
|
+
hostPromptReminder: adapter === "codex",
|
|
1584
|
+
statusFooterNudge: adapter === "codex",
|
|
1585
|
+
turnRitualNudge: adapter === "claude-code" ? adapter : undefined,
|
|
1586
|
+
}).trim();
|
|
1416
1587
|
if (adapter === "codex") {
|
|
1417
1588
|
const fileLinkContext = renderCodexWslFileLinkContext(coordRoot, workspaceCwd);
|
|
1418
1589
|
if (fileLinkContext) {
|
|
@@ -1428,8 +1599,8 @@ async function emitUserPromptSubmitSystemMessage(coordRoot, instanceId, sessionI
|
|
|
1428
1599
|
emitContext(adapter, "UserPromptSubmit", additionalContext);
|
|
1429
1600
|
return true;
|
|
1430
1601
|
}
|
|
1431
|
-
function emitSubagentStartContext(coordRoot, instanceId, sessionId, data, adapter) {
|
|
1432
|
-
// Look up the subagent's assigned name (just-written by
|
|
1602
|
+
async function emitSubagentStartContext(coordRoot, instanceId, sessionId, data, adapter) {
|
|
1603
|
+
// Look up the subagent's assigned name (just-written by the in-process name
|
|
1433
1604
|
// in session.started data) + the parent's short id for the "you are a subagent
|
|
1434
1605
|
// of X" framing.
|
|
1435
1606
|
const subagentName = data.name ?? "";
|
|
@@ -1441,69 +1612,55 @@ function emitSubagentStartContext(coordRoot, instanceId, sessionId, data, adapte
|
|
|
1441
1612
|
// Render peer table inline since the subagent might want to know who else
|
|
1442
1613
|
// is around. Reuse prompt-context (which dedups against the per-owner hash);
|
|
1443
1614
|
// first call will always emit.
|
|
1444
|
-
const agentCoordBin = coordBinPath("agent-coord", coordRoot) ?? "";
|
|
1445
1615
|
let combined = message;
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1616
|
+
const { renderPromptContext } = await import("../agents/render/prompt-context.js");
|
|
1617
|
+
const context = renderPromptContext({
|
|
1618
|
+
coordRoot,
|
|
1619
|
+
instanceId,
|
|
1620
|
+
sessionId,
|
|
1621
|
+
agentName: subagentName,
|
|
1622
|
+
}).trim();
|
|
1623
|
+
if (context)
|
|
1624
|
+
combined = `${message}\n\n${context}`;
|
|
1452
1625
|
// Use SubagentStart event-name in CC's hookSpecificOutput shape; cursor's
|
|
1453
1626
|
// flat `additional_context` works the same way.
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
});
|
|
1627
|
+
const { emitContext } = await import("./adapter/output.js");
|
|
1628
|
+
emitContext(adapter, "SubagentStart", combined);
|
|
1457
1629
|
}
|
|
1458
1630
|
function adapterPlatform(adapter) {
|
|
1459
1631
|
if (adapter === "claude-code")
|
|
1460
1632
|
return "claude-code";
|
|
1461
1633
|
return adapter;
|
|
1462
1634
|
}
|
|
1635
|
+
function adapterFromPlatform(platform) {
|
|
1636
|
+
if (platform === "cursor")
|
|
1637
|
+
return "cursor";
|
|
1638
|
+
if (platform === "codex")
|
|
1639
|
+
return "codex";
|
|
1640
|
+
return "claude-code";
|
|
1641
|
+
}
|
|
1463
1642
|
async function emitSessionStartSystemMessage(coordRoot, instanceId, sessionId, emittedData, adapter, recoveryBriefing = "") {
|
|
1464
|
-
const agentCoordBin = coordBinPath("agent-coord", coordRoot) ?? "";
|
|
1465
1643
|
const workflowChild = coordEnv("WORKFLOW_CHILD") === "1";
|
|
1466
1644
|
let additionalContext = "";
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
const platform = adapterPlatform(adapter);
|
|
1482
|
-
spawnSync(agentCoordBin, [
|
|
1483
|
-
"log",
|
|
1484
|
-
`SESSION_START model=${model} source=${source} platform=${platform}`,
|
|
1485
|
-
"--instance",
|
|
1645
|
+
// Opportunistic reconciliation makes normal session starts a failsafe for
|
|
1646
|
+
// archive, idle, cascade, and host lifecycle observations. It also runs the
|
|
1647
|
+
// stale cache sweep through the shared ADR 0077 composition.
|
|
1648
|
+
const { reconcileCoordinationV3 } = await import("../agents/reconcile-coordination-v3.js");
|
|
1649
|
+
reconcileCoordinationV3(coordRoot);
|
|
1650
|
+
// Workflow children retain lifecycle/event capture but do not receive
|
|
1651
|
+
// operator-facing peer, council, or init-remediation context. Injecting
|
|
1652
|
+
// that context can make a bounded child follow housekeeping instructions
|
|
1653
|
+
// instead of its assigned prompt.
|
|
1654
|
+
if (!workflowChild) {
|
|
1655
|
+
const agentName = emittedData.name ?? "";
|
|
1656
|
+
const { renderSessionContext } = await import("../agents/render/session-context.js");
|
|
1657
|
+
additionalContext = renderSessionContext({
|
|
1658
|
+
coordRoot,
|
|
1486
1659
|
instanceId,
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
// instead of its assigned prompt.
|
|
1492
|
-
if (!workflowChild) {
|
|
1493
|
-
const agentName = emittedData.name ?? "";
|
|
1494
|
-
const args = ["session-context", "--instance", instanceId, "--session", sessionId];
|
|
1495
|
-
if (agentName)
|
|
1496
|
-
args.push("--name", agentName);
|
|
1497
|
-
// The "You are agent-X." prefix in session-context renders unqualified by
|
|
1498
|
-
// default (claude-code-style). For cursor/codex the bash dispatchers add
|
|
1499
|
-
// a "(Cursor)" / "(Codex)" suffix; pass it through as --platform-label.
|
|
1500
|
-
if (adapter !== "claude-code") {
|
|
1501
|
-
args.push("--platform-label", platform === "cursor" ? "Cursor" : "Codex");
|
|
1502
|
-
}
|
|
1503
|
-
const result = spawnSync(agentCoordBin, args, { encoding: "utf8", timeout: 3000 });
|
|
1504
|
-
if (result.status === 0 && result.stdout)
|
|
1505
|
-
additionalContext = result.stdout.trim();
|
|
1506
|
-
}
|
|
1660
|
+
sessionId,
|
|
1661
|
+
agentName: agentName || undefined,
|
|
1662
|
+
platformLabel: adapter === "claude-code" ? undefined : adapter === "cursor" ? "Cursor" : "Codex",
|
|
1663
|
+
}).trim();
|
|
1507
1664
|
}
|
|
1508
1665
|
// Effect (claude-code): merge the journal recovery cue into the session-start
|
|
1509
1666
|
// context. Was a standalone additionalContext emission from the previous
|
|
@@ -1543,11 +1700,27 @@ function completeRecoveryInjection(coordRoot, instanceId, sessionId, recovery) {
|
|
|
1543
1700
|
void recovery;
|
|
1544
1701
|
}
|
|
1545
1702
|
main()
|
|
1546
|
-
.then((code) =>
|
|
1547
|
-
|
|
1548
|
-
|
|
1703
|
+
.then(async (code) => {
|
|
1704
|
+
writeHookHealthCompletion(hookHealthState, {
|
|
1705
|
+
finished_at_ms: performance.now(),
|
|
1706
|
+
finished_rss_bytes: process.memoryUsage().rss,
|
|
1707
|
+
pid: process.pid,
|
|
1708
|
+
});
|
|
1709
|
+
await closeProcessLoggers();
|
|
1710
|
+
process.exit(code);
|
|
1711
|
+
})
|
|
1712
|
+
.catch(async (err) => {
|
|
1713
|
+
logError(resolveCoordRoot(process.cwd()), err, {
|
|
1549
1714
|
argv: process.argv.slice(2),
|
|
1550
1715
|
pid: process.pid,
|
|
1716
|
+
phase: "top-level",
|
|
1717
|
+
});
|
|
1718
|
+
writeHookHealthCompletion(hookHealthState, {
|
|
1719
|
+
finished_at_ms: performance.now(),
|
|
1720
|
+
finished_rss_bytes: process.memoryUsage().rss,
|
|
1721
|
+
pid: process.pid,
|
|
1722
|
+
faulted: true,
|
|
1551
1723
|
});
|
|
1724
|
+
await closeProcessLoggers();
|
|
1552
1725
|
process.exit(0);
|
|
1553
1726
|
});
|