modelrig 0.9.0 → 0.11.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 (231) hide show
  1. package/CHANGELOG.md +227 -0
  2. package/README.md +51 -27
  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 +20 -0
  27. package/dist/artifacts/artifact.d.ts.map +1 -1
  28. package/dist/artifacts/artifact.js +207 -171
  29. package/dist/artifacts/index.d.ts +3 -1
  30. package/dist/artifacts/index.d.ts.map +1 -1
  31. package/dist/artifacts/index.js +8 -1
  32. package/dist/bakeoff/groundedness.d.ts +58 -0
  33. package/dist/bakeoff/groundedness.d.ts.map +1 -0
  34. package/dist/bakeoff/groundedness.js +165 -0
  35. package/dist/bakeoff/quality.d.ts +14 -1
  36. package/dist/bakeoff/quality.d.ts.map +1 -1
  37. package/dist/bakeoff/quality.js +10 -0
  38. package/dist/bakeoff/replay.d.ts.map +1 -1
  39. package/dist/bakeoff/replay.js +4 -0
  40. package/dist/cli.d.ts.map +1 -1
  41. package/dist/cli.js +8 -0
  42. package/dist/config.d.ts +31 -0
  43. package/dist/config.d.ts.map +1 -1
  44. package/dist/config.js +23 -0
  45. package/dist/doctor-cli.d.ts +7 -0
  46. package/dist/doctor-cli.d.ts.map +1 -0
  47. package/dist/doctor-cli.js +68 -0
  48. package/dist/doctor-preflight.d.ts +64 -0
  49. package/dist/doctor-preflight.d.ts.map +1 -0
  50. package/dist/doctor-preflight.js +167 -0
  51. package/dist/feedback/coverage.d.ts.map +1 -1
  52. package/dist/feedback/coverage.js +9 -2
  53. package/dist/feedback/grade.d.ts +8 -1
  54. package/dist/feedback/grade.d.ts.map +1 -1
  55. package/dist/feedback/grade.js +4 -0
  56. package/dist/gateway/http-protocol.d.ts +19 -0
  57. package/dist/gateway/http-protocol.d.ts.map +1 -1
  58. package/dist/gateway/serve-client.d.ts +99 -0
  59. package/dist/gateway/serve-client.d.ts.map +1 -0
  60. package/dist/gateway/serve-client.js +360 -0
  61. package/dist/index.d.ts +31 -3
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +71 -8
  64. package/dist/prompts/manifest.d.ts +128 -0
  65. package/dist/prompts/manifest.d.ts.map +1 -0
  66. package/dist/prompts/manifest.js +214 -0
  67. package/dist/prompts/prompt-fetch.d.ts +84 -0
  68. package/dist/prompts/prompt-fetch.d.ts.map +1 -0
  69. package/dist/prompts/prompt-fetch.js +120 -0
  70. package/dist/prompts/prompt-resolve.d.ts +76 -0
  71. package/dist/prompts/prompt-resolve.d.ts.map +1 -0
  72. package/dist/prompts/prompt-resolve.js +93 -0
  73. package/dist/prompts/slot-resolver.d.ts +91 -0
  74. package/dist/prompts/slot-resolver.d.ts.map +1 -0
  75. package/dist/prompts/slot-resolver.js +135 -0
  76. package/dist/prompts/tools-register.d.ts +60 -0
  77. package/dist/prompts/tools-register.d.ts.map +1 -0
  78. package/dist/prompts/tools-register.js +48 -0
  79. package/dist/prompts/version-hash.d.ts +29 -0
  80. package/dist/prompts/version-hash.d.ts.map +1 -0
  81. package/dist/prompts/version-hash.js +54 -0
  82. package/dist/prompts-export-cli.d.ts +21 -0
  83. package/dist/prompts-export-cli.d.ts.map +1 -0
  84. package/dist/prompts-export-cli.js +130 -0
  85. package/dist/registry/cache-policy.d.ts.map +1 -1
  86. package/dist/registry/cache-policy.js +22 -0
  87. package/dist/registry/pricing-shape.d.ts +38 -8
  88. package/dist/registry/pricing-shape.d.ts.map +1 -1
  89. package/dist/registry/pricing-shape.js +40 -12
  90. package/dist/registry/pricing.d.ts +6 -5
  91. package/dist/registry/pricing.d.ts.map +1 -1
  92. package/dist/registry/pricing.js +9 -5
  93. package/dist/routes/destination-loader.d.ts +16 -0
  94. package/dist/routes/destination-loader.d.ts.map +1 -0
  95. package/dist/routes/destination-loader.js +29 -0
  96. package/dist/routes/draft.d.ts +7 -0
  97. package/dist/routes/draft.d.ts.map +1 -1
  98. package/dist/routes/draft.js +12 -0
  99. package/dist/routes/loader.d.ts.map +1 -1
  100. package/dist/routes/loader.js +27 -54
  101. package/dist/routes/output-loader.d.ts +42 -0
  102. package/dist/routes/output-loader.d.ts.map +1 -0
  103. package/dist/routes/output-loader.js +112 -0
  104. package/dist/routes/prompt-loader.d.ts +49 -0
  105. package/dist/routes/prompt-loader.d.ts.map +1 -0
  106. package/dist/routes/prompt-loader.js +113 -0
  107. package/dist/routes/resolved-bundle.d.ts +19 -0
  108. package/dist/routes/resolved-bundle.d.ts.map +1 -1
  109. package/dist/routes/resolved-bundle.js +24 -0
  110. package/dist/routes/screen-loader.d.ts +1 -1
  111. package/dist/routes/screen-loader.d.ts.map +1 -1
  112. package/dist/routes/screen-loader.js +8 -1
  113. package/dist/run/accept.d.ts +3 -0
  114. package/dist/run/accept.d.ts.map +1 -1
  115. package/dist/run/accept.js +1 -0
  116. package/dist/run/cost.d.ts +31 -2
  117. package/dist/run/cost.d.ts.map +1 -1
  118. package/dist/run/cost.js +57 -2
  119. package/dist/run/destination.d.ts +39 -0
  120. package/dist/run/destination.d.ts.map +1 -0
  121. package/dist/run/destination.js +45 -0
  122. package/dist/run/dispatch.d.ts +25 -3
  123. package/dist/run/dispatch.d.ts.map +1 -1
  124. package/dist/run/dispatch.js +26 -4
  125. package/dist/run/raw-defaults.d.ts.map +1 -1
  126. package/dist/run/raw-defaults.js +6 -1
  127. package/dist/run/raw-finalize.d.ts +96 -0
  128. package/dist/run/raw-finalize.d.ts.map +1 -0
  129. package/dist/run/raw-finalize.js +283 -0
  130. package/dist/run/raw-knobs.d.ts +36 -0
  131. package/dist/run/raw-knobs.d.ts.map +1 -0
  132. package/dist/run/raw-knobs.js +99 -0
  133. package/dist/run/raw-request.d.ts +24 -0
  134. package/dist/run/raw-request.d.ts.map +1 -0
  135. package/dist/run/raw-request.js +69 -0
  136. package/dist/run/raw-schema.d.ts +76 -0
  137. package/dist/run/raw-schema.d.ts.map +1 -0
  138. package/dist/run/raw-schema.js +166 -0
  139. package/dist/run/raw-search-cost.d.ts +49 -0
  140. package/dist/run/raw-search-cost.d.ts.map +1 -0
  141. package/dist/run/raw-search-cost.js +79 -0
  142. package/dist/run/raw-support.d.ts +64 -6
  143. package/dist/run/raw-support.d.ts.map +1 -1
  144. package/dist/run/raw-support.js +84 -11
  145. package/dist/run/raw.d.ts +25 -26
  146. package/dist/run/raw.d.ts.map +1 -1
  147. package/dist/run/raw.js +30 -351
  148. package/dist/run/record-attempt.d.ts +8 -0
  149. package/dist/run/record-attempt.d.ts.map +1 -1
  150. package/dist/run/record-attempt.js +26 -12
  151. package/dist/run/record-call.d.ts +104 -0
  152. package/dist/run/record-call.d.ts.map +1 -0
  153. package/dist/run/record-call.js +277 -0
  154. package/dist/run/repair-attempt.d.ts +68 -0
  155. package/dist/run/repair-attempt.d.ts.map +1 -0
  156. package/dist/run/repair-attempt.js +180 -0
  157. package/dist/run/resolve-destination.d.ts +49 -0
  158. package/dist/run/resolve-destination.d.ts.map +1 -0
  159. package/dist/run/resolve-destination.js +76 -0
  160. package/dist/run/routing-docs.d.ts.map +1 -1
  161. package/dist/run/routing-docs.js +9 -4
  162. package/dist/run/run.d.ts +30 -1
  163. package/dist/run/run.d.ts.map +1 -1
  164. package/dist/run/run.js +75 -148
  165. package/dist/run/telemetry-row.d.ts +92 -0
  166. package/dist/run/telemetry-row.d.ts.map +1 -0
  167. package/dist/run/telemetry-row.js +81 -0
  168. package/dist/run/validate.d.ts +12 -1
  169. package/dist/run/validate.d.ts.map +1 -1
  170. package/dist/run/validate.js +31 -0
  171. package/dist/run/web-search-pricing.d.ts +43 -0
  172. package/dist/run/web-search-pricing.d.ts.map +1 -0
  173. package/dist/run/web-search-pricing.js +56 -0
  174. package/dist/settings/grading-guide.d.ts +27 -1
  175. package/dist/settings/grading-guide.d.ts.map +1 -1
  176. package/dist/status.d.ts +6 -0
  177. package/dist/status.d.ts.map +1 -1
  178. package/dist/status.js +4 -1
  179. package/dist/telemetry/artifact-store.d.ts.map +1 -1
  180. package/dist/telemetry/artifact-store.js +11 -0
  181. package/dist/telemetry/attempt-meta.d.ts +66 -1
  182. package/dist/telemetry/attempt-meta.d.ts.map +1 -1
  183. package/dist/telemetry/attempt-meta.js +27 -1
  184. package/dist/telemetry/exporter-setup.d.ts +2 -0
  185. package/dist/telemetry/exporter-setup.d.ts.map +1 -1
  186. package/dist/telemetry/exporter-setup.js +6 -1
  187. package/dist/telemetry/grade-mappers.d.ts +5 -2
  188. package/dist/telemetry/grade-mappers.d.ts.map +1 -1
  189. package/dist/telemetry/grade-mappers.js +8 -2
  190. package/dist/telemetry/grades-sql.d.ts +4 -1
  191. package/dist/telemetry/grades-sql.d.ts.map +1 -1
  192. package/dist/telemetry/grades-sql.js +26 -3
  193. package/dist/telemetry/ingest-protocol.d.ts +26 -2
  194. package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
  195. package/dist/telemetry/ingest-protocol.js +32 -29
  196. package/dist/telemetry/lanes.d.ts +31 -0
  197. package/dist/telemetry/lanes.d.ts.map +1 -0
  198. package/dist/telemetry/lanes.js +41 -0
  199. package/dist/telemetry/org-identity.d.ts +47 -0
  200. package/dist/telemetry/org-identity.d.ts.map +1 -0
  201. package/dist/telemetry/org-identity.js +100 -0
  202. package/dist/telemetry/route-registration.d.ts +48 -0
  203. package/dist/telemetry/route-registration.d.ts.map +1 -0
  204. package/dist/telemetry/route-registration.js +77 -0
  205. package/dist/telemetry/sinks.d.ts +10 -1
  206. package/dist/telemetry/sinks.d.ts.map +1 -1
  207. package/dist/telemetry/sinks.js +52 -6
  208. package/dist/telemetry/store-migrations.d.ts.map +1 -1
  209. package/dist/telemetry/store-migrations.js +13 -0
  210. package/dist/tenancy/api-key-format.d.ts +16 -1
  211. package/dist/tenancy/api-key-format.d.ts.map +1 -1
  212. package/dist/tenancy/api-key-format.js +17 -0
  213. package/dist/types/provider.d.ts +20 -3
  214. package/dist/types/provider.d.ts.map +1 -1
  215. package/dist/types/provider.js +1 -0
  216. package/dist/types/route.d.ts +76 -0
  217. package/dist/types/route.d.ts.map +1 -1
  218. package/dist/types/telemetry.d.ts +30 -2
  219. package/dist/types/telemetry.d.ts.map +1 -1
  220. package/docs/agent-skill/SKILL.md +75 -5
  221. package/docs/instrumentation.md +98 -36
  222. package/docs/llms.txt +96 -16
  223. package/docs/managed-serving.md +150 -0
  224. package/docs/mcp-oracle.md +75 -2
  225. package/docs/migration-playbook.md +5 -4
  226. package/docs/quickstart.md +169 -83
  227. package/package.json +3 -2
  228. package/registry/registry.json +82 -0
  229. package/dist/feedback/feedback.d.ts +0 -35
  230. package/dist/feedback/feedback.d.ts.map +0 -1
  231. package/dist/feedback/feedback.js +0 -39
@@ -67,7 +67,7 @@ function parseClassificationAndPhiGate(raw, ctx, problems) {
67
67
  /** Push a problem for every `{{var}}` referenced in the system template or the
68
68
  * grounding query that was not declared in `prompt.variables`. Colocated with
69
69
  * the variable parser it validates. */
70
- function pushUndeclaredVariableProblems(systemTemplate, groundingQuery, variables, problems) {
70
+ function pushUndeclaredVariableProblems(systemTemplate, groundingQuery, variables, problems, userTemplate) {
71
71
  const declared = new Set(variables);
72
72
  if (systemTemplate !== "") {
73
73
  for (const ref of (0, template_1.scanTemplateVariables)(systemTemplate)) {
@@ -76,6 +76,13 @@ function pushUndeclaredVariableProblems(systemTemplate, groundingQuery, variable
76
76
  }
77
77
  }
78
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
+ }
79
86
  if (groundingQuery !== undefined) {
80
87
  for (const ref of (0, template_1.scanTemplateVariables)(groundingQuery)) {
81
88
  if (!declared.has(ref))
@@ -42,6 +42,9 @@ export interface SuccessMetaInput {
42
42
  readonly mask?: RunMeta["mask"];
43
43
  /** SC-1a screen receipt (spec §5) — counts-only, when the route screens. */
44
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"];
45
48
  }
46
49
  /** The validated `RunMeta` for the accept path — `repairedBy` is null here (the
47
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,gB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AS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAChE,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,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"}
@@ -64,5 +64,6 @@ function buildSuccessMeta(input) {
64
64
  ...(input.quality !== undefined ? { quality: input.quality } : {}),
65
65
  ...(input.mask !== undefined ? { mask: input.mask } : {}),
66
66
  ...(input.screen !== undefined ? { screen: input.screen } : {}),
67
+ ...(input.destination !== undefined ? { destination: input.destination } : {}),
67
68
  };
68
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;;;;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,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,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
+ }
@@ -8,11 +8,12 @@
8
8
  * Tool *execution* is never ours (spec §4.4); these helpers normalize the
9
9
  * protocol and surface it — nothing here runs a tool.
10
10
  */
11
- import type { AdapterRequest, AdapterResult, CandidateRef, ProviderAdapter, ToolDefinition } from "../types/provider";
11
+ import type { AdapterRequest, AdapterResult, CandidateRef, ProviderAdapter, ServiceTier, ToolDefinition } from "../types/provider";
12
12
  import type { RigFailure } from "../types/failures";
13
- import type { RouteBundle, RunMeta, RunOptions, RunResult, RunTags } from "../types/route";
13
+ import type { OutputKind, RouteBundle, RunMeta, RunOptions, RunResult, RunTags } from "../types/route";
14
14
  import type { TelemetryRung, TelemetryStore } from "../types/telemetry";
15
15
  import type { AttemptMetaSource } from "../telemetry/attempt-meta";
16
+ import type { Destination } from "./destination";
16
17
  import type { LadderKeyMinter } from "./ladder-key";
17
18
  import type { MaskReceipt, ResolvedMaskPolicy } from "../mask/types";
18
19
  import type { RunVault } from "../mask/vault";
@@ -23,7 +24,9 @@ import type { ResolvedScreenPolicy, ScreenReceipt } from "../screen/types";
23
24
  * the tool-call helper here can record through the same closure. */
24
25
  export interface AttemptTelemetry {
25
26
  readonly candidate: CandidateRef;
26
- readonly servedTier: string;
27
+ /** Issue #2 (L6 F1): typed as the tier vocabulary (every producer passes a
28
+ * `ServiceTier`) so the meta usage can price at the served tier. */
29
+ readonly servedTier: ServiceTier;
27
30
  readonly tokensIn: number;
28
31
  readonly tokensOut: number;
29
32
  readonly tokensCached: number;
@@ -72,12 +75,28 @@ export declare function attemptMetaInputs(args: {
72
75
  readonly systemPrompt: string;
73
76
  readonly userDirective: string;
74
77
  readonly outputSchema: object | null;
78
+ /** QA-S7: the route's `outputKind` (absent on the bundle ⇒ `json`). This
79
+ * helper serves the ROUTE lane only, so every row it feeds carries the
80
+ * contract; the raw lane assembles its inputs inline and never sets it. */
81
+ readonly outputKind?: OutputKind | undefined;
75
82
  readonly result: AdapterResult;
76
83
  readonly tools?: readonly ToolDefinition[];
77
84
  }): AttemptMetaSource;
78
85
  /** run.ts's recordAttempt, threaded in so the tool-call path records through
79
86
  * the same ledger/tenancy closure the rest of the loop uses. */
80
87
  export type RecordAttempt = (attempt: AttemptTelemetry) => string;
88
+ /**
89
+ * Telemetry tag entry for a serving destination (Unified Route U2, ruling D-2 —
90
+ * the SINGLE tag literal U3/U4 stamp through). Returns the `destination` tag
91
+ * ONLY for a NON-default destination; for `direct` (the default) it returns `{}`
92
+ * so a routed telemetry row gains NO new tag — this is the CRITICAL
93
+ * absent⇒byte-identical rule (never stamp `destination` when it is `direct`, or
94
+ * every routed row would drift). DORMANT in U2: `modelrig-served` fails closed
95
+ * pre-dispatch (resolve-destination.ts), so no successful row reaches recording
96
+ * with a non-default destination yet; U3 stamps through this one helper once
97
+ * managed serving is enabled.
98
+ */
99
+ export declare function destinationTag(destination: Destination): Record<string, string>;
81
100
  /** Record the grounding-inject search's own telemetry row (WS3): a $-only line
82
101
  * under the synthetic "search" provider. Extracted from run.ts to keep it under
83
102
  * the LOC cap; behaviour is byte-identical to the prior inline recorder. */
@@ -185,6 +204,9 @@ export interface ToolCallResultParts {
185
204
  readonly callId: string;
186
205
  /** WI-1: the attempt-envelope inputs for the recorded row (spec §2). */
187
206
  readonly metaInputs?: AttemptMetaSource;
207
+ /** Unified Route U2 (D-2): the resolved served destination for `RunMeta`
208
+ * (always `direct` in U2 — `modelrig-served` fails closed pre-dispatch). */
209
+ readonly destination?: RunMeta["destination"];
188
210
  }
189
211
  /**
190
212
  * Record a tool-call turn and build its RunResult (spec §4.4). A tool call is
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/run/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,eAAe,EACf,cAAc,EACf,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAInE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CA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Q,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,EAAE;QAAE,EAAE,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACrD,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC;kDAC8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,QAAQ,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC;IACxC;gFAC4E;IAC5E,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAC/C;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,mBAAmB,GAAG,SAAS,CAkD/F"}
@@ -11,6 +11,7 @@
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.attemptMetaInputs = attemptMetaInputs;
14
+ exports.destinationTag = destinationTag;
14
15
  exports.recordSearchCostRow = recordSearchCostRow;
15
16
  exports.jsonModeCoaching = jsonModeCoaching;
16
17
  exports.buildAdapterRequest = buildAdapterRequest;
@@ -24,6 +25,8 @@ const node_crypto_1 = require("node:crypto");
24
25
  const attempt_meta_1 = require("../telemetry/attempt-meta");
25
26
  const cache_stamp_1 = require("./cache-stamp");
26
27
  const cache_handle_1 = require("./cache-handle");
28
+ const destination_1 = require("./destination");
29
+ const telemetry_row_1 = require("./telemetry-row");
27
30
  const seam_1 = require("../mask/seam");
28
31
  const grounding_1 = require("./grounding");
29
32
  const screen_1 = require("../screen/screen");
@@ -34,6 +37,7 @@ const screen_1 = require("../screen/screen");
34
37
  function attemptMetaInputs(args) {
35
38
  return {
36
39
  ...(args.result.meta !== undefined ? { adapterMeta: args.result.meta } : {}),
40
+ outputKind: args.outputKind ?? "json",
37
41
  renderedRequest: (0, attempt_meta_1.renderRequestForHash)({
38
42
  system: args.systemPrompt,
39
43
  user: args.userDirective,
@@ -43,6 +47,20 @@ function attemptMetaInputs(args) {
43
47
  ...(args.tools !== undefined ? { declaredToolNames: args.tools.map((t) => t.function.name) } : {}),
44
48
  };
45
49
  }
50
+ /**
51
+ * Telemetry tag entry for a serving destination (Unified Route U2, ruling D-2 —
52
+ * the SINGLE tag literal U3/U4 stamp through). Returns the `destination` tag
53
+ * ONLY for a NON-default destination; for `direct` (the default) it returns `{}`
54
+ * so a routed telemetry row gains NO new tag — this is the CRITICAL
55
+ * absent⇒byte-identical rule (never stamp `destination` when it is `direct`, or
56
+ * every routed row would drift). DORMANT in U2: `modelrig-served` fails closed
57
+ * pre-dispatch (resolve-destination.ts), so no successful row reaches recording
58
+ * with a non-default destination yet; U3 stamps through this one helper once
59
+ * managed serving is enabled.
60
+ */
61
+ function destinationTag(destination) {
62
+ return destination === destination_1.DEFAULT_DESTINATION ? {} : { destination };
63
+ }
46
64
  /** Record the grounding-inject search's own telemetry row (WS3): a $-only line
47
65
  * under the synthetic "search" provider. Extracted from run.ts to keep it under
48
66
  * the LOC cap; behaviour is byte-identical to the prior inline recorder. */
@@ -51,9 +69,11 @@ function recordSearchCostRow(telemetry, route, effectiveTags, servedVariant, sea
51
69
  // rides the same monotonic seq; candidate_index is the candidate this search
52
70
  // grounds for (the current one — the run loop set it before the search).
53
71
  const ladderKey = ladder.stamp();
54
- telemetry.record({
72
+ // U4: assembled by the ONE shared builder (./telemetry-row.ts). This row
73
+ // carries NO attempt-envelope `meta` — buildTelemetryRow omits the key when
74
+ // `meta` is not passed, preserving the former shape exactly.
75
+ telemetry.record((0, telemetry_row_1.buildTelemetryRow)({
55
76
  id: (0, node_crypto_1.randomUUID)(),
56
- ts: new Date().toISOString(),
57
77
  route: route.route,
58
78
  routeVersion: route.version,
59
79
  provider: "search",
@@ -71,7 +91,8 @@ function recordSearchCostRow(telemetry, route, effectiveTags, servedVariant, sea
71
91
  failureClass: null,
72
92
  attemptsJson: "{}",
73
93
  // Rung tag (R1 review, F1): the grounding-inject search-cost row.
74
- tagsJson: JSON.stringify({ ...effectiveTags, rung: "search" }),
94
+ baseTags: effectiveTags,
95
+ rung: "search",
75
96
  fingerprintCell: route.fingerprintCell,
76
97
  servedVariant,
77
98
  repairedBy: null,
@@ -81,7 +102,7 @@ function recordSearchCostRow(telemetry, route, effectiveTags, servedVariant, sea
81
102
  callId: ladderKey.callId,
82
103
  attemptSeq: ladderKey.attemptSeq,
83
104
  candidateIndex: ladderKey.candidateIndex,
84
- });
105
+ }));
85
106
  }
86
107
  /** Schema coaching for the json_mode rung — ported from the production DeepSeek
87
108
  * provider's schema-in-prompt guidance (minLength-is-a-FLOOR etc.). Lives here
@@ -349,6 +370,7 @@ function emitToolCallResult(record, parts) {
349
370
  repairedBy: null,
350
371
  callId: parts.callId,
351
372
  toolCalls: result.toolCalls,
373
+ ...(parts.destination !== undefined ? { destination: parts.destination } : {}),
352
374
  },
353
375
  };
354
376
  }
@@ -1 +1 @@
1
- {"version":3,"file":"raw-defaults.d.ts","sourceRoot":"","sources":["../../src/run/raw-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAI9D,CAAC;AAEF,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;4EACwE;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAeD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,aAAa,EA6DhD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAK1C"}
1
+ {"version":3,"file":"raw-defaults.d.ts","sourceRoot":"","sources":["../../src/run/raw-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAI9D,CAAC;AAEF,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;4EACwE;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAeD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,aAAa,EAkEhD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAK1C"}
@@ -55,7 +55,7 @@ exports.RAW_DEFAULTS = [
55
55
  {
56
56
  knob: "serviceTier",
57
57
  default: "standard",
58
- note: "forwarded to the adapter; `meta.servedTier` reports what actually served. On `flex`, set `timeoutMs` in minutes (default 900 s)",
58
+ note: "forwarded to the adapter; `meta.servedTier` reports what actually served, and the cost row is priced at the SERVED tier (gemini flex = 0.5× input + output, cache read NOT discounted; priority = 1.8×). On `flex`, set `timeoutMs` in minutes (default 900 s)",
59
59
  },
60
60
  {
61
61
  knob: "temperature",
@@ -87,6 +87,11 @@ exports.RAW_DEFAULTS = [
87
87
  default: "absent ⇒ byte-identical",
88
88
  note: "syntactic-JSON forcing (mime-shaping only); provider support per the raw-lane knob matrix",
89
89
  },
90
+ {
91
+ knob: "responseSchema",
92
+ default: "absent ⇒ byte-identical (no schema sent, no validation)",
93
+ note: "JSON Schema forwarded natively AND Ajv-checked client-side — a miss is a billed, terminal `content_invalid` (never repaired); `meta.schema_sha` on the row; provider support per the raw-lane knob matrix",
94
+ },
90
95
  {
91
96
  knob: "cache",
92
97
  default: "none",
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Raw-lane finalize + telemetry (spec §4.2/§4.3), extracted from raw.ts (Unified
3
+ * Route U4) to keep raw.ts under the 700-LOC cap (dev-rule P1). PURE MOVE in
4
+ * Phase A — `prepareRawStep`, `finalizeRaw`, `recordRawRow`, and the tier-aware
5
+ * timeout fixHint are byte-identical to their former raw.ts definitions.
6
+ *
7
+ * Raw-lane no-hard-hot-path-dependency invariant preserved: this module imports
8
+ * cost/telemetry/run-context/attempt-meta helpers and the native-search cost
9
+ * recorder — NO route/registry/capability-gate dependency.
10
+ */
11
+ import { type ActiveRunContext } from "../artifacts/run-context";
12
+ import type { AdapterResult, AdapterUsage, ProviderId, ServiceTier } from "../types/provider";
13
+ import type { RunResult, RunTags } from "../types/route";
14
+ import type { AttemptMetaV1 } from "../telemetry/attempt-meta";
15
+ import type { TelemetryRow, TelemetryStore } from "../types/telemetry";
16
+ import type { RawRunDeps, RawRunInput } from "./raw";
17
+ /** R1 — the teaching `fixHint` attached to a `timeout` failure on the raw lane:
18
+ * it names the elapsed budget, the tier, that tier's advertised target, and the
19
+ * two fixes (raise `timeoutMs`, or drop to `standard`). Built from
20
+ * `RAW_TIMEOUT_DEFAULT_MS` so the default it quotes can never drift. */
21
+ export declare function rawTimeoutFixHint(input: RawRunInput, tier: ServiceTier): string;
22
+ export interface RawRowParts {
23
+ readonly id: string;
24
+ readonly rawModelId: string;
25
+ /** A `ProviderId` on the raw lane; any non-empty string on a recorded call
26
+ * (OBS-1 `rig.recordCall` accepts providers ModelRig has no adapter for). */
27
+ readonly provider: ProviderId | string;
28
+ readonly model: string;
29
+ readonly usage?: AdapterUsage;
30
+ readonly costUsd: number;
31
+ readonly latencyMs: number;
32
+ /** CE-2 F2: the DECLARED service tier (default "standard"), reported truthfully
33
+ * on the row instead of the old hardcode. */
34
+ readonly requestedTier: ServiceTier;
35
+ /** OBS-1: the served tier when no `usage` is supplied — unused on the raw
36
+ * lane (absent ⇒ `usage.servedTier ?? "standard"`, byte-identical). */
37
+ readonly servedTier?: ServiceTier;
38
+ readonly failureClass: TelemetryRow["failureClass"];
39
+ readonly tags: RunTags;
40
+ readonly pricingMissing: boolean;
41
+ /** CE-1: the customer cache key applied to this raw dispatch, or null. */
42
+ readonly cacheKey?: string | null;
43
+ /** The per-call ladder key (spec §2.1 R0). The raw lane is a single-attempt,
44
+ * single-candidate dispatch: one call_id, attempt_seq 1, candidate_index 0. */
45
+ readonly callId: string;
46
+ /** WI-1 attempt envelope (spec §2) — built by the SAME producer the routed
47
+ * lane uses (lane parity), from the SAME rendered-request canonicalization. */
48
+ readonly meta?: AttemptMetaV1 | null;
49
+ }
50
+ /** Write the metered raw-lane telemetry row. Mirrors the run loop's minimal
51
+ * `recordSearchCostRow` shape: only load-bearing fields set, route = the
52
+ * `provider/model` handle the caller used, lane + key_ownership riding in
53
+ * `tags_json`. The exporter mirrors it on its normal cadence — no lane column,
54
+ * no schema change (telemetry map, 2026-08-10). */
55
+ export declare function recordRawRow(telemetry: TelemetryStore, p: RawRowParts): void;
56
+ /** The active-run-context binding a raw call resolves ONCE at entry (the ALS
57
+ * boundary — read synchronously before the stream generator defers), so
58
+ * `finalizeRaw` can mirror the call into a ground-truth step (G1 spec §4). Null
59
+ * when there is no `run.start` on this path (the common, uninstrumented case). */
60
+ export interface RawStepContext {
61
+ readonly runCtx: ActiveRunContext;
62
+ readonly stepKey: string;
63
+ readonly startedAtIso: string;
64
+ }
65
+ /**
66
+ * Read the ambient run context at the ENTRY of a raw call (spec §4) and, if
67
+ * present, resolve the step key `input.stepKey ?? tags.step ?? provider/model#n`
68
+ * (validated) — so `finalizeRaw` records a ground-truth step exactly like the
69
+ * routed lane. Also runs the required-dimension hygiene warning (spec §4),
70
+ * unconditionally, as the routed lane does. Fail-open: no context ⇒ null and no
71
+ * step is ever recorded; the dispatch is byte-identical to pre-G1.
72
+ */
73
+ export declare function prepareRawStep(deps: Pick<RawRunDeps, "manifest">, input: {
74
+ readonly provider: string;
75
+ readonly model: string;
76
+ readonly stepKey?: string;
77
+ readonly tags?: RunTags;
78
+ }): RawStepContext | null;
79
+ /** G1: mirror one lane-B inference (raw, or an OBS-1 recorded call) into a
80
+ * ground-truth step — parity with the routed lane's record-attempt. No-op when
81
+ * no run context was captured at entry. Fail-open is handled inside
82
+ * `emitGroundTruthStep` (buffer errors are swallowed). */
83
+ export declare function emitRawStep(step: RawStepContext | null, task: string, inferenceId: string, failureClass: string | null): void;
84
+ /**
85
+ * Turn an `AdapterResult` into a RunResult, recording exactly one telemetry row.
86
+ * Shared by the buffered and streaming paths so cost/telemetry are byte-identical.
87
+ * On a failure result: record the (possibly billed) row, then throw
88
+ * `RigFailureError` — the server maps it to a status exactly like the slug lane.
89
+ *
90
+ * G1: when a run context was captured at entry (`step`), a ground-truth step is
91
+ * emitted after the telemetry row on BOTH branches (success and failure) —
92
+ * fail-open, so a buffer error there never affects the returned result. No
93
+ * artifact CONTENT is written on the raw lane (spec F3): steps are metadata.
94
+ */
95
+ export declare function finalizeRaw(deps: RawRunDeps, input: RawRunInput, result: AdapterResult, latencyMs: number, step: RawStepContext | null): RunResult;
96
+ //# sourceMappingURL=raw-finalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw-finalize.d.ts","sourceRoot":"","sources":["../../src/run/raw-finalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAW,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