@cleocode/core 2026.9.23 → 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 +2 -2
- 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/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 +35 -1
- package/dist/decide/client.d.ts.map +1 -1
- package/dist/decide/client.js +124 -30
- package/dist/decide/client.js.map +1 -1
- package/dist/decide/credentials.d.ts +177 -17
- package/dist/decide/credentials.d.ts.map +1 -1
- package/dist/decide/credentials.js +505 -41
- package/dist/decide/credentials.js.map +1 -1
- package/dist/decide/index.d.ts +8 -8
- package/dist/decide/index.d.ts.map +1 -1
- package/dist/decide/index.js +8 -8
- package/dist/decide/index.js.map +1 -1
- package/dist/decide/jev-wire.d.ts +25 -19
- package/dist/decide/jev-wire.d.ts.map +1 -1
- package/dist/decide/jev-wire.js +56 -31
- package/dist/decide/jev-wire.js.map +1 -1
- package/dist/decide/operations.d.ts +63 -12
- package/dist/decide/operations.d.ts.map +1 -1
- package/dist/decide/operations.js +116 -58
- package/dist/decide/operations.js.map +1 -1
- package/dist/decide/provider-state.d.ts +85 -12
- package/dist/decide/provider-state.d.ts.map +1 -1
- package/dist/decide/provider-state.js +154 -21
- package/dist/decide/provider-state.js.map +1 -1
- package/dist/decide/provider.d.ts +5 -0
- package/dist/decide/provider.d.ts.map +1 -1
- package/dist/decide/provider.js.map +1 -1
- package/dist/decide/providers.d.ts +15 -2
- package/dist/decide/providers.d.ts.map +1 -1
- package/dist/decide/providers.js +22 -6
- package/dist/decide/providers.js.map +1 -1
- package/dist/decide/sites/registry.d.ts +22 -0
- package/dist/decide/sites/registry.d.ts.map +1 -1
- package/dist/decide/sites/registry.js +23 -0
- package/dist/decide/sites/registry.js.map +1 -1
- package/dist/decide/wizard.d.ts +12 -4
- package/dist/decide/wizard.d.ts.map +1 -1
- package/dist/decide/wizard.js +79 -26
- package/dist/decide/wizard.js.map +1 -1
- 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-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 +2928 -1053
- 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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.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 +5 -4
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +6 -4
- 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 +3017 -1142
- 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/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/learnings.d.ts +6 -6
- package/dist/memory/patterns.d.ts +4 -4
- 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/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/orchestrate/pivot.d.ts +4 -0
- package/dist/orchestrate/pivot.d.ts.map +1 -1
- package/dist/orchestrate/pivot.js +75 -12
- package/dist/orchestrate/pivot.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 +6 -3
- package/dist/orchestration/lead-rollup.js.map +1 -1
- package/dist/orchestration/spawn-prompt.js +1 -1
- package/dist/orchestration/spawn-prompt.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 +70 -3
- package/dist/project-scope.d.ts.map +1 -1
- package/dist/project-scope.js +154 -15
- package/dist/project-scope.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/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 +3027 -1152
- 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 +10 -10
- 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 +103 -26
- package/dist/sessions/focus-state-store.d.ts.map +1 -1
- package/dist/sessions/focus-state-store.js +166 -37
- 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.map +1 -1
- package/dist/setup/config-json-merge.js +1 -0
- package/dist/setup/config-json-merge.js.map +1 -1
- package/dist/setup/index.d.ts +4 -2
- package/dist/setup/index.d.ts.map +1 -1
- package/dist/setup/index.js +6 -2
- package/dist/setup/index.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/wizard.d.ts +1 -1
- package/dist/setup/wizard.d.ts.map +1 -1
- 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/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/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-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/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/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 +73 -18
- package/dist/store/credential-transfer.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/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/migration-manager.d.ts +61 -0
- package/dist/store/migration-manager.d.ts.map +1 -1
- package/dist/store/migration-manager.js +102 -4
- package/dist/store/migration-manager.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/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 +10 -0
- package/dist/store/portable-bundle-import.js.map +1 -1
- package/dist/store/portable-bundle-scan.d.ts.map +1 -1
- package/dist/store/portable-bundle-scan.js +1 -0
- 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/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/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +245 -47
- package/dist/store/sqlite-data-accessor.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 +52 -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 +13 -4
- package/dist/store/worktree-build-guard.d.ts.map +1 -1
- package/dist/store/worktree-build-guard.js +21 -10
- package/dist/store/worktree-build-guard.js.map +1 -1
- package/dist/store/worktree-isolation-guard.d.ts +121 -10
- package/dist/store/worktree-isolation-guard.d.ts.map +1 -1
- package/dist/store/worktree-isolation-guard.js +155 -34
- package/dist/store/worktree-isolation-guard.js.map +1 -1
- package/dist/system/backup.d.ts +7 -0
- package/dist/system/backup.d.ts.map +1 -1
- package/dist/system/backup.js +5 -0
- 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 +1 -1
- package/dist/task-tools/index.d.ts.map +1 -1
- package/dist/task-tools/index.js +1 -1
- package/dist/task-tools/index.js.map +1 -1
- package/dist/task-tools/score-task-priority.d.ts +38 -0
- package/dist/task-tools/score-task-priority.d.ts.map +1 -1
- package/dist/task-tools/score-task-priority.js +51 -0
- 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/analyze.d.ts.map +1 -1
- package/dist/tasks/analyze.js +3 -4
- package/dist/tasks/analyze.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 +59 -3
- package/dist/tasks/change-set.js.map +1 -1
- 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 +560 -59
- package/dist/tasks/component-pr.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 +20 -1
- package/dist/tasks/duplicate-detector.d.ts.map +1 -1
- package/dist/tasks/duplicate-detector.js +10 -2
- package/dist/tasks/duplicate-detector.js.map +1 -1
- package/dist/tasks/engine-wrap-ops.d.ts +19 -10
- package/dist/tasks/engine-wrap-ops.d.ts.map +1 -1
- package/dist/tasks/engine-wrap-ops.js +38 -10
- package/dist/tasks/engine-wrap-ops.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/plan.d.ts.map +1 -1
- package/dist/tasks/plan.js +16 -60
- package/dist/tasks/plan.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 +25 -2
- package/dist/tasks/task-next.d.ts.map +1 -1
- package/dist/tasks/task-next.js +32 -13
- package/dist/tasks/task-next.js.map +1 -1
- package/dist/tasks/update.d.ts.map +1 -1
- package/dist/tasks/update.js +7 -5
- package/dist/tasks/update.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 +51 -8
- 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 +23 -13
- package/schemas/project-info.schema.json +10 -4
- package/templates/CLEO-INJECTION.md +1 -1
- package/templates/CLEO-REFERENCE.md +3 -3
- package/templates/cleo-gitignore +11 -0
- package/templates/workflows/release-prepare.yml.tmpl +156 -10
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classification metrics for the System One benchmark (T12495).
|
|
3
|
+
*
|
|
4
|
+
* Two-label sites report precision, recall, F1 and false-positive rate for
|
|
5
|
+
* their positive class. The multi-class observation-type site reports macro
|
|
6
|
+
* averages over the labels present in the gold set (one-vs-rest per label).
|
|
7
|
+
*
|
|
8
|
+
* @task T12495
|
|
9
|
+
* @epic T12486
|
|
10
|
+
*/
|
|
11
|
+
import { percentile } from './stats.js';
|
|
12
|
+
/** Ratio, or `null` when the denominator is zero. */
|
|
13
|
+
function ratio(num, den) {
|
|
14
|
+
return den > 0 ? num / den : null;
|
|
15
|
+
}
|
|
16
|
+
/** Harmonic mean of precision and recall. */
|
|
17
|
+
function f1Of(p, r) {
|
|
18
|
+
if (p === null || r === null)
|
|
19
|
+
return null;
|
|
20
|
+
return p + r > 0 ? (2 * p * r) / (p + r) : 0;
|
|
21
|
+
}
|
|
22
|
+
/** One-vs-rest counts for `label`. */
|
|
23
|
+
function counts(preds, label) {
|
|
24
|
+
let tp = 0;
|
|
25
|
+
let fp = 0;
|
|
26
|
+
let fn = 0;
|
|
27
|
+
let tn = 0;
|
|
28
|
+
for (const p of preds) {
|
|
29
|
+
const g = p.gold === label;
|
|
30
|
+
const q = p.predicted === label;
|
|
31
|
+
if (g && q)
|
|
32
|
+
tp++;
|
|
33
|
+
else if (!g && q)
|
|
34
|
+
fp++;
|
|
35
|
+
else if (g && !q)
|
|
36
|
+
fn++;
|
|
37
|
+
else
|
|
38
|
+
tn++;
|
|
39
|
+
}
|
|
40
|
+
return { tp, fp, fn, tn };
|
|
41
|
+
}
|
|
42
|
+
/** Mean of the non-null values, or null. */
|
|
43
|
+
function meanOf(values) {
|
|
44
|
+
const xs = values.filter((v) => v !== null);
|
|
45
|
+
return xs.length > 0 ? xs.reduce((s, x) => s + x, 0) / xs.length : null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Score predictions.
|
|
49
|
+
*
|
|
50
|
+
* @param preds - Gold and predicted labels.
|
|
51
|
+
* @param positive - The positive class of a two-label site; `null` → macro averages.
|
|
52
|
+
* @returns The metrics (`null` where undefined, e.g. no positives predicted).
|
|
53
|
+
*/
|
|
54
|
+
export function classificationMetrics(preds, positive) {
|
|
55
|
+
const n = preds.length;
|
|
56
|
+
const accuracy = ratio(preds.filter((p) => p.gold === p.predicted).length, n);
|
|
57
|
+
if (positive !== null) {
|
|
58
|
+
const c = counts(preds, positive);
|
|
59
|
+
const precision = ratio(c.tp, c.tp + c.fp);
|
|
60
|
+
const recall = ratio(c.tp, c.tp + c.fn);
|
|
61
|
+
return {
|
|
62
|
+
n,
|
|
63
|
+
accuracy,
|
|
64
|
+
precision,
|
|
65
|
+
recall,
|
|
66
|
+
f1: f1Of(precision, recall),
|
|
67
|
+
falsePositiveRate: ratio(c.fp, c.fp + c.tn),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const labels = [...new Set(preds.map((p) => p.gold))].sort();
|
|
71
|
+
const per = labels.map((label) => {
|
|
72
|
+
const c = counts(preds, label);
|
|
73
|
+
const precision = ratio(c.tp, c.tp + c.fp) ?? 0;
|
|
74
|
+
const recall = ratio(c.tp, c.tp + c.fn);
|
|
75
|
+
return {
|
|
76
|
+
precision,
|
|
77
|
+
recall,
|
|
78
|
+
f1: f1Of(precision, recall),
|
|
79
|
+
fpr: ratio(c.fp, c.fp + c.tn),
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
n,
|
|
84
|
+
accuracy,
|
|
85
|
+
precision: meanOf(per.map((p) => p.precision)),
|
|
86
|
+
recall: meanOf(per.map((p) => p.recall)),
|
|
87
|
+
f1: meanOf(per.map((p) => p.f1)),
|
|
88
|
+
falsePositiveRate: meanOf(per.map((p) => p.fpr)),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Latency percentiles.
|
|
93
|
+
*
|
|
94
|
+
* @param samples - Latencies in ms.
|
|
95
|
+
* @returns p50 and p95 (nearest rank).
|
|
96
|
+
*/
|
|
97
|
+
export function latencyOf(samples) {
|
|
98
|
+
return { p50Ms: percentile(samples, 50), p95Ms: percentile(samples, 95) };
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/decide/bench/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA0BxC,qDAAqD;AACrD,SAAS,KAAK,CAAC,GAAW,EAAE,GAAW;IACrC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACpC,CAAC;A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E,EAAE,CAAC,EAAE,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cleo decide bench` as one core operation (T12495): build or reuse the
|
|
3
|
+
* dataset, apply owner corrections, draw the spot-check sample and — unless
|
|
4
|
+
* `sampleOnly` — run the providers and write the results and the report.
|
|
5
|
+
*
|
|
6
|
+
* Files, all in `outDir` (default `<projectRoot>/.cleo/decide-bench/`, which
|
|
7
|
+
* git ignores):
|
|
8
|
+
*
|
|
9
|
+
* - `dataset.jsonl` — the labelled, redacted rows. Reused on later calls so
|
|
10
|
+
* the owner's corrections stick; `rebuild` builds it again from the stores.
|
|
11
|
+
* - `spot-check.json` — the stratified sample for the owner.
|
|
12
|
+
* - `results.json` / `report.md` — written by a run.
|
|
13
|
+
*
|
|
14
|
+
* Dataset building, corrections and sampling never contact a provider.
|
|
15
|
+
*
|
|
16
|
+
* @task T12495
|
|
17
|
+
* @epic T12486
|
|
18
|
+
*/
|
|
19
|
+
import type { SpendLedger } from '../spend.js';
|
|
20
|
+
import type { DecideFetch } from '../transport.js';
|
|
21
|
+
import { type BenchDatasetSizes } from './dataset.js';
|
|
22
|
+
import { type BenchProfileResolver } from './profiles.js';
|
|
23
|
+
import { type BenchAggregateRow, type BenchSpendSummary } from './runner.js';
|
|
24
|
+
import { type BenchCorrectionsReceipt } from './spot-check.js';
|
|
25
|
+
import { type BenchConnection, type BenchSite, type BenchSource } from './types.js';
|
|
26
|
+
/** Dataset file name inside the output directory. */
|
|
27
|
+
export declare const BENCH_DATASET_FILE = "dataset.jsonl";
|
|
28
|
+
/** Spot-check file name inside the output directory. */
|
|
29
|
+
export declare const BENCH_SPOT_CHECK_FILE = "spot-check.json";
|
|
30
|
+
/** Results file name inside the output directory. */
|
|
31
|
+
export declare const BENCH_RESULTS_FILE = "results.json";
|
|
32
|
+
/** Report fragment file name inside the output directory. */
|
|
33
|
+
export declare const BENCH_REPORT_FILE = "report.md";
|
|
34
|
+
/** Invalid benchmark input (maps to a validation error in the CLI). */
|
|
35
|
+
export declare class DecideBenchInputError extends Error {
|
|
36
|
+
/** How to fix it. */
|
|
37
|
+
readonly fix: string;
|
|
38
|
+
/**
|
|
39
|
+
* @param message - What is wrong.
|
|
40
|
+
* @param fix - How to fix it.
|
|
41
|
+
*/
|
|
42
|
+
constructor(message: string, fix: string);
|
|
43
|
+
}
|
|
44
|
+
/** Input of {@link runDecideBenchOperation}. */
|
|
45
|
+
export interface DecideBenchInput {
|
|
46
|
+
/** Project whose stores are read. Default: the resolved project root. */
|
|
47
|
+
readonly projectRoot?: string;
|
|
48
|
+
/** Output directory. Default `<projectRoot>/.cleo/decide-bench`. */
|
|
49
|
+
readonly outDir?: string;
|
|
50
|
+
/** Profile names to compare (required unless `sampleOnly`). */
|
|
51
|
+
readonly profiles?: readonly string[];
|
|
52
|
+
/** Sites to sample and run. Default: all. */
|
|
53
|
+
readonly sites?: readonly string[];
|
|
54
|
+
/** Build the dataset and the sample only; no provider is contacted. */
|
|
55
|
+
readonly sampleOnly?: boolean;
|
|
56
|
+
/** Owner corrections file to apply before sampling. */
|
|
57
|
+
readonly correctionsPath?: string;
|
|
58
|
+
/** Hard total spend cap in US dollars. Default $5. */
|
|
59
|
+
readonly maxUsd?: number;
|
|
60
|
+
/** Repeated runs. Default 1. */
|
|
61
|
+
readonly runs?: number;
|
|
62
|
+
/** Rows per batch call. */
|
|
63
|
+
readonly batchSize?: number;
|
|
64
|
+
/** Rebuild the dataset from the stores even when one exists. */
|
|
65
|
+
readonly rebuild?: boolean;
|
|
66
|
+
/** PRNG seed for negatives and the sample. */
|
|
67
|
+
readonly seed?: number;
|
|
68
|
+
/** Spot-check sample size. Default 30. */
|
|
69
|
+
readonly sampleSize?: number;
|
|
70
|
+
/** Store port (tests). Default: the core accessors. */
|
|
71
|
+
readonly source?: BenchSource;
|
|
72
|
+
/** Profile resolver (tests; T12733 profiles later). Default: the interim adapter. */
|
|
73
|
+
readonly resolver?: BenchProfileResolver;
|
|
74
|
+
/** Explicit connections; skip profile resolution. */
|
|
75
|
+
readonly connections?: readonly BenchConnection[];
|
|
76
|
+
/** Transport (tests). */
|
|
77
|
+
readonly fetch?: DecideFetch;
|
|
78
|
+
/** Directory for per-connection provider-state files (tests). */
|
|
79
|
+
readonly providerStateDir?: string;
|
|
80
|
+
/** Monthly ledger to record spend in; `null` skips. Default: the file ledger. */
|
|
81
|
+
readonly spendLedger?: SpendLedger | null;
|
|
82
|
+
}
|
|
83
|
+
/** Output of {@link runDecideBenchOperation}. */
|
|
84
|
+
export interface DecideBenchSummary {
|
|
85
|
+
/** Output directory. */
|
|
86
|
+
readonly outDir: string;
|
|
87
|
+
/** Files written or reused. */
|
|
88
|
+
readonly files: {
|
|
89
|
+
readonly dataset: string;
|
|
90
|
+
readonly spotCheck: string;
|
|
91
|
+
readonly results?: string;
|
|
92
|
+
readonly report?: string;
|
|
93
|
+
};
|
|
94
|
+
/** Whether an existing dataset was reused. */
|
|
95
|
+
readonly datasetReused: boolean;
|
|
96
|
+
/** Dataset sizes (all sites). */
|
|
97
|
+
readonly dataset: BenchDatasetSizes;
|
|
98
|
+
/** Sites sampled and run. */
|
|
99
|
+
readonly sites: readonly BenchSite[];
|
|
100
|
+
/** Items in the spot-check sample. */
|
|
101
|
+
readonly spotCheckItems: number;
|
|
102
|
+
/** Applied corrections, when a file was given. */
|
|
103
|
+
readonly corrections?: BenchCorrectionsReceipt;
|
|
104
|
+
/** Whether providers were run. */
|
|
105
|
+
readonly ran: boolean;
|
|
106
|
+
/** Spend, when run. */
|
|
107
|
+
readonly spend?: BenchSpendSummary;
|
|
108
|
+
/** Mean and spread per provider × site, when run. */
|
|
109
|
+
readonly aggregate?: readonly BenchAggregateRow[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Run `cleo decide bench`.
|
|
113
|
+
*
|
|
114
|
+
* @param input - Flags and wiring.
|
|
115
|
+
* @returns What was written and, after a run, the spend and the aggregate.
|
|
116
|
+
* @throws DecideBenchInputError on invalid input (unknown site or profile, no profiles).
|
|
117
|
+
*/
|
|
118
|
+
export declare function runDecideBenchOperation(input?: DecideBenchInput): Promise<DecideBenchSummary>;
|
|
119
|
+
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/decide/bench/operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EACL,KAAK,iBAAiB,EAKvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,oBAAoB,EAAwB,MAAM,eAAe,CAAC;AAEhF,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAGvB,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,uBAAuB,EAG7B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAe,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjG,qDAAqD;AACrD,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD,wDAAwD;AACxD,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,qDAAqD;AACrD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,6DAA6D;AAC7D,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAE7C,uEAAuE;AACvE,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,qBAAqB;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAKzC;AAED,gDAAgD;AAChD,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,WAAW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wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,8CAA8C;IAC9C,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IACrC,sCAAsC;IACtC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,kDAAkD;IAClD,QAAQ,CAAC,WAAW,CAAC,EAAE,uBAAuB,CAAC;IAC/C,kCAAkC;IAClC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,uBAAuB;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IACnC,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACnD;AAyBD;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,GAAE,gBAAqB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CAgG7B"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cleo decide bench` as one core operation (T12495): build or reuse the
|
|
3
|
+
* dataset, apply owner corrections, draw the spot-check sample and — unless
|
|
4
|
+
* `sampleOnly` — run the providers and write the results and the report.
|
|
5
|
+
*
|
|
6
|
+
* Files, all in `outDir` (default `<projectRoot>/.cleo/decide-bench/`, which
|
|
7
|
+
* git ignores):
|
|
8
|
+
*
|
|
9
|
+
* - `dataset.jsonl` — the labelled, redacted rows. Reused on later calls so
|
|
10
|
+
* the owner's corrections stick; `rebuild` builds it again from the stores.
|
|
11
|
+
* - `spot-check.json` — the stratified sample for the owner.
|
|
12
|
+
* - `results.json` / `report.md` — written by a run.
|
|
13
|
+
*
|
|
14
|
+
* Dataset building, corrections and sampling never contact a provider.
|
|
15
|
+
*
|
|
16
|
+
* @task T12495
|
|
17
|
+
* @epic T12486
|
|
18
|
+
*/
|
|
19
|
+
import { existsSync } from 'node:fs';
|
|
20
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
21
|
+
import { join, resolve } from 'node:path';
|
|
22
|
+
import { getProjectRoot } from '../../paths.js';
|
|
23
|
+
import { benchDatasetSizes, buildBenchDataset, readBenchDataset, writeBenchDataset, } from './dataset.js';
|
|
24
|
+
import { resolveBenchProfiles } from './profiles.js';
|
|
25
|
+
import { renderBenchReport } from './report.js';
|
|
26
|
+
import { DEFAULT_BENCH_MAX_MICROS, runDecideBench, } from './runner.js';
|
|
27
|
+
import { createStoreBenchSource } from './source.js';
|
|
28
|
+
import { applyBenchCorrections, readBenchCorrections, sampleBenchSpotCheck, } from './spot-check.js';
|
|
29
|
+
import { DEFAULT_BENCH_SEED } from './stats.js';
|
|
30
|
+
import { BENCH_SITES } from './types.js';
|
|
31
|
+
/** Dataset file name inside the output directory. */
|
|
32
|
+
export const BENCH_DATASET_FILE = 'dataset.jsonl';
|
|
33
|
+
/** Spot-check file name inside the output directory. */
|
|
34
|
+
export const BENCH_SPOT_CHECK_FILE = 'spot-check.json';
|
|
35
|
+
/** Results file name inside the output directory. */
|
|
36
|
+
export const BENCH_RESULTS_FILE = 'results.json';
|
|
37
|
+
/** Report fragment file name inside the output directory. */
|
|
38
|
+
export const BENCH_REPORT_FILE = 'report.md';
|
|
39
|
+
/** Invalid benchmark input (maps to a validation error in the CLI). */
|
|
40
|
+
export class DecideBenchInputError extends Error {
|
|
41
|
+
/** How to fix it. */
|
|
42
|
+
fix;
|
|
43
|
+
/**
|
|
44
|
+
* @param message - What is wrong.
|
|
45
|
+
* @param fix - How to fix it.
|
|
46
|
+
*/
|
|
47
|
+
constructor(message, fix) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = 'DecideBenchInputError';
|
|
50
|
+
this.fix = fix;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Narrow the requested sites. */
|
|
54
|
+
function parseSites(sites) {
|
|
55
|
+
if (!sites || sites.length === 0)
|
|
56
|
+
return [...BENCH_SITES];
|
|
57
|
+
const out = [];
|
|
58
|
+
for (const s of sites) {
|
|
59
|
+
const site = BENCH_SITES.find((b) => b === s.trim());
|
|
60
|
+
if (!site) {
|
|
61
|
+
throw new DecideBenchInputError(`unknown site '${s}'`, `--sites ${BENCH_SITES.join(',')}`);
|
|
62
|
+
}
|
|
63
|
+
if (!out.includes(site))
|
|
64
|
+
out.push(site);
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/** Validate a positive number flag. */
|
|
69
|
+
function positive(value, name, fallback) {
|
|
70
|
+
if (value === undefined)
|
|
71
|
+
return fallback;
|
|
72
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
73
|
+
throw new DecideBenchInputError(`${name} must be a positive number`, `${name} <n>`);
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Run `cleo decide bench`.
|
|
79
|
+
*
|
|
80
|
+
* @param input - Flags and wiring.
|
|
81
|
+
* @returns What was written and, after a run, the spend and the aggregate.
|
|
82
|
+
* @throws DecideBenchInputError on invalid input (unknown site or profile, no profiles).
|
|
83
|
+
*/
|
|
84
|
+
export async function runDecideBenchOperation(input = {}) {
|
|
85
|
+
const sites = parseSites(input.sites);
|
|
86
|
+
const maxUsd = positive(input.maxUsd, '--max-usd', DEFAULT_BENCH_MAX_MICROS / 1e6);
|
|
87
|
+
const runs = Math.floor(positive(input.runs, '--runs', 1));
|
|
88
|
+
const batchSize = input.batchSize === undefined
|
|
89
|
+
? undefined
|
|
90
|
+
: Math.floor(positive(input.batchSize, '--batch-size', 1));
|
|
91
|
+
const seed = input.seed ?? DEFAULT_BENCH_SEED;
|
|
92
|
+
if (!Number.isSafeInteger(seed)) {
|
|
93
|
+
throw new DecideBenchInputError('--seed must be an integer', '--seed 12495');
|
|
94
|
+
}
|
|
95
|
+
const wantsRun = input.sampleOnly !== true;
|
|
96
|
+
const profiles = input.profiles ?? [];
|
|
97
|
+
if (wantsRun && profiles.length === 0 && !input.connections?.length) {
|
|
98
|
+
throw new DecideBenchInputError('no providers to compare', 'cleo decide bench --profiles layahost,jev (or --sample-only to build the dataset and sample without spend)');
|
|
99
|
+
}
|
|
100
|
+
// Resolve profiles before any file is written, so a typo fails fast.
|
|
101
|
+
let connections = input.connections ?? [];
|
|
102
|
+
if (wantsRun && connections.length === 0) {
|
|
103
|
+
try {
|
|
104
|
+
connections = resolveBenchProfiles(profiles, input.resolver);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
throw new DecideBenchInputError(err instanceof Error ? err.message : 'profile resolution failed', 'CLEO_DECIDE_PROFILE_<NAME>_KEY=… (and _URL to override the preset URL)');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const projectRoot = input.projectRoot ?? getProjectRoot();
|
|
111
|
+
const outDir = resolve(input.outDir ?? join(projectRoot, '.cleo', 'decide-bench'));
|
|
112
|
+
await mkdir(outDir, { recursive: true, mode: 0o700 });
|
|
113
|
+
const datasetPath = join(outDir, BENCH_DATASET_FILE);
|
|
114
|
+
const spotCheckPath = join(outDir, BENCH_SPOT_CHECK_FILE);
|
|
115
|
+
const reuse = input.rebuild !== true && existsSync(datasetPath);
|
|
116
|
+
let rows = reuse
|
|
117
|
+
? await readBenchDataset(datasetPath)
|
|
118
|
+
: await buildBenchDataset(input.source ?? createStoreBenchSource(projectRoot), { seed });
|
|
119
|
+
let corrections;
|
|
120
|
+
if (input.correctionsPath) {
|
|
121
|
+
const applied = applyBenchCorrections(rows, await readBenchCorrections(input.correctionsPath));
|
|
122
|
+
rows = applied.rows;
|
|
123
|
+
corrections = applied.receipt;
|
|
124
|
+
}
|
|
125
|
+
if (!reuse || corrections)
|
|
126
|
+
await writeBenchDataset(datasetPath, rows);
|
|
127
|
+
const selected = rows.filter((r) => sites.includes(r.site));
|
|
128
|
+
const spotCheck = sampleBenchSpotCheck(selected, {
|
|
129
|
+
seed,
|
|
130
|
+
...(input.sampleSize !== undefined ? { size: input.sampleSize } : {}),
|
|
131
|
+
});
|
|
132
|
+
await writeFile(spotCheckPath, `${JSON.stringify(spotCheck, null, 2)}\n`, { mode: 0o600 });
|
|
133
|
+
const base = {
|
|
134
|
+
outDir,
|
|
135
|
+
datasetReused: reuse,
|
|
136
|
+
dataset: benchDatasetSizes(rows),
|
|
137
|
+
sites,
|
|
138
|
+
spotCheckItems: spotCheck.items.length,
|
|
139
|
+
...(corrections ? { corrections } : {}),
|
|
140
|
+
};
|
|
141
|
+
if (!wantsRun) {
|
|
142
|
+
return { ...base, files: { dataset: datasetPath, spotCheck: spotCheckPath }, ran: false };
|
|
143
|
+
}
|
|
144
|
+
const results = await runDecideBench({
|
|
145
|
+
rows: selected,
|
|
146
|
+
connections,
|
|
147
|
+
runs,
|
|
148
|
+
maxMicros: Math.round(maxUsd * 1e6),
|
|
149
|
+
...(batchSize !== undefined ? { batchSize } : {}),
|
|
150
|
+
...(input.fetch ? { fetch: input.fetch } : {}),
|
|
151
|
+
...(input.providerStateDir ? { providerStateDir: input.providerStateDir } : {}),
|
|
152
|
+
...(input.spendLedger !== undefined ? { spendLedger: input.spendLedger } : {}),
|
|
153
|
+
});
|
|
154
|
+
const resultsPath = join(outDir, BENCH_RESULTS_FILE);
|
|
155
|
+
const reportPath = join(outDir, BENCH_REPORT_FILE);
|
|
156
|
+
await writeFile(resultsPath, `${JSON.stringify(results, null, 2)}\n`, { mode: 0o600 });
|
|
157
|
+
await writeFile(reportPath, renderBenchReport(results), { mode: 0o600 });
|
|
158
|
+
return {
|
|
159
|
+
...base,
|
|
160
|
+
files: {
|
|
161
|
+
dataset: datasetPath,
|
|
162
|
+
spotCheck: spotCheckPath,
|
|
163
|
+
results: resultsPath,
|
|
164
|
+
report: reportPath,
|
|
165
|
+
},
|
|
166
|
+
ran: true,
|
|
167
|
+
spend: results.spend,
|
|
168
|
+
aggregate: results.aggregate,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../src/decide/bench/operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAEL,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA6B,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAGL,wBAAwB,EACxB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,qBAAqB,EAErB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,WAAW,EAA0D,MAAM,YAAY,CAAC;AAEjG,qDAAqD;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAElD,wDAAw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;IACzE,OAAO;QACL,GAAG,IAAI;QACP,KAAK,EAAE;YACL,OAAO,EAAE,WAAW;YACpB,SAAS,EAAE,aAAa;YACxB,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,UAAU;SACnB;QACD,GAAG,EAAE,IAAI;QACT,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve `--profiles a,b` to benchmark connections (T12495).
|
|
3
|
+
*
|
|
4
|
+
* Named decide profiles are being built in core by T12733, which will export
|
|
5
|
+
* `resolveDecideProfile(name)` and `listDecideProfiles()`. Until it lands,
|
|
6
|
+
* the benchmark resolves names through this small adapter, behind the
|
|
7
|
+
* {@link BenchProfileResolver} interface so the switch is one function:
|
|
8
|
+
*
|
|
9
|
+
* 1. `CLEO_DECIDE_PROFILE_<NAME>_KEY` (plus `_URL`, `_MODEL`, `_PROVIDER`) in
|
|
10
|
+
* the environment — `<NAME>` upper-cased, non-alphanumerics as `_`. A
|
|
11
|
+
* profile whose provider has a preset URL (layahost, jev) needs only the
|
|
12
|
+
* key; `_URL` overrides the preset.
|
|
13
|
+
* 2. Otherwise, a name equal to the stored connection's provider kind
|
|
14
|
+
* (`cleo decide config`), or `default`, resolves to the stored connection.
|
|
15
|
+
*
|
|
16
|
+
* @task T12495
|
|
17
|
+
* @epic T12486
|
|
18
|
+
*/
|
|
19
|
+
import { loadDecideConnection } from '../credentials.js';
|
|
20
|
+
import type { BenchConnection } from './types.js';
|
|
21
|
+
/** Resolves one profile name to a connection. */
|
|
22
|
+
export interface BenchProfileResolver {
|
|
23
|
+
/**
|
|
24
|
+
* @param name - Profile name.
|
|
25
|
+
* @returns The connection, or `null` when no profile has that name.
|
|
26
|
+
* @throws BenchProfileInvalidError when the profile exists but is misconfigured.
|
|
27
|
+
*/
|
|
28
|
+
resolve(name: string): BenchConnection | null;
|
|
29
|
+
}
|
|
30
|
+
/** A profile name that resolved to nothing. */
|
|
31
|
+
export declare class BenchProfileError extends Error {
|
|
32
|
+
/** The names that did not resolve. */
|
|
33
|
+
readonly missing: readonly string[];
|
|
34
|
+
/**
|
|
35
|
+
* @param missing - Unresolved names.
|
|
36
|
+
*/
|
|
37
|
+
constructor(missing: readonly string[]);
|
|
38
|
+
}
|
|
39
|
+
/** A profile that exists but is misconfigured (bad URL or model). */
|
|
40
|
+
export declare class BenchProfileInvalidError extends Error {
|
|
41
|
+
/** The profile name. */
|
|
42
|
+
readonly profile: string;
|
|
43
|
+
/**
|
|
44
|
+
* @param profile - Profile name.
|
|
45
|
+
* @param problem - What is wrong, e.g. `invalid URL "…"`.
|
|
46
|
+
*/
|
|
47
|
+
constructor(profile: string, problem: string);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Environment variable prefix for one profile.
|
|
51
|
+
*
|
|
52
|
+
* @param name - Profile name.
|
|
53
|
+
* @returns `CLEO_DECIDE_PROFILE_<NAME>` (upper-cased, non-alphanumerics as `_`).
|
|
54
|
+
*/
|
|
55
|
+
export declare function benchProfileEnvPrefix(name: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* The interim resolver (environment, then the stored connection).
|
|
58
|
+
*
|
|
59
|
+
* @param env - Environment to read. Default `process.env`.
|
|
60
|
+
* @param stored - Stored-connection loader. Default `loadDecideConnection`.
|
|
61
|
+
* @returns A resolver.
|
|
62
|
+
*/
|
|
63
|
+
export declare function createInterimProfileResolver(env?: NodeJS.ProcessEnv, stored?: typeof loadDecideConnection): BenchProfileResolver;
|
|
64
|
+
/**
|
|
65
|
+
* Resolve every name, or throw naming all that did not resolve.
|
|
66
|
+
*
|
|
67
|
+
* @param names - Profile names (duplicates removed, order kept).
|
|
68
|
+
* @param resolver - Resolver. Default: {@link createInterimProfileResolver}.
|
|
69
|
+
* @returns One connection per name.
|
|
70
|
+
* @throws BenchProfileError when any name is unknown.
|
|
71
|
+
* @throws BenchProfileInvalidError when a profile has a bad URL or model.
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveBenchProfiles(names: readonly string[], resolver?: BenchProfileResolver): BenchConnection[];
|
|
74
|
+
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../src/decide/bench/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAA0B,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,iDAAiD;AACjD,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC;CAC/C;AAED,+CAA+C;AAC/C,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAEpC;;OAEG;gBACS,OAAO,EAAE,SAAS,MAAM,EAAE;CAOvC;AAED,qEAAqE;AACrE,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,wBAAwB;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK7C;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,MAAM,GAAE,OAAO,oBAA2C,GACzD,oBAAoB,CA2CtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,GAAE,oBAAqD,GAC9D,eAAe,EAAE,CAWnB"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve `--profiles a,b` to benchmark connections (T12495).
|
|
3
|
+
*
|
|
4
|
+
* Named decide profiles are being built in core by T12733, which will export
|
|
5
|
+
* `resolveDecideProfile(name)` and `listDecideProfiles()`. Until it lands,
|
|
6
|
+
* the benchmark resolves names through this small adapter, behind the
|
|
7
|
+
* {@link BenchProfileResolver} interface so the switch is one function:
|
|
8
|
+
*
|
|
9
|
+
* 1. `CLEO_DECIDE_PROFILE_<NAME>_KEY` (plus `_URL`, `_MODEL`, `_PROVIDER`) in
|
|
10
|
+
* the environment — `<NAME>` upper-cased, non-alphanumerics as `_`. A
|
|
11
|
+
* profile whose provider has a preset URL (layahost, jev) needs only the
|
|
12
|
+
* key; `_URL` overrides the preset.
|
|
13
|
+
* 2. Otherwise, a name equal to the stored connection's provider kind
|
|
14
|
+
* (`cleo decide config`), or `default`, resolves to the stored connection.
|
|
15
|
+
*
|
|
16
|
+
* @task T12495
|
|
17
|
+
* @epic T12486
|
|
18
|
+
*/
|
|
19
|
+
import { DECISION_PROVIDER_KINDS } from '@cleocode/contracts';
|
|
20
|
+
import { isAllowedDecideBaseUrl, loadDecideConnection } from '../credentials.js';
|
|
21
|
+
import { isValidDecisionModelName } from '../jev-wire.js';
|
|
22
|
+
import { DECISION_PROVIDER_PRESETS, parseDecisionProviderKind } from '../providers.js';
|
|
23
|
+
/** A profile name that resolved to nothing. */
|
|
24
|
+
export class BenchProfileError extends Error {
|
|
25
|
+
/** The names that did not resolve. */
|
|
26
|
+
missing;
|
|
27
|
+
/**
|
|
28
|
+
* @param missing - Unresolved names.
|
|
29
|
+
*/
|
|
30
|
+
constructor(missing) {
|
|
31
|
+
super(`unknown decide profile(s): ${missing.join(', ')}. Set CLEO_DECIDE_PROFILE_<NAME>_KEY (and _URL to override the provider's preset URL), or store one with cleo decide config and name its provider kind.`);
|
|
32
|
+
this.name = 'BenchProfileError';
|
|
33
|
+
this.missing = missing;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** A profile that exists but is misconfigured (bad URL or model). */
|
|
37
|
+
export class BenchProfileInvalidError extends Error {
|
|
38
|
+
/** The profile name. */
|
|
39
|
+
profile;
|
|
40
|
+
/**
|
|
41
|
+
* @param profile - Profile name.
|
|
42
|
+
* @param problem - What is wrong, e.g. `invalid URL "…"`.
|
|
43
|
+
*/
|
|
44
|
+
constructor(profile, problem) {
|
|
45
|
+
super(`decide profile '${profile}': ${problem}`);
|
|
46
|
+
this.name = 'BenchProfileInvalidError';
|
|
47
|
+
this.profile = profile;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Environment variable prefix for one profile.
|
|
52
|
+
*
|
|
53
|
+
* @param name - Profile name.
|
|
54
|
+
* @returns `CLEO_DECIDE_PROFILE_<NAME>` (upper-cased, non-alphanumerics as `_`).
|
|
55
|
+
*/
|
|
56
|
+
export function benchProfileEnvPrefix(name) {
|
|
57
|
+
return `CLEO_DECIDE_PROFILE_${name.toUpperCase().replace(/[^A-Z0-9]/g, '_')}`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The interim resolver (environment, then the stored connection).
|
|
61
|
+
*
|
|
62
|
+
* @param env - Environment to read. Default `process.env`.
|
|
63
|
+
* @param stored - Stored-connection loader. Default `loadDecideConnection`.
|
|
64
|
+
* @returns A resolver.
|
|
65
|
+
*/
|
|
66
|
+
export function createInterimProfileResolver(env = process.env, stored = loadDecideConnection) {
|
|
67
|
+
return {
|
|
68
|
+
resolve(name) {
|
|
69
|
+
const prefix = benchProfileEnvPrefix(name);
|
|
70
|
+
const key = env[`${prefix}_KEY`]?.trim();
|
|
71
|
+
if (key) {
|
|
72
|
+
const kind = parseDecisionProviderKind(env[`${prefix}_PROVIDER`]) ??
|
|
73
|
+
parseDecisionProviderKind(name) ??
|
|
74
|
+
'jev';
|
|
75
|
+
const preset = DECISION_PROVIDER_PRESETS[kind];
|
|
76
|
+
const baseUrl = env[`${prefix}_URL`]?.trim() || preset.defaultBaseUrl;
|
|
77
|
+
if (!baseUrl) {
|
|
78
|
+
throw new BenchProfileInvalidError(name, `no URL (set ${prefix}_URL)`);
|
|
79
|
+
}
|
|
80
|
+
if (!isAllowedDecideBaseUrl(baseUrl)) {
|
|
81
|
+
throw new BenchProfileInvalidError(name, `invalid URL in ${prefix}_URL (https://, or http:// to a loopback host)`);
|
|
82
|
+
}
|
|
83
|
+
const model = env[`${prefix}_MODEL`]?.trim() || preset.defaultModel;
|
|
84
|
+
if (model !== undefined && !isValidDecisionModelName(model)) {
|
|
85
|
+
throw new BenchProfileInvalidError(name, `invalid model name in ${prefix}_MODEL`);
|
|
86
|
+
}
|
|
87
|
+
return { name, provider: kind, baseUrl, apiKey: key, ...(model ? { model } : {}) };
|
|
88
|
+
}
|
|
89
|
+
const sealed = stored();
|
|
90
|
+
if (!sealed)
|
|
91
|
+
return null;
|
|
92
|
+
const matches = name === 'default' ||
|
|
93
|
+
(DECISION_PROVIDER_KINDS.some((k) => k === name) && sealed.provider === name);
|
|
94
|
+
if (!matches)
|
|
95
|
+
return null;
|
|
96
|
+
const c = sealed.connection();
|
|
97
|
+
return {
|
|
98
|
+
name,
|
|
99
|
+
provider: sealed.provider,
|
|
100
|
+
baseUrl: c.baseUrl,
|
|
101
|
+
apiKey: c.apiKey,
|
|
102
|
+
...(c.model ? { model: c.model } : {}),
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Resolve every name, or throw naming all that did not resolve.
|
|
109
|
+
*
|
|
110
|
+
* @param names - Profile names (duplicates removed, order kept).
|
|
111
|
+
* @param resolver - Resolver. Default: {@link createInterimProfileResolver}.
|
|
112
|
+
* @returns One connection per name.
|
|
113
|
+
* @throws BenchProfileError when any name is unknown.
|
|
114
|
+
* @throws BenchProfileInvalidError when a profile has a bad URL or model.
|
|
115
|
+
*/
|
|
116
|
+
export function resolveBenchProfiles(names, resolver = createInterimProfileResolver()) {
|
|
117
|
+
const unique = [...new Set(names.map((n) => n.trim()).filter((n) => n !== ''))];
|
|
118
|
+
const out = [];
|
|
119
|
+
const missing = [];
|
|
120
|
+
for (const name of unique) {
|
|
121
|
+
const c = resolver.resolve(name);
|
|
122
|
+
if (c)
|
|
123
|
+
out.push(c);
|
|
124
|
+
else
|
|
125
|
+
missing.push(name);
|
|
126
|
+
}
|
|
127
|
+
if (missing.length > 0)
|
|
128
|
+
throw new BenchProfileError(missing);
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=profiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../../src/decide/bench/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAavF,+CAA+C;AAC/C,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,sCAAsC;IAC7B,OAAO,CAAoB;IAEpC;;OAEG;IACH,YAAY,OAA0B;QACpC,KAAK,CACH,8BAA8B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,yJAAyJ,CAC1M,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,qEAAqE;AACrE,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,wBAAwB;IACf,OAAO,CAAS;IAEzB;;;OAGG;IACH,YAAY,OAAe,EAAE,OAAe;QAC1C,KAAK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