@code-yeongyu/senpi 2026.8.14 → 2026.8.16

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 (490) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +1 -0
  3. package/dist/cli/args.d.ts +1 -0
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +14 -0
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/auth-command.d.ts.map +1 -1
  8. package/dist/cli/auth-command.js +5 -4
  9. package/dist/cli/auth-command.js.map +1 -1
  10. package/dist/core/agent-session.d.ts +79 -8
  11. package/dist/core/agent-session.d.ts.map +1 -1
  12. package/dist/core/agent-session.js +190 -30
  13. package/dist/core/agent-session.js.map +1 -1
  14. package/dist/core/auth-storage.d.ts.map +1 -1
  15. package/dist/core/auth-storage.js +19 -8
  16. package/dist/core/auth-storage.js.map +1 -1
  17. package/dist/core/experimental.d.ts +4 -0
  18. package/dist/core/experimental.d.ts.map +1 -1
  19. package/dist/core/experimental.js +4 -0
  20. package/dist/core/experimental.js.map +1 -1
  21. package/dist/core/export-html/template.js +31 -9
  22. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-environment.d.ts +4 -0
  23. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-environment.d.ts.map +1 -0
  24. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-environment.js +30 -0
  25. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-environment.js.map +1 -0
  26. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.d.ts +2 -0
  27. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.d.ts.map +1 -1
  28. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.js +13 -47
  29. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.js.map +1 -1
  30. package/dist/core/extensions/builtin/claude-sdk-oauth/availability.d.ts +18 -1
  31. package/dist/core/extensions/builtin/claude-sdk-oauth/availability.d.ts.map +1 -1
  32. package/dist/core/extensions/builtin/claude-sdk-oauth/availability.js +64 -2
  33. package/dist/core/extensions/builtin/claude-sdk-oauth/availability.js.map +1 -1
  34. package/dist/core/extensions/builtin/claude-sdk-oauth/config-dir-credentials.d.ts +3 -0
  35. package/dist/core/extensions/builtin/claude-sdk-oauth/config-dir-credentials.d.ts.map +1 -0
  36. package/dist/core/extensions/builtin/claude-sdk-oauth/config-dir-credentials.js +27 -0
  37. package/dist/core/extensions/builtin/claude-sdk-oauth/config-dir-credentials.js.map +1 -0
  38. package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.d.ts +15 -2
  39. package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.d.ts.map +1 -1
  40. package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.js +45 -11
  41. package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.js.map +1 -1
  42. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +1 -0
  43. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -1
  44. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts.map +1 -1
  45. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js +17 -1
  46. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -1
  47. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.d.ts.map +1 -1
  48. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js +1 -0
  49. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js.map +1 -1
  50. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  51. package/dist/core/extensions/builtin/compaction/index.js +48 -6
  52. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  53. package/dist/core/extensions/builtin/compaction/log.d.ts +1 -1
  54. package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
  55. package/dist/core/extensions/builtin/compaction/log.js +2 -0
  56. package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
  57. package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts.map +1 -1
  58. package/dist/core/extensions/builtin/compaction/overflow-retry.js +38 -4
  59. package/dist/core/extensions/builtin/compaction/overflow-retry.js.map +1 -1
  60. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  61. package/dist/core/extensions/builtin/compaction/speculative.js +2 -1
  62. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  63. package/dist/core/extensions/builtin/compaction/summarization-turn-order.d.ts +33 -0
  64. package/dist/core/extensions/builtin/compaction/summarization-turn-order.d.ts.map +1 -0
  65. package/dist/core/extensions/builtin/compaction/summarization-turn-order.js +67 -0
  66. package/dist/core/extensions/builtin/compaction/summarization-turn-order.js.map +1 -0
  67. package/dist/core/extensions/builtin/config-reload/index.d.ts.map +1 -1
  68. package/dist/core/extensions/builtin/config-reload/index.js +31 -8
  69. package/dist/core/extensions/builtin/config-reload/index.js.map +1 -1
  70. package/dist/core/extensions/builtin/config-reload/routine-settings.d.ts.map +1 -1
  71. package/dist/core/extensions/builtin/config-reload/routine-settings.js +11 -12
  72. package/dist/core/extensions/builtin/config-reload/routine-settings.js.map +1 -1
  73. package/dist/core/extensions/builtin/goal/terminal-provider-error.d.ts.map +1 -1
  74. package/dist/core/extensions/builtin/goal/terminal-provider-error.js +16 -0
  75. package/dist/core/extensions/builtin/goal/terminal-provider-error.js.map +1 -1
  76. package/dist/core/extensions/builtin/index.d.ts.map +1 -1
  77. package/dist/core/extensions/builtin/index.js +4 -0
  78. package/dist/core/extensions/builtin/index.js.map +1 -1
  79. package/dist/core/extensions/builtin/mcp/process-tree.js +6 -1
  80. package/dist/core/extensions/builtin/mcp/process-tree.js.map +1 -1
  81. package/dist/core/extensions/builtin/prompt-preset/glm-5-3.d.ts +3 -0
  82. package/dist/core/extensions/builtin/prompt-preset/glm-5-3.d.ts.map +1 -0
  83. package/dist/core/extensions/builtin/prompt-preset/glm-5-3.js +14 -0
  84. package/dist/core/extensions/builtin/prompt-preset/glm-5-3.js.map +1 -0
  85. package/dist/core/extensions/builtin/prompt-preset/grok-4.6.d.ts +3 -0
  86. package/dist/core/extensions/builtin/prompt-preset/grok-4.6.d.ts.map +1 -0
  87. package/dist/core/extensions/builtin/prompt-preset/grok-4.6.js +91 -0
  88. package/dist/core/extensions/builtin/prompt-preset/grok-4.6.js.map +1 -0
  89. package/dist/core/extensions/builtin/prompt-preset/index.d.ts.map +1 -1
  90. package/dist/core/extensions/builtin/prompt-preset/index.js +22 -2
  91. package/dist/core/extensions/builtin/prompt-preset/index.js.map +1 -1
  92. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  93. package/dist/core/extensions/builtin/prompt-preset/presets.js +25 -0
  94. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  95. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
  96. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  97. package/dist/core/extensions/builtin/prompt-preset/settings.js +2 -0
  98. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  99. package/dist/core/extensions/builtin/reasoning/index.d.ts +3 -0
  100. package/dist/core/extensions/builtin/reasoning/index.d.ts.map +1 -0
  101. package/dist/core/extensions/builtin/reasoning/index.js +211 -0
  102. package/dist/core/extensions/builtin/reasoning/index.js.map +1 -0
  103. package/dist/core/extensions/builtin/service-tier.d.ts +44 -1
  104. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
  105. package/dist/core/extensions/builtin/service-tier.js +176 -24
  106. package/dist/core/extensions/builtin/service-tier.js.map +1 -1
  107. package/dist/core/extensions/runner.d.ts.map +1 -1
  108. package/dist/core/extensions/runner.js +4 -4
  109. package/dist/core/extensions/runner.js.map +1 -1
  110. package/dist/core/extensions/types.d.ts +12 -0
  111. package/dist/core/extensions/types.d.ts.map +1 -1
  112. package/dist/core/extensions/types.js.map +1 -1
  113. package/dist/core/keybindings.d.ts +24 -0
  114. package/dist/core/keybindings.d.ts.map +1 -1
  115. package/dist/core/lockfile-policy.d.ts +15 -0
  116. package/dist/core/lockfile-policy.d.ts.map +1 -0
  117. package/dist/core/lockfile-policy.js +15 -0
  118. package/dist/core/lockfile-policy.js.map +1 -0
  119. package/dist/core/model-config.d.ts.map +1 -1
  120. package/dist/core/model-config.js +1 -0
  121. package/dist/core/model-config.js.map +1 -1
  122. package/dist/core/model-resolver.d.ts +34 -7
  123. package/dist/core/model-resolver.d.ts.map +1 -1
  124. package/dist/core/model-resolver.js +115 -27
  125. package/dist/core/model-resolver.js.map +1 -1
  126. package/dist/core/model-runtime.d.ts.map +1 -1
  127. package/dist/core/model-runtime.js +5 -3
  128. package/dist/core/model-runtime.js.map +1 -1
  129. package/dist/core/provider-api-key-auth.d.ts.map +1 -1
  130. package/dist/core/provider-api-key-auth.js +45 -2
  131. package/dist/core/provider-api-key-auth.js.map +1 -1
  132. package/dist/core/provider-composer.d.ts +12 -1
  133. package/dist/core/provider-composer.d.ts.map +1 -1
  134. package/dist/core/provider-composer.js.map +1 -1
  135. package/dist/core/provider-display-names.d.ts.map +1 -1
  136. package/dist/core/provider-display-names.js +1 -0
  137. package/dist/core/provider-display-names.js.map +1 -1
  138. package/dist/core/remote-catalog-provider.d.ts +13 -0
  139. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  140. package/dist/core/remote-catalog-provider.js +15 -0
  141. package/dist/core/remote-catalog-provider.js.map +1 -1
  142. package/dist/core/retry-fallback/controller.d.ts +1 -1
  143. package/dist/core/retry-fallback/controller.d.ts.map +1 -1
  144. package/dist/core/retry-fallback/controller.js +5 -3
  145. package/dist/core/retry-fallback/controller.js.map +1 -1
  146. package/dist/core/sdk.d.ts +5 -3
  147. package/dist/core/sdk.d.ts.map +1 -1
  148. package/dist/core/sdk.js +14 -8
  149. package/dist/core/sdk.js.map +1 -1
  150. package/dist/core/session-manager.d.ts.map +1 -1
  151. package/dist/core/session-manager.js +20 -4
  152. package/dist/core/session-manager.js.map +1 -1
  153. package/dist/core/settings-manager.d.ts +50 -1
  154. package/dist/core/settings-manager.d.ts.map +1 -1
  155. package/dist/core/settings-manager.js +258 -15
  156. package/dist/core/settings-manager.js.map +1 -1
  157. package/dist/core/system-prompt.js +1 -1
  158. package/dist/core/system-prompt.js.map +1 -1
  159. package/dist/core/thinking-levels.d.ts +22 -0
  160. package/dist/core/thinking-levels.d.ts.map +1 -1
  161. package/dist/core/thinking-levels.js +29 -0
  162. package/dist/core/thinking-levels.js.map +1 -1
  163. package/dist/core/tools/bash.d.ts.map +1 -1
  164. package/dist/core/tools/bash.js +2 -0
  165. package/dist/core/tools/bash.js.map +1 -1
  166. package/dist/core/tools/edit.d.ts.map +1 -1
  167. package/dist/core/tools/edit.js +2 -0
  168. package/dist/core/tools/edit.js.map +1 -1
  169. package/dist/core/tools/find.js +1 -1
  170. package/dist/core/tools/find.js.map +1 -1
  171. package/dist/core/tools/grep.js +1 -1
  172. package/dist/core/tools/grep.js.map +1 -1
  173. package/dist/core/tools/read.d.ts.map +1 -1
  174. package/dist/core/tools/read.js +2 -0
  175. package/dist/core/tools/read.js.map +1 -1
  176. package/dist/core/tools/write.d.ts.map +1 -1
  177. package/dist/core/tools/write.js +2 -0
  178. package/dist/core/tools/write.js.map +1 -1
  179. package/dist/index.d.ts +1 -1
  180. package/dist/index.d.ts.map +1 -1
  181. package/dist/index.js.map +1 -1
  182. package/dist/main.d.ts.map +1 -1
  183. package/dist/main.js +18 -1
  184. package/dist/main.js.map +1 -1
  185. package/dist/modes/interactive/components/model-favorites.d.ts +2 -1
  186. package/dist/modes/interactive/components/model-favorites.d.ts.map +1 -1
  187. package/dist/modes/interactive/components/model-favorites.js +72 -6
  188. package/dist/modes/interactive/components/model-favorites.js.map +1 -1
  189. package/dist/modes/interactive/components/model-selector.d.ts +5 -1
  190. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  191. package/dist/modes/interactive/components/model-selector.js +10 -6
  192. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  193. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  194. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  195. package/dist/modes/interactive/components/settings-selector.js +10 -0
  196. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  197. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  198. package/dist/modes/interactive/components/tool-execution.js +22 -1
  199. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  200. package/dist/modes/interactive/interactive-mode.d.ts +14 -4
  201. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  202. package/dist/modes/interactive/interactive-mode.js +109 -50
  203. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  204. package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
  205. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
  206. package/dist/modes/interactive/model-catalog-refresh.js +36 -0
  207. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
  208. package/dist/modes/interactive/theme/dark.json +2 -0
  209. package/dist/modes/interactive/theme/grok-day.json +2 -0
  210. package/dist/modes/interactive/theme/grok-night.json +2 -0
  211. package/dist/modes/interactive/theme/light.json +2 -0
  212. package/dist/modes/interactive/theme/theme-controller.d.ts +10 -2
  213. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  214. package/dist/modes/interactive/theme/theme-controller.js +23 -10
  215. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  216. package/dist/modes/interactive/theme/theme-schema.json +9 -1
  217. package/dist/modes/interactive/theme/theme.d.ts +5 -3
  218. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  219. package/dist/modes/interactive/theme/theme.js +12 -2
  220. package/dist/modes/interactive/theme/theme.js.map +1 -1
  221. package/dist/modes/json-event.d.ts +4 -1
  222. package/dist/modes/json-event.d.ts.map +1 -1
  223. package/dist/modes/json-event.js +5 -2
  224. package/dist/modes/json-event.js.map +1 -1
  225. package/dist/modes/rpc/connection-handler.d.ts +10 -0
  226. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  227. package/dist/modes/rpc/connection-handler.js +87 -19
  228. package/dist/modes/rpc/connection-handler.js.map +1 -1
  229. package/dist/modes/rpc/multi-session-host.js +3 -3
  230. package/dist/modes/rpc/multi-session-host.js.map +1 -1
  231. package/dist/modes/rpc/rpc-client.d.ts +26 -1
  232. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  233. package/dist/modes/rpc/rpc-client.js +25 -2
  234. package/dist/modes/rpc/rpc-client.js.map +1 -1
  235. package/dist/modes/rpc/rpc-types.d.ts +60 -0
  236. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  237. package/dist/modes/rpc/rpc-types.js.map +1 -1
  238. package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
  239. package/dist/modes/rpc/session-command-router.js +2 -14
  240. package/dist/modes/rpc/session-command-router.js.map +1 -1
  241. package/dist/modes/rpc/session-event-writer.d.ts +29 -10
  242. package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
  243. package/dist/modes/rpc/session-event-writer.js +229 -50
  244. package/dist/modes/rpc/session-event-writer.js.map +1 -1
  245. package/dist/server/create-harness.d.ts.map +1 -1
  246. package/dist/server/create-harness.js +2 -0
  247. package/dist/server/create-harness.js.map +1 -1
  248. package/dist/utils/shell.d.ts +27 -0
  249. package/dist/utils/shell.d.ts.map +1 -1
  250. package/dist/utils/shell.js +79 -13
  251. package/dist/utils/shell.js.map +1 -1
  252. package/dist/utils/tools-manager.d.ts +10 -1
  253. package/dist/utils/tools-manager.d.ts.map +1 -1
  254. package/dist/utils/tools-manager.js +14 -19
  255. package/dist/utils/tools-manager.js.map +1 -1
  256. package/docs/compaction.md +3 -3
  257. package/docs/custom-provider.md +1 -1
  258. package/docs/environment-variables.md +8 -2
  259. package/docs/extensions.md +4 -0
  260. package/docs/json.md +6 -4
  261. package/docs/keybindings.md +8 -2
  262. package/docs/providers.md +7 -0
  263. package/docs/rpc.md +128 -6
  264. package/docs/sdk.md +9 -0
  265. package/docs/settings.md +93 -1
  266. package/docs/terminal-setup.md +23 -2
  267. package/docs/themes.md +24 -3
  268. package/docs/tui.md +2 -2
  269. package/docs/usage.md +24 -4
  270. package/examples/extensions/subagent/agents.ts +40 -9
  271. package/examples/extensions/subagent/index.ts +26 -3
  272. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +14 -0
  273. package/node_modules/@code-yeongyu/senpi-codemode/README.md +5 -0
  274. package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
  275. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +14 -1
  276. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/call-capture.ts +64 -0
  277. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-handler.ts +45 -61
  278. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-runtime.ts +6 -0
  279. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-execution-event.ts +201 -0
  280. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +2 -0
  281. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +22 -0
  282. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts +25 -0
  283. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
  284. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +77 -12
  285. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
  286. package/node_modules/@earendil-works/pi-agent-core/dist/harness/events.d.ts +43 -0
  287. package/node_modules/@earendil-works/pi-agent-core/dist/harness/events.d.ts.map +1 -0
  288. package/node_modules/@earendil-works/pi-agent-core/dist/harness/events.js +67 -0
  289. package/node_modules/@earendil-works/pi-agent-core/dist/harness/events.js.map +1 -0
  290. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.d.ts +4 -2
  291. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.d.ts.map +1 -1
  292. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.js +127 -88
  293. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.js.map +1 -1
  294. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.d.ts +5 -1
  295. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.d.ts.map +1 -1
  296. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js +9 -2
  297. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js.map +1 -1
  298. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.d.ts +12 -3
  299. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.d.ts.map +1 -1
  300. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.js +88 -45
  301. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.js.map +1 -1
  302. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.d.ts +1 -1
  303. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.d.ts.map +1 -1
  304. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.js +28 -19
  305. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.js.map +1 -1
  306. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.d.ts +1 -1
  307. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.d.ts.map +1 -1
  308. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.js.map +1 -1
  309. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.d.ts +1 -1
  310. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.d.ts.map +1 -1
  311. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.js.map +1 -1
  312. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +6 -1
  313. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  314. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +7 -2
  315. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  316. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.d.ts +1 -1
  317. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.d.ts.map +1 -1
  318. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.js.map +1 -1
  319. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.d.ts.map +1 -1
  320. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js +19 -0
  321. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js.map +1 -1
  322. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.d.ts +18 -5
  323. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.d.ts.map +1 -1
  324. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.js.map +1 -1
  325. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +1 -1
  326. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  327. package/node_modules/@earendil-works/pi-agent-core/dist/index.js +1 -1
  328. package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
  329. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +4 -1
  330. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  331. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  332. package/node_modules/@earendil-works/pi-agent-core/dist/search/index.d.ts +21 -0
  333. package/node_modules/@earendil-works/pi-agent-core/dist/search/index.d.ts.map +1 -0
  334. package/node_modules/@earendil-works/pi-agent-core/dist/search/index.js +2 -0
  335. package/node_modules/@earendil-works/pi-agent-core/dist/search/index.js.map +1 -0
  336. package/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.d.ts +29 -0
  337. package/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.d.ts.map +1 -0
  338. package/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js +103 -0
  339. package/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js.map +1 -0
  340. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  341. package/node_modules/@earendil-works/pi-ai/README.md +2 -0
  342. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  343. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +40 -14
  344. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  345. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  346. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +16 -4
  347. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  348. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.d.ts +69 -0
  349. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.d.ts.map +1 -0
  350. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js +159 -0
  351. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js.map +1 -0
  352. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.d.ts +3 -0
  353. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.d.ts.map +1 -1
  354. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +125 -5
  355. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js.map +1 -1
  356. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +7 -3
  357. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
  358. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts +1 -1
  359. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
  360. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +13 -9
  361. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
  362. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +7 -3
  363. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
  364. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts +1 -1
  365. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
  366. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +208 -42
  367. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  368. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  369. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +13 -4
  370. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  371. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  372. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +10 -7
  373. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  374. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +1 -0
  375. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  376. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +31 -7
  377. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  378. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  379. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +8 -1
  380. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  381. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/cursor.d.ts +16 -0
  382. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/cursor.d.ts.map +1 -0
  383. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/cursor.js +234 -0
  384. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/cursor.js.map +1 -0
  385. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.d.ts.map +1 -1
  386. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js +6 -3
  387. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js.map +1 -1
  388. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts +2 -0
  389. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts.map +1 -1
  390. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +5 -0
  391. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js.map +1 -1
  392. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +44 -9
  393. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
  394. package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +2 -0
  395. package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts.map +1 -1
  396. package/node_modules/@earendil-works/pi-ai/dist/auth/types.js.map +1 -1
  397. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.d.ts.map +1 -1
  398. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js +2 -0
  399. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js.map +1 -1
  400. package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
  401. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +2 -0
  402. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
  403. package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.d.ts +15 -0
  404. package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.d.ts.map +1 -0
  405. package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.js +32 -0
  406. package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.js.map +1 -0
  407. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  408. package/node_modules/@earendil-works/pi-ai/dist/providers/data/alibaba-token-plan.json +1 -1
  409. package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  410. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  411. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  412. package/node_modules/@earendil-works/pi-ai/dist/providers/data/deepseek.json +1 -1
  413. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  414. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  415. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  416. package/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
  417. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  418. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  419. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  420. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  421. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  422. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  423. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  424. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  425. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  426. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  427. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +14 -3
  428. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  429. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  430. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  431. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +2 -0
  432. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
  433. package/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.d.ts +2 -0
  434. package/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.d.ts.map +1 -0
  435. package/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.js +12 -0
  436. package/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.js.map +1 -0
  437. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
  438. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js +3 -2
  439. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js.map +1 -1
  440. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
  441. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -0
  442. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
  443. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts.map +1 -1
  444. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js +34 -0
  445. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js.map +1 -1
  446. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  447. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  448. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  449. package/node_modules/@earendil-works/pi-tui/README.md +1 -1
  450. package/node_modules/@earendil-works/pi-tui/dist/alt-screen-search.d.ts +26 -0
  451. package/node_modules/@earendil-works/pi-tui/dist/alt-screen-search.d.ts.map +1 -0
  452. package/node_modules/@earendil-works/pi-tui/dist/alt-screen-search.js +121 -0
  453. package/node_modules/@earendil-works/pi-tui/dist/alt-screen-search.js.map +1 -0
  454. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts +6 -1
  455. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts.map +1 -1
  456. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js +23 -7
  457. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js.map +1 -1
  458. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +4 -1
  459. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  460. package/node_modules/@earendil-works/pi-tui/dist/index.js +7 -1
  461. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  462. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +30 -0
  463. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  464. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +24 -0
  465. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  466. package/node_modules/@earendil-works/pi-tui/dist/layout.d.ts.map +1 -1
  467. package/node_modules/@earendil-works/pi-tui/dist/layout.js +9 -2
  468. package/node_modules/@earendil-works/pi-tui/dist/layout.js.map +1 -1
  469. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +8 -2
  470. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
  471. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +6 -2
  472. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -1
  473. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +6 -0
  474. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  475. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +18 -1
  476. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  477. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +21 -0
  478. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
  479. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +243 -5
  480. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
  481. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +2 -0
  482. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  483. package/node_modules/@earendil-works/pi-tui/dist/tui.js +33 -8
  484. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  485. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  486. package/package.json +7 -7
  487. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search.d.ts +0 -19
  488. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search.d.ts.map +0 -1
  489. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search.js +0 -41
  490. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search.js.map +0 -1
@@ -10,17 +10,21 @@ import type { OpenAICompletionsOptions } from "./api/openai-completions.ts";
10
10
  import type { OpenAIResponsesOptions } from "./api/openai-responses.ts";
11
11
  import type { PiMessagesOptions } from "./api/pi-messages.ts";
12
12
  import type { Model } from "./model.ts";
13
- import type { SessionAffinityFormat } from "./openai-responses-compat.ts";
13
+ import type { OpenAIResponsesCompat as BaseOpenAIResponsesCompat, SessionAffinityFormat } from "./openai-responses-compat.ts";
14
14
  import type { AssistantMessageDiagnostic } from "./utils/diagnostics.ts";
15
15
  import type { AssistantMessageEventStream } from "./utils/event-stream.ts";
16
16
  export type { Model } from "./model.ts";
17
- export type { OpenAIResponsesCompat, SessionAffinityFormat } from "./openai-responses-compat.ts";
17
+ export type { SessionAffinityFormat } from "./openai-responses-compat.ts";
18
+ export type OpenAIResponsesCompat = BaseOpenAIResponsesCompat & {
19
+ /** Whether the model supports message-anchored `additional_tools` input items. Default: false. */
20
+ supportsAdditionalTools?: boolean;
21
+ };
18
22
  export type { AssistantMessageEventStream } from "./utils/event-stream.ts";
19
23
  export type KnownApi = "openai-completions" | "mistral-conversations" | "openai-responses" | "azure-openai-responses" | "openai-codex-responses" | "anthropic-messages" | "bedrock-converse-stream" | "google-generative-ai" | "google-vertex" | "pi-messages";
20
24
  export type Api = KnownApi | (string & {});
21
25
  export type KnownImagesApi = "openrouter-images" | "openai-images";
22
26
  export type ImagesApi = KnownImagesApi | (string & {});
23
- export type KnownProvider = "alibaba-token-plan" | "amazon-bedrock" | "ant-ling" | "anthropic" | "google" | "google-vertex" | "openai" | "azure-openai-responses" | "openai-codex" | "ollama" | "radius" | "nvidia" | "deepseek" | "github-copilot" | "xai" | "groq" | "cerebras" | "openrouter" | "vercel-ai-gateway" | "opengateway" | "zai" | "zai-coding-cn" | "mistral" | "minimax" | "minimax-cn" | "moonshotai" | "moonshotai-cn" | "huggingface" | "fireworks" | "together" | "baseten" | "opencode" | "opencode-go" | "kimi-coding" | "cloudflare-workers-ai" | "cloudflare-ai-gateway" | "qwen-token-plan" | "qwen-token-plan-cn" | "qwen-token-plan-individual" | "xiaomi" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-sgp";
27
+ export type KnownProvider = "alibaba-token-plan" | "amazon-bedrock" | "ant-ling" | "anthropic" | "google" | "google-vertex" | "openai" | "azure-openai-responses" | "openai-codex" | "ollama" | "cursor" | "radius" | "nvidia" | "deepseek" | "github-copilot" | "xai" | "groq" | "cerebras" | "openrouter" | "vercel-ai-gateway" | "opengateway" | "zai" | "zai-coding-cn" | "mistral" | "minimax" | "minimax-cn" | "moonshotai" | "moonshotai-cn" | "huggingface" | "fireworks" | "together" | "baseten" | "opencode" | "opencode-go" | "kimi-coding" | "cloudflare-workers-ai" | "cloudflare-ai-gateway" | "qwen-token-plan" | "qwen-token-plan-cn" | "qwen-token-plan-individual" | "xiaomi" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-sgp";
24
28
  export type ProviderId = KnownProvider | string;
25
29
  export type KnownImagesProvider = "openrouter";
26
30
  export type ImagesProviderId = KnownImagesProvider | string;
@@ -290,6 +294,8 @@ export interface ToolCall {
290
294
  /** Error explaining why an incomplete tool call could not be recovered. */
291
295
  errorMessage?: string;
292
296
  thoughtSignature?: string;
297
+ /** OpenAI Responses namespace for calls to dynamically loaded or namespaced tools. */
298
+ namespace?: string;
293
299
  }
294
300
  /**
295
301
  * Provider-emitted content block whose semantics are owned by the originating
@@ -377,6 +383,11 @@ export interface AssistantMessage {
377
383
  deferred?: DeferredHandle;
378
384
  errorMessage?: string;
379
385
  rawStopReason?: string;
386
+ /**
387
+ * Provider indication of whether the model explicitly ended its turn.
388
+ * Preserved for debugging and does not currently affect agent control flow.
389
+ */
390
+ endTurn?: boolean;
380
391
  timestamp: number;
381
392
  }
382
393
  export interface ToolResultMessage<TDetails = any> {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2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C,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;IACpD,mFAAmF;IACnF,gBAAgB,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,SAAU,SAAQ,cAAc;IAChD,oGAAoG;IACpG,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,WAAW,CAAC,IAAI,SAAS,SAAS,CAClD,SAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,WAAW,GAAG,eAAe,GAAG,WAAW,GAAG,QAAQ,CAAC;IACrG,GAAG,EAAE,IAAI,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,MAAM,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;CAC7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAkZA,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import type { TelemetryContext } from \"@earendil-works/pi-telemetry\";\nimport type { AnthropicOptions } from \"./api/anthropic-messages.ts\";\nimport type { AzureOpenAIResponsesOptions } from \"./api/azure-openai-responses.ts\";\nimport type { BedrockOptions } from \"./api/bedrock-converse-stream.ts\";\nimport type { GoogleOptions } from \"./api/google-generative-ai.ts\";\nimport type { GoogleVertexOptions } from \"./api/google-vertex.ts\";\nimport type { MistralOptions } from \"./api/mistral-conversations.ts\";\nimport type { OpenAICodexResponsesOptions } from \"./api/openai-codex-responses.ts\";\nimport type { OpenAICompletionsOptions } from \"./api/openai-completions.ts\";\nimport type { OpenAIResponsesOptions } from \"./api/openai-responses.ts\";\nimport type { PiMessagesOptions } from \"./api/pi-messages.ts\";\nimport type { Model } from \"./model.ts\";\nimport type { SessionAffinityFormat } from \"./openai-responses-compat.ts\";\nimport type { AssistantMessageDiagnostic } from \"./utils/diagnostics.ts\";\nimport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type { Model } from \"./model.ts\";\nexport type { OpenAIResponsesCompat, SessionAffinityFormat } from \"./openai-responses-compat.ts\";\nexport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type KnownApi =\n\t| \"openai-completions\"\n\t| \"mistral-conversations\"\n\t| \"openai-responses\"\n\t| \"azure-openai-responses\"\n\t| \"openai-codex-responses\"\n\t| \"anthropic-messages\"\n\t| \"bedrock-converse-stream\"\n\t| \"google-generative-ai\"\n\t| \"google-vertex\"\n\t| \"pi-messages\";\n\nexport type Api = KnownApi | (string & {});\n\nexport type KnownImagesApi = \"openrouter-images\" | \"openai-images\";\n\nexport type ImagesApi = KnownImagesApi | (string & {});\n\nexport type KnownProvider =\n\t| \"alibaba-token-plan\"\n\t| \"amazon-bedrock\"\n\t| \"ant-ling\"\n\t| \"anthropic\"\n\t| \"google\"\n\t| \"google-vertex\"\n\t| \"openai\"\n\t| \"azure-openai-responses\"\n\t| \"openai-codex\"\n\t| \"ollama\"\n\t| \"radius\"\n\t| \"nvidia\"\n\t| \"deepseek\"\n\t| \"github-copilot\"\n\t| \"xai\"\n\t| \"groq\"\n\t| \"cerebras\"\n\t| \"openrouter\"\n\t| \"vercel-ai-gateway\"\n\t| \"opengateway\"\n\t| \"zai\"\n\t| \"zai-coding-cn\"\n\t| \"mistral\"\n\t| \"minimax\"\n\t| \"minimax-cn\"\n\t| \"moonshotai\"\n\t| \"moonshotai-cn\"\n\t| \"huggingface\"\n\t| \"fireworks\"\n\t| \"together\"\n\t| \"baseten\"\n\t| \"opencode\"\n\t| \"opencode-go\"\n\t| \"kimi-coding\"\n\t| \"cloudflare-workers-ai\"\n\t| \"cloudflare-ai-gateway\"\n\t| \"qwen-token-plan\"\n\t| \"qwen-token-plan-cn\"\n\t| \"qwen-token-plan-individual\"\n\t| \"xiaomi\"\n\t| \"xiaomi-token-plan-cn\"\n\t| \"xiaomi-token-plan-ams\"\n\t| \"xiaomi-token-plan-sgp\";\nexport type ProviderId = KnownProvider | string;\n\nexport type KnownImagesProvider = \"openrouter\";\n\nexport type ImagesProviderId = KnownImagesProvider | string;\n\nexport type ThinkingLevel = \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\";\nexport type ModelThinkingLevel = \"off\" | ThinkingLevel;\nexport type ThinkingLevelMap = Partial<Record<ModelThinkingLevel, string | null>>;\nexport type ChatTemplateKwargValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| {\n\t\t\t$var: \"thinking.enabled\" | \"thinking.effort\";\n\t\t\tomitWhenOff?: boolean;\n\t };\n\n/** Token budgets for each thinking level (token-based providers only) */\nexport interface ThinkingBudgets {\n\tminimal?: number;\n\tlow?: number;\n\tmedium?: number;\n\thigh?: number;\n\tmax?: number;\n}\n\n// Base options all providers share\nexport type CacheRetention = \"none\" | \"short\" | \"long\";\n\nexport type Transport = \"sse\" | \"websocket\" | \"websocket-cached\" | \"auto\";\n\n/** Provider-scoped environment overrides. Values take precedence over process.env. */\nexport type ProviderEnv = Record<string, string>;\nexport type ProviderHeaders = Record<string, string | null>;\n/** Effective model and fully transformed headers for a request payload hook. */\nexport type ProviderRequestMetadata = {\n\tmodel: Model<Api>;\n\theaders: ProviderHeaders;\n};\nexport type FetchFunction = typeof globalThis.fetch;\n\nexport interface ProviderResponse {\n\tstatus: number;\n\theaders: Record<string, string>;\n}\n\n/** Authentication, HTTP transport, and lifecycle callbacks shared by provider requests. */\nexport interface ProviderRequestOptions<TModel = Model<Api>> {\n\tsignal?: AbortSignal;\n\t/**\n\t * Abort the request when the provider reports that a safety classifier\n\t * declined the requested model and a substitute model served the turn\n\t * instead (Anthropic `server-side-fallback-*` betas). The substitute's output\n\t * is billed but was never requested, so aborting keeps model selection with\n\t * the caller. Providers without server-side fallback ignore this.\n\t * Default: undefined (honor the substituted response).\n\t */\n\tabortServerSideFallback?: boolean;\n\t/** Explicit parent context for telemetry produced by this logical request. */\n\ttelemetryContext?: TelemetryContext;\n\tapiKey?: string;\n\t/**\n\t * Stable identity of the originating session for account-affinity providers,\n\t * preserved across auxiliary calls that replace `sessionId` (for example\n\t * compaction). Providers without account affinity ignore this.\n\t */\n\taffinitySessionId?: string;\n\t/**\n\t * Identifies whether the stream belongs to the main agent loop or an auxiliary request.\n\t * An absent value must be treated as auxiliary as a fail-safe.\n\t */\n\tstreamKind?: \"main\" | \"auxiliary\";\n\t/**\n\t * Optional fetch implementation for provider HTTP requests.\n\t * Defaults to `globalThis.fetch`. Provider adapters that cannot inject a custom implementation may reject it.\n\t * This does not affect WebSocket transports.\n\t */\n\tfetch?: FetchFunction;\n\t/**\n\t * Provider-scoped environment values. These take precedence over process.env for\n\t * provider configuration such as regional settings, endpoint placeholders, and\n\t * proxy variables.\n\t */\n\tenv?: ProviderEnv;\n\t/**\n\t * Optional callback for inspecting or replacing provider payloads before sending.\n\t * Return undefined to keep the payload unchanged.\n\t */\n\tonPayload?: (\n\t\tpayload: unknown,\n\t\tmodel: TModel,\n\t\trequest?: ProviderRequestMetadata,\n\t) => unknown | undefined | Promise<unknown | undefined>;\n\t/**\n\t * Optional callback invoked after an HTTP response is received.\n\t */\n\tonResponse?: (response: ProviderResponse, model: TModel) => void | Promise<void>;\n\t/**\n\t * Optional custom HTTP headers to include in API requests.\n\t * Merged with provider defaults; caller values override default headers.\n\t * On AWS Bedrock these are injected via a Smithy `build`-step middleware so\n\t * they are covered by SigV4 signing; reserved headers (`x-amz-*`,\n\t * `authorization`, `host`) are silently ignored to preserve SigV4 / bearer auth.\n\t * A null value suppresses a provider/API default header with the same name.\n\t */\n\theaders?: ProviderHeaders;\n\t/**\n\t * HTTP request timeout in milliseconds for providers/SDKs that support it.\n\t * For example, OpenAI and Anthropic SDK clients default to 10 minutes.\n\t */\n\ttimeoutMs?: number;\n\t/**\n\t * Maximum retry attempts for providers/SDKs that support client-side retries.\n\t * For example, OpenAI and Anthropic SDK clients default to 2.\n\t */\n\tmaxRetries?: number;\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately\n\t * with an error containing the requested delay, allowing higher-level retry logic\n\t * to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n}\n\nexport interface StreamOptions extends ProviderRequestOptions<Model<Api>> {\n\ttemperature?: number;\n\t/**\n\t * Arbitrary sampling parameters merged into the request body as-is, after the named request\n\t * fields, so keys here override them. Lets custom OpenAI-compatible servers (llama.cpp, vLLM,\n\t * SGLang, ...) receive parameters pi does not model, e.g. `top_p`, `top_k`, `min_p`,\n\t * `repetition_penalty`. Merged over `Model.samplingParams` per key. Only applied by\n\t * OpenAI-compatible adapters (completions, responses, Azure responses); other APIs ignore it.\n\t */\n\tsamplingParams?: Record<string, unknown>;\n\tmaxTokens?: number;\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t * Providers that do not support this option ignore it.\n\t */\n\ttransport?: Transport;\n\t/**\n\t * Prompt cache retention preference. Providers map this to their supported values.\n\t * Default: \"short\".\n\t */\n\tcacheRetention?: CacheRetention;\n\t/**\n\t * Optional session identifier for providers that support session-based caching.\n\t * Providers can use this to enable prompt caching, request routing, or other\n\t * session-aware features. Ignored by providers that don't support it.\n\t */\n\tsessionId?: string;\n\t/**\n\t * Optional custom fields to merge into the outgoing provider request body.\n\t * Applied before `onPayload` so `onPayload` can observe/override them.\n\t * Provider-managed fields (e.g. `model`, `messages`, `stream`) are preserved\n\t * and cannot be overridden to avoid breaking core request semantics.\n\t */\n\textraBody?: Record<string, unknown>;\n\t/**\n\t * WebSocket connect timeout in milliseconds for providers that support\n\t * WebSocket transports. This covers the connection/open handshake only;\n\t * stream idleness after connection uses timeoutMs.\n\t */\n\twebsocketConnectTimeoutMs?: number;\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t * For example, Anthropic uses `user_id` for abuse tracking and rate limiting.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderStreamOptions = StreamOptions & Record<string, unknown>;\n\nexport interface DeferredFetchOptions extends ProviderRequestOptions<Model<Api>> {\n\t/**\n\t * Maximum provider long-poll duration in milliseconds.\n\t * Defaults to 0, which performs one status check.\n\t */\n\twait?: number;\n}\n\n/** Request options for best-effort deferred-response cancellation. */\nexport type DeferredCancelOptions = ProviderRequestOptions<Model<Api>>;\n\n/**\n * Maps known APIs to their full provider-specific stream option types.\n * Type-only imports from API implementation modules are erased at emit, so\n * this is tree-shake safe.\n */\nexport interface ApiOptionsMap {\n\t\"anthropic-messages\": AnthropicOptions;\n\t\"openai-completions\": OpenAICompletionsOptions;\n\t\"openai-responses\": OpenAIResponsesOptions;\n\t\"openai-codex-responses\": OpenAICodexResponsesOptions;\n\t\"azure-openai-responses\": AzureOpenAIResponsesOptions;\n\t\"google-generative-ai\": GoogleOptions;\n\t\"google-vertex\": GoogleVertexOptions;\n\t\"mistral-conversations\": MistralOptions;\n\t\"bedrock-converse-stream\": BedrockOptions;\n\t\"pi-messages\": PiMessagesOptions;\n}\n\n/**\n * Full stream options for an API. Known APIs resolve to their concrete option\n * type; custom API strings fall back to the generic shape.\n */\nexport type ApiStreamOptions<TApi extends Api> = TApi extends keyof ApiOptionsMap\n\t? ApiOptionsMap[TApi]\n\t: StreamOptions & Record<string, unknown>;\n\n/**\n * The uniform stream contract of an API implementation module: every module\n * under `src/api/` exports `stream` and `streamSimple`; capable modules may also\n * export deferred-response methods. Lazy wrappers (`lazyApi()`) and provider\n * factories pass these around as values. This is the untyped dispatch shape;\n * per-API option typing lives on the implementation modules themselves and on\n * `Provider.stream()` via `ApiStreamOptions`.\n */\nexport interface ProviderStreams {\n\tstream(model: Model<Api>, context: Context, options?: StreamOptions): AssistantMessageEventStream;\n\tstreamSimple(model: Model<Api>, context: Context, options?: SimpleStreamOptions): AssistantMessageEventStream;\n\tfetchDeferred?(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: DeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tcancelDeferred?(model: Model<Api>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;\n}\n\n/**\n * The uniform contract of an image-generation API implementation module:\n * every image API module under `src/api/` exports exactly `generateImages`,\n * so the module itself satisfies this interface. Lazy wrappers and image\n * provider factories pass these around as values.\n */\nexport interface ProviderImages {\n\tgenerateImages(\n\t\tmodel: ImagesModel<ImagesApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ImagesOptions,\n\t): Promise<AssistantImages>;\n}\n\nexport interface ImagesOptions extends ProviderRequestOptions<ImagesModel<ImagesApi>> {\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderImagesOptions = ImagesOptions & Record<string, unknown>;\n\n// Unified options with reasoning passed to streamSimple() and completeSimple()\nexport interface SimpleStreamOptions extends StreamOptions {\n\treasoning?: ThinkingLevel;\n\t/** Ask a capable provider to return a durable handle and continue the request asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n\t/** Custom token budgets for thinking levels (token-based providers only) */\n\tthinkingBudgets?: ThinkingBudgets;\n}\n\n// Generic StreamFunction with typed options.\n//\n// Contract:\n// - Must return an AssistantMessageEventStream.\n// - Once invoked, request/model/runtime failures should be encoded in the\n// returned stream, not thrown.\n// - Error termination must produce an AssistantMessage with stopReason\n// \"error\" or \"aborted\" and errorMessage, emitted via the stream protocol.\nexport type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: TOptions,\n) => AssistantMessageEventStream;\n\nexport type ImagesFunction<TApi extends ImagesApi = ImagesApi, TOptions extends ImagesOptions = ImagesOptions> = (\n\tmodel: ImagesModel<TApi>,\n\tcontext: ImagesContext,\n\toptions?: TOptions,\n) => Promise<AssistantImages>;\n\nexport interface TextSignatureV1 {\n\tv: 1;\n\tid: string;\n\tphase?: \"commentary\" | \"final_answer\";\n}\n\nexport interface TextContent {\n\ttype: \"text\";\n\ttext: string;\n\ttextSignature?: string; // e.g., for OpenAI responses, message metadata (legacy id string or TextSignatureV1 JSON)\n}\n\nexport interface ThinkingContent {\n\ttype: \"thinking\";\n\tthinking: string;\n\t/** Epoch ms, stamped by the agent loop at stream-event receipt, best-effort. */\n\tstartedAt?: number;\n\t/** Epoch ms, stamped by the agent loop at stream-event receipt, best-effort. */\n\tendedAt?: number;\n\tthinkingSignature?: string; // e.g., for OpenAI responses, the reasoning item ID\n\t/** When true, the thinking content was redacted by safety filters. The opaque\n\t * encrypted payload is stored in `thinkingSignature` so it can be passed back\n\t * to the API for multi-turn continuity. */\n\tredacted?: boolean;\n}\n\nexport interface ImageContent {\n\ttype: \"image\";\n\tdata: string; // base64 encoded image data\n\tmimeType: string; // e.g., \"image/jpeg\", \"image/png\". Video payloads (e.g. \"video/mp4\") ride this\n\t// same block for models that declare the \"video\" input modality; use isVideoMimeType() to branch.\n}\n\n/** True when an ImageContent block actually carries video data (e.g. \"video/mp4\"). */\nexport function isVideoMimeType(mimeType: string): boolean {\n\treturn mimeType.toLowerCase().startsWith(\"video/\");\n}\n\nexport interface ToolCall {\n\ttype: \"toolCall\";\n\tid: string;\n\tname: string;\n\targuments: Record<string, any>;\n\t/** Set by text tool-call middleware when a truncated call could not be recovered. Carriers of `incomplete` MUST NOT be executed. */\n\tincomplete?: true;\n\t/** Error explaining why an incomplete tool call could not be recovered. */\n\terrorMessage?: string;\n\tthoughtSignature?: string; // Google-specific: opaque signature for reusing thought context\n}\n\n/**\n * Provider-emitted content block whose semantics are owned by the originating\n * provider. Surfaces server-side tool invocations (web_search), server-side\n * tool results (web_search_tool_result), code execution traces, grounding\n * metadata fragments, and any other vendor-specific block the core does not\n * normalize.\n *\n * `subtype` mirrors the provider's wire `type` discriminator (e.g.\n * \"server_tool_use\", \"web_search_tool_result\", \"executableCode\"). `raw` is\n * the verbatim wire payload — extensions interpret it per provider+subtype.\n *\n * The owning provider id lives on the parent `AssistantMessage.provider`, not\n * here, to avoid drift on replay.\n *\n * On replay across providers, `convertMessages` implementations MUST drop\n * these blocks (they are not portable). This mirrors the existing\n * `redacted_thinking` skip pattern.\n */\nexport interface ProviderNativeContent {\n\ttype: \"providerNative\";\n\tsubtype: string;\n\traw: unknown;\n}\n\nexport interface Usage {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\t/** Subset of `cacheWrite` written with 1h retention. Only Anthropic reports this split. */\n\tcacheWrite1h?: number;\n\t/**\n\t * Reasoning/thinking tokens, when the provider reports them. This is a subset of\n\t * `output`: `output` already includes these tokens. Set to a number (possibly 0) by\n\t * providers that expose a reasoning breakdown; left undefined by providers that don't.\n\t */\n\treasoning?: number;\n\ttotalTokens: number;\n\tcost: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n}\n\nexport type StopReason = \"pending\" | \"stop\" | \"length\" | \"toolUse\" | \"error\" | \"aborted\" | \"deferred\";\n\nexport type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };\n\nexport interface DeferredHandle {\n\tprovider: string;\n\tmodelId: string;\n\tapi: string;\n\t/** Provider token, such as a response id or batch id plus row id. */\n\tid: string;\n\texpiresAt?: number;\n\tpollAfterMs?: number;\n\t/** Provider conversion data required to reconstruct the final assistant message. */\n\tdata?: JsonValue;\n}\n\nexport type AssistantStopDetails = { type: \"refusal\"; explanation?: string } | { type: \"sensitive\" };\n\nexport interface UserMessage {\n\trole: \"user\";\n\tcontent: string | (TextContent | ImageContent)[];\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface AssistantMessage {\n\trole: \"assistant\";\n\tcontent: (TextContent | ThinkingContent | ToolCall | ProviderNativeContent)[];\n\tapi: Api;\n\tprovider: ProviderId;\n\tmodel: string;\n\tresponseModel?: string; // Concrete `chunk.model` when different from the requested `model` (e.g. OpenRouter `auto` -> `anthropic/...`)\n\tresponseId?: string; // Provider-specific response/message identifier when the upstream API exposes one\n\tdiagnostics?: AssistantMessageDiagnostic[]; // Redacted provider/runtime diagnostics for failures and recoveries.\n\tusage: Usage;\n\tstopReason: StopReason;\n\tstopDetails?: AssistantStopDetails;\n\tdeferred?: DeferredHandle;\n\terrorMessage?: string;\n\trawStopReason?: string;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface ToolResultMessage<TDetails = any> {\n\trole: \"toolResult\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tcontent: (TextContent | ImageContent)[]; // Supports text and images\n\tdetails?: TDetails;\n\t/** Usage from the tool execution itself, if available. Not part of main LLM context accounting. */\n\tusage?: Usage;\n\t/**\n\t * Names from `Context.tools` that became available after this result.\n\t * Providers with native deferred tool loading use this as the load point;\n\t * other providers ignore it and use `Context.tools` normally.\n\t */\n\taddedToolNames?: string[];\n\tisError: boolean;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport type Message = UserMessage | AssistantMessage | ToolResultMessage;\n\nexport type ImagesInputContent = TextContent | ImageContent;\nexport type ImagesOutputContent = TextContent | ImageContent;\n\nexport interface ImagesContext {\n\tinput: ImagesInputContent[];\n}\n\nexport type ImagesStopReason = \"stop\" | \"error\" | \"aborted\";\n\nexport interface AssistantImages {\n\tapi: ImagesApi;\n\tprovider: ImagesProviderId;\n\tmodel: string;\n\toutput: ImagesOutputContent[];\n\tresponseId?: string;\n\tusage?: Usage;\n\tstopReason: ImagesStopReason;\n\terrorMessage?: string;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nimport type { TSchema } from \"typebox\";\n\nexport interface FreeformToolFormat {\n\ttype: \"grammar\";\n\tsyntax: \"lark\";\n\tdefinition: string;\n}\n\n/** OpenAI grammar variants for constrained sampling. */\nexport type GrammarFormat = \"openai_lark\" | \"openai_regex\";\n\nexport type GrammarVariants = Partial<Record<GrammarFormat, string>>;\n\n/**\n * Optional provider-side constrained sampling configs for a tool.\n *\n * The `json_schema` value roughly maps to the concept of `strict` in APIs which is\n * implemented as json-schema constrained sampling by APIs. Grammar variants let\n * callers provide provider-specific encodings of the same intended language.\n */\nexport type ConstrainedSamplingConfig =\n\t| {\n\t\t\ttype: \"json_schema\";\n\t\t\tstrict: \"prefer\" | \"require\";\n\t }\n\t| {\n\t\t\ttype: \"grammar\";\n\t\t\tvariants: GrammarVariants;\n\t };\nexport interface Tool<TParameters extends TSchema = TSchema> {\n\tname: string;\n\tdescription: string;\n\tparameters: TParameters;\n\tfreeform?: FreeformToolFormat;\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n}\n\nexport interface Context {\n\tsystemPrompt?: string;\n\tmessages: Message[];\n\ttools?: Tool[];\n}\n\n/**\n * Event protocol for AssistantMessageEventStream.\n *\n * Streams should emit `start` before partial updates, then terminate with either:\n * - `done` carrying the final successful AssistantMessage, or\n * - `error` carrying the final AssistantMessage with stopReason \"error\" or \"aborted\"\n * and errorMessage.\n */\nexport type AssistantMessageEvent =\n\t| { type: \"start\"; partial: AssistantMessage }\n\t| { type: \"text_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"text_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"text_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"thinking_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"thinking_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"thinking_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"toolcall_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"toolcall_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t/** Finalized - executable iff `incomplete !== true` on `toolCall`. */\n\t| { type: \"toolcall_end\"; contentIndex: number; toolCall: ToolCall; partial: AssistantMessage }\n\t| {\n\t\t\ttype: \"done\";\n\t\t\treason: Extract<StopReason, \"stop\" | \"length\" | \"toolUse\" | \"deferred\">;\n\t\t\tmessage: AssistantMessage;\n\t }\n\t| { type: \"error\"; reason: Extract<StopReason, \"aborted\" | \"error\">; error: AssistantMessage };\n\n/**\n * Compatibility settings for OpenAI-compatible completions APIs.\n * Use this to override URL-based auto-detection for custom providers.\n */\nexport interface OpenAICompletionsCompat {\n\t/** Whether the provider supports the `store` field. Default: auto-detected from URL. */\n\tsupportsStore?: boolean;\n\t/** Whether the provider supports the `developer` role (vs `system`). Default: auto-detected from URL. */\n\tsupportsDeveloperRole?: boolean;\n\t/** Whether the provider supports `reasoning_effort`. Default: auto-detected from URL. */\n\tsupportsReasoningEffort?: boolean;\n\t/** Whether the provider supports `stream_options: { include_usage: true }` for token usage in streaming responses. Default: true. */\n\tsupportsUsageInStreaming?: boolean;\n\t/** Whether streamed responses include `finish_reason`. When false, pi infers `stop` or `toolUse` when the stream ends. Default: true. */\n\tsupportsFinishReason?: boolean;\n\t/** Which field to use for max tokens. Default: auto-detected from URL. */\n\tmaxTokensField?: \"max_completion_tokens\" | \"max_tokens\";\n\t/** Whether tool results require the `name` field. Default: auto-detected from URL. */\n\trequiresToolResultName?: boolean;\n\t/** Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. */\n\trequiresAssistantAfterToolResult?: boolean;\n\t/** Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL. */\n\trequiresThinkingAsText?: boolean;\n\t/** Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL. */\n\trequiresReasoningContentOnAssistantMessages?: boolean;\n\t/** Format for reasoning/thinking parameter. \"openai\" uses reasoning_effort, \"openrouter\" uses reasoning: { effort }, \"deepseek\" uses thinking: { type } plus reasoning_effort when supported, \"together\" uses reasoning: { enabled } plus reasoning_effort when supported, \"baseten\" uses configurable chat_template_args plus reasoning_effort when supported, \"zai\" uses thinking: { type }, \"qwen\" uses top-level enable_thinking: boolean, \"qwen-chat-template\" uses chat_template_kwargs.enable_thinking and preserve_thinking, \"chat-template\" uses configurable chat_template_kwargs, \"string-thinking\" uses top-level thinking: string, and \"ant-ling\" uses reasoning: { effort } only when the mapped effort is non-null. Default: \"openai\". */\n\tthinkingFormat?:\n\t\t| \"openai\"\n\t\t| \"openrouter\"\n\t\t| \"deepseek\"\n\t\t| \"together\"\n\t\t| \"baseten\"\n\t\t| \"zai\"\n\t\t| \"qwen\"\n\t\t| \"chat-template\"\n\t\t| \"qwen-chat-template\"\n\t\t| \"string-thinking\"\n\t\t| \"ant-ling\";\n\t/** Whether the provider accepts explicit disabled-thinking markers when thinking is off. Default: true. */\n\tsupportsDisabledThinking?: boolean;\n\t/** Kwargs to send as `chat_template_kwargs` when `thinkingFormat` is `chat-template`. Use `{ \"$var\": \"thinking.enabled\" }` or `{ \"$var\": \"thinking.effort\" }` for pi-controlled thinking values. */\n\tchatTemplateKwargs?: Record<string, ChatTemplateKwargValue>;\n\t/** Arguments to send as `chat_template_args` when `thinkingFormat` is `baseten`. Use `{ \"$var\": \"thinking.enabled\" }` or `{ \"$var\": \"thinking.effort\" }` for pi-controlled thinking values. */\n\tchatTemplateArgs?: Record<string, ChatTemplateKwargValue>;\n\t/** OpenRouter-compatible routing preferences sent as the `provider` request field. */\n\topenRouterRouting?: OpenRouterRouting;\n\t/** Vercel AI Gateway routing preferences. Only used when baseUrl points to Vercel AI Gateway. */\n\tvercelGatewayRouting?: VercelGatewayRouting;\n\t/** Whether z.ai supports top-level `tool_stream: true` for streaming tool call deltas. Default: false. */\n\tzaiToolStream?: boolean;\n\t/** Whether the provider supports top-level `thinking_token_budget` to cap reasoning tokens (vLLM). Reasoning and the answer share `max_tokens` on these endpoints, so without a budget a reasoning-heavy turn can consume the whole response and emit no answer. Default: false. */\n\tsupportsThinkingTokenBudget?: boolean;\n\t/** Whether the provider supports OpenAI custom tools with Lark/regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. Default: false; the generated model catalog enables it for capable models. */\n\tsupportsOpenAIGrammarTools?: boolean;\n\t/** Whether the provider supports the `strict` field in tool definitions. Default: true. */\n\tsupportsStrictMode?: boolean;\n\t/**\n\t * Provider-specific JSON Schema flavor for tool parameters. `\"moonshot-mfjs\"`\n\t * normalizes schemas for Moonshot / Kimi backends that enforce a stricter subset.\n\t */\n\ttoolSchemaFlavor?: \"moonshot-mfjs\";\n\t/**\n\t * Tool call format for models that don't natively support tool calling.\n\t * When set, the middleware will intercept tool calls and format them as text.\n\t * Supported values: \"hermes\", \"morph-xml\", \"xml\" (deprecated alias for \"morph-xml\"), \"yaml-xml\", \"gemma4-delimiter\", \"anthropic-xml\", \"antml\", \"kimi-xtml\"\n\t */\n\ttoolCallFormat?: string;\n\t/** Cache control convention for prompt caching. \"anthropic\" applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content. */\n\tcacheControlFormat?: \"anthropic\";\n\t/** Whether to send session-affinity data from `options.sessionId`. Default: false. */\n\tsendSessionAffinityHeaders?: boolean;\n\t/** Provider-specific deferred tool serialization mode. */\n\tdeferredToolsMode?: \"kimi\";\n\t/** Session-affinity header format: `openai` sends `session_id`, `x-client-request-id`, and `x-session-affinity`; `openai-nosession` sends `x-client-request-id` and `x-session-affinity`; `openrouter` sends `x-session-id`. Does not affect the `prompt_cache_key` body param, which is governed by cache retention. Default: auto-detected. */\n\tsessionAffinityFormat?: SessionAffinityFormat;\n\t/** Whether the provider accepts the `prompt_cache_key` request field. Default: auto-detected. */\n\tsupportsPromptCacheKey?: boolean;\n\t/** Whether the provider supports long prompt cache retention (`prompt_cache_retention: \"24h\"` or Anthropic-style `cache_control.ttl: \"1h\"`, depending on format). Default: true. */\n\tsupportsLongCacheRetention?: boolean;\n}\n\n/** Compatibility settings for Anthropic Messages-compatible APIs. */\nexport interface AnthropicMessagesCompat {\n\t/**\n\t * Whether the provider accepts per-tool `eager_input_streaming`.\n\t * When false, the Anthropic provider omits `tools[].eager_input_streaming`\n\t * and sends the legacy `fine-grained-tool-streaming-2025-05-14` beta header\n\t * for tool-enabled requests.\n\t * Default: true.\n\t */\n\tsupportsEagerToolInputStreaming?: boolean;\n\t/** Whether the provider supports Anthropic long cache retention (`cache_control.ttl: \"1h\"`). Default: true. */\n\tsupportsLongCacheRetention?: boolean;\n\t/**\n\t * Whether to send the `x-session-affinity` header from `options.sessionId`\n\t * when caching is enabled. Required for providers like Fireworks that use\n\t * session affinity for prompt cache routing (requests to the same replica\n\t * maximize cache hits).\n\t * Default: false.\n\t */\n\tsendSessionAffinityHeaders?: boolean;\n\t/**\n\t * Whether the provider supports Anthropic-style `cache_control` markers on\n\t * tool definitions. When false, `cache_control` is omitted from tool params.\n\t * Some Anthropic-compatible providers (e.g., Fireworks) do not support this\n\t * field on tools and may reject or ignore it.\n\t * Default: true.\n\t */\n\tsupportsCacheControlOnTools?: boolean;\n\t/**\n\t * Whether the provider accepts `thinking: { type: \"disabled\" }` when\n\t * extended thinking is off. Some Anthropic-compatible providers support\n\t * thinking but reject Anthropic's explicit disabled marker.\n\t * Default: true.\n\t */\n\tsupportsDisabledThinking?: boolean;\n\t/**\n\t * Whether the model accepts the Anthropic `temperature` request field.\n\t * Claude Opus 4.7+ rejects non-default temperature values.\n\t * Default: true.\n\t */\n\tsupportsTemperature?: boolean;\n\t/** Whether the model accepts Anthropic `tool_choice`. Default: true. */\n\tsupportsToolChoice?: boolean;\n\t/**\n\t * Whether the model accepts forced Anthropic tool choices (`any` or a named\n\t * tool). Default: true, except Claude Fable/Mythos models.\n\t */\n\tsupportsForcedToolChoice?: boolean;\n\t/**\n\t * Whether to force adaptive thinking (`thinking.type: \"adaptive\"` plus\n\t * `output_config.effort`) regardless of the model id. Built-in models that\n\t * require adaptive thinking set this in generated metadata. Custom\n\t * Anthropic-compatible providers can set this to `true` for any model whose\n\t * upstream requires the adaptive format. Set to `false` to opt out on\n\t * overridden built-in models and disable model id/name inference.\n\t * Default: infer from adaptive Claude model ids/names when possible.\n\t */\n\tforceAdaptiveThinking?: boolean;\n\t/** Whether to replay empty thinking signatures as `signature: \"\"` instead of converting thinking to text. Default: false. */\n\tallowEmptySignature?: boolean;\n\t/** Whether the provider supports Anthropic strict tool schemas. Default: false; generated Anthropic models enable it explicitly. */\n\tsupportsStrictTools?: boolean;\n\t/**\n\t * How to replay thinking blocks that have no usable Anthropic signature.\n\t * `\"text\"` demotes them to text; `\"empty-signature\"` preserves Anthropic's\n\t * thinking shape with `signature: \"\"`. Defaults to `\"text\"`; the legacy\n\t * `allowEmptySignature` setting remains a compatibility alias for\n\t * `\"empty-signature\"`.\n\t */\n\tunsignedThinkingReplay?: \"text\" | \"empty-signature\";\n\t/**\n\t * Whether the provider supports deferred tools loaded by `tool_reference`\n\t * blocks in tool results. Default: true for first-party Anthropic models\n\t * except Haiku and models older than Claude 4.5; false for other providers.\n\t */\n\tsupportsToolReferences?: boolean;\n\t/**\n\t * Whether the provider executes Anthropic server-side `web_search_*` native\n\t * tools and accepts their `server_tool_use` / `web_search_tool_result`\n\t * blocks on replay. Anthropic-compatible endpoints (e.g., kimi-coding) may\n\t * run the search but reject the replayed server-tool blocks on the next\n\t * request. When false, hook-injected `web_search_*` tools are stripped from\n\t * the payload. Default: true only for the first-party Anthropic endpoint.\n\t */\n\tsupportsWebSearch?: boolean;\n}\n\n/** Compatibility settings for Amazon Bedrock models. */\nexport interface BedrockCompat {\n\t/** Whether the model supports Bedrock strict tool schemas. Default: false. */\n\tsupportsStrictMode?: boolean;\n}\n\n/**\n * OpenRouter provider routing preferences.\n * Controls which upstream providers OpenRouter routes requests to.\n * Sent as the `provider` field in the OpenRouter API request body.\n * @see https://openrouter.ai/docs/guides/routing/provider-selection\n */\nexport interface OpenRouterRouting {\n\t/** Whether to allow backup providers to serve requests. Default: true. */\n\tallow_fallbacks?: boolean;\n\t/** Whether to filter providers to only those that support all parameters in the request. Default: false. */\n\trequire_parameters?: boolean;\n\t/** Data collection setting. \"allow\" (default): allow providers that may store/train on data. \"deny\": only use providers that don't collect user data. */\n\tdata_collection?: \"deny\" | \"allow\";\n\t/** Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. */\n\tzdr?: boolean;\n\t/** Whether to restrict routing to only models that allow text distillation. */\n\tenforce_distillable_text?: boolean;\n\t/** An ordered list of provider names/slugs to try in sequence, falling back to the next if unavailable. */\n\torder?: string[];\n\t/** List of provider names/slugs to exclusively allow for this request. */\n\tonly?: string[];\n\t/** List of provider names/slugs to skip for this request. */\n\tignore?: string[];\n\t/** A list of quantization levels to filter providers by (e.g., [\"fp16\", \"bf16\", \"fp8\", \"fp6\", \"int8\", \"int4\", \"fp4\", \"fp32\"]). */\n\tquantizations?: string[];\n\t/** Sorting strategy. Can be a string (e.g., \"price\", \"throughput\", \"latency\") or an object with `by` and `partition`. */\n\tsort?:\n\t\t| string\n\t\t| {\n\t\t\t\t/** The sorting metric: \"price\", \"throughput\", \"latency\". */\n\t\t\t\tby?: string;\n\t\t\t\t/** Partitioning strategy: \"model\" (default) or \"none\". */\n\t\t\t\tpartition?: string | null;\n\t\t };\n\t/** Maximum price per million tokens (USD). */\n\tmax_price?: {\n\t\t/** Price per million prompt tokens. */\n\t\tprompt?: number | string;\n\t\t/** Price per million completion tokens. */\n\t\tcompletion?: number | string;\n\t\t/** Price per image. */\n\t\timage?: number | string;\n\t\t/** Price per audio unit. */\n\t\taudio?: number | string;\n\t\t/** Price per request. */\n\t\trequest?: number | string;\n\t};\n\t/** Preferred minimum throughput (tokens/second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */\n\tpreferred_min_throughput?:\n\t\t| number\n\t\t| {\n\t\t\t\t/** Minimum tokens/second at the 50th percentile. */\n\t\t\t\tp50?: number;\n\t\t\t\t/** Minimum tokens/second at the 75th percentile. */\n\t\t\t\tp75?: number;\n\t\t\t\t/** Minimum tokens/second at the 90th percentile. */\n\t\t\t\tp90?: number;\n\t\t\t\t/** Minimum tokens/second at the 99th percentile. */\n\t\t\t\tp99?: number;\n\t\t };\n\t/** Preferred maximum latency (seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */\n\tpreferred_max_latency?:\n\t\t| number\n\t\t| {\n\t\t\t\t/** Maximum latency in seconds at the 50th percentile. */\n\t\t\t\tp50?: number;\n\t\t\t\t/** Maximum latency in seconds at the 75th percentile. */\n\t\t\t\tp75?: number;\n\t\t\t\t/** Maximum latency in seconds at the 90th percentile. */\n\t\t\t\tp90?: number;\n\t\t\t\t/** Maximum latency in seconds at the 99th percentile. */\n\t\t\t\tp99?: number;\n\t\t };\n}\n\n/**\n * Vercel AI Gateway routing preferences.\n * Controls which upstream providers the gateway routes requests to.\n * @see https://vercel.com/docs/ai-gateway/models-and-providers/provider-options\n */\nexport interface VercelGatewayRouting {\n\t/** List of provider slugs to exclusively use for this request (e.g., [\"bedrock\", \"anthropic\"]). */\n\tonly?: string[];\n\t/** List of provider slugs to try in order (e.g., [\"anthropic\", \"openai\"]). */\n\torder?: string[];\n}\n\nexport interface ModelCostRates {\n\tinput: number; // $/million tokens\n\toutput: number; // $/million tokens\n\tcacheRead: number; // $/million tokens\n\tcacheWrite: number; // $/million tokens\n}\n\nexport interface ModelCostTier extends ModelCostRates {\n\t/** Use this tier for requests whose total input usage exceeds this token count. */\n\tinputTokensAbove: number;\n}\n\nexport interface ModelCost extends ModelCostRates {\n\t/** Request-wide pricing tiers. The highest matching input threshold applies to the full request. */\n\ttiers?: ModelCostTier[];\n}\n\nexport interface ImagesModel<TApi extends ImagesApi>\n\textends Omit<Model<Api>, \"api\" | \"provider\" | \"reasoning\" | \"contextWindow\" | \"maxTokens\" | \"compat\"> {\n\tapi: TApi;\n\tprovider: ImagesProviderId;\n\toutput: (\"text\" | \"image\")[];\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA0ZA,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import type { TelemetryContext } from \"@earendil-works/pi-telemetry\";\nimport type { AnthropicOptions } from \"./api/anthropic-messages.ts\";\nimport type { AzureOpenAIResponsesOptions } from \"./api/azure-openai-responses.ts\";\nimport type { BedrockOptions } from \"./api/bedrock-converse-stream.ts\";\nimport type { GoogleOptions } from \"./api/google-generative-ai.ts\";\nimport type { GoogleVertexOptions } from \"./api/google-vertex.ts\";\nimport type { MistralOptions } from \"./api/mistral-conversations.ts\";\nimport type { OpenAICodexResponsesOptions } from \"./api/openai-codex-responses.ts\";\nimport type { OpenAICompletionsOptions } from \"./api/openai-completions.ts\";\nimport type { OpenAIResponsesOptions } from \"./api/openai-responses.ts\";\nimport type { PiMessagesOptions } from \"./api/pi-messages.ts\";\nimport type { Model } from \"./model.ts\";\nimport type {\n\tOpenAIResponsesCompat as BaseOpenAIResponsesCompat,\n\tSessionAffinityFormat,\n} from \"./openai-responses-compat.ts\";\nimport type { AssistantMessageDiagnostic } from \"./utils/diagnostics.ts\";\nimport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type { Model } from \"./model.ts\";\nexport type { SessionAffinityFormat } from \"./openai-responses-compat.ts\";\nexport type OpenAIResponsesCompat = BaseOpenAIResponsesCompat & {\n\t/** Whether the model supports message-anchored `additional_tools` input items. Default: false. */\n\tsupportsAdditionalTools?: boolean;\n};\nexport type { AssistantMessageEventStream } from \"./utils/event-stream.ts\";\n\nexport type KnownApi =\n\t| \"openai-completions\"\n\t| \"mistral-conversations\"\n\t| \"openai-responses\"\n\t| \"azure-openai-responses\"\n\t| \"openai-codex-responses\"\n\t| \"anthropic-messages\"\n\t| \"bedrock-converse-stream\"\n\t| \"google-generative-ai\"\n\t| \"google-vertex\"\n\t| \"pi-messages\";\n\nexport type Api = KnownApi | (string & {});\n\nexport type KnownImagesApi = \"openrouter-images\" | \"openai-images\";\n\nexport type ImagesApi = KnownImagesApi | (string & {});\n\nexport type KnownProvider =\n\t| \"alibaba-token-plan\"\n\t| \"amazon-bedrock\"\n\t| \"ant-ling\"\n\t| \"anthropic\"\n\t| \"google\"\n\t| \"google-vertex\"\n\t| \"openai\"\n\t| \"azure-openai-responses\"\n\t| \"openai-codex\"\n\t| \"ollama\"\n\t| \"cursor\"\n\t| \"radius\"\n\t| \"nvidia\"\n\t| \"deepseek\"\n\t| \"github-copilot\"\n\t| \"xai\"\n\t| \"groq\"\n\t| \"cerebras\"\n\t| \"openrouter\"\n\t| \"vercel-ai-gateway\"\n\t| \"opengateway\"\n\t| \"zai\"\n\t| \"zai-coding-cn\"\n\t| \"mistral\"\n\t| \"minimax\"\n\t| \"minimax-cn\"\n\t| \"moonshotai\"\n\t| \"moonshotai-cn\"\n\t| \"huggingface\"\n\t| \"fireworks\"\n\t| \"together\"\n\t| \"baseten\"\n\t| \"opencode\"\n\t| \"opencode-go\"\n\t| \"kimi-coding\"\n\t| \"cloudflare-workers-ai\"\n\t| \"cloudflare-ai-gateway\"\n\t| \"qwen-token-plan\"\n\t| \"qwen-token-plan-cn\"\n\t| \"qwen-token-plan-individual\"\n\t| \"xiaomi\"\n\t| \"xiaomi-token-plan-cn\"\n\t| \"xiaomi-token-plan-ams\"\n\t| \"xiaomi-token-plan-sgp\";\nexport type ProviderId = KnownProvider | string;\n\nexport type KnownImagesProvider = \"openrouter\";\n\nexport type ImagesProviderId = KnownImagesProvider | string;\n\nexport type ThinkingLevel = \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\";\nexport type ModelThinkingLevel = \"off\" | ThinkingLevel;\nexport type ThinkingLevelMap = Partial<Record<ModelThinkingLevel, string | null>>;\nexport type ChatTemplateKwargValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| {\n\t\t\t$var: \"thinking.enabled\" | \"thinking.effort\";\n\t\t\tomitWhenOff?: boolean;\n\t };\n\n/** Token budgets for each thinking level (token-based providers only) */\nexport interface ThinkingBudgets {\n\tminimal?: number;\n\tlow?: number;\n\tmedium?: number;\n\thigh?: number;\n\tmax?: number;\n}\n\n// Base options all providers share\nexport type CacheRetention = \"none\" | \"short\" | \"long\";\n\nexport type Transport = \"sse\" | \"websocket\" | \"websocket-cached\" | \"auto\";\n\n/** Provider-scoped environment overrides. Values take precedence over process.env. */\nexport type ProviderEnv = Record<string, string>;\nexport type ProviderHeaders = Record<string, string | null>;\n/** Effective model and fully transformed headers for a request payload hook. */\nexport type ProviderRequestMetadata = {\n\tmodel: Model<Api>;\n\theaders: ProviderHeaders;\n};\nexport type FetchFunction = typeof globalThis.fetch;\n\nexport interface ProviderResponse {\n\tstatus: number;\n\theaders: Record<string, string>;\n}\n\n/** Authentication, HTTP transport, and lifecycle callbacks shared by provider requests. */\nexport interface ProviderRequestOptions<TModel = Model<Api>> {\n\tsignal?: AbortSignal;\n\t/**\n\t * Abort the request when the provider reports that a safety classifier\n\t * declined the requested model and a substitute model served the turn\n\t * instead (Anthropic `server-side-fallback-*` betas). The substitute's output\n\t * is billed but was never requested, so aborting keeps model selection with\n\t * the caller. Providers without server-side fallback ignore this.\n\t * Default: undefined (honor the substituted response).\n\t */\n\tabortServerSideFallback?: boolean;\n\t/** Explicit parent context for telemetry produced by this logical request. */\n\ttelemetryContext?: TelemetryContext;\n\tapiKey?: string;\n\t/**\n\t * Stable identity of the originating session for account-affinity providers,\n\t * preserved across auxiliary calls that replace `sessionId` (for example\n\t * compaction). Providers without account affinity ignore this.\n\t */\n\taffinitySessionId?: string;\n\t/**\n\t * Identifies whether the stream belongs to the main agent loop or an auxiliary request.\n\t * An absent value must be treated as auxiliary as a fail-safe.\n\t */\n\tstreamKind?: \"main\" | \"auxiliary\";\n\t/**\n\t * Optional fetch implementation for provider HTTP requests.\n\t * Defaults to `globalThis.fetch`. Provider adapters that cannot inject a custom implementation may reject it.\n\t * This does not affect WebSocket transports.\n\t */\n\tfetch?: FetchFunction;\n\t/**\n\t * Provider-scoped environment values. These take precedence over process.env for\n\t * provider configuration such as regional settings, endpoint placeholders, and\n\t * proxy variables.\n\t */\n\tenv?: ProviderEnv;\n\t/**\n\t * Optional callback for inspecting or replacing provider payloads before sending.\n\t * Return undefined to keep the payload unchanged.\n\t */\n\tonPayload?: (\n\t\tpayload: unknown,\n\t\tmodel: TModel,\n\t\trequest?: ProviderRequestMetadata,\n\t) => unknown | undefined | Promise<unknown | undefined>;\n\t/**\n\t * Optional callback invoked after an HTTP response is received.\n\t */\n\tonResponse?: (response: ProviderResponse, model: TModel) => void | Promise<void>;\n\t/**\n\t * Optional custom HTTP headers to include in API requests.\n\t * Merged with provider defaults; caller values override default headers.\n\t * On AWS Bedrock these are injected via a Smithy `build`-step middleware so\n\t * they are covered by SigV4 signing; reserved headers (`x-amz-*`,\n\t * `authorization`, `host`) are silently ignored to preserve SigV4 / bearer auth.\n\t * A null value suppresses a provider/API default header with the same name.\n\t */\n\theaders?: ProviderHeaders;\n\t/**\n\t * HTTP request timeout in milliseconds for providers/SDKs that support it.\n\t * For example, OpenAI and Anthropic SDK clients default to 10 minutes.\n\t */\n\ttimeoutMs?: number;\n\t/**\n\t * Maximum retry attempts for providers/SDKs that support client-side retries.\n\t * For example, OpenAI and Anthropic SDK clients default to 2.\n\t */\n\tmaxRetries?: number;\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately\n\t * with an error containing the requested delay, allowing higher-level retry logic\n\t * to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n}\n\nexport interface StreamOptions extends ProviderRequestOptions<Model<Api>> {\n\ttemperature?: number;\n\t/**\n\t * Arbitrary sampling parameters merged into the request body as-is, after the named request\n\t * fields, so keys here override them. Lets custom OpenAI-compatible servers (llama.cpp, vLLM,\n\t * SGLang, ...) receive parameters pi does not model, e.g. `top_p`, `top_k`, `min_p`,\n\t * `repetition_penalty`. Merged over `Model.samplingParams` per key. Only applied by\n\t * OpenAI-compatible adapters (completions, responses, Azure responses); other APIs ignore it.\n\t */\n\tsamplingParams?: Record<string, unknown>;\n\tmaxTokens?: number;\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t * Providers that do not support this option ignore it.\n\t */\n\ttransport?: Transport;\n\t/**\n\t * Prompt cache retention preference. Providers map this to their supported values.\n\t * Default: \"short\".\n\t */\n\tcacheRetention?: CacheRetention;\n\t/**\n\t * Optional session identifier for providers that support session-based caching.\n\t * Providers can use this to enable prompt caching, request routing, or other\n\t * session-aware features. Ignored by providers that don't support it.\n\t */\n\tsessionId?: string;\n\t/**\n\t * Optional custom fields to merge into the outgoing provider request body.\n\t * Applied before `onPayload` so `onPayload` can observe/override them.\n\t * Provider-managed fields (e.g. `model`, `messages`, `stream`) are preserved\n\t * and cannot be overridden to avoid breaking core request semantics.\n\t */\n\textraBody?: Record<string, unknown>;\n\t/**\n\t * WebSocket connect timeout in milliseconds for providers that support\n\t * WebSocket transports. This covers the connection/open handshake only;\n\t * stream idleness after connection uses timeoutMs.\n\t */\n\twebsocketConnectTimeoutMs?: number;\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t * For example, Anthropic uses `user_id` for abuse tracking and rate limiting.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderStreamOptions = StreamOptions & Record<string, unknown>;\n\nexport interface DeferredFetchOptions extends ProviderRequestOptions<Model<Api>> {\n\t/**\n\t * Maximum provider long-poll duration in milliseconds.\n\t * Defaults to 0, which performs one status check.\n\t */\n\twait?: number;\n}\n\n/** Request options for best-effort deferred-response cancellation. */\nexport type DeferredCancelOptions = ProviderRequestOptions<Model<Api>>;\n\n/**\n * Maps known APIs to their full provider-specific stream option types.\n * Type-only imports from API implementation modules are erased at emit, so\n * this is tree-shake safe.\n */\nexport interface ApiOptionsMap {\n\t\"anthropic-messages\": AnthropicOptions;\n\t\"openai-completions\": OpenAICompletionsOptions;\n\t\"openai-responses\": OpenAIResponsesOptions;\n\t\"openai-codex-responses\": OpenAICodexResponsesOptions;\n\t\"azure-openai-responses\": AzureOpenAIResponsesOptions;\n\t\"google-generative-ai\": GoogleOptions;\n\t\"google-vertex\": GoogleVertexOptions;\n\t\"mistral-conversations\": MistralOptions;\n\t\"bedrock-converse-stream\": BedrockOptions;\n\t\"pi-messages\": PiMessagesOptions;\n}\n\n/**\n * Full stream options for an API. Known APIs resolve to their concrete option\n * type; custom API strings fall back to the generic shape.\n */\nexport type ApiStreamOptions<TApi extends Api> = TApi extends keyof ApiOptionsMap\n\t? ApiOptionsMap[TApi]\n\t: StreamOptions & Record<string, unknown>;\n\n/**\n * The uniform stream contract of an API implementation module: every module\n * under `src/api/` exports `stream` and `streamSimple`; capable modules may also\n * export deferred-response methods. Lazy wrappers (`lazyApi()`) and provider\n * factories pass these around as values. This is the untyped dispatch shape;\n * per-API option typing lives on the implementation modules themselves and on\n * `Provider.stream()` via `ApiStreamOptions`.\n */\nexport interface ProviderStreams {\n\tstream(model: Model<Api>, context: Context, options?: StreamOptions): AssistantMessageEventStream;\n\tstreamSimple(model: Model<Api>, context: Context, options?: SimpleStreamOptions): AssistantMessageEventStream;\n\tfetchDeferred?(\n\t\tmodel: Model<Api>,\n\t\thandle: DeferredHandle,\n\t\toptions?: DeferredFetchOptions,\n\t): AssistantMessageEventStream;\n\tcancelDeferred?(model: Model<Api>, handle: DeferredHandle, options?: DeferredCancelOptions): Promise<void>;\n}\n\n/**\n * The uniform contract of an image-generation API implementation module:\n * every image API module under `src/api/` exports exactly `generateImages`,\n * so the module itself satisfies this interface. Lazy wrappers and image\n * provider factories pass these around as values.\n */\nexport interface ProviderImages {\n\tgenerateImages(\n\t\tmodel: ImagesModel<ImagesApi>,\n\t\tcontext: ImagesContext,\n\t\toptions?: ImagesOptions,\n\t): Promise<AssistantImages>;\n}\n\nexport interface ImagesOptions extends ProviderRequestOptions<ImagesModel<ImagesApi>> {\n\t/**\n\t * Optional metadata to include in API requests.\n\t * Providers extract the fields they understand and ignore the rest.\n\t */\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ProviderImagesOptions = ImagesOptions & Record<string, unknown>;\n\n// Unified options with reasoning passed to streamSimple() and completeSimple()\nexport interface SimpleStreamOptions extends StreamOptions {\n\treasoning?: ThinkingLevel;\n\t/** Ask a capable provider to return a durable handle and continue the request asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n\t/** Custom token budgets for thinking levels (token-based providers only) */\n\tthinkingBudgets?: ThinkingBudgets;\n}\n\n// Generic StreamFunction with typed options.\n//\n// Contract:\n// - Must return an AssistantMessageEventStream.\n// - Once invoked, request/model/runtime failures should be encoded in the\n// returned stream, not thrown.\n// - Error termination must produce an AssistantMessage with stopReason\n// \"error\" or \"aborted\" and errorMessage, emitted via the stream protocol.\nexport type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\toptions?: TOptions,\n) => AssistantMessageEventStream;\n\nexport type ImagesFunction<TApi extends ImagesApi = ImagesApi, TOptions extends ImagesOptions = ImagesOptions> = (\n\tmodel: ImagesModel<TApi>,\n\tcontext: ImagesContext,\n\toptions?: TOptions,\n) => Promise<AssistantImages>;\n\nexport interface TextSignatureV1 {\n\tv: 1;\n\tid: string;\n\tphase?: \"commentary\" | \"final_answer\";\n}\n\nexport interface TextContent {\n\ttype: \"text\";\n\ttext: string;\n\ttextSignature?: string; // e.g., for OpenAI responses, message metadata (legacy id string or TextSignatureV1 JSON)\n}\n\nexport interface ThinkingContent {\n\ttype: \"thinking\";\n\tthinking: string;\n\t/** Epoch ms, stamped by the agent loop at stream-event receipt, best-effort. */\n\tstartedAt?: number;\n\t/** Epoch ms, stamped by the agent loop at stream-event receipt, best-effort. */\n\tendedAt?: number;\n\tthinkingSignature?: string; // e.g., for OpenAI responses, the reasoning item ID\n\t/** When true, the thinking content was redacted by safety filters. The opaque\n\t * encrypted payload is stored in `thinkingSignature` so it can be passed back\n\t * to the API for multi-turn continuity. */\n\tredacted?: boolean;\n}\n\nexport interface ImageContent {\n\ttype: \"image\";\n\tdata: string; // base64 encoded image data\n\tmimeType: string; // e.g., \"image/jpeg\", \"image/png\". Video payloads (e.g. \"video/mp4\") ride this\n\t// same block for models that declare the \"video\" input modality; use isVideoMimeType() to branch.\n}\n\n/** True when an ImageContent block actually carries video data (e.g. \"video/mp4\"). */\nexport function isVideoMimeType(mimeType: string): boolean {\n\treturn mimeType.toLowerCase().startsWith(\"video/\");\n}\n\nexport interface ToolCall {\n\ttype: \"toolCall\";\n\tid: string;\n\tname: string;\n\targuments: Record<string, any>;\n\t/** Set by text tool-call middleware when a truncated call could not be recovered. Carriers of `incomplete` MUST NOT be executed. */\n\tincomplete?: true;\n\t/** Error explaining why an incomplete tool call could not be recovered. */\n\terrorMessage?: string;\n\tthoughtSignature?: string; // Google-specific: opaque signature for reusing thought context\n\t/** OpenAI Responses namespace for calls to dynamically loaded or namespaced tools. */\n\tnamespace?: string;\n}\n\n/**\n * Provider-emitted content block whose semantics are owned by the originating\n * provider. Surfaces server-side tool invocations (web_search), server-side\n * tool results (web_search_tool_result), code execution traces, grounding\n * metadata fragments, and any other vendor-specific block the core does not\n * normalize.\n *\n * `subtype` mirrors the provider's wire `type` discriminator (e.g.\n * \"server_tool_use\", \"web_search_tool_result\", \"executableCode\"). `raw` is\n * the verbatim wire payload — extensions interpret it per provider+subtype.\n *\n * The owning provider id lives on the parent `AssistantMessage.provider`, not\n * here, to avoid drift on replay.\n *\n * On replay across providers, `convertMessages` implementations MUST drop\n * these blocks (they are not portable). This mirrors the existing\n * `redacted_thinking` skip pattern.\n */\nexport interface ProviderNativeContent {\n\ttype: \"providerNative\";\n\tsubtype: string;\n\traw: unknown;\n}\n\nexport interface Usage {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\t/** Subset of `cacheWrite` written with 1h retention. Only Anthropic reports this split. */\n\tcacheWrite1h?: number;\n\t/**\n\t * Reasoning/thinking tokens, when the provider reports them. This is a subset of\n\t * `output`: `output` already includes these tokens. Set to a number (possibly 0) by\n\t * providers that expose a reasoning breakdown; left undefined by providers that don't.\n\t */\n\treasoning?: number;\n\ttotalTokens: number;\n\tcost: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n}\n\nexport type StopReason = \"pending\" | \"stop\" | \"length\" | \"toolUse\" | \"error\" | \"aborted\" | \"deferred\";\n\nexport type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };\n\nexport interface DeferredHandle {\n\tprovider: string;\n\tmodelId: string;\n\tapi: string;\n\t/** Provider token, such as a response id or batch id plus row id. */\n\tid: string;\n\texpiresAt?: number;\n\tpollAfterMs?: number;\n\t/** Provider conversion data required to reconstruct the final assistant message. */\n\tdata?: JsonValue;\n}\n\nexport type AssistantStopDetails = { type: \"refusal\"; explanation?: string } | { type: \"sensitive\" };\n\nexport interface UserMessage {\n\trole: \"user\";\n\tcontent: string | (TextContent | ImageContent)[];\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface AssistantMessage {\n\trole: \"assistant\";\n\tcontent: (TextContent | ThinkingContent | ToolCall | ProviderNativeContent)[];\n\tapi: Api;\n\tprovider: ProviderId;\n\tmodel: string;\n\tresponseModel?: string; // Concrete `chunk.model` when different from the requested `model` (e.g. OpenRouter `auto` -> `anthropic/...`)\n\tresponseId?: string; // Provider-specific response/message identifier when the upstream API exposes one\n\tdiagnostics?: AssistantMessageDiagnostic[]; // Redacted provider/runtime diagnostics for failures and recoveries.\n\tusage: Usage;\n\tstopReason: StopReason;\n\tstopDetails?: AssistantStopDetails;\n\tdeferred?: DeferredHandle;\n\terrorMessage?: string;\n\trawStopReason?: string;\n\t/**\n\t * Provider indication of whether the model explicitly ended its turn.\n\t * Preserved for debugging and does not currently affect agent control flow.\n\t */\n\tendTurn?: boolean;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport interface ToolResultMessage<TDetails = any> {\n\trole: \"toolResult\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tcontent: (TextContent | ImageContent)[]; // Supports text and images\n\tdetails?: TDetails;\n\t/** Usage from the tool execution itself, if available. Not part of main LLM context accounting. */\n\tusage?: Usage;\n\t/**\n\t * Names from `Context.tools` that became available after this result.\n\t * Providers with native deferred tool loading use this as the load point;\n\t * other providers ignore it and use `Context.tools` normally.\n\t */\n\taddedToolNames?: string[];\n\tisError: boolean;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nexport type Message = UserMessage | AssistantMessage | ToolResultMessage;\n\nexport type ImagesInputContent = TextContent | ImageContent;\nexport type ImagesOutputContent = TextContent | ImageContent;\n\nexport interface ImagesContext {\n\tinput: ImagesInputContent[];\n}\n\nexport type ImagesStopReason = \"stop\" | \"error\" | \"aborted\";\n\nexport interface AssistantImages {\n\tapi: ImagesApi;\n\tprovider: ImagesProviderId;\n\tmodel: string;\n\toutput: ImagesOutputContent[];\n\tresponseId?: string;\n\tusage?: Usage;\n\tstopReason: ImagesStopReason;\n\terrorMessage?: string;\n\ttimestamp: number; // Unix timestamp in milliseconds\n}\n\nimport type { TSchema } from \"typebox\";\n\nexport interface FreeformToolFormat {\n\ttype: \"grammar\";\n\tsyntax: \"lark\";\n\tdefinition: string;\n}\n\n/** OpenAI grammar variants for constrained sampling. */\nexport type GrammarFormat = \"openai_lark\" | \"openai_regex\";\n\nexport type GrammarVariants = Partial<Record<GrammarFormat, string>>;\n\n/**\n * Optional provider-side constrained sampling configs for a tool.\n *\n * The `json_schema` value roughly maps to the concept of `strict` in APIs which is\n * implemented as json-schema constrained sampling by APIs. Grammar variants let\n * callers provide provider-specific encodings of the same intended language.\n */\nexport type ConstrainedSamplingConfig =\n\t| {\n\t\t\ttype: \"json_schema\";\n\t\t\tstrict: \"prefer\" | \"require\";\n\t }\n\t| {\n\t\t\ttype: \"grammar\";\n\t\t\tvariants: GrammarVariants;\n\t };\nexport interface Tool<TParameters extends TSchema = TSchema> {\n\tname: string;\n\tdescription: string;\n\tparameters: TParameters;\n\tfreeform?: FreeformToolFormat;\n\tconstrainedSampling?: false | ConstrainedSamplingConfig;\n}\n\nexport interface Context {\n\tsystemPrompt?: string;\n\tmessages: Message[];\n\ttools?: Tool[];\n}\n\n/**\n * Event protocol for AssistantMessageEventStream.\n *\n * Streams should emit `start` before partial updates, then terminate with either:\n * - `done` carrying the final successful AssistantMessage, or\n * - `error` carrying the final AssistantMessage with stopReason \"error\" or \"aborted\"\n * and errorMessage.\n */\nexport type AssistantMessageEvent =\n\t| { type: \"start\"; partial: AssistantMessage }\n\t| { type: \"text_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"text_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"text_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"thinking_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"thinking_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t| { type: \"thinking_end\"; contentIndex: number; content: string; partial: AssistantMessage }\n\t| { type: \"toolcall_start\"; contentIndex: number; partial: AssistantMessage }\n\t| { type: \"toolcall_delta\"; contentIndex: number; delta: string; partial: AssistantMessage }\n\t/** Finalized - executable iff `incomplete !== true` on `toolCall`. */\n\t| { type: \"toolcall_end\"; contentIndex: number; toolCall: ToolCall; partial: AssistantMessage }\n\t| {\n\t\t\ttype: \"done\";\n\t\t\treason: Extract<StopReason, \"stop\" | \"length\" | \"toolUse\" | \"deferred\">;\n\t\t\tmessage: AssistantMessage;\n\t }\n\t| { type: \"error\"; reason: Extract<StopReason, \"aborted\" | \"error\">; error: AssistantMessage };\n\n/**\n * Compatibility settings for OpenAI-compatible completions APIs.\n * Use this to override URL-based auto-detection for custom providers.\n */\nexport interface OpenAICompletionsCompat {\n\t/** Whether the provider supports the `store` field. Default: auto-detected from URL. */\n\tsupportsStore?: boolean;\n\t/** Whether the provider supports the `developer` role (vs `system`). Default: auto-detected from URL. */\n\tsupportsDeveloperRole?: boolean;\n\t/** Whether the provider supports `reasoning_effort`. Default: auto-detected from URL. */\n\tsupportsReasoningEffort?: boolean;\n\t/** Whether the provider supports `stream_options: { include_usage: true }` for token usage in streaming responses. Default: true. */\n\tsupportsUsageInStreaming?: boolean;\n\t/** Whether streamed responses include `finish_reason`. When false, pi infers `stop` or `toolUse` when the stream ends. Default: true. */\n\tsupportsFinishReason?: boolean;\n\t/** Which field to use for max tokens. Default: auto-detected from URL. */\n\tmaxTokensField?: \"max_completion_tokens\" | \"max_tokens\";\n\t/** Whether tool results require the `name` field. Default: auto-detected from URL. */\n\trequiresToolResultName?: boolean;\n\t/** Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. */\n\trequiresAssistantAfterToolResult?: boolean;\n\t/** Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL. */\n\trequiresThinkingAsText?: boolean;\n\t/** Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL. */\n\trequiresReasoningContentOnAssistantMessages?: boolean;\n\t/** Format for reasoning/thinking parameter. \"openai\" uses reasoning_effort, \"openrouter\" uses reasoning: { effort }, \"deepseek\" uses thinking: { type } plus reasoning_effort when supported, \"together\" uses reasoning: { enabled } plus reasoning_effort when supported, \"baseten\" uses configurable chat_template_args plus reasoning_effort when supported, \"zai\" uses thinking: { type }, \"qwen\" uses top-level enable_thinking: boolean, \"qwen-chat-template\" uses chat_template_kwargs.enable_thinking and preserve_thinking, \"chat-template\" uses configurable chat_template_kwargs, \"string-thinking\" uses top-level thinking: string, and \"ant-ling\" uses reasoning: { effort } only when the mapped effort is non-null. Default: \"openai\". */\n\tthinkingFormat?:\n\t\t| \"openai\"\n\t\t| \"openrouter\"\n\t\t| \"deepseek\"\n\t\t| \"together\"\n\t\t| \"baseten\"\n\t\t| \"zai\"\n\t\t| \"qwen\"\n\t\t| \"chat-template\"\n\t\t| \"qwen-chat-template\"\n\t\t| \"string-thinking\"\n\t\t| \"ant-ling\";\n\t/** Whether the provider accepts explicit disabled-thinking markers when thinking is off. Default: true. */\n\tsupportsDisabledThinking?: boolean;\n\t/** Kwargs to send as `chat_template_kwargs` when `thinkingFormat` is `chat-template`. Use `{ \"$var\": \"thinking.enabled\" }` or `{ \"$var\": \"thinking.effort\" }` for pi-controlled thinking values. */\n\tchatTemplateKwargs?: Record<string, ChatTemplateKwargValue>;\n\t/** Arguments to send as `chat_template_args` when `thinkingFormat` is `baseten`. Use `{ \"$var\": \"thinking.enabled\" }` or `{ \"$var\": \"thinking.effort\" }` for pi-controlled thinking values. */\n\tchatTemplateArgs?: Record<string, ChatTemplateKwargValue>;\n\t/** OpenRouter-compatible routing preferences sent as the `provider` request field. */\n\topenRouterRouting?: OpenRouterRouting;\n\t/** Vercel AI Gateway routing preferences. Only used when baseUrl points to Vercel AI Gateway. */\n\tvercelGatewayRouting?: VercelGatewayRouting;\n\t/** Whether z.ai supports top-level `tool_stream: true` for streaming tool call deltas. Default: false. */\n\tzaiToolStream?: boolean;\n\t/** Whether the provider supports top-level `thinking_token_budget` to cap reasoning tokens (vLLM). Reasoning and the answer share `max_tokens` on these endpoints, so without a budget a reasoning-heavy turn can consume the whole response and emit no answer. Default: false. */\n\tsupportsThinkingTokenBudget?: boolean;\n\t/** Whether the provider supports OpenAI custom tools with Lark/regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. Default: false; the generated model catalog enables it for capable models. */\n\tsupportsOpenAIGrammarTools?: boolean;\n\t/** Whether the provider supports the `strict` field in tool definitions. Default: true. */\n\tsupportsStrictMode?: boolean;\n\t/**\n\t * Provider-specific JSON Schema flavor for tool parameters. `\"moonshot-mfjs\"`\n\t * normalizes schemas for Moonshot / Kimi backends that enforce a stricter subset.\n\t */\n\ttoolSchemaFlavor?: \"moonshot-mfjs\";\n\t/**\n\t * Tool call format for models that don't natively support tool calling.\n\t * When set, the middleware will intercept tool calls and format them as text.\n\t * Supported values: \"hermes\", \"morph-xml\", \"xml\" (deprecated alias for \"morph-xml\"), \"yaml-xml\", \"gemma4-delimiter\", \"anthropic-xml\", \"antml\", \"kimi-xtml\"\n\t */\n\ttoolCallFormat?: string;\n\t/** Cache control convention for prompt caching. \"anthropic\" applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content. */\n\tcacheControlFormat?: \"anthropic\";\n\t/** Whether to send session-affinity data from `options.sessionId`. Default: false. */\n\tsendSessionAffinityHeaders?: boolean;\n\t/** Provider-specific deferred tool serialization mode. */\n\tdeferredToolsMode?: \"kimi\";\n\t/** Session-affinity header format: `openai` sends `session_id`, `x-client-request-id`, and `x-session-affinity`; `openai-nosession` sends `x-client-request-id` and `x-session-affinity`; `openrouter` sends `x-session-id`. Does not affect the `prompt_cache_key` body param, which is governed by cache retention. Default: auto-detected. */\n\tsessionAffinityFormat?: SessionAffinityFormat;\n\t/** Whether the provider accepts the `prompt_cache_key` request field. Default: auto-detected. */\n\tsupportsPromptCacheKey?: boolean;\n\t/** Whether the provider supports long prompt cache retention (`prompt_cache_retention: \"24h\"` or Anthropic-style `cache_control.ttl: \"1h\"`, depending on format). Default: true. */\n\tsupportsLongCacheRetention?: boolean;\n}\n\n/** Compatibility settings for Anthropic Messages-compatible APIs. */\nexport interface AnthropicMessagesCompat {\n\t/**\n\t * Whether the provider accepts per-tool `eager_input_streaming`.\n\t * When false, the Anthropic provider omits `tools[].eager_input_streaming`\n\t * and sends the legacy `fine-grained-tool-streaming-2025-05-14` beta header\n\t * for tool-enabled requests.\n\t * Default: true.\n\t */\n\tsupportsEagerToolInputStreaming?: boolean;\n\t/** Whether the provider supports Anthropic long cache retention (`cache_control.ttl: \"1h\"`). Default: true. */\n\tsupportsLongCacheRetention?: boolean;\n\t/**\n\t * Whether to send the `x-session-affinity` header from `options.sessionId`\n\t * when caching is enabled. Required for providers like Fireworks that use\n\t * session affinity for prompt cache routing (requests to the same replica\n\t * maximize cache hits).\n\t * Default: false.\n\t */\n\tsendSessionAffinityHeaders?: boolean;\n\t/**\n\t * Whether the provider supports Anthropic-style `cache_control` markers on\n\t * tool definitions. When false, `cache_control` is omitted from tool params.\n\t * Some Anthropic-compatible providers (e.g., Fireworks) do not support this\n\t * field on tools and may reject or ignore it.\n\t * Default: true.\n\t */\n\tsupportsCacheControlOnTools?: boolean;\n\t/**\n\t * Whether the provider accepts `thinking: { type: \"disabled\" }` when\n\t * extended thinking is off. Some Anthropic-compatible providers support\n\t * thinking but reject Anthropic's explicit disabled marker.\n\t * Default: true.\n\t */\n\tsupportsDisabledThinking?: boolean;\n\t/**\n\t * Whether the model accepts the Anthropic `temperature` request field.\n\t * Claude Opus 4.7+ rejects non-default temperature values.\n\t * Default: true.\n\t */\n\tsupportsTemperature?: boolean;\n\t/** Whether the model accepts Anthropic `tool_choice`. Default: true. */\n\tsupportsToolChoice?: boolean;\n\t/**\n\t * Whether the model accepts forced Anthropic tool choices (`any` or a named\n\t * tool). Default: true, except Claude Fable/Mythos models.\n\t */\n\tsupportsForcedToolChoice?: boolean;\n\t/**\n\t * Whether to force adaptive thinking (`thinking.type: \"adaptive\"` plus\n\t * `output_config.effort`) regardless of the model id. Built-in models that\n\t * require adaptive thinking set this in generated metadata. Custom\n\t * Anthropic-compatible providers can set this to `true` for any model whose\n\t * upstream requires the adaptive format. Set to `false` to opt out on\n\t * overridden built-in models and disable model id/name inference.\n\t * Default: infer from adaptive Claude model ids/names when possible.\n\t */\n\tforceAdaptiveThinking?: boolean;\n\t/** Whether to replay empty thinking signatures as `signature: \"\"` instead of converting thinking to text. Default: false. */\n\tallowEmptySignature?: boolean;\n\t/** Whether the provider supports Anthropic strict tool schemas. Default: false; generated Anthropic models enable it explicitly. */\n\tsupportsStrictTools?: boolean;\n\t/**\n\t * How to replay thinking blocks that have no usable Anthropic signature.\n\t * `\"text\"` demotes them to text; `\"empty-signature\"` preserves Anthropic's\n\t * thinking shape with `signature: \"\"`. Defaults to `\"text\"`; the legacy\n\t * `allowEmptySignature` setting remains a compatibility alias for\n\t * `\"empty-signature\"`.\n\t */\n\tunsignedThinkingReplay?: \"text\" | \"empty-signature\";\n\t/**\n\t * Whether the provider supports deferred tools loaded by `tool_reference`\n\t * blocks in tool results. Default: true for first-party Anthropic models\n\t * except Haiku and models older than Claude 4.5; false for other providers.\n\t */\n\tsupportsToolReferences?: boolean;\n\t/**\n\t * Whether the provider executes Anthropic server-side `web_search_*` native\n\t * tools and accepts their `server_tool_use` / `web_search_tool_result`\n\t * blocks on replay. Anthropic-compatible endpoints (e.g., kimi-coding) may\n\t * run the search but reject the replayed server-tool blocks on the next\n\t * request. When false, hook-injected `web_search_*` tools are stripped from\n\t * the payload. Default: true only for the first-party Anthropic endpoint.\n\t */\n\tsupportsWebSearch?: boolean;\n}\n\n/** Compatibility settings for Amazon Bedrock models. */\nexport interface BedrockCompat {\n\t/** Whether the model supports Bedrock strict tool schemas. Default: false. */\n\tsupportsStrictMode?: boolean;\n}\n\n/**\n * OpenRouter provider routing preferences.\n * Controls which upstream providers OpenRouter routes requests to.\n * Sent as the `provider` field in the OpenRouter API request body.\n * @see https://openrouter.ai/docs/guides/routing/provider-selection\n */\nexport interface OpenRouterRouting {\n\t/** Whether to allow backup providers to serve requests. Default: true. */\n\tallow_fallbacks?: boolean;\n\t/** Whether to filter providers to only those that support all parameters in the request. Default: false. */\n\trequire_parameters?: boolean;\n\t/** Data collection setting. \"allow\" (default): allow providers that may store/train on data. \"deny\": only use providers that don't collect user data. */\n\tdata_collection?: \"deny\" | \"allow\";\n\t/** Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. */\n\tzdr?: boolean;\n\t/** Whether to restrict routing to only models that allow text distillation. */\n\tenforce_distillable_text?: boolean;\n\t/** An ordered list of provider names/slugs to try in sequence, falling back to the next if unavailable. */\n\torder?: string[];\n\t/** List of provider names/slugs to exclusively allow for this request. */\n\tonly?: string[];\n\t/** List of provider names/slugs to skip for this request. */\n\tignore?: string[];\n\t/** A list of quantization levels to filter providers by (e.g., [\"fp16\", \"bf16\", \"fp8\", \"fp6\", \"int8\", \"int4\", \"fp4\", \"fp32\"]). */\n\tquantizations?: string[];\n\t/** Sorting strategy. Can be a string (e.g., \"price\", \"throughput\", \"latency\") or an object with `by` and `partition`. */\n\tsort?:\n\t\t| string\n\t\t| {\n\t\t\t\t/** The sorting metric: \"price\", \"throughput\", \"latency\". */\n\t\t\t\tby?: string;\n\t\t\t\t/** Partitioning strategy: \"model\" (default) or \"none\". */\n\t\t\t\tpartition?: string | null;\n\t\t };\n\t/** Maximum price per million tokens (USD). */\n\tmax_price?: {\n\t\t/** Price per million prompt tokens. */\n\t\tprompt?: number | string;\n\t\t/** Price per million completion tokens. */\n\t\tcompletion?: number | string;\n\t\t/** Price per image. */\n\t\timage?: number | string;\n\t\t/** Price per audio unit. */\n\t\taudio?: number | string;\n\t\t/** Price per request. */\n\t\trequest?: number | string;\n\t};\n\t/** Preferred minimum throughput (tokens/second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */\n\tpreferred_min_throughput?:\n\t\t| number\n\t\t| {\n\t\t\t\t/** Minimum tokens/second at the 50th percentile. */\n\t\t\t\tp50?: number;\n\t\t\t\t/** Minimum tokens/second at the 75th percentile. */\n\t\t\t\tp75?: number;\n\t\t\t\t/** Minimum tokens/second at the 90th percentile. */\n\t\t\t\tp90?: number;\n\t\t\t\t/** Minimum tokens/second at the 99th percentile. */\n\t\t\t\tp99?: number;\n\t\t };\n\t/** Preferred maximum latency (seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. */\n\tpreferred_max_latency?:\n\t\t| number\n\t\t| {\n\t\t\t\t/** Maximum latency in seconds at the 50th percentile. */\n\t\t\t\tp50?: number;\n\t\t\t\t/** Maximum latency in seconds at the 75th percentile. */\n\t\t\t\tp75?: number;\n\t\t\t\t/** Maximum latency in seconds at the 90th percentile. */\n\t\t\t\tp90?: number;\n\t\t\t\t/** Maximum latency in seconds at the 99th percentile. */\n\t\t\t\tp99?: number;\n\t\t };\n}\n\n/**\n * Vercel AI Gateway routing preferences.\n * Controls which upstream providers the gateway routes requests to.\n * @see https://vercel.com/docs/ai-gateway/models-and-providers/provider-options\n */\nexport interface VercelGatewayRouting {\n\t/** List of provider slugs to exclusively use for this request (e.g., [\"bedrock\", \"anthropic\"]). */\n\tonly?: string[];\n\t/** List of provider slugs to try in order (e.g., [\"anthropic\", \"openai\"]). */\n\torder?: string[];\n}\n\nexport interface ModelCostRates {\n\tinput: number; // $/million tokens\n\toutput: number; // $/million tokens\n\tcacheRead: number; // $/million tokens\n\tcacheWrite: number; // $/million tokens\n}\n\nexport interface ModelCostTier extends ModelCostRates {\n\t/** Use this tier for requests whose total input usage exceeds this token count. */\n\tinputTokensAbove: number;\n}\n\nexport interface ModelCost extends ModelCostRates {\n\t/** Request-wide pricing tiers. The highest matching input threshold applies to the full request. */\n\ttiers?: ModelCostTier[];\n}\n\nexport interface ImagesModel<TApi extends ImagesApi>\n\textends Omit<Model<Api>, \"api\" | \"provider\" | \"reasoning\" | \"contextWindow\" | \"maxTokens\" | \"compat\"> {\n\tapi: TApi;\n\tprovider: ImagesProviderId;\n\toutput: (\"text\" | \"image\")[];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"overflow.d.ts","sourceRoot":"","sources":["../../src/utils/overflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA+EpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CA6B5F;AACD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAEhG;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C"}
1
+ {"version":3,"file":"overflow.d.ts","sourceRoot":"","sources":["../../src/utils/overflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAiFpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CA6B5F;AACD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAEhG;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C"}
@@ -24,6 +24,7 @@
24
24
  * - Kimi For Coding: "Your request exceeded model token limit: X (requested: Y)"
25
25
  * - DS4: "Prompt has X tokens, but the configured context size is Y tokens"
26
26
  * - Cerebras: "400/413 status code (no body)"
27
+ * - Gateways: "413 Request body too large" / "Request Entity Too Large" / "Payload Too Large" (byte-size overflow)
27
28
  * - Mistral: "Prompt contains X tokens ... too large for model with Y maximum context length"
28
29
  * - z.ai: Does NOT error, accepts overflow silently - handled via usage.input > contextWindow
29
30
  * - Xiaomi MiMo: Truncates input to fill contextWindow exactly, then returns finish_reason "length"
@@ -58,6 +59,7 @@ const OVERFLOW_PATTERNS = [
58
59
  /too many tokens/i, // Generic fallback
59
60
  /token limit exceeded/i, // Generic fallback
60
61
  /^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i, // Cerebras: 400/413 with no body
62
+ /(?:request[ _])?(?:body|entity|payload)[_ ]too[_ ]large/i, // Gateway HTTP 413 byte-size rejections ("Request body too large", "Request Entity Too Large", "body_too_large", "Payload Too Large"). Substring-anchored by design (JSON bodies lack an adjacent status code); a non-context size rejection (e.g. an oversized image) can over-match, which costs one bounded shrink-retry, never a wedge.
61
63
  ];
62
64
  /**
63
65
  * Patterns that indicate non-overflow errors (e.g. rate limiting, server errors).
@@ -1 +1 @@
1
- {"version":3,"file":"overflow.js","sourceRoot":"","sources":["../../src/utils/overflow.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,iBAAiB,GAAG;IACzB,qBAAqB,EAAE,2BAA2B;IAClD,oBAAoB,EAAE,kDAAkD;IACxE,wCAAwC,EAAE,iBAAiB;IAC3D,6BAA6B,EAAE,uCAAuC;IACtE,4FAA4F,EAAE,sCAAsC;IACpI,yCAAyC,EAAE,kBAAkB;IAC7D,+BAA+B,EAAE,aAAa;IAC9C,oCAAoC,EAAE,OAAO;IAC7C,uCAAuC,EAAE,6BAA6B;IACtE,kEAAkE,EAAE,sBAAsB;IAC1F,iFAAiF,EAAE,cAAc;IACjG,2BAA2B,EAAE,iBAAiB;IAC9C,qCAAqC,EAAE,mBAAmB;IAC1D,kCAAkC,EAAE,YAAY;IAChD,+BAA+B,EAAE,UAAU;IAC3C,6BAA6B,EAAE,kBAAkB;IACjD,sDAAsD,EAAE,UAAU;IAClE,+EAA+E,EAAE,aAAa;IAC9F,gCAAgC,EAAE,yDAAyD;IAC3F,oDAAoD,EAAE,iCAAiC;IACvF,kCAAkC,EAAE,8BAA8B;IAClE,gCAAgC,EAAE,mBAAmB;IACrD,kBAAkB,EAAE,mBAAmB;IACvC,uBAAuB,EAAE,mBAAmB;IAC5C,+CAA+C,EAAE,iCAAiC;CAClF,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,qBAAqB,GAAG;IAC7B,2CAA2C,EAAE,oFAAoF;IACjI,aAAa,EAAE,wBAAwB;IACvC,oBAAoB,EAAE,yBAAyB;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d,CAAC;AACD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAyB,EAAE,gBAAwB;IACtF,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,IAAI,gBAAgB,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAC;AAC3G,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAClC,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import type { AssistantMessage } from \"../types.ts\";\n\n/**\n * Regex patterns to detect context overflow errors from different providers.\n *\n * These patterns match error messages returned when the input exceeds\n * the model's context window.\n *\n * Provider-specific patterns (with example error messages):\n *\n * - Anthropic: \"prompt is too long: 213462 tokens > 200000 maximum\"\n * - Anthropic: \"413 {\\\"error\\\":{\\\"type\\\":\\\"request_too_large\\\",\\\"message\\\":\\\"Request exceeds the maximum size\\\"}}\"\n * - OpenAI: \"Your input exceeds the context window of this model\"\n * - OpenAI/LiteLLM: \"Requested token count exceeds the model's maximum context length of 131072 tokens\"\n * - OpenAI-compatible: \"Input length (265330) exceeds model's maximum context length (262144).\"\n * - Google: \"The input token count (1196265) exceeds the maximum number of tokens allowed (1048575)\"\n * - xAI: \"This model's maximum prompt length is 131072 but the request contains 537812 tokens\"\n * - Groq: \"Please reduce the length of the messages or completion\"\n * - OpenRouter: \"This endpoint's maximum context length is X tokens. However, you requested about Y tokens\"\n * - OpenRouter/Poolside: \"Input length X exceeds the maximum allowed input length of Y tokens.\"\n * - Together AI: \"The input (X tokens) is longer than the model's context length (Y tokens).\"\n * - llama.cpp: \"the request exceeds the available context size, try increasing it\"\n * - LM Studio: \"tokens to keep from the initial prompt is greater than the context length\"\n * - GitHub Copilot: \"prompt token count of X exceeds the limit of Y\"\n * - MiniMax: \"invalid params, context window exceeds limit\"\n * - Kimi For Coding: \"Your request exceeded model token limit: X (requested: Y)\"\n * - DS4: \"Prompt has X tokens, but the configured context size is Y tokens\"\n * - Cerebras: \"400/413 status code (no body)\"\n * - Mistral: \"Prompt contains X tokens ... too large for model with Y maximum context length\"\n * - z.ai: Does NOT error, accepts overflow silently - handled via usage.input > contextWindow\n * - Xiaomi MiMo: Truncates input to fill contextWindow exactly, then returns finish_reason \"length\"\n * with output=0 (no room left to generate). Detected via stopReason \"length\" + zero output +\n * input filling the context window.\n * - DashScope/Qwen: \"Range of input length should be [1, X]\" (HTTP 400 invalid_parameter_error)\n * - Ollama: Some deployments truncate silently, others return errors like \"prompt too long; exceeded max context length by X tokens\"\n */\nconst OVERFLOW_PATTERNS = [\n\t/prompt is too long/i, // Anthropic token overflow\n\t/request_too_large/i, // Anthropic request byte-size overflow (HTTP 413)\n\t/input is too long for requested model/i, // Amazon Bedrock\n\t/exceeds the context window/i, // OpenAI (Completions & Responses API)\n\t/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\\d,]+ tokens?|\\s*\\([\\d,]+\\))/i, // OpenAI-compatible proxies (LiteLLM)\n\t/input token count.*exceeds the maximum/i, // Google (Gemini)\n\t/maximum prompt length is \\d+/i, // xAI (Grok)\n\t/reduce the length of the messages/i, // Groq\n\t/maximum context length is \\d+ tokens/i, // OpenRouter (most backends)\n\t/exceeds (?:the )?maximum allowed input length of [\\d,]+ tokens?/i, // OpenRouter/Poolside\n\t/input \\(\\d+ tokens\\) is longer than the model'?s context length \\(\\d+ tokens\\)/i, // Together AI\n\t/exceeds the limit of \\d+/i, // GitHub Copilot\n\t/exceeds the available context size/i, // llama.cpp server\n\t/greater than the context length/i, // LM Studio\n\t/context window exceeds limit/i, // MiniMax\n\t/exceeded model token limit/i, // Kimi For Coding\n\t/too large for model with \\d+ maximum context length/i, // Mistral\n\t/prompt has [\\d,]+ tokens?, but the configured context size is [\\d,]+ tokens?/i, // DS4 server\n\t/model_context_window_exceeded/i, // z.ai non-standard finish_reason surfaced as error text\n\t/prompt too long; exceeded (?:max )?context length/i, // Ollama explicit overflow error\n\t/range of input length should be/i, // DashScope / Qwen Token Plan\n\t/context[_ ]length[_ ]exceeded/i, // Generic fallback\n\t/too many tokens/i, // Generic fallback\n\t/token limit exceeded/i, // Generic fallback\n\t/^4(?:00|13)\\s*(?:status code)?\\s*\\(no body\\)/i, // Cerebras: 400/413 with no body\n];\n\n/**\n * Patterns that indicate non-overflow errors (e.g. rate limiting, server errors).\n * Error messages matching any of these are excluded from overflow detection\n * even if they also match an OVERFLOW_PATTERN.\n *\n * Example: Bedrock formats throttling errors as \"ThrottlingException: Too many tokens,\n * please wait before trying again.\" which would match the /too many tokens/i overflow\n * pattern without this exclusion.\n */\nconst NON_OVERFLOW_PATTERNS = [\n\t/^(Throttling error|Service unavailable):/i, // AWS Bedrock non-overflow errors (human-readable prefixes from formatBedrockError)\n\t/rate limit/i, // Generic rate limiting\n\t/too many requests/i, // Generic HTTP 429 style\n];\n\n/**\n * Check if an assistant message represents a context overflow error.\n *\n * This handles three cases:\n * 1. Error-based overflow: Most providers return stopReason \"error\" with a\n * specific error message pattern.\n * 2. Silent overflow: Some providers accept overflow requests and return\n * successfully. For these, we check if usage.input exceeds the context window.\n * 3. Length-stop overflow: Xiaomi MiMo can return \"length\" with zero output when\n * the input fills the context window.\n *\n * ## Reliability by Provider\n *\n * **Reliable detection (returns error with detectable message):**\n * - Anthropic: \"prompt is too long: X tokens > Y maximum\" or \"request_too_large\"\n * - OpenAI (Completions & Responses): \"exceeds the context window\", \"exceeds the model's maximum context length of X tokens\", or \"exceeds model's maximum context length (X)\"\n * - Google Gemini: \"input token count exceeds the maximum\"\n * - xAI (Grok): \"maximum prompt length is X but request contains Y\"\n * - Groq: \"reduce the length of the messages\"\n * - Cerebras: 400/413 status code (no body)\n * - Mistral: \"Prompt contains X tokens ... too large for model with Y maximum context length\"\n * - OpenRouter (most backends): \"maximum context length is X tokens\"\n * - OpenRouter/Poolside: \"Input length X exceeds the maximum allowed input length of Y tokens.\"\n * - Together AI: \"The input (X tokens) is longer than the model's context length (Y tokens).\"\n * - llama.cpp: \"exceeds the available context size\"\n * - LM Studio: \"greater than the context length\"\n * - Kimi For Coding: \"exceeded model token limit: X (requested: Y)\"\n * - DS4: \"Prompt has X tokens, but the configured context size is Y tokens\"\n * - DashScope/Qwen: \"Range of input length should be [1, X]\"\n *\n * **Unreliable detection:**\n * - z.ai: Sometimes accepts overflow silently (detectable via usage.input > contextWindow),\n * sometimes returns rate limit errors. Pass contextWindow param to detect silent overflow.\n * - Xiaomi MiMo: Truncates input to fit contextWindow then returns stopReason \"length\" with\n * output=0. Pass contextWindow param to detect via the \"filled context + zero output\" signal.\n * - Ollama: May truncate input silently for some setups, but may also return explicit\n * overflow errors that match the patterns above. Silent truncation still cannot be\n * detected here because we do not know the expected token count.\n *\n * ## Custom Providers\n *\n * If you've added custom models via settings.json, this function may not detect\n * overflow errors from those providers. To add support:\n *\n * 1. Send a request that exceeds the model's context window\n * 2. Check the errorMessage in the response\n * 3. Create a regex pattern that matches the error\n * 4. The pattern should be added to OVERFLOW_PATTERNS in this file, or\n * check the errorMessage yourself before calling this function\n *\n * @param message - The assistant message to check\n * @param contextWindow - Optional context window size for detecting silent overflow (z.ai)\n * @returns true if the message indicates a context overflow\n */\nexport function isContextOverflow(message: AssistantMessage, contextWindow?: number): boolean {\n\t// Case 1: Check error message patterns\n\tif (message.stopReason === \"error\" && message.errorMessage) {\n\t\t// Skip messages matching known non-overflow patterns (e.g. throttling / rate-limit)\n\t\tconst isNonOverflow = NON_OVERFLOW_PATTERNS.some((p) => p.test(message.errorMessage!));\n\t\tif (!isNonOverflow && OVERFLOW_PATTERNS.some((p) => p.test(message.errorMessage!))) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Case 2: Silent overflow (z.ai style) - successful but usage exceeds context\n\tif (contextWindow && message.stopReason === \"stop\") {\n\t\tconst inputTokens = message.usage.input + message.usage.cacheRead;\n\t\tif (inputTokens > contextWindow) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Case 3: Length-stop overflow (Xiaomi MiMo style) - server truncates oversized input\n\t// to fit the context window, leaving no room for output. Returns stopReason \"length\"\n\t// with output=0 and input+cacheRead filling the context window.\n\tif (contextWindow && message.stopReason === \"length\" && message.usage.output === 0) {\n\t\tconst inputTokens = message.usage.input + message.usage.cacheRead;\n\t\tif (inputTokens >= contextWindow * 0.99) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n/**\n * Check whether a length stop ended below the caller or model's intended output limit.\n * Such responses may be caused by context pressure or provider-side truncation, so callers\n * can make one bounded compact-and-retry attempt. `desiredMaxOutput` must be the original\n * limit before any context-based clamping.\n */\nexport function isRecoverableLength(message: AssistantMessage, desiredMaxOutput: number): boolean {\n\treturn message.stopReason === \"length\" && desiredMaxOutput > 0 && message.usage.output < desiredMaxOutput;\n}\n\n/**\n * Get the overflow patterns for testing purposes.\n */\nexport function getOverflowPatterns(): RegExp[] {\n\treturn [...OVERFLOW_PATTERNS];\n}\n"]}
1
+ {"version":3,"file":"overflow.js","sourceRoot":"","sources":["../../src/utils/overflow.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,iBAAiB,GAAG;IACzB,qBAAqB,EAAE,2BAA2B;IAClD,oBAAoB,EAAE,kDAAkD;IACxE,wCAAwC,EAAE,iBAAiB;IAC3D,6BAA6B,EAAE,uCAAuC;IACtE,4FAA4F,EAAE,sCAAsC;IACpI,yCAAyC,EAAE,kBAAkB;IAC7D,+BAA+B,EAAE,aAAa;IAC9C,oCAAoC,EAAE,OAAO;IAC7C,uCAAuC,EAAE,6BAA6B;IACtE,kEAAkE,EAAE,sBAAsB;IAC1F,iFAAiF,EAAE,cAAc;IACjG,2BAA2B,EAAE,iBAAiB;IAC9C,qCAAqC,EAAE,mBAAmB;IAC1D,kCAAkC,EAAE,YAAY;IAChD,+BAA+B,EAAE,UAAU;IAC3C,6BAA6B,EAAE,kBAAkB;IACjD,sDAAsD,EAAE,UAAU;IAClE,+EAA+E,EAAE,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AAC;IAED,sFAAsF;IACtF,qFAAqF;IACrF,gEAAgE;IAChE,IAAI,aAAa,IAAI,OAAO,CAAC,UAAU,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpF,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;QAClE,IAAI,WAAW,IAAI,aAAa,GAAG,IAAI,EAAE,CAAC;YACzC,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AACD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAyB,EAAE,gBAAwB;IACtF,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,IAAI,gBAAgB,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAC;AAC3G,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAClC,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import type { AssistantMessage } from \"../types.ts\";\n\n/**\n * Regex patterns to detect context overflow errors from different providers.\n *\n * These patterns match error messages returned when the input exceeds\n * the model's context window.\n *\n * Provider-specific patterns (with example error messages):\n *\n * - Anthropic: \"prompt is too long: 213462 tokens > 200000 maximum\"\n * - Anthropic: \"413 {\\\"error\\\":{\\\"type\\\":\\\"request_too_large\\\",\\\"message\\\":\\\"Request exceeds the maximum size\\\"}}\"\n * - OpenAI: \"Your input exceeds the context window of this model\"\n * - OpenAI/LiteLLM: \"Requested token count exceeds the model's maximum context length of 131072 tokens\"\n * - OpenAI-compatible: \"Input length (265330) exceeds model's maximum context length (262144).\"\n * - Google: \"The input token count (1196265) exceeds the maximum number of tokens allowed (1048575)\"\n * - xAI: \"This model's maximum prompt length is 131072 but the request contains 537812 tokens\"\n * - Groq: \"Please reduce the length of the messages or completion\"\n * - OpenRouter: \"This endpoint's maximum context length is X tokens. However, you requested about Y tokens\"\n * - OpenRouter/Poolside: \"Input length X exceeds the maximum allowed input length of Y tokens.\"\n * - Together AI: \"The input (X tokens) is longer than the model's context length (Y tokens).\"\n * - llama.cpp: \"the request exceeds the available context size, try increasing it\"\n * - LM Studio: \"tokens to keep from the initial prompt is greater than the context length\"\n * - GitHub Copilot: \"prompt token count of X exceeds the limit of Y\"\n * - MiniMax: \"invalid params, context window exceeds limit\"\n * - Kimi For Coding: \"Your request exceeded model token limit: X (requested: Y)\"\n * - DS4: \"Prompt has X tokens, but the configured context size is Y tokens\"\n * - Cerebras: \"400/413 status code (no body)\"\n * - Gateways: \"413 Request body too large\" / \"Request Entity Too Large\" / \"Payload Too Large\" (byte-size overflow)\n * - Mistral: \"Prompt contains X tokens ... too large for model with Y maximum context length\"\n * - z.ai: Does NOT error, accepts overflow silently - handled via usage.input > contextWindow\n * - Xiaomi MiMo: Truncates input to fill contextWindow exactly, then returns finish_reason \"length\"\n * with output=0 (no room left to generate). Detected via stopReason \"length\" + zero output +\n * input filling the context window.\n * - DashScope/Qwen: \"Range of input length should be [1, X]\" (HTTP 400 invalid_parameter_error)\n * - Ollama: Some deployments truncate silently, others return errors like \"prompt too long; exceeded max context length by X tokens\"\n */\nconst OVERFLOW_PATTERNS = [\n\t/prompt is too long/i, // Anthropic token overflow\n\t/request_too_large/i, // Anthropic request byte-size overflow (HTTP 413)\n\t/input is too long for requested model/i, // Amazon Bedrock\n\t/exceeds the context window/i, // OpenAI (Completions & Responses API)\n\t/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\\d,]+ tokens?|\\s*\\([\\d,]+\\))/i, // OpenAI-compatible proxies (LiteLLM)\n\t/input token count.*exceeds the maximum/i, // Google (Gemini)\n\t/maximum prompt length is \\d+/i, // xAI (Grok)\n\t/reduce the length of the messages/i, // Groq\n\t/maximum context length is \\d+ tokens/i, // OpenRouter (most backends)\n\t/exceeds (?:the )?maximum allowed input length of [\\d,]+ tokens?/i, // OpenRouter/Poolside\n\t/input \\(\\d+ tokens\\) is longer than the model'?s context length \\(\\d+ tokens\\)/i, // Together AI\n\t/exceeds the limit of \\d+/i, // GitHub Copilot\n\t/exceeds the available context size/i, // llama.cpp server\n\t/greater than the context length/i, // LM Studio\n\t/context window exceeds limit/i, // MiniMax\n\t/exceeded model token limit/i, // Kimi For Coding\n\t/too large for model with \\d+ maximum context length/i, // Mistral\n\t/prompt has [\\d,]+ tokens?, but the configured context size is [\\d,]+ tokens?/i, // DS4 server\n\t/model_context_window_exceeded/i, // z.ai non-standard finish_reason surfaced as error text\n\t/prompt too long; exceeded (?:max )?context length/i, // Ollama explicit overflow error\n\t/range of input length should be/i, // DashScope / Qwen Token Plan\n\t/context[_ ]length[_ ]exceeded/i, // Generic fallback\n\t/too many tokens/i, // Generic fallback\n\t/token limit exceeded/i, // Generic fallback\n\t/^4(?:00|13)\\s*(?:status code)?\\s*\\(no body\\)/i, // Cerebras: 400/413 with no body\n\t/(?:request[ _])?(?:body|entity|payload)[_ ]too[_ ]large/i, // Gateway HTTP 413 byte-size rejections (\"Request body too large\", \"Request Entity Too Large\", \"body_too_large\", \"Payload Too Large\"). Substring-anchored by design (JSON bodies lack an adjacent status code); a non-context size rejection (e.g. an oversized image) can over-match, which costs one bounded shrink-retry, never a wedge.\n];\n\n/**\n * Patterns that indicate non-overflow errors (e.g. rate limiting, server errors).\n * Error messages matching any of these are excluded from overflow detection\n * even if they also match an OVERFLOW_PATTERN.\n *\n * Example: Bedrock formats throttling errors as \"ThrottlingException: Too many tokens,\n * please wait before trying again.\" which would match the /too many tokens/i overflow\n * pattern without this exclusion.\n */\nconst NON_OVERFLOW_PATTERNS = [\n\t/^(Throttling error|Service unavailable):/i, // AWS Bedrock non-overflow errors (human-readable prefixes from formatBedrockError)\n\t/rate limit/i, // Generic rate limiting\n\t/too many requests/i, // Generic HTTP 429 style\n];\n\n/**\n * Check if an assistant message represents a context overflow error.\n *\n * This handles three cases:\n * 1. Error-based overflow: Most providers return stopReason \"error\" with a\n * specific error message pattern.\n * 2. Silent overflow: Some providers accept overflow requests and return\n * successfully. For these, we check if usage.input exceeds the context window.\n * 3. Length-stop overflow: Xiaomi MiMo can return \"length\" with zero output when\n * the input fills the context window.\n *\n * ## Reliability by Provider\n *\n * **Reliable detection (returns error with detectable message):**\n * - Anthropic: \"prompt is too long: X tokens > Y maximum\" or \"request_too_large\"\n * - OpenAI (Completions & Responses): \"exceeds the context window\", \"exceeds the model's maximum context length of X tokens\", or \"exceeds model's maximum context length (X)\"\n * - Google Gemini: \"input token count exceeds the maximum\"\n * - xAI (Grok): \"maximum prompt length is X but request contains Y\"\n * - Groq: \"reduce the length of the messages\"\n * - Cerebras: 400/413 status code (no body)\n * - Mistral: \"Prompt contains X tokens ... too large for model with Y maximum context length\"\n * - OpenRouter (most backends): \"maximum context length is X tokens\"\n * - OpenRouter/Poolside: \"Input length X exceeds the maximum allowed input length of Y tokens.\"\n * - Together AI: \"The input (X tokens) is longer than the model's context length (Y tokens).\"\n * - llama.cpp: \"exceeds the available context size\"\n * - LM Studio: \"greater than the context length\"\n * - Kimi For Coding: \"exceeded model token limit: X (requested: Y)\"\n * - DS4: \"Prompt has X tokens, but the configured context size is Y tokens\"\n * - DashScope/Qwen: \"Range of input length should be [1, X]\"\n *\n * **Unreliable detection:**\n * - z.ai: Sometimes accepts overflow silently (detectable via usage.input > contextWindow),\n * sometimes returns rate limit errors. Pass contextWindow param to detect silent overflow.\n * - Xiaomi MiMo: Truncates input to fit contextWindow then returns stopReason \"length\" with\n * output=0. Pass contextWindow param to detect via the \"filled context + zero output\" signal.\n * - Ollama: May truncate input silently for some setups, but may also return explicit\n * overflow errors that match the patterns above. Silent truncation still cannot be\n * detected here because we do not know the expected token count.\n *\n * ## Custom Providers\n *\n * If you've added custom models via settings.json, this function may not detect\n * overflow errors from those providers. To add support:\n *\n * 1. Send a request that exceeds the model's context window\n * 2. Check the errorMessage in the response\n * 3. Create a regex pattern that matches the error\n * 4. The pattern should be added to OVERFLOW_PATTERNS in this file, or\n * check the errorMessage yourself before calling this function\n *\n * @param message - The assistant message to check\n * @param contextWindow - Optional context window size for detecting silent overflow (z.ai)\n * @returns true if the message indicates a context overflow\n */\nexport function isContextOverflow(message: AssistantMessage, contextWindow?: number): boolean {\n\t// Case 1: Check error message patterns\n\tif (message.stopReason === \"error\" && message.errorMessage) {\n\t\t// Skip messages matching known non-overflow patterns (e.g. throttling / rate-limit)\n\t\tconst isNonOverflow = NON_OVERFLOW_PATTERNS.some((p) => p.test(message.errorMessage!));\n\t\tif (!isNonOverflow && OVERFLOW_PATTERNS.some((p) => p.test(message.errorMessage!))) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Case 2: Silent overflow (z.ai style) - successful but usage exceeds context\n\tif (contextWindow && message.stopReason === \"stop\") {\n\t\tconst inputTokens = message.usage.input + message.usage.cacheRead;\n\t\tif (inputTokens > contextWindow) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Case 3: Length-stop overflow (Xiaomi MiMo style) - server truncates oversized input\n\t// to fit the context window, leaving no room for output. Returns stopReason \"length\"\n\t// with output=0 and input+cacheRead filling the context window.\n\tif (contextWindow && message.stopReason === \"length\" && message.usage.output === 0) {\n\t\tconst inputTokens = message.usage.input + message.usage.cacheRead;\n\t\tif (inputTokens >= contextWindow * 0.99) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n/**\n * Check whether a length stop ended below the caller or model's intended output limit.\n * Such responses may be caused by context pressure or provider-side truncation, so callers\n * can make one bounded compact-and-retry attempt. `desiredMaxOutput` must be the original\n * limit before any context-based clamping.\n */\nexport function isRecoverableLength(message: AssistantMessage, desiredMaxOutput: number): boolean {\n\treturn message.stopReason === \"length\" && desiredMaxOutput > 0 && message.usage.output < desiredMaxOutput;\n}\n\n/**\n * Get the overflow patterns for testing purposes.\n */\nexport function getOverflowPatterns(): RegExp[] {\n\treturn [...OVERFLOW_PATTERNS];\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function getPiUserAgent(): string;
2
+ //# sourceMappingURL=pi-user-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-user-agent.d.ts","sourceRoot":"","sources":["../../src/utils/pi-user-agent.ts"],"names":[],"mappings":"AAgBA,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
@@ -0,0 +1,12 @@
1
+ function loadNodeOs() {
2
+ if (typeof process === "undefined" || !(process.versions?.node || process.versions?.bun)) {
3
+ return null;
4
+ }
5
+ return process.getBuiltinModule?.("node:os") ?? null;
6
+ }
7
+ // Keep runtime OS loading browser-safe. A top-level runtime import of node:os breaks browser/Vite builds.
8
+ const nodeOs = loadNodeOs();
9
+ export function getPiUserAgent() {
10
+ return nodeOs ? `pi (${nodeOs.platform()} ${nodeOs.release()}; ${nodeOs.arch()})` : "pi (browser)";
11
+ }
12
+ //# sourceMappingURL=pi-user-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-user-agent.js","sourceRoot":"","sources":["../../src/utils/pi-user-agent.ts"],"names":[],"mappings":"AAMA,SAAS,UAAU;IAClB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;QAC1F,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAQ,OAAsC,CAAC,gBAAgB,EAAE,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;AACtF,CAAC;AAED,0GAA0G;AAC1G,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;AAE5B,MAAM,UAAU,cAAc;IAC7B,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,CAAC,QAAQ,EAAE,IAAI,MAAM,CAAC,OAAO,EAAE,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC;AACpG,CAAC","sourcesContent":["import type * as NodeOs from \"node:os\";\n\ntype ProcessWithOsBuiltinModule = typeof process & {\n\tgetBuiltinModule?: (id: \"node:os\") => typeof NodeOs;\n};\n\nfunction loadNodeOs(): typeof NodeOs | null {\n\tif (typeof process === \"undefined\" || !(process.versions?.node || process.versions?.bun)) {\n\t\treturn null;\n\t}\n\treturn (process as ProcessWithOsBuiltinModule).getBuiltinModule?.(\"node:os\") ?? null;\n}\n\n// Keep runtime OS loading browser-safe. A top-level runtime import of node:os breaks browser/Vite builds.\nconst nodeOs = loadNodeOs();\n\nexport function getPiUserAgent(): string {\n\treturn nodeOs ? `pi (${nodeOs.platform()} ${nodeOs.release()}; ${nodeOs.arch()})` : \"pi (browser)\";\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-cache-ttl.d.ts","sourceRoot":"","sources":["../../src/utils/prompt-cache-ttl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,uBAAuB,EACvB,GAAG,EAEH,KAAK,EACL,uBAAuB,EACvB,WAAW,EACX,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAClD,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAM9D;AAkBD,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC,GAChC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,CAAC,CA6BlE;AAED,MAAM,MAAM,+BAA+B,GAAG,IAAI,CACjD,QAAQ,CAAC,uBAAuB,CAAC,EAC/B,oBAAoB,GACpB,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,GAClB,wBAAwB,GACxB,kBAAkB,GAClB,6BAA6B,CAC/B,GAAG;IACH,kBAAkB,CAAC,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;IACnE,sBAAsB,CAAC,EAAE,uBAAuB,CAAC,wB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4B,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CA4CrG"}
@@ -70,6 +70,7 @@ function detectOpenAICompletionsCompat(model) {
70
70
  const isCloudflareAiGateway = provider === "cloudflare-ai-gateway" || baseUrl.includes("gateway.ai.cloudflare.com");
71
71
  const isNvidia = provider === "nvidia" || baseUrl.includes("integrate.api.nvidia.com");
72
72
  const isAntLing = provider === "ant-ling" || baseUrl.includes("api.ant-ling.com");
73
+ const isDeepSeek = provider === "deepseek" || baseUrl.toLowerCase().includes("deepseek.com");
73
74
  const isNonStandard = isNvidia ||
74
75
  provider === "cerebras" ||
75
76
  baseUrl.includes("cerebras.ai") ||
@@ -77,7 +78,7 @@ function detectOpenAICompletionsCompat(model) {
77
78
  baseUrl.includes("api.x.ai") ||
78
79
  isTogether ||
79
80
  baseUrl.includes("chutes.ai") ||
80
- baseUrl.includes("deepseek.com") ||
81
+ isDeepSeek ||
81
82
  isZai ||
82
83
  isMoonshot ||
83
84
  provider === "opencode" ||
@@ -86,6 +87,7 @@ function detectOpenAICompletionsCompat(model) {
86
87
  isCloudflareAiGateway ||
87
88
  isAntLing;
88
89
  const useMaxTokens = baseUrl.includes("chutes.ai") ||
90
+ isDeepSeek ||
89
91
  isMoonshot ||
90
92
  isCloudflareAiGateway ||
91
93
  isTogether ||
@@ -93,7 +95,6 @@ function detectOpenAICompletionsCompat(model) {
93
95
  isAntLing ||
94
96
  isZai;
95
97
  const isGrok = provider === "xai" || baseUrl.includes("api.x.ai");
96
- const isDeepSeek = provider === "deepseek" || baseUrl.includes("deepseek.com");
97
98
  const isOpenRouterDeveloperRoleModel = isOpenRouter && (model.id.startsWith("anthropic/") || model.id.startsWith("openai/"));
98
99
  const openRouterCacheControlPrefixes = ["anthropic/", "qwen/", "google/"];
99
100
  const cacheControlModelId = model.id.startsWith("~") ? model.id.slice(1) : model.id;