modelrig 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -0
- package/LICENSE +201 -0
- package/README.md +145 -8
- package/data/PROVENANCE.md +19 -0
- package/data/pricing-manual.json +22 -0
- package/data/pricing-map.json +46362 -0
- package/data/pricing-overlay.json +419 -0
- package/dist/adapters/anthropic.d.ts +90 -0
- package/dist/adapters/anthropic.d.ts.map +1 -0
- package/dist/adapters/anthropic.js +296 -0
- package/dist/adapters/build-adapters.d.ts +11 -0
- package/dist/adapters/build-adapters.d.ts.map +1 -0
- package/dist/adapters/build-adapters.js +45 -0
- package/dist/adapters/deepseek.d.ts +47 -0
- package/dist/adapters/deepseek.d.ts.map +1 -0
- package/dist/adapters/deepseek.js +216 -0
- package/dist/adapters/gemini.d.ts +44 -0
- package/dist/adapters/gemini.d.ts.map +1 -0
- package/dist/adapters/gemini.js +262 -0
- package/dist/adapters/grok.d.ts +53 -0
- package/dist/adapters/grok.d.ts.map +1 -0
- package/dist/adapters/grok.js +232 -0
- package/dist/adapters/openai-compat.d.ts +80 -0
- package/dist/adapters/openai-compat.d.ts.map +1 -0
- package/dist/adapters/openai-compat.js +244 -0
- package/dist/adapters/openai-stream.d.ts +58 -0
- package/dist/adapters/openai-stream.d.ts.map +1 -0
- package/dist/adapters/openai-stream.js +120 -0
- package/dist/adapters/openai.d.ts +55 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/adapters/openai.js +281 -0
- package/dist/adapters/sampling.d.ts +28 -0
- package/dist/adapters/sampling.d.ts.map +1 -0
- package/dist/adapters/sampling.js +34 -0
- package/dist/adapters/tool-mapping.d.ts +92 -0
- package/dist/adapters/tool-mapping.d.ts.map +1 -0
- package/dist/adapters/tool-mapping.js +143 -0
- package/dist/artifacts/artifact.d.ts +137 -0
- package/dist/artifacts/artifact.d.ts.map +1 -0
- package/dist/artifacts/artifact.js +377 -0
- package/dist/artifacts/content-uploader.d.ts +87 -0
- package/dist/artifacts/content-uploader.d.ts.map +1 -0
- package/dist/artifacts/content-uploader.js +124 -0
- package/dist/artifacts/index.d.ts +63 -0
- package/dist/artifacts/index.d.ts.map +1 -0
- package/dist/artifacts/index.js +80 -0
- package/dist/artifacts/run-context.d.ts +129 -0
- package/dist/artifacts/run-context.d.ts.map +1 -0
- package/dist/artifacts/run-context.js +208 -0
- package/dist/artifacts/scrub.d.ts +60 -0
- package/dist/artifacts/scrub.d.ts.map +1 -0
- package/dist/artifacts/scrub.js +139 -0
- package/dist/artifacts/step.d.ts +26 -0
- package/dist/artifacts/step.d.ts.map +1 -0
- package/dist/artifacts/step.js +37 -0
- package/dist/artifacts/taint.d.ts +63 -0
- package/dist/artifacts/taint.d.ts.map +1 -0
- package/dist/artifacts/taint.js +76 -0
- package/dist/bakeoff/cache-sim.d.ts +99 -0
- package/dist/bakeoff/cache-sim.d.ts.map +1 -0
- package/dist/bakeoff/cache-sim.js +126 -0
- package/dist/bakeoff/engine.d.ts +52 -0
- package/dist/bakeoff/engine.d.ts.map +1 -0
- package/dist/bakeoff/engine.js +163 -0
- package/dist/bakeoff/eval-cases.d.ts +96 -0
- package/dist/bakeoff/eval-cases.d.ts.map +1 -0
- package/dist/bakeoff/eval-cases.js +105 -0
- package/dist/bakeoff/replay.d.ts +52 -0
- package/dist/bakeoff/replay.d.ts.map +1 -0
- package/dist/bakeoff/replay.js +94 -0
- package/dist/bakeoff/report.d.ts +41 -0
- package/dist/bakeoff/report.d.ts.map +1 -0
- package/dist/bakeoff/report.js +142 -0
- package/dist/bakeoff/samples.d.ts +77 -0
- package/dist/bakeoff/samples.d.ts.map +1 -0
- package/dist/bakeoff/samples.js +148 -0
- package/dist/bakeoff/stats.d.ts +13 -0
- package/dist/bakeoff/stats.d.ts.map +1 -0
- package/dist/bakeoff/stats.js +48 -0
- package/dist/bakeoff/types.d.ts +37 -0
- package/dist/bakeoff/types.d.ts.map +1 -0
- package/dist/bakeoff/types.js +10 -0
- package/dist/cli.d.ts +25 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +590 -0
- package/dist/config.d.ts +204 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +252 -0
- package/dist/deprecations.d.ts +32 -0
- package/dist/deprecations.d.ts.map +1 -0
- package/dist/deprecations.js +59 -0
- package/dist/feedback/coverage.d.ts +32 -0
- package/dist/feedback/coverage.d.ts.map +1 -0
- package/dist/feedback/coverage.js +95 -0
- package/dist/feedback/feedback.d.ts +35 -0
- package/dist/feedback/feedback.d.ts.map +1 -0
- package/dist/feedback/feedback.js +39 -0
- package/dist/gateway/http-protocol.d.ts +175 -0
- package/dist/gateway/http-protocol.d.ts.map +1 -0
- package/dist/gateway/http-protocol.js +105 -0
- package/dist/index.d.ts +242 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +576 -0
- package/dist/init/finder.d.ts +94 -0
- package/dist/init/finder.d.ts.map +1 -0
- package/dist/init/finder.js +343 -0
- package/dist/init/init-cli.d.ts +10 -0
- package/dist/init/init-cli.d.ts.map +1 -0
- package/dist/init/init-cli.js +86 -0
- package/dist/init/observe-cli.d.ts +19 -0
- package/dist/init/observe-cli.d.ts.map +1 -0
- package/dist/init/observe-cli.js +73 -0
- package/dist/init/observe.d.ts +81 -0
- package/dist/init/observe.d.ts.map +1 -0
- package/dist/init/observe.js +245 -0
- package/dist/init/run.d.ts +99 -0
- package/dist/init/run.d.ts.map +1 -0
- package/dist/init/run.js +281 -0
- package/dist/init/signatures.d.ts +39 -0
- package/dist/init/signatures.d.ts.map +1 -0
- package/dist/init/signatures.js +116 -0
- package/dist/matrix/aggregate.d.ts +89 -0
- package/dist/matrix/aggregate.d.ts.map +1 -0
- package/dist/matrix/aggregate.js +186 -0
- package/dist/query/grammar.d.ts +35 -0
- package/dist/query/grammar.d.ts.map +1 -0
- package/dist/query/grammar.js +279 -0
- package/dist/query/run.d.ts +8 -0
- package/dist/query/run.d.ts.map +1 -0
- package/dist/query/run.js +21 -0
- package/dist/registry/build.d.ts +219 -0
- package/dist/registry/build.d.ts.map +1 -0
- package/dist/registry/build.js +313 -0
- package/dist/registry/cache-policy.d.ts +94 -0
- package/dist/registry/cache-policy.d.ts.map +1 -0
- package/dist/registry/cache-policy.js +238 -0
- package/dist/registry/call-notes.d.ts +11 -0
- package/dist/registry/call-notes.d.ts.map +1 -0
- package/dist/registry/call-notes.js +110 -0
- package/dist/registry/claims.d.ts +63 -0
- package/dist/registry/claims.d.ts.map +1 -0
- package/dist/registry/claims.js +107 -0
- package/dist/registry/effective-rate.d.ts +151 -0
- package/dist/registry/effective-rate.d.ts.map +1 -0
- package/dist/registry/effective-rate.js +156 -0
- package/dist/registry/facts.d.ts +32 -0
- package/dist/registry/facts.d.ts.map +1 -0
- package/dist/registry/facts.js +136 -0
- package/dist/registry/fingerprint.d.ts +20 -0
- package/dist/registry/fingerprint.d.ts.map +1 -0
- package/dist/registry/fingerprint.js +150 -0
- package/dist/registry/parity.d.ts +52 -0
- package/dist/registry/parity.d.ts.map +1 -0
- package/dist/registry/parity.js +82 -0
- package/dist/registry/pricing-shape.d.ts +113 -0
- package/dist/registry/pricing-shape.d.ts.map +1 -0
- package/dist/registry/pricing-shape.js +123 -0
- package/dist/registry/pricing.d.ts +43 -0
- package/dist/registry/pricing.d.ts.map +1 -0
- package/dist/registry/pricing.js +127 -0
- package/dist/registry/rows.d.ts +16 -0
- package/dist/registry/rows.d.ts.map +1 -0
- package/dist/registry/rows.js +57 -0
- package/dist/registry/seed.d.ts +43 -0
- package/dist/registry/seed.d.ts.map +1 -0
- package/dist/registry/seed.js +97 -0
- package/dist/registry/select.d.ts +68 -0
- package/dist/registry/select.d.ts.map +1 -0
- package/dist/registry/select.js +141 -0
- package/dist/registry/staleness.d.ts +18 -0
- package/dist/registry/staleness.d.ts.map +1 -0
- package/dist/registry/staleness.js +39 -0
- package/dist/rigindex/bootstrap.d.ts +36 -0
- package/dist/rigindex/bootstrap.d.ts.map +1 -0
- package/dist/rigindex/bootstrap.js +97 -0
- package/dist/rigindex/fit.d.ts +24 -0
- package/dist/rigindex/fit.d.ts.map +1 -0
- package/dist/rigindex/fit.js +76 -0
- package/dist/rigindex/gates.d.ts +52 -0
- package/dist/rigindex/gates.d.ts.map +1 -0
- package/dist/rigindex/gates.js +109 -0
- package/dist/rigindex/graph.d.ts +31 -0
- package/dist/rigindex/graph.d.ts.map +1 -0
- package/dist/rigindex/graph.js +120 -0
- package/dist/rigindex/index.d.ts +23 -0
- package/dist/rigindex/index.d.ts.map +1 -0
- package/dist/rigindex/index.js +112 -0
- package/dist/rigindex/types.d.ts +76 -0
- package/dist/rigindex/types.d.ts.map +1 -0
- package/dist/rigindex/types.js +8 -0
- package/dist/routes/cache-lint.d.ts +41 -0
- package/dist/routes/cache-lint.d.ts.map +1 -0
- package/dist/routes/cache-lint.js +81 -0
- package/dist/routes/draft.d.ts +83 -0
- package/dist/routes/draft.d.ts.map +1 -0
- package/dist/routes/draft.js +135 -0
- package/dist/routes/loader.d.ts +63 -0
- package/dist/routes/loader.d.ts.map +1 -0
- package/dist/routes/loader.js +574 -0
- package/dist/routes/manifest.d.ts +24 -0
- package/dist/routes/manifest.d.ts.map +1 -0
- package/dist/routes/manifest.js +118 -0
- package/dist/routes/resolved-bundle.d.ts +79 -0
- package/dist/routes/resolved-bundle.d.ts.map +1 -0
- package/dist/routes/resolved-bundle.js +148 -0
- package/dist/routes/sampling-config.d.ts +32 -0
- package/dist/routes/sampling-config.d.ts.map +1 -0
- package/dist/routes/sampling-config.js +91 -0
- package/dist/routes/serveability.d.ts +52 -0
- package/dist/routes/serveability.d.ts.map +1 -0
- package/dist/routes/serveability.js +73 -0
- package/dist/routes/template.d.ts +18 -0
- package/dist/routes/template.d.ts.map +1 -0
- package/dist/routes/template.js +94 -0
- package/dist/run/ajv.d.ts +22 -0
- package/dist/run/ajv.d.ts.map +1 -0
- package/dist/run/ajv.js +32 -0
- package/dist/run/cache-handle.d.ts +58 -0
- package/dist/run/cache-handle.d.ts.map +1 -0
- package/dist/run/cache-handle.js +54 -0
- package/dist/run/cache-stamp.d.ts +65 -0
- package/dist/run/cache-stamp.d.ts.map +1 -0
- package/dist/run/cache-stamp.js +0 -0
- package/dist/run/capture-write.d.ts +33 -0
- package/dist/run/capture-write.d.ts.map +1 -0
- package/dist/run/capture-write.js +55 -0
- package/dist/run/cost.d.ts +26 -0
- package/dist/run/cost.d.ts.map +1 -0
- package/dist/run/cost.js +41 -0
- package/dist/run/dispatch.d.ts +99 -0
- package/dist/run/dispatch.d.ts.map +1 -0
- package/dist/run/dispatch.js +191 -0
- package/dist/run/envelope.d.ts +21 -0
- package/dist/run/envelope.d.ts.map +1 -0
- package/dist/run/envelope.js +45 -0
- package/dist/run/grounding.d.ts +56 -0
- package/dist/run/grounding.d.ts.map +1 -0
- package/dist/run/grounding.js +89 -0
- package/dist/run/raw.d.ts +88 -0
- package/dist/run/raw.d.ts.map +1 -0
- package/dist/run/raw.js +286 -0
- package/dist/run/record-attempt.d.ts +40 -0
- package/dist/run/record-attempt.d.ts.map +1 -0
- package/dist/run/record-attempt.js +99 -0
- package/dist/run/repair.d.ts +36 -0
- package/dist/run/repair.d.ts.map +1 -0
- package/dist/run/repair.js +61 -0
- package/dist/run/resolve.d.ts +99 -0
- package/dist/run/resolve.d.ts.map +1 -0
- package/dist/run/resolve.js +203 -0
- package/dist/run/retry.d.ts +19 -0
- package/dist/run/retry.d.ts.map +1 -0
- package/dist/run/retry.js +50 -0
- package/dist/run/run.d.ts +55 -0
- package/dist/run/run.d.ts.map +1 -0
- package/dist/run/run.js +540 -0
- package/dist/run/stream.d.ts +49 -0
- package/dist/run/stream.d.ts.map +1 -0
- package/dist/run/stream.js +87 -0
- package/dist/run/validate.d.ts +15 -0
- package/dist/run/validate.d.ts.map +1 -0
- package/dist/run/validate.js +55 -0
- package/dist/savings/cache-ledger.d.ts +108 -0
- package/dist/savings/cache-ledger.d.ts.map +1 -0
- package/dist/savings/cache-ledger.js +174 -0
- package/dist/savings/cache-reconcile.d.ts +64 -0
- package/dist/savings/cache-reconcile.d.ts.map +1 -0
- package/dist/savings/cache-reconcile.js +59 -0
- package/dist/savings/cache-stats.d.ts +63 -0
- package/dist/savings/cache-stats.d.ts.map +1 -0
- package/dist/savings/cache-stats.js +108 -0
- package/dist/savings/emit.d.ts +38 -0
- package/dist/savings/emit.d.ts.map +1 -0
- package/dist/savings/emit.js +100 -0
- package/dist/savings/odometer.d.ts +32 -0
- package/dist/savings/odometer.d.ts.map +1 -0
- package/dist/savings/odometer.js +70 -0
- package/dist/savings/swap-execute.d.ts +58 -0
- package/dist/savings/swap-execute.d.ts.map +1 -0
- package/dist/savings/swap-execute.js +130 -0
- package/dist/savings/swaps-client.d.ts +55 -0
- package/dist/savings/swaps-client.d.ts.map +1 -0
- package/dist/savings/swaps-client.js +95 -0
- package/dist/settings/api-fetcher.d.ts +39 -0
- package/dist/settings/api-fetcher.d.ts.map +1 -0
- package/dist/settings/api-fetcher.js +92 -0
- package/dist/settings/index.d.ts +10 -0
- package/dist/settings/index.d.ts.map +1 -0
- package/dist/settings/index.js +15 -0
- package/dist/settings/task-settings.d.ts +91 -0
- package/dist/settings/task-settings.d.ts.map +1 -0
- package/dist/settings/task-settings.js +116 -0
- package/dist/status.d.ts +77 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +113 -0
- package/dist/telemetry/artifact-store.d.ts +48 -0
- package/dist/telemetry/artifact-store.d.ts.map +1 -0
- package/dist/telemetry/artifact-store.js +189 -0
- package/dist/telemetry/cache-miss-streak.d.ts +79 -0
- package/dist/telemetry/cache-miss-streak.d.ts.map +1 -0
- package/dist/telemetry/cache-miss-streak.js +99 -0
- package/dist/telemetry/capture.d.ts +31 -0
- package/dist/telemetry/capture.d.ts.map +1 -0
- package/dist/telemetry/capture.js +81 -0
- package/dist/telemetry/exporter-setup.d.ts +28 -0
- package/dist/telemetry/exporter-setup.d.ts.map +1 -0
- package/dist/telemetry/exporter-setup.js +34 -0
- package/dist/telemetry/exporter.d.ts +137 -0
- package/dist/telemetry/exporter.d.ts.map +1 -0
- package/dist/telemetry/exporter.js +510 -0
- package/dist/telemetry/health.d.ts +76 -0
- package/dist/telemetry/health.d.ts.map +1 -0
- package/dist/telemetry/health.js +92 -0
- package/dist/telemetry/ingest-protocol.d.ts +310 -0
- package/dist/telemetry/ingest-protocol.d.ts.map +1 -0
- package/dist/telemetry/ingest-protocol.js +363 -0
- package/dist/telemetry/load-error-report.d.ts +24 -0
- package/dist/telemetry/load-error-report.d.ts.map +1 -0
- package/dist/telemetry/load-error-report.js +50 -0
- package/dist/telemetry/otel-map.d.ts +121 -0
- package/dist/telemetry/otel-map.d.ts.map +1 -0
- package/dist/telemetry/otel-map.js +224 -0
- package/dist/telemetry/otel-normalize.d.ts +104 -0
- package/dist/telemetry/otel-normalize.d.ts.map +1 -0
- package/dist/telemetry/otel-normalize.js +530 -0
- package/dist/telemetry/otlp-emitter.d.ts +52 -0
- package/dist/telemetry/otlp-emitter.d.ts.map +1 -0
- package/dist/telemetry/otlp-emitter.js +144 -0
- package/dist/telemetry/otlp-proto.d.ts +29 -0
- package/dist/telemetry/otlp-proto.d.ts.map +1 -0
- package/dist/telemetry/otlp-proto.js +266 -0
- package/dist/telemetry/sinks.d.ts +90 -0
- package/dist/telemetry/sinks.d.ts.map +1 -0
- package/dist/telemetry/sinks.js +180 -0
- package/dist/telemetry/store.d.ts +65 -0
- package/dist/telemetry/store.d.ts.map +1 -0
- package/dist/telemetry/store.js +547 -0
- package/dist/tenancy/api-key-format.d.ts +77 -0
- package/dist/tenancy/api-key-format.d.ts.map +1 -0
- package/dist/tenancy/api-key-format.js +110 -0
- package/dist/tenancy/constants.d.ts +23 -0
- package/dist/tenancy/constants.d.ts.map +1 -0
- package/dist/tenancy/constants.js +25 -0
- package/dist/tenancy/scrub.d.ts +47 -0
- package/dist/tenancy/scrub.d.ts.map +1 -0
- package/dist/tenancy/scrub.js +85 -0
- package/dist/types/config-teaching.d.ts +62 -0
- package/dist/types/config-teaching.d.ts.map +1 -0
- package/dist/types/config-teaching.js +183 -0
- package/dist/types/failures-teaching.d.ts +56 -0
- package/dist/types/failures-teaching.d.ts.map +1 -0
- package/dist/types/failures-teaching.js +177 -0
- package/dist/types/failures.d.ts +27 -0
- package/dist/types/failures.d.ts.map +1 -0
- package/dist/types/failures.js +41 -0
- package/dist/types/provider.d.ts +200 -0
- package/dist/types/provider.d.ts.map +1 -0
- package/dist/types/provider.js +40 -0
- package/dist/types/route.d.ts +205 -0
- package/dist/types/route.d.ts.map +1 -0
- package/dist/types/route.js +6 -0
- package/dist/types/telemetry.d.ts +206 -0
- package/dist/types/telemetry.d.ts.map +1 -0
- package/dist/types/telemetry.js +6 -0
- package/dist/validate-cli.d.ts +12 -0
- package/dist/validate-cli.d.ts.map +1 -0
- package/dist/validate-cli.js +57 -0
- package/dist/verify/capture.d.ts +66 -0
- package/dist/verify/capture.d.ts.map +1 -0
- package/dist/verify/capture.js +180 -0
- package/dist/verify/cli-run.d.ts +23 -0
- package/dist/verify/cli-run.d.ts.map +1 -0
- package/dist/verify/cli-run.js +57 -0
- package/dist/verify/diff.d.ts +48 -0
- package/dist/verify/diff.d.ts.map +1 -0
- package/dist/verify/diff.js +157 -0
- package/dist/verify/index.d.ts +17 -0
- package/dist/verify/index.d.ts.map +1 -0
- package/dist/verify/index.js +24 -0
- package/dist/verify/report.d.ts +14 -0
- package/dist/verify/report.d.ts.map +1 -0
- package/dist/verify/report.js +88 -0
- package/dist/verify/types.d.ts +101 -0
- package/dist/verify/types.d.ts.map +1 -0
- package/dist/verify/types.js +17 -0
- package/dist/verify/verify.d.ts +29 -0
- package/dist/verify/verify.d.ts.map +1 -0
- package/dist/verify/verify.js +148 -0
- package/dist/watch/budget.d.ts +19 -0
- package/dist/watch/budget.d.ts.map +1 -0
- package/dist/watch/budget.js +35 -0
- package/dist/watch/evaluate.d.ts +225 -0
- package/dist/watch/evaluate.d.ts.map +1 -0
- package/dist/watch/evaluate.js +155 -0
- package/dist/watch/monitor.d.ts +116 -0
- package/dist/watch/monitor.d.ts.map +1 -0
- package/dist/watch/monitor.js +199 -0
- package/dist/watch/proposals.d.ts +89 -0
- package/dist/watch/proposals.d.ts.map +1 -0
- package/dist/watch/proposals.js +197 -0
- package/dist/watch/run-record.d.ts +64 -0
- package/dist/watch/run-record.d.ts.map +1 -0
- package/dist/watch/run-record.js +86 -0
- package/dist/watch/run-reported.d.ts +20 -0
- package/dist/watch/run-reported.d.ts.map +1 -0
- package/dist/watch/run-reported.js +53 -0
- package/dist/watch/run.d.ts +73 -0
- package/dist/watch/run.d.ts.map +1 -0
- package/dist/watch/run.js +83 -0
- package/dist/watch/state-store.d.ts +48 -0
- package/dist/watch/state-store.d.ts.map +1 -0
- package/dist/watch/state-store.js +86 -0
- package/dist/watch/state.d.ts +21 -0
- package/dist/watch/state.d.ts.map +1 -0
- package/dist/watch/state.js +93 -0
- package/package.json +56 -14
- package/registry/LICENSE +20 -0
- package/registry/leaderboard.json +3639 -0
- package/registry/registry.json +7263 -0
- package/index.js +0 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Watch-state persistence — Phase 5 addendum A4.
|
|
4
|
+
*
|
|
5
|
+
* The watch loop's pricing snapshot has to survive between runs, and the
|
|
6
|
+
* runs happen in an EPHEMERAL cron container. A local file cannot do that:
|
|
7
|
+
* every run reads nothing, re-seeds, and reports zero events — the cron was
|
|
8
|
+
* live and structurally incapable of ever firing a proposal.
|
|
9
|
+
*
|
|
10
|
+
* Two implementations behind one interface:
|
|
11
|
+
* - control plane (default when Supabase is configured): a keyed row in
|
|
12
|
+
* `control_state`. Survives the container.
|
|
13
|
+
* - local file (the self-host / no-Supabase fallback): the Phase 4
|
|
14
|
+
* behavior, kept because a single-machine user should not need a
|
|
15
|
+
* control plane to run a watch cycle.
|
|
16
|
+
*
|
|
17
|
+
* A store that cannot load is NOT treated as "no previous state". Seeding on
|
|
18
|
+
* a transient read failure would re-baseline the universe and silently
|
|
19
|
+
* swallow every price move since the last successful run, which is exactly
|
|
20
|
+
* the bug this file exists to fix — so a failed read throws.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.WATCH_STATE_KEY = void 0;
|
|
24
|
+
exports.createFileWatchStateStore = createFileWatchStateStore;
|
|
25
|
+
exports.createControlPlaneWatchStateStore = createControlPlaneWatchStateStore;
|
|
26
|
+
exports.createWatchStateStore = createWatchStateStore;
|
|
27
|
+
const state_1 = require("./state");
|
|
28
|
+
/** Key under which the pricing universe lives in `control_state`. */
|
|
29
|
+
exports.WATCH_STATE_KEY = "watch:pricing-universe";
|
|
30
|
+
function createFileWatchStateStore(path) {
|
|
31
|
+
return {
|
|
32
|
+
description: `local file ${path} (no control plane configured — NOT durable across containers)`,
|
|
33
|
+
load: async () => (0, state_1.loadWatchState)(path),
|
|
34
|
+
save: async (universe) => {
|
|
35
|
+
(0, state_1.saveWatchState)(path, universe);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function createControlPlaneWatchStateStore(config) {
|
|
40
|
+
const fetchFn = config.fetchFn ?? fetch;
|
|
41
|
+
const base = config.supabaseUrl.replace(/\/$/, "");
|
|
42
|
+
const key = config.key ?? exports.WATCH_STATE_KEY;
|
|
43
|
+
const headers = {
|
|
44
|
+
"content-type": "application/json",
|
|
45
|
+
apikey: config.serviceRoleKey,
|
|
46
|
+
authorization: `Bearer ${config.serviceRoleKey}`,
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
description: `control plane control_state["${key}"]`,
|
|
50
|
+
async load() {
|
|
51
|
+
const response = await fetchFn(`${base}/rest/v1/control_state?select=value&key=eq.${encodeURIComponent(key)}`, { headers });
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
// Loud, not silent: a read failure that returned null would look
|
|
54
|
+
// exactly like a first run and re-seed the baseline.
|
|
55
|
+
throw new Error(`watch state read failed (${response.status}) — refusing to re-seed, because ` +
|
|
56
|
+
"treating a failed read as 'no previous state' would discard every price move " +
|
|
57
|
+
`since the last successful cycle. ${await response.text().catch(() => "")}`);
|
|
58
|
+
}
|
|
59
|
+
const rows = (await response.json());
|
|
60
|
+
return rows.length > 0 ? rows[0].value : null;
|
|
61
|
+
},
|
|
62
|
+
async save(universe) {
|
|
63
|
+
const response = await fetchFn(`${base}/rest/v1/control_state?on_conflict=key`, {
|
|
64
|
+
method: "POST",
|
|
65
|
+
headers: { ...headers, prefer: "resolution=merge-duplicates,return=minimal" },
|
|
66
|
+
body: JSON.stringify([
|
|
67
|
+
{ key, value: universe, updated_at: new Date().toISOString() },
|
|
68
|
+
]),
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
throw new Error(`watch state write failed (${response.status}) — the next cycle would re-seed and ` +
|
|
72
|
+
`miss this cycle's changes. ${await response.text().catch(() => "")}`);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Pick the durable store when a control plane exists, else the local file. */
|
|
78
|
+
function createWatchStateStore(opts) {
|
|
79
|
+
if (opts.export === undefined)
|
|
80
|
+
return createFileWatchStateStore(opts.filePath);
|
|
81
|
+
return createControlPlaneWatchStateStore({
|
|
82
|
+
supabaseUrl: opts.export.supabaseUrl,
|
|
83
|
+
serviceRoleKey: opts.export.serviceRoleKey,
|
|
84
|
+
...(opts.fetchFn !== undefined ? { fetchFn: opts.fetchFn } : {}),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watch state — Phase 4 WS1. The cycle's memory: a JSON snapshot of the
|
|
3
|
+
* last-seen pricing universe (provider/model → token rates), diffed against
|
|
4
|
+
* the current pricing map each run. Seed runs emit no events by design.
|
|
5
|
+
*
|
|
6
|
+
* The universe is restricted to providers the loaded routes actually
|
|
7
|
+
* declare — a price move on a provider nobody routes to is not news.
|
|
8
|
+
*/
|
|
9
|
+
import type { TokenRates, WatchEvent } from "./evaluate";
|
|
10
|
+
/** provider/model → rates. Keys use OUR provider ids, not LiteLLM's. */
|
|
11
|
+
export type PriceUniverse = Record<string, TokenRates>;
|
|
12
|
+
/** Build the current universe from the vendored pricing map, filtered to
|
|
13
|
+
* the providers in scope. Model ids are normalized to the bare form route
|
|
14
|
+
* candidates use ("gemini/gemini-2.5-pro" → "gemini-2.5-pro"). */
|
|
15
|
+
export declare function buildPriceUniverse(providersInScope: ReadonlySet<string>, pricingMapPath?: string): PriceUniverse;
|
|
16
|
+
/** Pure diff: current vs last-seen → events. Null previous = seed run,
|
|
17
|
+
* nothing fires. Delisted models are silence, not events. */
|
|
18
|
+
export declare function computeWatchEvents(current: PriceUniverse, previous: PriceUniverse | null): WatchEvent[];
|
|
19
|
+
export declare function loadWatchState(path: string): PriceUniverse | null;
|
|
20
|
+
export declare function saveWatchState(path: string, universe: PriceUniverse): void;
|
|
21
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/watch/state.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzD,wEAAwE;AACxE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAkCvD;;kEAEkE;AAClE,wBAAgB,kBAAkB,CAChC,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,EACrC,cAAc,CAAC,EAAE,MAAM,GACtB,aAAa,CAoBf;AAED;6DAC6D;AAC7D,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,aAAa,GAAG,IAAI,GAC7B,UAAU,EAAE,CAkBd;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAGjE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAG1E"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Watch state — Phase 4 WS1. The cycle's memory: a JSON snapshot of the
|
|
4
|
+
* last-seen pricing universe (provider/model → token rates), diffed against
|
|
5
|
+
* the current pricing map each run. Seed runs emit no events by design.
|
|
6
|
+
*
|
|
7
|
+
* The universe is restricted to providers the loaded routes actually
|
|
8
|
+
* declare — a price move on a provider nobody routes to is not news.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.buildPriceUniverse = buildPriceUniverse;
|
|
12
|
+
exports.computeWatchEvents = computeWatchEvents;
|
|
13
|
+
exports.loadWatchState = loadWatchState;
|
|
14
|
+
exports.saveWatchState = saveWatchState;
|
|
15
|
+
const node_fs_1 = require("node:fs");
|
|
16
|
+
const node_path_1 = require("node:path");
|
|
17
|
+
/** LiteLLM's litellm_provider values → our ProviderId space (watch scope:
|
|
18
|
+
* the launch providers; extending = adding a line). */
|
|
19
|
+
const LITELLM_PROVIDER_MAP = {
|
|
20
|
+
gemini: "gemini",
|
|
21
|
+
openai: "openai",
|
|
22
|
+
deepseek: "deepseek",
|
|
23
|
+
anthropic: "anthropic",
|
|
24
|
+
xai: "grok",
|
|
25
|
+
// A1 hosts (openai-compatible generic adapter).
|
|
26
|
+
deepinfra: "deepinfra",
|
|
27
|
+
fireworks_ai: "fireworks",
|
|
28
|
+
};
|
|
29
|
+
/** Normalize a pricing-map key to the bare model id route candidates use:
|
|
30
|
+
* strip the leading litellm-provider segment, then Fireworks' wire prefix.
|
|
31
|
+
* DeepInfra org paths ("Qwen/QwQ-32B") are PART of the model id — kept. */
|
|
32
|
+
function normalizeModelId(rawKey, litellmProvider) {
|
|
33
|
+
let model = rawKey.startsWith(`${litellmProvider}/`)
|
|
34
|
+
? rawKey.slice(litellmProvider.length + 1)
|
|
35
|
+
: rawKey;
|
|
36
|
+
if (model.startsWith("accounts/fireworks/models/")) {
|
|
37
|
+
model = model.slice("accounts/fireworks/models/".length);
|
|
38
|
+
}
|
|
39
|
+
return model;
|
|
40
|
+
}
|
|
41
|
+
/** Build the current universe from the vendored pricing map, filtered to
|
|
42
|
+
* the providers in scope. Model ids are normalized to the bare form route
|
|
43
|
+
* candidates use ("gemini/gemini-2.5-pro" → "gemini-2.5-pro"). */
|
|
44
|
+
function buildPriceUniverse(providersInScope, pricingMapPath) {
|
|
45
|
+
const path = pricingMapPath ?? (0, node_path_1.join)(__dirname, "..", "..", "data", "pricing-map.json");
|
|
46
|
+
const map = JSON.parse((0, node_fs_1.readFileSync)(path, "utf8"));
|
|
47
|
+
const universe = {};
|
|
48
|
+
for (const [rawKey, entry] of Object.entries(map)) {
|
|
49
|
+
const provider = LITELLM_PROVIDER_MAP[entry.litellm_provider ?? ""];
|
|
50
|
+
if (provider === undefined || !providersInScope.has(provider))
|
|
51
|
+
continue;
|
|
52
|
+
if (typeof entry.input_cost_per_token !== "number" ||
|
|
53
|
+
typeof entry.output_cost_per_token !== "number") {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const model = normalizeModelId(rawKey, entry.litellm_provider ?? "");
|
|
57
|
+
universe[`${provider}/${model}`] = {
|
|
58
|
+
inputUsdPerTok: entry.input_cost_per_token,
|
|
59
|
+
outputUsdPerTok: entry.output_cost_per_token,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return universe;
|
|
63
|
+
}
|
|
64
|
+
/** Pure diff: current vs last-seen → events. Null previous = seed run,
|
|
65
|
+
* nothing fires. Delisted models are silence, not events. */
|
|
66
|
+
function computeWatchEvents(current, previous) {
|
|
67
|
+
if (previous === null)
|
|
68
|
+
return [];
|
|
69
|
+
const events = [];
|
|
70
|
+
for (const [key, rates] of Object.entries(current)) {
|
|
71
|
+
const slash = key.indexOf("/");
|
|
72
|
+
const provider = key.slice(0, slash);
|
|
73
|
+
const model = key.slice(slash + 1);
|
|
74
|
+
const before = previous[key];
|
|
75
|
+
if (before === undefined) {
|
|
76
|
+
events.push({ type: "new_model", provider, model, pricing: rates });
|
|
77
|
+
}
|
|
78
|
+
else if (before.inputUsdPerTok !== rates.inputUsdPerTok ||
|
|
79
|
+
before.outputUsdPerTok !== rates.outputUsdPerTok) {
|
|
80
|
+
events.push({ type: "price_change", provider, model, old: before, new: rates });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return events;
|
|
84
|
+
}
|
|
85
|
+
function loadWatchState(path) {
|
|
86
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
87
|
+
return null;
|
|
88
|
+
return JSON.parse((0, node_fs_1.readFileSync)(path, "utf8"));
|
|
89
|
+
}
|
|
90
|
+
function saveWatchState(path, universe) {
|
|
91
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(path), { recursive: true });
|
|
92
|
+
(0, node_fs_1.writeFileSync)(path, `${JSON.stringify(universe, null, 2)}\n`);
|
|
93
|
+
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modelrig",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "ModelRig — capability-aware AI gateway: routes-as-code, provider adapters, typed failures, budget envelopes, and local-first telemetry.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
7
|
+
"homepage": "https://modelrig.dev",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/modelrig/modelrig.git"
|
|
11
|
+
},
|
|
12
12
|
"keywords": [
|
|
13
|
-
"ai",
|
|
14
13
|
"llm",
|
|
15
|
-
"gateway",
|
|
16
|
-
"routing",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
14
|
+
"ai-gateway",
|
|
15
|
+
"model-routing",
|
|
16
|
+
"openai",
|
|
17
|
+
"anthropic",
|
|
18
|
+
"gemini",
|
|
19
|
+
"telemetry",
|
|
20
|
+
"failover"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"main": "dist/index.js",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"//files": "ALLOWLIST, not a denylist, and the difference is not academic. Without this field npm falls back to .npmignore, then to THIS DIRECTORY's .gitignore — never the repo root's. The root ignores `.env.*`, which is why git has never committed .env.local; the package-level .gitignore says nothing about it, so `npm pack` happily included it. A publish would have shipped 13 live secrets, the Supabase service-role key among them, into an immutable public tarball. Anything added here must be something we would hand a stranger. See __tests__/publish-safety.test.ts.",
|
|
28
|
+
"//files-registry": "registry/{registry,leaderboard}.json are fail-open runtime reads (facts.ts/rows.ts degrade to the static baseline when absent) — shipped by R-1 F2 RULING so a clean install routes on the PROBED capability profile the docs and the DVP report describe, not the static fallback. Enumerated file entries, NOT the registry/ dir (it also holds build scripts + tests). Public CC BY 4.0.",
|
|
29
|
+
"//files-data": "`data/` is a RUNTIME dependency, not a build input (R-1 clean-room audit, A1): getPricing() reads data/pricing-map.json from the package root at first cost lookup, with NO existsSync guard — so an absent data/ throws, not degrades. 0.1.0 shipped dist-only and broke the flagship 'effective cost' story on a clean `npm i`. It is public CC BY 4.0 pricing data (data/PROVENANCE.md) — safe to hand a stranger. The tarball clean-room test (__tests__/tarball-cleanroom.test.ts) installs the packed artifact and asserts getPricing() returns a real rate, so this can never silently regress again.",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"data",
|
|
33
|
+
"registry/registry.json",
|
|
34
|
+
"registry/leaderboard.json",
|
|
35
|
+
"README.md",
|
|
36
|
+
"CHANGELOG.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"type-check": "tsc --noEmit && tsc -p tsconfig.test.json",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:live": "MODELRIG_LIVE=1 vitest run"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@anthropic-ai/sdk": "^0.71.2",
|
|
47
|
+
"@google/genai": "^2.4.0",
|
|
48
|
+
"ajv": "^8.17.0",
|
|
49
|
+
"better-sqlite3": "^11.10.0",
|
|
50
|
+
"openai": "^4.77.0",
|
|
51
|
+
"yaml": "^2.6.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/better-sqlite3": "^7.6.12",
|
|
55
|
+
"tsx": "^4.21.0",
|
|
56
|
+
"typescript": "^5.2.0",
|
|
57
|
+
"vitest": "^2.1.0"
|
|
58
|
+
},
|
|
59
|
+
"bin": {
|
|
60
|
+
"modelrig": "dist/cli.js"
|
|
61
|
+
}
|
|
20
62
|
}
|
package/registry/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The ModelRig registry data (registry.json, layers/, leaderboard.json, and all
|
|
2
|
+
probe-derived data files in this directory) is licensed under the Creative
|
|
3
|
+
Commons Attribution 4.0 International License (CC BY 4.0).
|
|
4
|
+
|
|
5
|
+
You are free to share and adapt this data for any purpose, including
|
|
6
|
+
commercially, provided you give appropriate credit to ModelRig
|
|
7
|
+
(https://modelrig.dev), link to the license, and indicate if changes were made.
|
|
8
|
+
|
|
9
|
+
Full license text: https://creativecommons.org/licenses/by/4.0/legalcode
|
|
10
|
+
|
|
11
|
+
Attribution example:
|
|
12
|
+
"Model capability data from the ModelRig registry (https://modelrig.dev),
|
|
13
|
+
CC BY 4.0."
|
|
14
|
+
|
|
15
|
+
The build scripts in this directory (build-*.ts) are code, licensed under the
|
|
16
|
+
repository's Apache-2.0 LICENSE.
|
|
17
|
+
|
|
18
|
+
The pricing snapshot under data/ is derived from BerriAI/litellm's
|
|
19
|
+
model_prices_and_context_window.json (MIT License, Copyright (c) 2023 Berri AI)
|
|
20
|
+
at the pinned SHA recorded in data/PROVENANCE.md.
|