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,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Errors that teach — Phase 5 WS3.
|
|
4
|
+
*
|
|
5
|
+
* ONE table, not prose scattered across call sites. Every failure class here
|
|
6
|
+
* answers three questions in the order a stuck engineer asks them:
|
|
7
|
+
*
|
|
8
|
+
* 1. what happened? → `what` (plain language, no jargon-first)
|
|
9
|
+
* 2. what do I do about it? → `fixHint` (an action, not a diagnosis)
|
|
10
|
+
* 3. where do I read more? → `docsUrl` (a deep link, not a homepage)
|
|
11
|
+
*
|
|
12
|
+
* And where the fix is MECHANICAL, a fourth: `suggestedChange` — a
|
|
13
|
+
* JSON-patch-shaped hint a coding agent can apply without inventing
|
|
14
|
+
* anything. Only classes whose remedy is genuinely a config edit carry one;
|
|
15
|
+
* inventing a patch for "the model refused" would be worse than silence.
|
|
16
|
+
*
|
|
17
|
+
* The completeness test in failures-teaching.test.ts fails the build if a
|
|
18
|
+
* new FailureClass is added without an entry here, so this table cannot
|
|
19
|
+
* silently fall behind the taxonomy.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.FAILURE_TEACHING = void 0;
|
|
23
|
+
exports.teach = teach;
|
|
24
|
+
exports.renderFailureForTerminal = renderFailureForTerminal;
|
|
25
|
+
const DOCS_BASE = "https://modelrig.dev/docs/failures";
|
|
26
|
+
exports.FAILURE_TEACHING = {
|
|
27
|
+
content_invalid: {
|
|
28
|
+
class: "content_invalid",
|
|
29
|
+
what: "The model answered, but the answer did not match the schema your route requires — so it " +
|
|
30
|
+
"was rejected rather than passed downstream.",
|
|
31
|
+
fixHint: "Retry on this class is budgeted separately, so a flaky schema cannot eat your network " +
|
|
32
|
+
"retries. If it persists, the model likely cannot hold this shape: check the registry for " +
|
|
33
|
+
"a candidate with probed native structured output.",
|
|
34
|
+
docsUrl: `${DOCS_BASE}#content_invalid`,
|
|
35
|
+
// Mechanical: raise the content-retry budget. A repair rung is a bigger
|
|
36
|
+
// decision, so we suggest the small edit and name the bigger one in prose.
|
|
37
|
+
suggestedChange: () => ({
|
|
38
|
+
op: "replace",
|
|
39
|
+
path: "/policy/retries/content_invalid",
|
|
40
|
+
value: 3,
|
|
41
|
+
because: "A schema miss is usually transient at low retry counts; three attempts is the point " +
|
|
42
|
+
"past which the model is telling you it cannot hold this shape.",
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
capacity_shed: {
|
|
46
|
+
class: "capacity_shed",
|
|
47
|
+
what: "The provider shed your request rather than serving it — a 429, a 503, or a flex-tier " +
|
|
48
|
+
"rejection. Nothing was wrong with the request.",
|
|
49
|
+
fixHint: "Capacity retries back off automatically. If it happens constantly, you are asking for " +
|
|
50
|
+
"discounted sheddable capacity during peak: move the route off the flex tier, or add a " +
|
|
51
|
+
"candidate on another provider so a shed on one does not stall the route.",
|
|
52
|
+
docsUrl: `${DOCS_BASE}#capacity_shed`,
|
|
53
|
+
suggestedChange: () => ({
|
|
54
|
+
op: "replace",
|
|
55
|
+
path: "/policy/tier",
|
|
56
|
+
value: "standard",
|
|
57
|
+
because: "Flex capacity is discounted because it is sheddable. If sheds are routine on this " +
|
|
58
|
+
"route, standard tier is the cheaper choice once retries are counted.",
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
network: {
|
|
62
|
+
class: "network",
|
|
63
|
+
what: "The request never completed at the transport level — DNS, TLS, a dropped connection, or " +
|
|
64
|
+
"an error we could not classify any more precisely.",
|
|
65
|
+
fixHint: "These retry on their own budget. A persistent one is usually local: check egress, proxy " +
|
|
66
|
+
"settings, and whether the provider is up before changing anything in the route.",
|
|
67
|
+
docsUrl: `${DOCS_BASE}#network`,
|
|
68
|
+
},
|
|
69
|
+
refusal: {
|
|
70
|
+
class: "refusal",
|
|
71
|
+
what: "The model declined the task itself — this is an answer, not a fault.",
|
|
72
|
+
fixHint: "Retrying a refusal usually earns another refusal. Read the prompt as the model saw it: " +
|
|
73
|
+
"the input often contains something the model's policy will not touch. A different " +
|
|
74
|
+
"candidate may answer, but check the prompt first.",
|
|
75
|
+
docsUrl: `${DOCS_BASE}#refusal`,
|
|
76
|
+
// Deliberately no suggestedChange: no config edit fixes a refusal, and a
|
|
77
|
+
// patch that pretends otherwise would send someone down the wrong path.
|
|
78
|
+
},
|
|
79
|
+
cache_invalid: {
|
|
80
|
+
class: "cache_invalid",
|
|
81
|
+
what: "The provider-side cache or cached context this call relied on expired or was rejected, " +
|
|
82
|
+
"so the discount it was counting on is gone.",
|
|
83
|
+
fixHint: "Re-running usually repopulates the cache. If it recurs, your cached prefix is probably " +
|
|
84
|
+
"changing between calls — anything varying near the START of the prompt defeats prefix " +
|
|
85
|
+
"caching, so move volatile values to the end.",
|
|
86
|
+
docsUrl: `${DOCS_BASE}#cache_invalid`,
|
|
87
|
+
},
|
|
88
|
+
timeout: {
|
|
89
|
+
class: "timeout",
|
|
90
|
+
what: "The call passed the route's wall-clock deadline before the model finished.",
|
|
91
|
+
fixHint: "Either the deadline is too tight for this task or the model is slower than assumed. " +
|
|
92
|
+
"Check the latency column for this model before raising the timeout — a timeout raised to " +
|
|
93
|
+
"cover a slow model just makes a slow route.",
|
|
94
|
+
docsUrl: `${DOCS_BASE}#timeout`,
|
|
95
|
+
suggestedChange: () => ({
|
|
96
|
+
op: "replace",
|
|
97
|
+
path: "/policy/timeout_ms",
|
|
98
|
+
value: 300000,
|
|
99
|
+
because: "Long structured generations routinely exceed a 2-minute default. Five minutes is the " +
|
|
100
|
+
"ceiling used by the pipeline routes that produce full reports.",
|
|
101
|
+
}),
|
|
102
|
+
},
|
|
103
|
+
config_auth: {
|
|
104
|
+
class: "config_auth",
|
|
105
|
+
what: "The provider rejected the credentials, or there were none to send. This is never " +
|
|
106
|
+
"retried — retrying a dead key just spends time.",
|
|
107
|
+
fixHint: "Set the provider's API key in this environment. Until then the candidate is inert: the " +
|
|
108
|
+
"route still serves on its keyed candidates, and this one is skipped at dispatch.",
|
|
109
|
+
docsUrl: `${DOCS_BASE}#config_auth`,
|
|
110
|
+
// Mechanical only in the sense of naming the variable — the value is a
|
|
111
|
+
// secret and never appears in a suggested patch.
|
|
112
|
+
suggestedChange: (failure) => failure.provider === undefined
|
|
113
|
+
? null
|
|
114
|
+
: {
|
|
115
|
+
op: "add",
|
|
116
|
+
path: `/env/${envVarNameFor(failure.provider)}`,
|
|
117
|
+
value: "<your API key>",
|
|
118
|
+
because: `Provider "${failure.provider}" has no usable credentials here. Set ` +
|
|
119
|
+
`${envVarNameFor(failure.provider)} in the environment — never in the route file.`,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
budget_exhausted: {
|
|
123
|
+
class: "budget_exhausted",
|
|
124
|
+
what: "The envelope this work was running under hit its cap, so spending stopped mid-run. " +
|
|
125
|
+
"This is the budget machinery working, not a bug.",
|
|
126
|
+
fixHint: "Decide whether the cap was wrong or the run was. Check the envelope's spend against what " +
|
|
127
|
+
"you expected before raising it — a runaway loop and an under-sized cap look identical " +
|
|
128
|
+
"from here, and only one of them is fixed by more money.",
|
|
129
|
+
docsUrl: `${DOCS_BASE}#budget_exhausted`,
|
|
130
|
+
},
|
|
131
|
+
invariant_violation: {
|
|
132
|
+
class: "invariant_violation",
|
|
133
|
+
what: "Something tried to serve a model your route never declared. The run was stopped rather " +
|
|
134
|
+
"than allowed to bill you for a model you did not choose.",
|
|
135
|
+
fixHint: "This is a bug in ModelRig, not in your configuration — the candidate set is meant to be " +
|
|
136
|
+
"an upper bound that nothing can escape. Please report it with the route name and the " +
|
|
137
|
+
"model that appeared.",
|
|
138
|
+
docsUrl: `${DOCS_BASE}#invariant_violation`,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
/** Provider → the env var that keys it. Mirrors config.ts's PROVIDER_KEY_ENV;
|
|
142
|
+
* kept as a local lookup so this table has no import cycle with config. */
|
|
143
|
+
function envVarNameFor(provider) {
|
|
144
|
+
const known = {
|
|
145
|
+
gemini: "GEMINI_API_KEY",
|
|
146
|
+
openai: "OPENAI_API_KEY",
|
|
147
|
+
deepseek: "DEEPSEEK_API_KEY",
|
|
148
|
+
anthropic: "ANTHROPIC_API_KEY",
|
|
149
|
+
grok: "XAI_API_KEY",
|
|
150
|
+
deepinfra: "MODELRIG_DEEPINFRA_API_KEY",
|
|
151
|
+
fireworks: "MODELRIG_FIREWORKS_API_KEY",
|
|
152
|
+
};
|
|
153
|
+
return known[provider] ?? `${provider.toUpperCase()}_API_KEY`;
|
|
154
|
+
}
|
|
155
|
+
function teach(failure) {
|
|
156
|
+
const entry = exports.FAILURE_TEACHING[failure.class];
|
|
157
|
+
return {
|
|
158
|
+
class: failure.class,
|
|
159
|
+
message: failure.message,
|
|
160
|
+
what: entry.what,
|
|
161
|
+
fixHint: failure.fixHint ?? entry.fixHint,
|
|
162
|
+
docsUrl: entry.docsUrl,
|
|
163
|
+
suggestedChange: entry.suggestedChange?.(failure) ?? null,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** Terminal-friendly rendering — used by the CLI. Kept here so the CLI and
|
|
167
|
+
* the server cannot drift into two different-looking errors. */
|
|
168
|
+
function renderFailureForTerminal(failure) {
|
|
169
|
+
const t = teach(failure);
|
|
170
|
+
const lines = [`[${t.class}] ${t.message}`, "", t.what, "", `Fix: ${t.fixHint}`, `Docs: ${t.docsUrl}`];
|
|
171
|
+
if (t.suggestedChange !== null) {
|
|
172
|
+
const change = t.suggestedChange;
|
|
173
|
+
lines.push("", `Suggested change: ${change.op} ${change.path}` +
|
|
174
|
+
(change.value === undefined ? "" : ` = ${JSON.stringify(change.value)}`), ` ${change.because}`);
|
|
175
|
+
}
|
|
176
|
+
return lines.join("\n");
|
|
177
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed failure taxonomy — spec §2, §4.
|
|
3
|
+
* Adapters MUST map every provider error into a RigFailure; raw provider
|
|
4
|
+
* errors never cross the adapter boundary. Retry budgets are per-class and
|
|
5
|
+
* non-fungible (see run/retry.ts).
|
|
6
|
+
*/
|
|
7
|
+
export type FailureClass = "content_invalid" | "capacity_shed" | "network" | "refusal" | "cache_invalid" | "timeout" | "config_auth" | "budget_exhausted" | "invariant_violation";
|
|
8
|
+
export interface RigFailure {
|
|
9
|
+
readonly class: FailureClass;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
/** Provider/model that produced the failure, when applicable. */
|
|
12
|
+
readonly provider?: string;
|
|
13
|
+
readonly model?: string;
|
|
14
|
+
/** Raw underlying error for diagnostics; never used for control flow. */
|
|
15
|
+
readonly cause?: unknown;
|
|
16
|
+
/** Machine-readable remediation (errors-that-teach lands fully in Phase 5). */
|
|
17
|
+
readonly fixHint?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const TERMINAL_CLASSES: ReadonlySet<FailureClass>;
|
|
20
|
+
/** Error subclass for the rare paths that must throw (config errors, terminal
|
|
21
|
+
* failures surfacing to the caller). The failure travels intact on `.failure`. */
|
|
22
|
+
export declare class RigFailureError extends Error {
|
|
23
|
+
readonly failure: RigFailure;
|
|
24
|
+
constructor(failure: RigFailure);
|
|
25
|
+
}
|
|
26
|
+
export declare function isRigFailure(value: unknown): value is RigFailure;
|
|
27
|
+
//# sourceMappingURL=failures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failures.d.ts","sourceRoot":"","sources":["../../src/types/failures.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,eAAe,GACf,SAAS,GACT,SAAS,GACT,eAAe,GACf,SAAS,GACT,aAAa,GACb,kBAAkB,GAClB,qBAAqB,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,YAAY,CAGrD,CAAC;AAcH;kFACkF;AAClF,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;gBAEjB,OAAO,EAAE,UAAU;CAKhC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAIhE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Typed failure taxonomy — spec §2, §4.
|
|
4
|
+
* Adapters MUST map every provider error into a RigFailure; raw provider
|
|
5
|
+
* errors never cross the adapter boundary. Retry budgets are per-class and
|
|
6
|
+
* non-fungible (see run/retry.ts).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RigFailureError = exports.TERMINAL_CLASSES = void 0;
|
|
10
|
+
exports.isRigFailure = isRigFailure;
|
|
11
|
+
exports.TERMINAL_CLASSES = new Set([
|
|
12
|
+
"budget_exhausted",
|
|
13
|
+
"invariant_violation",
|
|
14
|
+
]);
|
|
15
|
+
const FAILURE_CLASSES = new Set([
|
|
16
|
+
"content_invalid",
|
|
17
|
+
"capacity_shed",
|
|
18
|
+
"network",
|
|
19
|
+
"refusal",
|
|
20
|
+
"cache_invalid",
|
|
21
|
+
"timeout",
|
|
22
|
+
"config_auth",
|
|
23
|
+
"budget_exhausted",
|
|
24
|
+
"invariant_violation",
|
|
25
|
+
]);
|
|
26
|
+
/** Error subclass for the rare paths that must throw (config errors, terminal
|
|
27
|
+
* failures surfacing to the caller). The failure travels intact on `.failure`. */
|
|
28
|
+
class RigFailureError extends Error {
|
|
29
|
+
constructor(failure) {
|
|
30
|
+
super(`[${failure.class}] ${failure.message}`);
|
|
31
|
+
this.name = "RigFailureError";
|
|
32
|
+
this.failure = failure;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.RigFailureError = RigFailureError;
|
|
36
|
+
function isRigFailure(value) {
|
|
37
|
+
if (typeof value !== "object" || value === null)
|
|
38
|
+
return false;
|
|
39
|
+
const v = value;
|
|
40
|
+
return typeof v.class === "string" && FAILURE_CLASSES.has(v.class) && typeof v.message === "string";
|
|
41
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProviderAdapter contract + the candidate-set invariant's type machinery.
|
|
3
|
+
* Spec §4. The invariant is structural: AdapterRequest carries a CandidateRef,
|
|
4
|
+
* and CandidateRef is a branded type constructible ONLY in run/resolve.ts.
|
|
5
|
+
*/
|
|
6
|
+
import type { RigFailure } from "./failures";
|
|
7
|
+
export type ProviderId = "gemini" | "openai" | "deepseek" | "anthropic" | "grok" | "deepinfra" | "fireworks";
|
|
8
|
+
/** Runtime enumeration of every ProviderId — the single list a raw-model lane
|
|
9
|
+
* (`provider/model`) validates against (http gateway spec §3.3). Kept in sync
|
|
10
|
+
* with the `ProviderId` union by the two compile-time assertions below: adding
|
|
11
|
+
* a provider to the union without adding it here (or vice-versa) fails the
|
|
12
|
+
* type-check. */
|
|
13
|
+
export declare const PROVIDER_IDS: readonly ["gemini", "openai", "deepseek", "anthropic", "grok", "deepinfra", "fireworks"];
|
|
14
|
+
export type CapabilityFlag = "structured_native" | "json_mode" | "grounded_native" | "context_cache_explicit" | "prompt_cache_key" | "prefix_cache_implicit" | "tier_flex" | "trace_visible" | "zero_retention";
|
|
15
|
+
/** The canonical flag enumeration — the single list every static capability
|
|
16
|
+
* materialization iterates (index.ts, template validation, tests). */
|
|
17
|
+
export declare const ALL_CAPABILITY_FLAGS: readonly CapabilityFlag[];
|
|
18
|
+
declare const candidateBrand: unique symbol;
|
|
19
|
+
/**
|
|
20
|
+
* A (provider, model) pair validated against a route's candidate list.
|
|
21
|
+
* DO NOT construct outside run/resolve.ts — no `as CandidateRef` anywhere
|
|
22
|
+
* (CI greps for it; see candidate-set-invariant.test.ts).
|
|
23
|
+
*/
|
|
24
|
+
export interface CandidateRef {
|
|
25
|
+
readonly provider: ProviderId;
|
|
26
|
+
readonly model: string;
|
|
27
|
+
readonly [candidateBrand]: true;
|
|
28
|
+
}
|
|
29
|
+
export type ServiceTier = "standard" | "flex" | "priority";
|
|
30
|
+
/**
|
|
31
|
+
* Sampling parameters a route (RoutePolicy.sampling) or the raw lane may
|
|
32
|
+
* declare (CE-6, spec §2). Every field is optional and ADDITIVE:
|
|
33
|
+
* - ABSENT block ⇒ byte-identical to pre-CE-6 — gemini keeps its ported
|
|
34
|
+
* constants (temperature 1.0 / topP 0.95 / topK 40), and the other adapters
|
|
35
|
+
* keep sending nothing (provider defaults win).
|
|
36
|
+
* - PRESENT field ⇒ sent to the provider AS DECLARED, no silent clamp. The
|
|
37
|
+
* provider is the authority on validity; a rejection surfaces through the
|
|
38
|
+
* normal failure ladder (`invalid_request` → network). Loader ranges are a
|
|
39
|
+
* permissive envelope (temperature 0–2, topP (0,1], maxOutputTokens ≥ 1);
|
|
40
|
+
* per-model constraints are the provider's to enforce.
|
|
41
|
+
*/
|
|
42
|
+
export interface SamplingParams {
|
|
43
|
+
/** Overrides an adapter's default/constant when set. Loader checks 0–2. */
|
|
44
|
+
readonly temperature?: number;
|
|
45
|
+
/** Nucleus-sampling top_p. Loader checks (0,1] (exclusive-0, inclusive-1). */
|
|
46
|
+
readonly topP?: number;
|
|
47
|
+
/** Routed-lane exposure of the existing adapter max-output-tokens param —
|
|
48
|
+
* previously settable only on the raw lane. Loader checks integer ≥ 1. */
|
|
49
|
+
readonly maxOutputTokens?: number;
|
|
50
|
+
}
|
|
51
|
+
/** A single callable tool the model may invoke. `parameters` is a JSON Schema
|
|
52
|
+
* describing the arguments (OpenAI `function` shape). */
|
|
53
|
+
export interface ToolDefinition {
|
|
54
|
+
readonly type: "function";
|
|
55
|
+
readonly function: {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
readonly description?: string;
|
|
58
|
+
/** JSON Schema for the arguments object. */
|
|
59
|
+
readonly parameters?: object;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** How the model should choose among the supplied tools. String forms mirror
|
|
63
|
+
* OpenAI (`auto`/`none`/`required`); the object form pins a named function. */
|
|
64
|
+
export type ToolChoice = "auto" | "none" | "required" | {
|
|
65
|
+
readonly type: "function";
|
|
66
|
+
readonly function: {
|
|
67
|
+
readonly name: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
/** A tool call emitted by the model, normalized to the OpenAI `tool_calls`
|
|
71
|
+
* shape. `arguments` is the raw JSON STRING the model produced (not parsed) —
|
|
72
|
+
* exactly what OpenAI returns, so callers and the HTTP gateway pass it through
|
|
73
|
+
* unchanged. */
|
|
74
|
+
export interface ToolCall {
|
|
75
|
+
readonly id: string;
|
|
76
|
+
readonly type: "function";
|
|
77
|
+
readonly function: {
|
|
78
|
+
readonly name: string;
|
|
79
|
+
readonly arguments: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export interface AdapterRequest {
|
|
83
|
+
readonly candidate: CandidateRef;
|
|
84
|
+
readonly systemPrompt: string;
|
|
85
|
+
readonly userPrompt: string;
|
|
86
|
+
/** JSON Schema for native structured output; null => prompt/json_mode path. */
|
|
87
|
+
readonly outputSchema: object | null;
|
|
88
|
+
readonly requestedTier: ServiceTier;
|
|
89
|
+
readonly timeoutMs: number;
|
|
90
|
+
/** Provider-neutral cache directive; adapters map to native mechanisms. */
|
|
91
|
+
readonly cache?: {
|
|
92
|
+
key: string;
|
|
93
|
+
ttlSeconds?: number;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Provider-native web-grounding directive (set by the run loop when the
|
|
97
|
+
* route requires "grounded"). BUILDER ADDITION pending architect sign-off:
|
|
98
|
+
* the scaffold's gemini adapter notes grounding is "driven by a
|
|
99
|
+
* cache/grounding directive on AdapterRequest", but the scaffolded type
|
|
100
|
+
* carried only `cache` — this optional field fills that gap additively.
|
|
101
|
+
*/
|
|
102
|
+
readonly grounding?: boolean;
|
|
103
|
+
readonly maxOutputTokens?: number;
|
|
104
|
+
/**
|
|
105
|
+
* Declared sampling (CE-6, spec §2). Threaded from `RoutePolicy.sampling`
|
|
106
|
+
* (routed lane, run/dispatch.ts) or from the raw lane's temperature/topP
|
|
107
|
+
* (run/raw.ts). Adapters map each present field and keep their current
|
|
108
|
+
* constants/omissions when the block (or a field) is absent. `maxOutputTokens`
|
|
109
|
+
* here takes precedence over the top-level `maxOutputTokens` above — the two
|
|
110
|
+
* are never both set in practice (the routed lane uses this block, the raw
|
|
111
|
+
* lane the top-level field), but the precedence keeps resolution deterministic
|
|
112
|
+
* (adapters/sampling.ts). */
|
|
113
|
+
readonly sampling?: SamplingParams;
|
|
114
|
+
/** Unified tool-calling (spec §4.4) — tools the model may call. Adapters map
|
|
115
|
+
* to native tool shapes; absent => no tool surface (identical to today). */
|
|
116
|
+
readonly tools?: readonly ToolDefinition[];
|
|
117
|
+
/** Tool-selection directive; only meaningful alongside `tools`. */
|
|
118
|
+
readonly toolChoice?: ToolChoice;
|
|
119
|
+
}
|
|
120
|
+
export interface AdapterUsage {
|
|
121
|
+
/**
|
|
122
|
+
* Total input tokens for this attempt. NORMALIZATION INVARIANT (cache-aware
|
|
123
|
+
* accounting, WS-A / spec §2): `tokensIn` INCLUDES both `tokensCached` (cache
|
|
124
|
+
* reads) and `tokensCacheWrite` (cache creation) as SUBSETS — never a
|
|
125
|
+
* partition. Every adapter maps to this convention (the anthropic adapter
|
|
126
|
+
* adds cache_read + cache_creation back onto its `input_tokens`, which the
|
|
127
|
+
* provider reports EXCLUSIVE of them — research §4). Cost math
|
|
128
|
+
* (`estimateCostUsd`) relies on it: `uncached = tokensIn − cached − write`.
|
|
129
|
+
*/
|
|
130
|
+
readonly tokensIn: number;
|
|
131
|
+
readonly tokensOut: number;
|
|
132
|
+
/** Cache-READ input tokens — a subset of `tokensIn`, billed at the read rate. */
|
|
133
|
+
readonly tokensCached: number;
|
|
134
|
+
/**
|
|
135
|
+
* Cache-CREATION (write) input tokens — a subset of `tokensIn`, billed at the
|
|
136
|
+
* write rate (a premium on some providers: Anthropic 1.25× 5m / 2× 1h, OpenAI
|
|
137
|
+
* 5.6+ 1.25×; free elsewhere). OPTIONAL and additive (WS-A): adapters that do
|
|
138
|
+
* not report cache writes (deepseek, gemini, older OpenAI) omit it and it is
|
|
139
|
+
* read as 0 downstream — so those adapters need NO change. Only anthropic and
|
|
140
|
+
* the openai-dialect adapters (GPT-5.6+ `cache_write_tokens`) set it.
|
|
141
|
+
*/
|
|
142
|
+
readonly tokensCacheWrite?: number;
|
|
143
|
+
/** The 1h-TTL portion of `tokensCacheWrite` (Anthropic only; bills at the
|
|
144
|
+
* higher 2× multiplier). A subset of `tokensCacheWrite`. Optional/additive:
|
|
145
|
+
* absent ⇒ 0, i.e. all cache-write was the default (5m) tier. */
|
|
146
|
+
readonly tokensCacheWrite1h?: number;
|
|
147
|
+
readonly servedTier: ServiceTier;
|
|
148
|
+
/** Time to first body byte, ms (Phase 4 WS3 — headers lie on inference
|
|
149
|
+
* servers; TTFB is the honest slowness signal). Streaming adapters stamp
|
|
150
|
+
* first-chunk arrival; non-streaming calls equal total latency (the first
|
|
151
|
+
* byte genuinely arrives with the body). Optional: absent on failures
|
|
152
|
+
* where nothing arrived. */
|
|
153
|
+
readonly ttfbMs?: number;
|
|
154
|
+
}
|
|
155
|
+
export type AdapterResult = {
|
|
156
|
+
readonly ok: true;
|
|
157
|
+
readonly text: string;
|
|
158
|
+
readonly usage: AdapterUsage;
|
|
159
|
+
/** Normalized tool calls the model emitted (spec §4.4) — present only
|
|
160
|
+
* when the request supplied `tools` and the model chose to call one.
|
|
161
|
+
* A tool-call turn carries these instead of (or alongside) `text`; the
|
|
162
|
+
* run loop surfaces them and does NOT schema-validate the turn. */
|
|
163
|
+
readonly toolCalls?: readonly ToolCall[];
|
|
164
|
+
}
|
|
165
|
+
/** F1 (C1 finding, closed Phase 3 step 0): failures that still BILLED
|
|
166
|
+
* tokens (refusals, truncations, post-stream rejections) carry `usage` so
|
|
167
|
+
* envelopes, telemetry, and bake-off cost math see the spend. Absent when
|
|
168
|
+
* the provider billed nothing (transport errors, pre-dispatch rejections). */
|
|
169
|
+
| {
|
|
170
|
+
readonly ok: false;
|
|
171
|
+
readonly failure: RigFailure;
|
|
172
|
+
readonly usage?: AdapterUsage;
|
|
173
|
+
};
|
|
174
|
+
/** One event from an adapter's streaming variant (G-1/G-5 Phase A). A stream
|
|
175
|
+
* emits zero or more `delta` events (raw, pre-validation text) and closes with
|
|
176
|
+
* exactly one `final` carrying the same `AdapterResult` `call()` would return —
|
|
177
|
+
* so the run loop's cost/validation/telemetry logic is identical for streamed
|
|
178
|
+
* and buffered dispatch. */
|
|
179
|
+
export type AdapterStreamEvent = {
|
|
180
|
+
readonly kind: "delta";
|
|
181
|
+
readonly text: string;
|
|
182
|
+
} | {
|
|
183
|
+
readonly kind: "final";
|
|
184
|
+
readonly result: AdapterResult;
|
|
185
|
+
};
|
|
186
|
+
export interface ProviderAdapter {
|
|
187
|
+
readonly id: ProviderId;
|
|
188
|
+
supports(feature: CapabilityFlag, model: string): boolean;
|
|
189
|
+
/** Whether this model exposes native tool-calling (spec §4.4). Optional and
|
|
190
|
+
* additive: absent => unknown/unsupported. Separate from CapabilityFlag on
|
|
191
|
+
* purpose — tool support is a call-shaping fact, not a probed/registry
|
|
192
|
+
* capability, so it stays out of the flag machinery (ZDR, claims, templates). */
|
|
193
|
+
supportsTools?(model: string): boolean;
|
|
194
|
+
call(req: AdapterRequest): Promise<AdapterResult>;
|
|
195
|
+
/** Optional streaming variant (spec §4.3). Adapters that can stream deltas
|
|
196
|
+
* implement it; the run loop falls back to `call()` (buffered) when absent. */
|
|
197
|
+
stream?(req: AdapterRequest): AsyncIterable<AdapterStreamEvent>;
|
|
198
|
+
}
|
|
199
|
+
export {};
|
|
200
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/types/provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,WAAW,GACX,MAAM,GAGN,WAAW,GACX,WAAW,CAAC;AAEhB;;;;iBAIiB;AACjB,eAAO,MAAM,YAAY,0FAQf,CAAC;AAYX,MAAM,MAAM,cAAc,GACtB,mBAAmB,GACnB,WAAW,GACX,iBAAiB,GACjB,wBAAwB,GACxB,kBAAkB,GAClB,uBAAuB,GACvB,WAAW,GAC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Ac,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;CACjE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ProviderAdapter contract + the candidate-set invariant's type machinery.
|
|
4
|
+
* Spec §4. The invariant is structural: AdapterRequest carries a CandidateRef,
|
|
5
|
+
* and CandidateRef is a branded type constructible ONLY in run/resolve.ts.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ALL_CAPABILITY_FLAGS = exports.PROVIDER_IDS = void 0;
|
|
9
|
+
/** Runtime enumeration of every ProviderId — the single list a raw-model lane
|
|
10
|
+
* (`provider/model`) validates against (http gateway spec §3.3). Kept in sync
|
|
11
|
+
* with the `ProviderId` union by the two compile-time assertions below: adding
|
|
12
|
+
* a provider to the union without adding it here (or vice-versa) fails the
|
|
13
|
+
* type-check. */
|
|
14
|
+
exports.PROVIDER_IDS = [
|
|
15
|
+
"gemini",
|
|
16
|
+
"openai",
|
|
17
|
+
"deepseek",
|
|
18
|
+
"anthropic",
|
|
19
|
+
"grok",
|
|
20
|
+
"deepinfra",
|
|
21
|
+
"fireworks",
|
|
22
|
+
];
|
|
23
|
+
// Every entry is a valid ProviderId …
|
|
24
|
+
const _providerIdsAreValid = exports.PROVIDER_IDS;
|
|
25
|
+
const _noMissingProviderId = true;
|
|
26
|
+
void _providerIdsAreValid;
|
|
27
|
+
void _noMissingProviderId;
|
|
28
|
+
/** The canonical flag enumeration — the single list every static capability
|
|
29
|
+
* materialization iterates (index.ts, template validation, tests). */
|
|
30
|
+
exports.ALL_CAPABILITY_FLAGS = [
|
|
31
|
+
"structured_native",
|
|
32
|
+
"json_mode",
|
|
33
|
+
"grounded_native",
|
|
34
|
+
"context_cache_explicit",
|
|
35
|
+
"prompt_cache_key",
|
|
36
|
+
"prefix_cache_implicit",
|
|
37
|
+
"tier_flex",
|
|
38
|
+
"trace_visible",
|
|
39
|
+
"zero_retention",
|
|
40
|
+
];
|