@mupt-ai/dari-gateway 0.1.0 → 0.2.1

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 (369) hide show
  1. package/README.md +8 -1
  2. package/dist/bun.d.ts +2 -0
  3. package/dist/bun.js +4 -0
  4. package/dist/context/eval_catalog.d.ts +3 -0
  5. package/dist/context/eval_catalog.js +7 -0
  6. package/dist/context/interaction_fingerprint.d.ts +27 -0
  7. package/dist/context/interaction_fingerprint.js +519 -0
  8. package/dist/context/interaction_fingerprint_format.d.ts +42 -0
  9. package/dist/context/interaction_fingerprint_format.js +113 -0
  10. package/dist/context/interaction_lease_depth.d.ts +2 -0
  11. package/dist/context/interaction_lease_depth.js +110 -0
  12. package/dist/context/lease_history.d.ts +7 -0
  13. package/dist/context/lease_history.js +158 -0
  14. package/dist/context/pricing.d.ts +4 -0
  15. package/dist/context/pricing.js +23 -0
  16. package/dist/context/provider_prompt_accounting.d.ts +14 -0
  17. package/dist/context/provider_prompt_accounting.js +187 -0
  18. package/dist/context/routing_context.d.ts +40 -0
  19. package/dist/context/routing_context.js +211 -0
  20. package/dist/http/auth.d.ts +2 -0
  21. package/dist/http/auth.js +35 -0
  22. package/dist/http/errors.d.ts +19 -0
  23. package/dist/http/errors.js +89 -0
  24. package/dist/http/handler.d.ts +12 -0
  25. package/dist/http/handler.js +81 -0
  26. package/dist/http/http2_server.d.ts +6 -0
  27. package/dist/http/http2_server.js +103 -0
  28. package/dist/http/serve.d.ts +20 -0
  29. package/dist/http/serve.js +78 -0
  30. package/dist/index.d.ts +6 -0
  31. package/dist/index.js +8 -0
  32. package/dist/ingress/anthropic_messages.d.ts +3 -0
  33. package/dist/ingress/anthropic_messages.js +122 -0
  34. package/dist/ingress/anthropic_models.d.ts +1 -0
  35. package/dist/ingress/anthropic_models.js +23 -0
  36. package/dist/ingress/chat_completions.d.ts +2 -0
  37. package/dist/ingress/chat_completions.js +37 -0
  38. package/dist/ingress/claude_code/request_context.d.ts +2 -0
  39. package/dist/ingress/claude_code/request_context.js +31 -0
  40. package/dist/ingress/codex.d.ts +3 -0
  41. package/dist/ingress/codex.js +65 -0
  42. package/dist/ingress/codex_models.d.ts +2 -0
  43. package/dist/ingress/codex_models.js +89 -0
  44. package/dist/ingress/json.d.ts +1 -0
  45. package/dist/ingress/json.js +95 -0
  46. package/dist/ingress/models.d.ts +1 -0
  47. package/dist/ingress/models.js +53 -0
  48. package/dist/interaction/capabilities.d.ts +3 -0
  49. package/dist/interaction/capabilities.js +24 -0
  50. package/dist/interaction/image.d.ts +4 -0
  51. package/dist/interaction/image.js +13 -0
  52. package/dist/interaction/portable_reasoning_state.d.ts +4 -0
  53. package/dist/interaction/portable_reasoning_state.js +18 -0
  54. package/dist/interaction/provider_continuation_state.d.ts +6 -0
  55. package/dist/interaction/provider_continuation_state.js +27 -0
  56. package/dist/interaction/tool_identity.d.ts +10 -0
  57. package/dist/interaction/tool_identity.js +41 -0
  58. package/dist/interaction/types.d.ts +203 -0
  59. package/dist/interaction/types.js +5 -0
  60. package/dist/models/context_limits.d.ts +2 -0
  61. package/dist/models/context_limits.js +7 -0
  62. package/dist/models/execution_provider.d.ts +8 -0
  63. package/dist/models/execution_provider.js +13 -0
  64. package/dist/models/gateways.d.ts +11 -0
  65. package/dist/models/gateways.js +45 -0
  66. package/dist/models/ids.d.ts +1 -0
  67. package/dist/models/ids.js +15 -0
  68. package/dist/models/provider_defaults.d.ts +4 -0
  69. package/dist/models/provider_defaults.js +41 -0
  70. package/dist/models/runtime_overrides.d.ts +4 -0
  71. package/dist/models/runtime_overrides.js +209 -0
  72. package/dist/observability/errors.d.ts +8 -0
  73. package/dist/observability/errors.js +11 -0
  74. package/dist/platform/platform.d.ts +152 -0
  75. package/dist/platform/platform.js +11 -0
  76. package/dist/platform/routing_contract.d.ts +2 -0
  77. package/dist/platform/routing_contract.js +5 -0
  78. package/dist/protocol/input/anthropic_messages.d.ts +2 -0
  79. package/dist/protocol/input/anthropic_messages.js +494 -0
  80. package/dist/protocol/input/chat_completions.d.ts +4 -0
  81. package/dist/protocol/input/chat_completions.js +212 -0
  82. package/dist/protocol/input/chat_completions_validation.d.ts +2 -0
  83. package/dist/protocol/input/chat_completions_validation.js +257 -0
  84. package/dist/protocol/input/openai_responses.d.ts +2 -0
  85. package/dist/protocol/input/openai_responses.js +666 -0
  86. package/dist/protocol/input/router_model.d.ts +7 -0
  87. package/dist/protocol/input/router_model.js +43 -0
  88. package/dist/protocol/output/anthropic_messages.d.ts +10 -0
  89. package/dist/protocol/output/anthropic_messages.js +15 -0
  90. package/dist/protocol/output/anthropic_messages_output.d.ts +10 -0
  91. package/dist/protocol/output/anthropic_messages_output.js +124 -0
  92. package/dist/protocol/output/anthropic_messages_stream.d.ts +16 -0
  93. package/dist/protocol/output/anthropic_messages_stream.js +267 -0
  94. package/dist/protocol/output/chat_completions.d.ts +29 -0
  95. package/dist/protocol/output/chat_completions.js +406 -0
  96. package/dist/protocol/output/chat_reasoning_detail.d.ts +2 -0
  97. package/dist/protocol/output/chat_reasoning_detail.js +13 -0
  98. package/dist/protocol/output/delivered_stream_snapshot.d.ts +10 -0
  99. package/dist/protocol/output/delivered_stream_snapshot.js +31 -0
  100. package/dist/protocol/output/openai_responses.d.ts +10 -0
  101. package/dist/protocol/output/openai_responses.js +14 -0
  102. package/dist/protocol/output/openai_responses_output.d.ts +14 -0
  103. package/dist/protocol/output/openai_responses_output.js +125 -0
  104. package/dist/protocol/output/openai_responses_stream.d.ts +18 -0
  105. package/dist/protocol/output/openai_responses_stream.js +546 -0
  106. package/dist/protocol/output/sse_stream.d.ts +31 -0
  107. package/dist/protocol/output/sse_stream.js +67 -0
  108. package/dist/providers/anthropic_safeguards.d.ts +11 -0
  109. package/dist/providers/anthropic_safeguards.js +81 -0
  110. package/dist/providers/aws_assume_role.d.ts +17 -0
  111. package/dist/providers/aws_assume_role.js +107 -0
  112. package/dist/providers/cancel_estimate.d.ts +43 -0
  113. package/dist/providers/cancel_estimate.js +89 -0
  114. package/dist/providers/execution.d.ts +72 -0
  115. package/dist/providers/execution.js +491 -0
  116. package/dist/providers/model_capabilities.d.ts +11 -0
  117. package/dist/providers/model_capabilities.js +29 -0
  118. package/dist/providers/pi.d.ts +65 -0
  119. package/dist/providers/pi.js +319 -0
  120. package/dist/providers/pi_context.d.ts +7 -0
  121. package/dist/providers/pi_context.js +405 -0
  122. package/dist/providers/pi_options.d.ts +11 -0
  123. package/dist/providers/pi_options.js +398 -0
  124. package/dist/providers/pi_output.d.ts +2 -0
  125. package/dist/providers/pi_output.js +453 -0
  126. package/dist/providers/provider_attempt_runner.d.ts +55 -0
  127. package/dist/providers/provider_attempt_runner.js +90 -0
  128. package/dist/providers/provider_call.d.ts +77 -0
  129. package/dist/providers/provider_call.js +292 -0
  130. package/dist/providers/provider_reported_cost.d.ts +10 -0
  131. package/dist/providers/provider_reported_cost.js +123 -0
  132. package/dist/providers/reasoning.d.ts +12 -0
  133. package/dist/providers/reasoning.js +30 -0
  134. package/dist/providers/response_capture.d.ts +23 -0
  135. package/dist/providers/response_capture.js +47 -0
  136. package/dist/providers/stream_finalization.d.ts +46 -0
  137. package/dist/providers/stream_finalization.js +165 -0
  138. package/dist/providers/subscription_limits.d.ts +31 -0
  139. package/dist/providers/subscription_limits.js +163 -0
  140. package/dist/providers/subscription_usage.d.ts +10 -0
  141. package/dist/providers/subscription_usage.js +79 -0
  142. package/dist/runtime/claude_code/auxiliary_routing.d.ts +3 -0
  143. package/dist/runtime/claude_code/auxiliary_routing.js +60 -0
  144. package/dist/runtime/customer_disconnect.d.ts +20 -0
  145. package/dist/runtime/customer_disconnect.js +49 -0
  146. package/dist/runtime/explicit_model.d.ts +4 -0
  147. package/dist/runtime/explicit_model.js +53 -0
  148. package/dist/runtime/harness_identity/conversation.d.ts +33 -0
  149. package/dist/runtime/harness_identity/conversation.js +39 -0
  150. package/dist/runtime/harness_identity/extract.d.ts +8 -0
  151. package/dist/runtime/harness_identity/extract.js +214 -0
  152. package/dist/runtime/harness_identity/index.d.ts +2 -0
  153. package/dist/runtime/harness_identity/index.js +2 -0
  154. package/dist/runtime/prepare_routed_completion.d.ts +33 -0
  155. package/dist/runtime/prepare_routed_completion.js +167 -0
  156. package/dist/runtime/provider_stream_lifecycle.d.ts +31 -0
  157. package/dist/runtime/provider_stream_lifecycle.js +88 -0
  158. package/dist/runtime/provider_stream_outcome.d.ts +23 -0
  159. package/dist/runtime/provider_stream_outcome.js +55 -0
  160. package/dist/runtime/request_tags.d.ts +7 -0
  161. package/dist/runtime/request_tags.js +33 -0
  162. package/dist/runtime/routed_completion.d.ts +17 -0
  163. package/dist/runtime/routed_completion.js +80 -0
  164. package/dist/runtime/routed_protocol.d.ts +30 -0
  165. package/dist/runtime/routed_protocol.js +1 -0
  166. package/dist/runtime/routed_runtime.d.ts +40 -0
  167. package/dist/runtime/routed_runtime.js +535 -0
  168. package/dist/runtime/routing_lease.d.ts +26 -0
  169. package/dist/runtime/routing_lease.js +210 -0
  170. package/dist/runtime/runtime_reporter.d.ts +71 -0
  171. package/dist/runtime/runtime_reporter.js +35 -0
  172. package/dist/self_host/config.d.ts +46 -0
  173. package/dist/self_host/config.js +105 -0
  174. package/dist/self_host/main.d.ts +16 -0
  175. package/dist/self_host/main.js +95 -0
  176. package/dist/self_host/platform.d.ts +13 -0
  177. package/dist/self_host/platform.js +50 -0
  178. package/dist/self_host/prefix_store.d.ts +46 -0
  179. package/dist/self_host/prefix_store.js +261 -0
  180. package/dist/self_host/resolve.d.ts +28 -0
  181. package/dist/self_host/resolve.js +171 -0
  182. package/dist/self_host/subscriptions/access.d.ts +10 -0
  183. package/dist/self_host/subscriptions/access.js +37 -0
  184. package/dist/self_host/subscriptions/http.d.ts +15 -0
  185. package/dist/self_host/subscriptions/http.js +187 -0
  186. package/dist/self_host/subscriptions/index.d.ts +24 -0
  187. package/dist/self_host/subscriptions/index.js +24 -0
  188. package/dist/self_host/subscriptions/oauth.d.ts +55 -0
  189. package/dist/self_host/subscriptions/oauth.js +281 -0
  190. package/dist/self_host/subscriptions/store.d.ts +78 -0
  191. package/dist/self_host/subscriptions/store.js +235 -0
  192. package/dist/strategies/auto_routing_selector.d.ts +12 -0
  193. package/dist/strategies/auto_routing_selector.js +61 -0
  194. package/dist/strategies/eval_relevance.d.ts +17 -0
  195. package/dist/strategies/eval_relevance.js +32 -0
  196. package/dist/strategies/fallback_decision.d.ts +8 -0
  197. package/dist/strategies/fallback_decision.js +17 -0
  198. package/dist/strategies/priority_selector.d.ts +7 -0
  199. package/dist/strategies/priority_selector.js +37 -0
  200. package/dist/strategies/route_decision.d.ts +22 -0
  201. package/dist/strategies/route_decision.js +65 -0
  202. package/dist/strategies/routing.d.ts +74 -0
  203. package/dist/strategies/routing.js +280 -0
  204. package/dist/strategies/selector_projection.d.ts +15 -0
  205. package/dist/strategies/selector_projection.js +161 -0
  206. package/dist/telemetry/background.d.ts +7 -0
  207. package/dist/telemetry/background.js +33 -0
  208. package/dist/telemetry/benchmark_replay.d.ts +37 -0
  209. package/dist/telemetry/benchmark_replay.js +108 -0
  210. package/dist/telemetry/billing_finalization.d.ts +64 -0
  211. package/dist/telemetry/billing_finalization.js +96 -0
  212. package/dist/telemetry/ingest_values.d.ts +4 -0
  213. package/dist/telemetry/ingest_values.js +12 -0
  214. package/dist/telemetry/model_cost.d.ts +3 -0
  215. package/dist/telemetry/model_cost.js +15 -0
  216. package/dist/telemetry/prefix_state.d.ts +47 -0
  217. package/dist/telemetry/prefix_state.js +116 -0
  218. package/dist/telemetry/report.d.ts +88 -0
  219. package/dist/telemetry/report.js +621 -0
  220. package/dist/telemetry/requests/interaction_observability.d.ts +45 -0
  221. package/dist/telemetry/requests/interaction_observability.js +180 -0
  222. package/dist/telemetry/requests/retained_interaction_request.d.ts +8 -0
  223. package/dist/telemetry/requests/retained_interaction_request.js +10 -0
  224. package/dist/telemetry/scrub.d.ts +2 -0
  225. package/dist/telemetry/scrub.js +31 -0
  226. package/dist/telemetry/skills/claude/catalog.d.ts +6 -0
  227. package/dist/telemetry/skills/claude/catalog.js +99 -0
  228. package/dist/telemetry/skills/claude/file_reads.d.ts +4 -0
  229. package/dist/telemetry/skills/claude/file_reads.js +110 -0
  230. package/dist/telemetry/skills/claude/observations.d.ts +3 -0
  231. package/dist/telemetry/skills/claude/observations.js +366 -0
  232. package/dist/telemetry/skills/codex/catalog.d.ts +11 -0
  233. package/dist/telemetry/skills/codex/catalog.js +138 -0
  234. package/dist/telemetry/skills/codex/exec_file_reads.d.ts +9 -0
  235. package/dist/telemetry/skills/codex/exec_file_reads.js +36 -0
  236. package/dist/telemetry/skills/codex/explicit.d.ts +3 -0
  237. package/dist/telemetry/skills/codex/explicit.js +90 -0
  238. package/dist/telemetry/skills/codex/file_reads.d.ts +4 -0
  239. package/dist/telemetry/skills/codex/file_reads.js +37 -0
  240. package/dist/telemetry/skills/codex/identity.d.ts +2 -0
  241. package/dist/telemetry/skills/codex/identity.js +20 -0
  242. package/dist/telemetry/skills/observations.d.ts +21 -0
  243. package/dist/telemetry/skills/observations.js +41 -0
  244. package/dist/telemetry/skills/paths.d.ts +11 -0
  245. package/dist/telemetry/skills/paths.js +61 -0
  246. package/dist/telemetry/skills/pi.d.ts +6 -0
  247. package/dist/telemetry/skills/pi.js +223 -0
  248. package/dist/telemetry/skills/shell_file_reads.d.ts +7 -0
  249. package/dist/telemetry/skills/shell_file_reads.js +226 -0
  250. package/dist/telemetry/skills/shell_words.d.ts +13 -0
  251. package/dist/telemetry/skills/shell_words.js +189 -0
  252. package/dist/telemetry/tools/input.d.ts +2 -0
  253. package/dist/telemetry/tools/input.js +14 -0
  254. package/dist/telemetry/tools/observations.d.ts +29 -0
  255. package/dist/telemetry/tools/observations.js +247 -0
  256. package/dist/telemetry/usage.d.ts +57 -0
  257. package/dist/telemetry/usage.js +136 -0
  258. package/dist/types.d.ts +94 -0
  259. package/dist/types.js +1 -0
  260. package/package.json +22 -5
  261. package/src/bun.ts +4 -0
  262. package/src/context/eval_catalog.ts +1 -1
  263. package/src/context/interaction_fingerprint.ts +9 -9
  264. package/src/context/interaction_fingerprint_format.ts +1 -1
  265. package/src/context/interaction_lease_depth.ts +1 -1
  266. package/src/context/pricing.ts +1 -1
  267. package/src/context/provider_prompt_accounting.ts +5 -5
  268. package/src/context/routing_context.ts +17 -17
  269. package/src/http/auth.ts +1 -1
  270. package/src/http/handler.ts +8 -8
  271. package/src/http/serve.ts +3 -3
  272. package/src/index.ts +10 -9
  273. package/src/ingress/anthropic_messages.ts +12 -12
  274. package/src/ingress/anthropic_models.ts +1 -1
  275. package/src/ingress/chat_completions.ts +9 -9
  276. package/src/ingress/claude_code/request_context.ts +2 -2
  277. package/src/ingress/codex.ts +10 -10
  278. package/src/ingress/codex_models.ts +4 -4
  279. package/src/ingress/json.ts +1 -1
  280. package/src/ingress/models.ts +10 -10
  281. package/src/interaction/capabilities.ts +1 -1
  282. package/src/interaction/portable_reasoning_state.ts +1 -1
  283. package/src/interaction/provider_continuation_state.ts +1 -1
  284. package/src/interaction/tool_identity.ts +2 -2
  285. package/src/interaction/types.ts +3 -0
  286. package/src/models/context_limits.ts +1 -1
  287. package/src/models/execution_provider.ts +1 -1
  288. package/src/models/ids.ts +1 -1
  289. package/src/models/provider_defaults.ts +1 -1
  290. package/src/models/runtime_overrides.ts +1 -1
  291. package/src/observability/errors.ts +2 -2
  292. package/src/platform/platform.ts +36 -4
  293. package/src/protocol/input/anthropic_messages.ts +7 -7
  294. package/src/protocol/input/chat_completions.ts +5 -5
  295. package/src/protocol/input/chat_completions_validation.ts +4 -4
  296. package/src/protocol/input/openai_responses.ts +6 -6
  297. package/src/protocol/output/anthropic_messages.ts +3 -3
  298. package/src/protocol/output/anthropic_messages_output.ts +6 -4
  299. package/src/protocol/output/anthropic_messages_stream.ts +7 -7
  300. package/src/protocol/output/chat_completions.ts +13 -13
  301. package/src/protocol/output/chat_reasoning_detail.ts +1 -1
  302. package/src/protocol/output/openai_responses.ts +3 -3
  303. package/src/protocol/output/openai_responses_output.ts +4 -2
  304. package/src/protocol/output/openai_responses_stream.ts +6 -6
  305. package/src/protocol/output/sse_stream.ts +3 -3
  306. package/src/providers/anthropic_safeguards.ts +2 -2
  307. package/src/providers/aws_assume_role.ts +2 -2
  308. package/src/providers/cancel_estimate.ts +1 -1
  309. package/src/providers/execution.ts +17 -17
  310. package/src/providers/pi.ts +115 -41
  311. package/src/providers/pi_context.ts +6 -6
  312. package/src/providers/pi_options.ts +283 -453
  313. package/src/providers/pi_output.ts +6 -5
  314. package/src/providers/provider_attempt_runner.ts +1 -1
  315. package/src/providers/provider_call.ts +37 -18
  316. package/src/providers/provider_reported_cost.ts +138 -0
  317. package/src/providers/reasoning.ts +2 -2
  318. package/src/providers/stream_finalization.ts +10 -10
  319. package/src/providers/subscription_limits.ts +3 -3
  320. package/src/runtime/claude_code/auxiliary_routing.ts +5 -5
  321. package/src/runtime/customer_disconnect.ts +1 -1
  322. package/src/runtime/explicit_model.ts +31 -4
  323. package/src/runtime/harness_identity/conversation.ts +1 -1
  324. package/src/runtime/harness_identity/extract.ts +3 -3
  325. package/src/runtime/harness_identity/index.ts +2 -2
  326. package/src/runtime/prepare_routed_completion.ts +46 -10
  327. package/src/runtime/provider_stream_lifecycle.ts +1 -1
  328. package/src/runtime/provider_stream_outcome.ts +2 -2
  329. package/src/runtime/request_tags.ts +34 -0
  330. package/src/runtime/routed_completion.ts +13 -11
  331. package/src/runtime/routed_protocol.ts +2 -2
  332. package/src/runtime/routed_runtime.ts +38 -20
  333. package/src/runtime/routing_lease.ts +7 -7
  334. package/src/runtime/runtime_reporter.ts +3 -3
  335. package/src/self_host/main.ts +19 -14
  336. package/src/self_host/platform.ts +5 -5
  337. package/src/self_host/prefix_store.ts +2 -2
  338. package/src/self_host/resolve.ts +11 -11
  339. package/src/self_host/subscriptions/access.ts +2 -2
  340. package/src/self_host/subscriptions/http.ts +2 -2
  341. package/src/self_host/subscriptions/index.ts +4 -4
  342. package/src/self_host/subscriptions/store.ts +1 -1
  343. package/src/strategies/auto_routing_selector.ts +2 -2
  344. package/src/strategies/eval_relevance.ts +3 -3
  345. package/src/strategies/priority_selector.ts +1 -1
  346. package/src/strategies/route_decision.ts +7 -7
  347. package/src/strategies/routing.ts +11 -11
  348. package/src/strategies/selector_projection.ts +2 -2
  349. package/src/telemetry/billing_finalization.ts +3 -3
  350. package/src/telemetry/model_cost.ts +1 -1
  351. package/src/telemetry/prefix_state.ts +4 -4
  352. package/src/telemetry/report.ts +30 -25
  353. package/src/telemetry/requests/interaction_observability.ts +1 -1
  354. package/src/telemetry/requests/retained_interaction_request.ts +1 -1
  355. package/src/telemetry/skills/claude/catalog.ts +1 -1
  356. package/src/telemetry/skills/claude/file_reads.ts +6 -6
  357. package/src/telemetry/skills/claude/observations.ts +3 -3
  358. package/src/telemetry/skills/codex/catalog.ts +3 -3
  359. package/src/telemetry/skills/codex/exec_file_reads.ts +4 -4
  360. package/src/telemetry/skills/codex/explicit.ts +3 -3
  361. package/src/telemetry/skills/codex/file_reads.ts +5 -5
  362. package/src/telemetry/skills/observations.ts +7 -7
  363. package/src/telemetry/skills/pi.ts +3 -3
  364. package/src/telemetry/skills/shell_file_reads.ts +2 -2
  365. package/src/telemetry/skills/shell_words.ts +1 -1
  366. package/src/telemetry/tools/input.ts +1 -1
  367. package/src/telemetry/tools/observations.ts +9 -9
  368. package/src/telemetry/usage.ts +9 -5
  369. package/src/types.ts +15 -0
@@ -1,4 +1,4 @@
1
- import { gatewayFor } from "./gateways";
1
+ import { gatewayFor } from "./gateways.js";
2
2
 
3
3
  // Built-in model provider presentation and endpoint defaults; gateways carry
4
4
  // their own. Mirrors the hosted Dari model catalog's provider defaults; keep
@@ -1,6 +1,6 @@
1
1
  import { canonicalModelId, isRecord } from "@mupt-ai/dari-router/policy-engine";
2
2
 
3
- import { gatewayFor } from "./gateways";
3
+ import { gatewayFor } from "./gateways.js";
4
4
 
5
5
  const MODEL_CONTEXT_OVERRIDES: Record<string, number> = {
6
6
  // Selector and title models are not router candidate configs, so their
@@ -2,9 +2,9 @@ import {
2
2
  gatewayPlatform,
3
3
  type OperationalErrorContext,
4
4
  type RequestErrorContext,
5
- } from "../platform/platform";
5
+ } from "../platform/platform.js";
6
6
 
7
- export type { OperationalErrorCode } from "../platform/platform";
7
+ export type { OperationalErrorCode } from "../platform/platform.js";
8
8
 
9
9
  export function captureRequestError(
10
10
  error: unknown,
@@ -3,10 +3,15 @@ import type {
3
3
  ReasoningEffort,
4
4
  RoutingStrategy,
5
5
  } from "@mupt-ai/dari-router/policy-engine";
6
- import type { HarnessConversationIdentity } from "../runtime/harness_identity";
7
- import type { InteractionRequest, SourceProtocol } from "../interaction/types";
8
- import type { SubscriptionUsageLimit } from "../providers/subscription_limits";
9
- import type { ClientHarness, ProviderKeySource, ResolvedRouter } from "../types";
6
+ import type { HarnessConversationIdentity } from "../runtime/harness_identity/index.js";
7
+ import type { InteractionRequest, SourceProtocol } from "../interaction/types.js";
8
+ import type { SubscriptionUsageLimit } from "../providers/subscription_limits.js";
9
+ import type {
10
+ ClientHarness,
11
+ ProviderCredential,
12
+ ProviderKeySource,
13
+ ResolvedRouter,
14
+ } from "../types.js";
10
15
 
11
16
  /**
12
17
  * Everything the gateway runtime needs from the deployment around it: router
@@ -24,6 +29,15 @@ export type GatewayPlatform = {
24
29
  * `prefixHashes`. Throws HttpError(401) for an unknown key.
25
30
  */
26
31
  resolveRouter(request: ResolveRouterRequest): Promise<ResolvedRouter>;
32
+ /**
33
+ * Optional. Supply the credential for one enabled model of this request,
34
+ * consulted after `resolveRouter` and before its provider keys (for the
35
+ * self-hosted gateway, its environment keys), so an embedder can serve
36
+ * per-tenant keys from its own store. Undefined keeps the resolved key.
37
+ */
38
+ resolveProviderCredential?(
39
+ request: ProviderCredentialRequest,
40
+ ): Promise<ProviderCredential | undefined>;
27
41
  /** Persist one completed turn's prefix entry and/or refresh a read entry. */
28
42
  writePrefixState(write: PrefixStateWrite): Promise<void>;
29
43
  /** Set or clear a conversation's prefetched routing lease. */
@@ -53,6 +67,15 @@ export type ResolveRouterRequest = {
53
67
  clientHarness?: ClientHarness;
54
68
  };
55
69
 
70
+ export type ProviderCredentialRequest = {
71
+ provider: Provider;
72
+ model: string;
73
+ routerId: string;
74
+ organizationId: string;
75
+ // The gateway key the request authenticated with.
76
+ apiKey: string;
77
+ };
78
+
56
79
  export type PrefixStateWrite = {
57
80
  organization_id: string;
58
81
  router_id: string;
@@ -94,8 +117,14 @@ export type RequestRecord = {
94
117
  isNewConversation: boolean;
95
118
  zdr: boolean;
96
119
  harnessConversationIdentity?: HarnessConversationIdentity;
120
+ // Parsed from the request's X-Dari-Tags header; empty when absent.
121
+ tags: RequestTags;
97
122
  };
98
123
 
124
+ // Caller-supplied attribution labels (run, trial, setting), opaque to the
125
+ // gateway.
126
+ export type RequestTags = Record<string, string>;
127
+
99
128
  export type RequestSummary = {
100
129
  request_id: string;
101
130
  organization_id: string;
@@ -130,7 +159,10 @@ export type RequestSummary = {
130
159
  cache_write_tokens: number | null;
131
160
  output_tokens: number | null;
132
161
  total_tokens: number | null;
162
+ // Provider-reported cost when the provider returns one (OpenRouter, Vercel
163
+ // AI Gateway), otherwise priced from the model's rates when known.
133
164
  total_cost_usd: number | null;
165
+ cost_source: "provider" | "pricing" | null;
134
166
  pricing_known: boolean | null;
135
167
  };
136
168
 
@@ -1,11 +1,11 @@
1
1
  import { isReasoningEffort, isRecord, type ReasoningEffort } from "@mupt-ai/dari-router/policy-engine";
2
2
 
3
- import { HttpError } from "../../http/errors";
4
- import { parseDataImageUrl } from "../../interaction/image";
5
- import { decodeUntrustedProviderContinuationState } from "../../interaction/provider_continuation_state";
6
- import { decodeUntrustedPortableReasoningState } from "../../interaction/portable_reasoning_state";
7
- import { toolsByWireName } from "../../interaction/tool_identity";
8
- import { explicitModelId, isAnthropicRouterModel, unsupportedModelMessage } from "./router_model";
3
+ import { HttpError } from "../../http/errors.js";
4
+ import { parseDataImageUrl } from "../../interaction/image.js";
5
+ import { decodeUntrustedProviderContinuationState } from "../../interaction/provider_continuation_state.js";
6
+ import { decodeUntrustedPortableReasoningState } from "../../interaction/portable_reasoning_state.js";
7
+ import { toolsByWireName } from "../../interaction/tool_identity.js";
8
+ import { explicitModelId, isAnthropicRouterModel, unsupportedModelMessage } from "./router_model.js";
9
9
  import type {
10
10
  ClientTool,
11
11
  InteractionContent,
@@ -17,7 +17,7 @@ import type {
17
17
  InteractionToolReference,
18
18
  ReasoningControls,
19
19
  ServerToolKind,
20
- } from "../../interaction/types";
20
+ } from "../../interaction/types.js";
21
21
 
22
22
  const SUPPORTED_SERVER_TOOL_TYPES: readonly ServerToolKind[] = [
23
23
  "bash_20250124",
@@ -5,7 +5,7 @@ import {
5
5
  type ResponseFormat,
6
6
  } from "@mupt-ai/dari-router/policy-engine";
7
7
 
8
- import { HttpError } from "../../http/errors";
8
+ import { HttpError } from "../../http/errors.js";
9
9
  import type {
10
10
  InteractionContent,
11
11
  InteractionItem,
@@ -14,10 +14,10 @@ import type {
14
14
  InteractionResponseFormat,
15
15
  InteractionTool,
16
16
  InteractionToolChoice,
17
- } from "../../interaction/types";
18
- import { toolsByWireName } from "../../interaction/tool_identity";
19
- import { decodeUntrustedProviderContinuationState } from "../../interaction/provider_continuation_state";
20
- import { validateChatCompletionsRequest } from "./chat_completions_validation";
17
+ } from "../../interaction/types.js";
18
+ import { toolsByWireName } from "../../interaction/tool_identity.js";
19
+ import { decodeUntrustedProviderContinuationState } from "../../interaction/provider_continuation_state.js";
20
+ import { validateChatCompletionsRequest } from "./chat_completions_validation.js";
21
21
 
22
22
  export function chatCompletionsToInteraction(request: ChatCompletionRequest): InteractionRequest {
23
23
  validateChatCompletionsRequest(request);
@@ -1,12 +1,12 @@
1
1
  import { isReasoningEffort, isRecord, type ChatCompletionRequest } from "@mupt-ai/dari-router/policy-engine";
2
2
 
3
- import { HttpError } from "../../http/errors";
4
- import { parseDataImageUrl } from "../../interaction/image";
5
- import { CANONICAL_ROUTER_MODEL, explicitModelId, unsupportedModelMessage } from "./router_model";
3
+ import { HttpError } from "../../http/errors.js";
4
+ import { parseDataImageUrl } from "../../interaction/image.js";
5
+ import { CANONICAL_ROUTER_MODEL, explicitModelId, unsupportedModelMessage } from "./router_model.js";
6
6
  import {
7
7
  isProtocolToolCallId,
8
8
  TOOL_CALL_ID_MAX_LENGTH,
9
- } from "../../interaction/tool_identity";
9
+ } from "../../interaction/tool_identity.js";
10
10
 
11
11
  export function validateChatCompletionsRequest(request: ChatCompletionRequest): void {
12
12
  if (request.model !== CANONICAL_ROUTER_MODEL && explicitModelId(request.model) === null) {
@@ -2,15 +2,15 @@ import { createHash } from "node:crypto";
2
2
 
3
3
  import { isReasoningEffort, isRecord, type ReasoningEffort } from "@mupt-ai/dari-router/policy-engine";
4
4
 
5
- import { HttpError } from "../../http/errors";
6
- import { parseDataImageUrl } from "../../interaction/image";
7
- import { decodeUntrustedProviderContinuationState } from "../../interaction/provider_continuation_state";
8
- import { CANONICAL_ROUTER_MODEL, explicitModelId, unsupportedModelMessage } from "./router_model";
5
+ import { HttpError } from "../../http/errors.js";
6
+ import { parseDataImageUrl } from "../../interaction/image.js";
7
+ import { decodeUntrustedProviderContinuationState } from "../../interaction/provider_continuation_state.js";
8
+ import { CANONICAL_ROUTER_MODEL, explicitModelId, unsupportedModelMessage } from "./router_model.js";
9
9
  import {
10
10
  isProtocolToolCallId,
11
11
  TOOL_CALL_ID_MAX_LENGTH,
12
12
  toolsByWireName,
13
- } from "../../interaction/tool_identity";
13
+ } from "../../interaction/tool_identity.js";
14
14
  import type {
15
15
  InteractionContent,
16
16
  InteractionItem,
@@ -20,7 +20,7 @@ import type {
20
20
  InteractionTool,
21
21
  InteractionToolChoice,
22
22
  ToolKind,
23
- } from "../../interaction/types";
23
+ } from "../../interaction/types.js";
24
24
 
25
25
  const UNSUPPORTED_INPUT_ITEM_TYPES = new Set([
26
26
  "additional_tools",
@@ -1,13 +1,13 @@
1
1
  import type { RoutingDecision } from "@mupt-ai/dari-router/policy-engine";
2
2
 
3
- import type { InteractionOutput, InteractionRequest } from "../../interaction/types";
3
+ import type { InteractionOutput, InteractionRequest } from "../../interaction/types.js";
4
4
  import {
5
5
  anthropicContent,
6
6
  anthropicMessageId,
7
7
  anthropicRouting,
8
8
  anthropicStopReason,
9
9
  anthropicUsage,
10
- } from "./anthropic_messages_output";
10
+ } from "./anthropic_messages_output.js";
11
11
 
12
12
  export function anthropicMessagesResponse(args: {
13
13
  id: string;
@@ -27,6 +27,6 @@ export function anthropicMessagesResponse(args: {
27
27
  stop_sequence: null,
28
28
  usage: anthropicUsage(args.output),
29
29
  ...(args.output.safeguardResults ? { safeguard_results: args.output.safeguardResults } : {}),
30
- dari_routing: anthropicRouting(args.routing, args.conversationId),
30
+ dari_routing: anthropicRouting(args.routing, args.id, args.conversationId),
31
31
  };
32
32
  }
@@ -1,7 +1,7 @@
1
- import { parseDataImageUrl } from "../../interaction/image";
2
- import { encodeProviderContinuationState } from "../../interaction/provider_continuation_state";
3
- import { encodePortableReasoningState } from "../../interaction/portable_reasoning_state";
4
- import type { InteractionOutput } from "../../interaction/types";
1
+ import { parseDataImageUrl } from "../../interaction/image.js";
2
+ import { encodeProviderContinuationState } from "../../interaction/provider_continuation_state.js";
3
+ import { encodePortableReasoningState } from "../../interaction/portable_reasoning_state.js";
4
+ import type { InteractionOutput } from "../../interaction/types.js";
5
5
  import type { RoutingDecision } from "@mupt-ai/dari-router/policy-engine";
6
6
 
7
7
  export function anthropicMessageId(requestId: string): string {
@@ -100,6 +100,7 @@ export function anthropicUsage(output: Pick<InteractionOutput, "usage">): Record
100
100
 
101
101
  export function anthropicRouting(
102
102
  decision: RoutingDecision,
103
+ requestId: string,
103
104
  conversationId?: string
104
105
  ): Record<string, unknown> {
105
106
  return {
@@ -107,6 +108,7 @@ export function anthropicRouting(
107
108
  selected_model: decision.selectedModel,
108
109
  reasoning_effort: decision.reasoningEffort,
109
110
  reason: decision.reason,
111
+ request_id: requestId,
110
112
  ...(conversationId ? { conversation_id: conversationId } : {}),
111
113
  ...(decision.leaseTurnsRemaining === undefined
112
114
  ? {}
@@ -1,20 +1,20 @@
1
- import { piMessageToInteractionOutput } from "../../providers/pi_output";
2
- import { providerToolCallIdentity } from "../../interaction/tool_identity";
3
- import type { InteractionOutput, InteractionRequest, ProviderIdentity } from "../../interaction/types";
1
+ import { piMessageToInteractionOutput } from "../../providers/pi_output.js";
2
+ import { providerToolCallIdentity } from "../../interaction/tool_identity.js";
3
+ import type { InteractionOutput, InteractionRequest, ProviderIdentity } from "../../interaction/types.js";
4
4
  import {
5
5
  isProviderFailureMessage,
6
6
  providerFailureFromEvent,
7
7
  providerFailureMessage,
8
8
  type ProviderStreamOutcome,
9
- } from "../../runtime/provider_stream_outcome";
10
- import { sseStream } from "./sse_stream";
9
+ } from "../../runtime/provider_stream_outcome.js";
10
+ import { sseStream } from "./sse_stream.js";
11
11
  import {
12
12
  anthropicMessageId,
13
13
  anthropicReasoningBlock,
14
14
  anthropicRouting,
15
15
  anthropicStopReason,
16
16
  anthropicUsage,
17
- } from "./anthropic_messages_output";
17
+ } from "./anthropic_messages_output.js";
18
18
 
19
19
  export function anthropicMessagesSseStream(args: {
20
20
  id: string;
@@ -58,7 +58,7 @@ export function anthropicMessagesSseStream(args: {
58
58
  stop_reason: null,
59
59
  stop_sequence: null,
60
60
  usage: { input_tokens: 0, output_tokens: 0 },
61
- dari_routing: anthropicRouting(args.routing, args.conversationId),
61
+ dari_routing: anthropicRouting(args.routing, args.id, args.conversationId),
62
62
  },
63
63
  });
64
64
 
@@ -1,17 +1,17 @@
1
1
  import { isRecord, type ChatMessage, type RoutingDecision } from "@mupt-ai/dari-router/policy-engine";
2
2
 
3
- import { piMessageToInteractionOutput } from "../../providers/pi_output";
4
- import { providerToolCallIdentity } from "../../interaction/tool_identity";
5
- import { encodeProviderContinuationState } from "../../interaction/provider_continuation_state";
6
- import { chatReasoningDetailId } from "./chat_reasoning_detail";
7
- import type { InteractionOutput, InteractionRequest, ProviderContinuationState, ProviderIdentity } from "../../interaction/types";
3
+ import { piMessageToInteractionOutput } from "../../providers/pi_output.js";
4
+ import { providerToolCallIdentity } from "../../interaction/tool_identity.js";
5
+ import { encodeProviderContinuationState } from "../../interaction/provider_continuation_state.js";
6
+ import { chatReasoningDetailId } from "./chat_reasoning_detail.js";
7
+ import type { InteractionOutput, InteractionRequest, ProviderContinuationState, ProviderIdentity } from "../../interaction/types.js";
8
8
  import {
9
9
  isProviderFailureMessage,
10
10
  providerFailureFromEvent,
11
11
  providerFailureMessage,
12
12
  type ProviderStreamOutcome,
13
- } from "../../runtime/provider_stream_outcome";
14
- import { sseStream } from "./sse_stream";
13
+ } from "../../runtime/provider_stream_outcome.js";
14
+ import { sseStream } from "./sse_stream.js";
15
15
 
16
16
  export function chatCompletionResponse(args: {
17
17
  id: string;
@@ -34,7 +34,7 @@ export function chatCompletionResponse(args: {
34
34
  },
35
35
  ],
36
36
  usage: usagePayload(args.output, args.modelCost),
37
- dari_routing: routingPayload(args.routing, args.conversationId),
37
+ dari_routing: routingPayload(args.routing, args.id, args.conversationId),
38
38
  };
39
39
  }
40
40
 
@@ -75,7 +75,7 @@ export function chatCompletionsSseStream(args: {
75
75
  usage: usagePayload(message, args.modelCost?.(message, true)) });
76
76
  };
77
77
 
78
- send(chunk({ completion, created, model: args.model, delta: {}, finishReason: null, routing: args.routing, conversationId: args.conversationId }));
78
+ send(chunk({ completion, created, model: args.model, delta: {}, finishReason: null, routing: routingPayload(args.routing, args.id, args.conversationId) }));
79
79
  send(chunk({ completion, created, model: args.model, delta: { role: "assistant" }, finishReason: null }));
80
80
 
81
81
  const argumentDeltaSeen = new Set<string>();
@@ -208,12 +208,13 @@ export function chatCompletionsSseStream(args: {
208
208
  });
209
209
  }
210
210
 
211
- function routingPayload(decision: RoutingDecision, conversationId?: string): Record<string, unknown> {
211
+ function routingPayload(decision: RoutingDecision, requestId: string, conversationId?: string): Record<string, unknown> {
212
212
  return {
213
213
  requested_model: "dari/routing",
214
214
  selected_model: decision.selectedModel,
215
215
  reasoning_effort: decision.reasoningEffort,
216
216
  reason: decision.reason,
217
+ request_id: requestId,
217
218
  ...(conversationId ? { conversation_id: conversationId } : {}),
218
219
  };
219
220
  }
@@ -224,9 +225,8 @@ function chunk(args: {
224
225
  model: string;
225
226
  delta: Record<string, unknown>;
226
227
  finishReason: string | null;
227
- routing?: RoutingDecision;
228
+ routing?: Record<string, unknown>;
228
229
  usage?: Record<string, unknown>;
229
- conversationId?: string;
230
230
  }): Record<string, unknown> {
231
231
  return {
232
232
  id: args.completion,
@@ -234,7 +234,7 @@ function chunk(args: {
234
234
  created: args.created,
235
235
  model: args.model,
236
236
  choices: [{ index: 0, delta: args.delta, finish_reason: args.finishReason }],
237
- ...(args.routing ? { dari_routing: routingPayload(args.routing, args.conversationId) } : {}),
237
+ ...(args.routing ? { dari_routing: args.routing } : {}),
238
238
  ...(args.usage ? { usage: args.usage } : {}),
239
239
  };
240
240
  }
@@ -1,4 +1,4 @@
1
- import type { ProviderContinuationState } from "../../interaction/types";
1
+ import type { ProviderContinuationState } from "../../interaction/types.js";
2
2
 
3
3
  export function chatReasoningDetailId(
4
4
  continuation: ProviderContinuationState,
@@ -4,8 +4,8 @@ import {
4
4
  openAIResponsesRouting,
5
5
  openAIResponsesTerminal,
6
6
  openAIResponsesUsage,
7
- } from "./openai_responses_output";
8
- import type { InteractionOutput, InteractionRequest } from "../../interaction/types";
7
+ } from "./openai_responses_output.js";
8
+ import type { InteractionOutput, InteractionRequest } from "../../interaction/types.js";
9
9
 
10
10
  export function openAIResponsesResponse(args: {
11
11
  id: string;
@@ -24,7 +24,7 @@ export function openAIResponsesResponse(args: {
24
24
  output: openAIResponsesOutputItems(args.output),
25
25
  usage: openAIResponsesUsage(args.output),
26
26
  parallel_tool_calls: args.request.parallelToolCalls ?? true,
27
- dari_routing: openAIResponsesRouting(args.routing, args.conversationId),
27
+ dari_routing: openAIResponsesRouting(args.routing, args.id, args.conversationId),
28
28
  };
29
29
  }
30
30
  import type { RoutingDecision } from "@mupt-ai/dari-router/policy-engine";
@@ -1,5 +1,5 @@
1
- import { encodeProviderContinuationState } from "../../interaction/provider_continuation_state";
2
- import type { InteractionOutput } from "../../interaction/types";
1
+ import { encodeProviderContinuationState } from "../../interaction/provider_continuation_state.js";
2
+ import type { InteractionOutput } from "../../interaction/types.js";
3
3
 
4
4
  export function openAIResponsesResponseId(requestId: string): string {
5
5
  return `resp_${requestId}`;
@@ -44,6 +44,7 @@ export function openAIResponsesUsage(output: Pick<InteractionOutput, "usage">):
44
44
 
45
45
  export function openAIResponsesRouting(
46
46
  decision: RoutingDecision,
47
+ requestId: string,
47
48
  conversationId?: string
48
49
  ): Record<string, unknown> {
49
50
  return {
@@ -51,6 +52,7 @@ export function openAIResponsesRouting(
51
52
  selected_model: decision.selectedModel,
52
53
  reasoning_effort: decision.reasoningEffort,
53
54
  reason: decision.reason,
55
+ request_id: requestId,
54
56
  ...(conversationId ? { conversation_id: conversationId } : {}),
55
57
  };
56
58
  }
@@ -5,21 +5,21 @@ import {
5
5
  openAIResponsesRouting,
6
6
  openAIResponsesTerminal,
7
7
  openAIResponsesUsage,
8
- } from "./openai_responses_output";
9
- import { piMessageToInteractionOutput } from "../../providers/pi_output";
8
+ } from "./openai_responses_output.js";
9
+ import { piMessageToInteractionOutput } from "../../providers/pi_output.js";
10
10
  import type {
11
11
  InteractionOutput,
12
12
  InteractionOutputItem,
13
13
  InteractionRequest,
14
14
  ProviderIdentity,
15
- } from "../../interaction/types";
15
+ } from "../../interaction/types.js";
16
16
  import {
17
17
  isProviderFailureMessage,
18
18
  providerFailureFromEvent,
19
19
  providerFailureMessage,
20
20
  type ProviderStreamOutcome,
21
- } from "../../runtime/provider_stream_outcome";
22
- import { sseStream } from "./sse_stream";
21
+ } from "../../runtime/provider_stream_outcome.js";
22
+ import { sseStream } from "./sse_stream.js";
23
23
 
24
24
  type StreamArgs = {
25
25
  id: string;
@@ -600,7 +600,7 @@ function responseEnvelope(
600
600
  output,
601
601
  parallel_tool_calls: args.request.parallelToolCalls ?? true,
602
602
  ...(interaction ? { usage: openAIResponsesUsage(interaction) } : {}),
603
- dari_routing: openAIResponsesRouting(args.routing, args.conversationId),
603
+ dari_routing: openAIResponsesRouting(args.routing, args.id, args.conversationId),
604
604
  };
605
605
  }
606
606
 
@@ -1,11 +1,11 @@
1
- import { ProviderStreamLifecycle } from "../../runtime/provider_stream_lifecycle";
1
+ import { ProviderStreamLifecycle } from "../../runtime/provider_stream_lifecycle.js";
2
2
  import {
3
3
  providerFailure,
4
4
  providerFailureFromCaught,
5
5
  providerFailureFromTerminal,
6
6
  type ProviderStreamOutcome,
7
- } from "../../runtime/provider_stream_outcome";
8
- import { DeliveredStreamSnapshot } from "./delivered_stream_snapshot";
7
+ } from "../../runtime/provider_stream_outcome.js";
8
+ import { DeliveredStreamSnapshot } from "./delivered_stream_snapshot.js";
9
9
 
10
10
  export type SseStreamLifecycleArgs = {
11
11
  onFinal?: (outcome: ProviderStreamOutcome) => void;
@@ -1,7 +1,7 @@
1
1
  import { isRecord } from "@mupt-ai/dari-router/policy-engine";
2
2
 
3
- import type { AnthropicSafeguards, InteractionRequest } from "../interaction/types";
4
- import type { ProviderFetch } from "./response_capture";
3
+ import type { AnthropicSafeguards, InteractionRequest } from "../interaction/types.js";
4
+ import type { ProviderFetch } from "./response_capture.js";
5
5
 
6
6
  // Claude Code's auto mode asks the Anthropic API to run its dangerous-tool-use
7
7
  // classifier server-side, at no charge, by sending `safeguards` with a paired
@@ -1,12 +1,12 @@
1
1
  import { AssumeRoleCommand, STSClient } from "@aws-sdk/client-sts";
2
2
 
3
- import { HttpError } from "../http/errors";
3
+ import { HttpError } from "../http/errors.js";
4
4
  import type {
5
5
  AwsAssumeRoleProviderAuth,
6
6
  AwsSigV4ProviderAuth,
7
7
  ProviderAuth,
8
8
  ResolvedProviderAuth,
9
- } from "../types";
9
+ } from "../types.js";
10
10
 
11
11
  const ROLE_SESSION_NAME = "dari-routing";
12
12
  // AssumeRole always goes through this regional STS endpoint. The customer's
@@ -8,7 +8,7 @@ import type {
8
8
  InteractionOutput,
9
9
  InteractionUsage,
10
10
  ProviderIdentity,
11
- } from "../interaction/types";
11
+ } from "../interaction/types.js";
12
12
 
13
13
  /** Prose from current models averages about 4.8 characters per token. */
14
14
  export const ESTIMATED_CHARS_PER_TOKEN = 4.8;
@@ -1,27 +1,27 @@
1
1
  import type { RoutingDecision } from "@mupt-ai/dari-router/policy-engine";
2
- import { HttpError } from "../http/errors";
3
- import { piMessageToInteractionOutput } from "./pi_output";
4
- import type { InteractionRequest } from "../interaction/types";
5
- import { captureOperationalError } from "../observability/errors";
2
+ import { HttpError } from "../http/errors.js";
3
+ import { piMessageToInteractionOutput } from "./pi_output.js";
4
+ import type { InteractionRequest } from "../interaction/types.js";
5
+ import { captureOperationalError } from "../observability/errors.js";
6
6
  import {
7
7
  CustomerDisconnectedError,
8
8
  customerCanceledProviderMessage,
9
- } from "../runtime/customer_disconnect";
9
+ } from "../runtime/customer_disconnect.js";
10
10
  import {
11
11
  isProviderFailureMessage,
12
12
  providerFailureFromCaught,
13
13
  providerFailureFromTerminal,
14
14
  providerFailureMessage,
15
- } from "../runtime/provider_stream_outcome";
15
+ } from "../runtime/provider_stream_outcome.js";
16
16
  import {
17
17
  reportedExecution,
18
18
  type ReportableProviderOutcome,
19
19
  type RoutedRuntimeReporter,
20
- } from "../runtime/runtime_reporter";
21
- import type { RoutedProtocol } from "../runtime/routed_protocol";
22
- import { trackBackgroundTelemetry } from "../telemetry/background";
23
- import { gatewayPlatform, type SubscriptionHold } from "../platform/platform";
24
- import { reportRoutingUsage } from "../telemetry/usage";
20
+ } from "../runtime/runtime_reporter.js";
21
+ import type { RoutedProtocol } from "../runtime/routed_protocol.js";
22
+ import { trackBackgroundTelemetry } from "../telemetry/background.js";
23
+ import { gatewayPlatform, type SubscriptionHold } from "../platform/platform.js";
24
+ import { reportRoutingUsage } from "../telemetry/usage.js";
25
25
  import {
26
26
  prepareProviderExecution,
27
27
  primeProviderStream,
@@ -32,20 +32,20 @@ import {
32
32
  type ProviderExecution,
33
33
  type StartedCompletion,
34
34
  type StartedStream,
35
- } from "./provider_call";
35
+ } from "./provider_call.js";
36
36
  import {
37
37
  runProviderAttemptPlan,
38
38
  type ProviderAttemptFailure,
39
39
  type ProviderAttemptPlanResult,
40
40
  type ProviderAttemptResult,
41
- } from "./provider_attempt_runner";
41
+ } from "./provider_attempt_runner.js";
42
42
  import {
43
43
  estimatedCancelUsage,
44
44
  NO_DELIVERED_OUTPUT,
45
45
  observeDeliveredOutput,
46
- } from "./cancel_estimate";
47
- import { providerResponseCaptureFromError, type ProviderResponseCapture } from "./response_capture";
48
- import { createStreamFinalizer } from "./stream_finalization";
46
+ } from "./cancel_estimate.js";
47
+ import { providerResponseCaptureFromError, type ProviderResponseCapture } from "./response_capture.js";
48
+ import { createStreamFinalizer } from "./stream_finalization.js";
49
49
  import {
50
50
  detectSubscriptionUsageLimit,
51
51
  failureWithSubscriptionUsageLimit,
@@ -53,7 +53,7 @@ import {
53
53
  subscriptionUsageLimitFromFailure,
54
54
  subscriptionSwitchedMessage,
55
55
  subscriptionUsageLimitMessage,
56
- } from "./subscription_limits";
56
+ } from "./subscription_limits.js";
57
57
 
58
58
  export type ProviderChoice = {
59
59
  decision: RoutingDecision;