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
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import { spawn } from "node:child_process";
|
|
26
26
|
import {
|
|
27
|
+
closeSync,
|
|
27
28
|
existsSync,
|
|
28
29
|
mkdirSync,
|
|
29
30
|
openSync,
|
|
@@ -34,9 +35,12 @@ import {
|
|
|
34
35
|
writeFileSync,
|
|
35
36
|
} from "node:fs";
|
|
36
37
|
import { join } from "node:path";
|
|
38
|
+
import { coordEnv } from "../../lib/env.ts";
|
|
37
39
|
import { resolveMachineLabel } from "../../lib/machine.ts";
|
|
38
40
|
import { presenceRelayUrl } from "../config.ts";
|
|
39
41
|
import { eventV3ActiveWatchPath } from "../events/v3/reader.ts";
|
|
42
|
+
import { closeProcessLoggers, legacyLogFields, processLogger } from "../storage/logger.ts";
|
|
43
|
+
import { RotatingTextSink } from "../storage/process-log.ts";
|
|
40
44
|
import { buildPresenceBlob, type PresenceBlob } from "./blob.ts";
|
|
41
45
|
import { originUrl, rootCommitSha, sanitizeRefComponent } from "./git.ts";
|
|
42
46
|
import {
|
|
@@ -127,13 +131,15 @@ export function ensureRelayDaemon(coordRoot: string): void {
|
|
|
127
131
|
if (!existsSync(harnBin)) return;
|
|
128
132
|
|
|
129
133
|
mkdirSync(presenceDir(coordRoot), { recursive: true });
|
|
130
|
-
const
|
|
134
|
+
const sharedLogs = coordEnv("SHARED_LOGS") !== "0";
|
|
135
|
+
const log = sharedLogs ? undefined : openSync(logFilePath(coordRoot), "a");
|
|
131
136
|
const child = spawn(harnBin, ["presence", "relay-daemon"], {
|
|
132
137
|
cwd: coordRoot,
|
|
133
138
|
detached: true,
|
|
134
|
-
stdio: ["ignore", log, log],
|
|
139
|
+
stdio: log === undefined ? ["ignore", "ignore", "ignore"] : ["ignore", log, log],
|
|
135
140
|
env: { ...process.env, HARNERY_OUTPUT_SESSION_TEE: "0" },
|
|
136
141
|
});
|
|
142
|
+
if (log !== undefined) closeSync(log);
|
|
137
143
|
child.unref();
|
|
138
144
|
} catch {
|
|
139
145
|
/* best-effort */
|
|
@@ -144,17 +150,32 @@ export function ensureRelayDaemon(coordRoot: string): void {
|
|
|
144
150
|
export async function runRelayDaemon(coordRoot: string): Promise<number> {
|
|
145
151
|
const url = presenceRelayUrl(coordRoot);
|
|
146
152
|
if (!url) {
|
|
147
|
-
|
|
153
|
+
const message = "relay-daemon: no relay configured (presence.relay)";
|
|
154
|
+
console.error(message);
|
|
155
|
+
if (coordEnv("SHARED_LOGS") !== "0") {
|
|
156
|
+
appendPresenceRelayDiagnostic(coordRoot, "relay.configuration_error", { message });
|
|
157
|
+
}
|
|
158
|
+
await closeProcessLoggers();
|
|
148
159
|
return 2;
|
|
149
160
|
}
|
|
150
161
|
if (typeof WebSocket === "undefined") {
|
|
151
|
-
|
|
162
|
+
const message = "relay-daemon: no global WebSocket in this runtime (need Bun or Node >= 21)";
|
|
163
|
+
console.error(message);
|
|
164
|
+
if (coordEnv("SHARED_LOGS") !== "0") {
|
|
165
|
+
appendPresenceRelayDiagnostic(coordRoot, "relay.runtime_error", { message });
|
|
166
|
+
}
|
|
167
|
+
await closeProcessLoggers();
|
|
152
168
|
return 2;
|
|
153
169
|
}
|
|
154
170
|
const sha = rootCommitSha(coordRoot);
|
|
155
171
|
const origin = originUrl(coordRoot);
|
|
156
172
|
if (!sha || !origin) {
|
|
157
|
-
|
|
173
|
+
const message = "relay-daemon: repo has no commits or no origin remote";
|
|
174
|
+
console.error(message);
|
|
175
|
+
if (coordEnv("SHARED_LOGS") !== "0") {
|
|
176
|
+
appendPresenceRelayDiagnostic(coordRoot, "relay.repository_error", { message });
|
|
177
|
+
}
|
|
178
|
+
await closeProcessLoggers();
|
|
158
179
|
return 2;
|
|
159
180
|
}
|
|
160
181
|
|
|
@@ -184,6 +205,9 @@ export async function runRelayDaemon(coordRoot: string): Promise<number> {
|
|
|
184
205
|
|
|
185
206
|
const log = (msg: string) => {
|
|
186
207
|
console.log(`[${new Date().toISOString()}] ${msg}`);
|
|
208
|
+
if (coordEnv("SHARED_LOGS") !== "0") {
|
|
209
|
+
appendPresenceRelayDiagnostic(coordRoot, "relay.lifecycle", { message: msg });
|
|
210
|
+
}
|
|
187
211
|
};
|
|
188
212
|
|
|
189
213
|
const publishNow = async (force = false): Promise<void> => {
|
|
@@ -286,7 +310,8 @@ export async function runRelayDaemon(coordRoot: string): Promise<number> {
|
|
|
286
310
|
} catch {
|
|
287
311
|
/* ignore */
|
|
288
312
|
}
|
|
289
|
-
process.exit(0);
|
|
313
|
+
void closeProcessLoggers().finally(() => process.exit(0));
|
|
314
|
+
return;
|
|
290
315
|
}
|
|
291
316
|
// Idle machine (no live sessions for a while) → exit; hooks restart us.
|
|
292
317
|
if (idleSince && Date.now() - idleSince > IDLE_EXIT_MS) {
|
|
@@ -299,7 +324,7 @@ export async function runRelayDaemon(coordRoot: string): Promise<number> {
|
|
|
299
324
|
} catch {
|
|
300
325
|
/* ignore */
|
|
301
326
|
}
|
|
302
|
-
process.exit(0);
|
|
327
|
+
void closeProcessLoggers().finally(() => process.exit(0));
|
|
303
328
|
}
|
|
304
329
|
}, KEEPALIVE_MS);
|
|
305
330
|
|
|
@@ -307,6 +332,29 @@ export async function runRelayDaemon(coordRoot: string): Promise<number> {
|
|
|
307
332
|
return await new Promise<number>(() => {});
|
|
308
333
|
}
|
|
309
334
|
|
|
335
|
+
export function appendPresenceRelayDiagnostic(
|
|
336
|
+
coordRoot: string,
|
|
337
|
+
event: string,
|
|
338
|
+
fields: Record<string, unknown> = {},
|
|
339
|
+
): "shared" | "legacy" {
|
|
340
|
+
if (coordEnv("SHARED_LOGS") !== "0") {
|
|
341
|
+
try {
|
|
342
|
+
const logger = processLogger(coordRoot, "presence-relay");
|
|
343
|
+
if (event.includes("error")) logger.error(event, legacyLogFields(fields));
|
|
344
|
+
else logger.info(event, legacyLogFields(fields));
|
|
345
|
+
return "shared";
|
|
346
|
+
} catch {
|
|
347
|
+
// Bootstrap failures retain a bounded text file for process diagnostics.
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const sink = new RotatingTextSink({ path: logFilePath(coordRoot), max_bytes: 512 * 1_024 });
|
|
351
|
+
sink.append(
|
|
352
|
+
`${JSON.stringify({ schema_version: 1, ts: new Date().toISOString(), event, ...fields })}\n`,
|
|
353
|
+
);
|
|
354
|
+
sink.close();
|
|
355
|
+
return "legacy";
|
|
356
|
+
}
|
|
357
|
+
|
|
310
358
|
/** Daemon status for `presence peers`/doctor surfaces. */
|
|
311
359
|
export function relayDaemonStatus(coordRoot: string): {
|
|
312
360
|
running: boolean;
|
|
@@ -6,23 +6,22 @@ import { promisify } from "node:util";
|
|
|
6
6
|
import type { TSchema } from "@sinclair/typebox";
|
|
7
7
|
import { whichBin } from "../../lib/headless/index.ts";
|
|
8
8
|
import {
|
|
9
|
-
type SemanticConfiguredModel,
|
|
10
9
|
type SemanticHarness,
|
|
11
10
|
SemanticModelReplyV2Schema,
|
|
11
|
+
type SemanticUsageReceiptV1,
|
|
12
12
|
} from "./contract.ts";
|
|
13
|
+
import { SEMANTIC_READER_ROUTES, type SemanticReaderRoute } from "./routes.ts";
|
|
13
14
|
import type { SemanticReaderResolution } from "./storage.ts";
|
|
15
|
+
import {
|
|
16
|
+
estimateVisibleSemanticUsage,
|
|
17
|
+
nativeSemanticUsage,
|
|
18
|
+
unreportedSemanticUsage,
|
|
19
|
+
} from "./usage.ts";
|
|
14
20
|
|
|
15
21
|
const execFileAsync = promisify(execFile);
|
|
16
22
|
const MAX_OUTPUT_BYTES = 512 * 1024;
|
|
17
23
|
const DEFAULT_TIMEOUT_MS = 90_000;
|
|
18
24
|
|
|
19
|
-
export interface SemanticReaderRoute {
|
|
20
|
-
harness: SemanticHarness;
|
|
21
|
-
binary: string;
|
|
22
|
-
configured_model: SemanticConfiguredModel;
|
|
23
|
-
invocation_model_id: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
25
|
export interface SemanticAdapterSuccess {
|
|
27
26
|
ok: true;
|
|
28
27
|
text: string;
|
|
@@ -30,6 +29,7 @@ export interface SemanticAdapterSuccess {
|
|
|
30
29
|
model_attestation: "verified" | "requested-only";
|
|
31
30
|
duration_ms: number;
|
|
32
31
|
output_bytes: number;
|
|
32
|
+
usage: SemanticUsageReceiptV1;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface SemanticAdapterFailure {
|
|
@@ -42,6 +42,7 @@ export interface SemanticAdapterFailure {
|
|
|
42
42
|
resolved_model_id?: string;
|
|
43
43
|
model_attestation?: "verified" | "requested-only";
|
|
44
44
|
duration_ms: number;
|
|
45
|
+
usage: SemanticUsageReceiptV1;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
export type SemanticAdapterResult = SemanticAdapterSuccess | SemanticAdapterFailure;
|
|
@@ -56,26 +57,7 @@ export interface SemanticAdapter {
|
|
|
56
57
|
): Promise<SemanticAdapterResult>;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
export
|
|
60
|
-
"claude-code": {
|
|
61
|
-
harness: "claude-code",
|
|
62
|
-
binary: "claude",
|
|
63
|
-
configured_model: "haiku-4.5",
|
|
64
|
-
invocation_model_id: "claude-haiku-4-5-20251001",
|
|
65
|
-
},
|
|
66
|
-
codex: {
|
|
67
|
-
harness: "codex",
|
|
68
|
-
binary: "codex",
|
|
69
|
-
configured_model: "gpt-5.6-luna",
|
|
70
|
-
invocation_model_id: "gpt-5.6-luna",
|
|
71
|
-
},
|
|
72
|
-
cursor: {
|
|
73
|
-
harness: "cursor",
|
|
74
|
-
binary: "cursor-agent",
|
|
75
|
-
configured_model: "composer-2.5",
|
|
76
|
-
invocation_model_id: "composer-2.5",
|
|
77
|
-
},
|
|
78
|
-
};
|
|
60
|
+
export { SEMANTIC_READER_ROUTES, type SemanticReaderRoute } from "./routes.ts";
|
|
79
61
|
|
|
80
62
|
export function createSemanticAdapters(): Record<SemanticHarness, SemanticAdapter> {
|
|
81
63
|
return {
|
|
@@ -119,7 +101,12 @@ function createAdapter(route: SemanticReaderRoute): SemanticAdapter {
|
|
|
119
101
|
responseSchema = SemanticModelReplyV2Schema,
|
|
120
102
|
) {
|
|
121
103
|
if (!whichBin(route.binary)) {
|
|
122
|
-
return {
|
|
104
|
+
return {
|
|
105
|
+
ok: false,
|
|
106
|
+
reason_code: "harness_unavailable",
|
|
107
|
+
duration_ms: 0,
|
|
108
|
+
usage: unreportedSemanticUsage(),
|
|
109
|
+
};
|
|
123
110
|
}
|
|
124
111
|
return await invokeRoute(route, prompt, timeoutMs, responseSchema);
|
|
125
112
|
},
|
|
@@ -144,16 +131,22 @@ async function invokeRoute(
|
|
|
144
131
|
});
|
|
145
132
|
pending.child.stdin?.end();
|
|
146
133
|
const { stdout } = await pending;
|
|
147
|
-
const
|
|
148
|
-
|
|
134
|
+
const outputFileText = invocation.outputFile
|
|
135
|
+
? readFileSync(invocation.outputFile, "utf8")
|
|
136
|
+
: undefined;
|
|
137
|
+
const parsed = parseSemanticHarnessOutput(route.harness, stdout, outputFileText);
|
|
149
138
|
if (!parsed.text.trim()) throw new Error("empty semantic response");
|
|
150
|
-
if (
|
|
139
|
+
if (
|
|
140
|
+
parsed.executedModelId &&
|
|
141
|
+
!modelIdsMatch(parsed.executedModelId, route.invocation_model_id)
|
|
142
|
+
) {
|
|
151
143
|
return {
|
|
152
144
|
ok: false,
|
|
153
145
|
reason_code: "model_mismatch",
|
|
154
146
|
resolved_model_id: parsed.executedModelId,
|
|
155
147
|
model_attestation: "verified",
|
|
156
148
|
duration_ms: Date.now() - started,
|
|
149
|
+
usage: parsed.usage ?? unreportedSemanticUsage(),
|
|
157
150
|
};
|
|
158
151
|
}
|
|
159
152
|
return {
|
|
@@ -163,6 +156,7 @@ async function invokeRoute(
|
|
|
163
156
|
model_attestation: parsed.executedModelId ? "verified" : "requested-only",
|
|
164
157
|
duration_ms: Date.now() - started,
|
|
165
158
|
output_bytes: Buffer.byteLength(parsed.text),
|
|
159
|
+
usage: parsed.usage ?? estimateVisibleSemanticUsage(prompt, parsed.text),
|
|
166
160
|
};
|
|
167
161
|
} catch (error) {
|
|
168
162
|
return {
|
|
@@ -171,6 +165,7 @@ async function invokeRoute(
|
|
|
171
165
|
resolved_model_id: route.invocation_model_id,
|
|
172
166
|
model_attestation: "requested-only",
|
|
173
167
|
duration_ms: Date.now() - started,
|
|
168
|
+
usage: unreportedSemanticUsage(),
|
|
174
169
|
};
|
|
175
170
|
} finally {
|
|
176
171
|
rmSync(dir, { recursive: true, force: true });
|
|
@@ -222,6 +217,7 @@ function buildInvocation(
|
|
|
222
217
|
"--ephemeral",
|
|
223
218
|
"--ignore-user-config",
|
|
224
219
|
"--ignore-rules",
|
|
220
|
+
"--json",
|
|
225
221
|
"--output-last-message",
|
|
226
222
|
outputFile,
|
|
227
223
|
"--cd",
|
|
@@ -235,7 +231,7 @@ function buildInvocation(
|
|
|
235
231
|
"-p",
|
|
236
232
|
prompt,
|
|
237
233
|
"--output-format",
|
|
238
|
-
"json",
|
|
234
|
+
"stream-json",
|
|
239
235
|
"--mode",
|
|
240
236
|
"ask",
|
|
241
237
|
"--sandbox",
|
|
@@ -247,28 +243,191 @@ function buildInvocation(
|
|
|
247
243
|
};
|
|
248
244
|
}
|
|
249
245
|
|
|
250
|
-
|
|
246
|
+
export interface ParsedSemanticHarnessOutput {
|
|
247
|
+
text: string;
|
|
248
|
+
executedModelId?: string;
|
|
249
|
+
usage?: SemanticUsageReceiptV1;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function parseSemanticHarnessOutput(
|
|
251
253
|
harness: SemanticHarness,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
stdout: string,
|
|
255
|
+
outputFileText?: string,
|
|
256
|
+
): ParsedSemanticHarnessOutput {
|
|
257
|
+
if (harness === "codex") return parseCodexOutput(stdout, outputFileText);
|
|
258
|
+
if (harness === "cursor") return parseCursorOutput(stdout);
|
|
255
259
|
try {
|
|
256
|
-
const envelope = JSON.parse(
|
|
260
|
+
const envelope = JSON.parse(stdout) as {
|
|
257
261
|
is_error?: boolean;
|
|
258
262
|
result?: unknown;
|
|
263
|
+
structured_output?: unknown;
|
|
259
264
|
model?: unknown;
|
|
265
|
+
usage?: unknown;
|
|
266
|
+
modelUsage?: unknown;
|
|
267
|
+
model_usage?: unknown;
|
|
260
268
|
};
|
|
261
269
|
if (envelope.is_error) throw new Error("harness returned an error envelope");
|
|
270
|
+
const structured = envelope.structured_output;
|
|
271
|
+
const modelUsage = objectValue(envelope.modelUsage) ?? objectValue(envelope.model_usage);
|
|
272
|
+
const modelUsageEntries = modelUsage ? Object.entries(modelUsage) : [];
|
|
273
|
+
const executedModelId =
|
|
274
|
+
typeof envelope.model === "string"
|
|
275
|
+
? envelope.model
|
|
276
|
+
: modelUsageEntries.length === 1
|
|
277
|
+
? modelUsageEntries[0]![0]
|
|
278
|
+
: undefined;
|
|
279
|
+
const usage = parseClaudeUsage(envelope.usage) ?? aggregateClaudeModelUsage(modelUsageEntries);
|
|
262
280
|
return {
|
|
263
|
-
text:
|
|
264
|
-
|
|
281
|
+
text:
|
|
282
|
+
structured !== undefined
|
|
283
|
+
? JSON.stringify(structured)
|
|
284
|
+
: typeof envelope.result === "string"
|
|
285
|
+
? envelope.result
|
|
286
|
+
: "",
|
|
287
|
+
...(executedModelId ? { executedModelId } : {}),
|
|
288
|
+
...(usage ? { usage } : {}),
|
|
265
289
|
};
|
|
266
290
|
} catch (error) {
|
|
267
|
-
if (error instanceof SyntaxError) return { text:
|
|
291
|
+
if (error instanceof SyntaxError) return { text: stdout };
|
|
268
292
|
throw error;
|
|
269
293
|
}
|
|
270
294
|
}
|
|
271
295
|
|
|
296
|
+
function parseCodexOutput(stdout: string, outputFileText?: string): ParsedSemanticHarnessOutput {
|
|
297
|
+
const events = parseJsonLines(stdout);
|
|
298
|
+
const completed = [...events]
|
|
299
|
+
.reverse()
|
|
300
|
+
.find((event) => event.type === "turn.completed" && objectValue(event.usage));
|
|
301
|
+
const usage = completed ? parseCodexUsage(completed.usage) : undefined;
|
|
302
|
+
const streamedText = [...events]
|
|
303
|
+
.reverse()
|
|
304
|
+
.map((event) => objectValue(event.item))
|
|
305
|
+
.find((item) => item?.type === "agent_message" && typeof item.text === "string")?.text;
|
|
306
|
+
return {
|
|
307
|
+
text: outputFileText ?? (typeof streamedText === "string" ? streamedText : ""),
|
|
308
|
+
...(usage ? { usage } : {}),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function parseCursorOutput(stdout: string): ParsedSemanticHarnessOutput {
|
|
313
|
+
const events = parseJsonLines(stdout);
|
|
314
|
+
const init = events.find(
|
|
315
|
+
(event) =>
|
|
316
|
+
event.type === "system" && event.subtype === "init" && typeof event.model === "string",
|
|
317
|
+
);
|
|
318
|
+
const terminal = [...events]
|
|
319
|
+
.reverse()
|
|
320
|
+
.find((event) => event.type === "result" && typeof event.result === "string");
|
|
321
|
+
if (!terminal) {
|
|
322
|
+
try {
|
|
323
|
+
const envelope = JSON.parse(stdout) as Record<string, unknown>;
|
|
324
|
+
if (envelope.is_error) throw new Error("harness returned an error envelope");
|
|
325
|
+
return {
|
|
326
|
+
text: typeof envelope.result === "string" ? envelope.result : "",
|
|
327
|
+
...(typeof envelope.model === "string" ? { executedModelId: envelope.model } : {}),
|
|
328
|
+
...(parseCursorUsage(envelope.usage) ? { usage: parseCursorUsage(envelope.usage) } : {}),
|
|
329
|
+
};
|
|
330
|
+
} catch (error) {
|
|
331
|
+
if (error instanceof SyntaxError) return { text: stdout };
|
|
332
|
+
throw error;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (terminal.is_error) throw new Error("harness returned an error envelope");
|
|
336
|
+
const usage = parseCursorUsage(terminal.usage);
|
|
337
|
+
return {
|
|
338
|
+
text: terminal.result as string,
|
|
339
|
+
...(typeof init?.model === "string" ? { executedModelId: init.model } : {}),
|
|
340
|
+
...(usage ? { usage } : {}),
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function parseClaudeUsage(value: unknown): SemanticUsageReceiptV1 | undefined {
|
|
345
|
+
const usage = objectValue(value);
|
|
346
|
+
if (!usage) return undefined;
|
|
347
|
+
return nativeSemanticUsage({
|
|
348
|
+
input_tokens: usage.input_tokens,
|
|
349
|
+
cached_input_tokens: usage.cache_read_input_tokens,
|
|
350
|
+
cache_creation_input_tokens: usage.cache_creation_input_tokens,
|
|
351
|
+
output_tokens: usage.output_tokens,
|
|
352
|
+
reasoning_tokens: usage.reasoning_tokens ?? usage.reasoning_output_tokens,
|
|
353
|
+
total_tokens: usage.total_tokens,
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function aggregateClaudeModelUsage(
|
|
358
|
+
entries: [string, unknown][],
|
|
359
|
+
): SemanticUsageReceiptV1 | undefined {
|
|
360
|
+
const values: Record<string, number> = {};
|
|
361
|
+
for (const [, raw] of entries) {
|
|
362
|
+
const usage = objectValue(raw);
|
|
363
|
+
if (!usage) continue;
|
|
364
|
+
addNumber(values, "input_tokens", usage.inputTokens);
|
|
365
|
+
addNumber(values, "cached_input_tokens", usage.cacheReadInputTokens);
|
|
366
|
+
addNumber(values, "cache_creation_input_tokens", usage.cacheCreationInputTokens);
|
|
367
|
+
addNumber(values, "output_tokens", usage.outputTokens);
|
|
368
|
+
}
|
|
369
|
+
return nativeSemanticUsage(values);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function parseCodexUsage(value: unknown): SemanticUsageReceiptV1 | undefined {
|
|
373
|
+
const usage = objectValue(value);
|
|
374
|
+
if (!usage) return undefined;
|
|
375
|
+
return nativeSemanticUsage({
|
|
376
|
+
input_tokens: usage.input_tokens,
|
|
377
|
+
cached_input_tokens: usage.cached_input_tokens,
|
|
378
|
+
cache_creation_input_tokens: usage.cache_write_input_tokens,
|
|
379
|
+
output_tokens: usage.output_tokens,
|
|
380
|
+
reasoning_tokens: usage.reasoning_output_tokens,
|
|
381
|
+
total_tokens: usage.total_tokens,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function parseCursorUsage(value: unknown): SemanticUsageReceiptV1 | undefined {
|
|
386
|
+
const usage = objectValue(value);
|
|
387
|
+
if (!usage) return undefined;
|
|
388
|
+
return nativeSemanticUsage({
|
|
389
|
+
input_tokens: usage.inputTokens ?? usage.input_tokens,
|
|
390
|
+
cached_input_tokens:
|
|
391
|
+
usage.cacheReadTokens ?? usage.cachedInputTokens ?? usage.cached_input_tokens,
|
|
392
|
+
cache_creation_input_tokens:
|
|
393
|
+
usage.cacheWriteTokens ?? usage.cacheCreationInputTokens ?? usage.cache_write_input_tokens,
|
|
394
|
+
output_tokens: usage.outputTokens ?? usage.output_tokens,
|
|
395
|
+
reasoning_tokens: usage.reasoningTokens ?? usage.reasoning_output_tokens,
|
|
396
|
+
total_tokens: usage.totalTokens ?? usage.total_tokens,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function parseJsonLines(raw: string): Record<string, unknown>[] {
|
|
401
|
+
return raw
|
|
402
|
+
.split(/\r?\n/)
|
|
403
|
+
.filter((line) => line.trim().length > 0)
|
|
404
|
+
.flatMap((line) => {
|
|
405
|
+
try {
|
|
406
|
+
const value = JSON.parse(line) as unknown;
|
|
407
|
+
return objectValue(value) ? [value as Record<string, unknown>] : [];
|
|
408
|
+
} catch {
|
|
409
|
+
return [];
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function objectValue(value: unknown): Record<string, unknown> | undefined {
|
|
415
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
416
|
+
? (value as Record<string, unknown>)
|
|
417
|
+
: undefined;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function addNumber(target: Record<string, number>, field: string, value: unknown): void {
|
|
421
|
+
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0) {
|
|
422
|
+
target[field] = (target[field] ?? 0) + value;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function modelIdsMatch(attested: string, requested: string): boolean {
|
|
427
|
+
const normalize = (value: string) => value.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
428
|
+
return normalize(attested) === normalize(requested);
|
|
429
|
+
}
|
|
430
|
+
|
|
272
431
|
function semanticChildEnv(): NodeJS.ProcessEnv {
|
|
273
432
|
const env = { ...process.env };
|
|
274
433
|
for (const key of Object.keys(env)) {
|
|
@@ -3,7 +3,10 @@ import { type Static, type TProperties, type TSchema, Type } from "@sinclair/typ
|
|
|
3
3
|
export const SEMANTIC_EVIDENCE_SCHEMA_VERSION = 1 as const;
|
|
4
4
|
export const SEMANTIC_READ_MODEL_SCHEMA_VERSION = 2 as const;
|
|
5
5
|
export const SEMANTIC_EVIDENCE_CONTRACT_VERSION = 1 as const;
|
|
6
|
-
export const SEMANTIC_PROMPT_CONTRACT_VERSION =
|
|
6
|
+
export const SEMANTIC_PROMPT_CONTRACT_VERSION = 4 as const;
|
|
7
|
+
export const SEMANTIC_USAGE_SCHEMA_VERSION = 1 as const;
|
|
8
|
+
export const SEMANTIC_VISIBLE_USAGE_ESTIMATOR_ID = "visible-o200k-base" as const;
|
|
9
|
+
export const SEMANTIC_VISIBLE_USAGE_ESTIMATOR_VERSION = 1 as const;
|
|
7
10
|
|
|
8
11
|
const StrictObject = <T extends TProperties>(properties: T) =>
|
|
9
12
|
Type.Object(properties, { additionalProperties: false });
|
|
@@ -74,6 +77,16 @@ export const SEMANTIC_EVIDENCE_KINDS = [
|
|
|
74
77
|
"recovery",
|
|
75
78
|
"claim-conflict",
|
|
76
79
|
] as const;
|
|
80
|
+
export const SEMANTIC_INVALID_REASON_CODES = [
|
|
81
|
+
"schema",
|
|
82
|
+
"identity",
|
|
83
|
+
"citation",
|
|
84
|
+
"basis",
|
|
85
|
+
"confidence",
|
|
86
|
+
"privacy",
|
|
87
|
+
"unsupported_claim",
|
|
88
|
+
"unknown",
|
|
89
|
+
] as const;
|
|
77
90
|
|
|
78
91
|
export type SemanticHarness = (typeof SEMANTIC_HARNESSES)[number];
|
|
79
92
|
export type SemanticConfiguredModel = (typeof SEMANTIC_CONFIGURED_MODELS)[number];
|
|
@@ -81,6 +94,7 @@ export type SemanticPhase = (typeof SEMANTIC_PHASES)[number];
|
|
|
81
94
|
export type SemanticExpressionCue = (typeof SEMANTIC_EXPRESSION_CUES)[number];
|
|
82
95
|
export type SemanticTag = (typeof SEMANTIC_TAGS)[number];
|
|
83
96
|
export type SemanticEvidenceKind = (typeof SEMANTIC_EVIDENCE_KINDS)[number];
|
|
97
|
+
export type SemanticInvalidReasonCode = (typeof SEMANTIC_INVALID_REASON_CODES)[number];
|
|
84
98
|
export type SemanticBasis =
|
|
85
99
|
| "direct-fact"
|
|
86
100
|
| "deterministic-projection"
|
|
@@ -98,12 +112,67 @@ const ExpressionCueSchema = Type.Union(
|
|
|
98
112
|
);
|
|
99
113
|
const TagSchema = Type.Union(SEMANTIC_TAGS.map((value) => Type.Literal(value)));
|
|
100
114
|
const EvidenceKindSchema = Type.Union(SEMANTIC_EVIDENCE_KINDS.map((value) => Type.Literal(value)));
|
|
115
|
+
const InvalidReasonCodeSchema = Type.Union(
|
|
116
|
+
SEMANTIC_INVALID_REASON_CODES.map((value) => Type.Literal(value)),
|
|
117
|
+
);
|
|
101
118
|
const ConfidenceSchema = Type.Union([
|
|
102
119
|
Type.Literal("high"),
|
|
103
120
|
Type.Literal("medium"),
|
|
104
121
|
Type.Literal("low"),
|
|
105
122
|
]);
|
|
106
123
|
|
|
124
|
+
const NativeUsageTokenSchema = StrictObject({
|
|
125
|
+
value: Type.Integer({ minimum: 0 }),
|
|
126
|
+
provenance: Type.Literal("native"),
|
|
127
|
+
});
|
|
128
|
+
const EstimatedUsageTokenSchema = StrictObject({
|
|
129
|
+
value: Type.Integer({ minimum: 0 }),
|
|
130
|
+
provenance: Type.Literal("estimated"),
|
|
131
|
+
});
|
|
132
|
+
const NativeUsageTokensSchema = StrictObject({
|
|
133
|
+
input_tokens: Type.Optional(NativeUsageTokenSchema),
|
|
134
|
+
cached_input_tokens: Type.Optional(NativeUsageTokenSchema),
|
|
135
|
+
cache_creation_input_tokens: Type.Optional(NativeUsageTokenSchema),
|
|
136
|
+
output_tokens: Type.Optional(NativeUsageTokenSchema),
|
|
137
|
+
reasoning_tokens: Type.Optional(NativeUsageTokenSchema),
|
|
138
|
+
total_tokens: Type.Optional(NativeUsageTokenSchema),
|
|
139
|
+
});
|
|
140
|
+
const EstimatedUsageTokensSchema = StrictObject({
|
|
141
|
+
input_tokens: EstimatedUsageTokenSchema,
|
|
142
|
+
output_tokens: EstimatedUsageTokenSchema,
|
|
143
|
+
total_tokens: EstimatedUsageTokenSchema,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
export const SemanticNativeUsageReceiptV1Schema = StrictObject({
|
|
147
|
+
schema_version: Type.Literal(SEMANTIC_USAGE_SCHEMA_VERSION),
|
|
148
|
+
source: Type.Literal("native"),
|
|
149
|
+
scope: Type.Literal("harness-call"),
|
|
150
|
+
tokens: NativeUsageTokensSchema,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
export const SemanticEstimatedUsageReceiptV1Schema = StrictObject({
|
|
154
|
+
schema_version: Type.Literal(SEMANTIC_USAGE_SCHEMA_VERSION),
|
|
155
|
+
source: Type.Literal("estimated"),
|
|
156
|
+
scope: Type.Literal("visible-payload"),
|
|
157
|
+
estimator: StrictObject({
|
|
158
|
+
id: Type.Literal(SEMANTIC_VISIBLE_USAGE_ESTIMATOR_ID),
|
|
159
|
+
version: Type.Literal(SEMANTIC_VISIBLE_USAGE_ESTIMATOR_VERSION),
|
|
160
|
+
}),
|
|
161
|
+
tokens: EstimatedUsageTokensSchema,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
export const SemanticUnreportedUsageReceiptV1Schema = StrictObject({
|
|
165
|
+
schema_version: Type.Literal(SEMANTIC_USAGE_SCHEMA_VERSION),
|
|
166
|
+
source: Type.Literal("unreported"),
|
|
167
|
+
scope: Type.Literal("unreported"),
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
export const SemanticUsageReceiptV1Schema = Type.Union([
|
|
171
|
+
SemanticNativeUsageReceiptV1Schema,
|
|
172
|
+
SemanticEstimatedUsageReceiptV1Schema,
|
|
173
|
+
SemanticUnreportedUsageReceiptV1Schema,
|
|
174
|
+
]);
|
|
175
|
+
|
|
107
176
|
function SemanticFieldSchema<T extends TSchema>(
|
|
108
177
|
value: T,
|
|
109
178
|
options: {
|
|
@@ -207,12 +276,56 @@ export const SemanticModelReplyV2Schema = StrictObject({
|
|
|
207
276
|
export function semanticModelReplyV2SchemaFor(expected: {
|
|
208
277
|
generation_id: string;
|
|
209
278
|
evidence_digest: string;
|
|
279
|
+
evidence_event_ids: string[];
|
|
210
280
|
}) {
|
|
281
|
+
const citationSchema = Type.Union(
|
|
282
|
+
expected.evidence_event_ids.map((value) => Type.Literal(value)),
|
|
283
|
+
);
|
|
284
|
+
const field = <T extends TSchema>(
|
|
285
|
+
value: T,
|
|
286
|
+
options: {
|
|
287
|
+
allowEmptyCitations?: boolean;
|
|
288
|
+
kind?: "synthesis" | "prediction" | "expression";
|
|
289
|
+
} = {},
|
|
290
|
+
) => {
|
|
291
|
+
const kind = options.kind ?? "synthesis";
|
|
292
|
+
return StrictObject({
|
|
293
|
+
value,
|
|
294
|
+
basis: Type.Literal(kind === "prediction" ? "prediction" : "model-synthesis"),
|
|
295
|
+
confidence:
|
|
296
|
+
kind === "prediction"
|
|
297
|
+
? Type.Literal("low")
|
|
298
|
+
: kind === "expression"
|
|
299
|
+
? Type.Union([Type.Literal("medium"), Type.Literal("low")])
|
|
300
|
+
: ConfidenceSchema,
|
|
301
|
+
evidence_event_ids: Type.Array(citationSchema, {
|
|
302
|
+
minItems: options.allowEmptyCitations ? 0 : 1,
|
|
303
|
+
maxItems: 16,
|
|
304
|
+
uniqueItems: true,
|
|
305
|
+
}),
|
|
306
|
+
});
|
|
307
|
+
};
|
|
211
308
|
return StrictObject({
|
|
212
309
|
schema_version: Type.Literal(SEMANTIC_READ_MODEL_SCHEMA_VERSION),
|
|
213
310
|
generation_id: Type.Literal(expected.generation_id),
|
|
214
311
|
evidence_digest: Type.Literal(expected.evidence_digest),
|
|
215
|
-
meaning:
|
|
312
|
+
meaning: StrictObject({
|
|
313
|
+
headline: field(Type.String({ minLength: 1, maxLength: 60 })),
|
|
314
|
+
summary: field(Type.String({ minLength: 1, maxLength: 240 })),
|
|
315
|
+
phase: field(PhaseSchema),
|
|
316
|
+
expression_cue: Type.Optional(field(ExpressionCueSchema, { kind: "expression" })),
|
|
317
|
+
purpose: Type.Optional(field(Type.String({ minLength: 1, maxLength: 180 }))),
|
|
318
|
+
recent_result: Type.Optional(field(Type.String({ minLength: 1, maxLength: 180 }))),
|
|
319
|
+
attention: Type.Optional(field(Type.String({ minLength: 1, maxLength: 180 }))),
|
|
320
|
+
next_step: Type.Optional(
|
|
321
|
+
field(Type.String({ minLength: 1, maxLength: 180 }), { kind: "prediction" }),
|
|
322
|
+
),
|
|
323
|
+
tags: Type.Optional(
|
|
324
|
+
field(Type.Array(TagSchema, { maxItems: 8, uniqueItems: true }), {
|
|
325
|
+
allowEmptyCitations: true,
|
|
326
|
+
}),
|
|
327
|
+
),
|
|
328
|
+
}),
|
|
216
329
|
});
|
|
217
330
|
}
|
|
218
331
|
|
|
@@ -246,6 +359,7 @@ export const SemanticAcceptedReadModelV2Schema = StrictObject({
|
|
|
246
359
|
...ReadModelBase,
|
|
247
360
|
reader_outcome: Type.Literal("accepted"),
|
|
248
361
|
reader: ResolvedReaderSchema,
|
|
362
|
+
receipt: Type.Optional(StrictObject({ usage: SemanticUsageReceiptV1Schema })),
|
|
249
363
|
meaning: SemanticMeaningV2Schema,
|
|
250
364
|
});
|
|
251
365
|
|
|
@@ -260,6 +374,7 @@ export const SemanticUnavailableReadModelV2Schema = StrictObject({
|
|
|
260
374
|
Type.Literal("model_unavailable"),
|
|
261
375
|
Type.Literal("model_mismatch"),
|
|
262
376
|
]),
|
|
377
|
+
usage: Type.Optional(SemanticUsageReceiptV1Schema),
|
|
263
378
|
}),
|
|
264
379
|
});
|
|
265
380
|
|
|
@@ -267,7 +382,15 @@ export const SemanticInvalidReadModelV2Schema = StrictObject({
|
|
|
267
382
|
...ReadModelBase,
|
|
268
383
|
reader_outcome: Type.Literal("invalid"),
|
|
269
384
|
reader: ResolvedReaderSchema,
|
|
270
|
-
receipt: StrictObject({
|
|
385
|
+
receipt: StrictObject({
|
|
386
|
+
reason_code: Type.Literal("invalid_output"),
|
|
387
|
+
validation_issue_codes: Type.Array(InvalidReasonCodeSchema, {
|
|
388
|
+
minItems: 1,
|
|
389
|
+
maxItems: SEMANTIC_INVALID_REASON_CODES.length,
|
|
390
|
+
uniqueItems: true,
|
|
391
|
+
}),
|
|
392
|
+
usage: Type.Optional(SemanticUsageReceiptV1Schema),
|
|
393
|
+
}),
|
|
271
394
|
});
|
|
272
395
|
|
|
273
396
|
export const SemanticDeferredReadModelV2Schema = StrictObject({
|
|
@@ -294,5 +417,14 @@ export type SemanticField<T> = {
|
|
|
294
417
|
};
|
|
295
418
|
export type SemanticMeaningV2 = Static<typeof SemanticMeaningV2Schema>;
|
|
296
419
|
export type SemanticModelReplyV2 = Static<typeof SemanticModelReplyV2Schema>;
|
|
420
|
+
export type SemanticUsageToken =
|
|
421
|
+
| Static<typeof NativeUsageTokenSchema>
|
|
422
|
+
| Static<typeof EstimatedUsageTokenSchema>;
|
|
423
|
+
export type SemanticNativeUsageReceiptV1 = Static<typeof SemanticNativeUsageReceiptV1Schema>;
|
|
424
|
+
export type SemanticEstimatedUsageReceiptV1 = Static<typeof SemanticEstimatedUsageReceiptV1Schema>;
|
|
425
|
+
export type SemanticUnreportedUsageReceiptV1 = Static<
|
|
426
|
+
typeof SemanticUnreportedUsageReceiptV1Schema
|
|
427
|
+
>;
|
|
428
|
+
export type SemanticUsageReceiptV1 = Static<typeof SemanticUsageReceiptV1Schema>;
|
|
297
429
|
export type SemanticAcceptedReadModelV2 = Static<typeof SemanticAcceptedReadModelV2Schema>;
|
|
298
430
|
export type SemanticAgentReadModelV2 = Static<typeof SemanticAgentReadModelV2Schema>;
|