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
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
export interface HarneryLogMetricsDelta {
|
|
5
|
+
accepted?: number;
|
|
6
|
+
encoded?: number;
|
|
7
|
+
appended?: number;
|
|
8
|
+
synced?: number;
|
|
9
|
+
dropped?: number;
|
|
10
|
+
coalesced?: number;
|
|
11
|
+
sampled?: number;
|
|
12
|
+
bytes_accepted?: number;
|
|
13
|
+
bytes_appended?: number;
|
|
14
|
+
bytes_dropped?: number;
|
|
15
|
+
rotations?: number;
|
|
16
|
+
failures?: Record<string, number>;
|
|
17
|
+
append_latency_ms?: number;
|
|
18
|
+
flush_latency_ms?: number;
|
|
19
|
+
queue?: {
|
|
20
|
+
bytes: number;
|
|
21
|
+
capacity_bytes: number;
|
|
22
|
+
peak_bytes: number;
|
|
23
|
+
snapshot_at: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface HarneryLogMetricsV1 {
|
|
28
|
+
schema: "harnery.log-metrics/v1";
|
|
29
|
+
generation: string;
|
|
30
|
+
window_started_at: string;
|
|
31
|
+
last_merge_at: string;
|
|
32
|
+
last_successful_sink_at?: string;
|
|
33
|
+
counters: {
|
|
34
|
+
accepted: number;
|
|
35
|
+
encoded: number;
|
|
36
|
+
appended: number;
|
|
37
|
+
synced: number;
|
|
38
|
+
dropped: number;
|
|
39
|
+
coalesced: number;
|
|
40
|
+
sampled: number;
|
|
41
|
+
bytes_accepted: number;
|
|
42
|
+
bytes_appended: number;
|
|
43
|
+
bytes_dropped: number;
|
|
44
|
+
rotations: number;
|
|
45
|
+
};
|
|
46
|
+
failures: Record<string, number>;
|
|
47
|
+
append_latency_histogram: readonly number[];
|
|
48
|
+
flush_latency_histogram: readonly number[];
|
|
49
|
+
queue?: HarneryLogMetricsDelta["queue"];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const HISTOGRAM_BUCKETS = [1, 2, 5, 10, 25, 50, 100, 250, 500, 1_000, 5_000];
|
|
53
|
+
|
|
54
|
+
export class LogMetricsAccumulator {
|
|
55
|
+
#delta: HarneryLogMetricsDelta = {};
|
|
56
|
+
#peakQueueBytes = 0;
|
|
57
|
+
|
|
58
|
+
increment<K extends keyof HarneryLogMetricsDelta>(key: K, amount = 1): void {
|
|
59
|
+
if (key === "failures" || key === "queue") return;
|
|
60
|
+
const current = this.#delta[key];
|
|
61
|
+
if (typeof current === "number") this.#delta[key] = (current + amount) as never;
|
|
62
|
+
else this.#delta[key] = amount as never;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
failure(reason: string, amount = 1): void {
|
|
66
|
+
if (!this.#delta.failures) this.#delta.failures = {};
|
|
67
|
+
const failures = this.#delta.failures;
|
|
68
|
+
failures[reason] = (failures[reason] ?? 0) + amount;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
observeQueue(bytes: number, capacityBytes: number, now: Date): void {
|
|
72
|
+
this.#peakQueueBytes = Math.max(this.#peakQueueBytes, bytes);
|
|
73
|
+
this.#delta.queue = {
|
|
74
|
+
bytes,
|
|
75
|
+
capacity_bytes: capacityBytes,
|
|
76
|
+
peak_bytes: this.#peakQueueBytes,
|
|
77
|
+
snapshot_at: now.toISOString(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
observeLatency(kind: "append_latency_ms" | "flush_latency_ms", milliseconds: number): void {
|
|
82
|
+
this.#delta[kind] = Math.max(0, milliseconds);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
take(): HarneryLogMetricsDelta {
|
|
86
|
+
const delta = this.#delta;
|
|
87
|
+
this.#delta = {};
|
|
88
|
+
this.#peakQueueBytes = 0;
|
|
89
|
+
return delta;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function mergeMetricsSidecar(
|
|
94
|
+
path: string,
|
|
95
|
+
delta: HarneryLogMetricsDelta,
|
|
96
|
+
now = new Date(),
|
|
97
|
+
): { merged: boolean; generation_reset: boolean } {
|
|
98
|
+
let current: HarneryLogMetricsV1;
|
|
99
|
+
let generationReset = false;
|
|
100
|
+
try {
|
|
101
|
+
current = existsSync(path)
|
|
102
|
+
? validateMetrics(JSON.parse(readFileSync(path, "utf8")))
|
|
103
|
+
: emptyMetrics(now);
|
|
104
|
+
generationReset = !existsSync(path);
|
|
105
|
+
} catch {
|
|
106
|
+
current = emptyMetrics(now);
|
|
107
|
+
generationReset = true;
|
|
108
|
+
}
|
|
109
|
+
const merged = mergeMetrics(current, delta, now);
|
|
110
|
+
const temporary = `${path}.tmp-${process.pid}-${randomUUID()}`;
|
|
111
|
+
try {
|
|
112
|
+
writeFileSync(temporary, `${JSON.stringify(merged)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
113
|
+
renameSync(temporary, path);
|
|
114
|
+
return { merged: true, generation_reset: generationReset };
|
|
115
|
+
} catch {
|
|
116
|
+
return { merged: false, generation_reset: generationReset };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function readMetricsSidecar(path: string): HarneryLogMetricsV1 | undefined {
|
|
121
|
+
if (!existsSync(path)) return undefined;
|
|
122
|
+
try {
|
|
123
|
+
return validateMetrics(JSON.parse(readFileSync(path, "utf8")));
|
|
124
|
+
} catch {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function mergeMetrics(
|
|
130
|
+
current: HarneryLogMetricsV1,
|
|
131
|
+
delta: HarneryLogMetricsDelta,
|
|
132
|
+
now: Date,
|
|
133
|
+
): HarneryLogMetricsV1 {
|
|
134
|
+
const counters = { ...current.counters };
|
|
135
|
+
for (const key of Object.keys(counters) as Array<keyof typeof counters>) {
|
|
136
|
+
counters[key] += delta[key] ?? 0;
|
|
137
|
+
}
|
|
138
|
+
const failures = { ...current.failures };
|
|
139
|
+
for (const [reason, count] of Object.entries(delta.failures ?? {})) {
|
|
140
|
+
failures[reason] = (failures[reason] ?? 0) + count;
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
...current,
|
|
144
|
+
last_merge_at: now.toISOString(),
|
|
145
|
+
...(delta.appended ? { last_successful_sink_at: now.toISOString() } : {}),
|
|
146
|
+
counters,
|
|
147
|
+
failures,
|
|
148
|
+
append_latency_histogram: addHistogram(
|
|
149
|
+
current.append_latency_histogram,
|
|
150
|
+
delta.append_latency_ms,
|
|
151
|
+
),
|
|
152
|
+
flush_latency_histogram: addHistogram(current.flush_latency_histogram, delta.flush_latency_ms),
|
|
153
|
+
...(delta.queue ? { queue: delta.queue } : {}),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function emptyMetrics(now: Date): HarneryLogMetricsV1 {
|
|
158
|
+
return {
|
|
159
|
+
schema: "harnery.log-metrics/v1",
|
|
160
|
+
generation: randomUUID(),
|
|
161
|
+
window_started_at: now.toISOString(),
|
|
162
|
+
last_merge_at: now.toISOString(),
|
|
163
|
+
counters: {
|
|
164
|
+
accepted: 0,
|
|
165
|
+
encoded: 0,
|
|
166
|
+
appended: 0,
|
|
167
|
+
synced: 0,
|
|
168
|
+
dropped: 0,
|
|
169
|
+
coalesced: 0,
|
|
170
|
+
sampled: 0,
|
|
171
|
+
bytes_accepted: 0,
|
|
172
|
+
bytes_appended: 0,
|
|
173
|
+
bytes_dropped: 0,
|
|
174
|
+
rotations: 0,
|
|
175
|
+
},
|
|
176
|
+
failures: {},
|
|
177
|
+
append_latency_histogram: HISTOGRAM_BUCKETS.map(() => 0),
|
|
178
|
+
flush_latency_histogram: HISTOGRAM_BUCKETS.map(() => 0),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function addHistogram(current: readonly number[], value: number | undefined): number[] {
|
|
183
|
+
const next = [...current];
|
|
184
|
+
if (value === undefined) return next;
|
|
185
|
+
const index = HISTOGRAM_BUCKETS.findIndex((bucket) => value <= bucket);
|
|
186
|
+
next[index < 0 ? next.length - 1 : index] += 1;
|
|
187
|
+
return next;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function validateMetrics(value: unknown): HarneryLogMetricsV1 {
|
|
191
|
+
if (
|
|
192
|
+
!value ||
|
|
193
|
+
typeof value !== "object" ||
|
|
194
|
+
(value as HarneryLogMetricsV1).schema !== "harnery.log-metrics/v1"
|
|
195
|
+
) {
|
|
196
|
+
throw new Error("invalid metrics sidecar");
|
|
197
|
+
}
|
|
198
|
+
return value as HarneryLogMetricsV1;
|
|
199
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HarneryStorageBudget,
|
|
3
|
+
HarneryStorageFamily,
|
|
4
|
+
HarneryStoragePolicy,
|
|
5
|
+
} from "./contract.ts";
|
|
6
|
+
|
|
7
|
+
export class HarneryStoragePolicyError extends Error {
|
|
8
|
+
constructor(message: string) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "HarneryStoragePolicyError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const UNITS = new Set(["milliseconds", "bytes", "files", "records"]);
|
|
15
|
+
const RETENTION_MODES = new Set([
|
|
16
|
+
"indefinite",
|
|
17
|
+
"oldest-sealed",
|
|
18
|
+
"owner-lifecycle",
|
|
19
|
+
"ttl",
|
|
20
|
+
"expired-only",
|
|
21
|
+
"delegated",
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
export function validateStoragePolicy(
|
|
25
|
+
value: unknown,
|
|
26
|
+
label = "storage policy",
|
|
27
|
+
): asserts value is HarneryStoragePolicy {
|
|
28
|
+
const policy = record(value, `${label} must be an object`);
|
|
29
|
+
if (policy.schema !== "harnery.storage-policy/v1") fail(label, "has an unsupported schema");
|
|
30
|
+
if (!identifier(policy.policy_version)) fail(label, "has an invalid policy_version");
|
|
31
|
+
if (policy.writes !== "active" && policy.writes !== "disabled") {
|
|
32
|
+
fail(label, "has an invalid writes state");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const rotation = record(policy.rotation, `${label}.rotation must be an object`);
|
|
36
|
+
if (!new Set(["none", "size", "owner-protocol"]).has(String(rotation.mode))) {
|
|
37
|
+
fail(label, "has an invalid rotation mode");
|
|
38
|
+
}
|
|
39
|
+
budget(rotation.max_segment_bytes, "bytes", `${label}.rotation.max_segment_bytes`);
|
|
40
|
+
budget(rotation.max_open_age, "milliseconds", `${label}.rotation.max_open_age`);
|
|
41
|
+
|
|
42
|
+
const retention = record(policy.retention, `${label}.retention must be an object`);
|
|
43
|
+
if (!new Set(["active", "proposed", "inactive"]).has(String(retention.status))) {
|
|
44
|
+
fail(label, "has an invalid retention status");
|
|
45
|
+
}
|
|
46
|
+
if (!RETENTION_MODES.has(String(retention.mode))) fail(label, "has an invalid retention mode");
|
|
47
|
+
budget(retention.max_age, "milliseconds", `${label}.retention.max_age`);
|
|
48
|
+
budget(retention.max_bytes, "bytes", `${label}.retention.max_bytes`);
|
|
49
|
+
budget(retention.max_files, "files", `${label}.retention.max_files`);
|
|
50
|
+
budget(retention.max_records, "records", `${label}.retention.max_records`);
|
|
51
|
+
if (!nonempty(retention.reason)) fail(label, "must explain its retention rule");
|
|
52
|
+
|
|
53
|
+
const records = record(policy.records, `${label}.records must be an object`);
|
|
54
|
+
budget(records.max_record_bytes, "bytes", `${label}.records.max_record_bytes`);
|
|
55
|
+
|
|
56
|
+
const privacy = record(policy.privacy, `${label}.privacy must be an object`);
|
|
57
|
+
if (!new Set(["private", "internal-metadata", "public"]).has(String(privacy.sensitivity))) {
|
|
58
|
+
fail(label, "has an invalid privacy sensitivity");
|
|
59
|
+
}
|
|
60
|
+
if (!new Set(["metadata-only", "owner-content", "public-content"]).has(String(privacy.content))) {
|
|
61
|
+
fail(label, "has an invalid privacy content class");
|
|
62
|
+
}
|
|
63
|
+
if (
|
|
64
|
+
!Array.isArray(privacy.forbidden_fields) ||
|
|
65
|
+
privacy.forbidden_fields.some((field) => !nonempty(field)) ||
|
|
66
|
+
new Set(privacy.forbidden_fields).size !== privacy.forbidden_fields.length
|
|
67
|
+
) {
|
|
68
|
+
fail(label, "has invalid forbidden_fields");
|
|
69
|
+
}
|
|
70
|
+
if (
|
|
71
|
+
!new Set(["fail-closed", "best-effort", "reject-before-write", "owner-protocol"]).has(
|
|
72
|
+
String(policy.failure_behavior),
|
|
73
|
+
)
|
|
74
|
+
) {
|
|
75
|
+
fail(label, "has an invalid failure_behavior");
|
|
76
|
+
}
|
|
77
|
+
if (policy.reconstruction_source !== undefined && !nonempty(policy.reconstruction_source)) {
|
|
78
|
+
fail(label, "has an invalid reconstruction_source");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function validateFamilyPolicy(family: HarneryStorageFamily): void {
|
|
83
|
+
validateStoragePolicy(family.policy, `storage family ${family.id} policy`);
|
|
84
|
+
if (family.policy.privacy.sensitivity !== family.sensitivity) {
|
|
85
|
+
throw new HarneryStoragePolicyError(
|
|
86
|
+
`storage family ${family.id} policy sensitivity does not match its descriptor`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
if (family.storage_class === "repairable-cache" && !family.policy.reconstruction_source) {
|
|
90
|
+
throw new HarneryStoragePolicyError(
|
|
91
|
+
`storage family ${family.id} repairable cache must name its reconstruction source`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
if (
|
|
95
|
+
(family.storage_class === "operational-log" || family.storage_class === "debug-log") &&
|
|
96
|
+
family.policy.retention.status === "active" &&
|
|
97
|
+
family.policy.retention.mode === "indefinite"
|
|
98
|
+
) {
|
|
99
|
+
throw new HarneryStoragePolicyError(
|
|
100
|
+
`storage family ${family.id} active log retention cannot be indefinite`,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function budget(value: unknown, unit: HarneryStorageBudget["unit"], label: string): void {
|
|
106
|
+
const candidate = record(value, `${label} must be an object`);
|
|
107
|
+
if (!UNITS.has(String(candidate.unit)) || candidate.unit !== unit) {
|
|
108
|
+
throw new HarneryStoragePolicyError(`${label} must use ${unit}`);
|
|
109
|
+
}
|
|
110
|
+
if (candidate.limit === null) {
|
|
111
|
+
if (!nonempty(candidate.unbounded_reason)) {
|
|
112
|
+
throw new HarneryStoragePolicyError(`${label} is unbounded without a reason`);
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!Number.isSafeInteger(candidate.limit) || (candidate.limit as number) <= 0) {
|
|
117
|
+
throw new HarneryStoragePolicyError(`${label} limit must be a positive safe integer or null`);
|
|
118
|
+
}
|
|
119
|
+
if (candidate.unbounded_reason !== undefined) {
|
|
120
|
+
throw new HarneryStoragePolicyError(`${label} has a limit and an unbounded_reason`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function record(value: unknown, message: string): Record<string, unknown> {
|
|
125
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
126
|
+
throw new HarneryStoragePolicyError(message);
|
|
127
|
+
}
|
|
128
|
+
return value as Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function identifier(value: unknown): boolean {
|
|
132
|
+
return typeof value === "string" && /^[a-z0-9][a-z0-9._-]{0,63}$/.test(value);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function nonempty(value: unknown): value is string {
|
|
136
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function fail(label: string, detail: string): never {
|
|
140
|
+
throw new HarneryStoragePolicyError(`${label} ${detail}`);
|
|
141
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { type ChildProcess, spawn, spawnSync } from "node:child_process";
|
|
2
|
+
import {
|
|
3
|
+
closeSync,
|
|
4
|
+
existsSync,
|
|
5
|
+
fdatasyncSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
openSync,
|
|
8
|
+
renameSync,
|
|
9
|
+
statSync,
|
|
10
|
+
writeSync,
|
|
11
|
+
} from "node:fs";
|
|
12
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
import { createStorageCatalog } from "./catalog.ts";
|
|
15
|
+
import { familyLogDirectory } from "./segments.ts";
|
|
16
|
+
|
|
17
|
+
export interface RotatingTextSinkOptions {
|
|
18
|
+
path: string;
|
|
19
|
+
max_bytes: number;
|
|
20
|
+
backups?: number;
|
|
21
|
+
durable?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ProcessLogDestinationOptions {
|
|
25
|
+
coord_root: string;
|
|
26
|
+
project_root?: string;
|
|
27
|
+
family_id: string;
|
|
28
|
+
filename: string;
|
|
29
|
+
legacy_path: string;
|
|
30
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface RotatingProcessOptions {
|
|
34
|
+
path: string;
|
|
35
|
+
command: string;
|
|
36
|
+
arguments?: string[];
|
|
37
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
38
|
+
max_bytes?: number;
|
|
39
|
+
backups?: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const DEFAULT_PROCESS_LOG_BYTES = 5 * 1024 * 1024;
|
|
43
|
+
const DEFAULT_PROCESS_LOG_BACKUPS = 3;
|
|
44
|
+
|
|
45
|
+
/** Resolve one catalog-owned partition path, with an explicit legacy rollback. */
|
|
46
|
+
export function processLogDestination(options: ProcessLogDestinationOptions): string {
|
|
47
|
+
const env = options.env ?? process.env;
|
|
48
|
+
if (env.HARNERY_SHARED_LOGS === "0") return resolve(options.legacy_path);
|
|
49
|
+
if (
|
|
50
|
+
basename(options.filename) !== options.filename ||
|
|
51
|
+
!/^[a-z0-9][a-z0-9.-]*$/i.test(options.filename)
|
|
52
|
+
) {
|
|
53
|
+
throw new Error("invalid process log filename");
|
|
54
|
+
}
|
|
55
|
+
const catalog = createStorageCatalog({
|
|
56
|
+
coord_root: resolve(options.coord_root),
|
|
57
|
+
project_root: resolve(options.project_root ?? options.coord_root),
|
|
58
|
+
});
|
|
59
|
+
return join(familyLogDirectory(catalog.require(options.family_id)), options.filename);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class RotatingTextSink {
|
|
63
|
+
readonly #options: Required<RotatingTextSinkOptions>;
|
|
64
|
+
#closed = false;
|
|
65
|
+
|
|
66
|
+
constructor(options: RotatingTextSinkOptions) {
|
|
67
|
+
if (!Number.isSafeInteger(options.max_bytes) || options.max_bytes <= 0)
|
|
68
|
+
throw new Error("invalid text log size limit");
|
|
69
|
+
const backups = options.backups ?? 3;
|
|
70
|
+
if (!Number.isSafeInteger(backups) || backups < 1)
|
|
71
|
+
throw new Error("invalid text log backup limit");
|
|
72
|
+
this.#options = {
|
|
73
|
+
...options,
|
|
74
|
+
backups,
|
|
75
|
+
durable: options.durable ?? false,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
append(text: string): void {
|
|
80
|
+
if (this.#closed) throw new Error("text sink is closed");
|
|
81
|
+
const bytes = Buffer.from(text, "utf8");
|
|
82
|
+
mkdirSync(dirname(this.#options.path), { recursive: true, mode: 0o700 });
|
|
83
|
+
let offset = 0;
|
|
84
|
+
while (offset < bytes.byteLength) {
|
|
85
|
+
let current = existsSync(this.#options.path) ? statSync(this.#options.path).size : 0;
|
|
86
|
+
if (current >= this.#options.max_bytes) {
|
|
87
|
+
this.#rotate();
|
|
88
|
+
current = 0;
|
|
89
|
+
}
|
|
90
|
+
const length = Math.min(bytes.byteLength - offset, this.#options.max_bytes - current);
|
|
91
|
+
const fd = openSync(this.#options.path, "a", 0o600);
|
|
92
|
+
try {
|
|
93
|
+
writeSync(fd, bytes.subarray(offset, offset + length));
|
|
94
|
+
if (this.#options.durable) fdatasyncSync(fd);
|
|
95
|
+
} finally {
|
|
96
|
+
closeSync(fd);
|
|
97
|
+
}
|
|
98
|
+
offset += length;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
startGeneration(): void {
|
|
103
|
+
if (this.#closed) throw new Error("text sink is closed");
|
|
104
|
+
if (existsSync(this.#options.path) && statSync(this.#options.path).size > 0) this.#rotate();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
flush(): void {}
|
|
108
|
+
close(): void {
|
|
109
|
+
this.#closed = true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#rotate(): void {
|
|
113
|
+
for (let index = this.#options.backups; index >= 1; index -= 1) {
|
|
114
|
+
const from = index === 1 ? this.#options.path : `${this.#options.path}.${index - 1}`;
|
|
115
|
+
const to = `${this.#options.path}.${index}`;
|
|
116
|
+
if (existsSync(from)) renameSync(from, to);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Spawn a detached-compatible Bun wrapper that continuously rotates child stdout/stderr. */
|
|
122
|
+
export function spawnRotatingProcess(options: RotatingProcessOptions): ChildProcess {
|
|
123
|
+
const path = resolve(options.path);
|
|
124
|
+
const sink = new RotatingTextSink({
|
|
125
|
+
path,
|
|
126
|
+
max_bytes: options.max_bytes ?? DEFAULT_PROCESS_LOG_BYTES,
|
|
127
|
+
backups: options.backups ?? DEFAULT_PROCESS_LOG_BACKUPS,
|
|
128
|
+
});
|
|
129
|
+
sink.startGeneration();
|
|
130
|
+
sink.close();
|
|
131
|
+
const specification = JSON.stringify({
|
|
132
|
+
path,
|
|
133
|
+
max_bytes: options.max_bytes ?? DEFAULT_PROCESS_LOG_BYTES,
|
|
134
|
+
backups: options.backups ?? DEFAULT_PROCESS_LOG_BACKUPS,
|
|
135
|
+
command: options.command,
|
|
136
|
+
arguments: options.arguments ?? [],
|
|
137
|
+
});
|
|
138
|
+
return spawn("bun", [fileURLToPath(import.meta.url), "--run", specification], {
|
|
139
|
+
detached: true,
|
|
140
|
+
stdio: "ignore",
|
|
141
|
+
env: { ...(options.env ?? process.env) } as NodeJS.ProcessEnv,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Run a short process synchronously while keeping its captured output bounded. */
|
|
146
|
+
export function runRotatingProcessSync(options: RotatingProcessOptions): number | null {
|
|
147
|
+
const sink = new RotatingTextSink({
|
|
148
|
+
path: options.path,
|
|
149
|
+
max_bytes: options.max_bytes ?? DEFAULT_PROCESS_LOG_BYTES,
|
|
150
|
+
backups: options.backups ?? DEFAULT_PROCESS_LOG_BACKUPS,
|
|
151
|
+
});
|
|
152
|
+
sink.startGeneration();
|
|
153
|
+
const result = spawnSync(options.command, options.arguments ?? [], {
|
|
154
|
+
encoding: "utf8",
|
|
155
|
+
env: { ...(options.env ?? process.env) } as NodeJS.ProcessEnv,
|
|
156
|
+
});
|
|
157
|
+
if (result.stdout) sink.append(result.stdout);
|
|
158
|
+
if (result.stderr) sink.append(result.stderr);
|
|
159
|
+
if (result.error) sink.append(`${result.error.message}\n`);
|
|
160
|
+
sink.close();
|
|
161
|
+
return result.status;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async function runProcessLogWorker(raw: string | undefined): Promise<void> {
|
|
165
|
+
const parsed = JSON.parse(raw ?? "null") as RotatingProcessOptions | null;
|
|
166
|
+
if (!parsed || typeof parsed.command !== "string" || !Array.isArray(parsed.arguments)) {
|
|
167
|
+
throw new Error("invalid process log worker specification");
|
|
168
|
+
}
|
|
169
|
+
const sink = new RotatingTextSink({
|
|
170
|
+
path: resolve(parsed.path),
|
|
171
|
+
max_bytes: parsed.max_bytes ?? DEFAULT_PROCESS_LOG_BYTES,
|
|
172
|
+
backups: parsed.backups ?? DEFAULT_PROCESS_LOG_BACKUPS,
|
|
173
|
+
});
|
|
174
|
+
sink.startGeneration();
|
|
175
|
+
const child = spawn(parsed.command, parsed.arguments, {
|
|
176
|
+
env: process.env,
|
|
177
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
178
|
+
});
|
|
179
|
+
child.stdout?.setEncoding("utf8");
|
|
180
|
+
child.stderr?.setEncoding("utf8");
|
|
181
|
+
child.stdout?.on("data", (chunk) => sink.append(String(chunk)));
|
|
182
|
+
child.stderr?.on("data", (chunk) => sink.append(String(chunk)));
|
|
183
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"] as const) {
|
|
184
|
+
process.on(signal, () => child.kill(signal));
|
|
185
|
+
}
|
|
186
|
+
const code = await new Promise<number>((resolveExit) => {
|
|
187
|
+
child.once("error", (error) => {
|
|
188
|
+
sink.append(`${error.message}\n`);
|
|
189
|
+
resolveExit(1);
|
|
190
|
+
});
|
|
191
|
+
child.once("exit", (exitCode) => resolveExit(exitCode ?? 1));
|
|
192
|
+
});
|
|
193
|
+
sink.close();
|
|
194
|
+
process.exitCode = code;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const invokedPath = process.argv[1] ? resolve(process.argv[1]) : "";
|
|
198
|
+
if (invokedPath === resolve(fileURLToPath(import.meta.url)) && process.argv[2] === "--run") {
|
|
199
|
+
void runProcessLogWorker(process.argv[3]).catch((error) => {
|
|
200
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
201
|
+
process.exitCode = 1;
|
|
202
|
+
});
|
|
203
|
+
}
|