@mupt-ai/dari-gateway 0.2.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 (366) hide show
  1. package/dist/bun.d.ts +2 -0
  2. package/dist/bun.js +4 -0
  3. package/dist/context/eval_catalog.d.ts +3 -0
  4. package/dist/context/eval_catalog.js +7 -0
  5. package/dist/context/interaction_fingerprint.d.ts +27 -0
  6. package/dist/context/interaction_fingerprint.js +519 -0
  7. package/dist/context/interaction_fingerprint_format.d.ts +42 -0
  8. package/dist/context/interaction_fingerprint_format.js +113 -0
  9. package/dist/context/interaction_lease_depth.d.ts +2 -0
  10. package/dist/context/interaction_lease_depth.js +110 -0
  11. package/dist/context/lease_history.d.ts +7 -0
  12. package/dist/context/lease_history.js +158 -0
  13. package/dist/context/pricing.d.ts +4 -0
  14. package/dist/context/pricing.js +23 -0
  15. package/dist/context/provider_prompt_accounting.d.ts +14 -0
  16. package/dist/context/provider_prompt_accounting.js +187 -0
  17. package/dist/context/routing_context.d.ts +40 -0
  18. package/dist/context/routing_context.js +211 -0
  19. package/dist/http/auth.d.ts +2 -0
  20. package/dist/http/auth.js +35 -0
  21. package/dist/http/errors.d.ts +19 -0
  22. package/dist/http/errors.js +89 -0
  23. package/dist/http/handler.d.ts +12 -0
  24. package/dist/http/handler.js +81 -0
  25. package/dist/http/http2_server.d.ts +6 -0
  26. package/dist/http/http2_server.js +103 -0
  27. package/dist/http/serve.d.ts +20 -0
  28. package/dist/http/serve.js +78 -0
  29. package/dist/index.d.ts +6 -0
  30. package/dist/index.js +8 -0
  31. package/dist/ingress/anthropic_messages.d.ts +3 -0
  32. package/dist/ingress/anthropic_messages.js +122 -0
  33. package/dist/ingress/anthropic_models.d.ts +1 -0
  34. package/dist/ingress/anthropic_models.js +23 -0
  35. package/dist/ingress/chat_completions.d.ts +2 -0
  36. package/dist/ingress/chat_completions.js +37 -0
  37. package/dist/ingress/claude_code/request_context.d.ts +2 -0
  38. package/dist/ingress/claude_code/request_context.js +31 -0
  39. package/dist/ingress/codex.d.ts +3 -0
  40. package/dist/ingress/codex.js +65 -0
  41. package/dist/ingress/codex_models.d.ts +2 -0
  42. package/dist/ingress/codex_models.js +89 -0
  43. package/dist/ingress/json.d.ts +1 -0
  44. package/dist/ingress/json.js +95 -0
  45. package/dist/ingress/models.d.ts +1 -0
  46. package/dist/ingress/models.js +53 -0
  47. package/dist/interaction/capabilities.d.ts +3 -0
  48. package/dist/interaction/capabilities.js +24 -0
  49. package/dist/interaction/image.d.ts +4 -0
  50. package/dist/interaction/image.js +13 -0
  51. package/dist/interaction/portable_reasoning_state.d.ts +4 -0
  52. package/dist/interaction/portable_reasoning_state.js +18 -0
  53. package/dist/interaction/provider_continuation_state.d.ts +6 -0
  54. package/dist/interaction/provider_continuation_state.js +27 -0
  55. package/dist/interaction/tool_identity.d.ts +10 -0
  56. package/dist/interaction/tool_identity.js +41 -0
  57. package/dist/interaction/types.d.ts +203 -0
  58. package/dist/interaction/types.js +5 -0
  59. package/dist/models/context_limits.d.ts +2 -0
  60. package/dist/models/context_limits.js +7 -0
  61. package/dist/models/execution_provider.d.ts +8 -0
  62. package/dist/models/execution_provider.js +13 -0
  63. package/dist/models/gateways.d.ts +11 -0
  64. package/dist/models/gateways.js +45 -0
  65. package/dist/models/ids.d.ts +1 -0
  66. package/dist/models/ids.js +15 -0
  67. package/dist/models/provider_defaults.d.ts +4 -0
  68. package/dist/models/provider_defaults.js +41 -0
  69. package/dist/models/runtime_overrides.d.ts +4 -0
  70. package/dist/models/runtime_overrides.js +209 -0
  71. package/dist/observability/errors.d.ts +8 -0
  72. package/dist/observability/errors.js +11 -0
  73. package/dist/platform/platform.d.ts +152 -0
  74. package/dist/platform/platform.js +11 -0
  75. package/dist/platform/routing_contract.d.ts +2 -0
  76. package/dist/platform/routing_contract.js +5 -0
  77. package/dist/protocol/input/anthropic_messages.d.ts +2 -0
  78. package/dist/protocol/input/anthropic_messages.js +494 -0
  79. package/dist/protocol/input/chat_completions.d.ts +4 -0
  80. package/dist/protocol/input/chat_completions.js +212 -0
  81. package/dist/protocol/input/chat_completions_validation.d.ts +2 -0
  82. package/dist/protocol/input/chat_completions_validation.js +257 -0
  83. package/dist/protocol/input/openai_responses.d.ts +2 -0
  84. package/dist/protocol/input/openai_responses.js +666 -0
  85. package/dist/protocol/input/router_model.d.ts +7 -0
  86. package/dist/protocol/input/router_model.js +43 -0
  87. package/dist/protocol/output/anthropic_messages.d.ts +10 -0
  88. package/dist/protocol/output/anthropic_messages.js +15 -0
  89. package/dist/protocol/output/anthropic_messages_output.d.ts +10 -0
  90. package/dist/protocol/output/anthropic_messages_output.js +124 -0
  91. package/dist/protocol/output/anthropic_messages_stream.d.ts +16 -0
  92. package/dist/protocol/output/anthropic_messages_stream.js +267 -0
  93. package/dist/protocol/output/chat_completions.d.ts +29 -0
  94. package/dist/protocol/output/chat_completions.js +406 -0
  95. package/dist/protocol/output/chat_reasoning_detail.d.ts +2 -0
  96. package/dist/protocol/output/chat_reasoning_detail.js +13 -0
  97. package/dist/protocol/output/delivered_stream_snapshot.d.ts +10 -0
  98. package/dist/protocol/output/delivered_stream_snapshot.js +31 -0
  99. package/dist/protocol/output/openai_responses.d.ts +10 -0
  100. package/dist/protocol/output/openai_responses.js +14 -0
  101. package/dist/protocol/output/openai_responses_output.d.ts +14 -0
  102. package/dist/protocol/output/openai_responses_output.js +125 -0
  103. package/dist/protocol/output/openai_responses_stream.d.ts +18 -0
  104. package/dist/protocol/output/openai_responses_stream.js +546 -0
  105. package/dist/protocol/output/sse_stream.d.ts +31 -0
  106. package/dist/protocol/output/sse_stream.js +67 -0
  107. package/dist/providers/anthropic_safeguards.d.ts +11 -0
  108. package/dist/providers/anthropic_safeguards.js +81 -0
  109. package/dist/providers/aws_assume_role.d.ts +17 -0
  110. package/dist/providers/aws_assume_role.js +107 -0
  111. package/dist/providers/cancel_estimate.d.ts +43 -0
  112. package/dist/providers/cancel_estimate.js +89 -0
  113. package/dist/providers/execution.d.ts +72 -0
  114. package/dist/providers/execution.js +491 -0
  115. package/dist/providers/model_capabilities.d.ts +11 -0
  116. package/dist/providers/model_capabilities.js +29 -0
  117. package/dist/providers/pi.d.ts +65 -0
  118. package/dist/providers/pi.js +319 -0
  119. package/dist/providers/pi_context.d.ts +7 -0
  120. package/dist/providers/pi_context.js +405 -0
  121. package/dist/providers/pi_options.d.ts +11 -0
  122. package/dist/providers/pi_options.js +398 -0
  123. package/dist/providers/pi_output.d.ts +2 -0
  124. package/dist/providers/pi_output.js +453 -0
  125. package/dist/providers/provider_attempt_runner.d.ts +55 -0
  126. package/dist/providers/provider_attempt_runner.js +90 -0
  127. package/dist/providers/provider_call.d.ts +77 -0
  128. package/dist/providers/provider_call.js +292 -0
  129. package/dist/providers/provider_reported_cost.d.ts +10 -0
  130. package/dist/providers/provider_reported_cost.js +123 -0
  131. package/dist/providers/reasoning.d.ts +12 -0
  132. package/dist/providers/reasoning.js +30 -0
  133. package/dist/providers/response_capture.d.ts +23 -0
  134. package/dist/providers/response_capture.js +47 -0
  135. package/dist/providers/stream_finalization.d.ts +46 -0
  136. package/dist/providers/stream_finalization.js +165 -0
  137. package/dist/providers/subscription_limits.d.ts +31 -0
  138. package/dist/providers/subscription_limits.js +163 -0
  139. package/dist/providers/subscription_usage.d.ts +10 -0
  140. package/dist/providers/subscription_usage.js +79 -0
  141. package/dist/runtime/claude_code/auxiliary_routing.d.ts +3 -0
  142. package/dist/runtime/claude_code/auxiliary_routing.js +60 -0
  143. package/dist/runtime/customer_disconnect.d.ts +20 -0
  144. package/dist/runtime/customer_disconnect.js +49 -0
  145. package/dist/runtime/explicit_model.d.ts +4 -0
  146. package/dist/runtime/explicit_model.js +53 -0
  147. package/dist/runtime/harness_identity/conversation.d.ts +33 -0
  148. package/dist/runtime/harness_identity/conversation.js +39 -0
  149. package/dist/runtime/harness_identity/extract.d.ts +8 -0
  150. package/dist/runtime/harness_identity/extract.js +214 -0
  151. package/dist/runtime/harness_identity/index.d.ts +2 -0
  152. package/dist/runtime/harness_identity/index.js +2 -0
  153. package/dist/runtime/prepare_routed_completion.d.ts +33 -0
  154. package/dist/runtime/prepare_routed_completion.js +167 -0
  155. package/dist/runtime/provider_stream_lifecycle.d.ts +31 -0
  156. package/dist/runtime/provider_stream_lifecycle.js +88 -0
  157. package/dist/runtime/provider_stream_outcome.d.ts +23 -0
  158. package/dist/runtime/provider_stream_outcome.js +55 -0
  159. package/dist/runtime/request_tags.d.ts +7 -0
  160. package/dist/runtime/request_tags.js +33 -0
  161. package/dist/runtime/routed_completion.d.ts +17 -0
  162. package/dist/runtime/routed_completion.js +80 -0
  163. package/dist/runtime/routed_protocol.d.ts +30 -0
  164. package/dist/runtime/routed_protocol.js +1 -0
  165. package/dist/runtime/routed_runtime.d.ts +40 -0
  166. package/dist/runtime/routed_runtime.js +535 -0
  167. package/dist/runtime/routing_lease.d.ts +26 -0
  168. package/dist/runtime/routing_lease.js +210 -0
  169. package/dist/runtime/runtime_reporter.d.ts +71 -0
  170. package/dist/runtime/runtime_reporter.js +35 -0
  171. package/dist/self_host/config.d.ts +46 -0
  172. package/dist/self_host/config.js +105 -0
  173. package/dist/self_host/main.d.ts +16 -0
  174. package/dist/self_host/main.js +95 -0
  175. package/dist/self_host/platform.d.ts +13 -0
  176. package/dist/self_host/platform.js +50 -0
  177. package/dist/self_host/prefix_store.d.ts +46 -0
  178. package/dist/self_host/prefix_store.js +261 -0
  179. package/dist/self_host/resolve.d.ts +28 -0
  180. package/dist/self_host/resolve.js +171 -0
  181. package/dist/self_host/subscriptions/access.d.ts +10 -0
  182. package/dist/self_host/subscriptions/access.js +37 -0
  183. package/dist/self_host/subscriptions/http.d.ts +15 -0
  184. package/dist/self_host/subscriptions/http.js +187 -0
  185. package/dist/self_host/subscriptions/index.d.ts +24 -0
  186. package/dist/self_host/subscriptions/index.js +24 -0
  187. package/dist/self_host/subscriptions/oauth.d.ts +55 -0
  188. package/dist/self_host/subscriptions/oauth.js +281 -0
  189. package/dist/self_host/subscriptions/store.d.ts +78 -0
  190. package/dist/self_host/subscriptions/store.js +235 -0
  191. package/dist/strategies/auto_routing_selector.d.ts +12 -0
  192. package/dist/strategies/auto_routing_selector.js +61 -0
  193. package/dist/strategies/eval_relevance.d.ts +17 -0
  194. package/dist/strategies/eval_relevance.js +32 -0
  195. package/dist/strategies/fallback_decision.d.ts +8 -0
  196. package/dist/strategies/fallback_decision.js +17 -0
  197. package/dist/strategies/priority_selector.d.ts +7 -0
  198. package/dist/strategies/priority_selector.js +37 -0
  199. package/dist/strategies/route_decision.d.ts +22 -0
  200. package/dist/strategies/route_decision.js +65 -0
  201. package/dist/strategies/routing.d.ts +74 -0
  202. package/dist/strategies/routing.js +280 -0
  203. package/dist/strategies/selector_projection.d.ts +15 -0
  204. package/dist/strategies/selector_projection.js +161 -0
  205. package/dist/telemetry/background.d.ts +7 -0
  206. package/dist/telemetry/background.js +33 -0
  207. package/dist/telemetry/benchmark_replay.d.ts +37 -0
  208. package/dist/telemetry/benchmark_replay.js +108 -0
  209. package/dist/telemetry/billing_finalization.d.ts +64 -0
  210. package/dist/telemetry/billing_finalization.js +96 -0
  211. package/dist/telemetry/ingest_values.d.ts +4 -0
  212. package/dist/telemetry/ingest_values.js +12 -0
  213. package/dist/telemetry/model_cost.d.ts +3 -0
  214. package/dist/telemetry/model_cost.js +15 -0
  215. package/dist/telemetry/prefix_state.d.ts +47 -0
  216. package/dist/telemetry/prefix_state.js +116 -0
  217. package/dist/telemetry/report.d.ts +88 -0
  218. package/dist/telemetry/report.js +621 -0
  219. package/dist/telemetry/requests/interaction_observability.d.ts +45 -0
  220. package/dist/telemetry/requests/interaction_observability.js +180 -0
  221. package/dist/telemetry/requests/retained_interaction_request.d.ts +8 -0
  222. package/dist/telemetry/requests/retained_interaction_request.js +10 -0
  223. package/dist/telemetry/scrub.d.ts +2 -0
  224. package/dist/telemetry/scrub.js +31 -0
  225. package/dist/telemetry/skills/claude/catalog.d.ts +6 -0
  226. package/dist/telemetry/skills/claude/catalog.js +99 -0
  227. package/dist/telemetry/skills/claude/file_reads.d.ts +4 -0
  228. package/dist/telemetry/skills/claude/file_reads.js +110 -0
  229. package/dist/telemetry/skills/claude/observations.d.ts +3 -0
  230. package/dist/telemetry/skills/claude/observations.js +366 -0
  231. package/dist/telemetry/skills/codex/catalog.d.ts +11 -0
  232. package/dist/telemetry/skills/codex/catalog.js +138 -0
  233. package/dist/telemetry/skills/codex/exec_file_reads.d.ts +9 -0
  234. package/dist/telemetry/skills/codex/exec_file_reads.js +36 -0
  235. package/dist/telemetry/skills/codex/explicit.d.ts +3 -0
  236. package/dist/telemetry/skills/codex/explicit.js +90 -0
  237. package/dist/telemetry/skills/codex/file_reads.d.ts +4 -0
  238. package/dist/telemetry/skills/codex/file_reads.js +37 -0
  239. package/dist/telemetry/skills/codex/identity.d.ts +2 -0
  240. package/dist/telemetry/skills/codex/identity.js +20 -0
  241. package/dist/telemetry/skills/observations.d.ts +21 -0
  242. package/dist/telemetry/skills/observations.js +41 -0
  243. package/dist/telemetry/skills/paths.d.ts +11 -0
  244. package/dist/telemetry/skills/paths.js +61 -0
  245. package/dist/telemetry/skills/pi.d.ts +6 -0
  246. package/dist/telemetry/skills/pi.js +223 -0
  247. package/dist/telemetry/skills/shell_file_reads.d.ts +7 -0
  248. package/dist/telemetry/skills/shell_file_reads.js +226 -0
  249. package/dist/telemetry/skills/shell_words.d.ts +13 -0
  250. package/dist/telemetry/skills/shell_words.js +189 -0
  251. package/dist/telemetry/tools/input.d.ts +2 -0
  252. package/dist/telemetry/tools/input.js +14 -0
  253. package/dist/telemetry/tools/observations.d.ts +29 -0
  254. package/dist/telemetry/tools/observations.js +247 -0
  255. package/dist/telemetry/usage.d.ts +57 -0
  256. package/dist/telemetry/usage.js +136 -0
  257. package/dist/types.d.ts +94 -0
  258. package/dist/types.js +1 -0
  259. package/package.json +21 -6
  260. package/src/bun.ts +2 -2
  261. package/src/context/eval_catalog.ts +1 -1
  262. package/src/context/interaction_fingerprint.ts +9 -9
  263. package/src/context/interaction_fingerprint_format.ts +1 -1
  264. package/src/context/interaction_lease_depth.ts +1 -1
  265. package/src/context/pricing.ts +1 -1
  266. package/src/context/provider_prompt_accounting.ts +5 -5
  267. package/src/context/routing_context.ts +16 -16
  268. package/src/http/auth.ts +1 -1
  269. package/src/http/handler.ts +8 -8
  270. package/src/http/serve.ts +3 -3
  271. package/src/index.ts +6 -6
  272. package/src/ingress/anthropic_messages.ts +12 -12
  273. package/src/ingress/anthropic_models.ts +1 -1
  274. package/src/ingress/chat_completions.ts +9 -9
  275. package/src/ingress/claude_code/request_context.ts +2 -2
  276. package/src/ingress/codex.ts +10 -10
  277. package/src/ingress/codex_models.ts +4 -4
  278. package/src/ingress/json.ts +1 -1
  279. package/src/ingress/models.ts +9 -9
  280. package/src/interaction/capabilities.ts +1 -1
  281. package/src/interaction/portable_reasoning_state.ts +1 -1
  282. package/src/interaction/provider_continuation_state.ts +1 -1
  283. package/src/interaction/tool_identity.ts +2 -2
  284. package/src/models/context_limits.ts +1 -1
  285. package/src/models/execution_provider.ts +1 -1
  286. package/src/models/ids.ts +1 -1
  287. package/src/models/provider_defaults.ts +1 -1
  288. package/src/models/runtime_overrides.ts +1 -1
  289. package/src/observability/errors.ts +2 -2
  290. package/src/platform/platform.ts +4 -4
  291. package/src/protocol/input/anthropic_messages.ts +7 -7
  292. package/src/protocol/input/chat_completions.ts +5 -5
  293. package/src/protocol/input/chat_completions_validation.ts +4 -4
  294. package/src/protocol/input/openai_responses.ts +6 -6
  295. package/src/protocol/output/anthropic_messages.ts +3 -3
  296. package/src/protocol/output/anthropic_messages_output.ts +6 -4
  297. package/src/protocol/output/anthropic_messages_stream.ts +7 -7
  298. package/src/protocol/output/chat_completions.ts +13 -13
  299. package/src/protocol/output/chat_reasoning_detail.ts +1 -1
  300. package/src/protocol/output/openai_responses.ts +3 -3
  301. package/src/protocol/output/openai_responses_output.ts +4 -2
  302. package/src/protocol/output/openai_responses_stream.ts +6 -6
  303. package/src/protocol/output/sse_stream.ts +3 -3
  304. package/src/providers/anthropic_safeguards.ts +2 -2
  305. package/src/providers/aws_assume_role.ts +2 -2
  306. package/src/providers/cancel_estimate.ts +1 -1
  307. package/src/providers/execution.ts +17 -17
  308. package/src/providers/pi.ts +14 -14
  309. package/src/providers/pi_context.ts +6 -6
  310. package/src/providers/pi_options.ts +10 -10
  311. package/src/providers/pi_output.ts +5 -5
  312. package/src/providers/provider_attempt_runner.ts +1 -1
  313. package/src/providers/provider_call.ts +14 -14
  314. package/src/providers/provider_reported_cost.ts +3 -3
  315. package/src/providers/reasoning.ts +2 -2
  316. package/src/providers/stream_finalization.ts +9 -9
  317. package/src/providers/subscription_limits.ts +3 -3
  318. package/src/runtime/claude_code/auxiliary_routing.ts +5 -5
  319. package/src/runtime/customer_disconnect.ts +1 -1
  320. package/src/runtime/explicit_model.ts +4 -4
  321. package/src/runtime/harness_identity/conversation.ts +1 -1
  322. package/src/runtime/harness_identity/extract.ts +3 -3
  323. package/src/runtime/harness_identity/index.ts +2 -2
  324. package/src/runtime/prepare_routed_completion.ts +13 -13
  325. package/src/runtime/provider_stream_lifecycle.ts +1 -1
  326. package/src/runtime/provider_stream_outcome.ts +2 -2
  327. package/src/runtime/request_tags.ts +2 -2
  328. package/src/runtime/routed_completion.ts +11 -11
  329. package/src/runtime/routed_protocol.ts +2 -2
  330. package/src/runtime/routed_runtime.ts +20 -19
  331. package/src/runtime/routing_lease.ts +7 -7
  332. package/src/runtime/runtime_reporter.ts +3 -3
  333. package/src/self_host/main.ts +12 -12
  334. package/src/self_host/platform.ts +5 -5
  335. package/src/self_host/prefix_store.ts +2 -2
  336. package/src/self_host/resolve.ts +6 -6
  337. package/src/self_host/subscriptions/access.ts +2 -2
  338. package/src/self_host/subscriptions/http.ts +2 -2
  339. package/src/self_host/subscriptions/index.ts +4 -4
  340. package/src/self_host/subscriptions/store.ts +1 -1
  341. package/src/strategies/auto_routing_selector.ts +2 -2
  342. package/src/strategies/eval_relevance.ts +3 -3
  343. package/src/strategies/priority_selector.ts +1 -1
  344. package/src/strategies/route_decision.ts +7 -7
  345. package/src/strategies/routing.ts +10 -10
  346. package/src/strategies/selector_projection.ts +2 -2
  347. package/src/telemetry/billing_finalization.ts +3 -3
  348. package/src/telemetry/model_cost.ts +1 -1
  349. package/src/telemetry/prefix_state.ts +4 -4
  350. package/src/telemetry/report.ts +21 -21
  351. package/src/telemetry/requests/interaction_observability.ts +1 -1
  352. package/src/telemetry/requests/retained_interaction_request.ts +1 -1
  353. package/src/telemetry/skills/claude/catalog.ts +1 -1
  354. package/src/telemetry/skills/claude/file_reads.ts +6 -6
  355. package/src/telemetry/skills/claude/observations.ts +3 -3
  356. package/src/telemetry/skills/codex/catalog.ts +3 -3
  357. package/src/telemetry/skills/codex/exec_file_reads.ts +4 -4
  358. package/src/telemetry/skills/codex/explicit.ts +3 -3
  359. package/src/telemetry/skills/codex/file_reads.ts +5 -5
  360. package/src/telemetry/skills/observations.ts +7 -7
  361. package/src/telemetry/skills/pi.ts +3 -3
  362. package/src/telemetry/skills/shell_file_reads.ts +2 -2
  363. package/src/telemetry/skills/shell_words.ts +1 -1
  364. package/src/telemetry/tools/input.ts +1 -1
  365. package/src/telemetry/tools/observations.ts +9 -9
  366. package/src/telemetry/usage.ts +5 -5
@@ -0,0 +1,94 @@
1
+ import type { CustomRouterConfig, Provider, ReasoningEffort, RouterEval, RouterEvalScore, RouterModelPrice, RouterPrefixHit, RoutingStrategy } from "@mupt-ai/dari-router/policy-engine";
2
+ export type ProviderKeySource = "user" | "managed" | "subscription";
3
+ export type BearerProviderAuth = {
4
+ type: "bearer";
5
+ apiKey: string;
6
+ };
7
+ export type AwsSigV4ProviderAuth = {
8
+ type: "aws_sigv4";
9
+ access_key_id: string;
10
+ secret_access_key: string;
11
+ session_token?: string | null;
12
+ region: string;
13
+ };
14
+ export type AwsAssumeRoleProviderAuth = {
15
+ type: "aws_assume_role";
16
+ role_arn: string;
17
+ external_id: string;
18
+ region: string;
19
+ };
20
+ export type ResolvedProviderAuth = BearerProviderAuth | AwsSigV4ProviderAuth;
21
+ export type ProviderCredential = {
22
+ apiKey: string;
23
+ baseUrl?: string;
24
+ headers?: Record<string, string>;
25
+ };
26
+ export type ProviderAuth = ResolvedProviderAuth | AwsAssumeRoleProviderAuth;
27
+ export type AwsProviderAuth = AwsSigV4ProviderAuth | AwsAssumeRoleProviderAuth;
28
+ export type PublicEvalCatalogScore = RouterEvalScore & {
29
+ source_row_name?: string | null;
30
+ source_date?: string | null;
31
+ last_synced_at?: string | null;
32
+ sample_count?: number | null;
33
+ };
34
+ export type PublicEvalCatalogCard = Omit<RouterEval, "scores"> & {
35
+ source_id: string;
36
+ source_name: string;
37
+ source_url: string;
38
+ harness: string;
39
+ updated_at: string | null;
40
+ scores: PublicEvalCatalogScore[];
41
+ };
42
+ export type ClientHarness = "claude_code";
43
+ export type ResolvedRouterModelConfig = {
44
+ provider: string;
45
+ native_model_id: string;
46
+ api: string;
47
+ base_url?: string | null;
48
+ context_window?: number | null;
49
+ standard_context_limit?: number | null;
50
+ allow_long_context?: boolean;
51
+ max_output_tokens?: number | null;
52
+ supported_thinking_levels?: ReasoningEffort[] | null;
53
+ default_thinking_level?: ReasoningEffort | null;
54
+ average_output_tokens?: Partial<Record<ReasoningEffort, number>> | null;
55
+ cost: RouterModelPrice;
56
+ supports_managed_key?: boolean;
57
+ fast_mode?: boolean;
58
+ fast_mode_cost?: RouterModelPrice | null;
59
+ zdr?: boolean;
60
+ };
61
+ export type ResolvedRouter = {
62
+ router_id: string;
63
+ organization_id: string;
64
+ api_key_id: string | null;
65
+ attributed_user_id: string | null;
66
+ enabled_models: string[];
67
+ provider_keys: Partial<Record<Provider, string>>;
68
+ provider_auth?: Partial<Record<Provider, AwsProviderAuth>>;
69
+ provider_key_sources?: Partial<Record<Provider, ProviderKeySource>>;
70
+ provider_credentials?: Record<string, ProviderCredential>;
71
+ subscription_credential_ids?: Partial<Record<Provider, string>>;
72
+ zdr?: boolean;
73
+ allow_long_context?: boolean;
74
+ speculative_routing?: boolean;
75
+ primary_retries?: number;
76
+ strict?: boolean;
77
+ model_fallback_enabled?: boolean;
78
+ fallback_requires_different_provider?: boolean;
79
+ evals?: RouterEval[];
80
+ eval_score_imputation?: boolean;
81
+ image_capability_filtering?: boolean;
82
+ lease_context_enabled?: boolean;
83
+ selector_image_input_enabled?: boolean;
84
+ public_eval_catalog?: PublicEvalCatalogCard[] | null;
85
+ prefix_hits?: RouterPrefixHit[];
86
+ routing_strategy?: RoutingStrategy;
87
+ custom_config?: CustomRouterConfig | null;
88
+ model_thinking_levels?: Record<string, ReasoningEffort[]>;
89
+ fast_models?: string[];
90
+ model_prices?: Record<string, RouterModelPrice>;
91
+ model_configs?: Record<string, ResolvedRouterModelConfig>;
92
+ credit_exhausted?: boolean;
93
+ autorouting_enabled?: boolean;
94
+ };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mupt-ai/dari-gateway",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Self-hostable LLM gateway for coding agents and APIs: one endpoint for Anthropic Messages, OpenAI Chat Completions, and OpenAI Responses, with subscription pooling, failover, and prompt-cache-aware routing.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -9,14 +9,27 @@
9
9
  },
10
10
  "type": "module",
11
11
  "exports": {
12
- ".": "./src/index.ts",
13
- "./bun": "./src/bun.ts",
14
- "./*": "./src/*.ts"
12
+ ".": {
13
+ "bun": "./src/index.ts",
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./bun": {
18
+ "bun": "./src/bun.ts",
19
+ "types": "./dist/bun.d.ts",
20
+ "default": "./dist/bun.js"
21
+ },
22
+ "./*": {
23
+ "bun": "./src/*.ts",
24
+ "types": "./dist/*.d.ts",
25
+ "default": "./dist/*.js"
26
+ }
15
27
  },
16
28
  "bin": {
17
- "dari-gateway": "./src/self_host/main.ts"
29
+ "dari-gateway": "./dist/self_host/main.js"
18
30
  },
19
31
  "files": [
32
+ "dist",
20
33
  "src",
21
34
  "!src/**/*.test.ts",
22
35
  "!src/**/*.fixtures.ts",
@@ -29,8 +42,10 @@
29
42
  ],
30
43
  "scripts": {
31
44
  "start": "bun run src/self_host/main.ts",
45
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
32
46
  "typecheck": "tsc --noEmit",
33
- "test": "bun test"
47
+ "test": "bun test",
48
+ "prepack": "bun run build"
34
49
  },
35
50
  "dependencies": {
36
51
  "@aws-sdk/client-sts": "3.1063.0",
package/src/bun.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  // Bun-only entry points: the Bun.serve HTTP server and the self-hosted
2
2
  // gateway, whose state lives in bun:sqlite.
3
- export { installShutdownHandlers, startServer } from "./http/serve";
4
- export { startSelfHostedGateway } from "./self_host/main";
3
+ export { installShutdownHandlers, startServer } from "./http/serve.js";
4
+ export { startSelfHostedGateway } from "./self_host/main.js";
@@ -1,4 +1,4 @@
1
- import type { PublicEvalCatalogCard } from "../types";
1
+ import type { PublicEvalCatalogCard } from "../types.js";
2
2
  import type { RouterEval } from "@mupt-ai/dari-router/policy-engine";
3
3
 
4
4
  // Convert public cards into hidden ratio-calibration inputs. Cards without a
@@ -2,20 +2,20 @@ import { createHash } from "node:crypto";
2
2
 
3
3
  import { stableStringify } from "@mupt-ai/dari-router/policy-engine";
4
4
 
5
- import { anthropicMessagesToInteraction } from "../protocol/input/anthropic_messages";
6
- import { internalChatCompletionsToInteraction } from "../protocol/input/chat_completions";
7
- import { anthropicContent } from "../protocol/output/anthropic_messages_output";
8
- import { assistantMessagePayload } from "../protocol/output/chat_completions";
9
- import { compatibleProviderContinuation } from "../interaction/provider_continuation_state";
5
+ import { anthropicMessagesToInteraction } from "../protocol/input/anthropic_messages.js";
6
+ import { internalChatCompletionsToInteraction } from "../protocol/input/chat_completions.js";
7
+ import { anthropicContent } from "../protocol/output/anthropic_messages_output.js";
8
+ import { assistantMessagePayload } from "../protocol/output/chat_completions.js";
9
+ import { compatibleProviderContinuation } from "../interaction/provider_continuation_state.js";
10
10
  import type {
11
11
  InteractionItem,
12
12
  InteractionOutput,
13
13
  InteractionRequest,
14
14
  ProviderContinuationState,
15
15
  ProviderIdentity,
16
- } from "../interaction/types";
17
- import { providerToolCallId, toolWireName } from "../interaction/tool_identity";
18
- import { ROUTING_PREFIX_HASHES_MAX_COUNT } from "../platform/routing_contract";
16
+ } from "../interaction/types.js";
17
+ import { providerToolCallId, toolWireName } from "../interaction/tool_identity.js";
18
+ import { ROUTING_PREFIX_HASHES_MAX_COUNT } from "../platform/routing_contract.js";
19
19
  import {
20
20
  appendFingerprintContentText,
21
21
  canonicalInteractionFingerprintStep,
@@ -25,7 +25,7 @@ import {
25
25
  normalizedAssistantFingerprintContent,
26
26
  type InteractionFingerprintStep,
27
27
  type ReasoningFingerprint,
28
- } from "./interaction_fingerprint_format";
28
+ } from "./interaction_fingerprint_format.js";
29
29
 
30
30
  const MAX_CONTINUATION_TARGETS = 16;
31
31
 
@@ -5,7 +5,7 @@ import { stableStringify } from "@mupt-ai/dari-router/policy-engine";
5
5
  import type {
6
6
  InteractionContent,
7
7
  InteractionRequest,
8
- } from "../interaction/types";
8
+ } from "../interaction/types.js";
9
9
 
10
10
  // Bump when canonical fingerprint semantics change so persisted hashes from
11
11
  // incompatible contracts remain disjoint.
@@ -2,7 +2,7 @@ import type {
2
2
  InteractionContent,
3
3
  InteractionMessage,
4
4
  InteractionRequest,
5
- } from "../interaction/types";
5
+ } from "../interaction/types.js";
6
6
 
7
7
  type AssistantGroup = {
8
8
  kind: "assistant";
@@ -1,5 +1,5 @@
1
1
  import type { ModelPricing, PricingLookup } from "@mupt-ai/dari-router/policy-engine";
2
- import type { ResolvedRouter } from "../types";
2
+ import type { ResolvedRouter } from "../types.js";
3
3
 
4
4
 
5
5
  export function pricingLookupForRouter(credentials: ResolvedRouter): PricingLookup {
@@ -4,15 +4,15 @@ import {
4
4
  type CandidatePromptAccounting,
5
5
  } from "@mupt-ai/dari-router/policy-engine";
6
6
 
7
- import { toolsByWireName } from "../interaction/tool_identity";
7
+ import { toolsByWireName } from "../interaction/tool_identity.js";
8
8
  import type {
9
9
  InteractionContent,
10
10
  InteractionRequest,
11
11
  ProviderIdentity,
12
- } from "../interaction/types";
13
- import { buildContext } from "../providers/pi_context";
14
- import { isOpenAIResponsesApi } from "../providers/model_capabilities";
15
- import type { InteractionPrefixContext } from "./interaction_fingerprint";
12
+ } from "../interaction/types.js";
13
+ import { buildContext } from "../providers/pi_context.js";
14
+ import { isOpenAIResponsesApi } from "../providers/model_capabilities.js";
15
+ import type { InteractionPrefixContext } from "./interaction_fingerprint.js";
16
16
 
17
17
  type PromptMetrics = {
18
18
  blockDepth: number;
@@ -15,34 +15,34 @@ import {
15
15
  } from "@mupt-ai/dari-router/policy-engine";
16
16
  import { randomUUID } from "node:crypto";
17
17
 
18
- import { HttpError } from "../http/errors";
19
- import { effectiveContextWindow } from "../models/context_limits";
20
- import { keySourceForModel } from "../models/execution_provider";
21
- import { requiredCapabilitiesFor } from "../interaction/capabilities";
22
- import { providerIdentityFromModel } from "../interaction/provider_continuation_state";
23
- import { isBackgroundRequest, type InteractionRequest, type ProviderIdentity } from "../interaction/types";
24
- import { requireCandidateModels } from "../models/ids";
25
- import { modelMetadataLookup } from "../providers/pi";
18
+ import { HttpError } from "../http/errors.js";
19
+ import { effectiveContextWindow } from "../models/context_limits.js";
20
+ import { keySourceForModel } from "../models/execution_provider.js";
21
+ import { requiredCapabilitiesFor } from "../interaction/capabilities.js";
22
+ import { providerIdentityFromModel } from "../interaction/provider_continuation_state.js";
23
+ import { isBackgroundRequest, type InteractionRequest, type ProviderIdentity } from "../interaction/types.js";
24
+ import { requireCandidateModels } from "../models/ids.js";
25
+ import { modelMetadataLookup } from "../providers/pi.js";
26
26
  import {
27
27
  modelSupportsImageInput,
28
28
  modelSupportsHostedWebSearch,
29
29
  modelSupportsReasoningConfigurationUpdate,
30
30
  providerApiCanSerializeResponseFormat,
31
- } from "../providers/model_capabilities";
31
+ } from "../providers/model_capabilities.js";
32
32
  import {
33
33
  selectorMessagesForInteraction,
34
34
  type SelectorImage,
35
- } from "../strategies/selector_projection";
36
- import type { ResolvedRouter } from "../types";
35
+ } from "../strategies/selector_projection.js";
36
+ import type { ResolvedRouter } from "../types.js";
37
37
  import {
38
38
  interactionPrefixContext,
39
39
  interactionPrefixLookupHashes,
40
40
  type InteractionPrefixContext,
41
- } from "./interaction_fingerprint";
42
- import { pricingLookupForRouter } from "./pricing";
43
- import { providerPromptAccounting } from "./provider_prompt_accounting";
44
- import { leaseHistoryFromPrefixHits } from "./lease_history";
45
- import { interactionLeaseFenceDepth } from "./interaction_lease_depth";
41
+ } from "./interaction_fingerprint.js";
42
+ import { pricingLookupForRouter } from "./pricing.js";
43
+ import { providerPromptAccounting } from "./provider_prompt_accounting.js";
44
+ import { leaseHistoryFromPrefixHits } from "./lease_history.js";
45
+ import { interactionLeaseFenceDepth } from "./interaction_lease_depth.js";
46
46
 
47
47
  export type ImageCapabilityPrunedModel = {
48
48
  model: string;
package/src/http/auth.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { timingSafeEqual } from "node:crypto";
2
2
 
3
- import { HttpError } from "./errors";
3
+ import { HttpError } from "./errors.js";
4
4
 
5
5
  export function bearerToken(headers: Headers): string {
6
6
  const value = headers.get("authorization") ?? "";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  handleResponses,
3
3
  handleResponsesWebSocketFallback,
4
- } from "../ingress/codex";
5
- import { handleModels } from "../ingress/models";
6
- import { handleChatCompletions } from "../ingress/chat_completions";
7
- import { handleAnthropicMessages } from "../ingress/anthropic_messages";
8
- import { bindGatewayPlatform, type GatewayPlatform } from "../platform/platform";
9
- import { DEFAULT_ROUTER_ALIAS } from "../platform/routing_contract";
10
- import type { SelectorBackend } from "../strategies/routing";
11
- import { errorResponse, HttpError } from "./errors";
4
+ } from "../ingress/codex.js";
5
+ import { handleModels } from "../ingress/models.js";
6
+ import { handleChatCompletions } from "../ingress/chat_completions.js";
7
+ import { handleAnthropicMessages } from "../ingress/anthropic_messages.js";
8
+ import { bindGatewayPlatform, type GatewayPlatform } from "../platform/platform.js";
9
+ import { DEFAULT_ROUTER_ALIAS } from "../platform/routing_contract.js";
10
+ import type { SelectorBackend } from "../strategies/routing.js";
11
+ import { errorResponse, HttpError } from "./errors.js";
12
12
 
13
13
  export type GatewayHandlerOptions = {
14
14
  platform: GatewayPlatform;
package/src/http/serve.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { captureOperationalError } from "../observability/errors";
2
- import { drainBackgroundTelemetryFor } from "../telemetry/background";
3
- import { startHttp2Server } from "./http2_server";
1
+ import { captureOperationalError } from "../observability/errors.js";
2
+ import { drainBackgroundTelemetryFor } from "../telemetry/background.js";
3
+ import { startHttp2Server } from "./http2_server.js";
4
4
 
5
5
  const GRACEFUL_SERVER_STOP_TIMEOUT_MS = 5_000;
6
6
  const FORCE_STOP_SETTLE_TIMEOUT_MS = 250;
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // (`@mupt-ai/dari-gateway/<dir>/<module>`) for deployments that compose the
3
3
  // gateway with their own platform. This entry needs no Bun APIs; the Bun
4
4
  // server and the SQLite-backed self-hosted gateway live in `./bun`.
5
- export { createRequestHandler, type GatewayHandlerOptions } from "./http/handler";
5
+ export { createRequestHandler, type GatewayHandlerOptions } from "./http/handler.js";
6
6
  export type {
7
7
  GatewayPlatform,
8
8
  OperationalErrorContext,
@@ -15,8 +15,8 @@ export type {
15
15
  RequestTags,
16
16
  ResolveRouterRequest,
17
17
  SubscriptionHold,
18
- } from "./platform/platform";
19
- export { createAutoRoutingSelectorBackend } from "./strategies/auto_routing_selector";
20
- export { createPrioritySelectorBackend } from "./strategies/priority_selector";
21
- export { createLlmSelectorBackend, type SelectorBackend } from "./strategies/routing";
22
- export type { ProviderCredential, ResolvedRouter } from "./types";
18
+ } from "./platform/platform.js";
19
+ export { createAutoRoutingSelectorBackend } from "./strategies/auto_routing_selector.js";
20
+ export { createPrioritySelectorBackend } from "./strategies/priority_selector.js";
21
+ export { createLlmSelectorBackend, type SelectorBackend } from "./strategies/routing.js";
22
+ export type { ProviderCredential, ResolvedRouter } from "./types.js";
@@ -1,18 +1,18 @@
1
1
  import { isRecord } from "@mupt-ai/dari-router/policy-engine";
2
- import { anthropicMessagesResponse } from "../protocol/output/anthropic_messages";
3
- import { anthropicMessagesSseStream } from "../protocol/output/anthropic_messages_stream";
4
- import { anthropicToken } from "../http/auth";
5
- import { errorResponseHeaders, normalizeError } from "../http/errors";
6
- import { captureRequestError } from "../observability/errors";
7
- import { anthropicMessagesToInteraction } from "../protocol/input/anthropic_messages";
8
- import { handleRoutedCompletion } from "../runtime/routed_completion";
9
- import type { SelectorBackend } from "../strategies/routing";
10
- import { claudeCodeRequestContext } from "./claude_code/request_context";
2
+ import { anthropicMessagesResponse } from "../protocol/output/anthropic_messages.js";
3
+ import { anthropicMessagesSseStream } from "../protocol/output/anthropic_messages_stream.js";
4
+ import { anthropicToken } from "../http/auth.js";
5
+ import { errorResponseHeaders, normalizeError } from "../http/errors.js";
6
+ import { captureRequestError } from "../observability/errors.js";
7
+ import { anthropicMessagesToInteraction } from "../protocol/input/anthropic_messages.js";
8
+ import { handleRoutedCompletion } from "../runtime/routed_completion.js";
9
+ import type { SelectorBackend } from "../strategies/routing.js";
10
+ import { claudeCodeRequestContext } from "./claude_code/request_context.js";
11
11
  import {
12
12
  claudeCodeConversationIdentity,
13
- } from "../runtime/harness_identity";
14
- import { parseJsonRequest } from "./json";
15
- import type { AnthropicSafeguards } from "../interaction/types";
13
+ } from "../runtime/harness_identity/index.js";
14
+ import { parseJsonRequest } from "./json.js";
15
+ import type { AnthropicSafeguards } from "../interaction/types.js";
16
16
 
17
17
  type AnthropicErrorType =
18
18
  | "authentication_error"
@@ -6,7 +6,7 @@
6
6
  is rejected, bare tier names classify). Fixed created_at keeps the response
7
7
  byte-stable. */
8
8
 
9
- import { ANTHROPIC_ROUTER_MODEL_TIERS } from "../protocol/input/router_model";
9
+ import { ANTHROPIC_ROUTER_MODEL_TIERS } from "../protocol/input/router_model.js";
10
10
 
11
11
  const ROUTER_MODEL_CREATED_AT = "2026-01-01T00:00:00Z";
12
12
 
@@ -1,16 +1,16 @@
1
1
  import type { ChatCompletionRequest } from "@mupt-ai/dari-router/policy-engine";
2
- import { bearerToken } from "../http/auth";
3
- import { errorResponse } from "../http/errors";
4
- import { captureRequestError } from "../observability/errors";
5
- import { chatCompletionResponse, chatCompletionsSseStream } from "../protocol/output/chat_completions";
6
- import { chatCompletionsToInteraction } from "../protocol/input/chat_completions";
7
- import { handleRoutedCompletion } from "../runtime/routed_completion";
8
- import type { SelectorBackend } from "../strategies/routing";
2
+ import { bearerToken } from "../http/auth.js";
3
+ import { errorResponse } from "../http/errors.js";
4
+ import { captureRequestError } from "../observability/errors.js";
5
+ import { chatCompletionResponse, chatCompletionsSseStream } from "../protocol/output/chat_completions.js";
6
+ import { chatCompletionsToInteraction } from "../protocol/input/chat_completions.js";
7
+ import { handleRoutedCompletion } from "../runtime/routed_completion.js";
8
+ import type { SelectorBackend } from "../strategies/routing.js";
9
9
  import {
10
10
  chatCompletionsConversationIdentity,
11
11
  openCodeRequestContext,
12
- } from "../runtime/harness_identity";
13
- import { parseJsonRequest } from "./json";
12
+ } from "../runtime/harness_identity/index.js";
13
+ import { parseJsonRequest } from "./json.js";
14
14
 
15
15
  export async function handleChatCompletions(
16
16
  request: Request,
@@ -1,5 +1,5 @@
1
- import { HttpError } from "../../http/errors";
2
- import type { AgentRequestContext, AgentRequestClass } from "../../interaction/types";
1
+ import { HttpError } from "../../http/errors.js";
2
+ import type { AgentRequestContext, AgentRequestClass } from "../../interaction/types.js";
3
3
 
4
4
  const REQUEST_CLASSES = new Set<AgentRequestClass>([
5
5
  "main", "subagent", "workflow", "auxiliary", "compaction", "side_reply",
@@ -1,17 +1,17 @@
1
- import { bearerToken } from "../http/auth";
2
- import { errorResponse } from "../http/errors";
3
- import { captureRequestError } from "../observability/errors";
4
- import { openAIResponsesResponse } from "../protocol/output/openai_responses";
5
- import { openAIResponsesSseStream } from "../protocol/output/openai_responses_stream";
6
- import { openAIResponsesToInteraction } from "../protocol/input/openai_responses";
7
- import { parseJsonRequest } from "./json";
8
- import { handleRoutedCompletion } from "../runtime/routed_completion";
9
- import type { SelectorBackend } from "../strategies/routing";
1
+ import { bearerToken } from "../http/auth.js";
2
+ import { errorResponse } from "../http/errors.js";
3
+ import { captureRequestError } from "../observability/errors.js";
4
+ import { openAIResponsesResponse } from "../protocol/output/openai_responses.js";
5
+ import { openAIResponsesSseStream } from "../protocol/output/openai_responses_stream.js";
6
+ import { openAIResponsesToInteraction } from "../protocol/input/openai_responses.js";
7
+ import { parseJsonRequest } from "./json.js";
8
+ import { handleRoutedCompletion } from "../runtime/routed_completion.js";
9
+ import type { SelectorBackend } from "../strategies/routing.js";
10
10
  import {
11
11
  codexConversationIdentity,
12
12
  codexRequestPurpose,
13
13
  codexRequestContext,
14
- } from "../runtime/harness_identity";
14
+ } from "../runtime/harness_identity/index.js";
15
15
 
16
16
  export async function handleResponses(
17
17
  request: Request,
@@ -1,7 +1,7 @@
1
- import type { ResolvedRouter } from "../types";
2
- import { CANONICAL_ROUTER_MODEL, explicitModelSlug } from "../protocol/input/router_model";
3
- import { effectiveContextWindow } from "../models/context_limits";
4
- import { modelSupportsHostedWebSearch } from "../providers/model_capabilities";
1
+ import type { ResolvedRouter } from "../types.js";
2
+ import { CANONICAL_ROUTER_MODEL, explicitModelSlug } from "../protocol/input/router_model.js";
3
+ import { effectiveContextWindow } from "../models/context_limits.js";
4
+ import { modelSupportsHostedWebSearch } from "../providers/model_capabilities.js";
5
5
 
6
6
  const DEFAULT_CODEX_CONTEXT_WINDOW = 128_000;
7
7
 
@@ -6,7 +6,7 @@ import {
6
6
  createZstdDecompress,
7
7
  } from "node:zlib";
8
8
 
9
- import { HttpError } from "../http/errors";
9
+ import { HttpError } from "../http/errors.js";
10
10
 
11
11
  const MAX_ENCODED_JSON_REQUEST_BYTES = 64 * 1024 * 1024;
12
12
  const MAX_DECODED_JSON_REQUEST_BYTES = 64 * 1024 * 1024;
@@ -4,15 +4,15 @@
4
4
  handler detects the caller, authenticates in that protocol's auth shape,
5
5
  and selects the matching catalog adapter. */
6
6
 
7
- import { anthropicToken, bearerToken } from "../http/auth";
8
- import { errorResponse } from "../http/errors";
9
- import { captureRequestError } from "../observability/errors";
10
- import { anthropicErrorResponse } from "./anthropic_messages";
11
- import { modelSupportsImageInput } from "../providers/model_capabilities";
12
- import { modelMetadataLookup } from "../providers/pi";
13
- import { resolveRouter } from "../strategies/routing";
14
- import { anthropicModelsResponse } from "./anthropic_models";
15
- import { codexModelsResponse } from "./codex_models";
7
+ import { anthropicToken, bearerToken } from "../http/auth.js";
8
+ import { errorResponse } from "../http/errors.js";
9
+ import { captureRequestError } from "../observability/errors.js";
10
+ import { anthropicErrorResponse } from "./anthropic_messages.js";
11
+ import { modelSupportsImageInput } from "../providers/model_capabilities.js";
12
+ import { modelMetadataLookup } from "../providers/pi.js";
13
+ import { resolveRouter } from "../strategies/routing.js";
14
+ import { anthropicModelsResponse } from "./anthropic_models.js";
15
+ import { codexModelsResponse } from "./codex_models.js";
16
16
 
17
17
  export async function handleModels(request: Request, routerId: string): Promise<Response> {
18
18
  // Anthropic SDK clients always send anthropic-version, and API-key probes
@@ -1,5 +1,5 @@
1
1
  import type { HardCapability } from "@mupt-ai/dari-router/policy-engine";
2
- import type { InteractionItem, InteractionRequest } from "./types";
2
+ import type { InteractionItem, InteractionRequest } from "./types.js";
3
3
 
4
4
  export function requiredCapabilitiesFor(
5
5
  request: Pick<InteractionRequest, "items" | "responseFormat" | "toolChoice" | "tools">
@@ -4,7 +4,7 @@ import {
4
4
  type PortableReasoningState,
5
5
  } from "@mupt-ai/dari-router/protocols";
6
6
 
7
- import { rethrowFrameworkErrorAsHttp } from "../http/errors";
7
+ import { rethrowFrameworkErrorAsHttp } from "../http/errors.js";
8
8
 
9
9
  export type { PortableReasoningState } from "@mupt-ai/dari-router/protocols";
10
10
 
@@ -6,7 +6,7 @@ import {
6
6
  type ProviderIdentity,
7
7
  } from "@mupt-ai/dari-router/protocols";
8
8
 
9
- import { rethrowFrameworkErrorAsHttp } from "../http/errors";
9
+ import { rethrowFrameworkErrorAsHttp } from "../http/errors.js";
10
10
 
11
11
  export type { ProviderContinuationState, ProviderIdentity } from "@mupt-ai/dari-router/protocols";
12
12
  export { compatibleProviderContinuation, isAnthropicEffort, sameProviderIdentity } from "@mupt-ai/dari-router/protocols";
@@ -1,5 +1,5 @@
1
- import { HttpError } from "../http/errors";
2
- import type { InteractionTool, ProviderIdentity } from "./types";
1
+ import { HttpError } from "../http/errors.js";
2
+ import type { InteractionTool, ProviderIdentity } from "./types.js";
3
3
 
4
4
  export const TOOL_CALL_ID_MAX_LENGTH = 512;
5
5
 
@@ -1,4 +1,4 @@
1
- import type { ResolvedRouterModelConfig } from "../types";
1
+ import type { ResolvedRouterModelConfig } from "../types.js";
2
2
 
3
3
  export function effectiveContextWindow(config: ResolvedRouterModelConfig | undefined, allowLongContext = false): number | null {
4
4
  const window = config?.context_window;
@@ -1,5 +1,5 @@
1
1
  import { providerForModel } from "@mupt-ai/dari-router/policy-engine";
2
- import type { ProviderKeySource, ResolvedRouter } from "../types";
2
+ import type { ProviderKeySource, ResolvedRouter } from "../types.js";
3
3
 
4
4
  /** Actual serving provider for a canonical model on a resolved managed router. */
5
5
  export function executionProviderForModel(
package/src/models/ids.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { providerForModel } from "@mupt-ai/dari-router/policy-engine";
2
- import { HttpError } from "../http/errors";
2
+ import { HttpError } from "../http/errors.js";
3
3
 
4
4
  export function requireCandidateModels(value: unknown): string[] {
5
5
  if (!Array.isArray(value) || value.length === 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,