@cleocode/core 2026.9.20 → 2026.9.22
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/adapters/discovery.d.ts.map +1 -1
- package/dist/adapters/discovery.js +3 -10
- package/dist/adapters/discovery.js.map +1 -1
- package/dist/adrs/link-pipeline.js +2 -2
- package/dist/adrs/link-pipeline.js.map +1 -1
- package/dist/adrs/parse.js +3 -3
- package/dist/adrs/parse.js.map +1 -1
- package/dist/agents/invoke-meta-agent.d.ts.map +1 -1
- package/dist/agents/invoke-meta-agent.js +8 -4
- package/dist/agents/invoke-meta-agent.js.map +1 -1
- package/dist/agents/scaffold.d.ts.map +1 -1
- package/dist/agents/scaffold.js +0 -1
- package/dist/agents/scaffold.js.map +1 -1
- package/dist/bootstrap.d.ts +5 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +45 -21
- package/dist/bootstrap.js.map +1 -1
- package/dist/cloud/crypto.d.ts +47 -0
- package/dist/cloud/crypto.d.ts.map +1 -0
- package/dist/cloud/crypto.js +223 -0
- package/dist/cloud/crypto.js.map +1 -0
- package/dist/cloud/http.d.ts +52 -0
- package/dist/cloud/http.d.ts.map +1 -0
- package/dist/cloud/http.js +98 -0
- package/dist/cloud/http.js.map +1 -0
- package/dist/cloud/index.d.ts +19 -0
- package/dist/cloud/index.d.ts.map +1 -0
- package/dist/cloud/index.js +19 -0
- package/dist/cloud/index.js.map +1 -0
- package/dist/cloud/journal.d.ts +169 -0
- package/dist/cloud/journal.d.ts.map +1 -0
- package/dist/cloud/journal.js +428 -0
- package/dist/cloud/journal.js.map +1 -0
- package/dist/cloud/keys.d.ts +213 -0
- package/dist/cloud/keys.d.ts.map +1 -0
- package/dist/cloud/keys.js +362 -0
- package/dist/cloud/keys.js.map +1 -0
- package/dist/cloud/manifest-check.d.ts +36 -0
- package/dist/cloud/manifest-check.d.ts.map +1 -0
- package/dist/cloud/manifest-check.js +70 -0
- package/dist/cloud/manifest-check.js.map +1 -0
- package/dist/cloud/projects.d.ts +13 -0
- package/dist/cloud/projects.d.ts.map +1 -0
- package/dist/cloud/projects.js +11 -0
- package/dist/cloud/projects.js.map +1 -0
- package/dist/cloud/signing.d.ts +105 -0
- package/dist/cloud/signing.d.ts.map +1 -0
- package/dist/cloud/signing.js +117 -0
- package/dist/cloud/signing.js.map +1 -0
- package/dist/cloud/streams.d.ts +6 -0
- package/dist/cloud/streams.d.ts.map +1 -0
- package/dist/cloud/streams.js +5 -0
- package/dist/cloud/streams.js.map +1 -0
- package/dist/decide/audit.d.ts +131 -0
- package/dist/decide/audit.d.ts.map +1 -0
- package/dist/decide/audit.js +98 -0
- package/dist/decide/audit.js.map +1 -0
- package/dist/decide/budget.d.ts +91 -0
- package/dist/decide/budget.d.ts.map +1 -0
- package/dist/decide/budget.js +194 -0
- package/dist/decide/budget.js.map +1 -0
- package/dist/decide/cache.d.ts +49 -0
- package/dist/decide/cache.d.ts.map +1 -0
- package/dist/decide/cache.js +87 -0
- package/dist/decide/cache.js.map +1 -0
- package/dist/decide/client.d.ts +103 -0
- package/dist/decide/client.d.ts.map +1 -0
- package/dist/decide/client.js +262 -0
- package/dist/decide/client.js.map +1 -0
- package/dist/decide/credentials.d.ts +159 -0
- package/dist/decide/credentials.d.ts.map +1 -0
- package/dist/decide/credentials.js +383 -0
- package/dist/decide/credentials.js.map +1 -0
- package/dist/decide/index.d.ts +18 -0
- package/dist/decide/index.d.ts.map +1 -0
- package/dist/decide/index.js +18 -0
- package/dist/decide/index.js.map +1 -0
- package/dist/decide/jev-wire.d.ts +155 -0
- package/dist/decide/jev-wire.d.ts.map +1 -0
- package/dist/decide/jev-wire.js +420 -0
- package/dist/decide/jev-wire.js.map +1 -0
- package/dist/decide/operations.d.ts +152 -0
- package/dist/decide/operations.d.ts.map +1 -0
- package/dist/decide/operations.js +199 -0
- package/dist/decide/operations.js.map +1 -0
- package/dist/decide/provider.d.ts +90 -0
- package/dist/decide/provider.d.ts.map +1 -0
- package/dist/decide/provider.js +43 -0
- package/dist/decide/provider.js.map +1 -0
- package/dist/decide/site.d.ts +148 -0
- package/dist/decide/site.d.ts.map +1 -0
- package/dist/decide/site.js +181 -0
- package/dist/decide/site.js.map +1 -0
- package/dist/decide/transport.d.ts +67 -0
- package/dist/decide/transport.d.ts.map +1 -0
- package/dist/decide/transport.js +350 -0
- package/dist/decide/transport.js.map +1 -0
- package/dist/dispatch/mutate-projection.d.ts.map +1 -1
- package/dist/dispatch/mutate-projection.js +5 -0
- package/dist/dispatch/mutate-projection.js.map +1 -1
- package/dist/docs/docs-update.d.ts.map +1 -1
- package/dist/docs/docs-update.js +25 -9
- package/dist/docs/docs-update.js.map +1 -1
- package/dist/docs/export-document.js +5963 -2406
- package/dist/docs/export-document.js.map +3 -3
- package/dist/docs/index.d.ts +2 -2
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +1 -1
- package/dist/docs/index.js.map +1 -1
- package/dist/docs/projection.d.ts.map +1 -1
- package/dist/docs/projection.js +2 -3
- package/dist/docs/projection.js.map +1 -1
- package/dist/docs/publish-pr.d.ts +69 -1
- package/dist/docs/publish-pr.d.ts.map +1 -1
- package/dist/docs/publish-pr.js +112 -10
- package/dist/docs/publish-pr.js.map +1 -1
- package/dist/doctor/db-substrate.d.ts +13 -8
- package/dist/doctor/db-substrate.d.ts.map +1 -1
- package/dist/doctor/db-substrate.js +39 -26
- package/dist/doctor/db-substrate.js.map +1 -1
- package/dist/doctor/index.d.ts +2 -0
- package/dist/doctor/index.d.ts.map +1 -1
- package/dist/doctor/index.js +1 -0
- package/dist/doctor/index.js.map +1 -1
- package/dist/doctor/knowledge.d.ts +16 -1
- package/dist/doctor/knowledge.d.ts.map +1 -1
- package/dist/doctor/knowledge.js +58 -32
- package/dist/doctor/knowledge.js.map +1 -1
- package/dist/doctor/nexus-schema-residency.d.ts +1 -1
- package/dist/doctor/nexus-schema-residency.d.ts.map +1 -1
- package/dist/doctor/nexus-schema-residency.js +3 -0
- package/dist/doctor/nexus-schema-residency.js.map +1 -1
- package/dist/doctor/project-identity.d.ts +44 -1
- package/dist/doctor/project-identity.d.ts.map +1 -1
- package/dist/doctor/project-identity.js +237 -10
- package/dist/doctor/project-identity.js.map +1 -1
- package/dist/doctor/projects.d.ts +170 -0
- package/dist/doctor/projects.d.ts.map +1 -0
- package/dist/doctor/projects.js +1075 -0
- package/dist/doctor/projects.js.map +1 -0
- package/dist/doctor/twin-collapse.d.ts +97 -0
- package/dist/doctor/twin-collapse.d.ts.map +1 -0
- package/dist/doctor/twin-collapse.js +168 -0
- package/dist/doctor/twin-collapse.js.map +1 -0
- package/dist/doctor/worktree-orphans.d.ts.map +1 -1
- package/dist/doctor/worktree-orphans.js +13 -29
- package/dist/doctor/worktree-orphans.js.map +1 -1
- package/dist/doctor/worktree-stores.d.ts +128 -0
- package/dist/doctor/worktree-stores.d.ts.map +1 -0
- package/dist/doctor/worktree-stores.js +374 -0
- package/dist/doctor/worktree-stores.js.map +1 -0
- package/dist/engine/engine-ops.d.ts +36 -6
- package/dist/engine/engine-ops.d.ts.map +1 -1
- package/dist/engine/engine-ops.js +115 -14
- package/dist/engine/engine-ops.js.map +1 -1
- package/dist/error-catalog.d.ts.map +1 -1
- package/dist/error-catalog.js +21 -0
- package/dist/error-catalog.js.map +1 -1
- package/dist/error-registry.d.ts.map +1 -1
- package/dist/error-registry.js +40 -0
- package/dist/error-registry.js.map +1 -1
- package/dist/gateway-client/generated/types.gen.d.ts +1 -1
- package/dist/gc/cleanup.d.ts.map +1 -1
- package/dist/gc/cleanup.js +32 -19
- package/dist/gc/cleanup.js.map +1 -1
- package/dist/git/bounded-git.d.ts +170 -0
- package/dist/git/bounded-git.d.ts.map +1 -0
- package/dist/git/bounded-git.js +371 -0
- package/dist/git/bounded-git.js.map +1 -0
- package/dist/git/work-tree.d.ts +20 -0
- package/dist/git/work-tree.d.ts.map +1 -1
- package/dist/git/work-tree.js +20 -2
- package/dist/git/work-tree.js.map +1 -1
- package/dist/hooks/handlers/session-hooks.d.ts +11 -26
- package/dist/hooks/handlers/session-hooks.d.ts.map +1 -1
- package/dist/hooks/handlers/session-hooks.js +18 -47
- package/dist/hooks/handlers/session-hooks.js.map +1 -1
- package/dist/hooks/payload-schemas.d.ts +2 -2
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/init/engine-ops.d.ts.map +1 -1
- package/dist/init/engine-ops.js +23 -1
- package/dist/init/engine-ops.js.map +1 -1
- package/dist/init.d.ts +158 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +578 -53
- package/dist/init.js.map +1 -1
- package/dist/inject/index.d.ts.map +1 -1
- package/dist/inject/index.js +8 -3
- package/dist/inject/index.js.map +1 -1
- package/dist/injection.d.ts +55 -0
- package/dist/injection.d.ts.map +1 -1
- package/dist/injection.js +102 -6
- package/dist/injection.js.map +1 -1
- package/dist/internal.d.ts +11 -7
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +9 -5
- package/dist/internal.js.map +1 -1
- package/dist/issue/diagnostics.d.ts.map +1 -1
- package/dist/issue/diagnostics.js +2 -1
- package/dist/issue/diagnostics.js.map +1 -1
- package/dist/lib/concurrency.d.ts +25 -0
- package/dist/lib/concurrency.d.ts.map +1 -0
- package/dist/lib/concurrency.js +43 -0
- package/dist/lib/concurrency.js.map +1 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lifecycle/engine-ops.d.ts.map +1 -1
- package/dist/lifecycle/engine-ops.js +4 -2
- package/dist/lifecycle/engine-ops.js.map +1 -1
- package/dist/lifecycle/stage-guidance.d.ts +5 -0
- package/dist/lifecycle/stage-guidance.d.ts.map +1 -1
- package/dist/lifecycle/stage-guidance.js +14 -4
- package/dist/lifecycle/stage-guidance.js.map +1 -1
- package/dist/llm/catalog-cache.d.ts +3 -2
- package/dist/llm/catalog-cache.d.ts.map +1 -1
- package/dist/llm/catalog-cache.js +5 -5
- package/dist/llm/catalog-cache.js.map +1 -1
- package/dist/llm/credentials.d.ts +4 -4
- package/dist/llm/credentials.js +6 -6
- package/dist/llm/credentials.js.map +1 -1
- package/dist/llm/plugin-facade.js +4400 -1801
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/llm/stable-device-id.d.ts.map +1 -1
- package/dist/llm/stable-device-id.js +3 -5
- package/dist/llm/stable-device-id.js.map +1 -1
- package/dist/memory/attention.js +31 -31
- package/dist/memory/attention.js.map +1 -1
- package/dist/memory/decision-contradiction.d.ts +152 -0
- package/dist/memory/decision-contradiction.d.ts.map +1 -0
- package/dist/memory/decision-contradiction.js +273 -0
- package/dist/memory/decision-contradiction.js.map +1 -0
- package/dist/memory/decisions.d.ts +42 -11
- package/dist/memory/decisions.d.ts.map +1 -1
- package/dist/memory/decisions.js +153 -56
- package/dist/memory/decisions.js.map +1 -1
- package/dist/memory/dialectic-evaluator.d.ts +7 -0
- package/dist/memory/dialectic-evaluator.d.ts.map +1 -1
- package/dist/memory/dialectic-evaluator.js +23 -8
- package/dist/memory/dialectic-evaluator.js.map +1 -1
- package/dist/memory/dispatch-trace-format.d.ts +39 -0
- package/dist/memory/dispatch-trace-format.d.ts.map +1 -0
- package/dist/memory/dispatch-trace-format.js +54 -0
- package/dist/memory/dispatch-trace-format.js.map +1 -0
- package/dist/memory/dispatch-trace.d.ts.map +1 -1
- package/dist/memory/dispatch-trace.js +1 -27
- package/dist/memory/dispatch-trace.js.map +1 -1
- package/dist/memory/engine-compat.d.ts +2 -0
- package/dist/memory/engine-compat.d.ts.map +1 -1
- package/dist/memory/engine-compat.js +1 -0
- package/dist/memory/engine-compat.js.map +1 -1
- package/dist/memory/import-from-provider.js +3 -3
- package/dist/memory/import-from-provider.js.map +1 -1
- package/dist/memory/learnings.d.ts +2 -2
- package/dist/memory/observation-type-decision.d.ts +96 -0
- package/dist/memory/observation-type-decision.d.ts.map +1 -0
- package/dist/memory/observation-type-decision.js +218 -0
- package/dist/memory/observation-type-decision.js.map +1 -0
- package/dist/memory/redaction.js +2 -0
- package/dist/memory/redaction.js.map +1 -1
- package/dist/memory/retrieval/build-retrieval-bundle.d.ts +9 -2
- package/dist/memory/retrieval/build-retrieval-bundle.d.ts.map +1 -1
- package/dist/memory/retrieval/build-retrieval-bundle.js +42 -11
- package/dist/memory/retrieval/build-retrieval-bundle.js.map +1 -1
- package/dist/memory/retrieval/get-current-session-id.d.ts +5 -0
- package/dist/memory/retrieval/get-current-session-id.d.ts.map +1 -1
- package/dist/memory/retrieval/get-current-session-id.js +7 -2
- package/dist/memory/retrieval/get-current-session-id.js.map +1 -1
- package/dist/memory/retrieval/observe.d.ts.map +1 -1
- package/dist/memory/retrieval/observe.js +30 -29
- package/dist/memory/retrieval/observe.js.map +1 -1
- package/dist/nexus/analyze-orchestrator.d.ts +38 -0
- package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
- package/dist/nexus/analyze-orchestrator.js +136 -48
- package/dist/nexus/analyze-orchestrator.js.map +1 -1
- package/dist/nexus/assessment-projection.d.ts +76 -0
- package/dist/nexus/assessment-projection.d.ts.map +1 -0
- package/dist/nexus/assessment-projection.js +143 -0
- package/dist/nexus/assessment-projection.js.map +1 -0
- package/dist/nexus/assessment-store.d.ts +14 -2
- package/dist/nexus/assessment-store.d.ts.map +1 -1
- package/dist/nexus/assessment-store.js +21 -3
- package/dist/nexus/assessment-store.js.map +1 -1
- package/dist/nexus/checkout-nonce.d.ts +48 -0
- package/dist/nexus/checkout-nonce.d.ts.map +1 -0
- package/dist/nexus/checkout-nonce.js +84 -0
- package/dist/nexus/checkout-nonce.js.map +1 -0
- package/dist/nexus/devices.d.ts +93 -0
- package/dist/nexus/devices.d.ts.map +1 -0
- package/dist/nexus/devices.js +141 -0
- package/dist/nexus/devices.js.map +1 -0
- package/dist/nexus/freshness.d.ts.map +1 -1
- package/dist/nexus/freshness.js +25 -6
- package/dist/nexus/freshness.js.map +1 -1
- package/dist/nexus/git-state.d.ts +225 -0
- package/dist/nexus/git-state.d.ts.map +1 -0
- package/dist/nexus/git-state.js +677 -0
- package/dist/nexus/git-state.js.map +1 -0
- package/dist/nexus/graph-manifest.d.ts +20 -4
- package/dist/nexus/graph-manifest.d.ts.map +1 -1
- package/dist/nexus/graph-manifest.js +40 -5
- package/dist/nexus/graph-manifest.js.map +1 -1
- package/dist/nexus/identity.d.ts +68 -23
- package/dist/nexus/identity.d.ts.map +1 -1
- package/dist/nexus/identity.js +99 -22
- package/dist/nexus/identity.js.map +1 -1
- package/dist/nexus/index.d.ts +5 -2
- package/dist/nexus/index.d.ts.map +1 -1
- package/dist/nexus/index.js +10 -4
- package/dist/nexus/index.js.map +1 -1
- package/dist/nexus/knowledge.d.ts +5 -0
- package/dist/nexus/knowledge.d.ts.map +1 -1
- package/dist/nexus/knowledge.js +40 -5
- package/dist/nexus/knowledge.js.map +1 -1
- package/dist/nexus/legacy-alias.d.ts +60 -0
- package/dist/nexus/legacy-alias.d.ts.map +1 -0
- package/dist/nexus/legacy-alias.js +68 -0
- package/dist/nexus/legacy-alias.js.map +1 -0
- package/dist/nexus/migrate-json-to-sqlite.js +2 -2
- package/dist/nexus/migrate-json-to-sqlite.js.map +1 -1
- package/dist/nexus/ops.d.ts +1 -0
- package/dist/nexus/ops.d.ts.map +1 -1
- package/dist/nexus/path-map.d.ts +264 -20
- package/dist/nexus/path-map.d.ts.map +1 -1
- package/dist/nexus/path-map.js +580 -44
- package/dist/nexus/path-map.js.map +1 -1
- package/dist/nexus/projects-clean.d.ts +9 -1
- package/dist/nexus/projects-clean.d.ts.map +1 -1
- package/dist/nexus/projects-clean.js +126 -14
- package/dist/nexus/projects-clean.js.map +1 -1
- package/dist/nexus/projects-scan.d.ts +56 -1
- package/dist/nexus/projects-scan.d.ts.map +1 -1
- package/dist/nexus/projects-scan.js +144 -3
- package/dist/nexus/projects-scan.js.map +1 -1
- package/dist/nexus/registry-hygiene.d.ts +18 -2
- package/dist/nexus/registry-hygiene.d.ts.map +1 -1
- package/dist/nexus/registry-hygiene.js +37 -11
- package/dist/nexus/registry-hygiene.js.map +1 -1
- package/dist/nexus/registry-roots.d.ts +47 -0
- package/dist/nexus/registry-roots.d.ts.map +1 -0
- package/dist/nexus/registry-roots.js +79 -0
- package/dist/nexus/registry-roots.js.map +1 -0
- package/dist/nexus/registry.d.ts +50 -9
- package/dist/nexus/registry.d.ts.map +1 -1
- package/dist/nexus/registry.js +311 -156
- package/dist/nexus/registry.js.map +1 -1
- package/dist/nexus/stored-roots.d.ts +171 -0
- package/dist/nexus/stored-roots.d.ts.map +1 -0
- package/dist/nexus/stored-roots.js +253 -0
- package/dist/nexus/stored-roots.js.map +1 -0
- package/dist/nexus/transfer.d.ts.map +1 -1
- package/dist/nexus/transfer.js +3 -0
- package/dist/nexus/transfer.js.map +1 -1
- package/dist/nexus/user-profile-hygiene.d.ts +168 -0
- package/dist/nexus/user-profile-hygiene.d.ts.map +1 -0
- package/dist/nexus/user-profile-hygiene.js +305 -0
- package/dist/nexus/user-profile-hygiene.js.map +1 -0
- package/dist/nexus/user-profile.d.ts +53 -2
- package/dist/nexus/user-profile.d.ts.map +1 -1
- package/dist/nexus/user-profile.js +106 -4
- package/dist/nexus/user-profile.js.map +1 -1
- package/dist/orchestrate/lifecycle-ops.d.ts.map +1 -1
- package/dist/orchestrate/lifecycle-ops.js +4 -1
- package/dist/orchestrate/lifecycle-ops.js.map +1 -1
- package/dist/orchestrate/pivot.d.ts.map +1 -1
- package/dist/orchestrate/pivot.js +5 -1
- package/dist/orchestrate/pivot.js.map +1 -1
- package/dist/orchestrate/plan.d.ts.map +1 -1
- package/dist/orchestrate/plan.js +5 -2
- package/dist/orchestrate/plan.js.map +1 -1
- package/dist/orchestrate/query-ops.d.ts +7 -2
- package/dist/orchestrate/query-ops.d.ts.map +1 -1
- package/dist/orchestrate/query-ops.js +17 -6
- package/dist/orchestrate/query-ops.js.map +1 -1
- package/dist/orchestrate/spawn-ops.d.ts +12 -0
- package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
- package/dist/orchestrate/spawn-ops.js +157 -71
- package/dist/orchestrate/spawn-ops.js.map +1 -1
- package/dist/orchestration/bootstrap.d.ts.map +1 -1
- package/dist/orchestration/bootstrap.js +4 -2
- package/dist/orchestration/bootstrap.js.map +1 -1
- package/dist/orchestration/classify-readiness.d.ts +37 -1
- package/dist/orchestration/classify-readiness.d.ts.map +1 -1
- package/dist/orchestration/classify-readiness.js +48 -19
- package/dist/orchestration/classify-readiness.js.map +1 -1
- package/dist/orchestration/index.d.ts +4 -2
- package/dist/orchestration/index.d.ts.map +1 -1
- package/dist/orchestration/index.js +6 -4
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/lead-rollup.d.ts +8 -5
- package/dist/orchestration/lead-rollup.d.ts.map +1 -1
- package/dist/orchestration/lead-rollup.js +32 -15
- package/dist/orchestration/lead-rollup.js.map +1 -1
- package/dist/orchestration/owner-decision-readiness.d.ts +88 -0
- package/dist/orchestration/owner-decision-readiness.d.ts.map +1 -0
- package/dist/orchestration/owner-decision-readiness.js +152 -0
- package/dist/orchestration/owner-decision-readiness.js.map +1 -0
- package/dist/orchestration/parallel.d.ts.map +1 -1
- package/dist/orchestration/parallel.js +10 -17
- package/dist/orchestration/parallel.js.map +1 -1
- package/dist/orchestration/psyche-memory-budget.d.ts +105 -0
- package/dist/orchestration/psyche-memory-budget.d.ts.map +1 -0
- package/dist/orchestration/psyche-memory-budget.js +383 -0
- package/dist/orchestration/psyche-memory-budget.js.map +1 -0
- package/dist/orchestration/spawn-prompt.d.ts +16 -2
- package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
- package/dist/orchestration/spawn-prompt.js +144 -181
- package/dist/orchestration/spawn-prompt.js.map +1 -1
- package/dist/orchestration/spawn.d.ts +7 -0
- package/dist/orchestration/spawn.d.ts.map +1 -1
- package/dist/orchestration/spawn.js +1 -0
- package/dist/orchestration/spawn.js.map +1 -1
- package/dist/orchestration/status.d.ts +8 -3
- package/dist/orchestration/status.d.ts.map +1 -1
- package/dist/orchestration/status.js +9 -6
- package/dist/orchestration/status.js.map +1 -1
- package/dist/orchestration/wave-topic.d.ts +54 -0
- package/dist/orchestration/wave-topic.d.ts.map +1 -0
- package/dist/orchestration/wave-topic.js +68 -0
- package/dist/orchestration/wave-topic.js.map +1 -0
- package/dist/orchestration/waves.d.ts +47 -8
- package/dist/orchestration/waves.d.ts.map +1 -1
- package/dist/orchestration/waves.js +152 -43
- package/dist/orchestration/waves.js.map +1 -1
- package/dist/paths.d.ts +24 -8
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +135 -71
- package/dist/paths.js.map +1 -1
- package/dist/phases/index.d.ts.map +1 -1
- package/dist/phases/index.js +6 -2
- package/dist/phases/index.js.map +1 -1
- package/dist/platform.d.ts +6 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +8 -19
- package/dist/platform.js.map +1 -1
- package/dist/project-info.d.ts +18 -0
- package/dist/project-info.d.ts.map +1 -1
- package/dist/project-info.js +29 -1
- package/dist/project-info.js.map +1 -1
- package/dist/project-lifecycle.d.ts +91 -32
- package/dist/project-lifecycle.d.ts.map +1 -1
- package/dist/project-lifecycle.js +639 -75
- package/dist/project-lifecycle.js.map +1 -1
- package/dist/project-scope.d.ts +104 -4
- package/dist/project-scope.d.ts.map +1 -1
- package/dist/project-scope.js +263 -13
- package/dist/project-scope.js.map +1 -1
- package/dist/project-tombstone.d.ts +111 -0
- package/dist/project-tombstone.d.ts.map +1 -0
- package/dist/project-tombstone.js +220 -0
- package/dist/project-tombstone.js.map +1 -0
- package/dist/release/artifacts.d.ts.map +1 -1
- package/dist/release/artifacts.js +14 -9
- package/dist/release/artifacts.js.map +1 -1
- package/dist/release/ci-evidence.d.ts +233 -0
- package/dist/release/ci-evidence.d.ts.map +1 -0
- package/dist/release/ci-evidence.js +668 -0
- package/dist/release/ci-evidence.js.map +1 -0
- package/dist/release/engine-ops.d.ts.map +1 -1
- package/dist/release/engine-ops.js +3 -3
- package/dist/release/engine-ops.js.map +1 -1
- package/dist/release/github-pr.d.ts +30 -0
- package/dist/release/github-pr.d.ts.map +1 -1
- package/dist/release/github-pr.js +40 -0
- package/dist/release/github-pr.js.map +1 -1
- package/dist/release/plan.d.ts.map +1 -1
- package/dist/release/plan.js +11 -7
- package/dist/release/plan.js.map +1 -1
- package/dist/release/pr-evidence.d.ts +38 -0
- package/dist/release/pr-evidence.d.ts.map +1 -1
- package/dist/release/pr-evidence.js +79 -15
- package/dist/release/pr-evidence.js.map +1 -1
- package/dist/release/reconcile.d.ts.map +1 -1
- package/dist/release/reconcile.js +3 -2
- package/dist/release/reconcile.js.map +1 -1
- package/dist/release/release-manifest.d.ts +2 -1
- package/dist/release/release-manifest.d.ts.map +1 -1
- package/dist/release/release-manifest.js +6 -5
- package/dist/release/release-manifest.js.map +1 -1
- package/dist/render/nexus/graph/index.d.ts +4 -0
- package/dist/render/nexus/graph/index.d.ts.map +1 -1
- package/dist/render/nexus/graph/index.js +57 -0
- package/dist/render/nexus/graph/index.js.map +1 -1
- package/dist/resources/spawn-wrapper.d.ts +8 -1
- package/dist/resources/spawn-wrapper.d.ts.map +1 -1
- package/dist/resources/spawn-wrapper.js +42 -5
- package/dist/resources/spawn-wrapper.js.map +1 -1
- package/dist/routing/build-command-groups.d.ts.map +1 -1
- package/dist/routing/build-command-groups.js +1 -0
- package/dist/routing/build-command-groups.js.map +1 -1
- package/dist/sagas/index.d.ts +1 -1
- package/dist/sagas/index.d.ts.map +1 -1
- package/dist/sagas/index.js +1 -1
- package/dist/sagas/index.js.map +1 -1
- package/dist/sagas/reconcile.d.ts +24 -4
- package/dist/sagas/reconcile.d.ts.map +1 -1
- package/dist/sagas/reconcile.js +226 -100
- package/dist/sagas/reconcile.js.map +1 -1
- package/dist/scaffold/ensure-config.d.ts.map +1 -1
- package/dist/scaffold/ensure-config.js +31 -1
- package/dist/scaffold/ensure-config.js.map +1 -1
- package/dist/scaffold/project-identity.d.ts +2 -8
- package/dist/scaffold/project-identity.d.ts.map +1 -1
- package/dist/scaffold/project-identity.js +5 -21
- package/dist/scaffold/project-identity.js.map +1 -1
- package/dist/security/input-sanitization.d.ts +9 -1
- package/dist/security/input-sanitization.d.ts.map +1 -1
- package/dist/security/input-sanitization.js +20 -3
- package/dist/security/input-sanitization.js.map +1 -1
- package/dist/selfimprove/fix-gen.js +4409 -1810
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/sentient/propose-tick.d.ts.map +1 -1
- package/dist/sentient/propose-tick.js +4 -2
- package/dist/sentient/propose-tick.js.map +1 -1
- package/dist/sequence/index.d.ts.map +1 -1
- package/dist/sequence/index.js +6 -23
- package/dist/sequence/index.js.map +1 -1
- package/dist/session/engine-ops.d.ts +15 -0
- package/dist/session/engine-ops.d.ts.map +1 -1
- package/dist/session/engine-ops.js +146 -22
- package/dist/session/engine-ops.js.map +1 -1
- package/dist/sessions/assumptions.d.ts.map +1 -1
- package/dist/sessions/assumptions.js +7 -4
- package/dist/sessions/assumptions.js.map +1 -1
- package/dist/sessions/briefing.d.ts +23 -0
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/briefing.js +59 -9
- package/dist/sessions/briefing.js.map +1 -1
- package/dist/sessions/decisions.d.ts +38 -3
- package/dist/sessions/decisions.d.ts.map +1 -1
- package/dist/sessions/decisions.js +235 -21
- package/dist/sessions/decisions.js.map +1 -1
- package/dist/sessions/drift-watchdog.d.ts.map +1 -1
- package/dist/sessions/drift-watchdog.js +8 -5
- package/dist/sessions/drift-watchdog.js.map +1 -1
- package/dist/sessions/focus-state-store.d.ts +89 -1
- package/dist/sessions/focus-state-store.d.ts.map +1 -1
- package/dist/sessions/focus-state-store.js +97 -1
- package/dist/sessions/focus-state-store.js.map +1 -1
- package/dist/sessions/index.d.ts +2 -2
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/index.js +34 -5
- package/dist/sessions/index.js.map +1 -1
- package/dist/sessions/session-drift.d.ts.map +1 -1
- package/dist/sessions/session-drift.js +4 -3
- package/dist/sessions/session-drift.js.map +1 -1
- package/dist/sessions/session-end-snapshot-entry.d.ts +26 -0
- package/dist/sessions/session-end-snapshot-entry.d.ts.map +1 -0
- package/dist/sessions/session-end-snapshot-entry.js +59 -0
- package/dist/sessions/session-end-snapshot-entry.js.map +1 -0
- package/dist/sessions/session-end-snapshot.d.ts +114 -0
- package/dist/sessions/session-end-snapshot.d.ts.map +1 -0
- package/dist/sessions/session-end-snapshot.js +446 -0
- package/dist/sessions/session-end-snapshot.js.map +1 -0
- package/dist/sessions/session-manifest-mirror.d.ts.map +1 -1
- package/dist/sessions/session-manifest-mirror.js +10 -17
- package/dist/sessions/session-manifest-mirror.js.map +1 -1
- package/dist/sessions/session-switch.d.ts.map +1 -1
- package/dist/sessions/session-switch.js +5 -3
- package/dist/sessions/session-switch.js.map +1 -1
- package/dist/sessions/snapshot.d.ts.map +1 -1
- package/dist/sessions/snapshot.js +5 -4
- package/dist/sessions/snapshot.js.map +1 -1
- package/dist/sessions/terminal-identity.d.ts +169 -0
- package/dist/sessions/terminal-identity.d.ts.map +1 -0
- package/dist/sessions/terminal-identity.js +273 -0
- package/dist/sessions/terminal-identity.js.map +1 -0
- package/dist/setup/sections/verification.d.ts +1 -1
- package/dist/setup/sections/verification.d.ts.map +1 -1
- package/dist/setup/sections/verification.js +11 -15
- package/dist/setup/sections/verification.js.map +1 -1
- package/dist/skills/discovery.d.ts +20 -3
- package/dist/skills/discovery.d.ts.map +1 -1
- package/dist/skills/discovery.js +41 -4
- package/dist/skills/discovery.js.map +1 -1
- package/dist/skills/dispatch.d.ts +5 -2
- package/dist/skills/dispatch.d.ts.map +1 -1
- package/dist/skills/dispatch.js +5 -2
- package/dist/skills/dispatch.js.map +1 -1
- package/dist/skills/doctor.d.ts.map +1 -1
- package/dist/skills/doctor.js +5 -1
- package/dist/skills/doctor.js.map +1 -1
- package/dist/skills/federated-search.js +2 -2
- package/dist/skills/federated-search.js.map +1 -1
- package/dist/skills/index.d.ts +3 -3
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/migration.d.ts +5 -5
- package/dist/skills/migration.d.ts.map +1 -1
- package/dist/skills/migration.js +7 -9
- package/dist/skills/migration.js.map +1 -1
- package/dist/skills/orchestrator/startup.d.ts.map +1 -1
- package/dist/skills/orchestrator/startup.js +14 -7
- package/dist/skills/orchestrator/startup.js.map +1 -1
- package/dist/skills/prune-bundled.d.ts +267 -0
- package/dist/skills/prune-bundled.d.ts.map +1 -0
- package/dist/skills/prune-bundled.js +536 -0
- package/dist/skills/prune-bundled.js.map +1 -0
- package/dist/skills/skill-paths.d.ts +30 -3
- package/dist/skills/skill-paths.d.ts.map +1 -1
- package/dist/skills/skill-paths.js +28 -9
- package/dist/skills/skill-paths.js.map +1 -1
- package/dist/skills/skill-root.d.ts +60 -11
- package/dist/skills/skill-root.d.ts.map +1 -1
- package/dist/skills/skill-root.js +100 -14
- package/dist/skills/skill-root.js.map +1 -1
- package/dist/skills/skills-guard.js +5 -5
- package/dist/skills/skills-guard.js.map +1 -1
- package/dist/skills/types.d.ts +32 -1
- package/dist/skills/types.d.ts.map +1 -1
- package/dist/skills/types.js +17 -34
- package/dist/skills/types.js.map +1 -1
- package/dist/spawn/agent-identity.d.ts +51 -2
- package/dist/spawn/agent-identity.d.ts.map +1 -1
- package/dist/spawn/agent-identity.js +89 -26
- package/dist/spawn/agent-identity.js.map +1 -1
- package/dist/spawn/branch-lock.d.ts.map +1 -1
- package/dist/spawn/branch-lock.js +80 -79
- package/dist/spawn/branch-lock.js.map +1 -1
- package/dist/spawn/index.d.ts +2 -2
- package/dist/spawn/index.d.ts.map +1 -1
- package/dist/spawn/index.js +1 -1
- package/dist/spawn/index.js.map +1 -1
- package/dist/spawn/worktree-lock-holder.d.ts +37 -0
- package/dist/spawn/worktree-lock-holder.d.ts.map +1 -0
- package/dist/spawn/worktree-lock-holder.js +41 -0
- package/dist/spawn/worktree-lock-holder.js.map +1 -0
- package/dist/stats/index.d.ts.map +1 -1
- package/dist/stats/index.js +4 -2
- package/dist/stats/index.js.map +1 -1
- package/dist/sticky/convert.d.ts.map +1 -1
- package/dist/sticky/convert.js +16 -4
- package/dist/sticky/convert.js.map +1 -1
- package/dist/store/attachment-store.d.ts +14 -0
- package/dist/store/attachment-store.d.ts.map +1 -1
- package/dist/store/attachment-store.js +11 -1
- package/dist/store/attachment-store.js.map +1 -1
- package/dist/store/backup-inspect.d.ts +7 -3
- package/dist/store/backup-inspect.d.ts.map +1 -1
- package/dist/store/backup-inspect.js +18 -7
- package/dist/store/backup-inspect.js.map +1 -1
- package/dist/store/backup-sidecar.d.ts +60 -0
- package/dist/store/backup-sidecar.d.ts.map +1 -0
- package/dist/store/backup-sidecar.js +96 -0
- package/dist/store/backup-sidecar.js.map +1 -0
- package/dist/store/data-accessor.d.ts +1 -1
- package/dist/store/data-accessor.d.ts.map +1 -1
- package/dist/store/data-accessor.js +6 -6
- package/dist/store/data-accessor.js.map +1 -1
- package/dist/store/data-safety-central.d.ts +13 -4
- package/dist/store/data-safety-central.d.ts.map +1 -1
- package/dist/store/data-safety-central.js +31 -4
- package/dist/store/data-safety-central.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +10 -0
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/exodus/__fixtures__/representative-fixture.d.ts.map +1 -1
- package/dist/store/exodus/__fixtures__/representative-fixture.js +4 -0
- package/dist/store/exodus/__fixtures__/representative-fixture.js.map +1 -1
- package/dist/store/exodus/migrate.js +1 -1
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/exodus/reconcile.js +1 -1
- package/dist/store/exodus/reconcile.js.map +1 -1
- package/dist/store/exodus/runtime-targets.d.ts +4 -3
- package/dist/store/exodus/runtime-targets.d.ts.map +1 -1
- package/dist/store/exodus/runtime-targets.js +4 -3
- package/dist/store/exodus/runtime-targets.js.map +1 -1
- package/dist/store/import-logging.d.ts.map +1 -1
- package/dist/store/import-logging.js +5 -4
- package/dist/store/import-logging.js.map +1 -1
- package/dist/store/legacy-tasks-lineage.d.ts.map +1 -1
- package/dist/store/legacy-tasks-lineage.js +2 -7
- package/dist/store/legacy-tasks-lineage.js.map +1 -1
- package/dist/store/lock.d.ts +1 -0
- package/dist/store/lock.d.ts.map +1 -1
- package/dist/store/lock.js +1 -0
- package/dist/store/lock.js.map +1 -1
- package/dist/store/memory-accessor.d.ts +8 -3
- package/dist/store/memory-accessor.d.ts.map +1 -1
- package/dist/store/memory-accessor.js +29 -13
- package/dist/store/memory-accessor.js.map +1 -1
- package/dist/store/memory-sqlite.d.ts.map +1 -1
- package/dist/store/memory-sqlite.js +5 -0
- package/dist/store/memory-sqlite.js.map +1 -1
- package/dist/store/open-cleo-db.d.ts.map +1 -1
- package/dist/store/open-cleo-db.js +11 -6
- package/dist/store/open-cleo-db.js.map +1 -1
- package/dist/store/portable-bundle-relocate.d.ts +13 -8
- package/dist/store/portable-bundle-relocate.d.ts.map +1 -1
- package/dist/store/portable-bundle-relocate.js +75 -31
- package/dist/store/portable-bundle-relocate.js.map +1 -1
- package/dist/store/portable-bundle-scan.d.ts.map +1 -1
- package/dist/store/portable-bundle-scan.js +2 -1
- package/dist/store/portable-bundle-scan.js.map +1 -1
- package/dist/store/portable-bundle.d.ts.map +1 -1
- package/dist/store/portable-bundle.js +7 -3
- package/dist/store/portable-bundle.js.map +1 -1
- package/dist/store/pre-repair-snapshot.d.ts +77 -0
- package/dist/store/pre-repair-snapshot.d.ts.map +1 -0
- package/dist/store/pre-repair-snapshot.js +122 -0
- package/dist/store/pre-repair-snapshot.js.map +1 -0
- package/dist/store/regenerators.d.ts +2 -1
- package/dist/store/regenerators.d.ts.map +1 -1
- package/dist/store/regenerators.js +17 -3
- package/dist/store/regenerators.js.map +1 -1
- package/dist/store/relocated-store-guard.d.ts +71 -0
- package/dist/store/relocated-store-guard.d.ts.map +1 -0
- package/dist/store/relocated-store-guard.js +138 -0
- package/dist/store/relocated-store-guard.js.map +1 -0
- package/dist/store/safety-data-accessor.d.ts +2 -2
- package/dist/store/safety-data-accessor.d.ts.map +1 -1
- package/dist/store/safety-data-accessor.js +2 -2
- package/dist/store/safety-data-accessor.js.map +1 -1
- package/dist/store/schema/attachments.d.ts +2 -2
- package/dist/store/schema/audit.d.ts +5 -5
- package/dist/store/schema/background-jobs.d.ts +1 -1
- package/dist/store/schema/cleo-global/models-catalog.d.ts +1 -1
- package/dist/store/schema/cleo-global/nexus.d.ts +686 -0
- package/dist/store/schema/cleo-global/nexus.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/nexus.js +175 -7
- package/dist/store/schema/cleo-global/nexus.js.map +1 -1
- package/dist/store/schema/cleo-global/skills.d.ts +2 -2
- package/dist/store/schema/cleo-project/audit.d.ts +5 -5
- package/dist/store/schema/cleo-project/docs.d.ts +3 -3
- package/dist/store/schema/cleo-project/lifecycle.d.ts +3 -3
- package/dist/store/schema/cleo-project/provenance-commits.d.ts +2 -2
- package/dist/store/schema/cleo-project/provenance-rest.d.ts +3 -3
- package/dist/store/schema/cleo-project/tasks-core-batch2.d.ts +1 -1
- package/dist/store/schema/cleo-project/tasks-core.d.ts +6 -6
- package/dist/store/schema/cleo-shared/brain.d.ts +26 -26
- package/dist/store/schema/lifecycle.d.ts +3 -3
- package/dist/store/schema/manifest.d.ts +1 -1
- package/dist/store/schema/memory-schema.d.ts +26 -26
- package/dist/store/schema/nexus-schema.d.ts +696 -2
- package/dist/store/schema/nexus-schema.d.ts.map +1 -1
- package/dist/store/schema/nexus-schema.js +175 -19
- package/dist/store/schema/nexus-schema.js.map +1 -1
- package/dist/store/schema/provenance/releases.d.ts +1 -1
- package/dist/store/schema/skills-schema.d.ts +2 -2
- package/dist/store/schema/tasks.d.ts +5 -5
- package/dist/store/session-binding-schema.d.ts +132 -0
- package/dist/store/session-binding-schema.d.ts.map +1 -0
- package/dist/store/session-binding-schema.js +53 -0
- package/dist/store/session-binding-schema.js.map +1 -0
- package/dist/store/session-store.d.ts +262 -4
- package/dist/store/session-store.d.ts.map +1 -1
- package/dist/store/session-store.js +486 -26
- package/dist/store/session-store.js.map +1 -1
- package/dist/store/skills-db.d.ts +17 -0
- package/dist/store/skills-db.d.ts.map +1 -1
- package/dist/store/skills-db.js +30 -0
- package/dist/store/skills-db.js.map +1 -1
- package/dist/store/snapshot-gate.d.ts +239 -0
- package/dist/store/snapshot-gate.d.ts.map +1 -0
- package/dist/store/snapshot-gate.js +401 -0
- package/dist/store/snapshot-gate.js.map +1 -0
- package/dist/store/split-brain-import.js +2 -2
- package/dist/store/split-brain-import.js.map +1 -1
- package/dist/store/sqlite-backup.d.ts +55 -13
- package/dist/store/sqlite-backup.d.ts.map +1 -1
- package/dist/store/sqlite-backup.js +414 -106
- package/dist/store/sqlite-backup.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts +15 -0
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +73 -4
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/sqlite.d.ts +15 -1
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +75 -5
- package/dist/store/sqlite.js.map +1 -1
- package/dist/store/store-write-guard.d.ts +28 -0
- package/dist/store/store-write-guard.d.ts.map +1 -0
- package/dist/store/store-write-guard.js +50 -0
- package/dist/store/store-write-guard.js.map +1 -0
- package/dist/store/table-classification.d.ts +143 -0
- package/dist/store/table-classification.d.ts.map +1 -0
- package/dist/store/table-classification.js +1866 -0
- package/dist/store/table-classification.js.map +1 -0
- package/dist/store/task-version.d.ts +72 -0
- package/dist/store/task-version.d.ts.map +1 -0
- package/dist/store/task-version.js +93 -0
- package/dist/store/task-version.js.map +1 -0
- package/dist/store/tasks-schema.d.ts +1 -0
- package/dist/store/tasks-schema.d.ts.map +1 -1
- package/dist/store/tasks-schema.js +13 -0
- package/dist/store/tasks-schema.js.map +1 -1
- package/dist/store/tasks-sqlite.d.ts +10 -3
- package/dist/store/tasks-sqlite.d.ts.map +1 -1
- package/dist/store/tasks-sqlite.js +12 -3
- package/dist/store/tasks-sqlite.js.map +1 -1
- package/dist/store/twin-collapse.d.ts +320 -0
- package/dist/store/twin-collapse.d.ts.map +1 -0
- package/dist/store/twin-collapse.js +931 -0
- package/dist/store/twin-collapse.js.map +1 -0
- package/dist/store/umbrella-data-accessor.d.ts +2 -2
- package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
- package/dist/store/umbrella-data-accessor.js +2 -2
- package/dist/store/umbrella-data-accessor.js.map +1 -1
- package/dist/store/validation-schemas.d.ts +63 -63
- package/dist/store/worktree-isolation-guard.d.ts +46 -24
- package/dist/store/worktree-isolation-guard.d.ts.map +1 -1
- package/dist/store/worktree-isolation-guard.js +71 -50
- package/dist/store/worktree-isolation-guard.js.map +1 -1
- package/dist/system/backup.d.ts.map +1 -1
- package/dist/system/backup.js +3 -67
- package/dist/system/backup.js.map +1 -1
- package/dist/system/cleo-link.d.ts +163 -0
- package/dist/system/cleo-link.d.ts.map +1 -0
- package/dist/system/cleo-link.js +246 -0
- package/dist/system/cleo-link.js.map +1 -0
- package/dist/system/dependencies.d.ts.map +1 -1
- package/dist/system/dependencies.js +3 -6
- package/dist/system/dependencies.js.map +1 -1
- package/dist/system/global-delivery.d.ts +205 -0
- package/dist/system/global-delivery.d.ts.map +1 -0
- package/dist/system/global-delivery.js +320 -0
- package/dist/system/global-delivery.js.map +1 -0
- package/dist/system/health.d.ts.map +1 -1
- package/dist/system/health.js +29 -6
- package/dist/system/health.js.map +1 -1
- package/dist/system/inject-generate.d.ts.map +1 -1
- package/dist/system/inject-generate.js +4 -4
- package/dist/system/inject-generate.js.map +1 -1
- package/dist/system/project-health.d.ts.map +1 -1
- package/dist/system/project-health.js +1 -20
- package/dist/system/project-health.js.map +1 -1
- package/dist/system/runtime.d.ts.map +1 -1
- package/dist/system/runtime.js +2 -12
- package/dist/system/runtime.js.map +1 -1
- package/dist/system/safestop.d.ts.map +1 -1
- package/dist/system/safestop.js +5 -2
- package/dist/system/safestop.js.map +1 -1
- package/dist/system/skill-fixtures.d.ts +200 -0
- package/dist/system/skill-fixtures.d.ts.map +1 -0
- package/dist/system/skill-fixtures.js +331 -0
- package/dist/system/skill-fixtures.js.map +1 -0
- package/dist/task-work/index.d.ts +6 -0
- package/dist/task-work/index.d.ts.map +1 -1
- package/dist/task-work/index.js +6 -3
- package/dist/task-work/index.js.map +1 -1
- package/dist/tasks/add.d.ts.map +1 -1
- package/dist/tasks/add.js +4 -2
- package/dist/tasks/add.js.map +1 -1
- package/dist/tasks/affected-packages.d.ts +218 -0
- package/dist/tasks/affected-packages.d.ts.map +1 -0
- package/dist/tasks/affected-packages.js +496 -0
- package/dist/tasks/affected-packages.js.map +1 -0
- package/dist/tasks/affected-scope.d.ts +59 -0
- package/dist/tasks/affected-scope.d.ts.map +1 -0
- package/dist/tasks/affected-scope.js +81 -0
- package/dist/tasks/affected-scope.js.map +1 -0
- package/dist/tasks/analyze.d.ts.map +1 -1
- package/dist/tasks/analyze.js +7 -2
- package/dist/tasks/analyze.js.map +1 -1
- package/dist/tasks/change-set.d.ts +175 -0
- package/dist/tasks/change-set.d.ts.map +1 -0
- package/dist/tasks/change-set.js +753 -0
- package/dist/tasks/change-set.js.map +1 -0
- package/dist/tasks/complete.d.ts +10 -0
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +59 -5
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/component-pr.d.ts +106 -0
- package/dist/tasks/component-pr.d.ts.map +1 -0
- package/dist/tasks/component-pr.js +190 -0
- package/dist/tasks/component-pr.js.map +1 -0
- package/dist/tasks/done-plan.d.ts +123 -0
- package/dist/tasks/done-plan.d.ts.map +1 -0
- package/dist/tasks/done-plan.js +696 -0
- package/dist/tasks/done-plan.js.map +1 -0
- package/dist/tasks/done-record.d.ts +127 -0
- package/dist/tasks/done-record.d.ts.map +1 -0
- package/dist/tasks/done-record.js +302 -0
- package/dist/tasks/done-record.js.map +1 -0
- package/dist/tasks/duplicate-detector.d.ts +68 -11
- package/dist/tasks/duplicate-detector.d.ts.map +1 -1
- package/dist/tasks/duplicate-detector.js +314 -58
- package/dist/tasks/duplicate-detector.js.map +1 -1
- package/dist/tasks/evidence-paths.d.ts +78 -0
- package/dist/tasks/evidence-paths.d.ts.map +1 -0
- package/dist/tasks/evidence-paths.js +150 -0
- package/dist/tasks/evidence-paths.js.map +1 -0
- package/dist/tasks/evidence.d.ts +101 -1
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +278 -31
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/gate-preview.d.ts +5 -0
- package/dist/tasks/gate-preview.d.ts.map +1 -1
- package/dist/tasks/gate-preview.js +25 -21
- package/dist/tasks/gate-preview.js.map +1 -1
- package/dist/tasks/gate-result-cache.d.ts +205 -0
- package/dist/tasks/gate-result-cache.d.ts.map +1 -0
- package/dist/tasks/gate-result-cache.js +285 -0
- package/dist/tasks/gate-result-cache.js.map +1 -0
- package/dist/tasks/gate-runner.d.ts +126 -3
- package/dist/tasks/gate-runner.d.ts.map +1 -1
- package/dist/tasks/gate-runner.js +483 -28
- package/dist/tasks/gate-runner.js.map +1 -1
- package/dist/tasks/session-scope.d.ts +3 -1
- package/dist/tasks/session-scope.d.ts.map +1 -1
- package/dist/tasks/session-scope.js +18 -3
- package/dist/tasks/session-scope.js.map +1 -1
- package/dist/tasks/task-next.d.ts +4 -0
- package/dist/tasks/task-next.d.ts.map +1 -1
- package/dist/tasks/task-next.js +32 -28
- package/dist/tasks/task-next.js.map +1 -1
- package/dist/tasks/tool-resolver.d.ts +23 -6
- package/dist/tasks/tool-resolver.d.ts.map +1 -1
- package/dist/tasks/tool-resolver.js +146 -8
- package/dist/tasks/tool-resolver.js.map +1 -1
- package/dist/tasks/tool-vacuity.d.ts +71 -0
- package/dist/tasks/tool-vacuity.d.ts.map +1 -0
- package/dist/tasks/tool-vacuity.js +334 -0
- package/dist/tasks/tool-vacuity.js.map +1 -0
- package/dist/tasks/update.d.ts +8 -0
- package/dist/tasks/update.d.ts.map +1 -1
- package/dist/tasks/update.js +159 -78
- package/dist/tasks/update.js.map +1 -1
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +18 -2
- package/dist/upgrade.js.map +1 -1
- package/dist/validation/doctor/checks.d.ts +20 -2
- package/dist/validation/doctor/checks.d.ts.map +1 -1
- package/dist/validation/doctor/checks.js +64 -4
- package/dist/validation/doctor/checks.js.map +1 -1
- package/dist/validation/doctor/index.d.ts +1 -1
- package/dist/validation/doctor/index.d.ts.map +1 -1
- package/dist/validation/doctor/index.js +1 -1
- package/dist/validation/doctor/index.js.map +1 -1
- package/dist/validation/doctor/utils.d.ts.map +1 -1
- package/dist/validation/doctor/utils.js +7 -2
- package/dist/validation/doctor/utils.js.map +1 -1
- package/dist/validation/engine-ops.d.ts +24 -1
- package/dist/validation/engine-ops.d.ts.map +1 -1
- package/dist/validation/engine-ops.js +272 -98
- package/dist/validation/engine-ops.js.map +1 -1
- package/dist/validation/validate-ops.d.ts.map +1 -1
- package/dist/validation/validate-ops.js +9 -3
- package/dist/validation/validate-ops.js.map +1 -1
- package/dist/worktree/worktree-adopt.d.ts.map +1 -1
- package/dist/worktree/worktree-adopt.js +5 -2
- package/dist/worktree/worktree-adopt.js.map +1 -1
- package/migrations/drizzle-cleo-global/20260927000000_t12469-project-locations/migration.sql +121 -0
- package/migrations/drizzle-cleo-global/20260927010000_t12543-user-profile-project-scope/migration.sql +23 -0
- package/migrations/drizzle-cleo-global/20260928010000_t12470-location-candidates/migration.sql +72 -0
- package/migrations/drizzle-cleo-global/20260928020000_t12510-nexus-devices/migration.sql +34 -0
- package/migrations/drizzle-cleo-global/20260928030000_t12511-project-git-state/migration.sql +62 -0
- package/migrations/drizzle-cleo-project/20260927000000_t12499-session-terminal-bindings/migration.sql +34 -0
- package/migrations/drizzle-cleo-project/20260928000000_t12500-binding-provider-flag/migration.sql +15 -0
- package/package.json +23 -13
- package/schemas/config.schema.json +54 -0
- package/schemas/project-context.schema.json +51 -3
- package/schemas/project-info.schema.json +28 -1
- package/templates/CLEO-INJECTION.md +40 -332
- package/templates/CLEO-REFERENCE.md +303 -0
- package/templates/workflows/README.md +36 -14
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request budget for decision providers — a token bucket shared by every CLEO
|
|
3
|
+
* process on the machine.
|
|
4
|
+
*
|
|
5
|
+
* The provider allows 600 requests/minute per key. Every CLEO process (CLI
|
|
6
|
+
* invocations, the sentient daemon, spawned agents) draws from ONE bucket whose
|
|
7
|
+
* state lives in `<cleoHome>/decide/budget.json`, guarded by a `proper-lockfile`
|
|
8
|
+
* lock — the same cross-process state-file pattern as
|
|
9
|
+
* `llm/rate-limit-guard.ts`, with much shorter lock retries because a decision
|
|
10
|
+
* has a sub-second budget.
|
|
11
|
+
*
|
|
12
|
+
* ## Why capacity 60 + 540/min, not 600 + 600/min
|
|
13
|
+
*
|
|
14
|
+
* A bucket of capacity `C` refilled at `r` admits at most `C + r·W` requests in
|
|
15
|
+
* any window `W`. The defaults (60 + 540/min) keep every 60-second window at or
|
|
16
|
+
* under 600 even after an idle period, so the budget itself never triggers a
|
|
17
|
+
* 429. A 429 still happens if the key is shared with non-CLEO clients; then
|
|
18
|
+
* {@link DecisionBudget.penalize} empties the bucket and blocks every process
|
|
19
|
+
* until the server's `retry-after` has passed.
|
|
20
|
+
*
|
|
21
|
+
* The bucket fails CLOSED: if the lock cannot be taken quickly or the state
|
|
22
|
+
* cannot be read, the request is denied and the caller falls back to its
|
|
23
|
+
* heuristic. Exceeding the provider's limit is worse than one fallback.
|
|
24
|
+
*
|
|
25
|
+
* @task T12490
|
|
26
|
+
* @epic T12486
|
|
27
|
+
*/
|
|
28
|
+
/** Default burst capacity (tokens). */
|
|
29
|
+
export declare const DEFAULT_BUDGET_CAPACITY = 60;
|
|
30
|
+
/** Default refill rate (tokens per minute). Capacity + refill ≤ 600 per minute. */
|
|
31
|
+
export declare const DEFAULT_BUDGET_REFILL_PER_MINUTE = 540;
|
|
32
|
+
/** Cool-down applied after a 429 that carried no usable `retry-after`. */
|
|
33
|
+
export declare const DEFAULT_RATE_LIMIT_COOLDOWN_MS = 10000;
|
|
34
|
+
/**
|
|
35
|
+
* Longest cool-down any 429 may impose. The bucket is machine-wide, so an
|
|
36
|
+
* uncapped `retry-after: 999999999` would stop every decision on the machine
|
|
37
|
+
* for decades.
|
|
38
|
+
*/
|
|
39
|
+
export declare const MAX_RATE_LIMIT_COOLDOWN_MS = 60000;
|
|
40
|
+
/** Result of {@link DecisionBudget.tryAcquire}. */
|
|
41
|
+
export type BudgetGrant = {
|
|
42
|
+
readonly granted: true;
|
|
43
|
+
} | {
|
|
44
|
+
readonly granted: false;
|
|
45
|
+
readonly reason: 'exhausted' | 'cooling_down' | 'unavailable';
|
|
46
|
+
};
|
|
47
|
+
/** A request budget. Implementations never throw. */
|
|
48
|
+
export interface DecisionBudget {
|
|
49
|
+
/** Take one token if available. */
|
|
50
|
+
tryAcquire(): Promise<BudgetGrant>;
|
|
51
|
+
/** Empty the bucket and block all acquisitions for `retryAfterMs` (after a 429). */
|
|
52
|
+
penalize(retryAfterMs?: number): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/** Bucket parameters. */
|
|
55
|
+
export interface TokenBucketOptions {
|
|
56
|
+
/** Burst capacity. Default {@link DEFAULT_BUDGET_CAPACITY}. */
|
|
57
|
+
readonly capacity?: number;
|
|
58
|
+
/** Refill rate per minute. Default {@link DEFAULT_BUDGET_REFILL_PER_MINUTE}. */
|
|
59
|
+
readonly refillPerMinute?: number;
|
|
60
|
+
/** Wall clock in epoch ms (shared across processes). Default `Date.now`. */
|
|
61
|
+
readonly now?: () => number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A process-local bucket. Useful for tests and for callers that must not touch
|
|
65
|
+
* the filesystem; it does NOT coordinate with other processes.
|
|
66
|
+
*
|
|
67
|
+
* @param opts - Bucket parameters.
|
|
68
|
+
* @returns A {@link DecisionBudget}.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createMemoryTokenBucket(opts?: TokenBucketOptions): DecisionBudget;
|
|
71
|
+
/** Options for {@link createFileTokenBucket}. */
|
|
72
|
+
export interface FileTokenBucketOptions extends TokenBucketOptions {
|
|
73
|
+
/** State-file path. Default {@link defaultBudgetStatePath}. */
|
|
74
|
+
readonly statePath?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Default location of the shared bucket state: `<cleoHome>/decide/budget.json`.
|
|
78
|
+
*
|
|
79
|
+
* @returns Absolute path.
|
|
80
|
+
*/
|
|
81
|
+
export declare function defaultBudgetStatePath(): string;
|
|
82
|
+
/**
|
|
83
|
+
* A bucket whose state is shared by every process on the machine through a
|
|
84
|
+
* locked JSON file.
|
|
85
|
+
*
|
|
86
|
+
* @param opts - Bucket parameters and state path.
|
|
87
|
+
* @returns A {@link DecisionBudget}; `tryAcquire` resolves `unavailable` when
|
|
88
|
+
* the lock or state file cannot be used.
|
|
89
|
+
*/
|
|
90
|
+
export declare function createFileTokenBucket(opts?: FileTokenBucketOptions): DecisionBudget;
|
|
91
|
+
//# sourceMappingURL=budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.d.ts","sourceRoot":"","sources":["../../src/decide/budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AASH,uCAAuC;AACvC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,mFAAmF;AACnF,eAAO,MAAM,gCAAgC,MAAM,CAAC;AACpD,0EAA0E;AAC1E,eAAO,MAAM,8BAA8B,QAAS,CAAC;AACrD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAEjD,mDAAmD;AACnD,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,cAAc,GAAG,aAAa,CAAA;CAAE,CAAC;AAE/F,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IACnC,oFAAoF;IACpF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,yBAAyB;AACzB,MAAM,WAAW,kBAAkB;IACjC,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAwDD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,GAAE,kBAAuB,GAAG,cAAc,CAWrF;AAED,iDAAiD;AACjD,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AA+CD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,GAAE,sBAA2B,GAAG,cAAc,CAiCvF"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request budget for decision providers — a token bucket shared by every CLEO
|
|
3
|
+
* process on the machine.
|
|
4
|
+
*
|
|
5
|
+
* The provider allows 600 requests/minute per key. Every CLEO process (CLI
|
|
6
|
+
* invocations, the sentient daemon, spawned agents) draws from ONE bucket whose
|
|
7
|
+
* state lives in `<cleoHome>/decide/budget.json`, guarded by a `proper-lockfile`
|
|
8
|
+
* lock — the same cross-process state-file pattern as
|
|
9
|
+
* `llm/rate-limit-guard.ts`, with much shorter lock retries because a decision
|
|
10
|
+
* has a sub-second budget.
|
|
11
|
+
*
|
|
12
|
+
* ## Why capacity 60 + 540/min, not 600 + 600/min
|
|
13
|
+
*
|
|
14
|
+
* A bucket of capacity `C` refilled at `r` admits at most `C + r·W` requests in
|
|
15
|
+
* any window `W`. The defaults (60 + 540/min) keep every 60-second window at or
|
|
16
|
+
* under 600 even after an idle period, so the budget itself never triggers a
|
|
17
|
+
* 429. A 429 still happens if the key is shared with non-CLEO clients; then
|
|
18
|
+
* {@link DecisionBudget.penalize} empties the bucket and blocks every process
|
|
19
|
+
* until the server's `retry-after` has passed.
|
|
20
|
+
*
|
|
21
|
+
* The bucket fails CLOSED: if the lock cannot be taken quickly or the state
|
|
22
|
+
* cannot be read, the request is denied and the caller falls back to its
|
|
23
|
+
* heuristic. Exceeding the provider's limit is worse than one fallback.
|
|
24
|
+
*
|
|
25
|
+
* @task T12490
|
|
26
|
+
* @epic T12486
|
|
27
|
+
*/
|
|
28
|
+
import { randomBytes } from 'node:crypto';
|
|
29
|
+
import { mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
30
|
+
import { dirname, join } from 'node:path';
|
|
31
|
+
import { getCleoHome } from '@cleocode/paths';
|
|
32
|
+
import lockfile from 'proper-lockfile';
|
|
33
|
+
import { z } from 'zod';
|
|
34
|
+
/** Default burst capacity (tokens). */
|
|
35
|
+
export const DEFAULT_BUDGET_CAPACITY = 60;
|
|
36
|
+
/** Default refill rate (tokens per minute). Capacity + refill ≤ 600 per minute. */
|
|
37
|
+
export const DEFAULT_BUDGET_REFILL_PER_MINUTE = 540;
|
|
38
|
+
/** Cool-down applied after a 429 that carried no usable `retry-after`. */
|
|
39
|
+
export const DEFAULT_RATE_LIMIT_COOLDOWN_MS = 10_000;
|
|
40
|
+
/**
|
|
41
|
+
* Longest cool-down any 429 may impose. The bucket is machine-wide, so an
|
|
42
|
+
* uncapped `retry-after: 999999999` would stop every decision on the machine
|
|
43
|
+
* for decades.
|
|
44
|
+
*/
|
|
45
|
+
export const MAX_RATE_LIMIT_COOLDOWN_MS = 60_000;
|
|
46
|
+
function resolve(opts) {
|
|
47
|
+
return {
|
|
48
|
+
capacity: Math.max(1, opts.capacity ?? DEFAULT_BUDGET_CAPACITY),
|
|
49
|
+
refillPerMs: Math.max(0, opts.refillPerMinute ?? DEFAULT_BUDGET_REFILL_PER_MINUTE) / 60_000,
|
|
50
|
+
now: opts.now ?? Date.now,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Apply refill + one acquisition to `state` (mutates) and report the outcome. */
|
|
54
|
+
function take(state, bucket) {
|
|
55
|
+
const now = bucket.now();
|
|
56
|
+
// A cool-down beyond the cap can only come from a state file written before
|
|
57
|
+
// the cap existed; honour at most the cap from when it was imposed.
|
|
58
|
+
state.blockedUntil = Math.min(state.blockedUntil, state.updatedAt + MAX_RATE_LIMIT_COOLDOWN_MS);
|
|
59
|
+
if (now < state.blockedUntil)
|
|
60
|
+
return { granted: false, reason: 'cooling_down' };
|
|
61
|
+
const elapsed = Math.max(0, now - state.updatedAt);
|
|
62
|
+
state.tokens = Math.min(bucket.capacity, state.tokens + elapsed * bucket.refillPerMs);
|
|
63
|
+
state.updatedAt = now;
|
|
64
|
+
if (state.tokens < 1)
|
|
65
|
+
return { granted: false, reason: 'exhausted' };
|
|
66
|
+
state.tokens -= 1;
|
|
67
|
+
return { granted: true };
|
|
68
|
+
}
|
|
69
|
+
function penalizeState(state, bucket, retryAfterMs) {
|
|
70
|
+
const now = bucket.now();
|
|
71
|
+
const wait = Math.min(MAX_RATE_LIMIT_COOLDOWN_MS, retryAfterMs !== undefined && retryAfterMs >= 0 ? retryAfterMs : DEFAULT_RATE_LIMIT_COOLDOWN_MS);
|
|
72
|
+
state.tokens = 0;
|
|
73
|
+
state.updatedAt = now;
|
|
74
|
+
state.blockedUntil = Math.max(state.blockedUntil, now + wait);
|
|
75
|
+
}
|
|
76
|
+
function freshState(bucket) {
|
|
77
|
+
return { tokens: bucket.capacity, updatedAt: bucket.now(), blockedUntil: 0 };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A process-local bucket. Useful for tests and for callers that must not touch
|
|
81
|
+
* the filesystem; it does NOT coordinate with other processes.
|
|
82
|
+
*
|
|
83
|
+
* @param opts - Bucket parameters.
|
|
84
|
+
* @returns A {@link DecisionBudget}.
|
|
85
|
+
*/
|
|
86
|
+
export function createMemoryTokenBucket(opts = {}) {
|
|
87
|
+
const bucket = resolve(opts);
|
|
88
|
+
const state = freshState(bucket);
|
|
89
|
+
return {
|
|
90
|
+
async tryAcquire() {
|
|
91
|
+
return take(state, bucket);
|
|
92
|
+
},
|
|
93
|
+
async penalize(retryAfterMs) {
|
|
94
|
+
penalizeState(state, bucket, retryAfterMs);
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Default location of the shared bucket state: `<cleoHome>/decide/budget.json`.
|
|
100
|
+
*
|
|
101
|
+
* @returns Absolute path.
|
|
102
|
+
*/
|
|
103
|
+
export function defaultBudgetStatePath() {
|
|
104
|
+
return join(getCleoHome(), 'decide', 'budget.json');
|
|
105
|
+
}
|
|
106
|
+
/** Short lock retries: the whole decision has a sub-second budget. */
|
|
107
|
+
const LOCK_OPTIONS = {
|
|
108
|
+
realpath: false,
|
|
109
|
+
stale: 2_000,
|
|
110
|
+
retries: { retries: 4, factor: 1.5, minTimeout: 5, maxTimeout: 25 },
|
|
111
|
+
};
|
|
112
|
+
/** Schema of the persisted state; anything else is treated as corrupt. */
|
|
113
|
+
const bucketStateSchema = z.object({
|
|
114
|
+
tokens: z.number(),
|
|
115
|
+
updatedAt: z.number(),
|
|
116
|
+
blockedUntil: z.number(),
|
|
117
|
+
});
|
|
118
|
+
function readState(path, bucket) {
|
|
119
|
+
let raw;
|
|
120
|
+
try {
|
|
121
|
+
raw = readFileSync(path, 'utf-8');
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return freshState(bucket);
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const parsed = bucketStateSchema.safeParse(JSON.parse(raw));
|
|
128
|
+
// A corrupt file resets to an EMPTY bucket, not a full one: fail closed.
|
|
129
|
+
return parsed.success ? parsed.data : { tokens: 0, updatedAt: bucket.now(), blockedUntil: 0 };
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return { tokens: 0, updatedAt: bucket.now(), blockedUntil: 0 };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function writeState(path, state) {
|
|
136
|
+
const tmp = join(dirname(path), `.budget.${randomBytes(6).toString('hex')}.tmp`);
|
|
137
|
+
writeFileSync(tmp, JSON.stringify(state), 'utf-8');
|
|
138
|
+
try {
|
|
139
|
+
renameSync(tmp, path);
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
try {
|
|
143
|
+
unlinkSync(tmp);
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
/* ignore cleanup failure */
|
|
147
|
+
}
|
|
148
|
+
throw err;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A bucket whose state is shared by every process on the machine through a
|
|
153
|
+
* locked JSON file.
|
|
154
|
+
*
|
|
155
|
+
* @param opts - Bucket parameters and state path.
|
|
156
|
+
* @returns A {@link DecisionBudget}; `tryAcquire` resolves `unavailable` when
|
|
157
|
+
* the lock or state file cannot be used.
|
|
158
|
+
*/
|
|
159
|
+
export function createFileTokenBucket(opts = {}) {
|
|
160
|
+
const bucket = resolve(opts);
|
|
161
|
+
const statePath = opts.statePath ?? defaultBudgetStatePath();
|
|
162
|
+
async function withState(mutate) {
|
|
163
|
+
mkdirSync(dirname(statePath), { recursive: true });
|
|
164
|
+
const release = await lockfile.lock(statePath, LOCK_OPTIONS);
|
|
165
|
+
try {
|
|
166
|
+
const state = readState(statePath, bucket);
|
|
167
|
+
const result = mutate(state);
|
|
168
|
+
writeState(statePath, state);
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
await release().catch(() => undefined);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
async tryAcquire() {
|
|
177
|
+
try {
|
|
178
|
+
return await withState((state) => take(state, bucket));
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return { granted: false, reason: 'unavailable' };
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
async penalize(retryAfterMs) {
|
|
185
|
+
try {
|
|
186
|
+
await withState((state) => penalizeState(state, bucket, retryAfterMs));
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
/* best effort: the next acquisition will meet the provider's 429 again */
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.js","sourceRoot":"","sources":["../../src/decide/budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,uCAAuC;AACvC,MAAM,CAAC,MAAM,uBAAuB,GAAG,E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AC;YACT,MAAM,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,CAAC,UAAU;YACd,IAAI,CAAC;gBACH,OAAO,MAAM,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;YACzD,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;YACnD,CAAC;QACH,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,YAAY;YACzB,IAAI,CAAC;gBACH,MAAM,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;YACzE,CAAC;YAAC,MAAM,CAAC;gBACP,0EAA0E;YAC5E,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory LRU cache of provider decision outcomes.
|
|
3
|
+
*
|
|
4
|
+
* Keyed by `sha256(adapterVersion, model, questions, state)` over a canonical
|
|
5
|
+
* (key-sorted) JSON serialization, so logically identical requests hit the
|
|
6
|
+
* same entry regardless of object key order. Only provider answers are
|
|
7
|
+
* stored; fallbacks are never cached. The cache is per-process and holds no
|
|
8
|
+
* secrets (the key is not part of any request).
|
|
9
|
+
*
|
|
10
|
+
* @task T12490
|
|
11
|
+
* @epic T12486
|
|
12
|
+
*/
|
|
13
|
+
import type { DecisionOutcome, DecisionRequest } from '@cleocode/contracts';
|
|
14
|
+
/** Default number of entries kept by {@link createDecisionCache}. */
|
|
15
|
+
export declare const DEFAULT_DECISION_CACHE_SIZE = 512;
|
|
16
|
+
/** A bounded store of decision outcomes. */
|
|
17
|
+
export interface DecisionCache {
|
|
18
|
+
/** Look up an outcome, marking it most-recently used. */
|
|
19
|
+
get(key: string): DecisionOutcome | undefined;
|
|
20
|
+
/** Store an outcome, evicting the least-recently used entry when full. */
|
|
21
|
+
set(key: string, outcome: DecisionOutcome): void;
|
|
22
|
+
/** Number of stored entries. */
|
|
23
|
+
readonly size: number;
|
|
24
|
+
/** Drop every entry. */
|
|
25
|
+
clear(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* sha256 hex of the canonical serialization of `value`.
|
|
29
|
+
*
|
|
30
|
+
* @param value - Any JSON-compatible value.
|
|
31
|
+
* @returns 64-char lowercase hex digest.
|
|
32
|
+
*/
|
|
33
|
+
export declare function hashCanonical(value: unknown): string;
|
|
34
|
+
/**
|
|
35
|
+
* Cache key for a request under a given adapter version.
|
|
36
|
+
*
|
|
37
|
+
* @param adapterVersion - Wire-adapter identity; bump it to invalidate entries.
|
|
38
|
+
* @param req - The request as sent to the provider (post-redaction).
|
|
39
|
+
* @returns sha256 hex key.
|
|
40
|
+
*/
|
|
41
|
+
export declare function decisionCacheKey(adapterVersion: string, req: DecisionRequest): string;
|
|
42
|
+
/**
|
|
43
|
+
* Create an LRU {@link DecisionCache}.
|
|
44
|
+
*
|
|
45
|
+
* @param maxEntries - Capacity (minimum 1). Defaults to {@link DEFAULT_DECISION_CACHE_SIZE}.
|
|
46
|
+
* @returns A new, empty cache.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createDecisionCache(maxEntries?: number): DecisionCache;
|
|
49
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/decide/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE5E,qEAAqE;AACrE,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAAC;IAC9C,0EAA0E;IAC1E,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IACjD,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,KAAK,IAAI,IAAI,CAAC;CACf;AAYD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,GAAG,MAAM,CAOrF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,GAAE,MAAoC,GAC/C,aAAa,CA2Bf"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory LRU cache of provider decision outcomes.
|
|
3
|
+
*
|
|
4
|
+
* Keyed by `sha256(adapterVersion, model, questions, state)` over a canonical
|
|
5
|
+
* (key-sorted) JSON serialization, so logically identical requests hit the
|
|
6
|
+
* same entry regardless of object key order. Only provider answers are
|
|
7
|
+
* stored; fallbacks are never cached. The cache is per-process and holds no
|
|
8
|
+
* secrets (the key is not part of any request).
|
|
9
|
+
*
|
|
10
|
+
* @task T12490
|
|
11
|
+
* @epic T12486
|
|
12
|
+
*/
|
|
13
|
+
import { createHash } from 'node:crypto';
|
|
14
|
+
/** Default number of entries kept by {@link createDecisionCache}. */
|
|
15
|
+
export const DEFAULT_DECISION_CACHE_SIZE = 512;
|
|
16
|
+
/** JSON serialization with object keys sorted at every depth. */
|
|
17
|
+
function canonicalJson(value) {
|
|
18
|
+
if (value === null || typeof value !== 'object')
|
|
19
|
+
return JSON.stringify(value) ?? 'null';
|
|
20
|
+
if (Array.isArray(value))
|
|
21
|
+
return `[${value.map(canonicalJson).join(',')}]`;
|
|
22
|
+
const entries = Object.entries(value)
|
|
23
|
+
.filter(([, v]) => v !== undefined)
|
|
24
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
25
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(',')}}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* sha256 hex of the canonical serialization of `value`.
|
|
29
|
+
*
|
|
30
|
+
* @param value - Any JSON-compatible value.
|
|
31
|
+
* @returns 64-char lowercase hex digest.
|
|
32
|
+
*/
|
|
33
|
+
export function hashCanonical(value) {
|
|
34
|
+
return createHash('sha256').update(canonicalJson(value)).digest('hex');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Cache key for a request under a given adapter version.
|
|
38
|
+
*
|
|
39
|
+
* @param adapterVersion - Wire-adapter identity; bump it to invalidate entries.
|
|
40
|
+
* @param req - The request as sent to the provider (post-redaction).
|
|
41
|
+
* @returns sha256 hex key.
|
|
42
|
+
*/
|
|
43
|
+
export function decisionCacheKey(adapterVersion, req) {
|
|
44
|
+
return hashCanonical({
|
|
45
|
+
adapterVersion,
|
|
46
|
+
model: req.model ?? null,
|
|
47
|
+
questions: req.questions,
|
|
48
|
+
state: req.state,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create an LRU {@link DecisionCache}.
|
|
53
|
+
*
|
|
54
|
+
* @param maxEntries - Capacity (minimum 1). Defaults to {@link DEFAULT_DECISION_CACHE_SIZE}.
|
|
55
|
+
* @returns A new, empty cache.
|
|
56
|
+
*/
|
|
57
|
+
export function createDecisionCache(maxEntries = DEFAULT_DECISION_CACHE_SIZE) {
|
|
58
|
+
const capacity = Math.max(1, Math.floor(maxEntries));
|
|
59
|
+
const entries = new Map();
|
|
60
|
+
return {
|
|
61
|
+
get(key) {
|
|
62
|
+
const hit = entries.get(key);
|
|
63
|
+
if (hit === undefined)
|
|
64
|
+
return undefined;
|
|
65
|
+
entries.delete(key);
|
|
66
|
+
entries.set(key, hit);
|
|
67
|
+
return hit;
|
|
68
|
+
},
|
|
69
|
+
set(key, outcome) {
|
|
70
|
+
entries.delete(key);
|
|
71
|
+
entries.set(key, outcome);
|
|
72
|
+
while (entries.size > capacity) {
|
|
73
|
+
const oldest = entries.keys().next();
|
|
74
|
+
if (oldest.done)
|
|
75
|
+
break;
|
|
76
|
+
entries.delete(oldest.value);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
get size() {
|
|
80
|
+
return entries.size;
|
|
81
|
+
},
|
|
82
|
+
clear() {
|
|
83
|
+
entries.clear();
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/decide/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,qEAAqE;AACrE,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAc/C,iEAAiE;AACjE,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC;IACxF,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC3E,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;SAClC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;SAClC,IAAI,CAAC,CAAC,CAAC,C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SAAS;gBAAE,OAAO,SAAS,CAAC;YACxC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACtB,OAAO,GAAG,CAAC;QACb,CAAC;QACD,GAAG,CAAC,GAAG,EAAE,OAAO;YACd,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC1B,OAAO,OAAO,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAC;gBAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;gBACrC,IAAI,MAAM,CAAC,IAAI;oBAAE,MAAM;gBACvB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QACD,IAAI,IAAI;YACN,OAAO,OAAO,CAAC,IAAI,CAAC;QACtB,CAAC;QACD,KAAK;YACH,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed-decision client — the one entry point CLEO call sites use for
|
|
3
|
+
* "System One" decisions.
|
|
4
|
+
*
|
|
5
|
+
* `decide(siteId, req, fallback, opts)` ALWAYS resolves with a
|
|
6
|
+
* {@link DecisionOutcome}; it never rejects because of the provider. The
|
|
7
|
+
* pipeline is:
|
|
8
|
+
*
|
|
9
|
+
* 1. No provider configured → the site's heuristic (`source: 'fallback'`).
|
|
10
|
+
* 2. Redact the state through the memory redaction module, then validate the
|
|
11
|
+
* request with the contract schema (invalid → fallback).
|
|
12
|
+
* 3. In-memory LRU cache hit → `source: 'cache'`.
|
|
13
|
+
* 4. Within ONE per-site deadline (default {@link DEFAULT_DECISION_TIMEOUT_MS}):
|
|
14
|
+
* take a token from the machine-wide budget, then call the provider.
|
|
15
|
+
* Budget denial, timeout, 401/402/429/5xx, network failure or a malformed
|
|
16
|
+
* answer → fallback. A 429 also empties the shared budget for its
|
|
17
|
+
* `retry-after` so no other process piles on.
|
|
18
|
+
* 5. Append one audit line (never containing the key or raw state).
|
|
19
|
+
*
|
|
20
|
+
* Provider-specific knowledge (endpoints, wire JSON) lives only in
|
|
21
|
+
* `./jev-wire.ts`; this module sees the {@link DecisionProvider} port.
|
|
22
|
+
*
|
|
23
|
+
* @task T12490
|
|
24
|
+
* @epic T12486
|
|
25
|
+
*/
|
|
26
|
+
import { type DecisionAnswer, type DecisionOutcome, type DecisionRequest, type DecisionState } from '@cleocode/contracts';
|
|
27
|
+
import { type DecisionAuditSink } from './audit.js';
|
|
28
|
+
import { type DecisionBudget } from './budget.js';
|
|
29
|
+
import { type DecisionCache } from './cache.js';
|
|
30
|
+
import { type DecisionProvider, type DecisionProviderConnection } from './provider.js';
|
|
31
|
+
/** Default per-site deadline for the budget + provider round trip, in ms. */
|
|
32
|
+
export declare const DEFAULT_DECISION_TIMEOUT_MS = 300;
|
|
33
|
+
/**
|
|
34
|
+
* A call site's local heuristic. It must be total and fast: it answers every
|
|
35
|
+
* question in the request whenever no provider answer is available.
|
|
36
|
+
*/
|
|
37
|
+
export type DecisionHeuristic = (req: DecisionRequest) => Readonly<Record<string, DecisionAnswer>>;
|
|
38
|
+
/** Options for {@link decide}. */
|
|
39
|
+
export interface DecideOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Provider connection (base URL + API key + optional default model).
|
|
42
|
+
* Absent (`undefined`) → the connection stored by `cleo decide config`
|
|
43
|
+
* (`./credentials.ts`) is loaded. `null`, a blank key or an invalid URL →
|
|
44
|
+
* unconfigured, and every call returns the fallback.
|
|
45
|
+
*/
|
|
46
|
+
readonly connection?: DecisionProviderConnection | null;
|
|
47
|
+
/** Explicit provider; overrides `connection`. Tests inject a fake here. */
|
|
48
|
+
readonly provider?: DecisionProvider;
|
|
49
|
+
/** Deadline for budget + provider, ms. Default {@link DEFAULT_DECISION_TIMEOUT_MS}. */
|
|
50
|
+
readonly timeoutMs?: number;
|
|
51
|
+
/** Outcome cache; `null` disables. Default: one per-process LRU. */
|
|
52
|
+
readonly cache?: DecisionCache | null;
|
|
53
|
+
/** Request budget; `null` disables. Default: the machine-wide file bucket. */
|
|
54
|
+
readonly budget?: DecisionBudget | null;
|
|
55
|
+
/** Audit sink; `null` disables. Default: `<projectRoot>/.cleo/audit/decisions.jsonl`. */
|
|
56
|
+
readonly audit?: DecisionAuditSink | null;
|
|
57
|
+
/** Project root for the default audit sink. Default: the resolved CLEO project root. */
|
|
58
|
+
readonly projectRoot?: string;
|
|
59
|
+
/** Cache-key namespace. Default: the Jev adapter version. */
|
|
60
|
+
readonly adapterVersion?: string;
|
|
61
|
+
/** Caller cancellation; treated like a timeout (fallback, no throw). */
|
|
62
|
+
readonly signal?: AbortSignal;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Reset the process-default cache and budget. Tests only.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export declare function _resetDecideDefaultsForTest(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Scrub secrets from a decision state before it leaves the machine, using the
|
|
72
|
+
* shared memory redaction patterns. Strings are redacted in place; structured
|
|
73
|
+
* state is redacted leaf by leaf so it stays valid JSON.
|
|
74
|
+
*
|
|
75
|
+
* @param state - Raw state.
|
|
76
|
+
* @returns Redacted state of the same shape.
|
|
77
|
+
*/
|
|
78
|
+
export declare function redactDecisionState(state: DecisionState): DecisionState;
|
|
79
|
+
/**
|
|
80
|
+
* Ask a typed decision at call site `siteId`.
|
|
81
|
+
*
|
|
82
|
+
* Never rejects on provider trouble: when the provider is unconfigured,
|
|
83
|
+
* over budget, slow, failing or wrong, the site's `fallback` heuristic answers
|
|
84
|
+
* and the outcome carries `source: 'fallback'`.
|
|
85
|
+
*
|
|
86
|
+
* @param siteId - Stable call-site identifier (audited; used for per-site tuning).
|
|
87
|
+
* @param req - Questions and state.
|
|
88
|
+
* @param fallback - The site's heuristic; receives the original (unredacted) request.
|
|
89
|
+
* @param opts - Provider, deadline, cache, budget and audit wiring.
|
|
90
|
+
* @returns The decision outcome.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* const outcome = await decide(
|
|
95
|
+
* 'tasks.duplicate-check',
|
|
96
|
+
* { state: text, questions: { dup: { type: 'noul', criteria: 'The two tasks describe the same work' } } },
|
|
97
|
+
* () => ({ dup: { type: 'noul', value: false, probability: 0.2, confidence: 0.5 } }),
|
|
98
|
+
* { connection, timeoutMs: 250 },
|
|
99
|
+
* );
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function decide(siteId: string, req: DecisionRequest, fallback: DecisionHeuristic, opts?: DecideOptions): Promise<DecisionOutcome>;
|
|
103
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/decide/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,aAAa,EAInB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAEhC,MAAM,eAAe,CAAC;AAEvB,6EAA6E;AAC7E,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,QAAQ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