@code-yeongyu/senpi 2026.9.4 → 2026.9.5

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 (1010) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/README.md +5 -4
  3. package/dist/cli/startup-ui.d.ts.map +1 -1
  4. package/dist/cli/startup-ui.js +2 -1
  5. package/dist/cli/startup-ui.js.map +1 -1
  6. package/dist/core/agent-session-runtime.js +2 -2
  7. package/dist/core/agent-session-runtime.js.map +1 -1
  8. package/dist/core/agent-session.d.ts +17 -1
  9. package/dist/core/agent-session.d.ts.map +1 -1
  10. package/dist/core/agent-session.js +86 -3
  11. package/dist/core/agent-session.js.map +1 -1
  12. package/dist/core/auth-storage.d.ts.map +1 -1
  13. package/dist/core/auth-storage.js +31 -41
  14. package/dist/core/auth-storage.js.map +1 -1
  15. package/dist/core/compaction/compaction.d.ts.map +1 -1
  16. package/dist/core/compaction/compaction.js +16 -7
  17. package/dist/core/compaction/compaction.js.map +1 -1
  18. package/dist/core/credential-pool/state-store.d.ts +1 -0
  19. package/dist/core/credential-pool/state-store.d.ts.map +1 -1
  20. package/dist/core/credential-pool/state-store.js +22 -2
  21. package/dist/core/credential-pool/state-store.js.map +1 -1
  22. package/dist/core/extensions/builtin/bash-timeout/index.d.ts.map +1 -1
  23. package/dist/core/extensions/builtin/bash-timeout/index.js +1 -5
  24. package/dist/core/extensions/builtin/bash-timeout/index.js.map +1 -1
  25. package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts +0 -2
  26. package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts.map +1 -1
  27. package/dist/core/extensions/builtin/bash-timeout/timeout.js +3 -4
  28. package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
  29. package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts +5 -0
  30. package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts.map +1 -1
  31. package/dist/core/extensions/builtin/compaction/model-usability-budget.js +11 -4
  32. package/dist/core/extensions/builtin/compaction/model-usability-budget.js.map +1 -1
  33. package/dist/core/extensions/builtin/goal/prompt.d.ts.map +1 -1
  34. package/dist/core/extensions/builtin/goal/prompt.js +1 -3
  35. package/dist/core/extensions/builtin/goal/prompt.js.map +1 -1
  36. package/dist/core/extensions/builtin/goal/store.d.ts.map +1 -1
  37. package/dist/core/extensions/builtin/goal/store.js +8 -20
  38. package/dist/core/extensions/builtin/goal/store.js.map +1 -1
  39. package/dist/core/extensions/builtin/goal/tool-registration.js +1 -1
  40. package/dist/core/extensions/builtin/goal/tool-registration.js.map +1 -1
  41. package/dist/core/extensions/builtin/hooks/trust-storage.d.ts.map +1 -1
  42. package/dist/core/extensions/builtin/hooks/trust-storage.js +3 -1
  43. package/dist/core/extensions/builtin/hooks/trust-storage.js.map +1 -1
  44. package/dist/core/extensions/builtin/imagegen/auth.d.ts.map +1 -1
  45. package/dist/core/extensions/builtin/imagegen/auth.js +10 -2
  46. package/dist/core/extensions/builtin/imagegen/auth.js.map +1 -1
  47. package/dist/core/extensions/builtin/loop/index.d.ts.map +1 -1
  48. package/dist/core/extensions/builtin/loop/index.js +20 -1
  49. package/dist/core/extensions/builtin/loop/index.js.map +1 -1
  50. package/dist/core/extensions/builtin/loop/store.d.ts +8 -6
  51. package/dist/core/extensions/builtin/loop/store.d.ts.map +1 -1
  52. package/dist/core/extensions/builtin/loop/store.js +54 -88
  53. package/dist/core/extensions/builtin/loop/store.js.map +1 -1
  54. package/dist/core/extensions/builtin/loop/tools.d.ts +6 -1
  55. package/dist/core/extensions/builtin/loop/tools.d.ts.map +1 -1
  56. package/dist/core/extensions/builtin/loop/tools.js +8 -1
  57. package/dist/core/extensions/builtin/loop/tools.js.map +1 -1
  58. package/dist/core/extensions/builtin/monitor-state-event.d.ts +2 -0
  59. package/dist/core/extensions/builtin/monitor-state-event.d.ts.map +1 -1
  60. package/dist/core/extensions/builtin/monitor-state-event.js.map +1 -1
  61. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts +9 -5
  62. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts.map +1 -1
  63. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js +20 -11
  64. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js.map +1 -1
  65. package/dist/core/extensions/builtin/recommended-models/index.d.ts +1 -1
  66. package/dist/core/extensions/builtin/recommended-models/index.d.ts.map +1 -1
  67. package/dist/core/extensions/builtin/recommended-models/index.js +1 -0
  68. package/dist/core/extensions/builtin/recommended-models/index.js.map +1 -1
  69. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
  70. package/dist/core/extensions/builtin/service-tier.js +12 -4
  71. package/dist/core/extensions/builtin/service-tier.js.map +1 -1
  72. package/dist/core/extensions/builtin/terminal/durable-command.d.ts +31 -0
  73. package/dist/core/extensions/builtin/terminal/durable-command.d.ts.map +1 -0
  74. package/dist/core/extensions/builtin/terminal/durable-command.js +96 -0
  75. package/dist/core/extensions/builtin/terminal/durable-command.js.map +1 -0
  76. package/dist/core/extensions/builtin/terminal/durable-file.d.ts +42 -0
  77. package/dist/core/extensions/builtin/terminal/durable-file.d.ts.map +1 -0
  78. package/dist/core/extensions/builtin/terminal/durable-file.js +102 -0
  79. package/dist/core/extensions/builtin/terminal/durable-file.js.map +1 -0
  80. package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
  81. package/dist/core/extensions/builtin/terminal/extension.js +226 -3
  82. package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
  83. package/dist/core/extensions/builtin/terminal/manager.d.ts +10 -0
  84. package/dist/core/extensions/builtin/terminal/manager.d.ts.map +1 -1
  85. package/dist/core/extensions/builtin/terminal/manager.js +21 -0
  86. package/dist/core/extensions/builtin/terminal/manager.js.map +1 -1
  87. package/dist/core/extensions/builtin/terminal/manifest-lease.d.ts +24 -0
  88. package/dist/core/extensions/builtin/terminal/manifest-lease.d.ts.map +1 -0
  89. package/dist/core/extensions/builtin/terminal/manifest-lease.js +105 -0
  90. package/dist/core/extensions/builtin/terminal/manifest-lease.js.map +1 -0
  91. package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -1
  92. package/dist/core/extensions/builtin/terminal/monitor-notify.js +5 -1
  93. package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -1
  94. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +42 -2
  95. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
  96. package/dist/core/extensions/builtin/terminal/monitor-registry.js +73 -2
  97. package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
  98. package/dist/core/extensions/builtin/terminal/monitor-status.d.ts.map +1 -1
  99. package/dist/core/extensions/builtin/terminal/monitor-status.js +21 -1
  100. package/dist/core/extensions/builtin/terminal/monitor-status.js.map +1 -1
  101. package/dist/core/extensions/builtin/terminal/prompt.d.ts.map +1 -1
  102. package/dist/core/extensions/builtin/terminal/prompt.js +9 -5
  103. package/dist/core/extensions/builtin/terminal/prompt.js.map +1 -1
  104. package/dist/core/extensions/builtin/terminal/restore.d.ts +56 -0
  105. package/dist/core/extensions/builtin/terminal/restore.d.ts.map +1 -0
  106. package/dist/core/extensions/builtin/terminal/restore.js +177 -0
  107. package/dist/core/extensions/builtin/terminal/restore.js.map +1 -0
  108. package/dist/core/extensions/builtin/terminal/shared.d.ts +25 -0
  109. package/dist/core/extensions/builtin/terminal/shared.d.ts.map +1 -1
  110. package/dist/core/extensions/builtin/terminal/shared.js +25 -0
  111. package/dist/core/extensions/builtin/terminal/shared.js.map +1 -1
  112. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.d.ts +91 -0
  113. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.d.ts.map +1 -0
  114. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.js +14 -0
  115. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.js.map +1 -0
  116. package/dist/core/extensions/builtin/terminal/terminal-manifest.d.ts +62 -0
  117. package/dist/core/extensions/builtin/terminal/terminal-manifest.d.ts.map +1 -0
  118. package/dist/core/extensions/builtin/terminal/terminal-manifest.js +204 -0
  119. package/dist/core/extensions/builtin/terminal/terminal-manifest.js.map +1 -0
  120. package/dist/core/extensions/builtin/terminal/tools/bash-input.d.ts.map +1 -1
  121. package/dist/core/extensions/builtin/terminal/tools/bash-input.js +3 -2
  122. package/dist/core/extensions/builtin/terminal/tools/bash-input.js.map +1 -1
  123. package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts.map +1 -1
  124. package/dist/core/extensions/builtin/terminal/tools/bash-output.js +5 -4
  125. package/dist/core/extensions/builtin/terminal/tools/bash-output.js.map +1 -1
  126. package/dist/core/extensions/builtin/terminal/tools/bash-resize.d.ts.map +1 -1
  127. package/dist/core/extensions/builtin/terminal/tools/bash-resize.js +3 -2
  128. package/dist/core/extensions/builtin/terminal/tools/bash-resize.js.map +1 -1
  129. package/dist/core/extensions/builtin/terminal/tools/context.d.ts +8 -0
  130. package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/terminal/tools/context.js +10 -0
  132. package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
  133. package/dist/core/extensions/builtin/terminal/tools/kill-bash.d.ts.map +1 -1
  134. package/dist/core/extensions/builtin/terminal/tools/kill-bash.js +5 -4
  135. package/dist/core/extensions/builtin/terminal/tools/kill-bash.js.map +1 -1
  136. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts +4 -1
  137. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
  138. package/dist/core/extensions/builtin/terminal/tools/monitor.js +114 -22
  139. package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
  140. package/dist/core/extensions/builtin/todotools/prompt.d.ts +2 -2
  141. package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
  142. package/dist/core/extensions/builtin/todotools/prompt.js +3 -6
  143. package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -1
  144. package/dist/core/extensions/builtin/tool-search/index.d.ts.map +1 -1
  145. package/dist/core/extensions/builtin/tool-search/index.js +1 -1
  146. package/dist/core/extensions/builtin/tool-search/index.js.map +1 -1
  147. package/dist/core/extensions/builtin/tool-search/native-search.d.ts +9 -4
  148. package/dist/core/extensions/builtin/tool-search/native-search.d.ts.map +1 -1
  149. package/dist/core/extensions/builtin/tool-search/native-search.js +11 -6
  150. package/dist/core/extensions/builtin/tool-search/native-search.js.map +1 -1
  151. package/dist/core/extensions/builtin/tool-search/native-support.d.ts +13 -0
  152. package/dist/core/extensions/builtin/tool-search/native-support.d.ts.map +1 -0
  153. package/dist/core/extensions/builtin/tool-search/native-support.js +45 -0
  154. package/dist/core/extensions/builtin/tool-search/native-support.js.map +1 -0
  155. package/dist/core/extensions/index.d.ts +1 -1
  156. package/dist/core/extensions/index.d.ts.map +1 -1
  157. package/dist/core/extensions/index.js.map +1 -1
  158. package/dist/core/extensions/runner.d.ts +5 -0
  159. package/dist/core/extensions/runner.d.ts.map +1 -1
  160. package/dist/core/extensions/runner.js +44 -1
  161. package/dist/core/extensions/runner.js.map +1 -1
  162. package/dist/core/extensions/types.d.ts +26 -3
  163. package/dist/core/extensions/types.d.ts.map +1 -1
  164. package/dist/core/extensions/types.js.map +1 -1
  165. package/dist/core/footer-data-provider.d.ts.map +1 -1
  166. package/dist/core/footer-data-provider.js +18 -1
  167. package/dist/core/footer-data-provider.js.map +1 -1
  168. package/dist/core/http-dispatcher.d.ts.map +1 -1
  169. package/dist/core/http-dispatcher.js +2 -0
  170. package/dist/core/http-dispatcher.js.map +1 -1
  171. package/dist/core/lockfile-policy.d.ts +11 -0
  172. package/dist/core/lockfile-policy.d.ts.map +1 -1
  173. package/dist/core/lockfile-policy.js +19 -0
  174. package/dist/core/lockfile-policy.js.map +1 -1
  175. package/dist/core/manual-continue.d.ts +13 -0
  176. package/dist/core/manual-continue.d.ts.map +1 -0
  177. package/dist/core/manual-continue.js +19 -0
  178. package/dist/core/manual-continue.js.map +1 -0
  179. package/dist/core/messages.d.ts.map +1 -1
  180. package/dist/core/messages.js +8 -2
  181. package/dist/core/messages.js.map +1 -1
  182. package/dist/core/model-config.d.ts.map +1 -1
  183. package/dist/core/model-config.js +3 -0
  184. package/dist/core/model-config.js.map +1 -1
  185. package/dist/core/provider-composer.d.ts.map +1 -1
  186. package/dist/core/provider-composer.js +13 -2
  187. package/dist/core/provider-composer.js.map +1 -1
  188. package/dist/core/retry-fallback/chains.d.ts +1 -13
  189. package/dist/core/retry-fallback/chains.d.ts.map +1 -1
  190. package/dist/core/retry-fallback/chains.js +3 -49
  191. package/dist/core/retry-fallback/chains.js.map +1 -1
  192. package/dist/core/retry-fallback/controller.d.ts.map +1 -1
  193. package/dist/core/retry-fallback/controller.js +4 -9
  194. package/dist/core/retry-fallback/controller.js.map +1 -1
  195. package/dist/core/retry-fallback/expansion.js +1 -1
  196. package/dist/core/retry-fallback/expansion.js.map +1 -1
  197. package/dist/core/retry-fallback/settings.d.ts +2 -4
  198. package/dist/core/retry-fallback/settings.d.ts.map +1 -1
  199. package/dist/core/retry-fallback/settings.js +7 -36
  200. package/dist/core/retry-fallback/settings.js.map +1 -1
  201. package/dist/core/sdk.d.ts.map +1 -1
  202. package/dist/core/sdk.js +1 -1
  203. package/dist/core/sdk.js.map +1 -1
  204. package/dist/core/session-manager.d.ts.map +1 -1
  205. package/dist/core/session-manager.js +10 -3
  206. package/dist/core/session-manager.js.map +1 -1
  207. package/dist/core/session-sidecar-store.d.ts +62 -0
  208. package/dist/core/session-sidecar-store.d.ts.map +1 -0
  209. package/dist/core/session-sidecar-store.js +149 -0
  210. package/dist/core/session-sidecar-store.js.map +1 -0
  211. package/dist/core/settings-manager.d.ts +5 -1
  212. package/dist/core/settings-manager.d.ts.map +1 -1
  213. package/dist/core/settings-manager.js +45 -15
  214. package/dist/core/settings-manager.js.map +1 -1
  215. package/dist/core/skills.d.ts.map +1 -1
  216. package/dist/core/skills.js +19 -2
  217. package/dist/core/skills.js.map +1 -1
  218. package/dist/core/terminal-settings.d.ts +3 -0
  219. package/dist/core/terminal-settings.d.ts.map +1 -1
  220. package/dist/core/terminal-settings.js.map +1 -1
  221. package/dist/core/tools/bash.d.ts.map +1 -1
  222. package/dist/core/tools/bash.js +1 -1
  223. package/dist/core/tools/bash.js.map +1 -1
  224. package/dist/core/tools/edit.d.ts.map +1 -1
  225. package/dist/core/tools/edit.js +2 -2
  226. package/dist/core/tools/edit.js.map +1 -1
  227. package/dist/core/tools/find.d.ts.map +1 -1
  228. package/dist/core/tools/find.js +2 -2
  229. package/dist/core/tools/find.js.map +1 -1
  230. package/dist/core/tools/grep.d.ts.map +1 -1
  231. package/dist/core/tools/grep.js +2 -2
  232. package/dist/core/tools/grep.js.map +1 -1
  233. package/dist/core/tools/ls.d.ts.map +1 -1
  234. package/dist/core/tools/ls.js +2 -2
  235. package/dist/core/tools/ls.js.map +1 -1
  236. package/dist/core/tools/read.d.ts.map +1 -1
  237. package/dist/core/tools/read.js +1 -1
  238. package/dist/core/tools/read.js.map +1 -1
  239. package/dist/core/tools/write.d.ts.map +1 -1
  240. package/dist/core/tools/write.js +3 -3
  241. package/dist/core/tools/write.js.map +1 -1
  242. package/dist/index.d.ts +1 -1
  243. package/dist/index.d.ts.map +1 -1
  244. package/dist/index.js.map +1 -1
  245. package/dist/main.d.ts.map +1 -1
  246. package/dist/main.js +2 -0
  247. package/dist/main.js.map +1 -1
  248. package/dist/modes/app-server/daemon/process.d.ts +33 -3
  249. package/dist/modes/app-server/daemon/process.d.ts.map +1 -1
  250. package/dist/modes/app-server/daemon/process.js +57 -6
  251. package/dist/modes/app-server/daemon/process.js.map +1 -1
  252. package/dist/modes/app-server/daemon.js +9 -1
  253. package/dist/modes/app-server/daemon.js.map +1 -1
  254. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  255. package/dist/modes/interactive/components/scoped-models-selector.js +5 -11
  256. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  257. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  258. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  259. package/dist/modes/interactive/components/settings-selector.js +21 -8
  260. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  261. package/dist/modes/interactive/components/thinking-selector.js +2 -2
  262. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  263. package/dist/modes/interactive/components/trust-selector.js +2 -2
  264. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  265. package/dist/modes/interactive/grok/welcome-card.d.ts.map +1 -1
  266. package/dist/modes/interactive/grok/welcome-card.js +5 -2
  267. package/dist/modes/interactive/grok/welcome-card.js.map +1 -1
  268. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  269. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  270. package/dist/modes/interactive/interactive-mode.js +83 -14
  271. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  272. package/dist/modes/interactive/version-label.d.ts +7 -0
  273. package/dist/modes/interactive/version-label.d.ts.map +1 -0
  274. package/dist/modes/interactive/version-label.js +9 -0
  275. package/dist/modes/interactive/version-label.js.map +1 -0
  276. package/dist/modes/rpc/host-ensure.d.ts +2 -0
  277. package/dist/modes/rpc/host-ensure.d.ts.map +1 -1
  278. package/dist/modes/rpc/host-ensure.js +77 -18
  279. package/dist/modes/rpc/host-ensure.js.map +1 -1
  280. package/dist/utils/version-check.d.ts.map +1 -1
  281. package/dist/utils/version-check.js +3 -4
  282. package/dist/utils/version-check.js.map +1 -1
  283. package/docs/compaction.md +2 -0
  284. package/docs/environment-variables.md +5 -0
  285. package/docs/extensions.md +22 -2
  286. package/docs/keybindings.md +1 -1
  287. package/docs/models.md +3 -0
  288. package/docs/quickstart.md +1 -1
  289. package/docs/rpc.md +1 -1
  290. package/docs/settings.md +13 -5
  291. package/docs/terminal-setup.md +27 -0
  292. package/docs/terminal-tools.md +35 -4
  293. package/docs/usage.md +5 -3
  294. package/node_modules/@anthropic-ai/sdk/CHANGELOG.md +96 -0
  295. package/node_modules/@anthropic-ai/sdk/README.md +1 -1
  296. package/node_modules/@anthropic-ai/sdk/core/credentials.d.mts.map +1 -1
  297. package/node_modules/@anthropic-ai/sdk/core/credentials.d.ts.map +1 -1
  298. package/node_modules/@anthropic-ai/sdk/core/credentials.js +5 -7
  299. package/node_modules/@anthropic-ai/sdk/core/credentials.js.map +1 -1
  300. package/node_modules/@anthropic-ai/sdk/core/credentials.mjs +5 -7
  301. package/node_modules/@anthropic-ai/sdk/core/credentials.mjs.map +1 -1
  302. package/node_modules/@anthropic-ai/sdk/core/middleware.d.mts.map +1 -1
  303. package/node_modules/@anthropic-ai/sdk/core/middleware.d.ts.map +1 -1
  304. package/node_modules/@anthropic-ai/sdk/core/middleware.js +4 -4
  305. package/node_modules/@anthropic-ai/sdk/core/middleware.js.map +1 -1
  306. package/node_modules/@anthropic-ai/sdk/core/middleware.mjs +4 -4
  307. package/node_modules/@anthropic-ai/sdk/core/middleware.mjs.map +1 -1
  308. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.mts +45 -0
  309. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.mts.map +1 -0
  310. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.ts +45 -0
  311. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.ts.map +1 -0
  312. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.js +58 -0
  313. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.js.map +1 -0
  314. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.mjs +54 -0
  315. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.mjs.map +1 -0
  316. package/node_modules/@anthropic-ai/sdk/internal/detect-platform.js +1 -1
  317. package/node_modules/@anthropic-ai/sdk/internal/detect-platform.js.map +1 -1
  318. package/node_modules/@anthropic-ai/sdk/internal/detect-platform.mjs +1 -1
  319. package/node_modules/@anthropic-ai/sdk/internal/detect-platform.mjs.map +1 -1
  320. package/node_modules/@anthropic-ai/sdk/internal/errors.d.mts.map +1 -1
  321. package/node_modules/@anthropic-ai/sdk/internal/errors.d.ts.map +1 -1
  322. package/node_modules/@anthropic-ai/sdk/internal/errors.js +3 -1
  323. package/node_modules/@anthropic-ai/sdk/internal/errors.js.map +1 -1
  324. package/node_modules/@anthropic-ai/sdk/internal/errors.mjs +3 -1
  325. package/node_modules/@anthropic-ai/sdk/internal/errors.mjs.map +1 -1
  326. package/node_modules/@anthropic-ai/sdk/internal/file-store.d.mts.map +1 -1
  327. package/node_modules/@anthropic-ai/sdk/internal/file-store.d.ts.map +1 -1
  328. package/node_modules/@anthropic-ai/sdk/internal/file-store.js +23 -25
  329. package/node_modules/@anthropic-ai/sdk/internal/file-store.js.map +1 -1
  330. package/node_modules/@anthropic-ai/sdk/internal/file-store.mjs +5 -6
  331. package/node_modules/@anthropic-ai/sdk/internal/file-store.mjs.map +1 -1
  332. package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.mts +9 -0
  333. package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.mts.map +1 -0
  334. package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.ts +9 -0
  335. package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.ts.map +1 -0
  336. package/node_modules/@anthropic-ai/sdk/internal/node.browser.js +22 -0
  337. package/node_modules/@anthropic-ai/sdk/internal/node.browser.js.map +1 -0
  338. package/node_modules/@anthropic-ai/sdk/internal/node.browser.mjs +19 -0
  339. package/node_modules/@anthropic-ai/sdk/internal/node.browser.mjs.map +1 -0
  340. package/node_modules/@anthropic-ai/sdk/internal/node.d.mts +14 -0
  341. package/node_modules/@anthropic-ai/sdk/internal/node.d.mts.map +1 -0
  342. package/node_modules/@anthropic-ai/sdk/internal/node.d.ts +14 -0
  343. package/node_modules/@anthropic-ai/sdk/internal/node.d.ts.map +1 -0
  344. package/node_modules/@anthropic-ai/sdk/internal/node.js +24 -0
  345. package/node_modules/@anthropic-ai/sdk/internal/node.js.map +1 -0
  346. package/node_modules/@anthropic-ai/sdk/internal/node.mjs +14 -0
  347. package/node_modules/@anthropic-ai/sdk/internal/node.mjs.map +1 -0
  348. package/node_modules/@anthropic-ai/sdk/internal/parse.js +1 -1
  349. package/node_modules/@anthropic-ai/sdk/internal/parse.js.map +1 -1
  350. package/node_modules/@anthropic-ai/sdk/internal/parse.mjs +1 -1
  351. package/node_modules/@anthropic-ai/sdk/internal/parse.mjs.map +1 -1
  352. package/node_modules/@anthropic-ai/sdk/internal/uploads.js +10 -6
  353. package/node_modules/@anthropic-ai/sdk/internal/uploads.js.map +1 -1
  354. package/node_modules/@anthropic-ai/sdk/internal/uploads.mjs +10 -6
  355. package/node_modules/@anthropic-ai/sdk/internal/uploads.mjs.map +1 -1
  356. package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.mts +6 -0
  357. package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.mts.map +1 -1
  358. package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.ts +6 -0
  359. package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.ts.map +1 -1
  360. package/node_modules/@anthropic-ai/sdk/internal/utils/values.js +7 -0
  361. package/node_modules/@anthropic-ai/sdk/internal/utils/values.js.map +1 -1
  362. package/node_modules/@anthropic-ai/sdk/internal/utils/values.mjs +6 -0
  363. package/node_modules/@anthropic-ai/sdk/internal/utils/values.mjs.map +1 -1
  364. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.d.mts.map +1 -1
  365. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.d.ts.map +1 -1
  366. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.js +6 -4
  367. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.js.map +1 -1
  368. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs +4 -2
  369. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs.map +1 -1
  370. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.d.mts.map +1 -1
  371. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.d.ts.map +1 -1
  372. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.js +3 -4
  373. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.js.map +1 -1
  374. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs +1 -2
  375. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs.map +1 -1
  376. package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.js +1 -1
  377. package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.js.map +1 -1
  378. package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.mjs +1 -1
  379. package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.mjs.map +1 -1
  380. package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.js +1 -1
  381. package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.js.map +1 -1
  382. package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs +1 -1
  383. package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs.map +1 -1
  384. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.d.mts.map +1 -1
  385. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.d.ts.map +1 -1
  386. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.js +2 -3
  387. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.js.map +1 -1
  388. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.mjs +2 -3
  389. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.mjs.map +1 -1
  390. package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.js +1 -1
  391. package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.js.map +1 -1
  392. package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.mjs +1 -1
  393. package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.mjs.map +1 -1
  394. package/node_modules/@anthropic-ai/sdk/lib/middleware.d.mts.map +1 -1
  395. package/node_modules/@anthropic-ai/sdk/lib/middleware.d.ts.map +1 -1
  396. package/node_modules/@anthropic-ai/sdk/lib/middleware.js +30 -7
  397. package/node_modules/@anthropic-ai/sdk/lib/middleware.js.map +1 -1
  398. package/node_modules/@anthropic-ai/sdk/lib/middleware.mjs +30 -7
  399. package/node_modules/@anthropic-ai/sdk/lib/middleware.mjs.map +1 -1
  400. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.mts +3 -2
  401. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.mts.map +1 -1
  402. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.ts +3 -2
  403. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.ts.map +1 -1
  404. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.js +3 -46
  405. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.js.map +1 -1
  406. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.mjs +3 -46
  407. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.mjs.map +1 -1
  408. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.mts +131 -0
  409. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.mts.map +1 -0
  410. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.ts +131 -0
  411. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.ts.map +1 -0
  412. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.js +45 -0
  413. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.js.map +1 -0
  414. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.mjs +41 -0
  415. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.mjs.map +1 -0
  416. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.d.mts.map +1 -1
  417. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.d.ts.map +1 -1
  418. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.js +35 -6
  419. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.js.map +1 -1
  420. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs +35 -6
  421. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs.map +1 -1
  422. package/node_modules/@anthropic-ai/sdk/package.json +4 -11
  423. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.mts +1 -1
  424. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.mts.map +1 -1
  425. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.ts +1 -1
  426. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.ts.map +1 -1
  427. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.js.map +1 -1
  428. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.mjs.map +1 -1
  429. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.mts +13 -9
  430. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.mts.map +1 -1
  431. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.ts +13 -9
  432. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.ts.map +1 -1
  433. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.js +4 -0
  434. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.js.map +1 -1
  435. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs +4 -0
  436. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs.map +1 -1
  437. package/node_modules/@anthropic-ai/sdk/resources/beta/deployment-runs.d.mts +6 -6
  438. package/node_modules/@anthropic-ai/sdk/resources/beta/deployment-runs.d.ts +6 -6
  439. package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.mts +3 -2
  440. package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.mts.map +1 -1
  441. package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.ts +3 -2
  442. package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.ts.map +1 -1
  443. package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.mts +28 -1
  444. package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.mts.map +1 -1
  445. package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.ts +28 -1
  446. package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.ts.map +1 -1
  447. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.mts +8 -1
  448. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.mts.map +1 -1
  449. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.ts +8 -1
  450. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.ts.map +1 -1
  451. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.js.map +1 -1
  452. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.mjs.map +1 -1
  453. package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.mts +25 -5
  454. package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.mts.map +1 -1
  455. package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.ts +25 -5
  456. package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.ts.map +1 -1
  457. package/node_modules/@anthropic-ai/sdk/resources/beta/files.js +6 -6
  458. package/node_modules/@anthropic-ai/sdk/resources/beta/files.js.map +1 -1
  459. package/node_modules/@anthropic-ai/sdk/resources/beta/files.mjs +7 -7
  460. package/node_modules/@anthropic-ai/sdk/resources/beta/files.mjs.map +1 -1
  461. package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.mts +5 -4
  462. package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.mts.map +1 -1
  463. package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.ts +5 -4
  464. package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.ts.map +1 -1
  465. package/node_modules/@anthropic-ai/sdk/resources/beta/index.js +11 -9
  466. package/node_modules/@anthropic-ai/sdk/resources/beta/index.js.map +1 -1
  467. package/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs +1 -0
  468. package/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs.map +1 -1
  469. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.mts +12 -9
  470. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.mts.map +1 -1
  471. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.ts +12 -9
  472. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.ts.map +1 -1
  473. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.mts +8 -5
  474. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
  475. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.ts +8 -5
  476. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
  477. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.mts +1 -1
  478. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.mts.map +1 -1
  479. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.ts +1 -1
  480. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.ts.map +1 -1
  481. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.js.map +1 -1
  482. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.mjs.map +1 -1
  483. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.mts +198 -29
  484. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.mts.map +1 -1
  485. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.ts +198 -29
  486. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.ts.map +1 -1
  487. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.js.map +1 -1
  488. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.mjs.map +1 -1
  489. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.mts +177 -0
  490. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.mts.map +1 -0
  491. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.ts +177 -0
  492. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.ts.map +1 -0
  493. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.js +56 -0
  494. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.js.map +1 -0
  495. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.mjs +52 -0
  496. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.mjs.map +1 -0
  497. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.mts +74 -0
  498. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.mts.map +1 -0
  499. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.ts +74 -0
  500. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.ts.map +1 -0
  501. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.js +52 -0
  502. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.js.map +1 -0
  503. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.mjs +48 -0
  504. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.mjs.map +1 -0
  505. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.mts +272 -0
  506. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.mts.map +1 -0
  507. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.ts +272 -0
  508. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.ts.map +1 -0
  509. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.js +119 -0
  510. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.js.map +1 -0
  511. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.mjs +115 -0
  512. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.mjs.map +1 -0
  513. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.mts +14 -0
  514. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.mts.map +1 -0
  515. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.ts +14 -0
  516. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.ts.map +1 -0
  517. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.js +21 -0
  518. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.js.map +1 -0
  519. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.mjs +16 -0
  520. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.mjs.map +1 -0
  521. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.mts +4 -0
  522. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.mts.map +1 -0
  523. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.ts +4 -0
  524. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.ts.map +1 -0
  525. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.js +11 -0
  526. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.js.map +1 -0
  527. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.mjs +5 -0
  528. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.mjs.map +1 -0
  529. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.mts +353 -0
  530. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.mts.map +1 -0
  531. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.ts +353 -0
  532. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.ts.map +1 -0
  533. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.js +169 -0
  534. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.js.map +1 -0
  535. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.mjs +165 -0
  536. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.mjs.map +1 -0
  537. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.mts +3 -0
  538. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.mts.map +1 -0
  539. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.ts +3 -0
  540. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.ts.map +1 -0
  541. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.js +9 -0
  542. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.js.map +1 -0
  543. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.mjs +4 -0
  544. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.mjs.map +1 -0
  545. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.mts +468 -0
  546. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.mts.map +1 -0
  547. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.ts +468 -0
  548. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.ts.map +1 -0
  549. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.js +198 -0
  550. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.js.map +1 -0
  551. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.mjs +193 -0
  552. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.mjs.map +1 -0
  553. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.mts +124 -0
  554. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.mts.map +1 -0
  555. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.ts +124 -0
  556. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.ts.map +1 -0
  557. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.js +114 -0
  558. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.js.map +1 -0
  559. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.mjs +110 -0
  560. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.mjs.map +1 -0
  561. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.mts +2 -0
  562. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.mts.map +1 -0
  563. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.ts +2 -0
  564. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.ts.map +1 -0
  565. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.js +6 -0
  566. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.js.map +1 -0
  567. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.mjs +3 -0
  568. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.mjs.map +1 -0
  569. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.mts +2 -0
  570. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.mts.map +1 -0
  571. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.ts +2 -0
  572. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.ts.map +1 -0
  573. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.js +6 -0
  574. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.js.map +1 -0
  575. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.mjs +3 -0
  576. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.mjs.map +1 -0
  577. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.mts +11 -0
  578. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.mts.map +1 -0
  579. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.ts +11 -0
  580. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.ts.map +1 -0
  581. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.js +25 -0
  582. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.js.map +1 -0
  583. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.mjs +12 -0
  584. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.mjs.map +1 -0
  585. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.mts +162 -0
  586. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.mts.map +1 -0
  587. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.ts +162 -0
  588. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.ts.map +1 -0
  589. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.js +76 -0
  590. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.js.map +1 -0
  591. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.mjs +72 -0
  592. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.mjs.map +1 -0
  593. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.mts +73 -0
  594. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.mts.map +1 -0
  595. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.ts +73 -0
  596. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.ts.map +1 -0
  597. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.js +62 -0
  598. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.js.map +1 -0
  599. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.mjs +57 -0
  600. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.mjs.map +1 -0
  601. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.mts +77 -0
  602. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.mts.map +1 -0
  603. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.ts +77 -0
  604. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.ts.map +1 -0
  605. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.js +31 -0
  606. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.js.map +1 -0
  607. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.mjs +27 -0
  608. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.mjs.map +1 -0
  609. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.mts +3 -0
  610. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.mts.map +1 -0
  611. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.ts +3 -0
  612. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.ts.map +1 -0
  613. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.js +9 -0
  614. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.js.map +1 -0
  615. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.mjs +4 -0
  616. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.mjs.map +1 -0
  617. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.mts +258 -0
  618. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.mts.map +1 -0
  619. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.ts +258 -0
  620. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.ts.map +1 -0
  621. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.js +174 -0
  622. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.js.map +1 -0
  623. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.mjs +169 -0
  624. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.mjs.map +1 -0
  625. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.mts +141 -0
  626. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.mts.map +1 -0
  627. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.ts +141 -0
  628. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.ts.map +1 -0
  629. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.js +125 -0
  630. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.js.map +1 -0
  631. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.mjs +121 -0
  632. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.mjs.map +1 -0
  633. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.mts +2 -0
  634. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.mts.map +1 -0
  635. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.ts +2 -0
  636. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.ts.map +1 -0
  637. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.js +6 -0
  638. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.js.map +1 -0
  639. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.mjs +3 -0
  640. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.mjs.map +1 -0
  641. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.mts +124 -0
  642. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.mts.map +1 -0
  643. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.ts +124 -0
  644. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.ts.map +1 -0
  645. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.js +67 -0
  646. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.js.map +1 -0
  647. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.mjs +63 -0
  648. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.mjs.map +1 -0
  649. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.mts +5 -0
  650. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.mts.map +1 -0
  651. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.ts +5 -0
  652. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.ts.map +1 -0
  653. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.js +13 -0
  654. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.js.map +1 -0
  655. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.mjs +6 -0
  656. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.mjs.map +1 -0
  657. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.mts +135 -0
  658. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.mts.map +1 -0
  659. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.ts +135 -0
  660. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.ts.map +1 -0
  661. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.js +102 -0
  662. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.js.map +1 -0
  663. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.mjs +98 -0
  664. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.mjs.map +1 -0
  665. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.mts +83 -0
  666. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.mts.map +1 -0
  667. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.ts +83 -0
  668. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.ts.map +1 -0
  669. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.js +34 -0
  670. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.js.map +1 -0
  671. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.mjs +30 -0
  672. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.mjs.map +1 -0
  673. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.mts +210 -0
  674. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.mts.map +1 -0
  675. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.ts +210 -0
  676. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.ts.map +1 -0
  677. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.js +189 -0
  678. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.js.map +1 -0
  679. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.mjs +185 -0
  680. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.mjs.map +1 -0
  681. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.mts +303 -0
  682. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.mts.map +1 -0
  683. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.ts +303 -0
  684. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.ts.map +1 -0
  685. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.js +112 -0
  686. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.js.map +1 -0
  687. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.mjs +107 -0
  688. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.mjs.map +1 -0
  689. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.mts +2 -0
  690. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.mts.map +1 -0
  691. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.ts +2 -0
  692. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.ts.map +1 -0
  693. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.js +6 -0
  694. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.js.map +1 -0
  695. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.mjs +3 -0
  696. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.mjs.map +1 -0
  697. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.mts +2 -0
  698. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.mts.map +1 -0
  699. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.ts +2 -0
  700. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.ts.map +1 -0
  701. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.js +6 -0
  702. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.js.map +1 -0
  703. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.mjs +3 -0
  704. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.mjs.map +1 -0
  705. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/events.d.mts +1 -1
  706. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/events.d.ts +1 -1
  707. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/sessions.d.mts +10 -10
  708. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/sessions.d.ts +10 -10
  709. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.mts +2 -1
  710. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.mts.map +1 -1
  711. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.ts +2 -1
  712. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.ts.map +1 -1
  713. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.js.map +1 -1
  714. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.mjs.map +1 -1
  715. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.mts +2 -2
  716. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.mts.map +1 -1
  717. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.ts +2 -2
  718. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.ts.map +1 -1
  719. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.js.map +1 -1
  720. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.mjs.map +1 -1
  721. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.mts +48 -120
  722. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.mts.map +1 -1
  723. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.ts +48 -120
  724. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.ts.map +1 -1
  725. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.js +12 -8
  726. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.js.map +1 -1
  727. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.mjs +12 -8
  728. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.mjs.map +1 -1
  729. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.mts +35 -138
  730. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.mts.map +1 -1
  731. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.ts +35 -138
  732. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.ts.map +1 -1
  733. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.js +18 -18
  734. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.js.map +1 -1
  735. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.mjs +18 -18
  736. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.mjs.map +1 -1
  737. package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.mts +21 -25
  738. package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.mts.map +1 -1
  739. package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.ts +21 -25
  740. package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.ts.map +1 -1
  741. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.mts +16 -17
  742. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.mts.map +1 -1
  743. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.ts +16 -17
  744. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.ts.map +1 -1
  745. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.js +21 -8
  746. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.js.map +1 -1
  747. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.mjs +21 -8
  748. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.mjs.map +1 -1
  749. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.mts +1 -3
  750. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.mts.map +1 -1
  751. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.ts +1 -3
  752. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.ts.map +1 -1
  753. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.js.map +1 -1
  754. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.mjs.map +1 -1
  755. package/node_modules/@anthropic-ai/sdk/src/core/credentials.ts +5 -7
  756. package/node_modules/@anthropic-ai/sdk/src/core/middleware.ts +4 -3
  757. package/node_modules/@anthropic-ai/sdk/src/helpers/beta/standard-schema.ts +99 -0
  758. package/node_modules/@anthropic-ai/sdk/src/internal/detect-platform.ts +1 -1
  759. package/node_modules/@anthropic-ai/sdk/src/internal/errors.ts +3 -1
  760. package/node_modules/@anthropic-ai/sdk/src/internal/file-store.ts +11 -10
  761. package/node_modules/@anthropic-ai/sdk/src/internal/node.browser.ts +22 -0
  762. package/node_modules/@anthropic-ai/sdk/src/internal/node.ts +14 -0
  763. package/node_modules/@anthropic-ai/sdk/src/internal/parse.ts +1 -1
  764. package/node_modules/@anthropic-ai/sdk/src/internal/uploads.ts +10 -7
  765. package/node_modules/@anthropic-ai/sdk/src/internal/utils/values.ts +7 -0
  766. package/node_modules/@anthropic-ai/sdk/src/lib/BetaMessageStream.ts +5 -3
  767. package/node_modules/@anthropic-ai/sdk/src/lib/MessageStream.ts +1 -3
  768. package/node_modules/@anthropic-ai/sdk/src/lib/credentials/credential-chain.ts +1 -1
  769. package/node_modules/@anthropic-ai/sdk/src/lib/credentials/identity-token.ts +1 -1
  770. package/node_modules/@anthropic-ai/sdk/src/lib/credentials/types.ts +2 -3
  771. package/node_modules/@anthropic-ai/sdk/src/lib/credentials/user-oauth.ts +1 -1
  772. package/node_modules/@anthropic-ai/sdk/src/lib/middleware.ts +33 -9
  773. package/node_modules/@anthropic-ai/sdk/src/lib/sessions/accumulate.ts +7 -49
  774. package/node_modules/@anthropic-ai/sdk/src/lib/standard-schema.ts +209 -0
  775. package/node_modules/@anthropic-ai/sdk/src/lib/tools/BetaToolRunner.ts +38 -6
  776. package/node_modules/@anthropic-ai/sdk/src/resources/beta/agents/agents.ts +1 -0
  777. package/node_modules/@anthropic-ai/sdk/src/resources/beta/beta.ts +45 -15
  778. package/node_modules/@anthropic-ai/sdk/src/resources/beta/deployment-runs.ts +6 -6
  779. package/node_modules/@anthropic-ai/sdk/src/resources/beta/deployments.ts +3 -2
  780. package/node_modules/@anthropic-ai/sdk/src/resources/beta/dreams.ts +42 -0
  781. package/node_modules/@anthropic-ai/sdk/src/resources/beta/environments/environments.ts +8 -1
  782. package/node_modules/@anthropic-ai/sdk/src/resources/beta/files.ts +34 -11
  783. package/node_modules/@anthropic-ai/sdk/src/resources/beta/index.ts +13 -7
  784. package/node_modules/@anthropic-ai/sdk/src/resources/beta/memory-stores/memories.ts +12 -9
  785. package/node_modules/@anthropic-ai/sdk/src/resources/beta/memory-stores/memory-versions.ts +8 -5
  786. package/node_modules/@anthropic-ai/sdk/src/resources/beta/messages/index.ts +5 -1
  787. package/node_modules/@anthropic-ai/sdk/src/resources/beta/messages/messages.ts +221 -38
  788. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/api-keys.ts +231 -0
  789. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/compliance-settings.ts +96 -0
  790. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/external-keys.ts +365 -0
  791. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/federation.ts +71 -0
  792. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/index.ts +31 -0
  793. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/issuers.ts +486 -0
  794. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules/index.ts +23 -0
  795. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules/rules.ts +624 -0
  796. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules/workspaces.ts +196 -0
  797. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules.ts +3 -0
  798. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation.ts +3 -0
  799. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/index.ts +92 -0
  800. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/invites.ts +207 -0
  801. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/organization.ts +269 -0
  802. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/rate-limits.ts +104 -0
  803. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts/index.ts +21 -0
  804. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts/service-accounts.ts +389 -0
  805. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts/workspaces.ts +217 -0
  806. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts.ts +3 -0
  807. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/users.ts +163 -0
  808. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/index.ts +43 -0
  809. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/members.ts +209 -0
  810. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/rate-limits.ts +113 -0
  811. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/service-accounts.ts +325 -0
  812. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/workspaces.ts +450 -0
  813. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces.ts +3 -0
  814. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization.ts +3 -0
  815. package/node_modules/@anthropic-ai/sdk/src/resources/beta/sessions/events.ts +1 -1
  816. package/node_modules/@anthropic-ai/sdk/src/resources/beta/sessions/sessions.ts +10 -10
  817. package/node_modules/@anthropic-ai/sdk/src/resources/beta/sessions/threads/threads.ts +2 -1
  818. package/node_modules/@anthropic-ai/sdk/src/resources/beta/skills/index.ts +7 -10
  819. package/node_modules/@anthropic-ai/sdk/src/resources/beta/skills/skills.ts +60 -150
  820. package/node_modules/@anthropic-ai/sdk/src/resources/beta/skills/versions.ts +43 -166
  821. package/node_modules/@anthropic-ai/sdk/src/resources/beta/user-profiles.ts +24 -27
  822. package/node_modules/@anthropic-ai/sdk/src/resources/beta/webhooks.ts +25 -29
  823. package/node_modules/@anthropic-ai/sdk/src/resources/messages/messages.ts +2 -8
  824. package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/fs-util.ts +6 -5
  825. package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/memories.ts +5 -3
  826. package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/node.browser.ts +1 -5
  827. package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/node.ts +122 -17
  828. package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/skills.ts +10 -43
  829. package/node_modules/@anthropic-ai/sdk/src/version.ts +1 -1
  830. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.d.mts.map +1 -1
  831. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.d.ts.map +1 -1
  832. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.js +13 -15
  833. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.js.map +1 -1
  834. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.mjs +3 -4
  835. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.mjs.map +1 -1
  836. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.d.mts.map +1 -1
  837. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.d.ts.map +1 -1
  838. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.js +6 -4
  839. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.js.map +1 -1
  840. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.mjs +5 -3
  841. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.mjs.map +1 -1
  842. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.mts +1 -2
  843. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.mts.map +1 -1
  844. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.ts +1 -2
  845. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.ts.map +1 -1
  846. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.js +0 -4
  847. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.js.map +1 -1
  848. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.mjs +0 -3
  849. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.mjs.map +1 -1
  850. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.mts +11 -9
  851. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.mts.map +1 -1
  852. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.ts +11 -9
  853. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.ts.map +1 -1
  854. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.js +96 -8
  855. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.js.map +1 -1
  856. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.mjs +96 -7
  857. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.mjs.map +1 -1
  858. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.mts +0 -8
  859. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.mts.map +1 -1
  860. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.ts +0 -8
  861. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.ts.map +1 -1
  862. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.js +20 -46
  863. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.js.map +1 -1
  864. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.mjs +9 -33
  865. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.mjs.map +1 -1
  866. package/node_modules/@anthropic-ai/sdk/version.d.mts +1 -1
  867. package/node_modules/@anthropic-ai/sdk/version.d.ts +1 -1
  868. package/node_modules/@anthropic-ai/sdk/version.js +1 -1
  869. package/node_modules/@anthropic-ai/sdk/version.mjs +1 -1
  870. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +45 -0
  871. package/node_modules/@code-yeongyu/senpi-codemode/README.md +4 -2
  872. package/node_modules/@code-yeongyu/senpi-codemode/package.json +5 -5
  873. package/node_modules/@code-yeongyu/senpi-codemode/src/config/settings.ts +29 -0
  874. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/session-manager.ts +8 -4
  875. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +3 -1
  876. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/display-image.js +162 -0
  877. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/prelude.ts +2 -2
  878. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-runtime.js +29 -60
  879. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/prelude.py +66 -1
  880. package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +28 -94
  881. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-execution.ts +7 -0
  882. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +6 -0
  883. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +14 -2
  884. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +12 -7
  885. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  886. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +58 -64
  887. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  888. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -1
  889. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +16 -6
  890. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
  891. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts +1 -1
  892. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts.map +1 -1
  893. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +6 -1
  894. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js.map +1 -1
  895. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +1 -1
  896. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js.map +1 -1
  897. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +2 -0
  898. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  899. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +40 -10
  900. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  901. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +6 -2
  902. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  903. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  904. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  905. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts +1 -1
  906. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  907. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +130 -15
  908. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  909. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +4 -4
  910. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
  911. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +1 -1
  912. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  913. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +1 -1
  914. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  915. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +3 -1
  916. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  917. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  918. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +30 -10
  919. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  920. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +3 -3
  921. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  922. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  923. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +1 -1
  924. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  925. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +8 -5
  926. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  927. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +2 -0
  928. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -1
  929. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +6 -0
  930. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
  931. package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.js +1 -1
  932. package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.js.map +1 -1
  933. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +30 -0
  934. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  935. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +30 -0
  936. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  937. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
  938. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  939. package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
  940. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  941. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +3 -1
  942. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  943. package/node_modules/@earendil-works/pi-ai/dist/models.js +27 -3
  944. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  945. package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.d.ts +2 -0
  946. package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.d.ts.map +1 -1
  947. package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.js.map +1 -1
  948. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  949. package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  950. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
  951. package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  952. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  953. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  954. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  955. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  956. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  957. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  958. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  959. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  960. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  961. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts +1 -1
  962. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts.map +1 -1
  963. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +8 -1
  964. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js.map +1 -1
  965. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +14 -1
  966. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  967. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  968. package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.d.ts +23 -0
  969. package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.d.ts.map +1 -0
  970. package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.js +58 -0
  971. package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.js.map +1 -0
  972. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.d.ts.map +1 -1
  973. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js +53 -12
  974. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js.map +1 -1
  975. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts +4 -2
  976. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
  977. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js +3 -0
  978. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js.map +1 -1
  979. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
  980. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +3 -0
  981. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
  982. package/node_modules/@earendil-works/pi-ai/package.json +3 -3
  983. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  984. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  985. package/node_modules/@earendil-works/pi-tui/README.md +1 -1
  986. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +1 -0
  987. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
  988. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +36 -3
  989. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
  990. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
  991. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  992. package/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
  993. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  994. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +2 -0
  995. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  996. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +106 -6
  997. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  998. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +6 -0
  999. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  1000. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +17 -4
  1001. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  1002. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +11 -0
  1003. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
  1004. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +57 -15
  1005. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
  1006. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  1007. package/node_modules/@earendil-works/pi-tui/dist/tui.js +22 -7
  1008. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  1009. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  1010. package/package.json +8 -8
@@ -2,10 +2,10 @@ import type { Tool as OpenAITool, ResponseCreateParamsStreaming, ResponseInput,
2
2
  import type { Api, AssistantMessage, Context, Model, Tool, Usage } from "../types.ts";
3
3
  import type { AssistantMessageEventStream } from "../utils/event-stream.ts";
4
4
  export interface OpenAIResponsesStreamOptions {
5
- serviceTier?: ResponseCreateParamsStreaming["service_tier"];
5
+ serviceTier?: ResponseCreateParamsStreaming["service_tier"] | "fast";
6
6
  grammarToolInputProperties?: ReadonlyMap<string, string>;
7
- resolveServiceTier?: (responseServiceTier: ResponseCreateParamsStreaming["service_tier"] | undefined, requestServiceTier: ResponseCreateParamsStreaming["service_tier"] | undefined) => ResponseCreateParamsStreaming["service_tier"] | undefined;
8
- applyServiceTierPricing?: (usage: Usage, serviceTier: ResponseCreateParamsStreaming["service_tier"] | undefined) => void;
7
+ resolveServiceTier?: (responseServiceTier: ResponseCreateParamsStreaming["service_tier"] | "fast" | undefined, requestServiceTier: ResponseCreateParamsStreaming["service_tier"] | "fast" | undefined) => ResponseCreateParamsStreaming["service_tier"] | "fast" | undefined;
8
+ applyServiceTierPricing?: (usage: Usage, serviceTier: ResponseCreateParamsStreaming["service_tier"] | "fast" | undefined) => void;
9
9
  }
10
10
  export interface ConvertResponsesMessagesOptions {
11
11
  includeSystemPrompt?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"openai-responses-shared.d.ts","sourceRoot":"","sources":["../../src/api/openai-responses-shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEX,IAAI,IAAI,UAAU,EAClB,6BAA6B,EAE7B,aAAa,EAOb,mBAAmB,EAEnB,MAAM,yCAAyC,CAAC;AAQjD,OAAO,KAAK,EACX,GAAG,EACH,gBAAgB,EAChB,OAAO,EAEP,KAAK,EAML,IAAI,EAEJ,KAAK,EACL,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AA4F5E,MAAM,WAAW,4BAA4B;IAC5C,WAAW,CAAC,EAAE,6BAA6B,CAAC,cAAc,CAAC,CAAC;IAC5D,0BAA0B,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzD,kBAAkB,CAAC,EAAE,CACpB,mBAAmB,EAAE,6BAA6B,CAAC,cAAc,CAAC,GAAG,SAAS,EAC9E,kBAAkB,EAAE,6BAA6B,CAAC,cAAc,CAAC,GAAG,SAAS,KACzE,6BAA6B,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAC/D,uBAAuB,CAAC,EAAE,CACzB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,6BAA6B,CAAC,cAAc,CAAC,GAAG,SAAS,KAClE,IAAI,CAAC;CACV;AAED,MAAM,WAAW,+BAA+B;IAC/C,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,sBAAsB,CAAC,EAAE,OAAO,CAAC;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AAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import type OpenAI from \"openai\";\nimport type {\n\tResponseInputItem as OpenAIResponseInputItem,\n\tTool as OpenAITool,\n\tResponseCreateParamsStreaming,\n\tResponseFunctionCallOutputItemList,\n\tResponseInput,\n\tResponseInputContent,\n\tResponseInputImage,\n\tResponseInputText,\n\tResponseOutputItem,\n\tResponseOutputMessage,\n\tResponseReasoningItem,\n\tResponseStreamEvent,\n\tResponseToolSearchOutputItemParam,\n} from \"openai/resources/responses/responses.js\";\nimport {\n\tCONTEXT_PROVENANCE_FIELD,\n\ttype ContextProvenance,\n\tcontextProvenanceFingerprint,\n\tgetContextProvenance,\n} from \"../context-provenance.ts\";\nimport { calculateCost } from \"../models.ts\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tContext,\n\tImageContent,\n\tModel,\n\tProviderNativeContent,\n\tStopReason,\n\tTextContent,\n\tTextSignatureV1,\n\tThinkingContent,\n\tTool,\n\tToolCall,\n\tUsage,\n} from \"../types.ts\";\nimport type { AssistantMessageEventStream } from \"../utils/event-stream.ts\";\nimport { shortHash } from \"../utils/hash.ts\";\nimport { parseStreamingJson } from \"../utils/json-parse.ts\";\nimport { sanitizeSurrogates } from \"../utils/sanitize-unicode.ts\";\nimport {\n\tappendGrammarToolInputJsonDelta,\n\ttype GrammarToolInputJsonBuffer,\n\tgetGrammarToolInput,\n\tgetJsonSchemaToolParameters,\n\tresolveGrammarConstrainedSampling,\n\tresolveJsonSchemaStrictSampling,\n} from \"./constrained-sampling.ts\";\nimport { transformMessages } from \"./transform-messages.ts\";\n\n// =============================================================================\n// Utilities\n// =============================================================================\n\nfunction encodeTextSignatureV1(id: string, phase?: TextSignatureV1[\"phase\"]): string {\n\tconst payload: TextSignatureV1 = { v: 1, id };\n\tif (phase) payload.phase = phase;\n\treturn JSON.stringify(payload);\n}\n\nfunction parseTextSignature(\n\tsignature: string | undefined,\n): { id: string; phase?: TextSignatureV1[\"phase\"] } | undefined {\n\tif (!signature) return undefined;\n\tif (signature.startsWith(\"{\")) {\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(signature) as Partial<TextSignatureV1>;\n\t\t\tif (parsed.v === 1 && typeof parsed.id === \"string\") {\n\t\t\t\tif (parsed.phase === \"commentary\" || parsed.phase === \"final_answer\") {\n\t\t\t\t\treturn { id: parsed.id, phase: parsed.phase };\n\t\t\t\t}\n\t\t\t\treturn { id: parsed.id };\n\t\t\t}\n\t\t} catch {\n\t\t\t// Fall through to legacy plain-string handling.\n\t\t}\n\t}\n\treturn { id: signature };\n}\n\n/**\n * Parse a persisted reasoning-item signature, rejecting anything that is not a\n * genuine Responses reasoning item. Foreign providers store non-JSON markers\n * (Kimi's \"reasoning_content\") or opaque payloads (Anthropic signatures) in\n * the same field; an unguarded JSON.parse turns a provenance mix-up into a\n * client-side throw, and blindly pushing the parsed value leaks invalid items.\n */\nfunction parseReasoningSignature(signature: string | undefined): ResponseReasoningItem | undefined {\n\tif (!signature) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(signature) as ResponseReasoningItem;\n\t\treturn parsed?.type === \"reasoning\" ? parsed : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\ntype ToolResultOutputContent = Array<ResponseInputText | ResponseInputImage>;\n\nfunction convertToolResultOutput<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontent: readonly (TextContent | ImageContent)[],\n): string | ToolResultOutputContent {\n\tconst textResult = content\n\t\t.filter((c): c is TextContent => c.type === \"text\")\n\t\t.map((c) => c.text)\n\t\t.join(\"\\n\");\n\tconst images = content.filter((c): c is ImageContent => c.type === \"image\");\n\tconst hasText = textResult.length > 0;\n\n\tif (images.length === 0 || !model.input.includes(\"image\")) {\n\t\treturn sanitizeSurrogates(hasText ? textResult : images.length > 0 ? \"(see attached image)\" : \"(no tool output)\");\n\t}\n\n\tconst output: ToolResultOutputContent = [];\n\tif (hasText) {\n\t\toutput.push({ type: \"input_text\", text: sanitizeSurrogates(textResult) });\n\t}\n\tfor (const image of images) {\n\t\toutput.push({\n\t\t\ttype: \"input_image\",\n\t\t\tdetail: \"auto\",\n\t\t\timage_url: `data:${image.mimeType};base64,${image.data}`,\n\t\t});\n\t}\n\treturn output;\n}\n\nexport interface OpenAIResponsesStreamOptions {\n\tserviceTier?: ResponseCreateParamsStreaming[\"service_tier\"];\n\tgrammarToolInputProperties?: ReadonlyMap<string, string>;\n\tresolveServiceTier?: (\n\t\tresponseServiceTier: ResponseCreateParamsStreaming[\"service_tier\"] | undefined,\n\t\trequestServiceTier: ResponseCreateParamsStreaming[\"service_tier\"] | undefined,\n\t) => ResponseCreateParamsStreaming[\"service_tier\"] | undefined;\n\tapplyServiceTierPricing?: (\n\t\tusage: Usage,\n\t\tserviceTier: ResponseCreateParamsStreaming[\"service_tier\"] | undefined,\n\t) => void;\n}\n\nexport interface ConvertResponsesMessagesOptions {\n\tincludeSystemPrompt?: boolean;\n\tpreserveThinking?: boolean;\n\tpreserveTextSignatures?: boolean;\n\tgrammarToolInputProperties?: ReadonlyMap<string, string>;\n\tdeferredTools?: ReadonlyMap<string, Tool>;\n\tdeferredToolsMode?: \"additional-tools\" | \"tool-search\";\n\ttoolOptions?: ConvertResponsesToolsOptions;\n\t/** Internal request-local provenance sealing pass. Never serialized to provider payloads. */\n\tsealContextProvenance?: boolean;\n}\n\nexport interface ConvertResponsesToolsOptions {\n\tstrict?: boolean | null;\n\tsupportsStrictMode?: boolean;\n\tsupportsOpenAIGrammarTools?: boolean;\n\tdeferLoading?: boolean;\n}\n\ntype ResponseCustomToolCallItem = {\n\ttype: \"custom_tool_call\";\n\tid?: string;\n\tcall_id: string;\n\tname: string;\n\tinput?: string;\n\tnamespace?: string;\n};\n\ntype ResponseCustomToolCallOutputItem = {\n\ttype: \"custom_tool_call_output\";\n\tcall_id: string;\n\tname?: string;\n\toutput: string | ResponseFunctionCallOutputItemList;\n};\n\ntype AdditionalToolsInputItem = {\n\ttype: \"additional_tools\";\n\trole: \"developer\";\n\ttools: OpenAITool[];\n};\n\ntype ResponseInputItem =\n\t| OpenAIResponseInputItem\n\t| ResponseCustomToolCallItem\n\t| ResponseCustomToolCallOutputItem\n\t| AdditionalToolsInputItem;\n\nexport const CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL = \"custom\";\n\ntype ResponseFunctionTool = Extract<OpenAITool, { type: \"function\" }>;\n\nfunction isResponseCustomToolCallItem(item: { type?: string }): item is ResponseCustomToolCallItem {\n\treturn item.type === \"custom_tool_call\";\n}\n\nfunction isFreeformTool(tool: Tool): boolean {\n\treturn tool.freeform !== undefined;\n}\n\nfunction isFreeformToolName(toolName: string, tools: Tool[] | undefined): boolean {\n\treturn tools?.some((tool) => tool.name === toolName && isFreeformTool(tool)) ?? false;\n}\n\nfunction getFreeformToolInput(argumentsValue: Record<string, unknown>): string {\n\treturn typeof argumentsValue.input === \"string\" ? argumentsValue.input : JSON.stringify(argumentsValue);\n}\n\nfunction contextProvenanceForInput(message: unknown, seal: boolean | undefined): ContextProvenance | undefined {\n\tconst provenance = getContextProvenance(message);\n\tif (!provenance) return undefined;\n\tconst fingerprint = contextProvenanceFingerprint(message);\n\tif (fingerprint === undefined) return undefined;\n\tconst stored = provenance.integrity;\n\tif (stored === undefined && seal) {\n\t\tprovenance.integrity = fingerprint;\n\t\treturn provenance;\n\t}\n\treturn stored === fingerprint ? provenance : undefined;\n}\n\nfunction withContextProvenance<T extends object>(item: T, message: unknown, seal: boolean | undefined): T {\n\tconst provenance = contextProvenanceForInput(message, seal);\n\tif (provenance) {\n\t\tObject.defineProperty(item, CONTEXT_PROVENANCE_FIELD, {\n\t\t\tvalue: provenance,\n\t\t\tenumerable: false,\n\t\t});\n\t}\n\treturn item;\n}\n// =============================================================================\n// Message conversion\n// =============================================================================\n\nexport function convertResponsesMessages<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\tallowedToolCallProviders: ReadonlySet<string>,\n\toptions?: ConvertResponsesMessagesOptions,\n): ResponseInput {\n\tconst messages: ResponseInputItem[] = [];\n\tconst loadedToolNames = new Set<string>();\n\n\tconst normalizeIdPart = (part: string): string => {\n\t\tconst sanitized = part.replace(/[^a-zA-Z0-9_-]/g, \"_\");\n\t\tconst normalized = sanitized.length > 64 ? sanitized.slice(0, 64) : sanitized;\n\t\treturn normalized.replace(/_+$/, \"\");\n\t};\n\n\tconst buildForeignResponsesItemId = (itemId: string): string => {\n\t\tconst normalized = `fc_${shortHash(itemId)}`;\n\t\treturn normalized.length > 64 ? normalized.slice(0, 64) : normalized;\n\t};\n\n\tconst normalizeToolCallId = (id: string, _targetModel: Model<TApi>, source: AssistantMessage): string => {\n\t\tif (!id.includes(\"|\")) return normalizeIdPart(id);\n\t\tconst [callId, itemId] = id.split(\"|\");\n\t\tconst normalizedCallId = normalizeIdPart(callId);\n\t\tif (itemId === CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL) {\n\t\t\treturn `${normalizedCallId}|${CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL}`;\n\t\t}\n\t\tif (!allowedToolCallProviders.has(model.provider)) return normalizeIdPart(id);\n\t\tconst isForeignToolCall = source.provider !== model.provider || source.api !== model.api;\n\t\tlet normalizedItemId = isForeignToolCall ? buildForeignResponsesItemId(itemId) : normalizeIdPart(itemId);\n\t\t// OpenAI Responses API requires item id to start with \"fc\"\n\t\tif (!normalizedItemId.startsWith(\"fc_\")) {\n\t\t\tnormalizedItemId = normalizeIdPart(`fc_${normalizedItemId}`);\n\t\t}\n\t\treturn `${normalizedCallId}|${normalizedItemId}`;\n\t};\n\n\tconst transformedMessages = transformMessages(context.messages, model, normalizeToolCallId, {\n\t\tpreserveThinking: options?.preserveThinking,\n\t\tpreserveTextSignatures: options?.preserveTextSignatures,\n\t});\n\n\tconst includeSystemPrompt = options?.includeSystemPrompt ?? true;\n\tif (includeSystemPrompt && context.systemPrompt) {\n\t\tconst compat = model.compat as { supportsDeveloperRole?: boolean } | undefined;\n\t\tconst role = model.reasoning && compat?.supportsDeveloperRole !== false ? \"developer\" : \"system\";\n\t\tmessages.push({\n\t\t\trole,\n\t\t\tcontent: sanitizeSurrogates(context.systemPrompt),\n\t\t});\n\t}\n\n\tlet msgIndex = 0;\n\tfor (const msg of transformedMessages) {\n\t\tif (msg.role === \"user\") {\n\t\t\tif (typeof msg.content === \"string\") {\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\t\tcontent: [{ type: \"input_text\", text: sanitizeSurrogates(msg.content) }],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst content: ResponseInputContent[] = msg.content.map((item): ResponseInputContent => {\n\t\t\t\t\tif (item.type === \"text\") {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: \"input_text\",\n\t\t\t\t\t\t\ttext: sanitizeSurrogates(item.text),\n\t\t\t\t\t\t} satisfies ResponseInputText;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"input_image\",\n\t\t\t\t\t\tdetail: \"auto\",\n\t\t\t\t\t\timage_url: `data:${item.mimeType};base64,${item.data}`,\n\t\t\t\t\t} satisfies ResponseInputImage;\n\t\t\t\t});\n\t\t\t\tif (content.length === 0) continue;\n\t\t\t\tmessages.push(withContextProvenance({ role: \"user\", content }, msg, options?.sealContextProvenance));\n\t\t\t}\n\t\t} else if (msg.role === \"assistant\") {\n\t\t\tconst output: ResponseInputItem[] = [];\n\t\t\tconst assistantMsg = msg as AssistantMessage;\n\t\t\tconst isSameProviderAndApi = assistantMsg.provider === model.provider && assistantMsg.api === model.api;\n\t\t\tconst isSameModel = isSameProviderAndApi && assistantMsg.model === model.id;\n\t\t\tconst isDifferentModel = isSameProviderAndApi && assistantMsg.model !== model.id;\n\t\t\tlet textBlockIndex = 0;\n\n\t\t\tconst pushAssistantText = (text: string, textSignature?: string): void => {\n\t\t\t\tconst parsedSignature = parseTextSignature(textSignature);\n\t\t\t\tconst fallbackMessageId =\n\t\t\t\t\ttextBlockIndex === 0 ? `msg_pi_${msgIndex}` : `msg_pi_${msgIndex}_${textBlockIndex}`;\n\t\t\t\ttextBlockIndex++;\n\t\t\t\t// OpenAI requires id to be max 64 characters\n\t\t\t\tlet msgId = parsedSignature?.id;\n\t\t\t\tif (!msgId) {\n\t\t\t\t\tmsgId = fallbackMessageId;\n\t\t\t\t} else if (msgId.length > 64) {\n\t\t\t\t\tmsgId = `msg_${shortHash(msgId)}`;\n\t\t\t\t}\n\t\t\t\toutput.push({\n\t\t\t\t\ttype: \"message\",\n\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\tcontent: [{ type: \"output_text\", text: sanitizeSurrogates(text), annotations: [] }],\n\t\t\t\t\tstatus: \"completed\",\n\t\t\t\t\tid: msgId,\n\t\t\t\t\tphase: parsedSignature?.phase,\n\t\t\t\t} satisfies ResponseOutputMessage);\n\t\t\t};\n\n\t\t\tfor (const block of msg.content) {\n\t\t\t\tif (block.type === \"thinking\") {\n\t\t\t\t\tconst reasoningItem = parseReasoningSignature(block.thinkingSignature);\n\t\t\t\t\tif (reasoningItem) {\n\t\t\t\t\t\toutput.push(reasoningItem);\n\t\t\t\t\t} else if (block.thinkingSignature && block.thinking.trim() !== \"\") {\n\t\t\t\t\t\t// A signed thinking block whose signature is not a real reasoning\n\t\t\t\t\t\t// item (foreign provenance or corrupted state): demote to plain\n\t\t\t\t\t\t// text, mirroring the cross-model policy in transformMessages.\n\t\t\t\t\t\tpushAssistantText(block.thinking);\n\t\t\t\t\t}\n\t\t\t\t\t// Signed foreign blocks with no text are intentionally dropped.\n\t\t\t\t} else if (block.type === \"providerNative\") {\n\t\t\t\t} else if (block.type === \"text\") {\n\t\t\t\t\tconst textBlock = block as TextContent;\n\t\t\t\t\tpushAssistantText(textBlock.text, textBlock.textSignature);\n\t\t\t\t} else if (block.type === \"toolCall\") {\n\t\t\t\t\tconst toolCall = block as ToolCall;\n\t\t\t\t\tconst [callId, itemIdRaw] = toolCall.id.split(\"|\");\n\t\t\t\t\tconst customInputProperty = options?.grammarToolInputProperties?.get(toolCall.name);\n\t\t\t\t\tconst isPersistedFreeform = itemIdRaw === CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL;\n\t\t\t\t\tconst isFreeform = isFreeformToolName(toolCall.name, context.tools) || isPersistedFreeform;\n\t\t\t\t\tlet itemId: string | undefined = isPersistedFreeform ? undefined : itemIdRaw;\n\n\t\t\t\t\t// An active grammar declaration wins over sentinel recovery below: its\n\t\t\t\t\t// named input property is richer than the persisted freeform fallback.\n\n\t\t\t\t\t// For different-model messages, set id to undefined to avoid pairing validation.\n\t\t\t\t\t// OpenAI tracks which fc_xxx IDs were paired with rs_xxx reasoning items.\n\t\t\t\t\t// By omitting the id, we avoid triggering that validation (like cross-provider does).\n\t\t\t\t\t// Function-call item ids must begin with fc_ while freeform calls can replay\n\t\t\t\t\t// without the local <call_id>|custom sentinel.\n\t\t\t\t\tif (\n\t\t\t\t\t\t(isDifferentModel && itemId?.startsWith(\"fc_\")) ||\n\t\t\t\t\t\t(!isFreeform && customInputProperty === undefined && !itemId?.startsWith(\"fc_\"))\n\t\t\t\t\t) {\n\t\t\t\t\t\titemId = undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst canReplayNamespace = isSameModel || options?.deferredTools?.has(toolCall.name) === true;\n\n\t\t\t\t\tif (customInputProperty !== undefined) {\n\t\t\t\t\t\toutput.push({\n\t\t\t\t\t\t\ttype: \"custom_tool_call\",\n\t\t\t\t\t\t\t...(itemId !== undefined ? { id: itemId } : {}),\n\t\t\t\t\t\t\tcall_id: callId,\n\t\t\t\t\t\t\tname: toolCall.name,\n\t\t\t\t\t\t\tinput: sanitizeSurrogates(\n\t\t\t\t\t\t\t\tgetGrammarToolInput(toolCall.name, toolCall.arguments, customInputProperty),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t...(canReplayNamespace && toolCall.namespace !== undefined\n\t\t\t\t\t\t\t\t? { namespace: toolCall.namespace }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t} satisfies ResponseCustomToolCallItem);\n\t\t\t\t\t} else if (isFreeform) {\n\t\t\t\t\t\toutput.push({\n\t\t\t\t\t\t\ttype: \"custom_tool_call\",\n\t\t\t\t\t\t\tcall_id: callId,\n\t\t\t\t\t\t\tname: toolCall.name,\n\t\t\t\t\t\t\tinput: getFreeformToolInput(toolCall.arguments),\n\t\t\t\t\t\t\t...(canReplayNamespace && toolCall.namespace !== undefined\n\t\t\t\t\t\t\t\t? { namespace: toolCall.namespace }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t} satisfies ResponseCustomToolCallItem);\n\t\t\t\t\t} else {\n\t\t\t\t\t\toutput.push({\n\t\t\t\t\t\t\ttype: \"function_call\",\n\t\t\t\t\t\t\t...(itemId?.startsWith(\"fc_\") ? { id: itemId } : {}),\n\t\t\t\t\t\t\tcall_id: callId,\n\t\t\t\t\t\t\tname: toolCall.name,\n\t\t\t\t\t\t\targuments: JSON.stringify(toolCall.arguments),\n\t\t\t\t\t\t\t...(canReplayNamespace && toolCall.namespace !== undefined\n\t\t\t\t\t\t\t\t? { namespace: toolCall.namespace }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (output.length === 0) continue;\n\t\t\tmessages.push(...output.map((item) => withContextProvenance(item, msg, options?.sealContextProvenance)));\n\t\t} else if (msg.role === \"toolResult\") {\n\t\t\tconst [callId, itemIdRaw] = msg.toolCallId.split(\"|\");\n\t\t\tconst output = convertToolResultOutput(model, msg.content);\n\t\t\tconst customInputProperty = options?.grammarToolInputProperties?.get(msg.toolName);\n\t\t\tconst isPersistedFreeform = itemIdRaw === CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL;\n\n\t\t\tif (customInputProperty !== undefined) {\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"custom_tool_call_output\",\n\t\t\t\t\t\t\tcall_id: callId,\n\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t} satisfies ResponseCustomToolCallOutputItem,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else if (isFreeformToolName(msg.toolName, context.tools) || isPersistedFreeform) {\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"custom_tool_call_output\",\n\t\t\t\t\t\t\tcall_id: callId,\n\t\t\t\t\t\t\tname: msg.toolName,\n\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t} satisfies ResponseCustomToolCallOutputItem,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{ type: \"function_call_output\", call_id: callId, output },\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst deferredTools: Tool[] = [];\n\t\t\tfor (const name of msg.addedToolNames ?? []) {\n\t\t\t\tconst tool = options?.deferredTools?.get(name);\n\t\t\t\tif (!tool || loadedToolNames.has(name)) continue;\n\t\t\t\tloadedToolNames.add(name);\n\t\t\t\tdeferredTools.push(tool);\n\t\t\t}\n\t\t\tif (deferredTools.length > 0 && options?.deferredToolsMode === \"additional-tools\") {\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"additional_tools\",\n\t\t\t\t\t\t\trole: \"developer\",\n\t\t\t\t\t\t\ttools: convertResponsesTools(deferredTools, options.toolOptions),\n\t\t\t\t\t\t} satisfies ResponseInputItem,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else if (deferredTools.length > 0 && options?.deferredToolsMode === \"tool-search\") {\n\t\t\t\tconst names = deferredTools.map((tool) => tool.name);\n\t\t\t\tconst searchCallId = `pi_tool_load_${shortHash(`${msg.toolCallId}:${names.join(\",\")}`)}`;\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"tool_search_call\",\n\t\t\t\t\t\t\tcall_id: searchCallId,\n\t\t\t\t\t\t\texecution: \"client\",\n\t\t\t\t\t\t\tstatus: \"completed\",\n\t\t\t\t\t\t\targuments: { query: names.join(\" \"), limit: names.length },\n\t\t\t\t\t\t} satisfies ResponseInputItem,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"tool_search_output\",\n\t\t\t\t\t\t\tcall_id: searchCallId,\n\t\t\t\t\t\t\texecution: \"client\",\n\t\t\t\t\t\t\tstatus: \"completed\",\n\t\t\t\t\t\t\ttools: convertResponsesTools(deferredTools, {\n\t\t\t\t\t\t\t\t...options?.toolOptions,\n\t\t\t\t\t\t\t\tdeferLoading: true,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t} satisfies ResponseToolSearchOutputItemParam,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tmsgIndex++;\n\t}\n\n\treturn messages as ResponseInput;\n}\n\n// =============================================================================\n// Tool conversion\n// =============================================================================\n\nexport function convertResponsesTools(tools: readonly Tool[], options?: ConvertResponsesToolsOptions): OpenAITool[] {\n\tconst defaultStrict = options?.strict === undefined ? false : options.strict;\n\tconst supportsStrictMode = options?.supportsStrictMode ?? true;\n\tconst supportsOpenAIGrammarTools = options?.supportsOpenAIGrammarTools ?? false;\n\n\treturn tools.map((tool) => {\n\t\tconst grammar = resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools);\n\t\tif (grammar) {\n\t\t\treturn {\n\t\t\t\ttype: \"custom\",\n\t\t\t\tname: tool.name,\n\t\t\t\tdescription: tool.description,\n\t\t\t\tformat: {\n\t\t\t\t\ttype: \"grammar\",\n\t\t\t\t\tsyntax: grammar.format,\n\t\t\t\t\tdefinition: grammar.definition,\n\t\t\t\t},\n\t\t\t\t...(options?.deferLoading ? { defer_loading: true } : {}),\n\t\t\t} satisfies OpenAITool;\n\t\t}\n\t\tif (tool.freeform) {\n\t\t\treturn {\n\t\t\t\ttype: \"custom\",\n\t\t\t\tname: tool.name,\n\t\t\t\tdescription: tool.description,\n\t\t\t\tformat: tool.freeform,\n\t\t\t\t...(options?.deferLoading ? { defer_loading: true } : {}),\n\t\t\t} as OpenAITool;\n\t\t}\n\n\t\tconst constrainedStrict = resolveJsonSchemaStrictSampling(tool, supportsStrictMode);\n\t\tconst strict = constrainedStrict ?? defaultStrict;\n\t\tconst functionTool: Omit<ResponseFunctionTool, \"strict\"> & {\n\t\t\tstrict?: ResponseFunctionTool[\"strict\"];\n\t\t} = {\n\t\t\ttype: \"function\",\n\t\t\tname: tool.name,\n\t\t\tdescription: tool.description,\n\t\t\tparameters: getJsonSchemaToolParameters(tool, strict === true) as ResponseFunctionTool[\"parameters\"],\n\t\t\t...(options?.deferLoading ? { defer_loading: true } : {}),\n\t\t};\n\t\tif (supportsStrictMode) {\n\t\t\tfunctionTool.strict = strict;\n\t\t}\n\t\treturn functionTool as OpenAITool;\n\t});\n}\n\n// =============================================================================\n// Stream processing\n// =============================================================================\n\ntype StreamingToolCall = ToolCall & {\n\tpartialJson?: string;\n\tcustomInput?: {\n\t\tproperty: string;\n\t\tjsonBuffer: GrammarToolInputJsonBuffer;\n\t};\n};\n\nfunction getCustomToolCallInput(block: StreamingToolCall): string {\n\tconst property = block.customInput?.property;\n\tif (property === undefined) return \"\";\n\tconst value = block.arguments[property];\n\treturn typeof value === \"string\" ? value : \"\";\n}\n\nfunction appendCustomToolCallInput(block: StreamingToolCall, nextInput: string, close: boolean): string | undefined {\n\tconst customInput = block.customInput;\n\tif (!customInput) return undefined;\n\tconst delta = appendGrammarToolInputJsonDelta(customInput.jsonBuffer, customInput.property, nextInput, close);\n\tblock.arguments = { [customInput.property]: nextInput };\n\treturn delta;\n}\n\ntype ResponsesOutputSlot =\n\t| { type: \"thinking\"; block: ThinkingContent; contentIndex: number }\n\t| { type: \"text\"; block: TextContent; contentIndex: number }\n\t| { type: \"toolCall\"; block: StreamingToolCall; contentIndex: number }\n\t| { type: \"providerNative\"; block: ProviderNativeContent; contentIndex: number };\n\ntype ToolCallOutputSlot = Extract<ResponsesOutputSlot, { type: \"toolCall\" }>;\n\ntype NativeImageGenerationCall = {\n\ttype: \"image_generation_call\";\n\tid?: string;\n\tstatus: string;\n\tresult?: string | null;\n\trevised_prompt?: string;\n};\n\nconst MAX_NATIVE_IMAGE_BASE64_CHARS = 24 * 1024 * 1024;\n\nfunction readNativeImageGenerationCall(value: unknown): NativeImageGenerationCall | undefined {\n\tif (typeof value !== \"object\" || value === null || !(\"type\" in value) || !(\"status\" in value)) return undefined;\n\tif (value.type !== \"image_generation_call\" || typeof value.status !== \"string\") return undefined;\n\treturn {\n\t\ttype: \"image_generation_call\",\n\t\t...(\"id\" in value && typeof value.id === \"string\" ? { id: value.id } : {}),\n\t\tstatus: value.status,\n\t\t...(\"result\" in value && (typeof value.result === \"string\" || value.result === null)\n\t\t\t? { result: value.result }\n\t\t\t: {}),\n\t\t...(\"revised_prompt\" in value && typeof value.revised_prompt === \"string\"\n\t\t\t? { revised_prompt: value.revised_prompt }\n\t\t\t: {}),\n\t};\n}\n\nfunction isValidBase64(value: string): boolean {\n\treturn value.length > 0 && value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(value);\n}\n\nfunction reconcileNativeImageGenerationCall(item: NativeImageGenerationCall): NativeImageGenerationCall {\n\tif (item.status !== \"completed\") {\n\t\treturn {\n\t\t\ttype: \"image_generation_call\",\n\t\t\t...(item.id !== undefined ? { id: item.id } : {}),\n\t\t\tstatus: item.status,\n\t\t};\n\t}\n\tif (typeof item.result !== \"string\" || !isValidBase64(item.result)) {\n\t\treturn {\n\t\t\ttype: \"image_generation_call\",\n\t\t\t...(item.id !== undefined ? { id: item.id } : {}),\n\t\t\tstatus: \"malformed\",\n\t\t};\n\t}\n\treturn {\n\t\ttype: \"image_generation_call\",\n\t\t...(item.id !== undefined ? { id: item.id } : {}),\n\t\tstatus: \"completed\",\n\t\tresult: item.result,\n\t\t...(item.revised_prompt?.trim() ? { revised_prompt: item.revised_prompt } : {}),\n\t};\n}\n\nexport async function processResponsesStream<TApi extends Api>(\n\topenaiStream: AsyncIterable<ResponseStreamEvent>,\n\toutput: AssistantMessage,\n\tstream: AssistantMessageEventStream,\n\tmodel: Model<TApi>,\n\toptions?: OpenAIResponsesStreamOptions,\n): Promise<void> {\n\tlet sawTerminalResponseEvent = false;\n\tlet nativeImageBase64Chars = 0;\n\tconst outputSlots = new Map<number, ResponsesOutputSlot>();\n\tconst reasoningBlocksById = new Map<string, ThinkingContent>();\n\tconst nativeImageCharsByOutputIndex = new Map<number, number>();\n\tconst finalizedNativeImageOutputIndexes = new Set<number>();\n\tconst applyMessagePhaseStopReason = (item: ResponseOutputItem): void => {\n\t\tif (item.type === \"message\" && item.phase === \"final_answer\") {\n\t\t\toutput.stopReason = \"stop\";\n\t\t}\n\t};\n\tconst getSlot = <TType extends ResponsesOutputSlot[\"type\"]>(\n\t\toutputIndex: number,\n\t\ttype: TType,\n\t): Extract<ResponsesOutputSlot, { type: TType }> | undefined => {\n\t\tconst slot = outputSlots.get(outputIndex);\n\t\treturn slot?.type === type ? (slot as Extract<ResponsesOutputSlot, { type: TType }>) : undefined;\n\t};\n\tconst pushToolCallDelta = (slot: ToolCallOutputSlot, delta: string | undefined): void => {\n\t\tif (delta === undefined) return;\n\t\tstream.push({\n\t\t\ttype: \"toolcall_delta\",\n\t\t\tcontentIndex: slot.contentIndex,\n\t\t\tdelta,\n\t\t\tpartial: output,\n\t\t});\n\t};\n\tconst createSlot = (\n\t\toutputIndex: number,\n\t\titem: ResponseOutputItem | ResponseCustomToolCallItem,\n\t): ResponsesOutputSlot | undefined => {\n\t\tif (item.type === \"reasoning\") {\n\t\t\tconst block: ThinkingContent = { type: \"thinking\", thinking: \"\" };\n\t\t\toutput.content.push(block);\n\t\t\tconst slot = {\n\t\t\t\ttype: \"thinking\",\n\t\t\t\tblock,\n\t\t\t\tcontentIndex: output.content.length - 1,\n\t\t\t} satisfies ResponsesOutputSlot;\n\t\t\toutputSlots.set(outputIndex, slot);\n\t\t\tstream.push({ type: \"thinking_start\", contentIndex: slot.contentIndex, partial: output });\n\t\t\treturn slot;\n\t\t}\n\t\tif (item.type === \"message\") {\n\t\t\tapplyMessagePhaseStopReason(item);\n\t\t\tconst block: TextContent = { type: \"text\", text: \"\" };\n\t\t\toutput.content.push(block);\n\t\t\tconst slot = { type: \"text\", block, contentIndex: output.content.length - 1 } satisfies ResponsesOutputSlot;\n\t\t\toutputSlots.set(outputIndex, slot);\n\t\t\tstream.push({ type: \"text_start\", contentIndex: slot.contentIndex, partial: output });\n\t\t\treturn slot;\n\t\t}\n\t\tif (item.type === \"function_call\") {\n\t\t\tconst block: StreamingToolCall = {\n\t\t\t\ttype: \"toolCall\",\n\t\t\t\tid: `${item.call_id}|${item.id}`,\n\t\t\t\tname: item.name,\n\t\t\t\targuments: {},\n\t\t\t\t...(item.namespace !== undefined ? { namespace: item.namespace } : {}),\n\t\t\t\tpartialJson: item.arguments || \"\",\n\t\t\t};\n\t\t\toutput.content.push(block);\n\t\t\tconst slot = {\n\t\t\t\ttype: \"toolCall\",\n\t\t\t\tblock,\n\t\t\t\tcontentIndex: output.content.length - 1,\n\t\t\t} satisfies ResponsesOutputSlot;\n\t\t\toutputSlots.set(outputIndex, slot);\n\t\t\tstream.push({ type: \"toolcall_start\", contentIndex: slot.contentIndex, partial: output });\n\t\t\treturn slot;\n\t\t}\n\t\tif (isResponseCustomToolCallItem(item)) {\n\t\t\tconst inputProperty = options?.grammarToolInputProperties?.get(item.name) ?? \"input\";\n\t\t\tconst input = item.input || \"\";\n\t\t\tconst block: StreamingToolCall = {\n\t\t\t\ttype: \"toolCall\",\n\t\t\t\tid: `${item.call_id}|${item.id ?? CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL}`,\n\t\t\t\tname: item.name,\n\t\t\t\targuments: { [inputProperty]: input },\n\t\t\t\t...(item.namespace !== undefined ? { namespace: item.namespace } : {}),\n\t\t\t\tcustomInput: {\n\t\t\t\t\tproperty: inputProperty,\n\t\t\t\t\tjsonBuffer: { input: \"\", started: false, closed: false },\n\t\t\t\t},\n\t\t\t};\n\t\t\toutput.content.push(block);\n\t\t\tconst slot = {\n\t\t\t\ttype: \"toolCall\",\n\t\t\t\tblock,\n\t\t\t\tcontentIndex: output.content.length - 1,\n\t\t\t} satisfies ResponsesOutputSlot;\n\t\t\toutputSlots.set(outputIndex, slot);\n\t\t\tstream.push({ type: \"toolcall_start\", contentIndex: slot.contentIndex, partial: output });\n\t\t\treturn slot;\n\t\t}\n\t\tconst imageItem = readNativeImageGenerationCall(item);\n\t\tconst block = {\n\t\t\ttype: \"providerNative\",\n\t\t\tsubtype: item.type,\n\t\t\traw: imageItem ? reconcileNativeImageGenerationCall(imageItem) : item,\n\t\t} satisfies ProviderNativeContent;\n\t\tconst slot = {\n\t\t\ttype: \"providerNative\",\n\t\t\tblock,\n\t\t\tcontentIndex: output.content.length,\n\t\t} satisfies ResponsesOutputSlot;\n\t\tif (imageItem) reconcileNativeImageSlot(outputIndex, slot, imageItem);\n\t\toutput.content.push(block);\n\t\toutputSlots.set(outputIndex, slot);\n\t\treturn slot;\n\t};\n\tconst getOrCreateSlot = (\n\t\toutputIndex: number,\n\t\titem: ResponseOutputItem | ResponseCustomToolCallItem,\n\t): ResponsesOutputSlot | undefined => {\n\t\treturn outputSlots.get(outputIndex) ?? createSlot(outputIndex, item);\n\t};\n\tfunction scrubNativeImageResults(): void {\n\t\tfor (const block of output.content) {\n\t\t\tif (block.type !== \"providerNative\" || block.subtype !== \"image_generation_call\") continue;\n\t\t\tconst item = readNativeImageGenerationCall(block.raw);\n\t\t\tif (typeof item?.result !== \"string\") continue;\n\t\t\tblock.raw = {\n\t\t\t\ttype: \"image_generation_call\",\n\t\t\t\t...(item.id !== undefined ? { id: item.id } : {}),\n\t\t\t\tstatus: \"malformed\",\n\t\t\t};\n\t\t}\n\t\tnativeImageBase64Chars = 0;\n\t\tnativeImageCharsByOutputIndex.clear();\n\t}\n\tfunction reconcileNativeImageSlot(\n\t\toutputIndex: number,\n\t\tslot: Extract<ResponsesOutputSlot, { type: \"providerNative\" }>,\n\t\titem: NativeImageGenerationCall,\n\t): void {\n\t\tconst reconciled = reconcileNativeImageGenerationCall(item);\n\t\tconst previousChars = nativeImageCharsByOutputIndex.get(outputIndex) ?? 0;\n\t\tconst nextChars = typeof reconciled.result === \"string\" ? reconciled.result.length : 0;\n\t\tconst nextTotal = nativeImageBase64Chars - previousChars + nextChars;\n\t\tif (nextTotal > MAX_NATIVE_IMAGE_BASE64_CHARS) {\n\t\t\tscrubNativeImageResults();\n\t\t\tthrow new Error(\"Native image generation results exceed the 24 MiB base64 limit\");\n\t\t}\n\t\tnativeImageBase64Chars = nextTotal;\n\t\tif (nextChars > 0) nativeImageCharsByOutputIndex.set(outputIndex, nextChars);\n\t\telse nativeImageCharsByOutputIndex.delete(outputIndex);\n\t\tslot.block.subtype = \"image_generation_call\";\n\t\tslot.block.raw = reconciled;\n\t}\n\tconst backfillNativeImageGenerationCalls = (responseOutput: readonly ResponseOutputItem[]): void => {\n\t\tfor (const [outputIndex, outputItem] of responseOutput.entries()) {\n\t\t\tif (finalizedNativeImageOutputIndexes.has(outputIndex)) continue;\n\t\t\tconst imageItem = readNativeImageGenerationCall(outputItem);\n\t\t\tif (!imageItem) continue;\n\t\t\tconst existingSlot = getSlot(outputIndex, \"providerNative\");\n\t\t\tif (existingSlot) reconcileNativeImageSlot(outputIndex, existingSlot, imageItem);\n\t\t\telse createSlot(outputIndex, outputItem);\n\t\t\toutputSlots.delete(outputIndex);\n\t\t}\n\t};\n\t// Azure OpenAI can omit reasoning.encrypted_content from response.output_item.done\n\t// and provide it only in response.completed.response.output. Backfill the\n\t// persisted reasoning signature from the terminal response to keep store:false\n\t// multi-turn replay stateless. See https://github.com/earendil-works/pi/issues/6409.\n\tconst backfillReasoningSignatures = (responseOutput: ResponseOutputItem[]): void => {\n\t\tfor (const item of responseOutput) {\n\t\t\tif (item.type !== \"reasoning\" || !item.encrypted_content) continue;\n\t\t\tconst block = reasoningBlocksById.get(item.id);\n\t\t\tif (!block?.thinkingSignature) continue;\n\n\t\t\tconst storedItem = parseReasoningSignature(block.thinkingSignature);\n\t\t\tif (!storedItem || storedItem.encrypted_content) continue;\n\t\t\tblock.thinkingSignature = JSON.stringify({\n\t\t\t\t...storedItem,\n\t\t\t\tencrypted_content: item.encrypted_content,\n\t\t\t});\n\t\t}\n\t};\n\tconst finalizeResponse = (\n\t\tresponse: Extract<ResponseStreamEvent, { type: \"response.completed\" | \"response.incomplete\" }>[\"response\"],\n\t) => {\n\t\tsawTerminalResponseEvent = true;\n\t\tbackfillReasoningSignatures(response.output ?? []);\n\t\tbackfillNativeImageGenerationCalls(response.output ?? []);\n\t\tif (response?.id) {\n\t\t\toutput.responseId = response.id;\n\t\t}\n\t\tif (response?.usage) {\n\t\t\tconst inputDetails = response.usage.input_tokens_details as\n\t\t\t\t| { cached_tokens?: number; cache_write_tokens?: number }\n\t\t\t\t| undefined;\n\t\t\tconst cachedTokens = inputDetails?.cached_tokens || 0;\n\t\t\tconst cacheWriteTokens = inputDetails?.cache_write_tokens || 0;\n\t\t\toutput.usage = {\n\t\t\t\t// OpenAI includes cached and cache-write tokens in input_tokens, so subtract both.\n\t\t\t\tinput: Math.max(0, (response.usage.input_tokens || 0) - cachedTokens - cacheWriteTokens),\n\t\t\t\toutput: response.usage.output_tokens || 0,\n\t\t\t\tcacheRead: cachedTokens,\n\t\t\t\tcacheWrite: cacheWriteTokens,\n\t\t\t\treasoning: response.usage.output_tokens_details?.reasoning_tokens || 0,\n\t\t\t\ttotalTokens: response.usage.total_tokens || 0,\n\t\t\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\t\t};\n\t\t}\n\t\tcalculateCost(model, output.usage);\n\t\tif (options?.applyServiceTierPricing) {\n\t\t\tconst serviceTier = options.resolveServiceTier\n\t\t\t\t? options.resolveServiceTier(response?.service_tier, options.serviceTier)\n\t\t\t\t: (response?.service_tier ?? options.serviceTier);\n\t\t\toptions.applyServiceTierPricing(output.usage, serviceTier);\n\t\t}\n\t\t// Map status to stop reason. For incomplete responses, retain the provider's\n\t\t// specific reason so max-output truncation and content filtering stay distinct.\n\t\tconst status = response?.status;\n\t\tconst incompleteDetails = response?.incomplete_details as { reason?: unknown } | null | undefined;\n\t\tconst incompleteReason = typeof incompleteDetails?.reason === \"string\" ? incompleteDetails.reason : undefined;\n\t\toutput.rawStopReason = incompleteReason ? `${status}.${incompleteReason}` : status;\n\t\tconst mappedStop = mapStopReason(status, incompleteReason);\n\t\toutput.stopReason = mappedStop.stopReason;\n\t\toutput.errorMessage = mappedStop.errorMessage;\n\t\tif (output.content.some((b) => b.type === \"toolCall\") && output.stopReason === \"stop\") {\n\t\t\toutput.stopReason = \"toolUse\";\n\t\t}\n\t};\n\n\tfor await (const event of openaiStream) {\n\t\tif (event.type === \"response.created\") {\n\t\t\toutput.responseId = event.response.id;\n\t\t} else if (event.type === \"response.output_item.added\") {\n\t\t\tcreateSlot(event.output_index, event.item);\n\t\t} else if (event.type === \"response.reasoning_summary_text.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"thinking\");\n\t\t\tif (!slot) continue;\n\t\t\tslot.block.thinking += event.delta;\n\t\t\tstream.push({\n\t\t\t\ttype: \"thinking_delta\",\n\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\tdelta: event.delta,\n\t\t\t\tpartial: output,\n\t\t\t});\n\t\t} else if (event.type === \"response.reasoning_summary_part.done\") {\n\t\t\tconst slot = getSlot(event.output_index, \"thinking\");\n\t\t\tif (!slot) continue;\n\t\t\tslot.block.thinking += \"\\n\\n\";\n\t\t\tstream.push({\n\t\t\t\ttype: \"thinking_delta\",\n\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\tdelta: \"\\n\\n\",\n\t\t\t\tpartial: output,\n\t\t\t});\n\t\t} else if (event.type === \"response.reasoning_text.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"thinking\");\n\t\t\tif (!slot) continue;\n\t\t\tslot.block.thinking += event.delta;\n\t\t\tstream.push({\n\t\t\t\ttype: \"thinking_delta\",\n\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\tdelta: event.delta,\n\t\t\t\tpartial: output,\n\t\t\t});\n\t\t} else if (event.type === \"response.output_text.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"text\");\n\t\t\tif (!slot) continue;\n\t\t\tslot.block.text += event.delta;\n\t\t\tstream.push({\n\t\t\t\ttype: \"text_delta\",\n\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\tdelta: event.delta,\n\t\t\t\tpartial: output,\n\t\t\t});\n\t\t} else if (event.type === \"response.refusal.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"text\");\n\t\t\tif (!slot) continue;\n\t\t\tslot.block.text += event.delta;\n\t\t\tstream.push({\n\t\t\t\ttype: \"text_delta\",\n\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\tdelta: event.delta,\n\t\t\t\tpartial: output,\n\t\t\t});\n\t\t} else if (event.type === \"response.function_call_arguments.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"toolCall\");\n\t\t\tif (!slot || slot.block.partialJson === undefined) continue;\n\t\t\tslot.block.partialJson += event.delta;\n\t\t\tslot.block.arguments = parseStreamingJson(slot.block.partialJson);\n\t\t\tpushToolCallDelta(slot, event.delta);\n\t\t} else if (event.type === \"response.function_call_arguments.done\") {\n\t\t\tconst slot = getSlot(event.output_index, \"toolCall\");\n\t\t\tif (!slot || slot.block.partialJson === undefined) continue;\n\t\t\tconst previousPartialJson = slot.block.partialJson;\n\t\t\tslot.block.partialJson = event.arguments;\n\t\t\tslot.block.arguments = parseStreamingJson(slot.block.partialJson);\n\n\t\t\tif (event.arguments.startsWith(previousPartialJson)) {\n\t\t\t\tconst delta = event.arguments.slice(previousPartialJson.length);\n\t\t\t\tif (delta.length > 0) pushToolCallDelta(slot, delta);\n\t\t\t}\n\t\t} else if (event.type === \"response.custom_tool_call_input.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"toolCall\");\n\t\t\tif (!slot?.block.customInput) continue;\n\t\t\tpushToolCallDelta(\n\t\t\t\tslot,\n\t\t\t\tappendCustomToolCallInput(slot.block, getCustomToolCallInput(slot.block) + event.delta, false),\n\t\t\t);\n\t\t} else if (event.type === \"response.custom_tool_call_input.done\") {\n\t\t\tconst slot = getSlot(event.output_index, \"toolCall\");\n\t\t\tif (!slot?.block.customInput) continue;\n\t\t\tpushToolCallDelta(slot, appendCustomToolCallInput(slot.block, event.input, true));\n\t\t} else if (event.type === \"response.output_item.done\") {\n\t\t\tconst item = event.item;\n\t\t\tapplyMessagePhaseStopReason(item);\n\t\t\tconst slot = getOrCreateSlot(event.output_index, item);\n\t\t\tconst imageItem = readNativeImageGenerationCall(item);\n\n\t\t\tif (imageItem && slot?.type === \"providerNative\") {\n\t\t\t\treconcileNativeImageSlot(event.output_index, slot, imageItem);\n\t\t\t\tfinalizedNativeImageOutputIndexes.add(event.output_index);\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (item.type === \"reasoning\" && slot?.type === \"thinking\") {\n\t\t\t\tconst summaryText = item.summary?.map((s) => s.text).join(\"\\n\\n\") || \"\";\n\t\t\t\tconst contentText = item.content?.map((c) => c.text).join(\"\\n\\n\") || \"\";\n\t\t\t\tslot.block.thinking = summaryText || contentText || slot.block.thinking;\n\t\t\t\tslot.block.thinkingSignature = JSON.stringify(item);\n\t\t\t\treasoningBlocksById.set(item.id, slot.block);\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"thinking_end\",\n\t\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\t\tcontent: slot.block.thinking,\n\t\t\t\t\tpartial: output,\n\t\t\t\t});\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (item.type === \"message\" && slot?.type === \"text\") {\n\t\t\t\tslot.block.text = item.content?.map((c) => (c.type === \"output_text\" ? c.text : c.refusal)).join(\"\") || \"\";\n\t\t\t\tslot.block.textSignature = encodeTextSignatureV1(item.id, item.phase ?? undefined);\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"text_end\",\n\t\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\t\tcontent: slot.block.text,\n\t\t\t\t\tpartial: output,\n\t\t\t\t});\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (\n\t\t\t\titem.type === \"function_call\" &&\n\t\t\t\tslot?.type === \"toolCall\" &&\n\t\t\t\tslot.block.partialJson !== undefined\n\t\t\t) {\n\t\t\t\tslot.block.arguments = parseStreamingJson(item.arguments || slot.block.partialJson || \"{}\");\n\t\t\t\tif (item.namespace !== undefined) slot.block.namespace = item.namespace;\n\t\t\t\t// Finalize in-place and strip the scratch buffer so replay only\n\t\t\t\t// carries parsed arguments.\n\t\t\t\tdelete slot.block.partialJson;\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"toolcall_end\",\n\t\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\t\ttoolCall: slot.block,\n\t\t\t\t\tpartial: output,\n\t\t\t\t});\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (item.type === \"custom_tool_call\" && slot?.type === \"toolCall\" && slot.block.customInput) {\n\t\t\t\tpushToolCallDelta(\n\t\t\t\t\tslot,\n\t\t\t\t\tappendCustomToolCallInput(slot.block, item.input ?? getCustomToolCallInput(slot.block), true),\n\t\t\t\t);\n\t\t\t\tif (item.namespace !== undefined) slot.block.namespace = item.namespace;\n\t\t\t\tdelete slot.block.customInput;\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"toolcall_end\",\n\t\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\t\ttoolCall: slot.block,\n\t\t\t\t\tpartial: output,\n\t\t\t\t});\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (isResponseCustomToolCallItem(item) && slot?.type === \"toolCall\") {\n\t\t\t\tconst input = typeof item.input === \"string\" ? item.input : \"\";\n\t\t\t\tslot.block.arguments = { input };\n\t\t\t\tdelete (slot.block as { partialJson?: string }).partialJson;\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"toolcall_end\",\n\t\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\t\ttoolCall: slot.block,\n\t\t\t\t\tpartial: output,\n\t\t\t\t});\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (slot?.type === \"providerNative\") {\n\t\t\t\tslot.block.subtype = item.type;\n\t\t\t\tslot.block.raw = item;\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t}\n\t\t} else if (event.type === \"response.completed\" || event.type === \"response.incomplete\") {\n\t\t\tfinalizeResponse(event.response);\n\t\t} else if (event.type === \"error\") {\n\t\t\tthrow new Error(`Error Code ${event.code}: ${event.message}` || \"Unknown error\");\n\t\t} else if (event.type === \"response.failed\") {\n\t\t\tsawTerminalResponseEvent = true;\n\t\t\toutput.rawStopReason = event.response?.status;\n\t\t\tconst error = event.response?.error;\n\t\t\tconst details = event.response?.incomplete_details;\n\t\t\tconst msg = error\n\t\t\t\t? `${error.code || \"unknown\"}: ${error.message || \"no message\"}`\n\t\t\t\t: details?.reason\n\t\t\t\t\t? `incomplete: ${details.reason}`\n\t\t\t\t\t: \"Unknown error (no error details in response)\";\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\tconst hasFinalizedToolCall = output.content.some((block) => block.type === \"toolCall\" && !(\"partialJson\" in block));\n\tif (!sawTerminalResponseEvent && !hasFinalizedToolCall) {\n\t\tthrow new Error(\"OpenAI Responses stream ended before a terminal response event\");\n\t}\n}\n\nfunction mapStopReason(\n\tstatus: OpenAI.Responses.ResponseStatus | undefined,\n\tincompleteReason?: string,\n): { stopReason: StopReason; errorMessage?: string } {\n\tif (!status) return { stopReason: \"stop\" };\n\tswitch (status) {\n\t\tcase \"completed\":\n\t\t\treturn { stopReason: \"stop\" };\n\t\tcase \"incomplete\":\n\t\t\tif (incompleteReason === \"max_output_tokens\") {\n\t\t\t\treturn { stopReason: \"length\" };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstopReason: \"error\",\n\t\t\t\terrorMessage: incompleteReason\n\t\t\t\t\t? `Response incomplete: ${incompleteReason}`\n\t\t\t\t\t: \"Response incomplete without a provider reason\",\n\t\t\t};\n\t\tcase \"failed\":\n\t\tcase \"cancelled\":\n\t\t\treturn { stopReason: \"error\" };\n\t\t// These two are wonky ...\n\t\tcase \"in_progress\":\n\t\tcase \"queued\":\n\t\t\treturn { stopReason: \"stop\" };\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = status;\n\t\t\tthrow new Error(`Unhandled stop reason: ${_exhaustive}`);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"openai-responses-shared.js","sourceRoot":"","sources":["../../src/api/openai-responses-shared.ts"],"names":[],"mappings":"AAgBA,OAAO,EACN,wBAAwB,EAExB,4BAA4B,EAC5B,oBAAoB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EA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a,CAAC;QACnB,KAAK,QAAQ;YACZ,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAC/B,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,WAAW,GAAU,MAAM,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,0BAA0B,WAAW,EAAE,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import type OpenAI from \"openai\";\nimport type {\n\tResponseInputItem as OpenAIResponseInputItem,\n\tTool as OpenAITool,\n\tResponseCreateParamsStreaming,\n\tResponseFunctionCallOutputItemList,\n\tResponseInput,\n\tResponseInputContent,\n\tResponseInputImage,\n\tResponseInputText,\n\tResponseOutputItem,\n\tResponseOutputMessage,\n\tResponseReasoningItem,\n\tResponseStreamEvent,\n\tResponseToolSearchOutputItemParam,\n} from \"openai/resources/responses/responses.js\";\nimport {\n\tCONTEXT_PROVENANCE_FIELD,\n\ttype ContextProvenance,\n\tcontextProvenanceFingerprint,\n\tgetContextProvenance,\n} from \"../context-provenance.ts\";\nimport { calculateCost } from \"../models.ts\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tContext,\n\tImageContent,\n\tModel,\n\tProviderNativeContent,\n\tStopReason,\n\tTextContent,\n\tTextSignatureV1,\n\tThinkingContent,\n\tTool,\n\tToolCall,\n\tUsage,\n} from \"../types.ts\";\nimport type { AssistantMessageEventStream } from \"../utils/event-stream.ts\";\nimport { shortHash } from \"../utils/hash.ts\";\nimport { parseStreamingJson } from \"../utils/json-parse.ts\";\nimport { sanitizeSurrogates } from \"../utils/sanitize-unicode.ts\";\nimport {\n\tappendGrammarToolInputJsonDelta,\n\ttype GrammarToolInputJsonBuffer,\n\tgetGrammarToolInput,\n\tgetJsonSchemaToolParameters,\n\tresolveGrammarConstrainedSampling,\n\tresolveJsonSchemaStrictSampling,\n} from \"./constrained-sampling.ts\";\nimport { transformMessages } from \"./transform-messages.ts\";\n\n// =============================================================================\n// Utilities\n// =============================================================================\n\nfunction encodeTextSignatureV1(id: string, phase?: TextSignatureV1[\"phase\"]): string {\n\tconst payload: TextSignatureV1 = { v: 1, id };\n\tif (phase) payload.phase = phase;\n\treturn JSON.stringify(payload);\n}\n\nfunction parseTextSignature(\n\tsignature: string | undefined,\n): { id: string; phase?: TextSignatureV1[\"phase\"] } | undefined {\n\tif (!signature) return undefined;\n\tif (signature.startsWith(\"{\")) {\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(signature) as Partial<TextSignatureV1>;\n\t\t\tif (parsed.v === 1 && typeof parsed.id === \"string\") {\n\t\t\t\tif (parsed.phase === \"commentary\" || parsed.phase === \"final_answer\") {\n\t\t\t\t\treturn { id: parsed.id, phase: parsed.phase };\n\t\t\t\t}\n\t\t\t\treturn { id: parsed.id };\n\t\t\t}\n\t\t} catch {\n\t\t\t// Fall through to legacy plain-string handling.\n\t\t}\n\t}\n\treturn { id: signature };\n}\n\n/**\n * Parse a persisted reasoning-item signature, rejecting anything that is not a\n * genuine Responses reasoning item. Foreign providers store non-JSON markers\n * (Kimi's \"reasoning_content\") or opaque payloads (Anthropic signatures) in\n * the same field; an unguarded JSON.parse turns a provenance mix-up into a\n * client-side throw, and blindly pushing the parsed value leaks invalid items.\n */\nfunction parseReasoningSignature(signature: string | undefined): ResponseReasoningItem | undefined {\n\tif (!signature) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(signature) as ResponseReasoningItem;\n\t\treturn parsed?.type === \"reasoning\" ? parsed : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\ntype ToolResultOutputContent = Array<ResponseInputText | ResponseInputImage>;\n\nfunction convertToolResultOutput<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontent: readonly (TextContent | ImageContent)[],\n): string | ToolResultOutputContent {\n\tconst textResult = content\n\t\t.filter((c): c is TextContent => c.type === \"text\")\n\t\t.map((c) => c.text)\n\t\t.join(\"\\n\");\n\tconst images = content.filter((c): c is ImageContent => c.type === \"image\");\n\tconst hasText = textResult.length > 0;\n\n\tif (images.length === 0 || !model.input.includes(\"image\")) {\n\t\treturn sanitizeSurrogates(hasText ? textResult : images.length > 0 ? \"(see attached image)\" : \"(no tool output)\");\n\t}\n\n\tconst output: ToolResultOutputContent = [];\n\tif (hasText) {\n\t\toutput.push({ type: \"input_text\", text: sanitizeSurrogates(textResult) });\n\t}\n\tfor (const image of images) {\n\t\toutput.push({\n\t\t\ttype: \"input_image\",\n\t\t\tdetail: \"auto\",\n\t\t\timage_url: `data:${image.mimeType};base64,${image.data}`,\n\t\t});\n\t}\n\treturn output;\n}\n\nexport interface OpenAIResponsesStreamOptions {\n\tserviceTier?: ResponseCreateParamsStreaming[\"service_tier\"] | \"fast\";\n\tgrammarToolInputProperties?: ReadonlyMap<string, string>;\n\tresolveServiceTier?: (\n\t\tresponseServiceTier: ResponseCreateParamsStreaming[\"service_tier\"] | \"fast\" | undefined,\n\t\trequestServiceTier: ResponseCreateParamsStreaming[\"service_tier\"] | \"fast\" | undefined,\n\t) => ResponseCreateParamsStreaming[\"service_tier\"] | \"fast\" | undefined;\n\tapplyServiceTierPricing?: (\n\t\tusage: Usage,\n\t\tserviceTier: ResponseCreateParamsStreaming[\"service_tier\"] | \"fast\" | undefined,\n\t) => void;\n}\n\nexport interface ConvertResponsesMessagesOptions {\n\tincludeSystemPrompt?: boolean;\n\tpreserveThinking?: boolean;\n\tpreserveTextSignatures?: boolean;\n\tgrammarToolInputProperties?: ReadonlyMap<string, string>;\n\tdeferredTools?: ReadonlyMap<string, Tool>;\n\tdeferredToolsMode?: \"additional-tools\" | \"tool-search\";\n\ttoolOptions?: ConvertResponsesToolsOptions;\n\t/** Internal request-local provenance sealing pass. Never serialized to provider payloads. */\n\tsealContextProvenance?: boolean;\n}\n\nexport interface ConvertResponsesToolsOptions {\n\tstrict?: boolean | null;\n\tsupportsStrictMode?: boolean;\n\tsupportsOpenAIGrammarTools?: boolean;\n\tdeferLoading?: boolean;\n}\n\ntype ResponseCustomToolCallItem = {\n\ttype: \"custom_tool_call\";\n\tid?: string;\n\tcall_id: string;\n\tname: string;\n\tinput?: string;\n\tnamespace?: string;\n};\n\ntype ResponseCustomToolCallOutputItem = {\n\ttype: \"custom_tool_call_output\";\n\tcall_id: string;\n\tname?: string;\n\toutput: string | ResponseFunctionCallOutputItemList;\n};\n\ntype AdditionalToolsInputItem = {\n\ttype: \"additional_tools\";\n\trole: \"developer\";\n\ttools: OpenAITool[];\n};\n\ntype ResponseInputItem =\n\t| OpenAIResponseInputItem\n\t| ResponseCustomToolCallItem\n\t| ResponseCustomToolCallOutputItem\n\t| AdditionalToolsInputItem;\n\nexport const CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL = \"custom\";\n\ntype ResponseFunctionTool = Extract<OpenAITool, { type: \"function\" }>;\n\nfunction isResponseCustomToolCallItem(item: { type?: string }): item is ResponseCustomToolCallItem {\n\treturn item.type === \"custom_tool_call\";\n}\n\nfunction isFreeformTool(tool: Tool): boolean {\n\treturn tool.freeform !== undefined;\n}\n\nfunction isFreeformToolName(toolName: string, tools: Tool[] | undefined): boolean {\n\treturn tools?.some((tool) => tool.name === toolName && isFreeformTool(tool)) ?? false;\n}\n\nfunction getFreeformToolInput(argumentsValue: Record<string, unknown>): string {\n\treturn typeof argumentsValue.input === \"string\" ? argumentsValue.input : JSON.stringify(argumentsValue);\n}\n\nfunction contextProvenanceForInput(message: unknown, seal: boolean | undefined): ContextProvenance | undefined {\n\tconst provenance = getContextProvenance(message);\n\tif (!provenance) return undefined;\n\tconst fingerprint = contextProvenanceFingerprint(message);\n\tif (fingerprint === undefined) return undefined;\n\tconst stored = provenance.integrity;\n\tif (stored === undefined && seal) {\n\t\tprovenance.integrity = fingerprint;\n\t\treturn provenance;\n\t}\n\treturn stored === fingerprint ? provenance : undefined;\n}\n\nfunction withContextProvenance<T extends object>(item: T, message: unknown, seal: boolean | undefined): T {\n\tconst provenance = contextProvenanceForInput(message, seal);\n\tif (provenance) {\n\t\tObject.defineProperty(item, CONTEXT_PROVENANCE_FIELD, {\n\t\t\tvalue: provenance,\n\t\t\tenumerable: false,\n\t\t});\n\t}\n\treturn item;\n}\n// =============================================================================\n// Message conversion\n// =============================================================================\n\nexport function convertResponsesMessages<TApi extends Api>(\n\tmodel: Model<TApi>,\n\tcontext: Context,\n\tallowedToolCallProviders: ReadonlySet<string>,\n\toptions?: ConvertResponsesMessagesOptions,\n): ResponseInput {\n\tconst messages: ResponseInputItem[] = [];\n\tconst loadedToolNames = new Set<string>();\n\n\tconst normalizeIdPart = (part: string): string => {\n\t\tconst sanitized = part.replace(/[^a-zA-Z0-9_-]/g, \"_\");\n\t\tconst normalized = sanitized.length > 64 ? sanitized.slice(0, 64) : sanitized;\n\t\treturn normalized.replace(/_+$/, \"\");\n\t};\n\n\tconst buildForeignResponsesItemId = (itemId: string): string => {\n\t\tconst normalized = `fc_${shortHash(itemId)}`;\n\t\treturn normalized.length > 64 ? normalized.slice(0, 64) : normalized;\n\t};\n\n\tconst normalizeToolCallId = (id: string, _targetModel: Model<TApi>, source: AssistantMessage): string => {\n\t\tif (!id.includes(\"|\")) return normalizeIdPart(id);\n\t\tconst [callId, itemId] = id.split(\"|\");\n\t\tconst normalizedCallId = normalizeIdPart(callId);\n\t\tif (itemId === CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL) {\n\t\t\treturn `${normalizedCallId}|${CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL}`;\n\t\t}\n\t\tif (!allowedToolCallProviders.has(model.provider)) return normalizeIdPart(id);\n\t\tconst isForeignToolCall = source.provider !== model.provider || source.api !== model.api;\n\t\tlet normalizedItemId = isForeignToolCall ? buildForeignResponsesItemId(itemId) : normalizeIdPart(itemId);\n\t\t// OpenAI Responses API requires item id to start with \"fc\"\n\t\tif (!normalizedItemId.startsWith(\"fc_\")) {\n\t\t\tnormalizedItemId = normalizeIdPart(`fc_${normalizedItemId}`);\n\t\t}\n\t\treturn `${normalizedCallId}|${normalizedItemId}`;\n\t};\n\n\tconst transformedMessages = transformMessages(context.messages, model, normalizeToolCallId, {\n\t\tpreserveThinking: options?.preserveThinking,\n\t\tpreserveTextSignatures: options?.preserveTextSignatures,\n\t});\n\n\tconst includeSystemPrompt = options?.includeSystemPrompt ?? true;\n\tif (includeSystemPrompt && context.systemPrompt) {\n\t\tconst compat = model.compat as { supportsDeveloperRole?: boolean } | undefined;\n\t\tconst role = model.reasoning && compat?.supportsDeveloperRole !== false ? \"developer\" : \"system\";\n\t\tmessages.push({\n\t\t\trole,\n\t\t\tcontent: sanitizeSurrogates(context.systemPrompt),\n\t\t});\n\t}\n\n\tlet msgIndex = 0;\n\tfor (const msg of transformedMessages) {\n\t\tif (msg.role === \"user\") {\n\t\t\tif (typeof msg.content === \"string\") {\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\t\tcontent: [{ type: \"input_text\", text: sanitizeSurrogates(msg.content) }],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst content: ResponseInputContent[] = msg.content.map((item): ResponseInputContent => {\n\t\t\t\t\tif (item.type === \"text\") {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: \"input_text\",\n\t\t\t\t\t\t\ttext: sanitizeSurrogates(item.text),\n\t\t\t\t\t\t} satisfies ResponseInputText;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"input_image\",\n\t\t\t\t\t\tdetail: \"auto\",\n\t\t\t\t\t\timage_url: `data:${item.mimeType};base64,${item.data}`,\n\t\t\t\t\t} satisfies ResponseInputImage;\n\t\t\t\t});\n\t\t\t\tif (content.length === 0) continue;\n\t\t\t\tmessages.push(withContextProvenance({ role: \"user\", content }, msg, options?.sealContextProvenance));\n\t\t\t}\n\t\t} else if (msg.role === \"assistant\") {\n\t\t\tconst output: ResponseInputItem[] = [];\n\t\t\tconst assistantMsg = msg as AssistantMessage;\n\t\t\tconst isSameProviderAndApi = assistantMsg.provider === model.provider && assistantMsg.api === model.api;\n\t\t\tconst isSameModel = isSameProviderAndApi && assistantMsg.model === model.id;\n\t\t\tconst isDifferentModel = isSameProviderAndApi && assistantMsg.model !== model.id;\n\t\t\tlet textBlockIndex = 0;\n\n\t\t\tconst pushAssistantText = (text: string, textSignature?: string): void => {\n\t\t\t\tconst parsedSignature = parseTextSignature(textSignature);\n\t\t\t\tconst fallbackMessageId =\n\t\t\t\t\ttextBlockIndex === 0 ? `msg_pi_${msgIndex}` : `msg_pi_${msgIndex}_${textBlockIndex}`;\n\t\t\t\ttextBlockIndex++;\n\t\t\t\t// OpenAI requires id to be max 64 characters\n\t\t\t\tlet msgId = parsedSignature?.id;\n\t\t\t\tif (!msgId) {\n\t\t\t\t\tmsgId = fallbackMessageId;\n\t\t\t\t} else if (msgId.length > 64) {\n\t\t\t\t\tmsgId = `msg_${shortHash(msgId)}`;\n\t\t\t\t}\n\t\t\t\toutput.push({\n\t\t\t\t\ttype: \"message\",\n\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\tcontent: [{ type: \"output_text\", text: sanitizeSurrogates(text), annotations: [] }],\n\t\t\t\t\tstatus: \"completed\",\n\t\t\t\t\tid: msgId,\n\t\t\t\t\tphase: parsedSignature?.phase,\n\t\t\t\t} satisfies ResponseOutputMessage);\n\t\t\t};\n\n\t\t\tfor (const block of msg.content) {\n\t\t\t\tif (block.type === \"thinking\") {\n\t\t\t\t\tconst reasoningItem = parseReasoningSignature(block.thinkingSignature);\n\t\t\t\t\tif (reasoningItem) {\n\t\t\t\t\t\toutput.push(reasoningItem);\n\t\t\t\t\t} else if (block.thinkingSignature && block.thinking.trim() !== \"\") {\n\t\t\t\t\t\t// A signed thinking block whose signature is not a real reasoning\n\t\t\t\t\t\t// item (foreign provenance or corrupted state): demote to plain\n\t\t\t\t\t\t// text, mirroring the cross-model policy in transformMessages.\n\t\t\t\t\t\tpushAssistantText(block.thinking);\n\t\t\t\t\t}\n\t\t\t\t\t// Signed foreign blocks with no text are intentionally dropped.\n\t\t\t\t} else if (block.type === \"providerNative\") {\n\t\t\t\t} else if (block.type === \"text\") {\n\t\t\t\t\tconst textBlock = block as TextContent;\n\t\t\t\t\tpushAssistantText(textBlock.text, textBlock.textSignature);\n\t\t\t\t} else if (block.type === \"toolCall\") {\n\t\t\t\t\tconst toolCall = block as ToolCall;\n\t\t\t\t\tconst [callId, itemIdRaw] = toolCall.id.split(\"|\");\n\t\t\t\t\tconst customInputProperty = options?.grammarToolInputProperties?.get(toolCall.name);\n\t\t\t\t\tconst isPersistedFreeform = itemIdRaw === CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL;\n\t\t\t\t\tconst isFreeform = isFreeformToolName(toolCall.name, context.tools) || isPersistedFreeform;\n\t\t\t\t\tlet itemId: string | undefined = isPersistedFreeform ? undefined : itemIdRaw;\n\n\t\t\t\t\t// An active grammar declaration wins over sentinel recovery below: its\n\t\t\t\t\t// named input property is richer than the persisted freeform fallback.\n\n\t\t\t\t\t// For different-model messages, set id to undefined to avoid pairing validation.\n\t\t\t\t\t// OpenAI tracks which fc_xxx IDs were paired with rs_xxx reasoning items.\n\t\t\t\t\t// By omitting the id, we avoid triggering that validation (like cross-provider does).\n\t\t\t\t\t// Function-call item ids must begin with fc_ while freeform calls can replay\n\t\t\t\t\t// without the local <call_id>|custom sentinel.\n\t\t\t\t\tif (\n\t\t\t\t\t\t(isDifferentModel && itemId?.startsWith(\"fc_\")) ||\n\t\t\t\t\t\t(!isFreeform && customInputProperty === undefined && !itemId?.startsWith(\"fc_\"))\n\t\t\t\t\t) {\n\t\t\t\t\t\titemId = undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst canReplayNamespace = isSameModel || options?.deferredTools?.has(toolCall.name) === true;\n\n\t\t\t\t\tif (customInputProperty !== undefined) {\n\t\t\t\t\t\toutput.push({\n\t\t\t\t\t\t\ttype: \"custom_tool_call\",\n\t\t\t\t\t\t\t...(itemId !== undefined ? { id: itemId } : {}),\n\t\t\t\t\t\t\tcall_id: callId,\n\t\t\t\t\t\t\tname: toolCall.name,\n\t\t\t\t\t\t\tinput: sanitizeSurrogates(\n\t\t\t\t\t\t\t\tgetGrammarToolInput(toolCall.name, toolCall.arguments, customInputProperty),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t...(canReplayNamespace && toolCall.namespace !== undefined\n\t\t\t\t\t\t\t\t? { namespace: toolCall.namespace }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t} satisfies ResponseCustomToolCallItem);\n\t\t\t\t\t} else if (isFreeform) {\n\t\t\t\t\t\toutput.push({\n\t\t\t\t\t\t\ttype: \"custom_tool_call\",\n\t\t\t\t\t\t\tcall_id: callId,\n\t\t\t\t\t\t\tname: toolCall.name,\n\t\t\t\t\t\t\tinput: getFreeformToolInput(toolCall.arguments),\n\t\t\t\t\t\t\t...(canReplayNamespace && toolCall.namespace !== undefined\n\t\t\t\t\t\t\t\t? { namespace: toolCall.namespace }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t} satisfies ResponseCustomToolCallItem);\n\t\t\t\t\t} else {\n\t\t\t\t\t\toutput.push({\n\t\t\t\t\t\t\ttype: \"function_call\",\n\t\t\t\t\t\t\t...(itemId?.startsWith(\"fc_\") ? { id: itemId } : {}),\n\t\t\t\t\t\t\tcall_id: callId,\n\t\t\t\t\t\t\tname: toolCall.name,\n\t\t\t\t\t\t\targuments: JSON.stringify(toolCall.arguments),\n\t\t\t\t\t\t\t...(canReplayNamespace && toolCall.namespace !== undefined\n\t\t\t\t\t\t\t\t? { namespace: toolCall.namespace }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (output.length === 0) continue;\n\t\t\tmessages.push(...output.map((item) => withContextProvenance(item, msg, options?.sealContextProvenance)));\n\t\t} else if (msg.role === \"toolResult\") {\n\t\t\tconst [callId, itemIdRaw] = msg.toolCallId.split(\"|\");\n\t\t\tconst output = convertToolResultOutput(model, msg.content);\n\t\t\tconst customInputProperty = options?.grammarToolInputProperties?.get(msg.toolName);\n\t\t\tconst isPersistedFreeform = itemIdRaw === CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL;\n\n\t\t\tif (customInputProperty !== undefined) {\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"custom_tool_call_output\",\n\t\t\t\t\t\t\tcall_id: callId,\n\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t} satisfies ResponseCustomToolCallOutputItem,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else if (isFreeformToolName(msg.toolName, context.tools) || isPersistedFreeform) {\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"custom_tool_call_output\",\n\t\t\t\t\t\t\tcall_id: callId,\n\t\t\t\t\t\t\tname: msg.toolName,\n\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t} satisfies ResponseCustomToolCallOutputItem,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{ type: \"function_call_output\", call_id: callId, output },\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst deferredTools: Tool[] = [];\n\t\t\tfor (const name of msg.addedToolNames ?? []) {\n\t\t\t\tconst tool = options?.deferredTools?.get(name);\n\t\t\t\tif (!tool || loadedToolNames.has(name)) continue;\n\t\t\t\tloadedToolNames.add(name);\n\t\t\t\tdeferredTools.push(tool);\n\t\t\t}\n\t\t\tif (deferredTools.length > 0 && options?.deferredToolsMode === \"additional-tools\") {\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"additional_tools\",\n\t\t\t\t\t\t\trole: \"developer\",\n\t\t\t\t\t\t\ttools: convertResponsesTools(deferredTools, options.toolOptions),\n\t\t\t\t\t\t} satisfies ResponseInputItem,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else if (deferredTools.length > 0 && options?.deferredToolsMode === \"tool-search\") {\n\t\t\t\tconst names = deferredTools.map((tool) => tool.name);\n\t\t\t\tconst searchCallId = `pi_tool_load_${shortHash(`${msg.toolCallId}:${names.join(\",\")}`)}`;\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"tool_search_call\",\n\t\t\t\t\t\t\tcall_id: searchCallId,\n\t\t\t\t\t\t\texecution: \"client\",\n\t\t\t\t\t\t\tstatus: \"completed\",\n\t\t\t\t\t\t\targuments: { query: names.join(\" \"), limit: names.length },\n\t\t\t\t\t\t} satisfies ResponseInputItem,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tmessages.push(\n\t\t\t\t\twithContextProvenance(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"tool_search_output\",\n\t\t\t\t\t\t\tcall_id: searchCallId,\n\t\t\t\t\t\t\texecution: \"client\",\n\t\t\t\t\t\t\tstatus: \"completed\",\n\t\t\t\t\t\t\ttools: convertResponsesTools(deferredTools, {\n\t\t\t\t\t\t\t\t...options?.toolOptions,\n\t\t\t\t\t\t\t\tdeferLoading: true,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t} satisfies ResponseToolSearchOutputItemParam,\n\t\t\t\t\t\tmsg,\n\t\t\t\t\t\toptions?.sealContextProvenance,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tmsgIndex++;\n\t}\n\n\treturn messages as ResponseInput;\n}\n\n// =============================================================================\n// Tool conversion\n// =============================================================================\n\nexport function convertResponsesTools(tools: readonly Tool[], options?: ConvertResponsesToolsOptions): OpenAITool[] {\n\tconst defaultStrict = options?.strict === undefined ? false : options.strict;\n\tconst supportsStrictMode = options?.supportsStrictMode ?? true;\n\tconst supportsOpenAIGrammarTools = options?.supportsOpenAIGrammarTools ?? false;\n\n\treturn tools.map((tool) => {\n\t\tconst grammar = resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools);\n\t\tif (grammar) {\n\t\t\treturn {\n\t\t\t\ttype: \"custom\",\n\t\t\t\tname: tool.name,\n\t\t\t\tdescription: tool.description,\n\t\t\t\tformat: {\n\t\t\t\t\ttype: \"grammar\",\n\t\t\t\t\tsyntax: grammar.format,\n\t\t\t\t\tdefinition: grammar.definition,\n\t\t\t\t},\n\t\t\t\t...(options?.deferLoading ? { defer_loading: true } : {}),\n\t\t\t} satisfies OpenAITool;\n\t\t}\n\t\tif (tool.freeform) {\n\t\t\treturn {\n\t\t\t\ttype: \"custom\",\n\t\t\t\tname: tool.name,\n\t\t\t\tdescription: tool.description,\n\t\t\t\tformat: tool.freeform,\n\t\t\t\t...(options?.deferLoading ? { defer_loading: true } : {}),\n\t\t\t} as OpenAITool;\n\t\t}\n\n\t\tconst constrainedStrict = resolveJsonSchemaStrictSampling(tool, supportsStrictMode);\n\t\tconst strict = constrainedStrict ?? defaultStrict;\n\t\tconst functionTool: Omit<ResponseFunctionTool, \"strict\"> & {\n\t\t\tstrict?: ResponseFunctionTool[\"strict\"];\n\t\t} = {\n\t\t\ttype: \"function\",\n\t\t\tname: tool.name,\n\t\t\tdescription: tool.description,\n\t\t\tparameters: getJsonSchemaToolParameters(tool, strict === true) as ResponseFunctionTool[\"parameters\"],\n\t\t\t...(options?.deferLoading ? { defer_loading: true } : {}),\n\t\t};\n\t\tif (supportsStrictMode) {\n\t\t\tfunctionTool.strict = strict;\n\t\t}\n\t\treturn functionTool as OpenAITool;\n\t});\n}\n\n// =============================================================================\n// Stream processing\n// =============================================================================\n\ntype StreamingToolCall = ToolCall & {\n\tpartialJson?: string;\n\tcustomInput?: {\n\t\tproperty: string;\n\t\tjsonBuffer: GrammarToolInputJsonBuffer;\n\t};\n};\n\nfunction getCustomToolCallInput(block: StreamingToolCall): string {\n\tconst property = block.customInput?.property;\n\tif (property === undefined) return \"\";\n\tconst value = block.arguments[property];\n\treturn typeof value === \"string\" ? value : \"\";\n}\n\nfunction appendCustomToolCallInput(block: StreamingToolCall, nextInput: string, close: boolean): string | undefined {\n\tconst customInput = block.customInput;\n\tif (!customInput) return undefined;\n\tconst delta = appendGrammarToolInputJsonDelta(customInput.jsonBuffer, customInput.property, nextInput, close);\n\tblock.arguments = { [customInput.property]: nextInput };\n\treturn delta;\n}\n\ntype ResponsesOutputSlot =\n\t| { type: \"thinking\"; block: ThinkingContent; contentIndex: number }\n\t| { type: \"text\"; block: TextContent; contentIndex: number }\n\t| { type: \"toolCall\"; block: StreamingToolCall; contentIndex: number }\n\t| { type: \"providerNative\"; block: ProviderNativeContent; contentIndex: number };\n\ntype ToolCallOutputSlot = Extract<ResponsesOutputSlot, { type: \"toolCall\" }>;\n\ntype NativeImageGenerationCall = {\n\ttype: \"image_generation_call\";\n\tid?: string;\n\tstatus: string;\n\tresult?: string | null;\n\trevised_prompt?: string;\n};\n\nconst MAX_NATIVE_IMAGE_BASE64_CHARS = 24 * 1024 * 1024;\n\nfunction readNativeImageGenerationCall(value: unknown): NativeImageGenerationCall | undefined {\n\tif (typeof value !== \"object\" || value === null || !(\"type\" in value) || !(\"status\" in value)) return undefined;\n\tif (value.type !== \"image_generation_call\" || typeof value.status !== \"string\") return undefined;\n\treturn {\n\t\ttype: \"image_generation_call\",\n\t\t...(\"id\" in value && typeof value.id === \"string\" ? { id: value.id } : {}),\n\t\tstatus: value.status,\n\t\t...(\"result\" in value && (typeof value.result === \"string\" || value.result === null)\n\t\t\t? { result: value.result }\n\t\t\t: {}),\n\t\t...(\"revised_prompt\" in value && typeof value.revised_prompt === \"string\"\n\t\t\t? { revised_prompt: value.revised_prompt }\n\t\t\t: {}),\n\t};\n}\n\nfunction isValidBase64(value: string): boolean {\n\treturn value.length > 0 && value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(value);\n}\n\nfunction reconcileNativeImageGenerationCall(item: NativeImageGenerationCall): NativeImageGenerationCall {\n\tif (item.status !== \"completed\") {\n\t\treturn {\n\t\t\ttype: \"image_generation_call\",\n\t\t\t...(item.id !== undefined ? { id: item.id } : {}),\n\t\t\tstatus: item.status,\n\t\t};\n\t}\n\tif (typeof item.result !== \"string\" || !isValidBase64(item.result)) {\n\t\treturn {\n\t\t\ttype: \"image_generation_call\",\n\t\t\t...(item.id !== undefined ? { id: item.id } : {}),\n\t\t\tstatus: \"malformed\",\n\t\t};\n\t}\n\treturn {\n\t\ttype: \"image_generation_call\",\n\t\t...(item.id !== undefined ? { id: item.id } : {}),\n\t\tstatus: \"completed\",\n\t\tresult: item.result,\n\t\t...(item.revised_prompt?.trim() ? { revised_prompt: item.revised_prompt } : {}),\n\t};\n}\n\nexport async function processResponsesStream<TApi extends Api>(\n\topenaiStream: AsyncIterable<ResponseStreamEvent>,\n\toutput: AssistantMessage,\n\tstream: AssistantMessageEventStream,\n\tmodel: Model<TApi>,\n\toptions?: OpenAIResponsesStreamOptions,\n): Promise<void> {\n\tlet sawTerminalResponseEvent = false;\n\tlet nativeImageBase64Chars = 0;\n\tconst outputSlots = new Map<number, ResponsesOutputSlot>();\n\tconst reasoningBlocksById = new Map<string, ThinkingContent>();\n\tconst nativeImageCharsByOutputIndex = new Map<number, number>();\n\tconst finalizedNativeImageOutputIndexes = new Set<number>();\n\tconst applyMessagePhaseStopReason = (item: ResponseOutputItem): void => {\n\t\tif (item.type === \"message\" && item.phase === \"final_answer\") {\n\t\t\toutput.stopReason = \"stop\";\n\t\t}\n\t};\n\tconst getSlot = <TType extends ResponsesOutputSlot[\"type\"]>(\n\t\toutputIndex: number,\n\t\ttype: TType,\n\t): Extract<ResponsesOutputSlot, { type: TType }> | undefined => {\n\t\tconst slot = outputSlots.get(outputIndex);\n\t\treturn slot?.type === type ? (slot as Extract<ResponsesOutputSlot, { type: TType }>) : undefined;\n\t};\n\tconst pushToolCallDelta = (slot: ToolCallOutputSlot, delta: string | undefined): void => {\n\t\tif (delta === undefined) return;\n\t\tstream.push({\n\t\t\ttype: \"toolcall_delta\",\n\t\t\tcontentIndex: slot.contentIndex,\n\t\t\tdelta,\n\t\t\tpartial: output,\n\t\t});\n\t};\n\tconst createSlot = (\n\t\toutputIndex: number,\n\t\titem: ResponseOutputItem | ResponseCustomToolCallItem,\n\t): ResponsesOutputSlot | undefined => {\n\t\tif (item.type === \"reasoning\") {\n\t\t\tconst block: ThinkingContent = { type: \"thinking\", thinking: \"\" };\n\t\t\toutput.content.push(block);\n\t\t\tconst slot = {\n\t\t\t\ttype: \"thinking\",\n\t\t\t\tblock,\n\t\t\t\tcontentIndex: output.content.length - 1,\n\t\t\t} satisfies ResponsesOutputSlot;\n\t\t\toutputSlots.set(outputIndex, slot);\n\t\t\tstream.push({ type: \"thinking_start\", contentIndex: slot.contentIndex, partial: output });\n\t\t\treturn slot;\n\t\t}\n\t\tif (item.type === \"message\") {\n\t\t\tapplyMessagePhaseStopReason(item);\n\t\t\tconst block: TextContent = { type: \"text\", text: \"\" };\n\t\t\toutput.content.push(block);\n\t\t\tconst slot = { type: \"text\", block, contentIndex: output.content.length - 1 } satisfies ResponsesOutputSlot;\n\t\t\toutputSlots.set(outputIndex, slot);\n\t\t\tstream.push({ type: \"text_start\", contentIndex: slot.contentIndex, partial: output });\n\t\t\treturn slot;\n\t\t}\n\t\tif (item.type === \"function_call\") {\n\t\t\tconst block: StreamingToolCall = {\n\t\t\t\ttype: \"toolCall\",\n\t\t\t\tid: `${item.call_id}|${item.id}`,\n\t\t\t\tname: item.name,\n\t\t\t\targuments: {},\n\t\t\t\t...(item.namespace !== undefined ? { namespace: item.namespace } : {}),\n\t\t\t\tpartialJson: item.arguments || \"\",\n\t\t\t};\n\t\t\toutput.content.push(block);\n\t\t\tconst slot = {\n\t\t\t\ttype: \"toolCall\",\n\t\t\t\tblock,\n\t\t\t\tcontentIndex: output.content.length - 1,\n\t\t\t} satisfies ResponsesOutputSlot;\n\t\t\toutputSlots.set(outputIndex, slot);\n\t\t\tstream.push({ type: \"toolcall_start\", contentIndex: slot.contentIndex, partial: output });\n\t\t\treturn slot;\n\t\t}\n\t\tif (isResponseCustomToolCallItem(item)) {\n\t\t\tconst inputProperty = options?.grammarToolInputProperties?.get(item.name) ?? \"input\";\n\t\t\tconst input = item.input || \"\";\n\t\t\tconst block: StreamingToolCall = {\n\t\t\t\ttype: \"toolCall\",\n\t\t\t\tid: `${item.call_id}|${item.id ?? CUSTOM_TOOL_CALL_ITEM_ID_SENTINEL}`,\n\t\t\t\tname: item.name,\n\t\t\t\targuments: { [inputProperty]: input },\n\t\t\t\t...(item.namespace !== undefined ? { namespace: item.namespace } : {}),\n\t\t\t\tcustomInput: {\n\t\t\t\t\tproperty: inputProperty,\n\t\t\t\t\tjsonBuffer: { input: \"\", started: false, closed: false },\n\t\t\t\t},\n\t\t\t};\n\t\t\toutput.content.push(block);\n\t\t\tconst slot = {\n\t\t\t\ttype: \"toolCall\",\n\t\t\t\tblock,\n\t\t\t\tcontentIndex: output.content.length - 1,\n\t\t\t} satisfies ResponsesOutputSlot;\n\t\t\toutputSlots.set(outputIndex, slot);\n\t\t\tstream.push({ type: \"toolcall_start\", contentIndex: slot.contentIndex, partial: output });\n\t\t\treturn slot;\n\t\t}\n\t\tconst imageItem = readNativeImageGenerationCall(item);\n\t\tconst block = {\n\t\t\ttype: \"providerNative\",\n\t\t\tsubtype: item.type,\n\t\t\traw: imageItem ? reconcileNativeImageGenerationCall(imageItem) : item,\n\t\t} satisfies ProviderNativeContent;\n\t\tconst slot = {\n\t\t\ttype: \"providerNative\",\n\t\t\tblock,\n\t\t\tcontentIndex: output.content.length,\n\t\t} satisfies ResponsesOutputSlot;\n\t\tif (imageItem) reconcileNativeImageSlot(outputIndex, slot, imageItem);\n\t\toutput.content.push(block);\n\t\toutputSlots.set(outputIndex, slot);\n\t\treturn slot;\n\t};\n\tconst getOrCreateSlot = (\n\t\toutputIndex: number,\n\t\titem: ResponseOutputItem | ResponseCustomToolCallItem,\n\t): ResponsesOutputSlot | undefined => {\n\t\treturn outputSlots.get(outputIndex) ?? createSlot(outputIndex, item);\n\t};\n\tfunction scrubNativeImageResults(): void {\n\t\tfor (const block of output.content) {\n\t\t\tif (block.type !== \"providerNative\" || block.subtype !== \"image_generation_call\") continue;\n\t\t\tconst item = readNativeImageGenerationCall(block.raw);\n\t\t\tif (typeof item?.result !== \"string\") continue;\n\t\t\tblock.raw = {\n\t\t\t\ttype: \"image_generation_call\",\n\t\t\t\t...(item.id !== undefined ? { id: item.id } : {}),\n\t\t\t\tstatus: \"malformed\",\n\t\t\t};\n\t\t}\n\t\tnativeImageBase64Chars = 0;\n\t\tnativeImageCharsByOutputIndex.clear();\n\t}\n\tfunction reconcileNativeImageSlot(\n\t\toutputIndex: number,\n\t\tslot: Extract<ResponsesOutputSlot, { type: \"providerNative\" }>,\n\t\titem: NativeImageGenerationCall,\n\t): void {\n\t\tconst reconciled = reconcileNativeImageGenerationCall(item);\n\t\tconst previousChars = nativeImageCharsByOutputIndex.get(outputIndex) ?? 0;\n\t\tconst nextChars = typeof reconciled.result === \"string\" ? reconciled.result.length : 0;\n\t\tconst nextTotal = nativeImageBase64Chars - previousChars + nextChars;\n\t\tif (nextTotal > MAX_NATIVE_IMAGE_BASE64_CHARS) {\n\t\t\tscrubNativeImageResults();\n\t\t\tthrow new Error(\"Native image generation results exceed the 24 MiB base64 limit\");\n\t\t}\n\t\tnativeImageBase64Chars = nextTotal;\n\t\tif (nextChars > 0) nativeImageCharsByOutputIndex.set(outputIndex, nextChars);\n\t\telse nativeImageCharsByOutputIndex.delete(outputIndex);\n\t\tslot.block.subtype = \"image_generation_call\";\n\t\tslot.block.raw = reconciled;\n\t}\n\tconst backfillNativeImageGenerationCalls = (responseOutput: readonly ResponseOutputItem[]): void => {\n\t\tfor (const [outputIndex, outputItem] of responseOutput.entries()) {\n\t\t\tif (finalizedNativeImageOutputIndexes.has(outputIndex)) continue;\n\t\t\tconst imageItem = readNativeImageGenerationCall(outputItem);\n\t\t\tif (!imageItem) continue;\n\t\t\tconst existingSlot = getSlot(outputIndex, \"providerNative\");\n\t\t\tif (existingSlot) reconcileNativeImageSlot(outputIndex, existingSlot, imageItem);\n\t\t\telse createSlot(outputIndex, outputItem);\n\t\t\toutputSlots.delete(outputIndex);\n\t\t}\n\t};\n\t// Azure OpenAI can omit reasoning.encrypted_content from response.output_item.done\n\t// and provide it only in response.completed.response.output. Backfill the\n\t// persisted reasoning signature from the terminal response to keep store:false\n\t// multi-turn replay stateless. See https://github.com/earendil-works/pi/issues/6409.\n\tconst backfillReasoningSignatures = (responseOutput: ResponseOutputItem[]): void => {\n\t\tfor (const item of responseOutput) {\n\t\t\tif (item.type !== \"reasoning\" || !item.encrypted_content) continue;\n\t\t\tconst block = reasoningBlocksById.get(item.id);\n\t\t\tif (!block?.thinkingSignature) continue;\n\n\t\t\tconst storedItem = parseReasoningSignature(block.thinkingSignature);\n\t\t\tif (!storedItem || storedItem.encrypted_content) continue;\n\t\t\tblock.thinkingSignature = JSON.stringify({\n\t\t\t\t...storedItem,\n\t\t\t\tencrypted_content: item.encrypted_content,\n\t\t\t});\n\t\t}\n\t};\n\tconst finalizeResponse = (\n\t\tresponse: Extract<ResponseStreamEvent, { type: \"response.completed\" | \"response.incomplete\" }>[\"response\"],\n\t) => {\n\t\tsawTerminalResponseEvent = true;\n\t\tbackfillReasoningSignatures(response.output ?? []);\n\t\tbackfillNativeImageGenerationCalls(response.output ?? []);\n\t\tif (response?.id) {\n\t\t\toutput.responseId = response.id;\n\t\t}\n\t\tif (response?.usage) {\n\t\t\tconst inputDetails = response.usage.input_tokens_details as\n\t\t\t\t| { cached_tokens?: number; cache_write_tokens?: number }\n\t\t\t\t| undefined;\n\t\t\tconst cachedTokens = inputDetails?.cached_tokens || 0;\n\t\t\tconst cacheWriteTokens = inputDetails?.cache_write_tokens || 0;\n\t\t\toutput.usage = {\n\t\t\t\t// OpenAI includes cached and cache-write tokens in input_tokens, so subtract both.\n\t\t\t\tinput: Math.max(0, (response.usage.input_tokens || 0) - cachedTokens - cacheWriteTokens),\n\t\t\t\toutput: response.usage.output_tokens || 0,\n\t\t\t\tcacheRead: cachedTokens,\n\t\t\t\tcacheWrite: cacheWriteTokens,\n\t\t\t\treasoning: response.usage.output_tokens_details?.reasoning_tokens || 0,\n\t\t\t\ttotalTokens: response.usage.total_tokens || 0,\n\t\t\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\t\t};\n\t\t}\n\t\tcalculateCost(model, output.usage);\n\t\tif (options?.applyServiceTierPricing) {\n\t\t\tconst serviceTier = options.resolveServiceTier\n\t\t\t\t? options.resolveServiceTier(response?.service_tier, options.serviceTier)\n\t\t\t\t: (response?.service_tier ?? options.serviceTier);\n\t\t\toptions.applyServiceTierPricing(output.usage, serviceTier);\n\t\t}\n\t\t// Map status to stop reason. For incomplete responses, retain the provider's\n\t\t// specific reason so max-output truncation and content filtering stay distinct.\n\t\tconst status = response?.status;\n\t\tconst incompleteDetails = response?.incomplete_details as { reason?: unknown } | null | undefined;\n\t\tconst incompleteReason = typeof incompleteDetails?.reason === \"string\" ? incompleteDetails.reason : undefined;\n\t\toutput.rawStopReason = incompleteReason ? `${status}.${incompleteReason}` : status;\n\t\tconst mappedStop = mapStopReason(status, incompleteReason);\n\t\toutput.stopReason = mappedStop.stopReason;\n\t\toutput.errorMessage = mappedStop.errorMessage;\n\t\tif (output.content.some((b) => b.type === \"toolCall\") && output.stopReason === \"stop\") {\n\t\t\toutput.stopReason = \"toolUse\";\n\t\t}\n\t};\n\n\tfor await (const event of openaiStream) {\n\t\tif (event.type === \"response.created\") {\n\t\t\toutput.responseId = event.response.id;\n\t\t} else if (event.type === \"response.output_item.added\") {\n\t\t\tcreateSlot(event.output_index, event.item);\n\t\t} else if (event.type === \"response.reasoning_summary_text.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"thinking\");\n\t\t\tif (!slot) continue;\n\t\t\tslot.block.thinking += event.delta;\n\t\t\tstream.push({\n\t\t\t\ttype: \"thinking_delta\",\n\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\tdelta: event.delta,\n\t\t\t\tpartial: output,\n\t\t\t});\n\t\t} else if (event.type === \"response.reasoning_summary_part.done\") {\n\t\t\tconst slot = getSlot(event.output_index, \"thinking\");\n\t\t\tif (!slot) continue;\n\t\t\tslot.block.thinking += \"\\n\\n\";\n\t\t\tstream.push({\n\t\t\t\ttype: \"thinking_delta\",\n\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\tdelta: \"\\n\\n\",\n\t\t\t\tpartial: output,\n\t\t\t});\n\t\t} else if (event.type === \"response.reasoning_text.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"thinking\");\n\t\t\tif (!slot) continue;\n\t\t\tslot.block.thinking += event.delta;\n\t\t\tstream.push({\n\t\t\t\ttype: \"thinking_delta\",\n\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\tdelta: event.delta,\n\t\t\t\tpartial: output,\n\t\t\t});\n\t\t} else if (event.type === \"response.output_text.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"text\");\n\t\t\tif (!slot) continue;\n\t\t\tslot.block.text += event.delta;\n\t\t\tstream.push({\n\t\t\t\ttype: \"text_delta\",\n\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\tdelta: event.delta,\n\t\t\t\tpartial: output,\n\t\t\t});\n\t\t} else if (event.type === \"response.refusal.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"text\");\n\t\t\tif (!slot) continue;\n\t\t\tslot.block.text += event.delta;\n\t\t\tstream.push({\n\t\t\t\ttype: \"text_delta\",\n\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\tdelta: event.delta,\n\t\t\t\tpartial: output,\n\t\t\t});\n\t\t} else if (event.type === \"response.function_call_arguments.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"toolCall\");\n\t\t\tif (!slot || slot.block.partialJson === undefined) continue;\n\t\t\tslot.block.partialJson += event.delta;\n\t\t\tslot.block.arguments = parseStreamingJson(slot.block.partialJson);\n\t\t\tpushToolCallDelta(slot, event.delta);\n\t\t} else if (event.type === \"response.function_call_arguments.done\") {\n\t\t\tconst slot = getSlot(event.output_index, \"toolCall\");\n\t\t\tif (!slot || slot.block.partialJson === undefined) continue;\n\t\t\tconst previousPartialJson = slot.block.partialJson;\n\t\t\tslot.block.partialJson = event.arguments;\n\t\t\tslot.block.arguments = parseStreamingJson(slot.block.partialJson);\n\n\t\t\tif (event.arguments.startsWith(previousPartialJson)) {\n\t\t\t\tconst delta = event.arguments.slice(previousPartialJson.length);\n\t\t\t\tif (delta.length > 0) pushToolCallDelta(slot, delta);\n\t\t\t}\n\t\t} else if (event.type === \"response.custom_tool_call_input.delta\") {\n\t\t\tconst slot = getSlot(event.output_index, \"toolCall\");\n\t\t\tif (!slot?.block.customInput) continue;\n\t\t\tpushToolCallDelta(\n\t\t\t\tslot,\n\t\t\t\tappendCustomToolCallInput(slot.block, getCustomToolCallInput(slot.block) + event.delta, false),\n\t\t\t);\n\t\t} else if (event.type === \"response.custom_tool_call_input.done\") {\n\t\t\tconst slot = getSlot(event.output_index, \"toolCall\");\n\t\t\tif (!slot?.block.customInput) continue;\n\t\t\tpushToolCallDelta(slot, appendCustomToolCallInput(slot.block, event.input, true));\n\t\t} else if (event.type === \"response.output_item.done\") {\n\t\t\tconst item = event.item;\n\t\t\tapplyMessagePhaseStopReason(item);\n\t\t\tconst slot = getOrCreateSlot(event.output_index, item);\n\t\t\tconst imageItem = readNativeImageGenerationCall(item);\n\n\t\t\tif (imageItem && slot?.type === \"providerNative\") {\n\t\t\t\treconcileNativeImageSlot(event.output_index, slot, imageItem);\n\t\t\t\tfinalizedNativeImageOutputIndexes.add(event.output_index);\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (item.type === \"reasoning\" && slot?.type === \"thinking\") {\n\t\t\t\tconst summaryText = item.summary?.map((s) => s.text).join(\"\\n\\n\") || \"\";\n\t\t\t\tconst contentText = item.content?.map((c) => c.text).join(\"\\n\\n\") || \"\";\n\t\t\t\tslot.block.thinking = summaryText || contentText || slot.block.thinking;\n\t\t\t\tslot.block.thinkingSignature = JSON.stringify(item);\n\t\t\t\treasoningBlocksById.set(item.id, slot.block);\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"thinking_end\",\n\t\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\t\tcontent: slot.block.thinking,\n\t\t\t\t\tpartial: output,\n\t\t\t\t});\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (item.type === \"message\" && slot?.type === \"text\") {\n\t\t\t\tslot.block.text = item.content?.map((c) => (c.type === \"output_text\" ? c.text : c.refusal)).join(\"\") || \"\";\n\t\t\t\tslot.block.textSignature = encodeTextSignatureV1(item.id, item.phase ?? undefined);\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"text_end\",\n\t\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\t\tcontent: slot.block.text,\n\t\t\t\t\tpartial: output,\n\t\t\t\t});\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (\n\t\t\t\titem.type === \"function_call\" &&\n\t\t\t\tslot?.type === \"toolCall\" &&\n\t\t\t\tslot.block.partialJson !== undefined\n\t\t\t) {\n\t\t\t\tslot.block.arguments = parseStreamingJson(item.arguments || slot.block.partialJson || \"{}\");\n\t\t\t\tif (item.namespace !== undefined) slot.block.namespace = item.namespace;\n\t\t\t\t// Finalize in-place and strip the scratch buffer so replay only\n\t\t\t\t// carries parsed arguments.\n\t\t\t\tdelete slot.block.partialJson;\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"toolcall_end\",\n\t\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\t\ttoolCall: slot.block,\n\t\t\t\t\tpartial: output,\n\t\t\t\t});\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (item.type === \"custom_tool_call\" && slot?.type === \"toolCall\" && slot.block.customInput) {\n\t\t\t\tpushToolCallDelta(\n\t\t\t\t\tslot,\n\t\t\t\t\tappendCustomToolCallInput(slot.block, item.input ?? getCustomToolCallInput(slot.block), true),\n\t\t\t\t);\n\t\t\t\tif (item.namespace !== undefined) slot.block.namespace = item.namespace;\n\t\t\t\tdelete slot.block.customInput;\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"toolcall_end\",\n\t\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\t\ttoolCall: slot.block,\n\t\t\t\t\tpartial: output,\n\t\t\t\t});\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (isResponseCustomToolCallItem(item) && slot?.type === \"toolCall\") {\n\t\t\t\tconst input = typeof item.input === \"string\" ? item.input : \"\";\n\t\t\t\tslot.block.arguments = { input };\n\t\t\t\tdelete (slot.block as { partialJson?: string }).partialJson;\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"toolcall_end\",\n\t\t\t\t\tcontentIndex: slot.contentIndex,\n\t\t\t\t\ttoolCall: slot.block,\n\t\t\t\t\tpartial: output,\n\t\t\t\t});\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t} else if (slot?.type === \"providerNative\") {\n\t\t\t\tslot.block.subtype = item.type;\n\t\t\t\tslot.block.raw = item;\n\t\t\t\toutputSlots.delete(event.output_index);\n\t\t\t}\n\t\t} else if (event.type === \"response.completed\" || event.type === \"response.incomplete\") {\n\t\t\tfinalizeResponse(event.response);\n\t\t} else if (event.type === \"error\") {\n\t\t\tthrow new Error(`Error Code ${event.code}: ${event.message}` || \"Unknown error\");\n\t\t} else if (event.type === \"response.failed\") {\n\t\t\tsawTerminalResponseEvent = true;\n\t\t\toutput.rawStopReason = event.response?.status;\n\t\t\tconst error = event.response?.error;\n\t\t\tconst details = event.response?.incomplete_details;\n\t\t\tconst msg = error\n\t\t\t\t? `${error.code || \"unknown\"}: ${error.message || \"no message\"}`\n\t\t\t\t: details?.reason\n\t\t\t\t\t? `incomplete: ${details.reason}`\n\t\t\t\t\t: \"Unknown error (no error details in response)\";\n\t\t\tthrow new Error(msg);\n\t\t}\n\t}\n\tconst hasFinalizedToolCall = output.content.some((block) => block.type === \"toolCall\" && !(\"partialJson\" in block));\n\tif (!sawTerminalResponseEvent && !hasFinalizedToolCall) {\n\t\tthrow new Error(\"OpenAI Responses stream ended before a terminal response event\");\n\t}\n}\n\nfunction mapStopReason(\n\tstatus: OpenAI.Responses.ResponseStatus | undefined,\n\tincompleteReason?: string,\n): { stopReason: StopReason; errorMessage?: string } {\n\tif (!status) return { stopReason: \"stop\" };\n\tswitch (status) {\n\t\tcase \"completed\":\n\t\t\treturn { stopReason: \"stop\" };\n\t\tcase \"incomplete\":\n\t\t\tif (incompleteReason === \"max_output_tokens\") {\n\t\t\t\treturn { stopReason: \"length\" };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstopReason: \"error\",\n\t\t\t\terrorMessage: incompleteReason\n\t\t\t\t\t? `Response incomplete: ${incompleteReason}`\n\t\t\t\t\t: \"Response incomplete without a provider reason\",\n\t\t\t};\n\t\tcase \"failed\":\n\t\tcase \"cancelled\":\n\t\t\treturn { stopReason: \"error\" };\n\t\t// These two are wonky ...\n\t\tcase \"in_progress\":\n\t\tcase \"queued\":\n\t\t\treturn { stopReason: \"stop\" };\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = status;\n\t\t\tthrow new Error(`Unhandled stop reason: ${_exhaustive}`);\n\t\t}\n\t}\n}\n"]}
@@ -16,7 +16,7 @@ export interface CachedWebSocketConnection {
16
16
  export interface OpenAIResponsesOptions extends StreamOptions {
17
17
  reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
18
18
  reasoningSummary?: "auto" | "detailed" | "concise" | null;
19
- serviceTier?: ResponseCreateParamsStreaming["service_tier"];
19
+ serviceTier?: ResponseCreateParamsStreaming["service_tier"] | "fast";
20
20
  toolChoice?: ResponseCreateParamsStreaming["tool_choice"];
21
21
  }
22
22
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"openai-responses.d.ts","sourceRoot":"","sources":["../../src/api/openai-responses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAuB,MAAM,yCAAyC,CAAC;AAElH,OAAO,KAAK,EASX,mBAAmB,EACnB,cAAc,EACd,aAAa,EAEb,MAAM,aAAa,CAAC;AAuBrB,KAAK,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AACjE,KAAK,iBAAiB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAElD,UAAU,aAAa;IACtB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC9E,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACjF;AAED,MAAM,WAAW,yBAAyB;IACzC,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,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,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC9E,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACjF;AAED,MAAM,WAAW,yBAAyB;IACzC,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;CAC1C;AA6HD,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC5D,eAAe,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;IAC1E,gBAAgB,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC;IAC1D,WAAW,CAAC,EAAE,6BAA6B,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC;IACrE,UAAU,CAAC,EAAE,6BAA6B,CAAC,aAAa,CAAC,CAAC;CAC1D;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,kBAAkB,EAAE,sBAAsB,CA8I7E,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,kBAAkB,EAAE,mBAAmB,CAuBhF,CAAC;AAkLF;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,IAAI,CAmBxG;AAED,mEAAmE;AACnE,wBAAgB,oCAAoC,IAAI,MAAM,CAE7D"}
@@ -1,5 +1,5 @@
1
1
  import OpenAI from "openai";
2
- import { clampThinkingLevel, supportsMax, supportsXhigh } from "../models.js";
2
+ import { clampThinkingLevel, inferOpenAIThinkingLevelMap, supportsMax, supportsXhigh } from "../models.js";
3
3
  import { splitDeferredTools } from "../utils/deferred-tools.js";
4
4
  import { formatProviderError, normalizeProviderError } from "../utils/error-body.js";
5
5
  import { AssistantMessageEventStream } from "../utils/event-stream.js";
@@ -52,6 +52,7 @@ function getCompat(model, env) {
52
52
  supportsAdditionalTools: model.compat?.supportsAdditionalTools ?? false,
53
53
  supportsToolSearch: model.compat?.supportsToolSearch ?? false,
54
54
  supportsExplicitPromptCacheMode: model.compat?.supportsExplicitPromptCacheMode ?? false,
55
+ supportsMaxOutputTokens: model.compat?.supportsMaxOutputTokens ?? true,
55
56
  };
56
57
  }
57
58
  function isOpenAIResponsesNativeEndpoint(model, env) {
@@ -274,7 +275,8 @@ function buildParams(model, context, options, compat = getCompat(model, options?
274
275
  : undefined;
275
276
  const toolPlacement = splitDeferredTools(context, deferredToolsMode !== undefined);
276
277
  const requestedReasoningEffort = options?.reasoningEffort ?? (options?.reasoningSummary ? "medium" : undefined);
277
- const mappedReasoningEffort = requestedReasoningEffort === undefined ? undefined : model.thinkingLevelMap?.[requestedReasoningEffort];
278
+ const thinkingLevelMap = inferOpenAIThinkingLevelMap(model);
279
+ const mappedReasoningEffort = requestedReasoningEffort === undefined ? undefined : thinkingLevelMap?.[requestedReasoningEffort];
278
280
  const reasoningEffort = mappedReasoningEffort === undefined ? requestedReasoningEffort : mappedReasoningEffort;
279
281
  const reasoningRequested = reasoningEffort !== undefined && reasoningEffort !== null;
280
282
  const reasoningUnavailable = reasoningEffort === null;
@@ -299,7 +301,7 @@ function buildParams(model, context, options, compat = getCompat(model, options?
299
301
  prompt_cache_options: disableImplicitPromptCache ? { mode: "explicit" } : undefined,
300
302
  store: false,
301
303
  };
302
- if (options?.maxTokens) {
304
+ if (options?.maxTokens && compat.supportsMaxOutputTokens) {
303
305
  params.max_output_tokens = Math.max(options.maxTokens, OPENAI_RESPONSES_MIN_OUTPUT_TOKENS);
304
306
  }
305
307
  if (options?.temperature !== undefined) {
@@ -325,9 +327,9 @@ function buildParams(model, context, options, compat = getCompat(model, options?
325
327
  };
326
328
  params.include = ["reasoning.encrypted_content"];
327
329
  }
328
- else if (!reasoningUnavailable && model.provider !== "github-copilot" && model.thinkingLevelMap?.off !== null) {
330
+ else if (!reasoningUnavailable && model.provider !== "github-copilot" && thinkingLevelMap?.off !== null) {
329
331
  params.reasoning = {
330
- effort: (model.thinkingLevelMap?.off ?? "none"),
332
+ effort: (thinkingLevelMap?.off ?? "none"),
331
333
  };
332
334
  }
333
335
  if (model.provider === "xai")
@@ -704,6 +706,7 @@ function getServiceTierCostMultiplier(model, serviceTier) {
704
706
  case "flex":
705
707
  return 0.5;
706
708
  case "priority":
709
+ case "fast":
707
710
  return model.id === "gpt-5.5" ? 2.5 : 2;
708
711
  default:
709
712
  return 1;