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.
Files changed (382) hide show
  1. package/CHANGELOG.md +324 -0
  2. package/README.md +55 -29
  3. package/data/PROVENANCE.md +14 -0
  4. package/data/pricing-map.json +26 -0
  5. package/dist/adapters/attempt-meta-map.d.ts +8 -1
  6. package/dist/adapters/attempt-meta-map.d.ts.map +1 -1
  7. package/dist/adapters/attempt-meta-map.js +4 -0
  8. package/dist/adapters/build-adapters.js +2 -2
  9. package/dist/adapters/gemini.d.ts +28 -1
  10. package/dist/adapters/gemini.d.ts.map +1 -1
  11. package/dist/adapters/gemini.js +38 -9
  12. package/dist/adapters/grok.d.ts.map +1 -1
  13. package/dist/adapters/grok.js +53 -4
  14. package/dist/adapters/openai-compat.d.ts +8 -2
  15. package/dist/adapters/openai-compat.d.ts.map +1 -1
  16. package/dist/adapters/openai-compat.js +8 -1
  17. package/dist/adapters/openai-stream.d.ts +10 -2
  18. package/dist/adapters/openai-stream.d.ts.map +1 -1
  19. package/dist/adapters/openai-stream.js +5 -1
  20. package/dist/adapters/openai.d.ts +10 -1
  21. package/dist/adapters/openai.d.ts.map +1 -1
  22. package/dist/adapters/openai.js +57 -7
  23. package/dist/adapters/responses-api.d.ts +61 -0
  24. package/dist/adapters/responses-api.d.ts.map +1 -0
  25. package/dist/adapters/responses-api.js +124 -0
  26. package/dist/artifacts/artifact.d.ts +31 -12
  27. package/dist/artifacts/artifact.d.ts.map +1 -1
  28. package/dist/artifacts/artifact.js +218 -188
  29. package/dist/artifacts/index.d.ts +15 -5
  30. package/dist/artifacts/index.d.ts.map +1 -1
  31. package/dist/artifacts/index.js +19 -5
  32. package/dist/artifacts/run-context.d.ts +3 -24
  33. package/dist/artifacts/run-context.d.ts.map +1 -1
  34. package/dist/artifacts/run-context.js +3 -39
  35. package/dist/bakeoff/engine.d.ts +29 -0
  36. package/dist/bakeoff/engine.d.ts.map +1 -1
  37. package/dist/bakeoff/engine.js +47 -0
  38. package/dist/bakeoff/eval-cases-rig.d.ts +36 -0
  39. package/dist/bakeoff/eval-cases-rig.d.ts.map +1 -0
  40. package/dist/bakeoff/eval-cases-rig.js +27 -0
  41. package/dist/bakeoff/eval-cases.d.ts +19 -0
  42. package/dist/bakeoff/eval-cases.d.ts.map +1 -1
  43. package/dist/bakeoff/eval-cases.js +18 -1
  44. package/dist/bakeoff/golden-judge.d.ts +47 -0
  45. package/dist/bakeoff/golden-judge.d.ts.map +1 -0
  46. package/dist/bakeoff/golden-judge.js +49 -0
  47. package/dist/bakeoff/groundedness.d.ts +58 -0
  48. package/dist/bakeoff/groundedness.d.ts.map +1 -0
  49. package/dist/bakeoff/groundedness.js +165 -0
  50. package/dist/bakeoff/quality.d.ts +43 -0
  51. package/dist/bakeoff/quality.d.ts.map +1 -1
  52. package/dist/bakeoff/quality.js +31 -0
  53. package/dist/bakeoff/replay.d.ts +11 -0
  54. package/dist/bakeoff/replay.d.ts.map +1 -1
  55. package/dist/bakeoff/replay.js +12 -0
  56. package/dist/bakeoff/report.d.ts +7 -0
  57. package/dist/bakeoff/report.d.ts.map +1 -1
  58. package/dist/bakeoff/report.js +26 -0
  59. package/dist/cli-judge.d.ts +12 -0
  60. package/dist/cli-judge.d.ts.map +1 -0
  61. package/dist/cli-judge.js +48 -0
  62. package/dist/cli.d.ts.map +1 -1
  63. package/dist/cli.js +22 -42
  64. package/dist/config.d.ts +85 -29
  65. package/dist/config.d.ts.map +1 -1
  66. package/dist/config.js +109 -47
  67. package/dist/detect/detector.d.ts +4 -2
  68. package/dist/detect/detector.d.ts.map +1 -1
  69. package/dist/detect/safe-harbor.d.ts +57 -0
  70. package/dist/detect/safe-harbor.d.ts.map +1 -0
  71. package/dist/detect/safe-harbor.js +278 -0
  72. package/dist/doctor-cli.d.ts +7 -0
  73. package/dist/doctor-cli.d.ts.map +1 -0
  74. package/dist/doctor-cli.js +67 -0
  75. package/dist/doctor-preflight.d.ts +52 -0
  76. package/dist/doctor-preflight.d.ts.map +1 -0
  77. package/dist/doctor-preflight.js +112 -0
  78. package/dist/feedback/coverage.d.ts +11 -8
  79. package/dist/feedback/coverage.d.ts.map +1 -1
  80. package/dist/feedback/coverage.js +29 -16
  81. package/dist/feedback/grade.d.ts +58 -0
  82. package/dist/feedback/grade.d.ts.map +1 -0
  83. package/dist/feedback/grade.js +67 -0
  84. package/dist/gateway/http-protocol.d.ts +20 -1
  85. package/dist/gateway/http-protocol.d.ts.map +1 -1
  86. package/dist/gateway/http-protocol.js +1 -1
  87. package/dist/gateway/serve-client.d.ts +99 -0
  88. package/dist/gateway/serve-client.d.ts.map +1 -0
  89. package/dist/gateway/serve-client.js +360 -0
  90. package/dist/index.d.ts +68 -29
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +167 -46
  93. package/dist/init/observe-cli.js +1 -1
  94. package/dist/init/observe.d.ts +2 -2
  95. package/dist/init/observe.d.ts.map +1 -1
  96. package/dist/init/observe.js +11 -7
  97. package/dist/mask/arm.d.ts +112 -0
  98. package/dist/mask/arm.d.ts.map +1 -0
  99. package/dist/mask/arm.js +179 -0
  100. package/dist/mask/index.d.ts +2 -0
  101. package/dist/mask/index.d.ts.map +1 -1
  102. package/dist/mask/index.js +7 -1
  103. package/dist/mask/mask-policy-cli.d.ts +12 -4
  104. package/dist/mask/mask-policy-cli.d.ts.map +1 -1
  105. package/dist/mask/mask-policy-cli.js +34 -9
  106. package/dist/prompts/manifest.d.ts +128 -0
  107. package/dist/prompts/manifest.d.ts.map +1 -0
  108. package/dist/prompts/manifest.js +214 -0
  109. package/dist/prompts/prompt-fetch.d.ts +84 -0
  110. package/dist/prompts/prompt-fetch.d.ts.map +1 -0
  111. package/dist/prompts/prompt-fetch.js +120 -0
  112. package/dist/prompts/prompt-resolve.d.ts +76 -0
  113. package/dist/prompts/prompt-resolve.d.ts.map +1 -0
  114. package/dist/prompts/prompt-resolve.js +93 -0
  115. package/dist/prompts/slot-resolver.d.ts +91 -0
  116. package/dist/prompts/slot-resolver.d.ts.map +1 -0
  117. package/dist/prompts/slot-resolver.js +135 -0
  118. package/dist/prompts/tools-register.d.ts +60 -0
  119. package/dist/prompts/tools-register.d.ts.map +1 -0
  120. package/dist/prompts/tools-register.js +48 -0
  121. package/dist/prompts/version-hash.d.ts +29 -0
  122. package/dist/prompts/version-hash.d.ts.map +1 -0
  123. package/dist/prompts/version-hash.js +54 -0
  124. package/dist/prompts-export-cli.d.ts +21 -0
  125. package/dist/prompts-export-cli.d.ts.map +1 -0
  126. package/dist/prompts-export-cli.js +130 -0
  127. package/dist/query/grammar.d.ts +2 -2
  128. package/dist/query/grammar.d.ts.map +1 -1
  129. package/dist/query/grammar.js +3 -1
  130. package/dist/query/saved.d.ts +13 -0
  131. package/dist/query/saved.d.ts.map +1 -1
  132. package/dist/query/saved.js +67 -1
  133. package/dist/receipts/types.d.ts +1 -1
  134. package/dist/receipts/types.d.ts.map +1 -1
  135. package/dist/receipts/types.js +1 -0
  136. package/dist/registry/build.d.ts +43 -1
  137. package/dist/registry/build.d.ts.map +1 -1
  138. package/dist/registry/build.js +52 -0
  139. package/dist/registry/cache-policy.d.ts.map +1 -1
  140. package/dist/registry/cache-policy.js +22 -0
  141. package/dist/registry/pricing-shape.d.ts +67 -8
  142. package/dist/registry/pricing-shape.d.ts.map +1 -1
  143. package/dist/registry/pricing-shape.js +50 -13
  144. package/dist/registry/pricing.d.ts +6 -5
  145. package/dist/registry/pricing.d.ts.map +1 -1
  146. package/dist/registry/pricing.js +9 -5
  147. package/dist/registry/rows.d.ts.map +1 -1
  148. package/dist/registry/rows.js +1 -0
  149. package/dist/registry/select.d.ts +6 -1
  150. package/dist/registry/select.d.ts.map +1 -1
  151. package/dist/registry/select.js +11 -0
  152. package/dist/routes/call-config.d.ts +199 -0
  153. package/dist/routes/call-config.d.ts.map +1 -0
  154. package/dist/routes/call-config.js +343 -0
  155. package/dist/routes/destination-loader.d.ts +16 -0
  156. package/dist/routes/destination-loader.d.ts.map +1 -0
  157. package/dist/routes/destination-loader.js +29 -0
  158. package/dist/routes/draft.d.ts +7 -0
  159. package/dist/routes/draft.d.ts.map +1 -1
  160. package/dist/routes/draft.js +12 -0
  161. package/dist/routes/loader.d.ts.map +1 -1
  162. package/dist/routes/loader.js +31 -56
  163. package/dist/routes/objective-loader.d.ts +12 -0
  164. package/dist/routes/objective-loader.d.ts.map +1 -1
  165. package/dist/routes/objective-loader.js +82 -0
  166. package/dist/routes/output-loader.d.ts +42 -0
  167. package/dist/routes/output-loader.d.ts.map +1 -0
  168. package/dist/routes/output-loader.js +112 -0
  169. package/dist/routes/prompt-loader.d.ts +49 -0
  170. package/dist/routes/prompt-loader.d.ts.map +1 -0
  171. package/dist/routes/prompt-loader.js +113 -0
  172. package/dist/routes/resolved-bundle.d.ts +69 -0
  173. package/dist/routes/resolved-bundle.d.ts.map +1 -1
  174. package/dist/routes/resolved-bundle.js +76 -0
  175. package/dist/routes/screen-loader.d.ts +29 -1
  176. package/dist/routes/screen-loader.d.ts.map +1 -1
  177. package/dist/routes/screen-loader.js +59 -1
  178. package/dist/run/accept.d.ts +5 -0
  179. package/dist/run/accept.d.ts.map +1 -1
  180. package/dist/run/accept.js +2 -0
  181. package/dist/run/cost.d.ts +31 -2
  182. package/dist/run/cost.d.ts.map +1 -1
  183. package/dist/run/cost.js +57 -2
  184. package/dist/run/destination.d.ts +39 -0
  185. package/dist/run/destination.d.ts.map +1 -0
  186. package/dist/run/destination.js +45 -0
  187. package/dist/run/dispatch.d.ts +67 -16
  188. package/dist/run/dispatch.d.ts.map +1 -1
  189. package/dist/run/dispatch.js +133 -29
  190. package/dist/run/grounding.d.ts +28 -2
  191. package/dist/run/grounding.d.ts.map +1 -1
  192. package/dist/run/grounding.js +54 -10
  193. package/dist/run/raw-defaults.d.ts.map +1 -1
  194. package/dist/run/raw-defaults.js +6 -1
  195. package/dist/run/raw-finalize.d.ts +50 -0
  196. package/dist/run/raw-finalize.d.ts.map +1 -0
  197. package/dist/run/raw-finalize.js +266 -0
  198. package/dist/run/raw-knobs.d.ts +36 -0
  199. package/dist/run/raw-knobs.d.ts.map +1 -0
  200. package/dist/run/raw-knobs.js +99 -0
  201. package/dist/run/raw-request.d.ts +24 -0
  202. package/dist/run/raw-request.d.ts.map +1 -0
  203. package/dist/run/raw-request.js +69 -0
  204. package/dist/run/raw-schema.d.ts +76 -0
  205. package/dist/run/raw-schema.d.ts.map +1 -0
  206. package/dist/run/raw-schema.js +166 -0
  207. package/dist/run/raw-search-cost.d.ts +48 -0
  208. package/dist/run/raw-search-cost.d.ts.map +1 -0
  209. package/dist/run/raw-search-cost.js +78 -0
  210. package/dist/run/raw-support.d.ts +64 -6
  211. package/dist/run/raw-support.d.ts.map +1 -1
  212. package/dist/run/raw-support.js +84 -11
  213. package/dist/run/raw.d.ts +25 -26
  214. package/dist/run/raw.d.ts.map +1 -1
  215. package/dist/run/raw.js +30 -351
  216. package/dist/run/record-attempt.d.ts +12 -0
  217. package/dist/run/record-attempt.d.ts.map +1 -1
  218. package/dist/run/record-attempt.js +30 -12
  219. package/dist/run/repair-attempt.d.ts +68 -0
  220. package/dist/run/repair-attempt.d.ts.map +1 -0
  221. package/dist/run/repair-attempt.js +180 -0
  222. package/dist/run/resolve-destination.d.ts +49 -0
  223. package/dist/run/resolve-destination.d.ts.map +1 -0
  224. package/dist/run/resolve-destination.js +76 -0
  225. package/dist/run/routing-docs.d.ts.map +1 -1
  226. package/dist/run/routing-docs.js +10 -5
  227. package/dist/run/run.d.ts +30 -1
  228. package/dist/run/run.d.ts.map +1 -1
  229. package/dist/run/run.js +94 -172
  230. package/dist/run/telemetry-row.d.ts +92 -0
  231. package/dist/run/telemetry-row.d.ts.map +1 -0
  232. package/dist/run/telemetry-row.js +81 -0
  233. package/dist/run/validate.d.ts +12 -1
  234. package/dist/run/validate.d.ts.map +1 -1
  235. package/dist/run/validate.js +31 -0
  236. package/dist/run/web-search-pricing.d.ts +43 -0
  237. package/dist/run/web-search-pricing.d.ts.map +1 -0
  238. package/dist/run/web-search-pricing.js +56 -0
  239. package/dist/savings/odometer.d.ts +4 -0
  240. package/dist/savings/odometer.d.ts.map +1 -1
  241. package/dist/savings/odometer.js +20 -1
  242. package/dist/savings/swap-execute.d.ts +7 -0
  243. package/dist/savings/swap-execute.d.ts.map +1 -1
  244. package/dist/savings/swap-execute.js +30 -0
  245. package/dist/savings/swaps-client.d.ts +10 -0
  246. package/dist/savings/swaps-client.d.ts.map +1 -1
  247. package/dist/screen/fixtures/probe-corpora.d.ts +23 -0
  248. package/dist/screen/fixtures/probe-corpora.d.ts.map +1 -0
  249. package/dist/screen/fixtures/probe-corpora.js +69 -0
  250. package/dist/screen/index.d.ts +21 -0
  251. package/dist/screen/index.d.ts.map +1 -0
  252. package/dist/screen/index.js +64 -0
  253. package/dist/screen/model-screen.d.ts +111 -0
  254. package/dist/screen/model-screen.d.ts.map +1 -0
  255. package/dist/screen/model-screen.js +178 -0
  256. package/dist/screen/patterns.d.ts +51 -0
  257. package/dist/screen/patterns.d.ts.map +1 -0
  258. package/dist/screen/patterns.js +151 -0
  259. package/dist/screen/phi-gate.d.ts +52 -0
  260. package/dist/screen/phi-gate.d.ts.map +1 -0
  261. package/dist/screen/phi-gate.js +86 -0
  262. package/dist/screen/policy.d.ts +71 -0
  263. package/dist/screen/policy.d.ts.map +1 -0
  264. package/dist/screen/policy.js +334 -0
  265. package/dist/screen/probe.d.ts +118 -0
  266. package/dist/screen/probe.d.ts.map +1 -0
  267. package/dist/screen/probe.js +132 -0
  268. package/dist/screen/screen-cli.d.ts +16 -0
  269. package/dist/screen/screen-cli.d.ts.map +1 -0
  270. package/dist/screen/screen-cli.js +178 -0
  271. package/dist/screen/screen.d.ts +99 -0
  272. package/dist/screen/screen.d.ts.map +1 -0
  273. package/dist/screen/screen.js +0 -0
  274. package/dist/screen/sidecar.d.ts +69 -0
  275. package/dist/screen/sidecar.d.ts.map +1 -0
  276. package/dist/screen/sidecar.js +145 -0
  277. package/dist/screen/types.d.ts +43 -2
  278. package/dist/screen/types.d.ts.map +1 -1
  279. package/dist/settings/api-fetcher.d.ts +14 -3
  280. package/dist/settings/api-fetcher.d.ts.map +1 -1
  281. package/dist/settings/api-fetcher.js +61 -10
  282. package/dist/settings/grading-guide.d.ts +102 -0
  283. package/dist/settings/grading-guide.d.ts.map +1 -0
  284. package/dist/settings/grading-guide.js +23 -0
  285. package/dist/settings/index.d.ts +3 -2
  286. package/dist/settings/index.d.ts.map +1 -1
  287. package/dist/settings/index.js +2 -1
  288. package/dist/settings/task-settings.d.ts +44 -7
  289. package/dist/settings/task-settings.d.ts.map +1 -1
  290. package/dist/settings/task-settings.js +53 -12
  291. package/dist/status.d.ts +32 -20
  292. package/dist/status.d.ts.map +1 -1
  293. package/dist/status.js +51 -30
  294. package/dist/telemetry/artifact-store.d.ts +5 -6
  295. package/dist/telemetry/artifact-store.d.ts.map +1 -1
  296. package/dist/telemetry/artifact-store.js +21 -24
  297. package/dist/telemetry/attempt-meta.d.ts +76 -1
  298. package/dist/telemetry/attempt-meta.d.ts.map +1 -1
  299. package/dist/telemetry/attempt-meta.js +33 -1
  300. package/dist/telemetry/exporter-setup.d.ts +2 -0
  301. package/dist/telemetry/exporter-setup.d.ts.map +1 -1
  302. package/dist/telemetry/exporter-setup.js +6 -1
  303. package/dist/telemetry/exporter.d.ts +2 -2
  304. package/dist/telemetry/exporter.d.ts.map +1 -1
  305. package/dist/telemetry/exporter.js +22 -41
  306. package/dist/telemetry/grade-mappers.d.ts +25 -0
  307. package/dist/telemetry/grade-mappers.d.ts.map +1 -0
  308. package/dist/telemetry/grade-mappers.js +64 -0
  309. package/dist/telemetry/grades-sql.d.ts +56 -0
  310. package/dist/telemetry/grades-sql.d.ts.map +1 -0
  311. package/dist/telemetry/grades-sql.js +156 -0
  312. package/dist/telemetry/ingest-protocol.d.ts +55 -48
  313. package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
  314. package/dist/telemetry/ingest-protocol.js +48 -83
  315. package/dist/telemetry/org-identity.d.ts +44 -0
  316. package/dist/telemetry/org-identity.d.ts.map +1 -0
  317. package/dist/telemetry/org-identity.js +98 -0
  318. package/dist/telemetry/route-registration.d.ts +48 -0
  319. package/dist/telemetry/route-registration.d.ts.map +1 -0
  320. package/dist/telemetry/route-registration.js +77 -0
  321. package/dist/telemetry/sinks.d.ts +10 -1
  322. package/dist/telemetry/sinks.d.ts.map +1 -1
  323. package/dist/telemetry/sinks.js +52 -6
  324. package/dist/telemetry/store-migrations.d.ts.map +1 -1
  325. package/dist/telemetry/store-migrations.js +64 -0
  326. package/dist/telemetry/store.d.ts +9 -6
  327. package/dist/telemetry/store.d.ts.map +1 -1
  328. package/dist/telemetry/store.js +8 -50
  329. package/dist/tenancy/api-key-format.d.ts +45 -1
  330. package/dist/tenancy/api-key-format.d.ts.map +1 -1
  331. package/dist/tenancy/api-key-format.js +50 -1
  332. package/dist/types/provider.d.ts +23 -3
  333. package/dist/types/provider.d.ts.map +1 -1
  334. package/dist/types/provider.js +26 -0
  335. package/dist/types/route.d.ts +154 -2
  336. package/dist/types/route.d.ts.map +1 -1
  337. package/dist/types/telemetry.d.ts +73 -48
  338. package/dist/types/telemetry.d.ts.map +1 -1
  339. package/dist/validate-cli.d.ts.map +1 -1
  340. package/dist/validate-cli.js +32 -0
  341. package/dist/verify/verify.d.ts +5 -0
  342. package/dist/verify/verify.d.ts.map +1 -1
  343. package/dist/verify/verify.js +2 -0
  344. package/dist/watch/evaluate.d.ts +84 -1
  345. package/dist/watch/evaluate.d.ts.map +1 -1
  346. package/dist/watch/evaluate.js +28 -0
  347. package/dist/watch/monitor.d.ts +8 -2
  348. package/dist/watch/monitor.d.ts.map +1 -1
  349. package/dist/watch/monitor.js +13 -5
  350. package/dist/watch/regret-monitor-cli.d.ts +16 -0
  351. package/dist/watch/regret-monitor-cli.d.ts.map +1 -0
  352. package/dist/watch/regret-monitor-cli.js +137 -0
  353. package/dist/watch/regret-monitor.d.ts +168 -0
  354. package/dist/watch/regret-monitor.d.ts.map +1 -0
  355. package/dist/watch/regret-monitor.js +304 -0
  356. package/dist/watch/upgrade.d.ts +62 -0
  357. package/dist/watch/upgrade.d.ts.map +1 -0
  358. package/dist/watch/upgrade.js +57 -0
  359. package/docs/agent-skill/SKILL.md +181 -9
  360. package/docs/how-it-fits.md +3 -2
  361. package/docs/instrumentation.md +219 -46
  362. package/docs/llms.txt +158 -35
  363. package/docs/managed-serving.md +150 -0
  364. package/docs/mcp-oracle.md +322 -0
  365. package/docs/migration-playbook.md +5 -4
  366. package/docs/quickstart.md +263 -89
  367. package/package.json +18 -4
  368. package/registry/leaderboard.json +74 -0
  369. package/registry/registry.json +232 -112
  370. package/screen.d.ts +16 -0
  371. package/templates/call-disposition-qa.json +77 -0
  372. package/templates/catalog-cleansing.json +77 -0
  373. package/templates/compliance-review.json +76 -0
  374. package/templates/cs-next-action.json +76 -0
  375. package/templates/document-extraction.json +78 -0
  376. package/templates/financial-classification.json +75 -0
  377. package/templates/lead-qualification.json +76 -0
  378. package/templates/medical-classification.json +71 -0
  379. package/templates/ticket-triage.json +76 -0
  380. package/dist/feedback/feedback.d.ts +0 -35
  381. package/dist/feedback/feedback.d.ts.map +0 -1
  382. package/dist/feedback/feedback.js +0 -39
@@ -27,6 +27,7 @@
27
27
  */
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.resolveRouteBundle = resolveRouteBundle;
30
+ exports.assertMirrorSafe = assertMirrorSafe;
30
31
  exports.canonicalBundleJson = canonicalBundleJson;
31
32
  exports.hashResolvedBundle = hashResolvedBundle;
32
33
  exports.bundleFromResolved = bundleFromResolved;
@@ -34,6 +35,7 @@ exports.singleRouteStore = singleRouteStore;
34
35
  const node_crypto_1 = require("node:crypto");
35
36
  const fingerprint_1 = require("../registry/fingerprint");
36
37
  const loader_1 = require("./loader");
38
+ const policy_1 = require("../screen/policy");
37
39
  /** Project an already-loaded (resolved) bundle to its serialisable form. Pure —
38
40
  * no filesystem; the loader already followed every file reference. */
39
41
  function resolveRouteBundle(bundle) {
@@ -41,18 +43,63 @@ function resolveRouteBundle(bundle) {
41
43
  route: bundle.route,
42
44
  version: bundle.version,
43
45
  outputSchema: bundle.outputSchema,
46
+ // Issue #1: prose contract crosses the wire (text only; json adds no key).
47
+ ...(bundle.outputKind === "text" ? { outputKind: "text" } : {}),
48
+ ...(bundle.outputKind === "text" && bundle.outputMinChars !== undefined ? { outputMinChars: bundle.outputMinChars } : {}),
44
49
  candidates: bundle.candidates,
45
50
  require: bundle.require,
46
51
  prefer: bundle.prefer,
47
52
  systemTemplate: bundle.systemTemplate,
53
+ ...(bundle.userTemplate !== undefined ? { userTemplate: bundle.userTemplate } : {}), // issue #5 (R1)
48
54
  variables: bundle.variables,
49
55
  policy: bundle.policy,
50
56
  ...(bundle.repair !== undefined ? { repair: bundle.repair } : {}),
51
57
  variants: bundle.variants,
52
58
  capture: bundle.capture,
53
59
  ...(bundle.groundingQuery !== undefined ? { groundingQuery: bundle.groundingQuery } : {}),
60
+ ...(bundle.groundingAssembly !== undefined ? { groundingAssembly: bundle.groundingAssembly } : {}),
61
+ ...(bundle.variableTrust !== undefined ? { variableTrust: bundle.variableTrust } : {}),
62
+ // SC-1b mirror fix (req 1): carry the RAW screen policy (re-resolved on the
63
+ // gateway) + the fully-resolved mask policy (entries inlined) so neither is
64
+ // silently inert on the hosted lane. Absent ⇒ omitted ⇒ byte-identical.
65
+ ...(bundle.screen !== undefined ? { screenPolicy: bundle.screen.policy } : {}),
66
+ ...(bundle.mask !== undefined ? { mask: bundle.mask } : {}),
67
+ // PSR-2: carry the served prompt's manifest so promote's write-through and the
68
+ // round-trip both preserve it. Absent ⇒ omitted ⇒ byte-identical.
69
+ ...(bundle.manifest !== undefined ? { manifest: bundle.manifest } : {}),
54
70
  };
55
71
  }
72
+ /**
73
+ * Refuse-on-export guard (SC-1b req 1 — the #322 QA finding). A route that
74
+ * declares `screen: enforce` MUST be guaranteed to re-resolve its enforcement on
75
+ * the hosted (mirror) lane, or the hosted lane silently fails open. The mirror
76
+ * rebuilds the screen policy with `resolveScreenPolicy`, which ALWAYS builds the
77
+ * T0 pattern detector deterministically (no filesystem) — so a pure-T0 enforce
78
+ * policy re-resolves identically and mirrors safely. A T1 `classifier:` detector,
79
+ * though, depends on gateway-local weights the mirror cannot guarantee: there it
80
+ * would DEGRADE to T0 SILENTLY, weaker than what was authored and proven. Rather
81
+ * than ship a silently-degraded enforce we REFUSE at export with a teaching
82
+ * error. `mask` needs no guard: its resolved policy (dictionary entries inlined)
83
+ * crosses the wire whole and re-materialises identically.
84
+ *
85
+ * Called from the exporter (`buildExportedRouteMirrors`) — a hard failure at
86
+ * SYNC, on the developer's machine, never a silent inert enforce at request.
87
+ */
88
+ function assertMirrorSafe(bundle) {
89
+ const screen = bundle.screen;
90
+ if (screen === undefined || screen.policy.mode !== "enforce")
91
+ return;
92
+ const classifiers = (screen.policy.detectors ?? []).filter((d) => d.startsWith("classifier:"));
93
+ if (classifiers.length > 0) {
94
+ throw new loader_1.RouteConfigError(`route "${bundle.route}" declares screen.mode: enforce with a classifier detector ` +
95
+ `(${classifiers.join(", ")}), which cannot be guaranteed to re-resolve on the hosted ` +
96
+ `(mirror) lane: the gateway has no access to the local classifier weights and would ` +
97
+ `silently DEGRADE to the T0 pattern tier — an enforce weaker than the one you authored ` +
98
+ `and proved. Fix: self-host this route, or drop the classifier from the enforce policy ` +
99
+ `(T0 patterns re-resolve deterministically on the mirror; the classifier stays a signal ` +
100
+ `under detect). Spec: screening §4.3, SC-1b req 1.`);
101
+ }
102
+ }
56
103
  /** Deterministic JSON: object keys sorted recursively, array order preserved.
57
104
  * The whole point is that the SAME bundle always produces the SAME bytes, so
58
105
  * the content hash is stable across processes and machines. */
@@ -105,20 +152,49 @@ function bundleFromResolved(raw) {
105
152
  throw new loader_1.RouteConfigError(`mirrored route bundle "${b.route}" is missing \`policy\``);
106
153
  }
107
154
  const outputSchema = b.outputSchema ?? null;
155
+ // Issue #1: a mirrored `output: text` route rebuilds as text (never JSON-parsed
156
+ // on the hosted lane). Anything but the literal "text" ⇒ json (byte-identical);
157
+ // text + a schema is a corrupt mirror (the loader refuses that pair at author).
158
+ const outputKind = b.outputKind === "text" ? "text" : undefined;
159
+ if (outputKind === "text" && outputSchema !== null) {
160
+ throw new loader_1.RouteConfigError(`mirrored route bundle "${b.route}" declares output: text AND a schema — remove one`);
161
+ }
162
+ const minChars = b.outputMinChars;
163
+ const outputMinChars = outputKind === "text" && typeof minChars === "number" && Number.isInteger(minChars) && minChars >= 1 ? minChars : undefined;
108
164
  return Object.freeze({
109
165
  route: b.route,
110
166
  version: b.version,
111
167
  outputSchema: outputSchema === null ? null : Object.freeze(outputSchema),
168
+ ...(outputKind !== undefined ? { outputKind } : {}),
169
+ ...(outputMinChars !== undefined ? { outputMinChars } : {}),
112
170
  candidates: Object.freeze([...b.candidates]),
113
171
  require: Object.freeze([...(b.require ?? [])]),
114
172
  prefer: Object.freeze([...(b.prefer ?? [])]),
115
173
  systemTemplate: b.systemTemplate,
174
+ // Issue #5 (R1): a mirrored `prompt.user` rebuilds as the user turn; anything
175
+ // but a non-empty string ⇒ absent ⇒ the fixed trigger (byte-identical).
176
+ ...(typeof b.userTemplate === "string" && b.userTemplate !== "" ? { userTemplate: b.userTemplate } : {}),
116
177
  variables: Object.freeze([...(b.variables ?? [])]),
117
178
  policy: b.policy,
118
179
  ...(b.repair !== undefined ? { repair: b.repair } : {}),
119
180
  variants: Object.freeze([...(b.variants ?? [])]),
120
181
  capture: b.capture === true,
121
182
  ...(b.groundingQuery !== undefined ? { groundingQuery: b.groundingQuery } : {}),
183
+ ...(b.groundingAssembly !== undefined ? { groundingAssembly: b.groundingAssembly } : {}),
184
+ ...(b.variableTrust !== undefined ? { variableTrust: Object.freeze({ ...b.variableTrust }) } : {}),
185
+ // SC-1b mirror fix (req 1): RE-RESOLVE the raw screen policy so `route.screen`
186
+ // is a live `ResolvedScreenPolicy` (built detectors) on the hosted lane — no
187
+ // longer `undefined` (the silent fail-open). `resolveScreenPolicy` always
188
+ // builds the T0 pattern detector; a configured-but-absent T1 classifier
189
+ // degrades to T0 with `degraded: true` (never a silent inert enforce — and
190
+ // `assertMirrorSafe` already refused a T1-classifier enforce at export).
191
+ ...(b.screenPolicy !== undefined ? { screen: (0, policy_1.resolveScreenPolicy)(b.screenPolicy) } : {}),
192
+ // Mask carries its FULLY-RESOLVED policy (entries inlined) — passed through,
193
+ // re-materialising byte-identically so `mask: block` is never inert.
194
+ ...(b.mask !== undefined ? { mask: b.mask } : {}),
195
+ // PSR-2: the served prompt's structure-only manifest, passed through whole
196
+ // (no re-resolve — it carries no filesystem/closure state). Absent ⇒ omitted.
197
+ ...(b.manifest !== undefined ? { manifest: b.manifest } : {}),
122
198
  // Recomputed, never trusted from the wire — cannot drift from the schema.
123
199
  fingerprintCell: (0, fingerprint_1.fingerprintSchema)(outputSchema)?.cellKey ?? null,
124
200
  });
@@ -4,10 +4,38 @@
4
4
  * Pure functions that push into the shared `problems[]`; unit-tested directly.
5
5
  * Spec: docs/ModelRig/screening/spec.md §2.4 (S1 assembly knob, S2 x-trust).
6
6
  */
7
+ import type { ResolvedScreenPolicy } from "../screen/types";
8
+ import type { DataClassification } from "../artifacts/classification";
9
+ import type { ResolvedMaskPolicy } from "../mask/types";
10
+ import type { Requirement } from "../types/route";
11
+ /**
12
+ * Parse + resolve the optional `screen:` block (SC-1a, spec §4.1). Returns the
13
+ * resolved policy, or `undefined` when the block is absent OR `mode: off` (both
14
+ * ⇒ byte-identical, no screening). Pushes teaching-style problems for a
15
+ * malformed block: an unknown detector / action, or a `sources` key that loosens
16
+ * a default tier, is a LOAD error (validated at the SAME point as `require:` /
17
+ * `mask:`). A configured-but-unavailable optional classifier is NOT a load error
18
+ * — resolution degrades to T0 (spec §4.3), surfaced later on the receipt.
19
+ */
20
+ export declare function parseScreenBlock(raw: unknown, problems: string[]): ResolvedScreenPolicy | undefined;
21
+ /**
22
+ * SC-2 (spec-sc2 §4): parse the route-level `classification` (rides the 00058
23
+ * `data_classification` enum — zero-DDL) and, for a `phi` value, GATE the route
24
+ * posture at load. A `phi` route must mask (≥ redact) AND (`require:
25
+ * zero_retention` OR a `sidecar` detector present), else it refuses to load with
26
+ * the specific teaching message (checkPhiPosture). Returns the parsed
27
+ * classification, or `undefined` when absent/invalid (an invalid value is a
28
+ * pushed problem). Runs at the same point as `require:` / `mask:` / `screen:`.
29
+ */
30
+ export declare function parseClassificationAndPhiGate(raw: unknown, ctx: {
31
+ mask?: ResolvedMaskPolicy;
32
+ screen?: ResolvedScreenPolicy;
33
+ require: readonly Requirement[];
34
+ }, problems: string[]): DataClassification | undefined;
7
35
  /** Push a problem for every `{{var}}` referenced in the system template or the
8
36
  * grounding query that was not declared in `prompt.variables`. Colocated with
9
37
  * the variable parser it validates. */
10
- export declare function pushUndeclaredVariableProblems(systemTemplate: string, groundingQuery: string | undefined, variables: readonly string[], problems: string[]): void;
38
+ export declare function pushUndeclaredVariableProblems(systemTemplate: string, groundingQuery: string | undefined, variables: readonly string[], problems: string[], userTemplate?: string): void;
11
39
  /** Parse `prompt.variables` — each entry is a bare name (semi, stays in the
12
40
  * system slot — the default) or `{name, "x-trust": "untrusted"}` (spotlighted out
13
41
  * of the system slot, S2). Returns the declared names and, when any variable is
@@ -1 +1 @@
1
- {"version":3,"file":"screen-loader.d.ts","sourceRoot":"","sources":["../../src/routes/screen-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;uCAEuC;AACvC,wBAAgB,8BAA8B,CAC5C,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,QAAQ,EAAE,MAAM,EAAE,GACjB,IAAI,CAcN;AAED;;;iFAGiF;AACjF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAAE,GACjB;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ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B,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAAE,GACjB;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;CAAE,CAwB5E;AAED;;iFAEiF;AACjF,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,QAAQ,EAAE,MAAM,EAAE,GACjB,QAAQ,GAAG,WAAW,GAAG,SAAS,CAQpC"}
@@ -6,17 +6,68 @@
6
6
  * Spec: docs/ModelRig/screening/spec.md §2.4 (S1 assembly knob, S2 x-trust).
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.parseScreenBlock = parseScreenBlock;
10
+ exports.parseClassificationAndPhiGate = parseClassificationAndPhiGate;
9
11
  exports.pushUndeclaredVariableProblems = pushUndeclaredVariableProblems;
10
12
  exports.parseVariables = parseVariables;
11
13
  exports.parseGroundingAssembly = parseGroundingAssembly;
12
14
  const template_1 = require("./template");
15
+ const policy_1 = require("../screen/policy");
16
+ const phi_gate_1 = require("../screen/phi-gate");
17
+ const classification_1 = require("../artifacts/classification");
13
18
  function isRecord(v) {
14
19
  return typeof v === "object" && v !== null && !Array.isArray(v);
15
20
  }
21
+ /**
22
+ * Parse + resolve the optional `screen:` block (SC-1a, spec §4.1). Returns the
23
+ * resolved policy, or `undefined` when the block is absent OR `mode: off` (both
24
+ * ⇒ byte-identical, no screening). Pushes teaching-style problems for a
25
+ * malformed block: an unknown detector / action, or a `sources` key that loosens
26
+ * a default tier, is a LOAD error (validated at the SAME point as `require:` /
27
+ * `mask:`). A configured-but-unavailable optional classifier is NOT a load error
28
+ * — resolution degrades to T0 (spec §4.3), surfaced later on the receipt.
29
+ */
30
+ function parseScreenBlock(raw, problems) {
31
+ if (raw === undefined)
32
+ return undefined;
33
+ const shapeProblems = (0, policy_1.validateScreenPolicyShape)(raw);
34
+ if (shapeProblems.length > 0) {
35
+ for (const p of shapeProblems)
36
+ problems.push(`screen: ${p}`);
37
+ return undefined;
38
+ }
39
+ const policy = (0, policy_1.parseScreenPolicy)(raw);
40
+ if (policy.mode === "off")
41
+ return undefined; // off ⇒ no screening, byte-identical
42
+ return (0, policy_1.resolveScreenPolicy)(policy);
43
+ }
44
+ /**
45
+ * SC-2 (spec-sc2 §4): parse the route-level `classification` (rides the 00058
46
+ * `data_classification` enum — zero-DDL) and, for a `phi` value, GATE the route
47
+ * posture at load. A `phi` route must mask (≥ redact) AND (`require:
48
+ * zero_retention` OR a `sidecar` detector present), else it refuses to load with
49
+ * the specific teaching message (checkPhiPosture). Returns the parsed
50
+ * classification, or `undefined` when absent/invalid (an invalid value is a
51
+ * pushed problem). Runs at the same point as `require:` / `mask:` / `screen:`.
52
+ */
53
+ function parseClassificationAndPhiGate(raw, ctx, problems) {
54
+ if (raw === undefined || raw === null)
55
+ return undefined;
56
+ const norm = (0, classification_1.normalizeClassification)(raw);
57
+ if (norm === null || !classification_1.DATA_CLASSIFICATIONS.includes(norm)) {
58
+ problems.push(`classification "${String(raw)}" is not one of ${classification_1.DATA_CLASSIFICATIONS.join(" | ")}`);
59
+ return undefined;
60
+ }
61
+ const classification = norm;
62
+ for (const p of (0, phi_gate_1.checkPhiPosture)({ classification, mask: ctx.mask, screen: ctx.screen, require: ctx.require })) {
63
+ problems.push(`phi posture: ${p}`);
64
+ }
65
+ return classification;
66
+ }
16
67
  /** Push a problem for every `{{var}}` referenced in the system template or the
17
68
  * grounding query that was not declared in `prompt.variables`. Colocated with
18
69
  * the variable parser it validates. */
19
- function pushUndeclaredVariableProblems(systemTemplate, groundingQuery, variables, problems) {
70
+ function pushUndeclaredVariableProblems(systemTemplate, groundingQuery, variables, problems, userTemplate) {
20
71
  const declared = new Set(variables);
21
72
  if (systemTemplate !== "") {
22
73
  for (const ref of (0, template_1.scanTemplateVariables)(systemTemplate)) {
@@ -25,6 +76,13 @@ function pushUndeclaredVariableProblems(systemTemplate, groundingQuery, variable
25
76
  }
26
77
  }
27
78
  }
79
+ if (userTemplate !== undefined) {
80
+ for (const ref of (0, template_1.scanTemplateVariables)(userTemplate)) {
81
+ if (!declared.has(ref)) {
82
+ problems.push(`prompt.user references undeclared variable "${ref}" (declare it in prompt.variables)`);
83
+ }
84
+ }
85
+ }
28
86
  if (groundingQuery !== undefined) {
29
87
  for (const ref of (0, template_1.scanTemplateVariables)(groundingQuery)) {
30
88
  if (!declared.has(ref))
@@ -40,6 +40,11 @@ export interface SuccessMetaInput {
40
40
  readonly quality?: RunMeta["quality"];
41
41
  /** CS-1 mask receipt (spec §6) — counts-only, when the route masks. */
42
42
  readonly mask?: RunMeta["mask"];
43
+ /** SC-1a screen receipt (spec §5) — counts-only, when the route screens. */
44
+ readonly screen?: RunMeta["screen"];
45
+ /** Unified Route U2 (D-2): the resolved served destination (always `direct` in
46
+ * U2 — `modelrig-served` fails closed pre-dispatch). Additive result metadata. */
47
+ readonly destination?: RunMeta["destination"];
43
48
  }
44
49
  /** The validated `RunMeta` for the accept path — `repairedBy` is null here (the
45
50
  * repair path builds its own meta), `validated` is always true. */
@@ -1 +1 @@
1
- {"version":3,"file":"accept.d.ts","sourceRoot":"","sources":["../../src/run/accept.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE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wEAAwE;IACxE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1C,wEAAwE;IACxE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1C,uDAAuD;IACvD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC,uEAAuE;IACvE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpC;sFACkF;IAClF,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAC/C;AAED;mEACmE;AACnE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CA2BjE"}
@@ -63,5 +63,7 @@ function buildSuccessMeta(input) {
63
63
  ...(input.grounding !== undefined ? { grounding: input.grounding } : {}),
64
64
  ...(input.quality !== undefined ? { quality: input.quality } : {}),
65
65
  ...(input.mask !== undefined ? { mask: input.mask } : {}),
66
+ ...(input.screen !== undefined ? { screen: input.screen } : {}),
67
+ ...(input.destination !== undefined ? { destination: input.destination } : {}),
66
68
  };
67
69
  }
@@ -4,8 +4,36 @@
4
4
  * site: a model with no pricing entry NEVER costs $0 against an active
5
5
  * envelope — the envelope is charged a conservative per-token rate instead,
6
6
  * while telemetry keeps the honest $0 with `pricing_missing` flagged.
7
+ *
8
+ * KNOWN GAP (issue #2 follow-up, S9c record): context bands are LISTED on
9
+ * `pricing_v2.context_bands` but NOT APPLIED here — a Gemini row whose prompt
10
+ * exceeds 200k tokens is priced at the ≤200k rates (Google doubles input,
11
+ * output and cache read above 200k), so such rows UNDER-state Google's list.
12
+ * The snapshot's `*_above_200k_tokens` keys were always ignored; this is not
13
+ * new, only now stated.
14
+ *
15
+ * SCOPE (QA-S5, 2026-10-12): served-tier pricing applies to what THIS module
16
+ * prices — the attempt cost row (`cost_estimate_usd`, both lanes, every
17
+ * attempt) and the `meta.cost` components. The server's managed re-pricing
18
+ * (`modelrig-server/src/compute-fee.ts` `listPriceCents`, which feeds the
19
+ * `/costs` rollup and the settlement draw) still calls `estimateCostUsd`
20
+ * WITHOUT a served tier and so prices at base. That is a money path and is
21
+ * deliberately not changed alongside this; tracked for the next money-path MR.
7
22
  */
8
- import type { AdapterUsage, ProviderId } from "../types/provider";
23
+ import type { ModelPricing } from "../registry/pricing";
24
+ import type { AdapterUsage, ProviderId, ServiceTier } from "../types/provider";
25
+ /** The `servedTier` an attempt reports, when the caller has it — optional so
26
+ * every existing (tier-less) caller is unchanged and bills at base. */
27
+ type UsageTier = Partial<Pick<AdapterUsage, "servedTier">>;
28
+ /**
29
+ * Per-token rates for the tier that actually SERVED an attempt (issue #2).
30
+ * `standard` (or an unknown tier) ⇒ the flat base price — today's behaviour,
31
+ * byte-identical. `flex` / `priority` ⇒ the model's published `pricing_v2`
32
+ * tier rates (`tierRates`, per component — Gemini flex halves input + output
33
+ * but NOT cache read); a model that publishes no such tier bills at base, never
34
+ * at a guessed multiplier. Returns null only when the model is unpriced.
35
+ */
36
+ export declare function pricingForServedTier(provider: ProviderId, model: string, servedTier: ServiceTier | undefined): ModelPricing | null;
9
37
  export declare const ESTIMATE_CHARS_PER_TOKEN = 4;
10
38
  export declare const ESTIMATE_MAX_OUTPUT_TOKENS = 64000;
11
39
  /** Addendum A1 conservative default — above the priciest frontier output
@@ -26,7 +54,7 @@ export declare function attemptCost(provider: ProviderId, model: string, usage:
26
54
  * `attemptCost`'s `pricingMissing`). Every component uses the SAME per-token
27
55
  * rates as {@link estimateCostUsd}, so the sum equals the recorded
28
56
  * `cost_estimate_usd` for a priced model. `other` is reserved (0 today). */
29
- export declare function costComponents(provider: ProviderId, model: string, usage: Pick<AdapterUsage, "tokensIn" | "tokensOut" | "tokensCached" | "tokensCacheWrite" | "tokensCacheWrite1h">): {
57
+ export declare function costComponents(provider: ProviderId, model: string, usage: Pick<AdapterUsage, "tokensIn" | "tokensOut" | "tokensCached" | "tokensCacheWrite" | "tokensCacheWrite1h"> & UsageTier): {
30
58
  in: number;
31
59
  out: number;
32
60
  cache_read: number;
@@ -36,4 +64,5 @@ export declare function costComponents(provider: ProviderId, model: string, usag
36
64
  /** Pre-dispatch upper-bound estimate for the envelope precheck: prompt
37
65
  * length + the full output bound, at real pricing or the conservative rate. */
38
66
  export declare function dispatchEstimateUsd(provider: ProviderId, model: string, promptChars: number, unpricedRatePerTok: number): number;
67
+ export {};
39
68
  //# sourceMappingURL=cost.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../src/run/cost.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAEjD;;yEAEyE;AACzE,eAAO,MAAM,kCAAkC,MAAM,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AAED,wBAAgB,WAAW,CACzB,QAAQ,EAAE,UAAU,EACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,EACnB,kBAAkB,EAAE,MAAM,GACzB,WAAW,CAkBb;AAED;;;;;4EAK4E;AAC5E,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,UAAU,EACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,IAAI,CACT,YAAY,EACZ,UAAU,GAAG,WAAW,GAAG,cAAc,GAAG,kBAAkB,GAAG,oBAA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K,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,EACnB,kBAAkB,EAAE,MAAM,GACzB,WAAW,CAoBb;AAED;;;;;4EAK4E;AAC5E,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,UAAU,EACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,IAAI,CACT,YAAY,EACZ,UAAU,GAAG,WAAW,GAAG,cAAc,GAAG,kBAAkB,GAAG,oBAAoB,CACtF,GACC,SAAS,GACV;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAmB5F;AAED;+EAC+E;AAC/E,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,UAAU,EACpB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,MAAM,GACzB,MAAM,CAOR"}
package/dist/run/cost.js CHANGED
@@ -5,13 +5,65 @@
5
5
  * site: a model with no pricing entry NEVER costs $0 against an active
6
6
  * envelope — the envelope is charged a conservative per-token rate instead,
7
7
  * while telemetry keeps the honest $0 with `pricing_missing` flagged.
8
+ *
9
+ * KNOWN GAP (issue #2 follow-up, S9c record): context bands are LISTED on
10
+ * `pricing_v2.context_bands` but NOT APPLIED here — a Gemini row whose prompt
11
+ * exceeds 200k tokens is priced at the ≤200k rates (Google doubles input,
12
+ * output and cache read above 200k), so such rows UNDER-state Google's list.
13
+ * The snapshot's `*_above_200k_tokens` keys were always ignored; this is not
14
+ * new, only now stated.
15
+ *
16
+ * SCOPE (QA-S5, 2026-10-12): served-tier pricing applies to what THIS module
17
+ * prices — the attempt cost row (`cost_estimate_usd`, both lanes, every
18
+ * attempt) and the `meta.cost` components. The server's managed re-pricing
19
+ * (`modelrig-server/src/compute-fee.ts` `listPriceCents`, which feeds the
20
+ * `/costs` rollup and the settlement draw) still calls `estimateCostUsd`
21
+ * WITHOUT a served tier and so prices at base. That is a money path and is
22
+ * deliberately not changed alongside this; tracked for the next money-path MR.
8
23
  */
9
24
  Object.defineProperty(exports, "__esModule", { value: true });
10
25
  exports.DEFAULT_UNPRICED_RATE_USD_PER_MTOK = exports.ESTIMATE_MAX_OUTPUT_TOKENS = exports.ESTIMATE_CHARS_PER_TOKEN = void 0;
26
+ exports.pricingForServedTier = pricingForServedTier;
11
27
  exports.attemptCost = attemptCost;
12
28
  exports.costComponents = costComponents;
13
29
  exports.dispatchEstimateUsd = dispatchEstimateUsd;
14
30
  const pricing_1 = require("../registry/pricing");
31
+ const pricing_shape_1 = require("../registry/pricing-shape");
32
+ /** The served tiers that carry their own published rates (issue #2). `standard`
33
+ * is `base` by definition; an unlisted tier bills at base (fail-closed, L5). */
34
+ const SERVED_TIER_RATES = {
35
+ flex: "flex",
36
+ priority: "priority",
37
+ };
38
+ /**
39
+ * Per-token rates for the tier that actually SERVED an attempt (issue #2).
40
+ * `standard` (or an unknown tier) ⇒ the flat base price — today's behaviour,
41
+ * byte-identical. `flex` / `priority` ⇒ the model's published `pricing_v2`
42
+ * tier rates (`tierRates`, per component — Gemini flex halves input + output
43
+ * but NOT cache read); a model that publishes no such tier bills at base, never
44
+ * at a guessed multiplier. Returns null only when the model is unpriced.
45
+ */
46
+ function pricingForServedTier(provider, model, servedTier) {
47
+ const base = (0, pricing_1.getPricing)(provider, model);
48
+ if (base === null)
49
+ return null;
50
+ const tier = servedTier === undefined ? undefined : SERVED_TIER_RATES[servedTier];
51
+ if (tier === undefined)
52
+ return base;
53
+ const v2 = (0, pricing_1.getPricingV2)(provider, model);
54
+ const rates = v2 === null ? null : (0, pricing_shape_1.tierRates)(v2, tier);
55
+ if (rates === null)
56
+ return base;
57
+ return {
58
+ inputUsdPerTok: rates.input,
59
+ outputUsdPerTok: rates.output,
60
+ // A component the richer shape does not carry falls back to the flat base
61
+ // rate (the authoritative snapshot value), never to a scaled guess.
62
+ cachedInputUsdPerTok: rates.cache_read ?? base.cachedInputUsdPerTok,
63
+ cacheWriteUsdPerTok: rates.cache_write ?? base.cacheWriteUsdPerTok,
64
+ cacheWrite1hUsdPerTok: rates.cache_write_1h ?? base.cacheWrite1hUsdPerTok,
65
+ };
66
+ }
15
67
  exports.ESTIMATE_CHARS_PER_TOKEN = 4;
16
68
  exports.ESTIMATE_MAX_OUTPUT_TOKENS = 64000;
17
69
  /** Addendum A1 conservative default — above the priciest frontier output
@@ -19,7 +71,9 @@ exports.ESTIMATE_MAX_OUTPUT_TOKENS = 64000;
19
71
  * free. Override via MODELRIG_UNPRICED_RATE_USD_PER_MTOK / RigConfig. */
20
72
  exports.DEFAULT_UNPRICED_RATE_USD_PER_MTOK = 100;
21
73
  function attemptCost(provider, model, usage, unpricedRatePerTok) {
22
- const pricing = (0, pricing_1.getPricing)(provider, model);
74
+ // Issue #2: price at the tier that SERVED (usage.servedTier), not the
75
+ // standard base — a flex row at standard rates overstated Gemini ~1.6×.
76
+ const pricing = pricingForServedTier(provider, model, usage.servedTier);
23
77
  if (pricing === null) {
24
78
  return {
25
79
  costUsd: 0,
@@ -37,7 +91,8 @@ function attemptCost(provider, model, usage, unpricedRatePerTok) {
37
91
  * rates as {@link estimateCostUsd}, so the sum equals the recorded
38
92
  * `cost_estimate_usd` for a priced model. `other` is reserved (0 today). */
39
93
  function costComponents(provider, model, usage) {
40
- const pricing = (0, pricing_1.getPricing)(provider, model);
94
+ // Same served-tier rates as attemptCost, so the components still sum to the row.
95
+ const pricing = pricingForServedTier(provider, model, usage.servedTier);
41
96
  if (pricing === null)
42
97
  return null;
43
98
  const tokensIn = Math.max(usage.tokensIn, 0);
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Serving destination axis (Unified Route lane, spec U1 / ruling D-2) — the
3
+ * SINGLE vocabulary for WHERE a model call is served:
4
+ * - "direct" → called directly (today's behavior: routed lane uses the
5
+ * configured key; the raw inline on-ramp uses the caller's BYOK
6
+ * key). This is the default; ABSENT ⇒ BYTE-IDENTICAL.
7
+ * - "modelrig-served" → ModelRig serves the model on its OWN managed credentials
8
+ * (Fireworks / DeepInfra today; Z.ai deferred), behind the
9
+ * `config.managedServing` flag (set in code, default off; wired in U3).
10
+ *
11
+ * RULING D-2 (Matt, 2026-09-08, final): this axis is a "destination", NEVER a
12
+ * "lane"/"mode", and its served value is NEVER "managed" — that word already means
13
+ * key_ownership:managed (billing, registry/claims.ts) and artifact_posture:managed
14
+ * (content custody, settings/task-settings.ts), both orthogonal and both keep their
15
+ * names. See docs/ModelRig/unified-route/{research,spec}.md.
16
+ *
17
+ * The per-provider serving facts are seeded in raw-support.ts's capability table (the
18
+ * ONE source of truth), not here — this module owns the type + the vocabulary set + the
19
+ * lookups, which READ that table. Wired in U1 (raw-support.ts); the route contract
20
+ * consumes it in U2.
21
+ */
22
+ import type { ProviderId } from "../types/provider";
23
+ /** The serving destination for a model call (ruling D-2). */
24
+ export type Destination = "direct" | "modelrig-served";
25
+ /** The ordered, exhaustive set — the loader validates a route's `destination:` against
26
+ * this (routes/loader.ts, U2), mirroring PROVIDERS/TIERS. */
27
+ export declare const DESTINATIONS: readonly Destination[];
28
+ /** The default when a route/run declares none — ABSENT ⇒ BYTE-IDENTICAL. */
29
+ export declare const DEFAULT_DESTINATION: Destination;
30
+ /**
31
+ * Which destinations a provider can be served through. Seeded in the capability table
32
+ * (raw-support.ts) — `direct` for every provider; `modelrig-served` only for providers
33
+ * with a ModelRig-owned key today (fireworks, deepinfra — config.ts:303-304). Reads the
34
+ * seeded serving cell from RAW_KNOB_SUPPORT — no second list (one source of truth).
35
+ */
36
+ export declare function servedDestinations(provider: ProviderId): readonly Destination[];
37
+ /** True when a provider can serve the given destination (over servedDestinations()). */
38
+ export declare function destinationSupported(provider: ProviderId, destination: Destination): boolean;
39
+ //# sourceMappingURL=destination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destination.d.ts","sourceRoot":"","sources":["../../src/run/destination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAEvD;6DAC6D;AAC7D,eAAO,MAAM,YAAY,EAAE,SAAS,WAAW,EAAkC,CAAC;AAElF,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,EAAE,WAAsB,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,UAAU,GAAG,SAAS,WAAW,EAAE,CAE/E;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAE5F"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /**
3
+ * Serving destination axis (Unified Route lane, spec U1 / ruling D-2) — the
4
+ * SINGLE vocabulary for WHERE a model call is served:
5
+ * - "direct" → called directly (today's behavior: routed lane uses the
6
+ * configured key; the raw inline on-ramp uses the caller's BYOK
7
+ * key). This is the default; ABSENT ⇒ BYTE-IDENTICAL.
8
+ * - "modelrig-served" → ModelRig serves the model on its OWN managed credentials
9
+ * (Fireworks / DeepInfra today; Z.ai deferred), behind the
10
+ * `config.managedServing` flag (set in code, default off; wired in U3).
11
+ *
12
+ * RULING D-2 (Matt, 2026-09-08, final): this axis is a "destination", NEVER a
13
+ * "lane"/"mode", and its served value is NEVER "managed" — that word already means
14
+ * key_ownership:managed (billing, registry/claims.ts) and artifact_posture:managed
15
+ * (content custody, settings/task-settings.ts), both orthogonal and both keep their
16
+ * names. See docs/ModelRig/unified-route/{research,spec}.md.
17
+ *
18
+ * The per-provider serving facts are seeded in raw-support.ts's capability table (the
19
+ * ONE source of truth), not here — this module owns the type + the vocabulary set + the
20
+ * lookups, which READ that table. Wired in U1 (raw-support.ts); the route contract
21
+ * consumes it in U2.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.DEFAULT_DESTINATION = exports.DESTINATIONS = void 0;
25
+ exports.servedDestinations = servedDestinations;
26
+ exports.destinationSupported = destinationSupported;
27
+ const raw_support_1 = require("./raw-support");
28
+ /** The ordered, exhaustive set — the loader validates a route's `destination:` against
29
+ * this (routes/loader.ts, U2), mirroring PROVIDERS/TIERS. */
30
+ exports.DESTINATIONS = ["direct", "modelrig-served"];
31
+ /** The default when a route/run declares none — ABSENT ⇒ BYTE-IDENTICAL. */
32
+ exports.DEFAULT_DESTINATION = "direct";
33
+ /**
34
+ * Which destinations a provider can be served through. Seeded in the capability table
35
+ * (raw-support.ts) — `direct` for every provider; `modelrig-served` only for providers
36
+ * with a ModelRig-owned key today (fireworks, deepinfra — config.ts:303-304). Reads the
37
+ * seeded serving cell from RAW_KNOB_SUPPORT — no second list (one source of truth).
38
+ */
39
+ function servedDestinations(provider) {
40
+ return raw_support_1.RAW_KNOB_SUPPORT[provider].serving.destinations;
41
+ }
42
+ /** True when a provider can serve the given destination (over servedDestinations()). */
43
+ function destinationSupported(provider, destination) {
44
+ return servedDestinations(provider).includes(destination);
45
+ }