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
|
@@ -3,6 +3,8 @@ import { basename, dirname, join } from "node:path";
|
|
|
3
3
|
|
|
4
4
|
import { toolResponseMintedSessionName } from "../../agents/session-name-display.ts";
|
|
5
5
|
|
|
6
|
+
export const ASSISTANT_STATUS_BOX_PREFIX = "┌─ agent-";
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* Scan a CC-style JSONL transcript for the `┌─ agent-` status-box prefix in
|
|
8
10
|
* the most-recent assistant turn. Used by `turn.completed` events to populate
|
|
@@ -76,6 +78,22 @@ export function scanAssistantTextIncludes(
|
|
|
76
78
|
return false;
|
|
77
79
|
}
|
|
78
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Strict status-box evidence shared by turn telemetry and the Stop-time
|
|
83
|
+
* continuation fallback. Both inputs are assistant-only surfaces: the JSONL
|
|
84
|
+
* scanner rejects tool_result rows, while lastAssistantMessage comes directly
|
|
85
|
+
* from the adapter's completed assistant response.
|
|
86
|
+
*/
|
|
87
|
+
export function scanAssistantStatusBoxPresent(
|
|
88
|
+
transcriptPath: string | undefined,
|
|
89
|
+
lastAssistantMessage: string | undefined,
|
|
90
|
+
): boolean {
|
|
91
|
+
return (
|
|
92
|
+
scanAssistantTextIncludes(transcriptPath, ASSISTANT_STATUS_BOX_PREFIX) ||
|
|
93
|
+
lastAssistantMessage?.includes(ASSISTANT_STATUS_BOX_PREFIX) === true
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
79
97
|
/** Most recent user-visible assistant text across Claude Code and Codex JSONL. */
|
|
80
98
|
export function scanLatestAssistantText(transcriptPath: string | undefined): string | undefined {
|
|
81
99
|
const readablePath = resolveTranscriptPath(transcriptPath);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export const HARNERY_INBOX_RECORD_SCHEMA = "harnery.inbox-record/v1" as const;
|
|
2
|
+
export const HARNERY_INBOX_STATUS_SCHEMA = "harnery.inbox-status/v1" as const;
|
|
3
|
+
|
|
4
|
+
export interface HarneryInboxLimits {
|
|
5
|
+
max_message_body_bytes: number;
|
|
6
|
+
max_pending_count: number;
|
|
7
|
+
max_pending_bytes: number;
|
|
8
|
+
max_history_bytes: number;
|
|
9
|
+
max_history_records: number;
|
|
10
|
+
warning_pressure_ratio: number;
|
|
11
|
+
max_surface_count: number;
|
|
12
|
+
max_surface_bytes: number;
|
|
13
|
+
max_surface_tokens: number;
|
|
14
|
+
surfaced_grace_ms: number;
|
|
15
|
+
terminal_grace_ms: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface HarneryInboxMessageRecordV1 {
|
|
19
|
+
schema: typeof HARNERY_INBOX_RECORD_SCHEMA;
|
|
20
|
+
kind: "message";
|
|
21
|
+
message_id: string;
|
|
22
|
+
sender_instance_id: string;
|
|
23
|
+
sender_display_name: string;
|
|
24
|
+
recipient_instance_id: string;
|
|
25
|
+
recipient_display_name: string;
|
|
26
|
+
created_at: string;
|
|
27
|
+
body: string;
|
|
28
|
+
body_bytes: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface HarneryInboxSurfacedRecordV1 {
|
|
32
|
+
schema: typeof HARNERY_INBOX_RECORD_SCHEMA;
|
|
33
|
+
kind: "surfaced";
|
|
34
|
+
message_id: string;
|
|
35
|
+
surfaced_at: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type HarneryInboxRecordV1 = HarneryInboxMessageRecordV1 | HarneryInboxSurfacedRecordV1;
|
|
39
|
+
|
|
40
|
+
export interface HarneryInboxStatusV1 {
|
|
41
|
+
schema: typeof HARNERY_INBOX_STATUS_SCHEMA;
|
|
42
|
+
recipient_instance_id: string;
|
|
43
|
+
pending_count: number;
|
|
44
|
+
pending_bytes: number;
|
|
45
|
+
total_history_bytes: number;
|
|
46
|
+
oldest_pending_at?: string;
|
|
47
|
+
pressure: "normal" | "warning" | "exhausted";
|
|
48
|
+
last_surface_at?: string;
|
|
49
|
+
last_compaction_at?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type HarneryInboxCapacityReason =
|
|
53
|
+
| "message_body_limit"
|
|
54
|
+
| "pending_count_limit"
|
|
55
|
+
| "pending_bytes_limit"
|
|
56
|
+
| "history_bytes_limit";
|
|
57
|
+
|
|
58
|
+
export class HarneryInboxCapacityError extends Error {
|
|
59
|
+
constructor(
|
|
60
|
+
readonly reason_code: HarneryInboxCapacityReason,
|
|
61
|
+
readonly current: number,
|
|
62
|
+
readonly limit: number,
|
|
63
|
+
) {
|
|
64
|
+
super(
|
|
65
|
+
`inbox capacity ${reason_code}: ${current}/${limit}; use a managed artifact for larger payloads`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface HarneryInboxSurfaceBudget {
|
|
71
|
+
max_count: number;
|
|
72
|
+
max_bytes: number;
|
|
73
|
+
max_tokens: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface HarneryInboxSurfaceResult {
|
|
77
|
+
emitted: readonly HarneryInboxMessageRecordV1[];
|
|
78
|
+
remaining_pending_count: number;
|
|
79
|
+
remaining_pending_bytes: number;
|
|
80
|
+
repeated_after_crash_possible: true;
|
|
81
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { HarneryInboxLimits, HarneryInboxRecordV1 } from "./contract.ts";
|
|
2
|
+
import { project } from "./service.ts";
|
|
3
|
+
|
|
4
|
+
export const HARNERY_INBOX_COMPACTION_PLAN_SCHEMA = "harnery.inbox-compaction-plan/v1" as const;
|
|
5
|
+
|
|
6
|
+
export type HarneryRecipientLifecycle = "active" | "resumable" | "terminal";
|
|
7
|
+
|
|
8
|
+
export interface HarneryInboxCompactionPlan {
|
|
9
|
+
schema: typeof HARNERY_INBOX_COMPACTION_PLAN_SCHEMA;
|
|
10
|
+
recipient_instance_id: string;
|
|
11
|
+
action: "none" | "compact-surfaced" | "prune-terminal";
|
|
12
|
+
reason_code:
|
|
13
|
+
| "pending_protected"
|
|
14
|
+
| "active_recipient"
|
|
15
|
+
| "surfaced_grace"
|
|
16
|
+
| "terminal_grace"
|
|
17
|
+
| "eligible";
|
|
18
|
+
remove_record_count: number;
|
|
19
|
+
retained_record_count: number;
|
|
20
|
+
protected_pending_count: number;
|
|
21
|
+
dry_run: true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function planInboxCompaction(input: {
|
|
25
|
+
recipient_instance_id: string;
|
|
26
|
+
records: readonly HarneryInboxRecordV1[];
|
|
27
|
+
lifecycle: HarneryRecipientLifecycle;
|
|
28
|
+
terminal_at?: string;
|
|
29
|
+
now: Date;
|
|
30
|
+
limits: HarneryInboxLimits;
|
|
31
|
+
}): HarneryInboxCompactionPlan {
|
|
32
|
+
const projection = project(input.records);
|
|
33
|
+
const surfacedAt = new Map<string, number>();
|
|
34
|
+
for (const record of input.records) {
|
|
35
|
+
if (record.kind === "surfaced")
|
|
36
|
+
surfacedAt.set(record.message_id, Date.parse(record.surfaced_at));
|
|
37
|
+
}
|
|
38
|
+
const compactableIds = new Set(
|
|
39
|
+
[...surfacedAt]
|
|
40
|
+
.filter(([, timestamp]) => input.now.getTime() - timestamp >= input.limits.surfaced_grace_ms)
|
|
41
|
+
.map(([id]) => id),
|
|
42
|
+
);
|
|
43
|
+
const compactableRecords = input.records.filter((record) =>
|
|
44
|
+
compactableIds.has(record.message_id),
|
|
45
|
+
).length;
|
|
46
|
+
if (input.lifecycle === "terminal") {
|
|
47
|
+
if (projection.pending.length > 0) {
|
|
48
|
+
return plan(
|
|
49
|
+
input,
|
|
50
|
+
"none",
|
|
51
|
+
"pending_protected",
|
|
52
|
+
0,
|
|
53
|
+
input.records.length,
|
|
54
|
+
projection.pending.length,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
const terminalAt = input.terminal_at ? Date.parse(input.terminal_at) : Number.NaN;
|
|
58
|
+
if (
|
|
59
|
+
!Number.isFinite(terminalAt) ||
|
|
60
|
+
input.now.getTime() - terminalAt < input.limits.terminal_grace_ms
|
|
61
|
+
) {
|
|
62
|
+
return plan(input, "none", "terminal_grace", 0, input.records.length, 0);
|
|
63
|
+
}
|
|
64
|
+
return plan(input, "prune-terminal", "eligible", input.records.length, 0, 0);
|
|
65
|
+
}
|
|
66
|
+
if (compactableRecords === 0) {
|
|
67
|
+
return plan(
|
|
68
|
+
input,
|
|
69
|
+
"none",
|
|
70
|
+
surfacedAt.size > 0 ? "surfaced_grace" : "active_recipient",
|
|
71
|
+
0,
|
|
72
|
+
input.records.length,
|
|
73
|
+
projection.pending.length,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return plan(
|
|
77
|
+
input,
|
|
78
|
+
"compact-surfaced",
|
|
79
|
+
"eligible",
|
|
80
|
+
compactableRecords,
|
|
81
|
+
input.records.length - compactableRecords,
|
|
82
|
+
projection.pending.length,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function plan(
|
|
87
|
+
input: { recipient_instance_id: string },
|
|
88
|
+
action: HarneryInboxCompactionPlan["action"],
|
|
89
|
+
reason_code: HarneryInboxCompactionPlan["reason_code"],
|
|
90
|
+
remove_record_count: number,
|
|
91
|
+
retained_record_count: number,
|
|
92
|
+
protected_pending_count: number,
|
|
93
|
+
): HarneryInboxCompactionPlan {
|
|
94
|
+
return {
|
|
95
|
+
schema: HARNERY_INBOX_COMPACTION_PLAN_SCHEMA,
|
|
96
|
+
recipient_instance_id: input.recipient_instance_id,
|
|
97
|
+
action,
|
|
98
|
+
reason_code,
|
|
99
|
+
remove_record_count,
|
|
100
|
+
retained_record_count,
|
|
101
|
+
protected_pending_count,
|
|
102
|
+
dry_run: true,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { existsSync, statSync } from "node:fs";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { readCrashSafeJsonlFile, updateCrashSafeJsonlFile } from "../storage/durable-history.ts";
|
|
5
|
+
import {
|
|
6
|
+
HARNERY_INBOX_RECORD_SCHEMA,
|
|
7
|
+
HARNERY_INBOX_STATUS_SCHEMA,
|
|
8
|
+
HarneryInboxCapacityError,
|
|
9
|
+
type HarneryInboxLimits,
|
|
10
|
+
type HarneryInboxMessageRecordV1,
|
|
11
|
+
type HarneryInboxRecordV1,
|
|
12
|
+
type HarneryInboxStatusV1,
|
|
13
|
+
type HarneryInboxSurfaceBudget,
|
|
14
|
+
type HarneryInboxSurfaceResult,
|
|
15
|
+
} from "./contract.ts";
|
|
16
|
+
|
|
17
|
+
export interface HarneryInboxServiceOptions {
|
|
18
|
+
coord_root: string;
|
|
19
|
+
limits: HarneryInboxLimits;
|
|
20
|
+
now?: () => Date;
|
|
21
|
+
id?: () => string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface HarneryInboxSendInput {
|
|
25
|
+
sender_instance_id: string;
|
|
26
|
+
sender_display_name: string;
|
|
27
|
+
recipient_instance_id: string;
|
|
28
|
+
recipient_display_name: string;
|
|
29
|
+
body: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface HarneryInboxSendReceipt {
|
|
33
|
+
state: "queued";
|
|
34
|
+
message_id: string;
|
|
35
|
+
body_bytes: number;
|
|
36
|
+
synced: true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class HarneryInboxService {
|
|
40
|
+
readonly #options: HarneryInboxServiceOptions;
|
|
41
|
+
|
|
42
|
+
constructor(options: HarneryInboxServiceOptions) {
|
|
43
|
+
validateLimits(options.limits);
|
|
44
|
+
this.#options = options;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
send(input: HarneryInboxSendInput): HarneryInboxSendReceipt {
|
|
48
|
+
const recipient = opaqueId(input.recipient_instance_id, "recipient instance");
|
|
49
|
+
const bodyBytes = Buffer.byteLength(input.body);
|
|
50
|
+
const limits = this.#options.limits;
|
|
51
|
+
if (bodyBytes === 0 || bodyBytes > limits.max_message_body_bytes) {
|
|
52
|
+
throw new HarneryInboxCapacityError(
|
|
53
|
+
"message_body_limit",
|
|
54
|
+
bodyBytes,
|
|
55
|
+
limits.max_message_body_bytes,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const record: HarneryInboxMessageRecordV1 = {
|
|
59
|
+
schema: HARNERY_INBOX_RECORD_SCHEMA,
|
|
60
|
+
kind: "message",
|
|
61
|
+
message_id: `msg_${this.#options.id?.() ?? randomUUID()}`,
|
|
62
|
+
sender_instance_id: opaqueId(input.sender_instance_id, "sender instance"),
|
|
63
|
+
sender_display_name: boundedDisplay(input.sender_display_name),
|
|
64
|
+
recipient_instance_id: recipient,
|
|
65
|
+
recipient_display_name: boundedDisplay(input.recipient_display_name),
|
|
66
|
+
created_at: now(this.#options).toISOString(),
|
|
67
|
+
body: input.body,
|
|
68
|
+
body_bytes: bodyBytes,
|
|
69
|
+
};
|
|
70
|
+
const path = inboxPath(this.#options.coord_root, recipient);
|
|
71
|
+
return updateCrashSafeJsonlFile<HarneryInboxRecordV1, HarneryInboxSendReceipt>(
|
|
72
|
+
path,
|
|
73
|
+
readOptions(limits),
|
|
74
|
+
(records) => {
|
|
75
|
+
const projection = project(records);
|
|
76
|
+
capacityCheck(projection, record, path, limits);
|
|
77
|
+
return {
|
|
78
|
+
append: [record],
|
|
79
|
+
result: {
|
|
80
|
+
state: "queued",
|
|
81
|
+
message_id: record.message_id,
|
|
82
|
+
body_bytes: bodyBytes,
|
|
83
|
+
synced: true,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
records(recipientInstanceId: string): HarneryInboxRecordV1[] {
|
|
91
|
+
return readCrashSafeJsonlFile<HarneryInboxRecordV1>(
|
|
92
|
+
inboxPath(this.#options.coord_root, opaqueId(recipientInstanceId, "recipient instance")),
|
|
93
|
+
readOptions(this.#options.limits),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
pending(recipientInstanceId: string): HarneryInboxMessageRecordV1[] {
|
|
98
|
+
return project(this.records(recipientInstanceId)).pending;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
status(recipientInstanceId: string): HarneryInboxStatusV1 {
|
|
102
|
+
const recipient = opaqueId(recipientInstanceId, "recipient instance");
|
|
103
|
+
const path = inboxPath(this.#options.coord_root, recipient);
|
|
104
|
+
const projection = project(this.records(recipient));
|
|
105
|
+
const pendingBytes = projection.pending.reduce((sum, record) => sum + record.body_bytes, 0);
|
|
106
|
+
const ratio = Math.max(
|
|
107
|
+
projection.pending.length / this.#options.limits.max_pending_count,
|
|
108
|
+
pendingBytes / this.#options.limits.max_pending_bytes,
|
|
109
|
+
);
|
|
110
|
+
return {
|
|
111
|
+
schema: HARNERY_INBOX_STATUS_SCHEMA,
|
|
112
|
+
recipient_instance_id: recipient,
|
|
113
|
+
pending_count: projection.pending.length,
|
|
114
|
+
pending_bytes: pendingBytes,
|
|
115
|
+
total_history_bytes: existsSync(path) ? statSync(path).size : 0,
|
|
116
|
+
...(projection.pending[0] ? { oldest_pending_at: projection.pending[0].created_at } : {}),
|
|
117
|
+
pressure:
|
|
118
|
+
ratio >= 1
|
|
119
|
+
? "exhausted"
|
|
120
|
+
: ratio >= this.#options.limits.warning_pressure_ratio
|
|
121
|
+
? "warning"
|
|
122
|
+
: "normal",
|
|
123
|
+
...(projection.lastSurfaceAt ? { last_surface_at: projection.lastSurfaceAt } : {}),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async surface(
|
|
128
|
+
recipientInstanceId: string,
|
|
129
|
+
emit: (messages: readonly HarneryInboxMessageRecordV1[]) => Promise<void> | void,
|
|
130
|
+
budget: HarneryInboxSurfaceBudget = {
|
|
131
|
+
max_count: this.#options.limits.max_surface_count,
|
|
132
|
+
max_bytes: this.#options.limits.max_surface_bytes,
|
|
133
|
+
max_tokens: this.#options.limits.max_surface_tokens,
|
|
134
|
+
},
|
|
135
|
+
): Promise<HarneryInboxSurfaceResult> {
|
|
136
|
+
validateSurfaceBudget(budget);
|
|
137
|
+
const recipient = opaqueId(recipientInstanceId, "recipient instance");
|
|
138
|
+
const selected = selectOldestFitting(this.pending(recipient), budget);
|
|
139
|
+
await emit(selected);
|
|
140
|
+
if (selected.length > 0) {
|
|
141
|
+
const surfacedAt = now(this.#options).toISOString();
|
|
142
|
+
updateCrashSafeJsonlFile<HarneryInboxRecordV1, void>(
|
|
143
|
+
inboxPath(this.#options.coord_root, recipient),
|
|
144
|
+
readOptions(this.#options.limits),
|
|
145
|
+
(records) => {
|
|
146
|
+
const stillPending = new Set(
|
|
147
|
+
project(records).pending.map(({ message_id }) => message_id),
|
|
148
|
+
);
|
|
149
|
+
return {
|
|
150
|
+
append: selected
|
|
151
|
+
.filter(({ message_id }) => stillPending.has(message_id))
|
|
152
|
+
.map(({ message_id }) => ({
|
|
153
|
+
schema: HARNERY_INBOX_RECORD_SCHEMA,
|
|
154
|
+
kind: "surfaced" as const,
|
|
155
|
+
message_id,
|
|
156
|
+
surfaced_at: surfacedAt,
|
|
157
|
+
})),
|
|
158
|
+
result: undefined,
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
const remaining = this.pending(recipient);
|
|
164
|
+
return {
|
|
165
|
+
emitted: selected,
|
|
166
|
+
remaining_pending_count: remaining.length,
|
|
167
|
+
remaining_pending_bytes: remaining.reduce((sum, record) => sum + record.body_bytes, 0),
|
|
168
|
+
repeated_after_crash_possible: true,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function inboxPath(coordRoot: string, recipientInstanceId: string): string {
|
|
174
|
+
const id = opaqueId(recipientInstanceId, "recipient instance");
|
|
175
|
+
return join(resolve(coordRoot), ".harnery", "inbox", `${id}.jsonl`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function project(records: readonly HarneryInboxRecordV1[]): {
|
|
179
|
+
pending: HarneryInboxMessageRecordV1[];
|
|
180
|
+
surfaced: ReadonlySet<string>;
|
|
181
|
+
lastSurfaceAt?: string;
|
|
182
|
+
} {
|
|
183
|
+
const messages = new Map<string, HarneryInboxMessageRecordV1>();
|
|
184
|
+
const surfaced = new Set<string>();
|
|
185
|
+
let lastSurfaceAt: string | undefined;
|
|
186
|
+
for (const record of records) {
|
|
187
|
+
validateRecord(record);
|
|
188
|
+
if (record.kind === "message") {
|
|
189
|
+
if (messages.has(record.message_id))
|
|
190
|
+
throw new Error(`duplicate inbox message ${record.message_id}`);
|
|
191
|
+
messages.set(record.message_id, record);
|
|
192
|
+
} else {
|
|
193
|
+
if (!messages.has(record.message_id))
|
|
194
|
+
throw new Error(`surfaced marker precedes ${record.message_id}`);
|
|
195
|
+
surfaced.add(record.message_id);
|
|
196
|
+
if (!lastSurfaceAt || record.surfaced_at > lastSurfaceAt) lastSurfaceAt = record.surfaced_at;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
pending: [...messages.values()].filter(({ message_id }) => !surfaced.has(message_id)),
|
|
201
|
+
surfaced,
|
|
202
|
+
...(lastSurfaceAt ? { lastSurfaceAt } : {}),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function selectOldestFitting(
|
|
207
|
+
pending: readonly HarneryInboxMessageRecordV1[],
|
|
208
|
+
budget: HarneryInboxSurfaceBudget,
|
|
209
|
+
): HarneryInboxMessageRecordV1[] {
|
|
210
|
+
const selected: HarneryInboxMessageRecordV1[] = [];
|
|
211
|
+
let bytes = 0;
|
|
212
|
+
let tokens = 0;
|
|
213
|
+
for (const record of pending) {
|
|
214
|
+
const recordTokens = Math.ceil(record.body_bytes / 4);
|
|
215
|
+
if (
|
|
216
|
+
selected.length >= budget.max_count ||
|
|
217
|
+
bytes + record.body_bytes > budget.max_bytes ||
|
|
218
|
+
tokens + recordTokens > budget.max_tokens
|
|
219
|
+
) {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
selected.push(record);
|
|
223
|
+
bytes += record.body_bytes;
|
|
224
|
+
tokens += recordTokens;
|
|
225
|
+
}
|
|
226
|
+
return selected;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function capacityCheck(
|
|
230
|
+
projection: ReturnType<typeof project>,
|
|
231
|
+
record: HarneryInboxMessageRecordV1,
|
|
232
|
+
path: string,
|
|
233
|
+
limits: HarneryInboxLimits,
|
|
234
|
+
): void {
|
|
235
|
+
const pendingBytes = projection.pending.reduce((sum, item) => sum + item.body_bytes, 0);
|
|
236
|
+
if (projection.pending.length + 1 > limits.max_pending_count) {
|
|
237
|
+
throw new HarneryInboxCapacityError(
|
|
238
|
+
"pending_count_limit",
|
|
239
|
+
projection.pending.length,
|
|
240
|
+
limits.max_pending_count,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
if (pendingBytes + record.body_bytes > limits.max_pending_bytes) {
|
|
244
|
+
throw new HarneryInboxCapacityError(
|
|
245
|
+
"pending_bytes_limit",
|
|
246
|
+
pendingBytes,
|
|
247
|
+
limits.max_pending_bytes,
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
const nextHistoryBytes =
|
|
251
|
+
(existsSync(path) ? statSync(path).size : 0) + Buffer.byteLength(`${JSON.stringify(record)}\n`);
|
|
252
|
+
if (nextHistoryBytes > limits.max_history_bytes) {
|
|
253
|
+
throw new HarneryInboxCapacityError(
|
|
254
|
+
"history_bytes_limit",
|
|
255
|
+
nextHistoryBytes,
|
|
256
|
+
limits.max_history_bytes,
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function readOptions(limits: HarneryInboxLimits) {
|
|
262
|
+
return {
|
|
263
|
+
max_record_bytes: Math.max(limits.max_message_body_bytes * 2, 4_096),
|
|
264
|
+
max_records: limits.max_history_records,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function now(options: HarneryInboxServiceOptions): Date {
|
|
269
|
+
return options.now?.() ?? new Date();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function opaqueId(value: string, field: string): string {
|
|
273
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(value)) throw new Error(`invalid ${field} id`);
|
|
274
|
+
return value;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function boundedDisplay(value: string): string {
|
|
278
|
+
const result = value.trim();
|
|
279
|
+
if (result.length === 0 || Buffer.byteLength(result) > 256)
|
|
280
|
+
throw new Error("invalid display name");
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function validateRecord(record: HarneryInboxRecordV1): void {
|
|
285
|
+
if (record.schema !== HARNERY_INBOX_RECORD_SCHEMA) throw new Error("unknown inbox record schema");
|
|
286
|
+
if (record.kind === "message" && Buffer.byteLength(record.body) !== record.body_bytes) {
|
|
287
|
+
throw new Error(`inbox message ${record.message_id} has invalid body_bytes`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function validateLimits(limits: HarneryInboxLimits): void {
|
|
292
|
+
for (const [field, value] of Object.entries(limits)) {
|
|
293
|
+
if (field === "warning_pressure_ratio") continue;
|
|
294
|
+
if (!Number.isSafeInteger(value) || value <= 0) throw new Error(`invalid inbox limit ${field}`);
|
|
295
|
+
}
|
|
296
|
+
if (limits.warning_pressure_ratio <= 0 || limits.warning_pressure_ratio >= 1) {
|
|
297
|
+
throw new Error("warning_pressure_ratio must be between zero and one");
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function validateSurfaceBudget(budget: HarneryInboxSurfaceBudget): void {
|
|
302
|
+
for (const value of Object.values(budget)) {
|
|
303
|
+
if (!Number.isSafeInteger(value) || value <= 0) throw new Error("invalid inbox surface budget");
|
|
304
|
+
}
|
|
305
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HarneryInboxMessageRecordV1 } from "./contract.ts";
|
|
2
|
+
import type { HarneryInboxService } from "./service.ts";
|
|
3
|
+
|
|
4
|
+
export async function* watchInbox(
|
|
5
|
+
service: HarneryInboxService,
|
|
6
|
+
recipientInstanceId: string,
|
|
7
|
+
options: { signal: AbortSignal; poll_ms?: number },
|
|
8
|
+
): AsyncGenerator<HarneryInboxMessageRecordV1> {
|
|
9
|
+
const seen = new Set<string>();
|
|
10
|
+
while (!options.signal.aborted) {
|
|
11
|
+
try {
|
|
12
|
+
for (const message of service.pending(recipientInstanceId)) {
|
|
13
|
+
if (seen.has(message.message_id)) continue;
|
|
14
|
+
seen.add(message.message_id);
|
|
15
|
+
yield message;
|
|
16
|
+
}
|
|
17
|
+
} catch {
|
|
18
|
+
// A transient missing or incomplete source is retried; no cursor is advanced.
|
|
19
|
+
}
|
|
20
|
+
await delay(options.poll_ms ?? 250, options.signal);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function delay(ms: number, signal: AbortSignal): Promise<void> {
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
const timer = setTimeout(resolve, ms);
|
|
27
|
+
signal.addEventListener(
|
|
28
|
+
"abort",
|
|
29
|
+
() => {
|
|
30
|
+
clearTimeout(timer);
|
|
31
|
+
resolve();
|
|
32
|
+
},
|
|
33
|
+
{ once: true },
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -131,16 +131,22 @@ export function projectPresenceCodecDigests(
|
|
|
131
131
|
break;
|
|
132
132
|
case "context.observed": {
|
|
133
133
|
const measurement = event.payload.measurement;
|
|
134
|
-
if (measurement.state === "observed"
|
|
134
|
+
if (measurement.state === "observed") {
|
|
135
|
+
const usedPercent =
|
|
136
|
+
"used_percent" in measurement.value
|
|
137
|
+
? measurement.value.used_percent
|
|
138
|
+
: measurement.value.limit_tokens > 0
|
|
139
|
+
? (measurement.value.used_tokens / measurement.value.limit_tokens) * 100
|
|
140
|
+
: undefined;
|
|
141
|
+
if (usedPercent === undefined) break;
|
|
135
142
|
slot.context = {
|
|
136
|
-
used_percent: Math.min(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
confidence: measurement.confidence === "exact" ? "exact" : "reported",
|
|
143
|
+
used_percent: Math.min(100, Math.max(0, Math.round(usedPercent))),
|
|
144
|
+
confidence:
|
|
145
|
+
measurement.attestation === "inferred"
|
|
146
|
+
? "estimated"
|
|
147
|
+
: measurement.confidence === "exact"
|
|
148
|
+
? "exact"
|
|
149
|
+
: "reported",
|
|
144
150
|
event_id: event.event_id,
|
|
145
151
|
observed_at: event.time.observed_at,
|
|
146
152
|
};
|