modelrig 0.8.1 → 0.10.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 +324 -0
- package/README.md +55 -29
- package/data/PROVENANCE.md +14 -0
- package/data/pricing-map.json +26 -0
- package/dist/adapters/attempt-meta-map.d.ts +8 -1
- package/dist/adapters/attempt-meta-map.d.ts.map +1 -1
- package/dist/adapters/attempt-meta-map.js +4 -0
- package/dist/adapters/build-adapters.js +2 -2
- package/dist/adapters/gemini.d.ts +28 -1
- package/dist/adapters/gemini.d.ts.map +1 -1
- package/dist/adapters/gemini.js +38 -9
- package/dist/adapters/grok.d.ts.map +1 -1
- package/dist/adapters/grok.js +53 -4
- package/dist/adapters/openai-compat.d.ts +8 -2
- package/dist/adapters/openai-compat.d.ts.map +1 -1
- package/dist/adapters/openai-compat.js +8 -1
- package/dist/adapters/openai-stream.d.ts +10 -2
- package/dist/adapters/openai-stream.d.ts.map +1 -1
- package/dist/adapters/openai-stream.js +5 -1
- package/dist/adapters/openai.d.ts +10 -1
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +57 -7
- package/dist/adapters/responses-api.d.ts +61 -0
- package/dist/adapters/responses-api.d.ts.map +1 -0
- package/dist/adapters/responses-api.js +124 -0
- package/dist/artifacts/artifact.d.ts +31 -12
- package/dist/artifacts/artifact.d.ts.map +1 -1
- package/dist/artifacts/artifact.js +218 -188
- package/dist/artifacts/index.d.ts +15 -5
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +19 -5
- package/dist/artifacts/run-context.d.ts +3 -24
- package/dist/artifacts/run-context.d.ts.map +1 -1
- package/dist/artifacts/run-context.js +3 -39
- package/dist/bakeoff/engine.d.ts +29 -0
- package/dist/bakeoff/engine.d.ts.map +1 -1
- package/dist/bakeoff/engine.js +47 -0
- package/dist/bakeoff/eval-cases-rig.d.ts +36 -0
- package/dist/bakeoff/eval-cases-rig.d.ts.map +1 -0
- package/dist/bakeoff/eval-cases-rig.js +27 -0
- package/dist/bakeoff/eval-cases.d.ts +19 -0
- package/dist/bakeoff/eval-cases.d.ts.map +1 -1
- package/dist/bakeoff/eval-cases.js +18 -1
- package/dist/bakeoff/golden-judge.d.ts +47 -0
- package/dist/bakeoff/golden-judge.d.ts.map +1 -0
- package/dist/bakeoff/golden-judge.js +49 -0
- package/dist/bakeoff/groundedness.d.ts +58 -0
- package/dist/bakeoff/groundedness.d.ts.map +1 -0
- package/dist/bakeoff/groundedness.js +165 -0
- package/dist/bakeoff/quality.d.ts +43 -0
- package/dist/bakeoff/quality.d.ts.map +1 -1
- package/dist/bakeoff/quality.js +31 -0
- package/dist/bakeoff/replay.d.ts +11 -0
- package/dist/bakeoff/replay.d.ts.map +1 -1
- package/dist/bakeoff/replay.js +12 -0
- package/dist/bakeoff/report.d.ts +7 -0
- package/dist/bakeoff/report.d.ts.map +1 -1
- package/dist/bakeoff/report.js +26 -0
- package/dist/cli-judge.d.ts +12 -0
- package/dist/cli-judge.d.ts.map +1 -0
- package/dist/cli-judge.js +48 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +22 -42
- package/dist/config.d.ts +85 -29
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +109 -47
- package/dist/detect/detector.d.ts +4 -2
- package/dist/detect/detector.d.ts.map +1 -1
- package/dist/detect/safe-harbor.d.ts +57 -0
- package/dist/detect/safe-harbor.d.ts.map +1 -0
- package/dist/detect/safe-harbor.js +278 -0
- package/dist/doctor-cli.d.ts +7 -0
- package/dist/doctor-cli.d.ts.map +1 -0
- package/dist/doctor-cli.js +67 -0
- package/dist/doctor-preflight.d.ts +52 -0
- package/dist/doctor-preflight.d.ts.map +1 -0
- package/dist/doctor-preflight.js +112 -0
- package/dist/feedback/coverage.d.ts +11 -8
- package/dist/feedback/coverage.d.ts.map +1 -1
- package/dist/feedback/coverage.js +29 -16
- package/dist/feedback/grade.d.ts +58 -0
- package/dist/feedback/grade.d.ts.map +1 -0
- package/dist/feedback/grade.js +67 -0
- package/dist/gateway/http-protocol.d.ts +20 -1
- package/dist/gateway/http-protocol.d.ts.map +1 -1
- package/dist/gateway/http-protocol.js +1 -1
- package/dist/gateway/serve-client.d.ts +99 -0
- package/dist/gateway/serve-client.d.ts.map +1 -0
- package/dist/gateway/serve-client.js +360 -0
- package/dist/index.d.ts +68 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +167 -46
- package/dist/init/observe-cli.js +1 -1
- package/dist/init/observe.d.ts +2 -2
- package/dist/init/observe.d.ts.map +1 -1
- package/dist/init/observe.js +11 -7
- package/dist/mask/arm.d.ts +112 -0
- package/dist/mask/arm.d.ts.map +1 -0
- package/dist/mask/arm.js +179 -0
- package/dist/mask/index.d.ts +2 -0
- package/dist/mask/index.d.ts.map +1 -1
- package/dist/mask/index.js +7 -1
- package/dist/mask/mask-policy-cli.d.ts +12 -4
- package/dist/mask/mask-policy-cli.d.ts.map +1 -1
- package/dist/mask/mask-policy-cli.js +34 -9
- package/dist/prompts/manifest.d.ts +128 -0
- package/dist/prompts/manifest.d.ts.map +1 -0
- package/dist/prompts/manifest.js +214 -0
- package/dist/prompts/prompt-fetch.d.ts +84 -0
- package/dist/prompts/prompt-fetch.d.ts.map +1 -0
- package/dist/prompts/prompt-fetch.js +120 -0
- package/dist/prompts/prompt-resolve.d.ts +76 -0
- package/dist/prompts/prompt-resolve.d.ts.map +1 -0
- package/dist/prompts/prompt-resolve.js +93 -0
- package/dist/prompts/slot-resolver.d.ts +91 -0
- package/dist/prompts/slot-resolver.d.ts.map +1 -0
- package/dist/prompts/slot-resolver.js +135 -0
- package/dist/prompts/tools-register.d.ts +60 -0
- package/dist/prompts/tools-register.d.ts.map +1 -0
- package/dist/prompts/tools-register.js +48 -0
- package/dist/prompts/version-hash.d.ts +29 -0
- package/dist/prompts/version-hash.d.ts.map +1 -0
- package/dist/prompts/version-hash.js +54 -0
- package/dist/prompts-export-cli.d.ts +21 -0
- package/dist/prompts-export-cli.d.ts.map +1 -0
- package/dist/prompts-export-cli.js +130 -0
- package/dist/query/grammar.d.ts +2 -2
- package/dist/query/grammar.d.ts.map +1 -1
- package/dist/query/grammar.js +3 -1
- package/dist/query/saved.d.ts +13 -0
- package/dist/query/saved.d.ts.map +1 -1
- package/dist/query/saved.js +67 -1
- package/dist/receipts/types.d.ts +1 -1
- package/dist/receipts/types.d.ts.map +1 -1
- package/dist/receipts/types.js +1 -0
- package/dist/registry/build.d.ts +43 -1
- package/dist/registry/build.d.ts.map +1 -1
- package/dist/registry/build.js +52 -0
- package/dist/registry/cache-policy.d.ts.map +1 -1
- package/dist/registry/cache-policy.js +22 -0
- package/dist/registry/pricing-shape.d.ts +67 -8
- package/dist/registry/pricing-shape.d.ts.map +1 -1
- package/dist/registry/pricing-shape.js +50 -13
- package/dist/registry/pricing.d.ts +6 -5
- package/dist/registry/pricing.d.ts.map +1 -1
- package/dist/registry/pricing.js +9 -5
- package/dist/registry/rows.d.ts.map +1 -1
- package/dist/registry/rows.js +1 -0
- package/dist/registry/select.d.ts +6 -1
- package/dist/registry/select.d.ts.map +1 -1
- package/dist/registry/select.js +11 -0
- package/dist/routes/call-config.d.ts +199 -0
- package/dist/routes/call-config.d.ts.map +1 -0
- package/dist/routes/call-config.js +343 -0
- package/dist/routes/destination-loader.d.ts +16 -0
- package/dist/routes/destination-loader.d.ts.map +1 -0
- package/dist/routes/destination-loader.js +29 -0
- package/dist/routes/draft.d.ts +7 -0
- package/dist/routes/draft.d.ts.map +1 -1
- package/dist/routes/draft.js +12 -0
- package/dist/routes/loader.d.ts.map +1 -1
- package/dist/routes/loader.js +31 -56
- package/dist/routes/objective-loader.d.ts +12 -0
- package/dist/routes/objective-loader.d.ts.map +1 -1
- package/dist/routes/objective-loader.js +82 -0
- package/dist/routes/output-loader.d.ts +42 -0
- package/dist/routes/output-loader.d.ts.map +1 -0
- package/dist/routes/output-loader.js +112 -0
- package/dist/routes/prompt-loader.d.ts +49 -0
- package/dist/routes/prompt-loader.d.ts.map +1 -0
- package/dist/routes/prompt-loader.js +113 -0
- package/dist/routes/resolved-bundle.d.ts +69 -0
- package/dist/routes/resolved-bundle.d.ts.map +1 -1
- package/dist/routes/resolved-bundle.js +76 -0
- package/dist/routes/screen-loader.d.ts +29 -1
- package/dist/routes/screen-loader.d.ts.map +1 -1
- package/dist/routes/screen-loader.js +59 -1
- package/dist/run/accept.d.ts +5 -0
- package/dist/run/accept.d.ts.map +1 -1
- package/dist/run/accept.js +2 -0
- package/dist/run/cost.d.ts +31 -2
- package/dist/run/cost.d.ts.map +1 -1
- package/dist/run/cost.js +57 -2
- package/dist/run/destination.d.ts +39 -0
- package/dist/run/destination.d.ts.map +1 -0
- package/dist/run/destination.js +45 -0
- package/dist/run/dispatch.d.ts +67 -16
- package/dist/run/dispatch.d.ts.map +1 -1
- package/dist/run/dispatch.js +133 -29
- package/dist/run/grounding.d.ts +28 -2
- package/dist/run/grounding.d.ts.map +1 -1
- package/dist/run/grounding.js +54 -10
- package/dist/run/raw-defaults.d.ts.map +1 -1
- package/dist/run/raw-defaults.js +6 -1
- package/dist/run/raw-finalize.d.ts +50 -0
- package/dist/run/raw-finalize.d.ts.map +1 -0
- package/dist/run/raw-finalize.js +266 -0
- package/dist/run/raw-knobs.d.ts +36 -0
- package/dist/run/raw-knobs.d.ts.map +1 -0
- package/dist/run/raw-knobs.js +99 -0
- package/dist/run/raw-request.d.ts +24 -0
- package/dist/run/raw-request.d.ts.map +1 -0
- package/dist/run/raw-request.js +69 -0
- package/dist/run/raw-schema.d.ts +76 -0
- package/dist/run/raw-schema.d.ts.map +1 -0
- package/dist/run/raw-schema.js +166 -0
- package/dist/run/raw-search-cost.d.ts +48 -0
- package/dist/run/raw-search-cost.d.ts.map +1 -0
- package/dist/run/raw-search-cost.js +78 -0
- package/dist/run/raw-support.d.ts +64 -6
- package/dist/run/raw-support.d.ts.map +1 -1
- package/dist/run/raw-support.js +84 -11
- package/dist/run/raw.d.ts +25 -26
- package/dist/run/raw.d.ts.map +1 -1
- package/dist/run/raw.js +30 -351
- package/dist/run/record-attempt.d.ts +12 -0
- package/dist/run/record-attempt.d.ts.map +1 -1
- package/dist/run/record-attempt.js +30 -12
- package/dist/run/repair-attempt.d.ts +68 -0
- package/dist/run/repair-attempt.d.ts.map +1 -0
- package/dist/run/repair-attempt.js +180 -0
- package/dist/run/resolve-destination.d.ts +49 -0
- package/dist/run/resolve-destination.d.ts.map +1 -0
- package/dist/run/resolve-destination.js +76 -0
- package/dist/run/routing-docs.d.ts.map +1 -1
- package/dist/run/routing-docs.js +10 -5
- package/dist/run/run.d.ts +30 -1
- package/dist/run/run.d.ts.map +1 -1
- package/dist/run/run.js +94 -172
- package/dist/run/telemetry-row.d.ts +92 -0
- package/dist/run/telemetry-row.d.ts.map +1 -0
- package/dist/run/telemetry-row.js +81 -0
- package/dist/run/validate.d.ts +12 -1
- package/dist/run/validate.d.ts.map +1 -1
- package/dist/run/validate.js +31 -0
- package/dist/run/web-search-pricing.d.ts +43 -0
- package/dist/run/web-search-pricing.d.ts.map +1 -0
- package/dist/run/web-search-pricing.js +56 -0
- package/dist/savings/odometer.d.ts +4 -0
- package/dist/savings/odometer.d.ts.map +1 -1
- package/dist/savings/odometer.js +20 -1
- package/dist/savings/swap-execute.d.ts +7 -0
- package/dist/savings/swap-execute.d.ts.map +1 -1
- package/dist/savings/swap-execute.js +30 -0
- package/dist/savings/swaps-client.d.ts +10 -0
- package/dist/savings/swaps-client.d.ts.map +1 -1
- package/dist/screen/fixtures/probe-corpora.d.ts +23 -0
- package/dist/screen/fixtures/probe-corpora.d.ts.map +1 -0
- package/dist/screen/fixtures/probe-corpora.js +69 -0
- package/dist/screen/index.d.ts +21 -0
- package/dist/screen/index.d.ts.map +1 -0
- package/dist/screen/index.js +64 -0
- package/dist/screen/model-screen.d.ts +111 -0
- package/dist/screen/model-screen.d.ts.map +1 -0
- package/dist/screen/model-screen.js +178 -0
- package/dist/screen/patterns.d.ts +51 -0
- package/dist/screen/patterns.d.ts.map +1 -0
- package/dist/screen/patterns.js +151 -0
- package/dist/screen/phi-gate.d.ts +52 -0
- package/dist/screen/phi-gate.d.ts.map +1 -0
- package/dist/screen/phi-gate.js +86 -0
- package/dist/screen/policy.d.ts +71 -0
- package/dist/screen/policy.d.ts.map +1 -0
- package/dist/screen/policy.js +334 -0
- package/dist/screen/probe.d.ts +118 -0
- package/dist/screen/probe.d.ts.map +1 -0
- package/dist/screen/probe.js +132 -0
- package/dist/screen/screen-cli.d.ts +16 -0
- package/dist/screen/screen-cli.d.ts.map +1 -0
- package/dist/screen/screen-cli.js +178 -0
- package/dist/screen/screen.d.ts +99 -0
- package/dist/screen/screen.d.ts.map +1 -0
- package/dist/screen/screen.js +0 -0
- package/dist/screen/sidecar.d.ts +69 -0
- package/dist/screen/sidecar.d.ts.map +1 -0
- package/dist/screen/sidecar.js +145 -0
- package/dist/screen/types.d.ts +43 -2
- package/dist/screen/types.d.ts.map +1 -1
- package/dist/settings/api-fetcher.d.ts +14 -3
- package/dist/settings/api-fetcher.d.ts.map +1 -1
- package/dist/settings/api-fetcher.js +61 -10
- package/dist/settings/grading-guide.d.ts +102 -0
- package/dist/settings/grading-guide.d.ts.map +1 -0
- package/dist/settings/grading-guide.js +23 -0
- package/dist/settings/index.d.ts +3 -2
- package/dist/settings/index.d.ts.map +1 -1
- package/dist/settings/index.js +2 -1
- package/dist/settings/task-settings.d.ts +44 -7
- package/dist/settings/task-settings.d.ts.map +1 -1
- package/dist/settings/task-settings.js +53 -12
- package/dist/status.d.ts +32 -20
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +51 -30
- package/dist/telemetry/artifact-store.d.ts +5 -6
- package/dist/telemetry/artifact-store.d.ts.map +1 -1
- package/dist/telemetry/artifact-store.js +21 -24
- package/dist/telemetry/attempt-meta.d.ts +76 -1
- package/dist/telemetry/attempt-meta.d.ts.map +1 -1
- package/dist/telemetry/attempt-meta.js +33 -1
- package/dist/telemetry/exporter-setup.d.ts +2 -0
- package/dist/telemetry/exporter-setup.d.ts.map +1 -1
- package/dist/telemetry/exporter-setup.js +6 -1
- package/dist/telemetry/exporter.d.ts +2 -2
- package/dist/telemetry/exporter.d.ts.map +1 -1
- package/dist/telemetry/exporter.js +22 -41
- package/dist/telemetry/grade-mappers.d.ts +25 -0
- package/dist/telemetry/grade-mappers.d.ts.map +1 -0
- package/dist/telemetry/grade-mappers.js +64 -0
- package/dist/telemetry/grades-sql.d.ts +56 -0
- package/dist/telemetry/grades-sql.d.ts.map +1 -0
- package/dist/telemetry/grades-sql.js +156 -0
- package/dist/telemetry/ingest-protocol.d.ts +55 -48
- package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
- package/dist/telemetry/ingest-protocol.js +48 -83
- package/dist/telemetry/org-identity.d.ts +44 -0
- package/dist/telemetry/org-identity.d.ts.map +1 -0
- package/dist/telemetry/org-identity.js +98 -0
- package/dist/telemetry/route-registration.d.ts +48 -0
- package/dist/telemetry/route-registration.d.ts.map +1 -0
- package/dist/telemetry/route-registration.js +77 -0
- package/dist/telemetry/sinks.d.ts +10 -1
- package/dist/telemetry/sinks.d.ts.map +1 -1
- package/dist/telemetry/sinks.js +52 -6
- package/dist/telemetry/store-migrations.d.ts.map +1 -1
- package/dist/telemetry/store-migrations.js +64 -0
- package/dist/telemetry/store.d.ts +9 -6
- package/dist/telemetry/store.d.ts.map +1 -1
- package/dist/telemetry/store.js +8 -50
- package/dist/tenancy/api-key-format.d.ts +45 -1
- package/dist/tenancy/api-key-format.d.ts.map +1 -1
- package/dist/tenancy/api-key-format.js +50 -1
- package/dist/types/provider.d.ts +23 -3
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/types/provider.js +26 -0
- package/dist/types/route.d.ts +154 -2
- package/dist/types/route.d.ts.map +1 -1
- package/dist/types/telemetry.d.ts +73 -48
- package/dist/types/telemetry.d.ts.map +1 -1
- package/dist/validate-cli.d.ts.map +1 -1
- package/dist/validate-cli.js +32 -0
- package/dist/verify/verify.d.ts +5 -0
- package/dist/verify/verify.d.ts.map +1 -1
- package/dist/verify/verify.js +2 -0
- package/dist/watch/evaluate.d.ts +84 -1
- package/dist/watch/evaluate.d.ts.map +1 -1
- package/dist/watch/evaluate.js +28 -0
- package/dist/watch/monitor.d.ts +8 -2
- package/dist/watch/monitor.d.ts.map +1 -1
- package/dist/watch/monitor.js +13 -5
- package/dist/watch/regret-monitor-cli.d.ts +16 -0
- package/dist/watch/regret-monitor-cli.d.ts.map +1 -0
- package/dist/watch/regret-monitor-cli.js +137 -0
- package/dist/watch/regret-monitor.d.ts +168 -0
- package/dist/watch/regret-monitor.d.ts.map +1 -0
- package/dist/watch/regret-monitor.js +304 -0
- package/dist/watch/upgrade.d.ts +62 -0
- package/dist/watch/upgrade.d.ts.map +1 -0
- package/dist/watch/upgrade.js +57 -0
- package/docs/agent-skill/SKILL.md +181 -9
- package/docs/how-it-fits.md +3 -2
- package/docs/instrumentation.md +219 -46
- package/docs/llms.txt +158 -35
- package/docs/managed-serving.md +150 -0
- package/docs/mcp-oracle.md +322 -0
- package/docs/migration-playbook.md +5 -4
- package/docs/quickstart.md +263 -89
- package/package.json +18 -4
- package/registry/leaderboard.json +74 -0
- package/registry/registry.json +232 -112
- package/screen.d.ts +16 -0
- package/templates/call-disposition-qa.json +77 -0
- package/templates/catalog-cleansing.json +77 -0
- package/templates/compliance-review.json +76 -0
- package/templates/cs-next-action.json +76 -0
- package/templates/document-extraction.json +78 -0
- package/templates/financial-classification.json +75 -0
- package/templates/lead-qualification.json +76 -0
- package/templates/medical-classification.json +71 -0
- package/templates/ticket-triage.json +76 -0
- package/dist/feedback/feedback.d.ts +0 -35
- package/dist/feedback/feedback.d.ts.map +0 -1
- package/dist/feedback/feedback.js +0 -39
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.runStoreMigrations = runStoreMigrations;
|
|
14
|
+
const grades_sql_1 = require("./grades-sql");
|
|
14
15
|
/** Apply every pending schema migration to an open telemetry database. Safe to
|
|
15
16
|
* call on every open (idempotent). */
|
|
16
17
|
function runStoreMigrations(db) {
|
|
@@ -142,4 +143,67 @@ function runStoreMigrations(db) {
|
|
|
142
143
|
}
|
|
143
144
|
db.pragma("user_version = 13");
|
|
144
145
|
}
|
|
146
|
+
// v14 (grade primitive, R1): the unified `grades` table + a one-time backfill
|
|
147
|
+
// from the local `feedback` table (the local mirror of migration 00070). The
|
|
148
|
+
// table itself comes from SCHEMA_SQL's CREATE IF NOT EXISTS (a no-op on
|
|
149
|
+
// migrating databases); this rung backfills existing feedback rows so a
|
|
150
|
+
// pre-grade database's verdicts still export as grades. The evaluations
|
|
151
|
+
// backfill lives in artifact-store.ts (it owns that table). INSERT OR IGNORE
|
|
152
|
+
// makes the backfill idempotent even if it races a live write. Additive.
|
|
153
|
+
if (db.pragma("user_version", { simple: true }) < 14) {
|
|
154
|
+
(0, grades_sql_1.backfillGradesFromFeedback)(db);
|
|
155
|
+
db.pragma("user_version = 14");
|
|
156
|
+
}
|
|
157
|
+
// v15 (grade primitive GP-2, mirrors migration 00072): drop the three GP-1-only
|
|
158
|
+
// compat columns `legacy_score`, `origin`, `label` from the local `grades` table,
|
|
159
|
+
// folding any `label` into `scale_label` first. SQLite cannot DROP COLUMN when a
|
|
160
|
+
// CHECK constraint references the column (`origin` has one), so this rebuilds the
|
|
161
|
+
// table into the new shape (= GRADES_TABLE_SQL) and copies the surviving columns.
|
|
162
|
+
// Idempotent: guarded on the presence of the `origin` column, so a re-open no-ops.
|
|
163
|
+
if (db.pragma("user_version", { simple: true }) < 15) {
|
|
164
|
+
const gradeCols = db.pragma("table_info(grades)");
|
|
165
|
+
const hasGrades = gradeCols.length > 0;
|
|
166
|
+
const hasOrigin = gradeCols.some((c) => c.name === "origin");
|
|
167
|
+
if (hasGrades && hasOrigin) {
|
|
168
|
+
db.exec(`
|
|
169
|
+
CREATE TABLE grades_gp2 (
|
|
170
|
+
id TEXT PRIMARY KEY,
|
|
171
|
+
ts TEXT,
|
|
172
|
+
subject_kind TEXT NOT NULL CHECK (subject_kind IN ('inference','run','artifact')),
|
|
173
|
+
subject_id TEXT NOT NULL,
|
|
174
|
+
score REAL NOT NULL,
|
|
175
|
+
scale_max REAL,
|
|
176
|
+
scale_label TEXT,
|
|
177
|
+
comment TEXT,
|
|
178
|
+
kind TEXT NOT NULL CHECK (kind IN ('human','model-judge','deterministic')),
|
|
179
|
+
grader TEXT,
|
|
180
|
+
source TEXT,
|
|
181
|
+
org_id TEXT,
|
|
182
|
+
created_by TEXT
|
|
183
|
+
);
|
|
184
|
+
INSERT OR IGNORE INTO grades_gp2
|
|
185
|
+
(id, ts, subject_kind, subject_id, score, scale_max, scale_label, comment, kind, grader, source, org_id, created_by)
|
|
186
|
+
SELECT
|
|
187
|
+
id, ts, subject_kind, subject_id, score, scale_max, COALESCE(scale_label, label), comment, kind, grader, source, org_id, created_by
|
|
188
|
+
FROM grades;
|
|
189
|
+
DROP TABLE grades;
|
|
190
|
+
ALTER TABLE grades_gp2 RENAME TO grades;
|
|
191
|
+
CREATE INDEX IF NOT EXISTS idx_grades_subject ON grades (subject_kind, subject_id);
|
|
192
|
+
`);
|
|
193
|
+
}
|
|
194
|
+
db.pragma("user_version = 15");
|
|
195
|
+
}
|
|
196
|
+
// v16 (call-qa F4): the per-criterion `criteria` column on the local `grades`
|
|
197
|
+
// table — a JSON breakdown a HUMAN scorecard carries so it can ride the wire
|
|
198
|
+
// to the server's `grade_criteria` (kind=human). Additive, nullable; old rows
|
|
199
|
+
// read null ("a single-score grade, or recorded before F4"). SCHEMA_SQL's
|
|
200
|
+
// CREATE handles a fresh database; this ALTER-if-absent gives a migrating one
|
|
201
|
+
// the column. Same pattern as v6/v13.
|
|
202
|
+
if (db.pragma("user_version", { simple: true }) < 16) {
|
|
203
|
+
const gradeCols = db.prepare("PRAGMA table_info(grades)").all();
|
|
204
|
+
if (gradeCols.length > 0 && !gradeCols.some((c) => c.name === "criteria")) {
|
|
205
|
+
db.exec("ALTER TABLE grades ADD COLUMN criteria TEXT");
|
|
206
|
+
}
|
|
207
|
+
db.pragma("user_version = 16");
|
|
208
|
+
}
|
|
145
209
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* separate handle. ExportableTelemetryStore MUST NOT gain capture accessors;
|
|
10
10
|
* the export-isolation tests are the tripwire.
|
|
11
11
|
*/
|
|
12
|
-
import type { EnvelopeRow,
|
|
12
|
+
import type { EnvelopeRow, GradeRow, RunRow, StepRow, TelemetryRow, TelemetryStore } from "../types/telemetry";
|
|
13
13
|
import { type EndpointHealth } from "./health";
|
|
14
14
|
/**
|
|
15
15
|
* Superset of the TelemetryStore contract with the enumeration hooks the
|
|
@@ -23,10 +23,15 @@ export interface ExportableTelemetryStore extends TelemetryStore {
|
|
|
23
23
|
rowid: number;
|
|
24
24
|
row: TelemetryRow;
|
|
25
25
|
}>;
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/** Record a unified judgment (grade primitive, R1) — the canonical write path
|
|
27
|
+
* for `rig.grade`. Writes the shared local `grades` table. */
|
|
28
|
+
recordGrade(row: GradeRow): void;
|
|
29
|
+
/** Grade rows past the watermark, oldest first (grade primitive `:grades`
|
|
30
|
+
* stream). Reads grades written by EITHER handle (telemetry + artifact) — one
|
|
31
|
+
* physical table over the shared telemetry file. */
|
|
32
|
+
readGradesAfter(afterRowid: number, limit: number): Array<{
|
|
28
33
|
rowid: number;
|
|
29
|
-
row:
|
|
34
|
+
row: GradeRow;
|
|
30
35
|
}>;
|
|
31
36
|
/** Record a run (E2 chunk A) — run.start/run.end. Upsert: run.end overwrites
|
|
32
37
|
* the running projection with its terminal status/ended_at. */
|
|
@@ -47,8 +52,6 @@ export interface ExportableTelemetryStore extends TelemetryStore {
|
|
|
47
52
|
* non-null inference_id, or null (E4 chunk A: bake-off rehydration resolves an
|
|
48
53
|
* eval case's source step to the inference that keys its captured input). */
|
|
49
54
|
getStepInferenceId(runId: string, stepKey: string): string | null;
|
|
50
|
-
/** Newest-first local feedback read (console/dev inspection). */
|
|
51
|
-
listFeedback(limit: number): FeedbackRow[];
|
|
52
55
|
listEnvelopes(): EnvelopeRow[];
|
|
53
56
|
/** Local exporter watermark (per source instance), 0 when unset. */
|
|
54
57
|
getExportWatermark(sourceId: string): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/telemetry/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EACV,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/telemetry/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EACN,OAAO,EACP,YAAY,EACZ,cAAc,EACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAA2B,KAAK,cAAc,EAAuB,MAAM,UAAU,CAAC;AAU7F;;;;;GAKG;AACH,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,qEAAqE;IACrE,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,YAAY,CAAA;KAAE,CAAC,CAAC;IACpG;kEAC8D;IAC9D,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC;;wDAEoD;IACpD,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAC;IAC5F;mEAC+D;IAC/D,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iFAAiF;IACjF,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,kEAAkE;IAClE,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxF,mEAAmE;IACnE,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC1F;;iFAE6E;IAC7E,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClE,aAAa,IAAI,WAAW,EAAE,CAAC;IAC/B,oEAAoE;IACpE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7C,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9D;;;;;OAKG;IACH,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE,CAAC;CAC3E;AAgSD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,wBAAwB,CA6P3E"}
|
package/dist/telemetry/store.js
CHANGED
|
@@ -20,6 +20,7 @@ const node_fs_1 = require("node:fs");
|
|
|
20
20
|
const node_path_1 = require("node:path");
|
|
21
21
|
const health_1 = require("./health");
|
|
22
22
|
const store_migrations_1 = require("./store-migrations");
|
|
23
|
+
const grades_sql_1 = require("./grades-sql");
|
|
23
24
|
const SCHEMA_SQL = `
|
|
24
25
|
CREATE TABLE IF NOT EXISTS inferences (
|
|
25
26
|
id TEXT PRIMARY KEY,
|
|
@@ -154,7 +155,7 @@ CREATE TABLE IF NOT EXISTS steps (
|
|
|
154
155
|
PRIMARY KEY (run_id, step_key, attempt_no)
|
|
155
156
|
);
|
|
156
157
|
CREATE INDEX IF NOT EXISTS idx_steps_run ON steps (run_id);
|
|
157
|
-
`;
|
|
158
|
+
${grades_sql_1.GRADES_TABLE_SQL}`;
|
|
158
159
|
function toRunRow(r) {
|
|
159
160
|
return {
|
|
160
161
|
id: r.id,
|
|
@@ -185,25 +186,6 @@ function toStepRow(r) {
|
|
|
185
186
|
failureClass: r.failure_class,
|
|
186
187
|
};
|
|
187
188
|
}
|
|
188
|
-
function toFeedbackRow(r) {
|
|
189
|
-
return {
|
|
190
|
-
id: r.id,
|
|
191
|
-
ts: r.ts,
|
|
192
|
-
inferenceId: r.inference_id,
|
|
193
|
-
episodeKey: r.episode_key,
|
|
194
|
-
verdict: r.verdict,
|
|
195
|
-
score: r.score,
|
|
196
|
-
note: r.note,
|
|
197
|
-
source: r.source,
|
|
198
|
-
// `?? null` rather than a bare read: a v6 database returns `undefined`
|
|
199
|
-
// for a column that did not exist when its rows were written, and
|
|
200
|
-
// `undefined` would serialize to a MISSING key on the wire rather than an
|
|
201
|
-
// explicit null — which reads to the server as "no opinion" instead of
|
|
202
|
-
// "no org", a distinction that matters exactly once and expensively.
|
|
203
|
-
orgId: r.org_id ?? null,
|
|
204
|
-
createdBy: r.created_by ?? null,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
189
|
function toTelemetryRow(r) {
|
|
208
190
|
return {
|
|
209
191
|
id: r.id,
|
|
@@ -288,14 +270,6 @@ function openTelemetryStore(dbPath) {
|
|
|
288
270
|
INSERT INTO envelopes (envelope_key, budget_usd, spent_usd, status)
|
|
289
271
|
VALUES (?, ?, 0, 'open')
|
|
290
272
|
ON CONFLICT (envelope_key) DO NOTHING
|
|
291
|
-
`);
|
|
292
|
-
const insertFeedback = db.prepare(`
|
|
293
|
-
INSERT INTO feedback (
|
|
294
|
-
id, ts, inference_id, episode_key, verdict, score, note, source, org_id, created_by
|
|
295
|
-
)
|
|
296
|
-
VALUES (
|
|
297
|
-
@id, @ts, @inference_id, @episode_key, @verdict, @score, @note, @source, @org_id, @created_by
|
|
298
|
-
)
|
|
299
273
|
`);
|
|
300
274
|
const accrueEnvelope = db.prepare(`
|
|
301
275
|
UPDATE envelopes
|
|
@@ -321,6 +295,7 @@ function openTelemetryStore(dbPath) {
|
|
|
321
295
|
export_seq = excluded.export_seq,
|
|
322
296
|
meta_json = excluded.meta_json
|
|
323
297
|
`);
|
|
298
|
+
const insertGrade = (0, grades_sql_1.prepareGradeInsert)(db);
|
|
324
299
|
const insertStep = db.prepare(`
|
|
325
300
|
INSERT OR IGNORE INTO steps (
|
|
326
301
|
run_id, step_key, attempt_no, task, provenance, inference_id, span_trace_id, span_id,
|
|
@@ -374,25 +349,14 @@ function openTelemetryStore(dbPath) {
|
|
|
374
349
|
mask_json: row.mask != null ? JSON.stringify(row.mask) : null,
|
|
375
350
|
});
|
|
376
351
|
},
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
id: row.id,
|
|
380
|
-
ts: row.ts,
|
|
381
|
-
inference_id: row.inferenceId,
|
|
382
|
-
episode_key: row.episodeKey,
|
|
383
|
-
verdict: row.verdict,
|
|
384
|
-
score: row.score,
|
|
385
|
-
note: row.note,
|
|
386
|
-
source: row.source,
|
|
387
|
-
org_id: row.orgId,
|
|
388
|
-
created_by: row.createdBy,
|
|
389
|
-
});
|
|
352
|
+
recordGrade(row) {
|
|
353
|
+
insertGrade.run((0, grades_sql_1.gradeBindParams)(row));
|
|
390
354
|
},
|
|
391
|
-
|
|
355
|
+
readGradesAfter(afterRowid, limit) {
|
|
392
356
|
const rows = db
|
|
393
|
-
.prepare("SELECT rowid AS __rowid, * FROM
|
|
357
|
+
.prepare("SELECT rowid AS __rowid, * FROM grades WHERE rowid > ? ORDER BY rowid LIMIT ?")
|
|
394
358
|
.all(afterRowid, limit);
|
|
395
|
-
return rows.map((r) => ({ rowid: r.__rowid, row:
|
|
359
|
+
return rows.map((r) => ({ rowid: r.__rowid, row: (0, grades_sql_1.toGradeRow)(r) }));
|
|
396
360
|
},
|
|
397
361
|
recordRun(row) {
|
|
398
362
|
const seq = nextRunSeq.get().n;
|
|
@@ -446,12 +410,6 @@ function openTelemetryStore(dbPath) {
|
|
|
446
410
|
.get(runId, stepKey);
|
|
447
411
|
return r === undefined ? null : r.inference_id;
|
|
448
412
|
},
|
|
449
|
-
listFeedback(limit) {
|
|
450
|
-
const rows = db
|
|
451
|
-
.prepare("SELECT * FROM feedback ORDER BY ts DESC, rowid DESC LIMIT ?")
|
|
452
|
-
.all(limit);
|
|
453
|
-
return rows.map(toFeedbackRow);
|
|
454
|
-
},
|
|
455
413
|
queryByTag(tag, value) {
|
|
456
414
|
return selectByTag.all(tag, value).map(toTelemetryRow);
|
|
457
415
|
},
|
|
@@ -38,8 +38,52 @@ export declare const API_KEY_BODY_MIN_LENGTH = 43;
|
|
|
38
38
|
* (capture / artifacts / content / scrub). Held by a coding agent flipping
|
|
39
39
|
* settings for the user. READING settings needs no scope — any org-scoped key
|
|
40
40
|
* may read, since settings ride the already-readable task row.
|
|
41
|
+
*
|
|
42
|
+
* `route-config` (live-routing-evals, 00063): PATCH a route's live call-config
|
|
43
|
+
* (which model/provider + sampling; POST rollback). Held by a coding agent
|
|
44
|
+
* editing routing for the user. READING call-config needs no scope — it rides
|
|
45
|
+
* the already-readable route + config rows (contrast: a write is an actuation).
|
|
46
|
+
*
|
|
47
|
+
* `org-settings` (content-capture Phase 2, 00065): PATCH an org's governance
|
|
48
|
+
* settings (artifact_posture / telemetry_posture / contribution — the org-wide
|
|
49
|
+
* content-custody + telemetry master gate). The KEY/API twin of the Phase-1
|
|
50
|
+
* console posture control. Owner-only to MINT (stricter than the admin/owner
|
|
51
|
+
* gate on decision/oracle-act — a key delegates what its creator has, and only
|
|
52
|
+
* an owner may flip org-wide governance) and owner-only to WRITE. READING org
|
|
53
|
+
* settings needs no scope — any org-scoped key may read, since they ride the
|
|
54
|
+
* already-readable orgs row.
|
|
55
|
+
*
|
|
56
|
+
* `serve` (managed-serving-keyless K2, 00084): SERVE a managed inference on the
|
|
57
|
+
* hosted gateway's MANAGED mirror lane (`POST /v1/chat/completions` resolving an
|
|
58
|
+
* org's mirrored route against OUR managed provider keys). This is the first-class
|
|
59
|
+
* inference authority the mirror lane was always meant to gate on — it replaces the
|
|
60
|
+
* overloaded `oracle-act` placeholder there (gateway-routes.ts flagged that as an
|
|
61
|
+
* interim stand-in for a real inference/serve scope). It is an ORDINARY machine
|
|
62
|
+
* grant (not owner-only to mint): serving is a delegated coding-agent act, like
|
|
63
|
+
* `route-config`/`prompt-write`, not a money/deletion authority. It is DISTINCT
|
|
64
|
+
* from per-org PROVISIONING: a key may carry `serve` and still be refused because
|
|
65
|
+
* the org is not provisioned for managed serving (orgs.managed_serving_enabled,
|
|
66
|
+
* 00085) — the scope says "this key may serve", the column says "this org may".
|
|
67
|
+
* During the K2 deprecation window the mirror lane still ALSO accepts `oracle-act`
|
|
68
|
+
* so keys minted before the remint keep working; that acceptance is removed once
|
|
69
|
+
* keys are reminted with `serve`.
|
|
70
|
+
*
|
|
71
|
+
* `artifact-delete` (CD-1 / R-7, 00068): DELETE an org's own stored artifact
|
|
72
|
+
* CONTENT (`DELETE /v1/artifacts/:id/content`) or PURGE the record
|
|
73
|
+
* (`DELETE /v1/artifacts/:id`). Held by an automation deleting on the org's
|
|
74
|
+
* behalf — the machine twin of the console's owner-only delete controls.
|
|
75
|
+
*
|
|
76
|
+
* **This is the most dangerous grant in the set, and it is dangerous for a
|
|
77
|
+
* structural reason the others are not:** every other scope's damage is
|
|
78
|
+
* recoverable or additive, and every other consequential act ALSO has a role
|
|
79
|
+
* gate behind it. Deletion is irreversible, and a key has no role — so for the
|
|
80
|
+
* machine path this scope is not *a* gate, it is the *only* gate. It is
|
|
81
|
+
* therefore owner-only to MINT (`OWNER_ONLY_SCOPES` in modelrig-server's
|
|
82
|
+
* key-admin, alongside `org-settings`): if a member could mint it, the
|
|
83
|
+
* owner-only session gate on the routes would be decorative, since the cheapest
|
|
84
|
+
* way past a role check would be to issue yourself a credential that has none.
|
|
41
85
|
*/
|
|
42
|
-
export declare const API_KEY_SCOPES: readonly ["ingest", "query", "
|
|
86
|
+
export declare const API_KEY_SCOPES: readonly ["ingest", "query", "grade", "decision", "oracle-act", "artifact-write", "artifact-read", "task-settings", "route-config", "org-settings", "artifact-delete", "prompt-write", "serve"];
|
|
43
87
|
export type ApiKeyScope = (typeof API_KEY_SCOPES)[number];
|
|
44
88
|
/** sha256 of the WHOLE presented string, prefix included — so a caller cannot
|
|
45
89
|
* strip the prefix and land on a different row. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-key-format.d.ts","sourceRoot":"","sources":["../../src/tenancy/api-key-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;;GAGG;AACH,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC;;6EAE6E;AAC7E,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,oFAAoF;AACpF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"api-key-format.d.ts","sourceRoot":"","sources":["../../src/tenancy/api-key-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;;GAGG;AACH,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC;;6EAE6E;AAC7E,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,oFAAoF;AACpF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,eAAO,MAAM,cAAc,iMAcjB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D;mDACmD;AACnD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAI1D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,EAAE,CAIvD;AAED;gEACgE;AAChE,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAExF"}
|
|
@@ -47,16 +47,65 @@ exports.API_KEY_BODY_MIN_LENGTH = 43;
|
|
|
47
47
|
* (capture / artifacts / content / scrub). Held by a coding agent flipping
|
|
48
48
|
* settings for the user. READING settings needs no scope — any org-scoped key
|
|
49
49
|
* may read, since settings ride the already-readable task row.
|
|
50
|
+
*
|
|
51
|
+
* `route-config` (live-routing-evals, 00063): PATCH a route's live call-config
|
|
52
|
+
* (which model/provider + sampling; POST rollback). Held by a coding agent
|
|
53
|
+
* editing routing for the user. READING call-config needs no scope — it rides
|
|
54
|
+
* the already-readable route + config rows (contrast: a write is an actuation).
|
|
55
|
+
*
|
|
56
|
+
* `org-settings` (content-capture Phase 2, 00065): PATCH an org's governance
|
|
57
|
+
* settings (artifact_posture / telemetry_posture / contribution — the org-wide
|
|
58
|
+
* content-custody + telemetry master gate). The KEY/API twin of the Phase-1
|
|
59
|
+
* console posture control. Owner-only to MINT (stricter than the admin/owner
|
|
60
|
+
* gate on decision/oracle-act — a key delegates what its creator has, and only
|
|
61
|
+
* an owner may flip org-wide governance) and owner-only to WRITE. READING org
|
|
62
|
+
* settings needs no scope — any org-scoped key may read, since they ride the
|
|
63
|
+
* already-readable orgs row.
|
|
64
|
+
*
|
|
65
|
+
* `serve` (managed-serving-keyless K2, 00084): SERVE a managed inference on the
|
|
66
|
+
* hosted gateway's MANAGED mirror lane (`POST /v1/chat/completions` resolving an
|
|
67
|
+
* org's mirrored route against OUR managed provider keys). This is the first-class
|
|
68
|
+
* inference authority the mirror lane was always meant to gate on — it replaces the
|
|
69
|
+
* overloaded `oracle-act` placeholder there (gateway-routes.ts flagged that as an
|
|
70
|
+
* interim stand-in for a real inference/serve scope). It is an ORDINARY machine
|
|
71
|
+
* grant (not owner-only to mint): serving is a delegated coding-agent act, like
|
|
72
|
+
* `route-config`/`prompt-write`, not a money/deletion authority. It is DISTINCT
|
|
73
|
+
* from per-org PROVISIONING: a key may carry `serve` and still be refused because
|
|
74
|
+
* the org is not provisioned for managed serving (orgs.managed_serving_enabled,
|
|
75
|
+
* 00085) — the scope says "this key may serve", the column says "this org may".
|
|
76
|
+
* During the K2 deprecation window the mirror lane still ALSO accepts `oracle-act`
|
|
77
|
+
* so keys minted before the remint keep working; that acceptance is removed once
|
|
78
|
+
* keys are reminted with `serve`.
|
|
79
|
+
*
|
|
80
|
+
* `artifact-delete` (CD-1 / R-7, 00068): DELETE an org's own stored artifact
|
|
81
|
+
* CONTENT (`DELETE /v1/artifacts/:id/content`) or PURGE the record
|
|
82
|
+
* (`DELETE /v1/artifacts/:id`). Held by an automation deleting on the org's
|
|
83
|
+
* behalf — the machine twin of the console's owner-only delete controls.
|
|
84
|
+
*
|
|
85
|
+
* **This is the most dangerous grant in the set, and it is dangerous for a
|
|
86
|
+
* structural reason the others are not:** every other scope's damage is
|
|
87
|
+
* recoverable or additive, and every other consequential act ALSO has a role
|
|
88
|
+
* gate behind it. Deletion is irreversible, and a key has no role — so for the
|
|
89
|
+
* machine path this scope is not *a* gate, it is the *only* gate. It is
|
|
90
|
+
* therefore owner-only to MINT (`OWNER_ONLY_SCOPES` in modelrig-server's
|
|
91
|
+
* key-admin, alongside `org-settings`): if a member could mint it, the
|
|
92
|
+
* owner-only session gate on the routes would be decorative, since the cheapest
|
|
93
|
+
* way past a role check would be to issue yourself a credential that has none.
|
|
50
94
|
*/
|
|
51
95
|
exports.API_KEY_SCOPES = [
|
|
52
96
|
"ingest",
|
|
53
97
|
"query",
|
|
54
|
-
"
|
|
98
|
+
"grade",
|
|
55
99
|
"decision",
|
|
56
100
|
"oracle-act",
|
|
57
101
|
"artifact-write",
|
|
58
102
|
"artifact-read",
|
|
59
103
|
"task-settings",
|
|
104
|
+
"route-config",
|
|
105
|
+
"org-settings",
|
|
106
|
+
"artifact-delete",
|
|
107
|
+
"prompt-write",
|
|
108
|
+
"serve",
|
|
60
109
|
];
|
|
61
110
|
/** sha256 of the WHOLE presented string, prefix included — so a caller cannot
|
|
62
111
|
* strip the prefix and land on a different row. */
|
package/dist/types/provider.d.ts
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { RigFailure } from "./failures";
|
|
7
7
|
import type { AttemptMetaV1 } from "../telemetry/attempt-meta";
|
|
8
|
-
export type ProviderId = "gemini" | "openai" | "deepseek" | "anthropic" | "grok" | "deepinfra" | "fireworks";
|
|
8
|
+
export type ProviderId = "gemini" | "openai" | "deepseek" | "anthropic" | "grok" | "deepinfra" | "fireworks" | "zai";
|
|
9
9
|
/** Runtime enumeration of every ProviderId — the single list a raw-model lane
|
|
10
10
|
* (`provider/model`) validates against (http gateway spec §3.3). Kept in sync
|
|
11
11
|
* with the `ProviderId` union by the two compile-time assertions below: adding
|
|
12
12
|
* a provider to the union without adding it here (or vice-versa) fails the
|
|
13
13
|
* type-check. */
|
|
14
|
-
export declare const PROVIDER_IDS: readonly ["gemini", "openai", "deepseek", "anthropic", "grok", "deepinfra", "fireworks"];
|
|
14
|
+
export declare const PROVIDER_IDS: readonly ["gemini", "openai", "deepseek", "anthropic", "grok", "deepinfra", "fireworks", "zai"];
|
|
15
15
|
export type CapabilityFlag = "structured_native" | "json_mode" | "grounded_native" | "context_cache_explicit" | "prompt_cache_key" | "prefix_cache_implicit" | "tier_flex" | "trace_visible" | "zero_retention";
|
|
16
16
|
/** The canonical flag enumeration — the single list every static capability
|
|
17
17
|
* materialization iterates (index.ts, template validation, tests). */
|
|
@@ -27,6 +27,9 @@ export type UntrustedBlockShape = "tool_result" | "user_json";
|
|
|
27
27
|
/** The untrusted-block shape for a provider; `user_json` for any provider that
|
|
28
28
|
* does not declare a preference. */
|
|
29
29
|
export declare function untrustedBlockFor(provider: ProviderId): UntrustedBlockShape;
|
|
30
|
+
/** Whether `quarantine` can gate tool calls via `tool_choice: "none"` on this
|
|
31
|
+
* provider (else the run drops + counts them post-dispatch, A7). */
|
|
32
|
+
export declare function toolChoiceNoneCapable(provider: ProviderId): boolean;
|
|
30
33
|
declare const candidateBrand: unique symbol;
|
|
31
34
|
/**
|
|
32
35
|
* A (provider, model) pair validated against a route's candidate list.
|
|
@@ -109,7 +112,9 @@ export interface AdapterRequest {
|
|
|
109
112
|
readonly candidate: CandidateRef;
|
|
110
113
|
readonly systemPrompt: string;
|
|
111
114
|
readonly userPrompt: string;
|
|
112
|
-
/** JSON Schema for native structured output; null => prompt/json_mode path.
|
|
115
|
+
/** JSON Schema for native structured output; null => prompt/json_mode path.
|
|
116
|
+
* Set by the routed lane from the bundle's `schema`, and by the raw lane from
|
|
117
|
+
* a declared `RawRunInput.responseSchema` (R2) — the SAME adapter path. */
|
|
113
118
|
readonly outputSchema: object | null;
|
|
114
119
|
readonly requestedTier: ServiceTier;
|
|
115
120
|
readonly timeoutMs: number;
|
|
@@ -211,6 +216,21 @@ export type AdapterResult = {
|
|
|
211
216
|
* A tool-call turn carries these instead of (or alongside) `text`; the
|
|
212
217
|
* run loop surfaces them and does NOT schema-validate the turn. */
|
|
213
218
|
readonly toolCalls?: readonly ToolCall[];
|
|
219
|
+
/** Native web-grounding citations (Native Web Search lane, spec N2) —
|
|
220
|
+
* present only on a grounded Responses-API attempt (openai/grok), in the
|
|
221
|
+
* inject rung's `url_citation` shape (run/grounding.ts). ADDITIVE: absent on
|
|
222
|
+
* every non-grounded call, so nothing else changes. The raw lane surfaces
|
|
223
|
+
* these on `RunMeta.citations`; a zero-citation grounded response carries an
|
|
224
|
+
* empty array (surfaced, never thrown). */
|
|
225
|
+
readonly citations?: readonly {
|
|
226
|
+
readonly type: "url_citation";
|
|
227
|
+
readonly url: string;
|
|
228
|
+
readonly title?: string;
|
|
229
|
+
}[];
|
|
230
|
+
/** Native web_search tool calls billed on this grounded attempt (spec N3) —
|
|
231
|
+
* used by the raw success path to price the synthetic `rung:"search"` cost
|
|
232
|
+
* row. ADDITIVE: absent ⇒ the raw path assumes 1 (disclosed). */
|
|
233
|
+
readonly searchCalls?: number;
|
|
214
234
|
/** NATIVE attempt metadata (WI-1, spec §2) — finish reason, refusal,
|
|
215
235
|
* reasoning tokens, model snapshot, provider request id, sampling echo,
|
|
216
236
|
* tool-call names/counts. ADDITIVE: an adapter that reports nothing omits
|
|
@@ -1 +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;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,WAAW,GACX,MAAM,GAGN,WAAW,GACX,WAAW,CAAC;
|
|
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;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,WAAW,GACX,MAAM,GAGN,WAAW,GACX,WAAW,GAIX,KAAK,CAAC;AAEV;;;;iBAIiB;AACjB,eAAO,MAAM,YAAY,iGASf,CAAC;AAYX,MAAM,MAAM,cAAc,GACtB,mBAAmB,GACnB,WAAW,GACX,iBAAiB,GACjB,wBAAwB,GACxB,kBAAkB,GAClB,uBAAuB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|
exports.untrustedBlockFor = untrustedBlockFor;
|
|
10
|
+
exports.toolChoiceNoneCapable = toolChoiceNoneCapable;
|
|
10
11
|
/** Runtime enumeration of every ProviderId — the single list a raw-model lane
|
|
11
12
|
* (`provider/model`) validates against (http gateway spec §3.3). Kept in sync
|
|
12
13
|
* with the `ProviderId` union by the two compile-time assertions below: adding
|
|
@@ -20,6 +21,7 @@ exports.PROVIDER_IDS = [
|
|
|
20
21
|
"grok",
|
|
21
22
|
"deepinfra",
|
|
22
23
|
"fireworks",
|
|
24
|
+
"zai",
|
|
23
25
|
];
|
|
24
26
|
// Every entry is a valid ProviderId …
|
|
25
27
|
const _providerIdsAreValid = exports.PROVIDER_IDS;
|
|
@@ -47,3 +49,27 @@ const UNTRUSTED_BLOCK = {
|
|
|
47
49
|
function untrustedBlockFor(provider) {
|
|
48
50
|
return UNTRUSTED_BLOCK[provider] ?? "user_json";
|
|
49
51
|
}
|
|
52
|
+
/** Screening SC-1a (spec §4.2) — whether a provider can serve `tool_choice:
|
|
53
|
+
* "none"` so a QUARANTINED turn is prevented from actuating a tool call
|
|
54
|
+
* pre-dispatch. A provider WITHOUT parity forces the fallback: dispatch, then
|
|
55
|
+
* DROP + COUNT any tool calls in the response (A7, honest). Kept as its own
|
|
56
|
+
* additive registry map (mirrors {@link UNTRUSTED_BLOCK} / `untrustedBlockFor`)
|
|
57
|
+
* rather than a boolean `CapabilityFlag`, so the exhaustively-materialized flag
|
|
58
|
+
* union and every adapter's `supports()` stay untouched. A provider absent from
|
|
59
|
+
* the map is treated as NOT capable (fail safe — drop+count is always honest;
|
|
60
|
+
* silently trusting tool_choice:none on a provider that ignores it would not
|
|
61
|
+
* be). The screen engine takes the resolved boolean, so both paths unit-test. */
|
|
62
|
+
const TOOL_CHOICE_NONE = {
|
|
63
|
+
openai: true,
|
|
64
|
+
anthropic: true,
|
|
65
|
+
gemini: true,
|
|
66
|
+
deepseek: true,
|
|
67
|
+
grok: true,
|
|
68
|
+
// deepinfra/fireworks: aggregator hosts — parity varies per served model, so
|
|
69
|
+
// they fall back to the honest drop+count path (never a silent trust).
|
|
70
|
+
};
|
|
71
|
+
/** Whether `quarantine` can gate tool calls via `tool_choice: "none"` on this
|
|
72
|
+
* provider (else the run drops + counts them post-dispatch, A7). */
|
|
73
|
+
function toolChoiceNoneCapable(provider) {
|
|
74
|
+
return TOOL_CHOICE_NONE[provider] ?? false;
|
|
75
|
+
}
|