harnery 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commander.d.ts +30 -5
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +124 -96
- package/dist/commands/agents.d.ts +23 -3
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +379 -198
- 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 +5 -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/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 +22 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +113 -0
- package/dist/commands/governor.js +14 -12
- package/dist/commands/inbox.d.ts +5 -0
- package/dist/commands/inbox.d.ts.map +1 -0
- package/dist/commands/inbox.js +57 -0
- package/dist/commands/init.d.ts +4 -5
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +63 -13
- package/dist/commands/ledger-v3.d.ts.map +1 -1
- package/dist/commands/ledger-v3.js +347 -1
- package/dist/commands/logs.d.ts +4 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +169 -0
- package/dist/commands/messages.d.ts +5 -0
- package/dist/commands/messages.d.ts.map +1 -0
- package/dist/commands/messages.js +45 -0
- package/dist/commands/outline.d.ts +1 -1
- package/dist/commands/outline.d.ts.map +1 -1
- package/dist/commands/outline.js +2 -2
- package/dist/commands/read.d.ts +1 -1
- package/dist/commands/read.d.ts.map +1 -1
- package/dist/commands/read.js +2 -2
- package/dist/commands/semantic.d.ts.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/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 +67 -7
- package/dist/commands/work.js +3 -3
- package/dist/commands/workflow.js +13 -13
- package/dist/core/adapters/profiles.d.ts +1 -1
- package/dist/core/agents/cli.js +209 -39
- 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/render/prompt-context.d.ts +9 -3
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +24 -7
- 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 +94 -13
- package/dist/core/agents/rules/verdict.d.ts +1 -0
- package/dist/core/agents/rules/verdict.d.ts.map +1 -1
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +4 -0
- package/dist/core/agents/session-finalization-state-v3.js +1 -1
- package/dist/core/agents/session-finalizer-v3.js +5 -1
- package/dist/core/agents/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 +21 -0
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +46 -1
- package/dist/core/config.d.ts +62 -4
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +98 -4
- package/dist/core/conversations/archive.d.ts +49 -0
- package/dist/core/conversations/archive.d.ts.map +1 -0
- package/dist/core/conversations/archive.js +136 -0
- package/dist/core/conversations/catalog.d.ts +10 -0
- package/dist/core/conversations/catalog.d.ts.map +1 -0
- package/dist/core/conversations/catalog.js +72 -0
- package/dist/core/conversations/context-pack.d.ts +6 -0
- package/dist/core/conversations/context-pack.d.ts.map +1 -0
- package/dist/core/conversations/context-pack.js +60 -0
- package/dist/core/conversations/contract.d.ts +155 -0
- package/dist/core/conversations/contract.d.ts.map +1 -0
- package/dist/core/conversations/contract.js +1 -0
- package/dist/core/conversations/evaluation.d.ts +16 -0
- package/dist/core/conversations/evaluation.d.ts.map +1 -0
- package/dist/core/conversations/evaluation.js +9 -0
- package/dist/core/conversations/index.d.ts +10 -0
- package/dist/core/conversations/index.d.ts.map +1 -0
- package/dist/core/conversations/index.js +9 -0
- package/dist/core/conversations/lifecycle.d.ts +28 -0
- package/dist/core/conversations/lifecycle.d.ts.map +1 -0
- package/dist/core/conversations/lifecycle.js +29 -0
- package/dist/core/conversations/normalize.d.ts +14 -0
- package/dist/core/conversations/normalize.d.ts.map +1 -0
- package/dist/core/conversations/normalize.js +82 -0
- package/dist/core/conversations/query.d.ts +8 -0
- package/dist/core/conversations/query.d.ts.map +1 -0
- package/dist/core/conversations/query.js +280 -0
- package/dist/core/conversations/search-index.d.ts +9 -0
- package/dist/core/conversations/search-index.d.ts.map +1 -0
- package/dist/core/conversations/search-index.js +29 -0
- package/dist/core/events/legacy-storage/canary.d.ts +18 -0
- package/dist/core/events/legacy-storage/canary.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/canary.js +150 -0
- package/dist/core/events/legacy-storage/fence.d.ts +15 -0
- package/dist/core/events/legacy-storage/fence.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/fence.js +115 -0
- package/dist/core/events/legacy-storage/index.d.ts +6 -0
- package/dist/core/events/legacy-storage/index.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/index.js +5 -0
- package/dist/core/events/legacy-storage/inventory.d.ts +10 -0
- package/dist/core/events/legacy-storage/inventory.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/inventory.js +40 -0
- package/dist/core/events/legacy-storage/manifest.d.ts +23 -0
- package/dist/core/events/legacy-storage/manifest.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/manifest.js +108 -0
- package/dist/core/events/legacy-storage/reader.d.ts +15 -0
- package/dist/core/events/legacy-storage/reader.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/reader.js +154 -0
- package/dist/core/events/v3/authority-outbox.d.ts +7 -2
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
- package/dist/core/events/v3/authority-outbox.js +16 -3
- package/dist/core/events/v3/base-contract.d.ts +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.js +3 -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 +4 -2
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +3 -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 +45 -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.js +1 -1
- 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 +25 -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 +55 -1
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +353 -24
- 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 +4 -2
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +13 -5
- package/dist/core/hooks/adapter/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 +212 -30
- package/dist/core/hooks/effects/image-capture.d.ts +1 -1
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +4 -2
- package/dist/core/hooks/remediation-cap.d.ts +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/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/buffer.d.ts +28 -0
- package/dist/core/storage/buffer.d.ts.map +1 -0
- package/dist/core/storage/buffer.js +101 -0
- package/dist/core/storage/builtins.d.ts +3 -0
- package/dist/core/storage/builtins.d.ts.map +1 -0
- package/dist/core/storage/builtins.js +683 -0
- package/dist/core/storage/catalog.d.ts +19 -0
- package/dist/core/storage/catalog.d.ts.map +1 -0
- package/dist/core/storage/catalog.js +365 -0
- package/dist/core/storage/config.d.ts +16 -0
- package/dist/core/storage/config.d.ts.map +1 -0
- package/dist/core/storage/config.js +311 -0
- package/dist/core/storage/contract.d.ts +275 -0
- package/dist/core/storage/contract.d.ts.map +1 -0
- package/dist/core/storage/contract.js +3 -0
- package/dist/core/storage/durable-history.d.ts +36 -0
- package/dist/core/storage/durable-history.d.ts.map +1 -0
- package/dist/core/storage/durable-history.js +606 -0
- package/dist/core/storage/health.d.ts +4 -0
- package/dist/core/storage/health.d.ts.map +1 -0
- package/dist/core/storage/health.js +65 -0
- package/dist/core/storage/index.d.ts +16 -0
- package/dist/core/storage/index.d.ts.map +1 -0
- package/dist/core/storage/index.js +15 -0
- package/dist/core/storage/inventory.d.ts +25 -0
- package/dist/core/storage/inventory.d.ts.map +1 -0
- package/dist/core/storage/inventory.js +666 -0
- package/dist/core/storage/jsonl.d.ts +52 -0
- package/dist/core/storage/jsonl.d.ts.map +1 -0
- package/dist/core/storage/jsonl.js +156 -0
- package/dist/core/storage/log-retention.d.ts +52 -0
- package/dist/core/storage/log-retention.d.ts.map +1 -0
- package/dist/core/storage/log-retention.js +419 -0
- package/dist/core/storage/logger.d.ts +82 -0
- package/dist/core/storage/logger.d.ts.map +1 -0
- package/dist/core/storage/logger.js +411 -0
- package/dist/core/storage/maintenance-providers.d.ts +26 -0
- package/dist/core/storage/maintenance-providers.d.ts.map +1 -0
- package/dist/core/storage/maintenance-providers.js +141 -0
- package/dist/core/storage/maintenance.d.ts +125 -0
- package/dist/core/storage/maintenance.d.ts.map +1 -0
- package/dist/core/storage/maintenance.js +609 -0
- package/dist/core/storage/metrics.d.ts +60 -0
- package/dist/core/storage/metrics.d.ts.map +1 -0
- package/dist/core/storage/metrics.js +134 -0
- package/dist/core/storage/policy.d.ts +7 -0
- package/dist/core/storage/policy.d.ts.map +1 -0
- package/dist/core/storage/policy.js +110 -0
- package/dist/core/storage/process-log.d.ts +38 -0
- package/dist/core/storage/process-log.d.ts.map +1 -0
- package/dist/core/storage/process-log.js +165 -0
- package/dist/core/storage/query.d.ts +34 -0
- package/dist/core/storage/query.d.ts.map +1 -0
- package/dist/core/storage/query.js +295 -0
- package/dist/core/storage/receipts.d.ts +23 -0
- package/dist/core/storage/receipts.d.ts.map +1 -0
- package/dist/core/storage/receipts.js +117 -0
- package/dist/core/storage/segments.d.ts +84 -0
- package/dist/core/storage/segments.d.ts.map +1 -0
- package/dist/core/storage/segments.js +542 -0
- package/dist/core/storage/sink-graph.d.ts +65 -0
- package/dist/core/storage/sink-graph.d.ts.map +1 -0
- package/dist/core/storage/sink-graph.js +213 -0
- package/dist/core/storage/storm-control.d.ts +23 -0
- package/dist/core/storage/storm-control.d.ts.map +1 -0
- package/dist/core/storage/storm-control.js +59 -0
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +10 -14
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/lazy-commands.d.ts +26 -0
- package/dist/lazy-commands.d.ts.map +1 -0
- package/dist/lazy-commands.js +210 -0
- package/dist/lib/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/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +5 -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 +29 -2
- package/schemas/config.schema.json +58 -0
- package/schemas/event-v3.schema.json +324 -112
- package/src/commander.ts +462 -95
- package/src/commands/agents.ts +517 -190
- package/src/commands/backup.ts +18 -14
- package/src/commands/browse-session.ts +12 -0
- package/src/commands/browse.ts +6 -7
- package/src/commands/conversations.ts +279 -0
- package/src/commands/deinit.ts +6 -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 +143 -0
- package/src/commands/governor.ts +13 -12
- package/src/commands/inbox.ts +61 -0
- package/src/commands/init.ts +78 -16
- package/src/commands/ledger-v3.ts +421 -1
- package/src/commands/logs.ts +224 -0
- package/src/commands/messages.ts +61 -0
- package/src/commands/outline.ts +6 -2
- package/src/commands/read.ts +6 -2
- package/src/commands/semantic.ts +66 -1
- package/src/commands/storage.ts +310 -0
- package/src/commands/tunnel.ts +66 -52
- package/src/commands/web.ts +77 -7
- package/src/commands/work.ts +3 -3
- package/src/commands/workflow.ts +13 -13
- package/src/core/agents/cli.ts +259 -53
- 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/render/prompt-context.ts +27 -6
- package/src/core/agents/rules/stop-hook.ts +107 -16
- package/src/core/agents/rules/verdict.ts +1 -0
- package/src/core/agents/session-events.ts +4 -0
- package/src/core/agents/session-finalization-state-v3.ts +1 -1
- package/src/core/agents/session-finalizer-v3.ts +4 -1
- package/src/core/agents/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 +64 -1
- package/src/core/config.ts +126 -5
- package/src/core/conversations/archive.ts +237 -0
- package/src/core/conversations/catalog.ts +79 -0
- package/src/core/conversations/context-pack.ts +72 -0
- package/src/core/conversations/contract.ts +178 -0
- package/src/core/conversations/evaluation.ts +30 -0
- package/src/core/conversations/index.ts +9 -0
- package/src/core/conversations/lifecycle.ts +63 -0
- package/src/core/conversations/normalize.ts +105 -0
- package/src/core/conversations/query.ts +318 -0
- package/src/core/conversations/search-index.ts +48 -0
- package/src/core/events/legacy-storage/canary.ts +177 -0
- package/src/core/events/legacy-storage/fence.ts +129 -0
- package/src/core/events/legacy-storage/index.ts +5 -0
- package/src/core/events/legacy-storage/inventory.ts +51 -0
- package/src/core/events/legacy-storage/manifest.ts +136 -0
- package/src/core/events/legacy-storage/reader.ts +178 -0
- package/src/core/events/v3/authority-outbox.ts +22 -1
- package/src/core/events/v3/base-contract.ts +17 -7
- package/src/core/events/v3/bootstrap.ts +195 -2
- package/src/core/events/v3/capabilities.ts +3 -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 +5 -2
- package/src/core/events/v3/live-route-observer.ts +80 -0
- package/src/core/events/v3/live-routing.ts +64 -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 +1 -1
- package/src/core/events/v3/producers/intake.ts +30 -2
- package/src/core/events/v3/producers/producer-state-observer.ts +52 -0
- package/src/core/events/v3/producers/recorder.ts +571 -33
- 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 +12 -5
- package/src/core/hooks/adapter/runtime-telemetry.ts +408 -13
- package/src/core/hooks/cli.ts +226 -32
- package/src/core/hooks/effects/image-capture.ts +4 -1
- 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/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/buffer.ts +124 -0
- package/src/core/storage/builtins.ts +916 -0
- package/src/core/storage/catalog.ts +467 -0
- package/src/core/storage/config.ts +423 -0
- package/src/core/storage/contract.ts +342 -0
- package/src/core/storage/durable-history.ts +738 -0
- package/src/core/storage/health.ts +76 -0
- package/src/core/storage/index.ts +15 -0
- package/src/core/storage/inventory.ts +859 -0
- package/src/core/storage/jsonl.ts +213 -0
- package/src/core/storage/log-retention.ts +555 -0
- package/src/core/storage/logger.ts +546 -0
- package/src/core/storage/maintenance-providers.ts +200 -0
- package/src/core/storage/maintenance.ts +929 -0
- package/src/core/storage/metrics.ts +199 -0
- package/src/core/storage/policy.ts +141 -0
- package/src/core/storage/process-log.ts +203 -0
- package/src/core/storage/query.ts +360 -0
- package/src/core/storage/receipts.ts +162 -0
- package/src/core/storage/segments.ts +721 -0
- package/src/core/storage/sink-graph.ts +343 -0
- package/src/core/storage/storm-control.ts +91 -0
- package/src/core/work/state.ts +12 -21
- package/src/core/workflow/live-session-v3.ts +2 -4
- package/src/index.ts +2 -0
- package/src/lazy-commands.ts +294 -0
- package/src/lib/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/templates.ts +5 -0
- package/src/lib/local-file-url.ts +31 -0
- package/src/lib/web-performance.ts +335 -0
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { BoundedLogBuffer } from "./buffer.ts";
|
|
4
|
+
import { createStorageCatalog, type HarneryStorageCatalog } from "./catalog.ts";
|
|
5
|
+
import type {
|
|
6
|
+
HarneryLoggerBinding,
|
|
7
|
+
HarneryLogLevel,
|
|
8
|
+
HarneryRegisteredStorageFamily,
|
|
9
|
+
} from "./contract.ts";
|
|
10
|
+
import {
|
|
11
|
+
encodeLogRecord,
|
|
12
|
+
type HarneryLazyFields,
|
|
13
|
+
type HarneryLogContext,
|
|
14
|
+
type HarneryLogFields,
|
|
15
|
+
type HarneryLogRecordV1,
|
|
16
|
+
type HarneryLogScalar,
|
|
17
|
+
sanitizeLogError,
|
|
18
|
+
validateLogContext,
|
|
19
|
+
validateLogEvent,
|
|
20
|
+
validateLogFields,
|
|
21
|
+
} from "./jsonl.ts";
|
|
22
|
+
import { LogMetricsAccumulator } from "./metrics.ts";
|
|
23
|
+
import { FileSegmentSink, familyLogDirectory } from "./segments.ts";
|
|
24
|
+
import { ProcessStormController } from "./storm-control.ts";
|
|
25
|
+
|
|
26
|
+
export interface HarneryLogger {
|
|
27
|
+
isEnabled(level: HarneryLogLevel): boolean;
|
|
28
|
+
child(context: HarneryLogContext): HarneryLogger;
|
|
29
|
+
trace(event: string, fields?: HarneryLazyFields, error?: unknown): void;
|
|
30
|
+
debug(event: string, fields?: HarneryLazyFields, error?: unknown): void;
|
|
31
|
+
info(event: string, fields?: HarneryLazyFields, error?: unknown): void;
|
|
32
|
+
warn(event: string, fields?: HarneryLazyFields, error?: unknown): void;
|
|
33
|
+
error(event: string, fields?: HarneryLazyFields, error?: unknown): void;
|
|
34
|
+
fatal(event: string, fields?: HarneryLazyFields, error?: unknown): void;
|
|
35
|
+
flush(options?: { durability?: "memory" | "disk" }): Promise<void>;
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface HarneryLoggerRuntime {
|
|
40
|
+
logger(componentId: string, context?: HarneryLogContext): HarneryLogger;
|
|
41
|
+
flush(options?: { durability?: "memory" | "disk" }): Promise<void>;
|
|
42
|
+
close(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface HarneryLogLevelConfig {
|
|
46
|
+
default?: HarneryLogLevel;
|
|
47
|
+
families?: Readonly<Record<string, HarneryLogLevel>>;
|
|
48
|
+
components?: Readonly<Record<string, HarneryLogLevel>>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type HarneryLogEnvironment = Readonly<Record<string, string | undefined>>;
|
|
52
|
+
|
|
53
|
+
export class HarneryUnsupportedDurabilityError extends Error {
|
|
54
|
+
constructor(readonly familyId: string) {
|
|
55
|
+
super(`family ${familyId} does not support durable disk flush`);
|
|
56
|
+
this.name = "HarneryUnsupportedDurabilityError";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface QueuedRecord {
|
|
61
|
+
record: HarneryLogRecordV1;
|
|
62
|
+
encoded: Buffer;
|
|
63
|
+
}
|
|
64
|
+
interface FamilyPipeline {
|
|
65
|
+
family: HarneryRegisteredStorageFamily;
|
|
66
|
+
buffer: BoundedLogBuffer<QueuedRecord>;
|
|
67
|
+
metrics: LogMetricsAccumulator;
|
|
68
|
+
storm: ProcessStormController;
|
|
69
|
+
durableNextFlush: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const LEVELS: readonly HarneryLogLevel[] = ["trace", "debug", "info", "warn", "error", "fatal"];
|
|
73
|
+
|
|
74
|
+
export function createFileLoggerRuntime(options: {
|
|
75
|
+
catalog: HarneryStorageCatalog;
|
|
76
|
+
bindings?: readonly HarneryLoggerBinding[];
|
|
77
|
+
level_config?: HarneryLogLevelConfig;
|
|
78
|
+
env?: HarneryLogEnvironment;
|
|
79
|
+
strict_levels?: boolean;
|
|
80
|
+
}): HarneryLoggerRuntime {
|
|
81
|
+
return new LoggerRuntime(
|
|
82
|
+
options.catalog,
|
|
83
|
+
options.bindings ?? options.catalog.logger_bindings,
|
|
84
|
+
options.level_config,
|
|
85
|
+
options.env,
|
|
86
|
+
options.strict_levels,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function createInMemoryLoggerRuntime(options: {
|
|
91
|
+
catalog: HarneryStorageCatalog;
|
|
92
|
+
bindings: readonly HarneryLoggerBinding[];
|
|
93
|
+
records?: HarneryLogRecordV1[];
|
|
94
|
+
level_config?: HarneryLogLevelConfig;
|
|
95
|
+
env?: HarneryLogEnvironment;
|
|
96
|
+
}): HarneryLoggerRuntime & { records: HarneryLogRecordV1[] } {
|
|
97
|
+
const records = options.records ?? [];
|
|
98
|
+
const runtime = new LoggerRuntime(
|
|
99
|
+
options.catalog,
|
|
100
|
+
options.bindings,
|
|
101
|
+
options.level_config,
|
|
102
|
+
options.env ?? {},
|
|
103
|
+
false,
|
|
104
|
+
async (items) => {
|
|
105
|
+
records.push(...items.map((item) => item.record));
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
return Object.assign(runtime, { records });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function createNullLoggerRuntime(): HarneryLoggerRuntime {
|
|
112
|
+
const logger: HarneryLogger = {
|
|
113
|
+
isEnabled: () => false,
|
|
114
|
+
child: () => logger,
|
|
115
|
+
trace() {},
|
|
116
|
+
debug() {},
|
|
117
|
+
info() {},
|
|
118
|
+
warn() {},
|
|
119
|
+
error() {},
|
|
120
|
+
fatal() {},
|
|
121
|
+
async flush() {},
|
|
122
|
+
async close() {},
|
|
123
|
+
};
|
|
124
|
+
return { logger: () => logger, async flush() {}, async close() {} };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
class LoggerRuntime implements HarneryLoggerRuntime {
|
|
128
|
+
readonly #catalog: HarneryStorageCatalog;
|
|
129
|
+
readonly #bindings: Map<string, string>;
|
|
130
|
+
readonly #pipelines = new Map<string, FamilyPipeline>();
|
|
131
|
+
readonly #writerId = `${process.pid}-${Date.now()}-${randomBytes(8).toString("hex")}`;
|
|
132
|
+
readonly #levels: HarneryLogLevelConfig;
|
|
133
|
+
readonly #env: HarneryLogEnvironment;
|
|
134
|
+
readonly #strict: boolean;
|
|
135
|
+
readonly #drainOverride?: (items: readonly QueuedRecord[]) => Promise<void>;
|
|
136
|
+
#writerSeq = 0;
|
|
137
|
+
#closed = false;
|
|
138
|
+
|
|
139
|
+
constructor(
|
|
140
|
+
catalog: HarneryStorageCatalog,
|
|
141
|
+
bindings: readonly HarneryLoggerBinding[],
|
|
142
|
+
levels?: HarneryLogLevelConfig,
|
|
143
|
+
env: HarneryLogEnvironment = process.env,
|
|
144
|
+
strict = true,
|
|
145
|
+
drainOverride?: (items: readonly QueuedRecord[]) => Promise<void>,
|
|
146
|
+
) {
|
|
147
|
+
this.#catalog = catalog;
|
|
148
|
+
this.#bindings = new Map(bindings.map((binding) => [binding.component_id, binding.family_id]));
|
|
149
|
+
this.#levels = levels ?? {};
|
|
150
|
+
this.#env = env;
|
|
151
|
+
this.#strict = strict;
|
|
152
|
+
this.#drainOverride = drainOverride;
|
|
153
|
+
for (const familyId of this.#bindings.values()) this.#pipeline(this.#catalog.require(familyId));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
logger(componentId: string, context: HarneryLogContext = {}): HarneryLogger {
|
|
157
|
+
const familyId = this.#bindings.get(componentId);
|
|
158
|
+
if (!familyId) throw new Error(`unknown logger binding: ${componentId}`);
|
|
159
|
+
const family = this.#catalog.require(familyId);
|
|
160
|
+
return new BoundLogger(this, componentId, family, validateLogContext(context));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async flush(options: { durability?: "memory" | "disk" } = {}): Promise<void> {
|
|
164
|
+
const pipelines = [...this.#pipelines.values()];
|
|
165
|
+
if (options.durability === "disk") {
|
|
166
|
+
for (const pipeline of pipelines) {
|
|
167
|
+
if (pipeline.family.durability === "best-effort")
|
|
168
|
+
throw new HarneryUnsupportedDurabilityError(pipeline.family.id);
|
|
169
|
+
pipeline.durableNextFlush = true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
for (const pipeline of pipelines) this.#emitStormSummaries(pipeline);
|
|
173
|
+
await Promise.all(pipelines.map((pipeline) => pipeline.buffer.flush()));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async close(): Promise<void> {
|
|
177
|
+
if (this.#closed) return;
|
|
178
|
+
this.#closed = true;
|
|
179
|
+
for (const pipeline of this.#pipelines.values()) this.#emitStormSummaries(pipeline);
|
|
180
|
+
await Promise.all([...this.#pipelines.values()].map((pipeline) => pipeline.buffer.close()));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
enabled(
|
|
184
|
+
componentId: string,
|
|
185
|
+
family: HarneryRegisteredStorageFamily,
|
|
186
|
+
level: HarneryLogLevel,
|
|
187
|
+
): boolean {
|
|
188
|
+
if (family.policy.writes !== "active" || this.#closed) return false;
|
|
189
|
+
const minimum = resolveLogLevel({
|
|
190
|
+
component_id: componentId,
|
|
191
|
+
family,
|
|
192
|
+
config: this.#levels,
|
|
193
|
+
env: this.#env,
|
|
194
|
+
strict: this.#strict,
|
|
195
|
+
});
|
|
196
|
+
return LEVELS.indexOf(level) >= LEVELS.indexOf(minimum);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
emit(
|
|
200
|
+
componentId: string,
|
|
201
|
+
family: HarneryRegisteredStorageFamily,
|
|
202
|
+
context: HarneryLogContext,
|
|
203
|
+
level: HarneryLogLevel,
|
|
204
|
+
event: string,
|
|
205
|
+
lazy: HarneryLazyFields = {},
|
|
206
|
+
error?: unknown,
|
|
207
|
+
): void {
|
|
208
|
+
if (!this.enabled(componentId, family, level)) return;
|
|
209
|
+
const pipeline = this.#pipeline(family);
|
|
210
|
+
try {
|
|
211
|
+
validateLogEvent(event);
|
|
212
|
+
const fields = validateLogFields(typeof lazy === "function" ? lazy() : lazy, family.policy);
|
|
213
|
+
const record: HarneryLogRecordV1 = {
|
|
214
|
+
schema: "harnery.log-record/v1",
|
|
215
|
+
kind: "record",
|
|
216
|
+
emitted_at: new Date().toISOString(),
|
|
217
|
+
family_id: family.id,
|
|
218
|
+
policy_version: family.policy.policy_version,
|
|
219
|
+
component_id: componentId,
|
|
220
|
+
level,
|
|
221
|
+
event,
|
|
222
|
+
writer_id: this.#writerId,
|
|
223
|
+
writer_seq: ++this.#writerSeq,
|
|
224
|
+
context,
|
|
225
|
+
fields,
|
|
226
|
+
...(error === undefined ? {} : { error: sanitizeLogError(error) }),
|
|
227
|
+
};
|
|
228
|
+
const encoded = encodeLogRecord(record, family);
|
|
229
|
+
pipeline.metrics.increment("accepted");
|
|
230
|
+
pipeline.metrics.increment("encoded");
|
|
231
|
+
pipeline.metrics.increment("bytes_accepted", encoded.byteLength);
|
|
232
|
+
if (!pipeline.storm.admit(`${componentId}:${event}`, level, encoded.byteLength)) {
|
|
233
|
+
pipeline.metrics.increment("sampled");
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
pipeline.buffer.enqueue({
|
|
237
|
+
value: { record, encoded },
|
|
238
|
+
bytes: encoded.byteLength,
|
|
239
|
+
high_priority: level === "warn" || level === "error" || level === "fatal",
|
|
240
|
+
});
|
|
241
|
+
} catch {
|
|
242
|
+
pipeline.metrics.failure("encoding");
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
#pipeline(family: HarneryRegisteredStorageFamily): FamilyPipeline {
|
|
247
|
+
const current = this.#pipelines.get(family.id);
|
|
248
|
+
if (current) return current;
|
|
249
|
+
const metrics = new LogMetricsAccumulator();
|
|
250
|
+
const sink = this.#drainOverride
|
|
251
|
+
? undefined
|
|
252
|
+
: new FileSegmentSink({ directory: familyLogDirectory(family), family });
|
|
253
|
+
const pipeline = {} as FamilyPipeline;
|
|
254
|
+
pipeline.family = family;
|
|
255
|
+
pipeline.metrics = metrics;
|
|
256
|
+
pipeline.durableNextFlush = false;
|
|
257
|
+
pipeline.storm = new ProcessStormController({
|
|
258
|
+
enabled: family.storm_policy?.enabled ?? true,
|
|
259
|
+
window_ms: family.storm_policy?.window_ms ?? 1_000,
|
|
260
|
+
max_exemplars: family.storm_policy?.max_exemplars ?? 3,
|
|
261
|
+
});
|
|
262
|
+
const policy = family.buffer_policy ?? {
|
|
263
|
+
max_bytes: 1024 * 1024,
|
|
264
|
+
max_records: 2_000,
|
|
265
|
+
flush_interval_ms: 250,
|
|
266
|
+
high_severity_reserve_bytes: 128 * 1024,
|
|
267
|
+
};
|
|
268
|
+
pipeline.buffer = new BoundedLogBuffer({
|
|
269
|
+
...policy,
|
|
270
|
+
minimum_high_priority_drain_interval_ms: 25,
|
|
271
|
+
on_drop: (_reason, item) => {
|
|
272
|
+
metrics.increment("dropped");
|
|
273
|
+
metrics.increment("bytes_dropped", item.encoded.byteLength);
|
|
274
|
+
},
|
|
275
|
+
on_drain_error: () => metrics.failure("sink"),
|
|
276
|
+
drain: async (items) => {
|
|
277
|
+
const started = Date.now();
|
|
278
|
+
try {
|
|
279
|
+
if (this.#drainOverride) await this.#drainOverride(items.map((item) => item.value));
|
|
280
|
+
else
|
|
281
|
+
await sink!.append(
|
|
282
|
+
items.map((item) => item.value.encoded),
|
|
283
|
+
metrics.take(),
|
|
284
|
+
pipeline.durableNextFlush,
|
|
285
|
+
);
|
|
286
|
+
} finally {
|
|
287
|
+
pipeline.durableNextFlush = false;
|
|
288
|
+
metrics.observeLatency("flush_latency_ms", Date.now() - started);
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
this.#pipelines.set(family.id, pipeline);
|
|
293
|
+
return pipeline;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
#emitStormSummaries(pipeline: FamilyPipeline): void {
|
|
297
|
+
for (const summary of pipeline.storm.drainSummaries(true)) {
|
|
298
|
+
const record: HarneryLogRecordV1 = {
|
|
299
|
+
schema: "harnery.log-record/v1",
|
|
300
|
+
kind: "aggregate",
|
|
301
|
+
emitted_at: summary.last_emitted_at,
|
|
302
|
+
family_id: pipeline.family.id,
|
|
303
|
+
policy_version: pipeline.family.policy.policy_version,
|
|
304
|
+
component_id: "harnery.logger",
|
|
305
|
+
level: "warn",
|
|
306
|
+
event: "log.storm_aggregate",
|
|
307
|
+
writer_id: this.#writerId,
|
|
308
|
+
writer_seq: ++this.#writerSeq,
|
|
309
|
+
context: {},
|
|
310
|
+
fields: { key: summary.key },
|
|
311
|
+
aggregate: {
|
|
312
|
+
count: summary.count,
|
|
313
|
+
represented_bytes: summary.represented_bytes,
|
|
314
|
+
first_emitted_at: summary.first_emitted_at,
|
|
315
|
+
last_emitted_at: summary.last_emitted_at,
|
|
316
|
+
exemplar_digests: summary.exemplar_digests,
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
const encoded = encodeLogRecord(record, pipeline.family);
|
|
320
|
+
pipeline.buffer.enqueue({
|
|
321
|
+
value: { record, encoded },
|
|
322
|
+
bytes: encoded.byteLength,
|
|
323
|
+
high_priority: true,
|
|
324
|
+
});
|
|
325
|
+
pipeline.metrics.increment("coalesced", summary.count);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
class BoundLogger implements HarneryLogger {
|
|
331
|
+
constructor(
|
|
332
|
+
readonly runtime: LoggerRuntime,
|
|
333
|
+
readonly componentId: string,
|
|
334
|
+
readonly family: HarneryRegisteredStorageFamily,
|
|
335
|
+
readonly context: HarneryLogContext,
|
|
336
|
+
) {}
|
|
337
|
+
isEnabled(level: HarneryLogLevel): boolean {
|
|
338
|
+
return this.runtime.enabled(this.componentId, this.family, level);
|
|
339
|
+
}
|
|
340
|
+
child(context: HarneryLogContext): HarneryLogger {
|
|
341
|
+
return new BoundLogger(
|
|
342
|
+
this.runtime,
|
|
343
|
+
this.componentId,
|
|
344
|
+
this.family,
|
|
345
|
+
validateLogContext({ ...this.context, ...context }),
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
trace(e: string, f?: HarneryLazyFields, x?: unknown): void {
|
|
349
|
+
this.runtime.emit(this.componentId, this.family, this.context, "trace", e, f, x);
|
|
350
|
+
}
|
|
351
|
+
debug(e: string, f?: HarneryLazyFields, x?: unknown): void {
|
|
352
|
+
this.runtime.emit(this.componentId, this.family, this.context, "debug", e, f, x);
|
|
353
|
+
}
|
|
354
|
+
info(e: string, f?: HarneryLazyFields, x?: unknown): void {
|
|
355
|
+
this.runtime.emit(this.componentId, this.family, this.context, "info", e, f, x);
|
|
356
|
+
}
|
|
357
|
+
warn(e: string, f?: HarneryLazyFields, x?: unknown): void {
|
|
358
|
+
this.runtime.emit(this.componentId, this.family, this.context, "warn", e, f, x);
|
|
359
|
+
}
|
|
360
|
+
error(e: string, f?: HarneryLazyFields, x?: unknown): void {
|
|
361
|
+
this.runtime.emit(this.componentId, this.family, this.context, "error", e, f, x);
|
|
362
|
+
}
|
|
363
|
+
fatal(e: string, f?: HarneryLazyFields, x?: unknown): void {
|
|
364
|
+
this.runtime.emit(this.componentId, this.family, this.context, "fatal", e, f, x);
|
|
365
|
+
}
|
|
366
|
+
flush(o?: { durability?: "memory" | "disk" }): Promise<void> {
|
|
367
|
+
return this.runtime.flush(o);
|
|
368
|
+
}
|
|
369
|
+
close(): Promise<void> {
|
|
370
|
+
return this.runtime.close();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export function resolveLogLevel(options: {
|
|
375
|
+
component_id: string;
|
|
376
|
+
family: HarneryRegisteredStorageFamily;
|
|
377
|
+
config?: HarneryLogLevelConfig;
|
|
378
|
+
env?: HarneryLogEnvironment;
|
|
379
|
+
strict?: boolean;
|
|
380
|
+
}): HarneryLogLevel {
|
|
381
|
+
const env = options.env ?? process.env;
|
|
382
|
+
const strict = options.strict ?? true;
|
|
383
|
+
const scoped = parseScopedLevels(env.HARNERY_LOG_LEVELS, strict);
|
|
384
|
+
const raw =
|
|
385
|
+
scoped.components[options.component_id] ??
|
|
386
|
+
scoped.families[options.family.id] ??
|
|
387
|
+
options.config?.components?.[options.component_id] ??
|
|
388
|
+
options.config?.families?.[options.family.id] ??
|
|
389
|
+
env.HARNERY_LOG_LEVEL ??
|
|
390
|
+
options.config?.default ??
|
|
391
|
+
options.family.default_level ??
|
|
392
|
+
"info";
|
|
393
|
+
if (isLevel(raw)) return raw;
|
|
394
|
+
if (strict) throw new Error(`invalid Harnery log level: ${raw}`);
|
|
395
|
+
return options.family.default_level ?? "info";
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function parseScopedLevels(
|
|
399
|
+
raw: string | undefined,
|
|
400
|
+
strict: boolean,
|
|
401
|
+
): { components: Record<string, HarneryLogLevel>; families: Record<string, HarneryLogLevel> } {
|
|
402
|
+
const result = {
|
|
403
|
+
components: {} as Record<string, HarneryLogLevel>,
|
|
404
|
+
families: {} as Record<string, HarneryLogLevel>,
|
|
405
|
+
};
|
|
406
|
+
if (!raw) return result;
|
|
407
|
+
for (const token of raw
|
|
408
|
+
.split(",")
|
|
409
|
+
.map((part) => part.trim())
|
|
410
|
+
.filter(Boolean)) {
|
|
411
|
+
const [scope, value] = token.split("=", 2);
|
|
412
|
+
const [kind, id] = (scope ?? "").split(":", 2);
|
|
413
|
+
if (!id || !isLevel(value)) {
|
|
414
|
+
if (strict) throw new Error(`invalid HARNERY_LOG_LEVELS entry: ${token}`);
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
if (kind === "component") result.components[id] = value;
|
|
418
|
+
else if (kind === "family") result.families[id] = value;
|
|
419
|
+
else if (strict) throw new Error(`invalid HARNERY_LOG_LEVELS scope: ${token}`);
|
|
420
|
+
}
|
|
421
|
+
return result;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function isLevel(value: unknown): value is HarneryLogLevel {
|
|
425
|
+
return typeof value === "string" && LEVELS.includes(value as HarneryLogLevel);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
export function legacyLogFields(value: Record<string, unknown>): HarneryLogFields {
|
|
429
|
+
const out: HarneryLogFields = {};
|
|
430
|
+
for (const [key, candidate] of Object.entries(value)) {
|
|
431
|
+
if (candidate === undefined) continue;
|
|
432
|
+
if (
|
|
433
|
+
candidate === null ||
|
|
434
|
+
typeof candidate === "string" ||
|
|
435
|
+
typeof candidate === "number" ||
|
|
436
|
+
typeof candidate === "boolean"
|
|
437
|
+
)
|
|
438
|
+
out[key] = candidate as HarneryLogScalar;
|
|
439
|
+
else if (
|
|
440
|
+
Array.isArray(candidate) &&
|
|
441
|
+
candidate.every(
|
|
442
|
+
(item) => item === null || ["string", "number", "boolean"].includes(typeof item),
|
|
443
|
+
)
|
|
444
|
+
)
|
|
445
|
+
out[key] = candidate as HarneryLogScalar[];
|
|
446
|
+
else {
|
|
447
|
+
const encoded = JSON.stringify(candidate);
|
|
448
|
+
if (encoded !== undefined && Buffer.byteLength(encoded) <= 4_096) out[key] = encoded;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return out;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export interface HarneryBoundedObjectArray {
|
|
455
|
+
json: string;
|
|
456
|
+
included: number;
|
|
457
|
+
omitted: number;
|
|
458
|
+
truncated: boolean;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** Encode an allow-listed array of scalar records without slicing a JSON token. */
|
|
462
|
+
export function encodeBoundedLogObjectArray(
|
|
463
|
+
values: readonly unknown[],
|
|
464
|
+
options: { max_bytes: number; allowed_fields: readonly string[] },
|
|
465
|
+
): HarneryBoundedObjectArray {
|
|
466
|
+
if (!Number.isSafeInteger(options.max_bytes) || options.max_bytes < 2) {
|
|
467
|
+
throw new Error("bounded log object array needs at least two bytes");
|
|
468
|
+
}
|
|
469
|
+
const allowed = new Set(options.allowed_fields);
|
|
470
|
+
if (allowed.size !== options.allowed_fields.length || allowed.size === 0) {
|
|
471
|
+
throw new Error("bounded log object array needs unique allowed fields");
|
|
472
|
+
}
|
|
473
|
+
const normalized = values.map((value, index) => {
|
|
474
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
475
|
+
throw new Error(`bounded log object array item ${index} must be an object`);
|
|
476
|
+
}
|
|
477
|
+
const source = value as Record<string, unknown>;
|
|
478
|
+
for (const key of Object.keys(source)) {
|
|
479
|
+
if (!allowed.has(key)) throw new Error(`bounded log object array rejects field: ${key}`);
|
|
480
|
+
}
|
|
481
|
+
const item: Record<string, HarneryLogScalar> = {};
|
|
482
|
+
for (const key of options.allowed_fields) {
|
|
483
|
+
const candidate = source[key];
|
|
484
|
+
if (candidate === undefined) continue;
|
|
485
|
+
if (
|
|
486
|
+
candidate !== null &&
|
|
487
|
+
typeof candidate !== "string" &&
|
|
488
|
+
typeof candidate !== "boolean" &&
|
|
489
|
+
(typeof candidate !== "number" || !Number.isFinite(candidate))
|
|
490
|
+
) {
|
|
491
|
+
throw new Error(`bounded log object array field ${key} must be scalar`);
|
|
492
|
+
}
|
|
493
|
+
item[key] = candidate as HarneryLogScalar;
|
|
494
|
+
}
|
|
495
|
+
return item;
|
|
496
|
+
});
|
|
497
|
+
const included: Record<string, HarneryLogScalar>[] = [];
|
|
498
|
+
let bytes = 2;
|
|
499
|
+
for (const item of normalized) {
|
|
500
|
+
const encoded = JSON.stringify(item);
|
|
501
|
+
const nextBytes = Buffer.byteLength(encoded) + (included.length > 0 ? 1 : 0);
|
|
502
|
+
if (bytes + nextBytes > options.max_bytes) break;
|
|
503
|
+
included.push(item);
|
|
504
|
+
bytes += nextBytes;
|
|
505
|
+
}
|
|
506
|
+
return {
|
|
507
|
+
json: JSON.stringify(included),
|
|
508
|
+
included: included.length,
|
|
509
|
+
omitted: normalized.length - included.length,
|
|
510
|
+
truncated: included.length !== normalized.length,
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const PROCESS_RUNTIMES = new Map<string, HarneryLoggerRuntime>();
|
|
515
|
+
|
|
516
|
+
const PROCESS_LOGGER_BINDINGS = {
|
|
517
|
+
"agent-hook": "agent-hook-debug-log",
|
|
518
|
+
"agent-coord": "agent-coord-debug-log",
|
|
519
|
+
"semantic-service": "semantic-service-log",
|
|
520
|
+
"governor-service": "governor-service-log",
|
|
521
|
+
"presence-relay": "presence-relay-log",
|
|
522
|
+
} as const;
|
|
523
|
+
|
|
524
|
+
export type HarneryProcessLoggerComponent = keyof typeof PROCESS_LOGGER_BINDINGS;
|
|
525
|
+
|
|
526
|
+
export function processLogger(
|
|
527
|
+
coordRoot: string,
|
|
528
|
+
componentId: HarneryProcessLoggerComponent,
|
|
529
|
+
): HarneryLogger {
|
|
530
|
+
const root = resolve(coordRoot);
|
|
531
|
+
let runtime = PROCESS_RUNTIMES.get(root);
|
|
532
|
+
if (!runtime) {
|
|
533
|
+
const bindings = Object.entries(PROCESS_LOGGER_BINDINGS).map(([component_id, family_id]) => ({
|
|
534
|
+
component_id,
|
|
535
|
+
family_id,
|
|
536
|
+
}));
|
|
537
|
+
const catalog = createStorageCatalog({ coord_root: root }, { logger_bindings: bindings });
|
|
538
|
+
runtime = createFileLoggerRuntime({ catalog, bindings, strict_levels: false });
|
|
539
|
+
PROCESS_RUNTIMES.set(root, runtime);
|
|
540
|
+
}
|
|
541
|
+
return runtime.logger(componentId);
|
|
542
|
+
}
|
|
543
|
+
export async function closeProcessLoggers(): Promise<void> {
|
|
544
|
+
await Promise.all([...PROCESS_RUNTIMES.values()].map((runtime) => runtime.close()));
|
|
545
|
+
PROCESS_RUNTIMES.clear();
|
|
546
|
+
}
|