@cleocode/core 2026.9.22 → 2026.9.24
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/admin/import-tasks.d.ts.map +1 -1
- package/dist/admin/import-tasks.js +35 -6
- package/dist/admin/import-tasks.js.map +1 -1
- package/dist/admin/import.d.ts.map +1 -1
- package/dist/admin/import.js +25 -6
- package/dist/admin/import.js.map +1 -1
- package/dist/build-provenance.json +6 -0
- package/dist/cloud/http.d.ts +8 -0
- package/dist/cloud/http.d.ts.map +1 -1
- package/dist/cloud/http.js +8 -1
- package/dist/cloud/http.js.map +1 -1
- package/dist/cloud/index.d.ts +6 -1
- package/dist/cloud/index.d.ts.map +1 -1
- package/dist/cloud/index.js +6 -1
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/nexus-auth.d.ts +169 -0
- package/dist/cloud/nexus-auth.d.ts.map +1 -0
- package/dist/cloud/nexus-auth.js +372 -0
- package/dist/cloud/nexus-auth.js.map +1 -0
- package/dist/cloud/nexus-credentials.d.ts +188 -0
- package/dist/cloud/nexus-credentials.d.ts.map +1 -0
- package/dist/cloud/nexus-credentials.js +323 -0
- package/dist/cloud/nexus-credentials.js.map +1 -0
- package/dist/cloud/nexus-link.d.ts +85 -0
- package/dist/cloud/nexus-link.d.ts.map +1 -0
- package/dist/cloud/nexus-link.js +226 -0
- package/dist/cloud/nexus-link.js.map +1 -0
- package/dist/cloud/presence.d.ts +88 -0
- package/dist/cloud/presence.d.ts.map +1 -0
- package/dist/cloud/presence.js +137 -0
- package/dist/cloud/presence.js.map +1 -0
- package/dist/cloud/projects.d.ts +3 -1
- package/dist/cloud/projects.d.ts.map +1 -1
- package/dist/cloud/projects.js +4 -2
- package/dist/cloud/projects.js.map +1 -1
- package/dist/crypto/credentials.d.ts +14 -4
- package/dist/crypto/credentials.d.ts.map +1 -1
- package/dist/crypto/credentials.js +15 -1
- package/dist/crypto/credentials.js.map +1 -1
- package/dist/decide/audit.d.ts +7 -1
- package/dist/decide/audit.d.ts.map +1 -1
- package/dist/decide/audit.js.map +1 -1
- package/dist/decide/bench/dataset.d.ts +125 -0
- package/dist/decide/bench/dataset.d.ts.map +1 -0
- package/dist/decide/bench/dataset.js +457 -0
- package/dist/decide/bench/dataset.js.map +1 -0
- package/dist/decide/bench/index.d.ts +23 -0
- package/dist/decide/bench/index.d.ts.map +1 -0
- package/dist/decide/bench/index.js +23 -0
- package/dist/decide/bench/index.js.map +1 -0
- package/dist/decide/bench/metrics.d.ts +55 -0
- package/dist/decide/bench/metrics.d.ts.map +1 -0
- package/dist/decide/bench/metrics.js +100 -0
- package/dist/decide/bench/metrics.js.map +1 -0
- package/dist/decide/bench/operation.d.ts +119 -0
- package/dist/decide/bench/operation.d.ts.map +1 -0
- package/dist/decide/bench/operation.js +171 -0
- package/dist/decide/bench/operation.js.map +1 -0
- package/dist/decide/bench/profiles.d.ts +74 -0
- package/dist/decide/bench/profiles.d.ts.map +1 -0
- package/dist/decide/bench/profiles.js +131 -0
- package/dist/decide/bench/profiles.js.map +1 -0
- package/dist/decide/bench/questions.d.ts +40 -0
- package/dist/decide/bench/questions.d.ts.map +1 -0
- package/dist/decide/bench/questions.js +107 -0
- package/dist/decide/bench/questions.js.map +1 -0
- package/dist/decide/bench/report.d.ts +21 -0
- package/dist/decide/bench/report.d.ts.map +1 -0
- package/dist/decide/bench/report.js +120 -0
- package/dist/decide/bench/report.js.map +1 -0
- package/dist/decide/bench/runner.d.ts +203 -0
- package/dist/decide/bench/runner.d.ts.map +1 -0
- package/dist/decide/bench/runner.js +335 -0
- package/dist/decide/bench/runner.js.map +1 -0
- package/dist/decide/bench/source.d.ts +21 -0
- package/dist/decide/bench/source.d.ts.map +1 -0
- package/dist/decide/bench/source.js +67 -0
- package/dist/decide/bench/source.js.map +1 -0
- package/dist/decide/bench/spot-check.d.ts +117 -0
- package/dist/decide/bench/spot-check.d.ts.map +1 -0
- package/dist/decide/bench/spot-check.js +221 -0
- package/dist/decide/bench/spot-check.js.map +1 -0
- package/dist/decide/bench/stats.d.ts +57 -0
- package/dist/decide/bench/stats.d.ts.map +1 -0
- package/dist/decide/bench/stats.js +82 -0
- package/dist/decide/bench/stats.js.map +1 -0
- package/dist/decide/bench/types.d.ts +216 -0
- package/dist/decide/bench/types.d.ts.map +1 -0
- package/dist/decide/bench/types.js +104 -0
- package/dist/decide/bench/types.js.map +1 -0
- package/dist/decide/client.d.ts +80 -4
- package/dist/decide/client.d.ts.map +1 -1
- package/dist/decide/client.js +428 -39
- package/dist/decide/client.js.map +1 -1
- package/dist/decide/credentials.d.ts +200 -16
- package/dist/decide/credentials.d.ts.map +1 -1
- package/dist/decide/credentials.js +547 -45
- package/dist/decide/credentials.js.map +1 -1
- package/dist/decide/index.d.ts +10 -4
- package/dist/decide/index.d.ts.map +1 -1
- package/dist/decide/index.js +10 -4
- package/dist/decide/index.js.map +1 -1
- package/dist/decide/jev-wire.d.ts +105 -7
- package/dist/decide/jev-wire.d.ts.map +1 -1
- package/dist/decide/jev-wire.js +426 -54
- package/dist/decide/jev-wire.js.map +1 -1
- package/dist/decide/operations.d.ts +149 -21
- package/dist/decide/operations.d.ts.map +1 -1
- package/dist/decide/operations.js +241 -31
- package/dist/decide/operations.js.map +1 -1
- package/dist/decide/provider-state.d.ts +162 -0
- package/dist/decide/provider-state.d.ts.map +1 -0
- package/dist/decide/provider-state.js +267 -0
- package/dist/decide/provider-state.js.map +1 -0
- package/dist/decide/provider.d.ts +31 -5
- package/dist/decide/provider.d.ts.map +1 -1
- package/dist/decide/provider.js.map +1 -1
- package/dist/decide/providers.d.ts +71 -0
- package/dist/decide/providers.d.ts.map +1 -0
- package/dist/decide/providers.js +85 -0
- package/dist/decide/providers.js.map +1 -0
- package/dist/decide/site.d.ts +2 -2
- package/dist/decide/site.d.ts.map +1 -1
- package/dist/decide/site.js +2 -0
- package/dist/decide/site.js.map +1 -1
- package/dist/decide/sites/list.d.ts +46 -0
- package/dist/decide/sites/list.d.ts.map +1 -0
- package/dist/decide/sites/list.js +206 -0
- package/dist/decide/sites/list.js.map +1 -0
- package/dist/decide/sites/registry.d.ts +152 -0
- package/dist/decide/sites/registry.d.ts.map +1 -0
- package/dist/decide/sites/registry.js +398 -0
- package/dist/decide/sites/registry.js.map +1 -0
- package/dist/decide/spend.d.ts +196 -0
- package/dist/decide/spend.d.ts.map +1 -0
- package/dist/decide/spend.js +387 -0
- package/dist/decide/spend.js.map +1 -0
- package/dist/decide/wizard.d.ts +61 -0
- package/dist/decide/wizard.d.ts.map +1 -0
- package/dist/decide/wizard.js +197 -0
- package/dist/decide/wizard.js.map +1 -0
- package/dist/dispatch/mvi-projection.d.ts +15 -2
- package/dist/dispatch/mvi-projection.d.ts.map +1 -1
- package/dist/dispatch/mvi-projection.js +73 -12
- package/dist/dispatch/mvi-projection.js.map +1 -1
- package/dist/docs/adr-allocator.d.ts +2 -2
- package/dist/docs/adr-allocator.d.ts.map +1 -1
- package/dist/docs/adr-allocator.js +17 -4
- package/dist/docs/adr-allocator.js.map +1 -1
- package/dist/docs/blob-consolidation.js +1 -1
- package/dist/docs/blob-consolidation.js.map +1 -1
- package/dist/docs/display-alias.d.ts +1 -1
- package/dist/docs/display-alias.d.ts.map +1 -1
- package/dist/docs/display-alias.js +7 -4
- package/dist/docs/display-alias.js.map +1 -1
- package/dist/docs/docs-audit.d.ts.map +1 -1
- package/dist/docs/docs-audit.js +1 -2
- package/dist/docs/docs-audit.js.map +1 -1
- package/dist/docs/docs-inconsistency-detector.js +1 -1
- package/dist/docs/docs-inconsistency-detector.js.map +1 -1
- package/dist/docs/docs-update.d.ts.map +1 -1
- package/dist/docs/docs-update.js +6 -1
- package/dist/docs/docs-update.js.map +1 -1
- package/dist/docs/export-document.js +3462 -1227
- package/dist/docs/export-document.js.map +3 -3
- package/dist/docs/numbering.js +1 -1
- package/dist/docs/numbering.js.map +1 -1
- package/dist/docs/supersede.d.ts.map +1 -1
- package/dist/docs/supersede.js +6 -3
- package/dist/docs/supersede.js.map +1 -1
- package/dist/docs/version-ssot.js +1 -1
- package/dist/docs/version-ssot.js.map +1 -1
- package/dist/doctor/db-substrate.d.ts.map +1 -1
- package/dist/doctor/db-substrate.js +39 -24
- package/dist/doctor/db-substrate.js.map +1 -1
- package/dist/doctor/knowledge-summary.d.ts +10 -3
- package/dist/doctor/knowledge-summary.d.ts.map +1 -1
- package/dist/doctor/knowledge-summary.js +10 -3
- package/dist/doctor/knowledge-summary.js.map +1 -1
- package/dist/doctor/project-identity.d.ts +128 -37
- package/dist/doctor/project-identity.d.ts.map +1 -1
- package/dist/doctor/project-identity.js +476 -63
- package/dist/doctor/project-identity.js.map +1 -1
- package/dist/doctor/twin-collapse.d.ts +52 -2
- package/dist/doctor/twin-collapse.d.ts.map +1 -1
- package/dist/doctor/twin-collapse.js +108 -4
- package/dist/doctor/twin-collapse.js.map +1 -1
- package/dist/error-catalog.js +2 -2
- package/dist/error-catalog.js.map +1 -1
- package/dist/error-registry.js +1 -1
- package/dist/error-registry.js.map +1 -1
- package/dist/gateway-client/generated/types.gen.d.ts +22 -2
- package/dist/gateway-client/generated/types.gen.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/init/scaffold-workflows.d.ts.map +1 -1
- package/dist/init/scaffold-workflows.js +6 -3
- package/dist/init/scaffold-workflows.js.map +1 -1
- package/dist/init/upgrade-workflows.d.ts.map +1 -1
- package/dist/init/upgrade-workflows.js +6 -3
- package/dist/init/upgrade-workflows.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +20 -11
- package/dist/init.js.map +1 -1
- package/dist/inject/index.d.ts.map +1 -1
- package/dist/inject/index.js +2 -3
- package/dist/inject/index.js.map +1 -1
- package/dist/internal.d.ts +6 -5
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +7 -5
- package/dist/internal.js.map +1 -1
- package/dist/llm/credential-remove-entry.d.ts +59 -0
- package/dist/llm/credential-remove-entry.d.ts.map +1 -0
- package/dist/llm/credential-remove-entry.js +101 -0
- package/dist/llm/credential-remove-entry.js.map +1 -0
- package/dist/llm/oauth/device-code.d.ts +26 -6
- package/dist/llm/oauth/device-code.d.ts.map +1 -1
- package/dist/llm/oauth/device-code.js +44 -12
- package/dist/llm/oauth/device-code.js.map +1 -1
- package/dist/llm/plugin-facade.js +3556 -1321
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/memory/attention.d.ts.map +1 -1
- package/dist/memory/attention.js +5 -3
- package/dist/memory/attention.js.map +1 -1
- package/dist/memory/decision-contradiction.d.ts +3 -3
- package/dist/memory/decision-contradiction.d.ts.map +1 -1
- package/dist/memory/decision-contradiction.js +4 -3
- package/dist/memory/decision-contradiction.js.map +1 -1
- package/dist/memory/decisions.d.ts +48 -3
- package/dist/memory/decisions.d.ts.map +1 -1
- package/dist/memory/decisions.js +98 -14
- package/dist/memory/decisions.js.map +1 -1
- package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
- package/dist/memory/graph-memory-bridge.js +2 -0
- package/dist/memory/graph-memory-bridge.js.map +1 -1
- package/dist/memory/learnings.d.ts +6 -6
- package/dist/memory/observation-type-decision.d.ts +2 -2
- package/dist/memory/observation-type-decision.d.ts.map +1 -1
- package/dist/memory/observation-type-decision.js +3 -2
- package/dist/memory/observation-type-decision.js.map +1 -1
- package/dist/memory/patterns.d.ts +4 -4
- package/dist/memory/pipeline-manifest-sqlite.d.ts +111 -0
- package/dist/memory/pipeline-manifest-sqlite.d.ts.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.js +230 -2
- package/dist/memory/pipeline-manifest-sqlite.js.map +1 -1
- package/dist/migration/manual/T10165-backfill-adr-index.d.ts.map +1 -1
- package/dist/migration/manual/T10165-backfill-adr-index.js +5 -1
- package/dist/migration/manual/T10165-backfill-adr-index.js.map +1 -1
- package/dist/nexus/fleet-status.d.ts +83 -0
- package/dist/nexus/fleet-status.d.ts.map +1 -0
- package/dist/nexus/fleet-status.js +414 -0
- package/dist/nexus/fleet-status.js.map +1 -0
- package/dist/nexus/git-state.d.ts +15 -0
- package/dist/nexus/git-state.d.ts.map +1 -1
- package/dist/nexus/git-state.js +67 -2
- package/dist/nexus/git-state.js.map +1 -1
- package/dist/nexus/identity.d.ts.map +1 -1
- package/dist/nexus/identity.js +4 -0
- package/dist/nexus/identity.js.map +1 -1
- package/dist/nexus/index.d.ts +4 -1
- package/dist/nexus/index.d.ts.map +1 -1
- package/dist/nexus/index.js +7 -1
- package/dist/nexus/index.js.map +1 -1
- package/dist/nexus/migrate-json-to-sqlite.d.ts +3 -2
- package/dist/nexus/migrate-json-to-sqlite.d.ts.map +1 -1
- package/dist/nexus/migrate-json-to-sqlite.js +9 -17
- package/dist/nexus/migrate-json-to-sqlite.js.map +1 -1
- package/dist/nexus/migrations/M-split-graph.d.ts.map +1 -1
- package/dist/nexus/migrations/M-split-graph.js +4 -0
- package/dist/nexus/migrations/M-split-graph.js.map +1 -1
- package/dist/nexus/ops.d.ts +1 -0
- package/dist/nexus/ops.d.ts.map +1 -1
- package/dist/nexus/project-activity.d.ts +104 -0
- package/dist/nexus/project-activity.d.ts.map +1 -0
- package/dist/nexus/project-activity.js +150 -0
- package/dist/nexus/project-activity.js.map +1 -0
- package/dist/nexus/query.d.ts +2 -2
- package/dist/nexus/query.d.ts.map +1 -1
- package/dist/nexus/query.js +4 -19
- package/dist/nexus/query.js.map +1 -1
- package/dist/nexus/registry-errors.d.ts +61 -0
- package/dist/nexus/registry-errors.d.ts.map +1 -0
- package/dist/nexus/registry-errors.js +85 -0
- package/dist/nexus/registry-errors.js.map +1 -0
- package/dist/nexus/registry.d.ts +30 -5
- package/dist/nexus/registry.d.ts.map +1 -1
- package/dist/nexus/registry.js +115 -70
- package/dist/nexus/registry.js.map +1 -1
- package/dist/nexus/store.d.ts.map +1 -1
- package/dist/nexus/store.js +2 -0
- package/dist/nexus/store.js.map +1 -1
- package/dist/orchestrate/pivot.d.ts +4 -0
- package/dist/orchestrate/pivot.d.ts.map +1 -1
- package/dist/orchestrate/pivot.js +82 -14
- package/dist/orchestrate/pivot.js.map +1 -1
- package/dist/orchestrate/plan.d.ts.map +1 -1
- package/dist/orchestrate/plan.js +3 -0
- package/dist/orchestrate/plan.js.map +1 -1
- package/dist/orchestrate/query-ops.d.ts.map +1 -1
- package/dist/orchestrate/query-ops.js +29 -27
- package/dist/orchestrate/query-ops.js.map +1 -1
- package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
- package/dist/orchestrate/spawn-ops.js +29 -3
- package/dist/orchestrate/spawn-ops.js.map +1 -1
- package/dist/orchestration/bootstrap.d.ts.map +1 -1
- package/dist/orchestration/bootstrap.js +20 -14
- package/dist/orchestration/bootstrap.js.map +1 -1
- package/dist/orchestration/index.d.ts +15 -1
- package/dist/orchestration/index.d.ts.map +1 -1
- package/dist/orchestration/index.js +25 -6
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/lead-rollup.d.ts +7 -1
- package/dist/orchestration/lead-rollup.d.ts.map +1 -1
- package/dist/orchestration/lead-rollup.js +20 -5
- package/dist/orchestration/lead-rollup.js.map +1 -1
- package/dist/orchestration/owner-decision-readiness.d.ts +2 -2
- package/dist/orchestration/owner-decision-readiness.d.ts.map +1 -1
- package/dist/orchestration/owner-decision-readiness.js +3 -2
- package/dist/orchestration/owner-decision-readiness.js.map +1 -1
- package/dist/orchestration/spawn-prompt.js +1 -1
- package/dist/orchestration/spawn-prompt.js.map +1 -1
- package/dist/orchestration/validate-spawn.d.ts.map +1 -1
- package/dist/orchestration/validate-spawn.js +2 -0
- package/dist/orchestration/validate-spawn.js.map +1 -1
- package/dist/orchestration/waves.d.ts +21 -10
- package/dist/orchestration/waves.d.ts.map +1 -1
- package/dist/orchestration/waves.js +38 -35
- package/dist/orchestration/waves.js.map +1 -1
- package/dist/paths.d.ts +9 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +30 -13
- package/dist/paths.js.map +1 -1
- package/dist/phases/index.d.ts +1 -1
- package/dist/phases/index.d.ts.map +1 -1
- package/dist/phases/index.js +3 -4
- package/dist/phases/index.js.map +1 -1
- package/dist/project-info.d.ts +40 -3
- package/dist/project-info.d.ts.map +1 -1
- package/dist/project-info.js +74 -6
- package/dist/project-info.js.map +1 -1
- package/dist/project-lifecycle.d.ts +28 -7
- package/dist/project-lifecycle.d.ts.map +1 -1
- package/dist/project-lifecycle.js +114 -47
- package/dist/project-lifecycle.js.map +1 -1
- package/dist/project-scope.d.ts +86 -3
- package/dist/project-scope.d.ts.map +1 -1
- package/dist/project-scope.js +192 -17
- package/dist/project-scope.js.map +1 -1
- package/dist/release/github-pr.d.ts.map +1 -1
- package/dist/release/github-pr.js +2 -1
- package/dist/release/github-pr.js.map +1 -1
- package/dist/release/open.d.ts +12 -2
- package/dist/release/open.d.ts.map +1 -1
- package/dist/release/open.js +32 -3
- package/dist/release/open.js.map +1 -1
- package/dist/release/preflight-skip.d.ts +73 -0
- package/dist/release/preflight-skip.d.ts.map +1 -0
- package/dist/release/preflight-skip.js +254 -0
- package/dist/release/preflight-skip.js.map +1 -0
- package/dist/render/decide/index.d.ts +51 -0
- package/dist/render/decide/index.d.ts.map +1 -0
- package/dist/render/decide/index.js +289 -0
- package/dist/render/decide/index.js.map +1 -0
- package/dist/render/index.d.ts +1 -0
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +1 -0
- package/dist/render/index.js.map +1 -1
- package/dist/render/nexus/graph/index.d.ts +5 -0
- package/dist/render/nexus/graph/index.d.ts.map +1 -1
- package/dist/render/nexus/graph/index.js +53 -0
- package/dist/render/nexus/graph/index.js.map +1 -1
- package/dist/routing/capability-matrix.d.ts.map +1 -1
- package/dist/routing/capability-matrix.js +7 -0
- package/dist/routing/capability-matrix.js.map +1 -1
- package/dist/scaffold/ensure-config.d.ts +14 -6
- package/dist/scaffold/ensure-config.d.ts.map +1 -1
- package/dist/scaffold/ensure-config.js +39 -17
- package/dist/scaffold/ensure-config.js.map +1 -1
- package/dist/scaffold/project-identity.d.ts +115 -23
- package/dist/scaffold/project-identity.d.ts.map +1 -1
- package/dist/scaffold/project-identity.js +196 -44
- package/dist/scaffold/project-identity.js.map +1 -1
- package/dist/selfimprove/fix-gen.js +3569 -1334
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/sentient/cross-project-hygiene.d.ts +12 -6
- package/dist/sentient/cross-project-hygiene.d.ts.map +1 -1
- package/dist/sentient/cross-project-hygiene.js +15 -10
- package/dist/sentient/cross-project-hygiene.js.map +1 -1
- package/dist/session/engine-ops.d.ts +13 -4
- package/dist/session/engine-ops.d.ts.map +1 -1
- package/dist/session/engine-ops.js +38 -45
- package/dist/session/engine-ops.js.map +1 -1
- package/dist/sessions/briefing.d.ts +7 -3
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/briefing.js +32 -71
- package/dist/sessions/briefing.js.map +1 -1
- package/dist/sessions/drift-watchdog.d.ts.map +1 -1
- package/dist/sessions/drift-watchdog.js +11 -19
- package/dist/sessions/drift-watchdog.js.map +1 -1
- package/dist/sessions/focus-state-store.d.ts +109 -27
- package/dist/sessions/focus-state-store.d.ts.map +1 -1
- package/dist/sessions/focus-state-store.js +171 -39
- package/dist/sessions/focus-state-store.js.map +1 -1
- package/dist/sessions/handoff.d.ts.map +1 -1
- package/dist/sessions/handoff.js +9 -18
- package/dist/sessions/handoff.js.map +1 -1
- package/dist/sessions/index.d.ts +4 -2
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/index.js +35 -6
- 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 -2
- package/dist/sessions/session-drift.js.map +1 -1
- package/dist/sessions/session-view.d.ts +8 -1
- package/dist/sessions/session-view.d.ts.map +1 -1
- package/dist/sessions/session-view.js +9 -2
- package/dist/sessions/session-view.js.map +1 -1
- package/dist/setup/config-json-merge.d.ts +28 -0
- package/dist/setup/config-json-merge.d.ts.map +1 -1
- package/dist/setup/config-json-merge.js +52 -0
- package/dist/setup/config-json-merge.js.map +1 -1
- package/dist/setup/index.d.ts +15 -10
- package/dist/setup/index.d.ts.map +1 -1
- package/dist/setup/index.js +19 -10
- package/dist/setup/index.js.map +1 -1
- package/dist/setup/sections/llm.js +1 -1
- package/dist/setup/sections/llm.js.map +1 -1
- package/dist/setup/sections/nexus-account.d.ts +32 -0
- package/dist/setup/sections/nexus-account.d.ts.map +1 -0
- package/dist/setup/sections/nexus-account.js +64 -0
- package/dist/setup/sections/nexus-account.js.map +1 -0
- package/dist/setup/sections/system-one.d.ts +28 -0
- package/dist/setup/sections/system-one.d.ts.map +1 -0
- package/dist/setup/sections/system-one.js +53 -0
- package/dist/setup/sections/system-one.js.map +1 -0
- package/dist/setup/wizard.d.ts +15 -1
- package/dist/setup/wizard.d.ts.map +1 -1
- package/dist/setup/wizard.js +15 -0
- package/dist/setup/wizard.js.map +1 -1
- package/dist/skills/orchestrator/startup.d.ts.map +1 -1
- package/dist/skills/orchestrator/startup.js +18 -31
- package/dist/skills/orchestrator/startup.js.map +1 -1
- package/dist/skills/prune-bundled.d.ts +40 -1
- package/dist/skills/prune-bundled.d.ts.map +1 -1
- package/dist/skills/prune-bundled.js +117 -1
- package/dist/skills/prune-bundled.js.map +1 -1
- package/dist/snapshot/index.d.ts.map +1 -1
- package/dist/snapshot/index.js +60 -53
- package/dist/snapshot/index.js.map +1 -1
- package/dist/spawn/agent-identity.d.ts +33 -1
- package/dist/spawn/agent-identity.d.ts.map +1 -1
- package/dist/spawn/agent-identity.js +53 -1
- package/dist/spawn/agent-identity.js.map +1 -1
- package/dist/spawn/index.d.ts +1 -1
- 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/stats/index.d.ts.map +1 -1
- package/dist/stats/index.js +3 -4
- package/dist/stats/index.js.map +1 -1
- package/dist/status/index.d.ts +12 -3
- package/dist/status/index.d.ts.map +1 -1
- package/dist/status/index.js +47 -5
- package/dist/status/index.js.map +1 -1
- package/dist/store/agent-registry-accessor.d.ts.map +1 -1
- package/dist/store/agent-registry-accessor.js +2 -0
- package/dist/store/agent-registry-accessor.js.map +1 -1
- package/dist/store/attachment-repair.d.ts.map +1 -1
- package/dist/store/attachment-repair.js +42 -3
- package/dist/store/attachment-repair.js.map +1 -1
- package/dist/store/attachment-store.d.ts.map +1 -1
- package/dist/store/attachment-store.js +30 -46
- package/dist/store/attachment-store.js.map +1 -1
- package/dist/store/backup-pack.js +1 -1
- package/dist/store/backup-pack.js.map +1 -1
- package/dist/store/backup-recover-brain.d.ts +4 -0
- package/dist/store/backup-recover-brain.d.ts.map +1 -1
- package/dist/store/backup-recover-brain.js +2 -0
- package/dist/store/backup-recover-brain.js.map +1 -1
- package/dist/store/backup-recover.d.ts +9 -0
- package/dist/store/backup-recover.d.ts.map +1 -1
- package/dist/store/backup-recover.js +28 -1
- package/dist/store/backup-recover.js.map +1 -1
- package/dist/store/backup-sidecar.d.ts +30 -0
- package/dist/store/backup-sidecar.d.ts.map +1 -1
- package/dist/store/backup-sidecar.js +90 -2
- package/dist/store/backup-sidecar.js.map +1 -1
- package/dist/store/backup.d.ts +15 -1
- package/dist/store/backup.d.ts.map +1 -1
- package/dist/store/backup.js +18 -2
- package/dist/store/backup.js.map +1 -1
- package/dist/store/blob-keep.d.ts +135 -0
- package/dist/store/blob-keep.d.ts.map +1 -0
- package/dist/store/blob-keep.js +283 -0
- package/dist/store/blob-keep.js.map +1 -0
- package/dist/store/conduit-sqlite.d.ts.map +1 -1
- package/dist/store/conduit-sqlite.js +3 -0
- package/dist/store/conduit-sqlite.js.map +1 -1
- package/dist/store/converters.d.ts.map +1 -1
- package/dist/store/converters.js +11 -0
- package/dist/store/converters.js.map +1 -1
- package/dist/store/credential-transfer.d.ts +37 -5
- package/dist/store/credential-transfer.d.ts.map +1 -1
- package/dist/store/credential-transfer.js +75 -18
- package/dist/store/credential-transfer.js.map +1 -1
- package/dist/store/cross-db-cleanup.d.ts.map +1 -1
- package/dist/store/cross-db-cleanup.js +2 -0
- package/dist/store/cross-db-cleanup.js.map +1 -1
- 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.map +1 -1
- package/dist/store/db-helpers.d.ts +18 -0
- package/dist/store/db-helpers.d.ts.map +1 -1
- package/dist/store/db-helpers.js +46 -0
- package/dist/store/db-helpers.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +13 -2
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/exodus/on-open.d.ts.map +1 -1
- package/dist/store/exodus/on-open.js +35 -0
- package/dist/store/exodus/on-open.js.map +1 -1
- package/dist/store/exodus/runtime-targets.d.ts +3 -3
- package/dist/store/exodus/runtime-targets.js +3 -3
- package/dist/store/import-remap.d.ts +12 -1
- package/dist/store/import-remap.d.ts.map +1 -1
- package/dist/store/import-remap.js +14 -0
- package/dist/store/import-remap.js.map +1 -1
- package/dist/store/legacy-tasks-lineage.d.ts +3 -1
- package/dist/store/legacy-tasks-lineage.d.ts.map +1 -1
- package/dist/store/legacy-tasks-lineage.js +3 -1
- package/dist/store/legacy-tasks-lineage.js.map +1 -1
- package/dist/store/memory-accessor.js +1 -1
- package/dist/store/memory-accessor.js.map +1 -1
- package/dist/store/migrate-signaldock-to-conduit.d.ts.map +1 -1
- package/dist/store/migrate-signaldock-to-conduit.js +3 -0
- package/dist/store/migrate-signaldock-to-conduit.js.map +1 -1
- package/dist/store/migration-manager.d.ts +61 -0
- package/dist/store/migration-manager.d.ts.map +1 -1
- package/dist/store/migration-manager.js +138 -6
- package/dist/store/migration-manager.js.map +1 -1
- package/dist/store/migration-sqlite.d.ts.map +1 -1
- package/dist/store/migration-sqlite.js +2 -0
- package/dist/store/migration-sqlite.js.map +1 -1
- package/dist/store/nexus-sqlite.d.ts.map +1 -1
- package/dist/store/nexus-sqlite.js +3 -0
- package/dist/store/nexus-sqlite.js.map +1 -1
- package/dist/store/nexus-validation-schemas.d.ts +64 -0
- package/dist/store/nexus-validation-schemas.d.ts.map +1 -1
- package/dist/store/open-cleo-db.d.ts.map +1 -1
- package/dist/store/open-cleo-db.js +3 -0
- package/dist/store/open-cleo-db.js.map +1 -1
- package/dist/store/portable-bundle-import.d.ts +8 -0
- package/dist/store/portable-bundle-import.d.ts.map +1 -1
- package/dist/store/portable-bundle-import.js +12 -0
- package/dist/store/portable-bundle-import.js.map +1 -1
- package/dist/store/portable-bundle-relocate.d.ts.map +1 -1
- package/dist/store/portable-bundle-relocate.js +2 -0
- 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 +15 -14
- package/dist/store/portable-bundle.js.map +1 -1
- package/dist/store/ports/domain-binding.d.ts.map +1 -1
- package/dist/store/ports/domain-binding.js +5 -0
- package/dist/store/ports/domain-binding.js.map +1 -1
- package/dist/store/pre-repair-snapshot.d.ts +4 -1
- package/dist/store/pre-repair-snapshot.d.ts.map +1 -1
- package/dist/store/pre-repair-snapshot.js +5 -1
- package/dist/store/pre-repair-snapshot.js.map +1 -1
- package/dist/store/regenerators.d.ts +4 -2
- package/dist/store/regenerators.d.ts.map +1 -1
- package/dist/store/regenerators.js +7 -3
- package/dist/store/regenerators.js.map +1 -1
- package/dist/store/repair-malformed-dbs.d.ts +4 -0
- package/dist/store/repair-malformed-dbs.d.ts.map +1 -1
- package/dist/store/repair-malformed-dbs.js +3 -0
- package/dist/store/repair-malformed-dbs.js.map +1 -1
- package/dist/store/safety-data-accessor.d.ts +8 -3
- package/dist/store/safety-data-accessor.d.ts.map +1 -1
- package/dist/store/safety-data-accessor.js +11 -4
- package/dist/store/safety-data-accessor.js.map +1 -1
- package/dist/store/schema/cleo-global/nexus.d.ts +48 -0
- package/dist/store/schema/cleo-global/nexus.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/nexus.js +17 -0
- package/dist/store/schema/cleo-global/nexus.js.map +1 -1
- package/dist/store/schema/cleo-project/docs.d.ts +16 -0
- package/dist/store/schema/cleo-project/docs.d.ts.map +1 -1
- package/dist/store/schema/cleo-project/docs.js +10 -0
- package/dist/store/schema/cleo-project/docs.js.map +1 -1
- package/dist/store/schema/cleo-project/tasks-core.d.ts +80 -0
- package/dist/store/schema/cleo-project/tasks-core.d.ts.map +1 -1
- package/dist/store/schema/cleo-project/tasks-core.js +25 -1
- package/dist/store/schema/cleo-project/tasks-core.js.map +1 -1
- package/dist/store/schema/cleo-shared/brain.d.ts +1 -1
- package/dist/store/schema/memory-schema.d.ts +1 -1
- package/dist/store/schema/nexus-schema.d.ts +48 -0
- package/dist/store/schema/nexus-schema.d.ts.map +1 -1
- package/dist/store/schema/nexus-schema.js +28 -7
- package/dist/store/schema/nexus-schema.js.map +1 -1
- package/dist/store/session-store.d.ts +65 -0
- package/dist/store/session-store.d.ts.map +1 -1
- package/dist/store/session-store.js +108 -7
- package/dist/store/session-store.js.map +1 -1
- package/dist/store/split-brain-import.d.ts.map +1 -1
- package/dist/store/split-brain-import.js +2 -0
- package/dist/store/split-brain-import.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +252 -47
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/sqlite-native.d.ts.map +1 -1
- package/dist/store/sqlite-native.js +1 -0
- package/dist/store/sqlite-native.js.map +1 -1
- package/dist/store/sqlite.d.ts +15 -3
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +57 -20
- package/dist/store/sqlite.js.map +1 -1
- package/dist/store/store-write-guard.d.ts +9 -3
- package/dist/store/store-write-guard.d.ts.map +1 -1
- package/dist/store/store-write-guard.js +25 -4
- package/dist/store/store-write-guard.js.map +1 -1
- package/dist/store/table-classification.d.ts +1 -1
- package/dist/store/table-classification.d.ts.map +1 -1
- package/dist/store/table-classification.js +34 -8
- package/dist/store/table-classification.js.map +1 -1
- package/dist/store/task-claim.d.ts +144 -0
- package/dist/store/task-claim.d.ts.map +1 -0
- package/dist/store/task-claim.js +195 -0
- package/dist/store/task-claim.js.map +1 -0
- package/dist/store/task-version.d.ts +43 -5
- package/dist/store/task-version.d.ts.map +1 -1
- package/dist/store/task-version.js +113 -17
- package/dist/store/task-version.js.map +1 -1
- package/dist/store/tasks-schema.d.ts +2 -0
- package/dist/store/tasks-schema.d.ts.map +1 -1
- package/dist/store/tasks-schema.js +1 -0
- package/dist/store/tasks-schema.js.map +1 -1
- package/dist/store/tasks-sqlite.js +1 -1
- package/dist/store/tasks-sqlite.js.map +1 -1
- package/dist/store/twin-collapse.d.ts +339 -22
- package/dist/store/twin-collapse.d.ts.map +1 -1
- package/dist/store/twin-collapse.js +1323 -48
- package/dist/store/twin-collapse.js.map +1 -1
- package/dist/store/umbrella-data-accessor.d.ts +8 -3
- package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
- package/dist/store/umbrella-data-accessor.js +10 -4
- package/dist/store/umbrella-data-accessor.js.map +1 -1
- package/dist/store/validation-schemas.d.ts +161 -1
- package/dist/store/validation-schemas.d.ts.map +1 -1
- package/dist/store/with-retry.d.ts +36 -0
- package/dist/store/with-retry.d.ts.map +1 -1
- package/dist/store/with-retry.js +51 -0
- package/dist/store/with-retry.js.map +1 -1
- package/dist/store/worktree-build-guard.d.ts +200 -0
- package/dist/store/worktree-build-guard.d.ts.map +1 -0
- package/dist/store/worktree-build-guard.js +497 -0
- package/dist/store/worktree-build-guard.js.map +1 -0
- package/dist/store/worktree-isolation-guard.d.ts +138 -0
- package/dist/store/worktree-isolation-guard.d.ts.map +1 -1
- package/dist/store/worktree-isolation-guard.js +189 -2
- package/dist/store/worktree-isolation-guard.js.map +1 -1
- package/dist/store/writer-lease.d.ts.map +1 -1
- package/dist/store/writer-lease.js +2 -0
- package/dist/store/writer-lease.js.map +1 -1
- package/dist/system/backup.d.ts +13 -2
- package/dist/system/backup.d.ts.map +1 -1
- package/dist/system/backup.js +11 -3
- package/dist/system/backup.js.map +1 -1
- package/dist/system/health.d.ts.map +1 -1
- package/dist/system/health.js +3 -1
- package/dist/system/health.js.map +1 -1
- package/dist/system/inject-generate.d.ts.map +1 -1
- package/dist/system/inject-generate.js +23 -10
- package/dist/system/inject-generate.js.map +1 -1
- package/dist/system/project-health.d.ts +8 -0
- package/dist/system/project-health.d.ts.map +1 -1
- package/dist/system/project-health.js +13 -5
- package/dist/system/project-health.js.map +1 -1
- package/dist/task-tools/index.d.ts +4 -2
- package/dist/task-tools/index.d.ts.map +1 -1
- package/dist/task-tools/index.js +3 -2
- package/dist/task-tools/index.js.map +1 -1
- package/dist/task-tools/score-task-priority.d.ts +131 -18
- package/dist/task-tools/score-task-priority.d.ts.map +1 -1
- package/dist/task-tools/score-task-priority.js +243 -80
- package/dist/task-tools/score-task-priority.js.map +1 -1
- package/dist/task-work/claims.d.ts +215 -0
- package/dist/task-work/claims.d.ts.map +1 -0
- package/dist/task-work/claims.js +272 -0
- package/dist/task-work/claims.js.map +1 -0
- package/dist/task-work/index.d.ts +47 -3
- package/dist/task-work/index.d.ts.map +1 -1
- package/dist/task-work/index.js +74 -41
- package/dist/task-work/index.js.map +1 -1
- package/dist/tasks/add.d.ts.map +1 -1
- package/dist/tasks/add.js +3 -2
- package/dist/tasks/add.js.map +1 -1
- package/dist/tasks/affected-packages.d.ts +5 -1
- package/dist/tasks/affected-packages.d.ts.map +1 -1
- package/dist/tasks/affected-packages.js +21 -3
- package/dist/tasks/affected-packages.js.map +1 -1
- package/dist/tasks/analyze.d.ts +29 -1
- package/dist/tasks/analyze.d.ts.map +1 -1
- package/dist/tasks/analyze.js +47 -37
- package/dist/tasks/analyze.js.map +1 -1
- package/dist/tasks/backfill-child-projections.d.ts.map +1 -1
- package/dist/tasks/backfill-child-projections.js +4 -1
- package/dist/tasks/backfill-child-projections.js.map +1 -1
- package/dist/tasks/change-set.d.ts +5 -0
- package/dist/tasks/change-set.d.ts.map +1 -1
- package/dist/tasks/change-set.js +75 -6
- package/dist/tasks/change-set.js.map +1 -1
- package/dist/tasks/command-line.d.ts +54 -0
- package/dist/tasks/command-line.d.ts.map +1 -0
- package/dist/tasks/command-line.js +151 -0
- package/dist/tasks/command-line.js.map +1 -0
- package/dist/tasks/complete.d.ts +16 -0
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +27 -7
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/component-pr.d.ts +162 -1
- package/dist/tasks/component-pr.d.ts.map +1 -1
- package/dist/tasks/component-pr.js +639 -53
- package/dist/tasks/component-pr.js.map +1 -1
- package/dist/tasks/delete.d.ts.map +1 -1
- package/dist/tasks/delete.js +20 -0
- package/dist/tasks/delete.js.map +1 -1
- package/dist/tasks/done-record.d.ts +14 -1
- package/dist/tasks/done-record.d.ts.map +1 -1
- package/dist/tasks/done-record.js +37 -0
- package/dist/tasks/done-record.js.map +1 -1
- package/dist/tasks/duplicate-detector.d.ts +23 -4
- package/dist/tasks/duplicate-detector.d.ts.map +1 -1
- package/dist/tasks/duplicate-detector.js +14 -5
- package/dist/tasks/duplicate-detector.js.map +1 -1
- package/dist/tasks/engine-wrap-ops.d.ts +48 -10
- package/dist/tasks/engine-wrap-ops.d.ts.map +1 -1
- package/dist/tasks/engine-wrap-ops.js +78 -10
- package/dist/tasks/engine-wrap-ops.js.map +1 -1
- package/dist/tasks/engine-wrap.d.ts +1 -1
- package/dist/tasks/engine-wrap.d.ts.map +1 -1
- package/dist/tasks/engine-wrap.js +1 -1
- package/dist/tasks/engine-wrap.js.map +1 -1
- package/dist/tasks/evidence.d.ts +2 -0
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +30 -4
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/gate-runner.d.ts.map +1 -1
- package/dist/tasks/gate-runner.js +48 -12
- package/dist/tasks/gate-runner.js.map +1 -1
- package/dist/tasks/graph-ops.d.ts +9 -2
- package/dist/tasks/graph-ops.d.ts.map +1 -1
- package/dist/tasks/graph-ops.js +24 -32
- package/dist/tasks/graph-ops.js.map +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +1 -1
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/ops.d.ts +1 -0
- package/dist/tasks/ops.d.ts.map +1 -1
- package/dist/tasks/plan.d.ts.map +1 -1
- package/dist/tasks/plan.js +16 -60
- package/dist/tasks/plan.js.map +1 -1
- package/dist/tasks/ranking-audit.d.ts +122 -0
- package/dist/tasks/ranking-audit.d.ts.map +1 -0
- package/dist/tasks/ranking-audit.js +193 -0
- package/dist/tasks/ranking-audit.js.map +1 -0
- package/dist/tasks/task-analyze.d.ts.map +1 -1
- package/dist/tasks/task-analyze.js +19 -32
- package/dist/tasks/task-analyze.js.map +1 -1
- package/dist/tasks/task-context.d.ts.map +1 -1
- package/dist/tasks/task-context.js +13 -0
- package/dist/tasks/task-context.js.map +1 -1
- package/dist/tasks/task-import.d.ts.map +1 -1
- package/dist/tasks/task-import.js +21 -12
- package/dist/tasks/task-import.js.map +1 -1
- package/dist/tasks/task-next.d.ts +67 -2
- package/dist/tasks/task-next.d.ts.map +1 -1
- package/dist/tasks/task-next.js +99 -102
- package/dist/tasks/task-next.js.map +1 -1
- package/dist/tasks/task-ops.d.ts +1 -1
- package/dist/tasks/task-ops.d.ts.map +1 -1
- package/dist/tasks/task-ops.js +1 -1
- package/dist/tasks/task-ops.js.map +1 -1
- package/dist/tasks/tool-resolver.d.ts +7 -1
- package/dist/tasks/tool-resolver.d.ts.map +1 -1
- package/dist/tasks/tool-resolver.js +24 -10
- package/dist/tasks/tool-resolver.js.map +1 -1
- package/dist/tasks/update.d.ts +8 -2
- package/dist/tasks/update.d.ts.map +1 -1
- package/dist/tasks/update.js +35 -6
- package/dist/tasks/update.js.map +1 -1
- package/dist/telemetry/sqlite.d.ts.map +1 -1
- package/dist/telemetry/sqlite.js +2 -0
- package/dist/telemetry/sqlite.js.map +1 -1
- package/dist/upgrade.d.ts +1 -1
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +48 -9
- package/dist/upgrade.js.map +1 -1
- package/dist/validation/doctor/checks.d.ts +20 -6
- package/dist/validation/doctor/checks.d.ts.map +1 -1
- package/dist/validation/doctor/checks.js +53 -10
- package/dist/validation/doctor/checks.js.map +1 -1
- package/dist/validation/validate-ops.d.ts.map +1 -1
- package/dist/validation/validate-ops.js +2 -3
- package/dist/validation/validate-ops.js.map +1 -1
- package/migrations/drizzle-cleo-global/20260929010000_t12512-registry-probed-opened/migration.sql +35 -0
- package/migrations/drizzle-cleo-global/20260929020000_t12721-git-state-head-committed-at/migration.sql +25 -0
- package/migrations/drizzle-cleo-project/20260929000000_t12535-docs-attachments-union-shape/migration.sql +21 -0
- package/migrations/drizzle-cleo-project/20260929120000_t12502-task-claim-leases/migration.sql +77 -0
- package/migrations/drizzle-cleo-project/20260929130000_t12736-claim-lease-iso-repair/migration.sql +37 -0
- package/package.json +24 -14
- package/schemas/config.schema.json +13 -0
- package/schemas/project-info.schema.json +10 -4
- package/templates/CLEO-INJECTION.md +1 -1
- package/templates/CLEO-REFERENCE.md +7 -3
- package/templates/cleo-gitignore +11 -0
- package/templates/workflows/release-prepare.yml.tmpl +156 -10
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monthly spend cap for System One decisions — the CLEO-enforced COST budget
|
|
3
|
+
* of owner decision D11159 (spec `system-one-integration` §7).
|
|
4
|
+
*
|
|
5
|
+
* Every CLEO process on the machine records provider-reported cost (integer
|
|
6
|
+
* micro-dollars) into ONE ledger, `<cleoHome>/decide/spend.json`, guarded by a
|
|
7
|
+
* `proper-lockfile` lock. Once the month-to-date spend reaches the cap
|
|
8
|
+
* (`decide.budget.monthlyMicros`, default
|
|
9
|
+
* {@link DEFAULT_MONTHLY_SPEND_CAP_MICROS} = $1), every site degrades to its
|
|
10
|
+
* heuristic with fallback reason `budget` until the UTC month rolls over. It
|
|
11
|
+
* never fails a command.
|
|
12
|
+
*
|
|
13
|
+
* ## Reserve, then commit
|
|
14
|
+
*
|
|
15
|
+
* A caller reserves its estimated cost BEFORE the provider call, under the
|
|
16
|
+
* same lock as the cap check, and commits the reported cost (or releases the
|
|
17
|
+
* reservation) after it. Concurrent callers therefore see each other's
|
|
18
|
+
* in-flight spend and cannot overshoot the cap together. A reservation still
|
|
19
|
+
* pending after {@link RESERVATION_TTL_MS} (its process died, or exited
|
|
20
|
+
* before its commit landed) is CHARGED at its estimate, not dropped: the
|
|
21
|
+
* request may have been billed, and the cap must not undercount it.
|
|
22
|
+
*
|
|
23
|
+
* The lock retries for about a second with backoff: a decision may wait for
|
|
24
|
+
* the ledger, but a cost is never dropped because 40 processes recorded at
|
|
25
|
+
* once (review of #1685: the first version lost 33 of 40 concurrent records).
|
|
26
|
+
*
|
|
27
|
+
* The ledger also carries the key-limit stop: a 403 `key_limit_exceeded`
|
|
28
|
+
* (an unverified provider extension) means the key's monthly decision limit
|
|
29
|
+
* is reached, so decisions stop until the end of the UTC month.
|
|
30
|
+
*
|
|
31
|
+
* A corrupt ledger fails closed (every site uses its heuristic) and
|
|
32
|
+
* `cleo decide status` says so; `cleo decide budget reset` repairs it, moving
|
|
33
|
+
* the bad file aside as a receipt. It refuses a readable ledger unless
|
|
34
|
+
* `--force` is given, and then keeps the month-to-date spend, so a reset can
|
|
35
|
+
* never lift a reached cap.
|
|
36
|
+
*
|
|
37
|
+
* @task T12664
|
|
38
|
+
* @epic T12486
|
|
39
|
+
*/
|
|
40
|
+
import { randomBytes } from 'node:crypto';
|
|
41
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
42
|
+
import { dirname, join } from 'node:path';
|
|
43
|
+
import { getCleoHome } from '@cleocode/paths';
|
|
44
|
+
import lockfile from 'proper-lockfile';
|
|
45
|
+
import { z } from 'zod';
|
|
46
|
+
/** Default monthly cap: 1,000,000 micro-dollars = $1 (D11159). */
|
|
47
|
+
export const DEFAULT_MONTHLY_SPEND_CAP_MICROS = 1_000_000;
|
|
48
|
+
/** Config key holding the monthly cap in micro-dollars. */
|
|
49
|
+
export const MONTHLY_SPEND_CAP_KEY = 'decide.budget.monthlyMicros';
|
|
50
|
+
/**
|
|
51
|
+
* How long a reservation stays pending, ms. After that it is charged at its
|
|
52
|
+
* estimate (it may have been billed). Decision deadlines are hundreds of ms,
|
|
53
|
+
* so a live call always commits or releases long before this.
|
|
54
|
+
*/
|
|
55
|
+
export const RESERVATION_TTL_MS = 60_000;
|
|
56
|
+
/**
|
|
57
|
+
* The UTC month of `epochMs`, `YYYY-MM`.
|
|
58
|
+
*
|
|
59
|
+
* @param epochMs - Epoch milliseconds.
|
|
60
|
+
* @returns The month string.
|
|
61
|
+
*/
|
|
62
|
+
export function utcMonth(epochMs) {
|
|
63
|
+
const d = new Date(epochMs);
|
|
64
|
+
return `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, '0')}`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Epoch ms of the first instant of the next UTC month.
|
|
68
|
+
*
|
|
69
|
+
* @param epochMs - Epoch milliseconds.
|
|
70
|
+
* @returns Start of the next UTC month.
|
|
71
|
+
*/
|
|
72
|
+
export function startOfNextUtcMonth(epochMs) {
|
|
73
|
+
const d = new Date(epochMs);
|
|
74
|
+
return Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 1);
|
|
75
|
+
}
|
|
76
|
+
function freshState(now) {
|
|
77
|
+
return { month: utcMonth(now), spentMicros: 0, keyLimitedUntil: 0, reservations: {} };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Roll a state over to the current month and charge expired reservations at
|
|
81
|
+
* their estimate (mutates). An expired reservation's call may have been
|
|
82
|
+
* billed, so it is counted rather than forgotten.
|
|
83
|
+
*/
|
|
84
|
+
function roll(state, now) {
|
|
85
|
+
const month = utcMonth(now);
|
|
86
|
+
if (state.month !== month) {
|
|
87
|
+
state.month = month;
|
|
88
|
+
state.spentMicros = 0;
|
|
89
|
+
}
|
|
90
|
+
if (state.keyLimitedUntil <= now)
|
|
91
|
+
state.keyLimitedUntil = 0;
|
|
92
|
+
for (const [id, r] of Object.entries(state.reservations)) {
|
|
93
|
+
if (now - r.at >= RESERVATION_TTL_MS) {
|
|
94
|
+
state.spentMicros += positive(r.micros);
|
|
95
|
+
delete state.reservations[id];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function reservedOf(state) {
|
|
100
|
+
return Object.values(state.reservations).reduce((n, r) => n + r.micros, 0);
|
|
101
|
+
}
|
|
102
|
+
function positive(micros) {
|
|
103
|
+
return Number.isFinite(micros) && micros > 0 ? Math.round(micros) : 0;
|
|
104
|
+
}
|
|
105
|
+
function doReserve(state, capMicros, estimateMicros, now) {
|
|
106
|
+
roll(state, now);
|
|
107
|
+
if (state.keyLimitedUntil > now)
|
|
108
|
+
return { verdict: 'key_limited' };
|
|
109
|
+
const estimate = positive(estimateMicros);
|
|
110
|
+
if (state.spentMicros + reservedOf(state) + estimate > capMicros ||
|
|
111
|
+
state.spentMicros >= capMicros) {
|
|
112
|
+
return { verdict: 'over_budget' };
|
|
113
|
+
}
|
|
114
|
+
const id = randomBytes(8).toString('hex');
|
|
115
|
+
state.reservations[id] = { micros: estimate, at: now };
|
|
116
|
+
return { verdict: 'ok', id };
|
|
117
|
+
}
|
|
118
|
+
function toStatus(state) {
|
|
119
|
+
return {
|
|
120
|
+
month: state.month,
|
|
121
|
+
spentMicros: state.spentMicros,
|
|
122
|
+
reservedMicros: reservedOf(state),
|
|
123
|
+
...(state.keyLimitedUntil > 0 ? { keyLimitedUntil: state.keyLimitedUntil } : {}),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/** The operations every ledger implements, over a state accessor. */
|
|
127
|
+
function ledgerOver(withState, now) {
|
|
128
|
+
return {
|
|
129
|
+
async reserve(capMicros, estimateMicros) {
|
|
130
|
+
try {
|
|
131
|
+
return await withState((s) => doReserve(s, capMicros, estimateMicros, now()), true);
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return { verdict: 'unavailable' };
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
async commit(id, costMicros) {
|
|
138
|
+
try {
|
|
139
|
+
await withState((s) => {
|
|
140
|
+
roll(s, now());
|
|
141
|
+
delete s.reservations[id];
|
|
142
|
+
s.spentMicros += positive(costMicros);
|
|
143
|
+
}, true);
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
/* the reservation expires; an unrecorded cost only makes the cap later */
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
async release(id) {
|
|
150
|
+
try {
|
|
151
|
+
await withState((s) => {
|
|
152
|
+
delete s.reservations[id];
|
|
153
|
+
}, true);
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
/* the reservation expires on its own */
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
async record(costMicros) {
|
|
160
|
+
const micros = positive(costMicros);
|
|
161
|
+
if (micros === 0)
|
|
162
|
+
return;
|
|
163
|
+
try {
|
|
164
|
+
await withState((s) => {
|
|
165
|
+
roll(s, now());
|
|
166
|
+
s.spentMicros += micros;
|
|
167
|
+
}, true);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
/* best effort */
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
async markKeyLimited() {
|
|
174
|
+
try {
|
|
175
|
+
await withState((s) => {
|
|
176
|
+
roll(s, now());
|
|
177
|
+
s.keyLimitedUntil = startOfNextUtcMonth(now());
|
|
178
|
+
}, true);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
/* the next call meets the 403 again */
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
async status() {
|
|
185
|
+
try {
|
|
186
|
+
return await withState((s) => {
|
|
187
|
+
roll(s, now());
|
|
188
|
+
return toStatus(s);
|
|
189
|
+
}, false);
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* A process-local ledger (tests, callers that must not touch disk).
|
|
199
|
+
*
|
|
200
|
+
* @param opts - Clock.
|
|
201
|
+
* @returns A {@link SpendLedger} that does NOT coordinate across processes.
|
|
202
|
+
*/
|
|
203
|
+
export function createMemorySpendLedger(opts = {}) {
|
|
204
|
+
const now = opts.now ?? Date.now;
|
|
205
|
+
const state = freshState(now());
|
|
206
|
+
return ledgerOver(async (mutate) => mutate(state), now);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Default ledger location: `<cleoHome>/decide/spend.json`.
|
|
210
|
+
*
|
|
211
|
+
* @returns Absolute path.
|
|
212
|
+
*/
|
|
213
|
+
export function defaultSpendStatePath() {
|
|
214
|
+
return join(getCleoHome(), 'decide', 'spend.json');
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Lock retries: about a second with backoff (5 ms growing to 50 ms). Long
|
|
218
|
+
* enough that dozens of concurrent processes all get their turn; a caller on
|
|
219
|
+
* a decision deadline is bounded by that deadline, not by this.
|
|
220
|
+
*/
|
|
221
|
+
const LOCK_OPTIONS = {
|
|
222
|
+
realpath: false,
|
|
223
|
+
stale: 5_000,
|
|
224
|
+
retries: { retries: 40, factor: 1.2, minTimeout: 5, maxTimeout: 50, randomize: true },
|
|
225
|
+
};
|
|
226
|
+
const ledgerSchema = z.object({
|
|
227
|
+
month: z.string(),
|
|
228
|
+
spentMicros: z.number().nonnegative(),
|
|
229
|
+
keyLimitedUntil: z.number().nonnegative(),
|
|
230
|
+
reservations: z
|
|
231
|
+
.record(z.string(), z.object({ micros: z.number().nonnegative(), at: z.number() }))
|
|
232
|
+
.default({}),
|
|
233
|
+
});
|
|
234
|
+
/** Thrown when the ledger file exists but cannot be parsed. */
|
|
235
|
+
class CorruptLedgerError extends Error {
|
|
236
|
+
}
|
|
237
|
+
function readLedger(path, now) {
|
|
238
|
+
let raw;
|
|
239
|
+
try {
|
|
240
|
+
raw = readFileSync(path, 'utf-8');
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
return freshState(now);
|
|
244
|
+
}
|
|
245
|
+
let json;
|
|
246
|
+
try {
|
|
247
|
+
json = JSON.parse(raw);
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
throw new CorruptLedgerError('spend ledger is not JSON');
|
|
251
|
+
}
|
|
252
|
+
const parsed = ledgerSchema.safeParse(json);
|
|
253
|
+
if (!parsed.success)
|
|
254
|
+
throw new CorruptLedgerError('spend ledger has an unexpected shape');
|
|
255
|
+
return parsed.data;
|
|
256
|
+
}
|
|
257
|
+
function writeLedger(path, state) {
|
|
258
|
+
const tmp = join(dirname(path), `.spend.${randomBytes(6).toString('hex')}.tmp`);
|
|
259
|
+
writeFileSync(tmp, JSON.stringify(state), 'utf-8');
|
|
260
|
+
try {
|
|
261
|
+
renameSync(tmp, path);
|
|
262
|
+
}
|
|
263
|
+
catch (err) {
|
|
264
|
+
try {
|
|
265
|
+
unlinkSync(tmp);
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
/* ignore cleanup failure */
|
|
269
|
+
}
|
|
270
|
+
throw err;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* A ledger shared by every process on the machine through a locked JSON file.
|
|
275
|
+
* A lock or read failure (including a corrupt file) makes `reserve` answer
|
|
276
|
+
* `unavailable`, which the client treats as a fallback: the cap fails closed,
|
|
277
|
+
* like the request bucket.
|
|
278
|
+
*
|
|
279
|
+
* @param opts - Clock and state path.
|
|
280
|
+
* @returns A {@link SpendLedger}.
|
|
281
|
+
*/
|
|
282
|
+
export function createFileSpendLedger(opts = {}) {
|
|
283
|
+
const now = opts.now ?? Date.now;
|
|
284
|
+
const statePath = opts.statePath ?? defaultSpendStatePath();
|
|
285
|
+
return ledgerOver(async (mutate, write) => {
|
|
286
|
+
mkdirSync(dirname(statePath), { recursive: true });
|
|
287
|
+
const release = await lockfile.lock(statePath, LOCK_OPTIONS);
|
|
288
|
+
try {
|
|
289
|
+
const state = readLedger(statePath, now());
|
|
290
|
+
const result = mutate(state);
|
|
291
|
+
if (write)
|
|
292
|
+
writeLedger(statePath, state);
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
await release().catch(() => undefined);
|
|
297
|
+
}
|
|
298
|
+
}, now);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Whether the ledger file is readable.
|
|
302
|
+
*
|
|
303
|
+
* @param statePath - Ledger path. Default {@link defaultSpendStatePath}.
|
|
304
|
+
* @returns `ok`, `absent`, `corrupt` or `unavailable` (unreadable for another reason).
|
|
305
|
+
*/
|
|
306
|
+
export function inspectSpendLedger(statePath = defaultSpendStatePath()) {
|
|
307
|
+
if (!existsSync(statePath))
|
|
308
|
+
return 'absent';
|
|
309
|
+
try {
|
|
310
|
+
readLedger(statePath, Date.now());
|
|
311
|
+
return 'ok';
|
|
312
|
+
}
|
|
313
|
+
catch (err) {
|
|
314
|
+
return err instanceof CorruptLedgerError ? 'corrupt' : 'unavailable';
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Thrown by {@link resetSpendLedger} when the ledger is not corrupt and
|
|
319
|
+
* `force` was not given. A reached cap is not a fault to repair.
|
|
320
|
+
*/
|
|
321
|
+
export class SpendResetRefusedError extends Error {
|
|
322
|
+
/** Health of the ledger that was not reset. */
|
|
323
|
+
health;
|
|
324
|
+
/** @param health - The ledger's health (anything but `corrupt`). */
|
|
325
|
+
constructor(health) {
|
|
326
|
+
super(`The System One spend ledger is ${health === 'ok' ? 'healthy' : health}, so it was not reset: ` +
|
|
327
|
+
'`cleo decide budget reset` only repairs a corrupt ledger. A reached monthly cap lifts when ' +
|
|
328
|
+
'the UTC month rolls over or when `decide.budget.monthlyMicros` is raised; resetting does not ' +
|
|
329
|
+
'lift it. Pass --force to reset anyway (month-to-date spend is kept; in-flight reservations ' +
|
|
330
|
+
'and the key-limit stop are cleared).');
|
|
331
|
+
this.name = 'SpendResetRefusedError';
|
|
332
|
+
this.health = health;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Reset the ledger (`cleo decide budget reset`): move the current file aside
|
|
337
|
+
* to `spend.json.reset-<iso>` and start a new ledger for this month. The
|
|
338
|
+
* repair for a corrupt ledger, which otherwise fails closed forever.
|
|
339
|
+
*
|
|
340
|
+
* Refuses (throws {@link SpendResetRefusedError}) unless the ledger is
|
|
341
|
+
* corrupt or `opts.force` is set, so an agent cannot reset its way past a
|
|
342
|
+
* reached cap. When the old file is readable its month-to-date spend
|
|
343
|
+
* (expired reservations included) is carried over; only a corrupt file's
|
|
344
|
+
* spend is lost, and the moved file is kept as the receipt of it.
|
|
345
|
+
*
|
|
346
|
+
* @param statePath - Ledger path. Default {@link defaultSpendStatePath}.
|
|
347
|
+
* @param now - Wall clock, epoch ms.
|
|
348
|
+
* @param opts - `force` resets a ledger that is not corrupt.
|
|
349
|
+
* @returns What was reset, the spend carried over and where the old file went.
|
|
350
|
+
* @throws {SpendResetRefusedError} When the ledger is not corrupt and `force` is not set.
|
|
351
|
+
*/
|
|
352
|
+
export async function resetSpendLedger(statePath = defaultSpendStatePath(), now = Date.now(), opts = {}) {
|
|
353
|
+
const resetAt = new Date(now).toISOString();
|
|
354
|
+
mkdirSync(dirname(statePath), { recursive: true });
|
|
355
|
+
const release = await lockfile.lock(statePath, LOCK_OPTIONS);
|
|
356
|
+
try {
|
|
357
|
+
// Inspect under the lock, so the verdict is about the file we move.
|
|
358
|
+
const before = inspectSpendLedger(statePath);
|
|
359
|
+
const forced = opts.force === true;
|
|
360
|
+
if (before !== 'corrupt' && !forced)
|
|
361
|
+
throw new SpendResetRefusedError(before);
|
|
362
|
+
const next = freshState(now);
|
|
363
|
+
if (before === 'ok') {
|
|
364
|
+
const old = readLedger(statePath, now);
|
|
365
|
+
roll(old, now);
|
|
366
|
+
next.spentMicros = old.spentMicros;
|
|
367
|
+
}
|
|
368
|
+
let backupPath;
|
|
369
|
+
if (existsSync(statePath)) {
|
|
370
|
+
backupPath = `${statePath}.reset-${resetAt.replace(/[:.]/g, '-')}`;
|
|
371
|
+
renameSync(statePath, backupPath);
|
|
372
|
+
}
|
|
373
|
+
writeLedger(statePath, next);
|
|
374
|
+
return {
|
|
375
|
+
statePath,
|
|
376
|
+
before,
|
|
377
|
+
...(backupPath ? { backupPath } : {}),
|
|
378
|
+
resetAt,
|
|
379
|
+
spentMicros: next.spentMicros,
|
|
380
|
+
forced,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
finally {
|
|
384
|
+
await release().catch(() => undefined);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
//# sourceMappingURL=spend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spend.js","sourceRoot":"","sources":["../../src/decide/spend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,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,KAA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AAC,CAAC;QAC9E,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;YACvC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACf,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;QACrC,CAAC;QACD,IAAI,UAA8B,CAAC;QACnC,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1B,UAAU,GAAG,GAAG,SAAS,UAAU,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;YACnE,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACpC,CAAC;QACD,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC7B,OAAO;YACL,SAAS;YACT,MAAM;YACN,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrC,OAAO;YACP,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,MAAM;SACP,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive System One setup: `cleo decide config` on a TTY, and the
|
|
3
|
+
* `system-one` section of `cleo setup`.
|
|
4
|
+
*
|
|
5
|
+
* Steps: pick the provider (layahost first, recommended) → name the profile
|
|
6
|
+
* (Enter keeps `default`; the profile is `<provider>/<name>`, T12733) → use
|
|
7
|
+
* the provider's default URL (stored as `default`) or enter an override →
|
|
8
|
+
* the API key through {@link WizardIO.secret} (masked) → probe
|
|
9
|
+
* `GET /v1/models` → pick the model (layahost defaults to its routing model)
|
|
10
|
+
* → save (probes again and re-detects capabilities; other profiles are kept)
|
|
11
|
+
* → when another profile is active, whether to make this one active →
|
|
12
|
+
* optionally one smoke-test question through the saved profile.
|
|
13
|
+
*
|
|
14
|
+
* All logic lives here; the IO is injected, so tests drive it with a stub and
|
|
15
|
+
* the CLI with readline. Nothing this module returns or prints carries the
|
|
16
|
+
* key: only the masked last-4 preview from the saved summary.
|
|
17
|
+
*
|
|
18
|
+
* @task T12713
|
|
19
|
+
* @task T12733
|
|
20
|
+
* @epic T12486
|
|
21
|
+
*/
|
|
22
|
+
import type { WizardIO } from '../setup/wizard.js';
|
|
23
|
+
import { type DecideAskResult, type DecideConfigureResult } from './operations.js';
|
|
24
|
+
/** How many times the wizard re-asks for a URL or model name before giving up. */
|
|
25
|
+
export declare const DECIDE_WIZARD_MAX_ATTEMPTS = 3;
|
|
26
|
+
/** State the setup smoke test judges. */
|
|
27
|
+
export declare const DECIDE_SMOKE_STATE = "CLEO setup check: the System One provider was just configured.";
|
|
28
|
+
/** The setup smoke test's yes/no question; the answer should be "yes". */
|
|
29
|
+
export declare const DECIDE_SMOKE_QUESTION = "The text says a provider was configured.";
|
|
30
|
+
/** Options for {@link runDecideWizard}. */
|
|
31
|
+
export interface DecideWizardOptions {
|
|
32
|
+
/** `fetch` for the model probe and the save-time probe; tests inject a stub. */
|
|
33
|
+
readonly fetch?: typeof fetch;
|
|
34
|
+
/** Deadline for each probe, ms. Default {@link DEFAULT_DECIDE_PROBE_TIMEOUT_MS}. */
|
|
35
|
+
readonly timeoutMs?: number;
|
|
36
|
+
/** Smoke-test runner. Default: one `decide ask` through the saved settings. */
|
|
37
|
+
readonly smoke?: () => Promise<DecideAskResult>;
|
|
38
|
+
/** Project root for the smoke test's audit line. Default: the resolved project root. */
|
|
39
|
+
readonly projectRoot?: string;
|
|
40
|
+
}
|
|
41
|
+
/** Result of {@link runDecideWizard}. Secret-free. */
|
|
42
|
+
export interface DecideWizardResult {
|
|
43
|
+
/** Whether settings were saved. */
|
|
44
|
+
readonly configured: boolean;
|
|
45
|
+
/** One-line human summary. */
|
|
46
|
+
readonly summary: string;
|
|
47
|
+
/** The saved settings, when saved. */
|
|
48
|
+
readonly config?: DecideConfigureResult;
|
|
49
|
+
/** The smoke-test answer, when one ran. */
|
|
50
|
+
readonly smoke?: DecideAskResult;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Run the interactive System One setup.
|
|
54
|
+
*
|
|
55
|
+
* @param io - Prompt surface. The key is read with {@link WizardIO.secret}.
|
|
56
|
+
* @param opts - Injectable `fetch`, deadline and smoke runner.
|
|
57
|
+
* @returns Whether settings were saved, a summary and the secret-free results.
|
|
58
|
+
* @throws {DecideCredentialsError} Only when the save itself rejects the settings.
|
|
59
|
+
*/
|
|
60
|
+
export declare function runDecideWizard(io: WizardIO, opts?: DecideWizardOptions): Promise<DecideWizardResult>;
|
|
61
|
+
//# sourceMappingURL=wizard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wizard.d.ts","sourceRoot":"","sources":["../../src/decide/wizard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AASnD,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AAGzB,kFAAkF;AAClF,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,yCAAyC;AACzC,eAAO,MAAM,kBAAkB,mEAAmE,CAAC;AAEnG,0EAA0E;AAC1E,eAAO,MAAM,qBAAqB,6CAA6C,CAAC;AAEhF,2CAA2C;AAC3C,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,oFAAoF;IACpF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IAChD,wFAAwF;IACxF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,sDAAsD;AACtD,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sCAAsC;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IACxC,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;CAClC;AAoGD;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,EAAE,EAAE,QAAQ,EACZ,IAAI,GAAE,mBAAwB,GAC7B,OAAO,CAAC,kBAAkB,CAAC,CAiG7B"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive System One setup: `cleo decide config` on a TTY, and the
|
|
3
|
+
* `system-one` section of `cleo setup`.
|
|
4
|
+
*
|
|
5
|
+
* Steps: pick the provider (layahost first, recommended) → name the profile
|
|
6
|
+
* (Enter keeps `default`; the profile is `<provider>/<name>`, T12733) → use
|
|
7
|
+
* the provider's default URL (stored as `default`) or enter an override →
|
|
8
|
+
* the API key through {@link WizardIO.secret} (masked) → probe
|
|
9
|
+
* `GET /v1/models` → pick the model (layahost defaults to its routing model)
|
|
10
|
+
* → save (probes again and re-detects capabilities; other profiles are kept)
|
|
11
|
+
* → when another profile is active, whether to make this one active →
|
|
12
|
+
* optionally one smoke-test question through the saved profile.
|
|
13
|
+
*
|
|
14
|
+
* All logic lives here; the IO is injected, so tests drive it with a stub and
|
|
15
|
+
* the CLI with readline. Nothing this module returns or prints carries the
|
|
16
|
+
* key: only the masked last-4 preview from the saved summary.
|
|
17
|
+
*
|
|
18
|
+
* @task T12713
|
|
19
|
+
* @task T12733
|
|
20
|
+
* @epic T12486
|
|
21
|
+
*/
|
|
22
|
+
import { DECIDE_DEFAULT_PROFILE_NAME, DECIDE_PROFILE_DEFAULT_URL } from '@cleocode/contracts';
|
|
23
|
+
import { decideProfileId, isAllowedDecideBaseUrl, isValidDecideProfileName, listDecideProfiles, useDecideProfile, } from './credentials.js';
|
|
24
|
+
import { isValidDecisionModelName, listJevModels } from './jev-wire.js';
|
|
25
|
+
import { askDecideDebug, configureDecide, DEFAULT_DECIDE_PROBE_TIMEOUT_MS, } from './operations.js';
|
|
26
|
+
import { listDecisionProviderPresets } from './providers.js';
|
|
27
|
+
/** How many times the wizard re-asks for a URL or model name before giving up. */
|
|
28
|
+
export const DECIDE_WIZARD_MAX_ATTEMPTS = 3;
|
|
29
|
+
/** State the setup smoke test judges. */
|
|
30
|
+
export const DECIDE_SMOKE_STATE = 'CLEO setup check: the System One provider was just configured.';
|
|
31
|
+
/** The setup smoke test's yes/no question; the answer should be "yes". */
|
|
32
|
+
export const DECIDE_SMOKE_QUESTION = 'The text says a provider was configured.';
|
|
33
|
+
/** Ask for a profile name (Enter → `default`) until it is valid, or give up. */
|
|
34
|
+
async function askProfileName(io, provider) {
|
|
35
|
+
const fallback = DECIDE_DEFAULT_PROFILE_NAME;
|
|
36
|
+
for (let attempt = 0; attempt < DECIDE_WIZARD_MAX_ATTEMPTS; attempt++) {
|
|
37
|
+
const name = (await io.prompt(`Profile name, saved as ${provider}/<name> (Enter for "${fallback}"):`)).trim();
|
|
38
|
+
if (!name)
|
|
39
|
+
return fallback;
|
|
40
|
+
if (isValidDecideProfileName(name))
|
|
41
|
+
return name;
|
|
42
|
+
io.warn('Profile names use 1-32 lowercase letters, digits or -, starting and ending with a letter or digit.');
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* After saving a profile that is not active (another one is): ask whether to
|
|
48
|
+
* make it active (default no, so adding a second key never silently switches
|
|
49
|
+
* everyday decisions).
|
|
50
|
+
*/
|
|
51
|
+
async function confirmActivation(io, profile) {
|
|
52
|
+
const { active } = listDecideProfiles();
|
|
53
|
+
return io.confirm(`Make "${profile}" the active profile for everyday decisions? ("${active ?? 'none'}" is active now)`, false);
|
|
54
|
+
}
|
|
55
|
+
/** Ask for an override base URL until it is acceptable, or give up. */
|
|
56
|
+
async function askBaseUrl(io, preset) {
|
|
57
|
+
for (let attempt = 0; attempt < DECIDE_WIZARD_MAX_ATTEMPTS; attempt++) {
|
|
58
|
+
const url = (await io.prompt(`${preset.kind} base URL (e.g. https://provider.example):`)).trim();
|
|
59
|
+
if (!url)
|
|
60
|
+
return undefined;
|
|
61
|
+
if (isAllowedDecideBaseUrl(url))
|
|
62
|
+
return url;
|
|
63
|
+
io.warn('That URL is not accepted: use an absolute https:// URL (plain http:// only for localhost, 127.0.0.1 or ::1), without user:pass@.');
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
/** Ask for a model name until it is valid, or give up. */
|
|
68
|
+
async function askModelName(io) {
|
|
69
|
+
for (let attempt = 0; attempt < DECIDE_WIZARD_MAX_ATTEMPTS; attempt++) {
|
|
70
|
+
const model = (await io.prompt('Model name (the provider listed none):')).trim();
|
|
71
|
+
if (!model)
|
|
72
|
+
return undefined;
|
|
73
|
+
if (isValidDecisionModelName(model))
|
|
74
|
+
return model;
|
|
75
|
+
io.warn('Model names may contain only letters, digits and . _ : / @ - (1-128 characters).');
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Choose the model: the preset default first (layahost), then the listed
|
|
81
|
+
* models in the provider's order. With one candidate there is nothing to ask.
|
|
82
|
+
*/
|
|
83
|
+
async function chooseModel(io, preset, listed) {
|
|
84
|
+
const fallback = preset.defaultModel;
|
|
85
|
+
const candidates = fallback ? [fallback, ...listed.filter((m) => m !== fallback)] : [...listed];
|
|
86
|
+
if (candidates.length === 0)
|
|
87
|
+
return askModelName(io);
|
|
88
|
+
if (candidates.length === 1) {
|
|
89
|
+
io.info(`Model: ${candidates[0]}`);
|
|
90
|
+
return candidates[0];
|
|
91
|
+
}
|
|
92
|
+
const question = fallback
|
|
93
|
+
? `Which model? (${fallback} is the recommended default)`
|
|
94
|
+
: 'Which model?';
|
|
95
|
+
return io.select(question, candidates);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Choose the URL: the provider's preset (stored as `default`, so a changed
|
|
99
|
+
* preset flows through) unless the user declines and enters an override. A
|
|
100
|
+
* provider without a preset asks for the URL directly.
|
|
101
|
+
*
|
|
102
|
+
* @returns `default`, an override URL, or `undefined` when none was entered.
|
|
103
|
+
*/
|
|
104
|
+
async function chooseUrl(io, preset) {
|
|
105
|
+
const presetUrl = preset.defaultBaseUrl;
|
|
106
|
+
if (presetUrl && (await io.confirm(`Use the default URL (${presetUrl})?`, true))) {
|
|
107
|
+
return DECIDE_PROFILE_DEFAULT_URL;
|
|
108
|
+
}
|
|
109
|
+
return askBaseUrl(io, preset);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Run the interactive System One setup.
|
|
113
|
+
*
|
|
114
|
+
* @param io - Prompt surface. The key is read with {@link WizardIO.secret}.
|
|
115
|
+
* @param opts - Injectable `fetch`, deadline and smoke runner.
|
|
116
|
+
* @returns Whether settings were saved, a summary and the secret-free results.
|
|
117
|
+
* @throws {DecideCredentialsError} Only when the save itself rejects the settings.
|
|
118
|
+
*/
|
|
119
|
+
export async function runDecideWizard(io, opts = {}) {
|
|
120
|
+
const presets = listDecisionProviderPresets();
|
|
121
|
+
const picked = await io.select('Which System One provider?', presets.map((p) => p.label));
|
|
122
|
+
const preset = presets.find((p) => p.label === picked) ?? presets[0];
|
|
123
|
+
if (!preset)
|
|
124
|
+
return { configured: false, summary: 'skipped (no provider presets)' };
|
|
125
|
+
const name = await askProfileName(io, preset.kind);
|
|
126
|
+
if (!name) {
|
|
127
|
+
io.warn('No valid profile name entered; System One left unchanged.');
|
|
128
|
+
return { configured: false, summary: 'skipped (no valid profile name)' };
|
|
129
|
+
}
|
|
130
|
+
const profile = decideProfileId(preset.kind, name);
|
|
131
|
+
const urlSetting = await chooseUrl(io, preset);
|
|
132
|
+
const baseUrl = urlSetting === DECIDE_PROFILE_DEFAULT_URL ? preset.defaultBaseUrl : urlSetting;
|
|
133
|
+
if (!urlSetting || !baseUrl) {
|
|
134
|
+
io.warn('No valid URL entered; System One left unchanged.');
|
|
135
|
+
return { configured: false, summary: 'skipped (no valid URL)' };
|
|
136
|
+
}
|
|
137
|
+
const apiKey = (await io.secret(`${profile} API key:`)).trim();
|
|
138
|
+
if (!apiKey) {
|
|
139
|
+
io.warn('No API key entered; System One left unchanged.');
|
|
140
|
+
return { configured: false, summary: 'skipped (empty api key)' };
|
|
141
|
+
}
|
|
142
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_DECIDE_PROBE_TIMEOUT_MS;
|
|
143
|
+
let listed = [];
|
|
144
|
+
try {
|
|
145
|
+
listed = await listJevModels({ baseUrl, apiKey }, AbortSignal.timeout(timeoutMs), {
|
|
146
|
+
fetch: opts.fetch,
|
|
147
|
+
});
|
|
148
|
+
io.info(`Reached ${baseUrl}: ${listed.length} model(s) listed.`);
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
io.warn(`Could not list models at ${baseUrl}: ${err instanceof Error ? err.message : 'probe failed'}`);
|
|
152
|
+
if (!(await io.confirm('Save these settings anyway?', false))) {
|
|
153
|
+
return { configured: false, summary: 'cancelled (provider probe failed)' };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const model = await chooseModel(io, preset, listed);
|
|
157
|
+
if (!model) {
|
|
158
|
+
io.warn('No model chosen; System One left unchanged (the provider rejects requests without one).');
|
|
159
|
+
return { configured: false, summary: 'skipped (no model)' };
|
|
160
|
+
}
|
|
161
|
+
let config = await configureDecide({
|
|
162
|
+
provider: preset.kind,
|
|
163
|
+
profile,
|
|
164
|
+
baseUrl: urlSetting,
|
|
165
|
+
apiKey,
|
|
166
|
+
model,
|
|
167
|
+
fetch: opts.fetch,
|
|
168
|
+
timeoutMs,
|
|
169
|
+
});
|
|
170
|
+
if (!config.active && (await confirmActivation(io, profile))) {
|
|
171
|
+
await useDecideProfile(profile);
|
|
172
|
+
config = { ...config, active: true, activeProfile: profile };
|
|
173
|
+
}
|
|
174
|
+
const role = config.active ? 'active' : `inactive; switch with: cleo decide use ${profile}`;
|
|
175
|
+
io.info(`Saved ${profile} (${config.baseUrl ?? baseUrl}, ${role}): model ${config.model ?? 'none'}, key ${config.keyPreview ?? '…'} (${config.providerState}).`);
|
|
176
|
+
if (config.warning)
|
|
177
|
+
io.warn(config.warning);
|
|
178
|
+
const summary = `${profile} configured${config.active ? ' and active' : ''} (model ${config.model ?? 'none'}, ${config.providerState})`;
|
|
179
|
+
const wantsSmoke = await io.confirm('Ask one test question to confirm it works? (one billed decision)', true);
|
|
180
|
+
if (!wantsSmoke)
|
|
181
|
+
return { configured: true, summary, config };
|
|
182
|
+
const smoke = await (opts.smoke ??
|
|
183
|
+
(() => askDecideDebug({
|
|
184
|
+
state: DECIDE_SMOKE_STATE,
|
|
185
|
+
question: DECIDE_SMOKE_QUESTION,
|
|
186
|
+
profile,
|
|
187
|
+
...(opts.projectRoot ? { projectRoot: opts.projectRoot } : {}),
|
|
188
|
+
})))();
|
|
189
|
+
if (smoke.source === 'provider') {
|
|
190
|
+
io.info(`Smoke test answered by the provider in ${smoke.latencyMs} ms.`);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
io.warn(`Smoke test fell back to the heuristic (${smoke.fallbackReason ?? smoke.source}). Check \`cleo decide status\`.`);
|
|
194
|
+
}
|
|
195
|
+
return { configured: true, summary, config, smoke };
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=wizard.js.map
|