@coro-ai/runner 0.1.32 → 0.1.33

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 (377) hide show
  1. package/dashboard-dist/assets/{index--JceWwKS.js → index-C7l2FOsX.js} +9 -3
  2. package/dashboard-dist/index.html +1 -1
  3. package/dist/src/config/local-config.d.ts +3 -0
  4. package/dist/src/config/local-config.js +2 -0
  5. package/dist/src/config/local-config.js.map +1 -1
  6. package/dist/src/intake/handler.js +27 -9
  7. package/dist/src/intake/handler.js.map +1 -1
  8. package/dist/src/intake/system-prompt.d.ts +1 -0
  9. package/dist/src/intake/system-prompt.js +8 -1
  10. package/dist/src/intake/system-prompt.js.map +1 -1
  11. package/dist/src/intake/tools.js +5 -0
  12. package/dist/src/intake/tools.js.map +1 -1
  13. package/dist/src/jobs/runner.d.ts +6 -0
  14. package/dist/src/jobs/runner.js +7 -0
  15. package/dist/src/jobs/runner.js.map +1 -1
  16. package/node_modules/@coro-ai/cloud-protocol/package.json +1 -1
  17. package/node_modules/@coro-ai/intelligence-base/package.json +1 -1
  18. package/node_modules/@coro-ai/llm-anthropic/dist/chat-via-sdk.d.ts +2 -0
  19. package/node_modules/@coro-ai/llm-anthropic/dist/chat-via-sdk.d.ts.map +1 -1
  20. package/node_modules/@coro-ai/llm-anthropic/dist/chat-via-sdk.js +25 -46
  21. package/node_modules/@coro-ai/llm-anthropic/dist/chat-via-sdk.js.map +1 -1
  22. package/node_modules/@coro-ai/llm-anthropic/dist/executor.d.ts +7 -0
  23. package/node_modules/@coro-ai/llm-anthropic/dist/executor.d.ts.map +1 -1
  24. package/node_modules/@coro-ai/llm-anthropic/dist/executor.js +57 -3
  25. package/node_modules/@coro-ai/llm-anthropic/dist/executor.js.map +1 -1
  26. package/node_modules/@coro-ai/llm-anthropic/dist/http-routes.d.ts.map +1 -1
  27. package/node_modules/@coro-ai/llm-anthropic/dist/http-routes.js +3 -2
  28. package/node_modules/@coro-ai/llm-anthropic/dist/http-routes.js.map +1 -1
  29. package/node_modules/@coro-ai/llm-anthropic/dist/index.d.ts +1 -1
  30. package/node_modules/@coro-ai/llm-anthropic/dist/index.d.ts.map +1 -1
  31. package/node_modules/@coro-ai/llm-anthropic/dist/index.js +2 -1
  32. package/node_modules/@coro-ai/llm-anthropic/dist/index.js.map +1 -1
  33. package/node_modules/@coro-ai/llm-anthropic/dist/login.d.ts +3 -1
  34. package/node_modules/@coro-ai/llm-anthropic/dist/login.d.ts.map +1 -1
  35. package/node_modules/@coro-ai/llm-anthropic/dist/login.js +5 -2
  36. package/node_modules/@coro-ai/llm-anthropic/dist/login.js.map +1 -1
  37. package/node_modules/@coro-ai/llm-anthropic/dist/test-connection.d.ts +2 -0
  38. package/node_modules/@coro-ai/llm-anthropic/dist/test-connection.d.ts.map +1 -1
  39. package/node_modules/@coro-ai/llm-anthropic/dist/test-connection.js +8 -0
  40. package/node_modules/@coro-ai/llm-anthropic/dist/test-connection.js.map +1 -1
  41. package/node_modules/@coro-ai/llm-anthropic/package.json +1 -1
  42. package/node_modules/@coro-ai/llm-openai/dist/executor.d.ts.map +1 -1
  43. package/node_modules/@coro-ai/llm-openai/dist/executor.js +125 -83
  44. package/node_modules/@coro-ai/llm-openai/dist/executor.js.map +1 -1
  45. package/node_modules/@coro-ai/llm-openai/package.json +1 -1
  46. package/node_modules/@coro-ai/plugin-sdk/dist/chat-mcp.d.ts +30 -0
  47. package/node_modules/@coro-ai/plugin-sdk/dist/chat-mcp.d.ts.map +1 -0
  48. package/node_modules/@coro-ai/plugin-sdk/dist/chat-mcp.js +85 -0
  49. package/node_modules/@coro-ai/plugin-sdk/dist/chat-mcp.js.map +1 -0
  50. package/node_modules/@coro-ai/plugin-sdk/dist/index.d.ts +1 -0
  51. package/node_modules/@coro-ai/plugin-sdk/dist/index.d.ts.map +1 -1
  52. package/node_modules/@coro-ai/plugin-sdk/dist/index.js +1 -0
  53. package/node_modules/@coro-ai/plugin-sdk/dist/index.js.map +1 -1
  54. package/node_modules/@coro-ai/plugin-sdk/dist/types.d.ts +6 -0
  55. package/node_modules/@coro-ai/plugin-sdk/dist/types.d.ts.map +1 -1
  56. package/node_modules/@coro-ai/plugin-sdk/package.json +1 -1
  57. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +9 -17
  58. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +9 -17
  59. package/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
  60. package/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
  61. package/node_modules/hono/dist/cjs/jsx/base.js +8 -14
  62. package/node_modules/hono/dist/cjs/jsx/components.js +41 -21
  63. package/node_modules/hono/dist/cjs/jsx/context.js +131 -5
  64. package/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
  65. package/node_modules/hono/dist/helper/css/common.js +3 -1
  66. package/node_modules/hono/dist/helper/css/index.js +9 -1
  67. package/node_modules/hono/dist/jsx/base.js +15 -15
  68. package/node_modules/hono/dist/jsx/components.js +42 -22
  69. package/node_modules/hono/dist/jsx/context.js +129 -5
  70. package/node_modules/hono/dist/jsx/streaming.js +10 -8
  71. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +1 -1
  72. package/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
  73. package/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
  74. package/node_modules/hono/package.json +1 -1
  75. package/node_modules/openai/CHANGELOG.md +48 -0
  76. package/node_modules/openai/README.md +85 -102
  77. package/node_modules/openai/_vendor/zod-to-json-schema/parseDef.d.mts.map +1 -1
  78. package/node_modules/openai/_vendor/zod-to-json-schema/parseDef.d.ts.map +1 -1
  79. package/node_modules/openai/_vendor/zod-to-json-schema/parseDef.js +41 -15
  80. package/node_modules/openai/_vendor/zod-to-json-schema/parseDef.js.map +1 -1
  81. package/node_modules/openai/_vendor/zod-to-json-schema/parseDef.mjs +41 -15
  82. package/node_modules/openai/_vendor/zod-to-json-schema/parseDef.mjs.map +1 -1
  83. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/branded.d.mts +1 -1
  84. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/branded.d.mts.map +1 -1
  85. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/branded.d.ts +1 -1
  86. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/branded.d.ts.map +1 -1
  87. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/branded.js +2 -2
  88. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/branded.js.map +1 -1
  89. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/branded.mjs +2 -2
  90. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/branded.mjs.map +1 -1
  91. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/catch.d.mts +1 -1
  92. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/catch.d.mts.map +1 -1
  93. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/catch.d.ts +1 -1
  94. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/catch.d.ts.map +1 -1
  95. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/catch.js +2 -2
  96. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/catch.js.map +1 -1
  97. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/catch.mjs +2 -2
  98. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/catch.mjs.map +1 -1
  99. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/default.d.mts +1 -1
  100. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/default.d.mts.map +1 -1
  101. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/default.d.ts +1 -1
  102. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/default.d.ts.map +1 -1
  103. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/default.js +2 -2
  104. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/default.js.map +1 -1
  105. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/default.mjs +2 -2
  106. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/default.mjs.map +1 -1
  107. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nullable.d.mts +1 -1
  108. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nullable.d.mts.map +1 -1
  109. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nullable.d.ts +1 -1
  110. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nullable.d.ts.map +1 -1
  111. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nullable.js +2 -2
  112. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nullable.js.map +1 -1
  113. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nullable.mjs +2 -2
  114. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/nullable.mjs.map +1 -1
  115. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.d.mts +1 -1
  116. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.d.mts.map +1 -1
  117. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.d.ts +1 -1
  118. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.d.ts.map +1 -1
  119. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.js +3 -3
  120. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.js.map +1 -1
  121. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.mjs +3 -3
  122. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/optional.mjs.map +1 -1
  123. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/pipeline.d.mts +1 -1
  124. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/pipeline.d.mts.map +1 -1
  125. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/pipeline.d.ts +1 -1
  126. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/pipeline.d.ts.map +1 -1
  127. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/pipeline.js +3 -3
  128. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/pipeline.js.map +1 -1
  129. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/pipeline.mjs +3 -3
  130. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/pipeline.mjs.map +1 -1
  131. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/promise.d.mts +1 -1
  132. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/promise.d.mts.map +1 -1
  133. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/promise.d.ts +1 -1
  134. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/promise.d.ts.map +1 -1
  135. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/promise.js +2 -2
  136. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/promise.js.map +1 -1
  137. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/promise.mjs +2 -2
  138. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/promise.mjs.map +1 -1
  139. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/readonly.d.mts +1 -1
  140. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/readonly.d.mts.map +1 -1
  141. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/readonly.d.ts +1 -1
  142. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/readonly.d.ts.map +1 -1
  143. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/readonly.js +2 -2
  144. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/readonly.js.map +1 -1
  145. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/readonly.mjs +2 -2
  146. package/node_modules/openai/_vendor/zod-to-json-schema/parsers/readonly.mjs.map +1 -1
  147. package/node_modules/openai/auth/workload-identity-auth.d.mts.map +1 -1
  148. package/node_modules/openai/auth/workload-identity-auth.d.ts.map +1 -1
  149. package/node_modules/openai/auth/workload-identity-auth.js +12 -4
  150. package/node_modules/openai/auth/workload-identity-auth.js.map +1 -1
  151. package/node_modules/openai/auth/workload-identity-auth.mjs +13 -5
  152. package/node_modules/openai/auth/workload-identity-auth.mjs.map +1 -1
  153. package/node_modules/openai/azure.d.mts +3 -1
  154. package/node_modules/openai/azure.d.mts.map +1 -1
  155. package/node_modules/openai/azure.d.ts +3 -1
  156. package/node_modules/openai/azure.d.ts.map +1 -1
  157. package/node_modules/openai/azure.js.map +1 -1
  158. package/node_modules/openai/azure.mjs.map +1 -1
  159. package/node_modules/openai/beta/realtime/internal-base.d.mts +14 -1
  160. package/node_modules/openai/beta/realtime/internal-base.d.mts.map +1 -1
  161. package/node_modules/openai/beta/realtime/internal-base.d.ts +14 -1
  162. package/node_modules/openai/beta/realtime/internal-base.d.ts.map +1 -1
  163. package/node_modules/openai/beta/realtime/internal-base.js +21 -5
  164. package/node_modules/openai/beta/realtime/internal-base.js.map +1 -1
  165. package/node_modules/openai/beta/realtime/internal-base.mjs +21 -5
  166. package/node_modules/openai/beta/realtime/internal-base.mjs.map +1 -1
  167. package/node_modules/openai/beta/realtime/websocket.d.mts +3 -5
  168. package/node_modules/openai/beta/realtime/websocket.d.mts.map +1 -1
  169. package/node_modules/openai/beta/realtime/websocket.d.ts +3 -5
  170. package/node_modules/openai/beta/realtime/websocket.d.ts.map +1 -1
  171. package/node_modules/openai/beta/realtime/websocket.js +2 -3
  172. package/node_modules/openai/beta/realtime/websocket.js.map +1 -1
  173. package/node_modules/openai/beta/realtime/websocket.mjs +3 -4
  174. package/node_modules/openai/beta/realtime/websocket.mjs.map +1 -1
  175. package/node_modules/openai/beta/realtime/ws.d.mts +3 -5
  176. package/node_modules/openai/beta/realtime/ws.d.mts.map +1 -1
  177. package/node_modules/openai/beta/realtime/ws.d.ts +3 -5
  178. package/node_modules/openai/beta/realtime/ws.d.ts.map +1 -1
  179. package/node_modules/openai/beta/realtime/ws.js +2 -3
  180. package/node_modules/openai/beta/realtime/ws.js.map +1 -1
  181. package/node_modules/openai/beta/realtime/ws.mjs +3 -4
  182. package/node_modules/openai/beta/realtime/ws.mjs.map +1 -1
  183. package/node_modules/openai/client.d.mts +9 -1
  184. package/node_modules/openai/client.d.mts.map +1 -1
  185. package/node_modules/openai/client.d.ts +9 -1
  186. package/node_modules/openai/client.d.ts.map +1 -1
  187. package/node_modules/openai/client.js +56 -9
  188. package/node_modules/openai/client.js.map +1 -1
  189. package/node_modules/openai/client.mjs +56 -9
  190. package/node_modules/openai/client.mjs.map +1 -1
  191. package/node_modules/openai/helpers/zod.d.mts.map +1 -1
  192. package/node_modules/openai/helpers/zod.d.ts.map +1 -1
  193. package/node_modules/openai/helpers/zod.js +12 -0
  194. package/node_modules/openai/helpers/zod.js.map +1 -1
  195. package/node_modules/openai/helpers/zod.mjs +12 -0
  196. package/node_modules/openai/helpers/zod.mjs.map +1 -1
  197. package/node_modules/openai/internal/bedrock.d.mts +34 -0
  198. package/node_modules/openai/internal/bedrock.d.mts.map +1 -0
  199. package/node_modules/openai/internal/bedrock.d.ts +34 -0
  200. package/node_modules/openai/internal/bedrock.d.ts.map +1 -0
  201. package/node_modules/openai/internal/bedrock.js +107 -0
  202. package/node_modules/openai/internal/bedrock.js.map +1 -0
  203. package/node_modules/openai/internal/bedrock.mjs +99 -0
  204. package/node_modules/openai/internal/bedrock.mjs.map +1 -0
  205. package/node_modules/openai/internal/provider.d.mts +23 -0
  206. package/node_modules/openai/internal/provider.d.mts.map +1 -0
  207. package/node_modules/openai/internal/provider.d.ts +23 -0
  208. package/node_modules/openai/internal/provider.d.ts.map +1 -0
  209. package/node_modules/openai/internal/provider.js +36 -0
  210. package/node_modules/openai/internal/provider.js.map +1 -0
  211. package/node_modules/openai/internal/provider.mjs +32 -0
  212. package/node_modules/openai/internal/provider.mjs.map +1 -0
  213. package/node_modules/openai/internal/utils/log.d.mts.map +1 -1
  214. package/node_modules/openai/internal/utils/log.d.ts.map +1 -1
  215. package/node_modules/openai/internal/utils/log.js +1 -0
  216. package/node_modules/openai/internal/utils/log.js.map +1 -1
  217. package/node_modules/openai/internal/utils/log.mjs +1 -0
  218. package/node_modules/openai/internal/utils/log.mjs.map +1 -1
  219. package/node_modules/openai/lib/AbstractChatCompletionRunner.d.mts +15 -4
  220. package/node_modules/openai/lib/AbstractChatCompletionRunner.d.mts.map +1 -1
  221. package/node_modules/openai/lib/AbstractChatCompletionRunner.d.ts +15 -4
  222. package/node_modules/openai/lib/AbstractChatCompletionRunner.d.ts.map +1 -1
  223. package/node_modules/openai/lib/AbstractChatCompletionRunner.js +63 -40
  224. package/node_modules/openai/lib/AbstractChatCompletionRunner.js.map +1 -1
  225. package/node_modules/openai/lib/AbstractChatCompletionRunner.mjs +63 -40
  226. package/node_modules/openai/lib/AbstractChatCompletionRunner.mjs.map +1 -1
  227. package/node_modules/openai/lib/AssistantStream.d.mts.map +1 -1
  228. package/node_modules/openai/lib/AssistantStream.d.ts.map +1 -1
  229. package/node_modules/openai/lib/AssistantStream.js +4 -24
  230. package/node_modules/openai/lib/AssistantStream.js.map +1 -1
  231. package/node_modules/openai/lib/AssistantStream.mjs +4 -24
  232. package/node_modules/openai/lib/AssistantStream.mjs.map +1 -1
  233. package/node_modules/openai/lib/ChatCompletionRunner.js +1 -1
  234. package/node_modules/openai/lib/ChatCompletionRunner.js.map +1 -1
  235. package/node_modules/openai/lib/ChatCompletionRunner.mjs +1 -1
  236. package/node_modules/openai/lib/ChatCompletionRunner.mjs.map +1 -1
  237. package/node_modules/openai/lib/ChatCompletionStream.d.mts.map +1 -1
  238. package/node_modules/openai/lib/ChatCompletionStream.d.ts.map +1 -1
  239. package/node_modules/openai/lib/ChatCompletionStream.js +4 -13
  240. package/node_modules/openai/lib/ChatCompletionStream.js.map +1 -1
  241. package/node_modules/openai/lib/ChatCompletionStream.mjs +4 -13
  242. package/node_modules/openai/lib/ChatCompletionStream.mjs.map +1 -1
  243. package/node_modules/openai/lib/ChatCompletionStreamingRunner.js +1 -1
  244. package/node_modules/openai/lib/ChatCompletionStreamingRunner.js.map +1 -1
  245. package/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs +1 -1
  246. package/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs.map +1 -1
  247. package/node_modules/openai/lib/EventEmitter.d.mts.map +1 -1
  248. package/node_modules/openai/lib/EventEmitter.d.ts.map +1 -1
  249. package/node_modules/openai/lib/EventEmitter.js +12 -2
  250. package/node_modules/openai/lib/EventEmitter.js.map +1 -1
  251. package/node_modules/openai/lib/EventEmitter.mjs +12 -2
  252. package/node_modules/openai/lib/EventEmitter.mjs.map +1 -1
  253. package/node_modules/openai/lib/EventStream.d.mts +1 -0
  254. package/node_modules/openai/lib/EventStream.d.mts.map +1 -1
  255. package/node_modules/openai/lib/EventStream.d.ts +1 -0
  256. package/node_modules/openai/lib/EventStream.d.ts.map +1 -1
  257. package/node_modules/openai/lib/EventStream.js +19 -2
  258. package/node_modules/openai/lib/EventStream.js.map +1 -1
  259. package/node_modules/openai/lib/EventStream.mjs +19 -2
  260. package/node_modules/openai/lib/EventStream.mjs.map +1 -1
  261. package/node_modules/openai/lib/ResponsesParser.d.mts.map +1 -1
  262. package/node_modules/openai/lib/ResponsesParser.d.ts.map +1 -1
  263. package/node_modules/openai/lib/ResponsesParser.js +12 -4
  264. package/node_modules/openai/lib/ResponsesParser.js.map +1 -1
  265. package/node_modules/openai/lib/ResponsesParser.mjs +12 -4
  266. package/node_modules/openai/lib/ResponsesParser.mjs.map +1 -1
  267. package/node_modules/openai/lib/responses/ResponseAccumulator.d.mts +10 -0
  268. package/node_modules/openai/lib/responses/ResponseAccumulator.d.mts.map +1 -0
  269. package/node_modules/openai/lib/responses/ResponseAccumulator.d.ts +10 -0
  270. package/node_modules/openai/lib/responses/ResponseAccumulator.d.ts.map +1 -0
  271. package/node_modules/openai/lib/responses/ResponseAccumulator.js +402 -0
  272. package/node_modules/openai/lib/responses/ResponseAccumulator.js.map +1 -0
  273. package/node_modules/openai/lib/responses/ResponseAccumulator.mjs +399 -0
  274. package/node_modules/openai/lib/responses/ResponseAccumulator.mjs.map +1 -0
  275. package/node_modules/openai/lib/responses/ResponseInputItems.d.mts +19 -0
  276. package/node_modules/openai/lib/responses/ResponseInputItems.d.mts.map +1 -0
  277. package/node_modules/openai/lib/responses/ResponseInputItems.d.ts +19 -0
  278. package/node_modules/openai/lib/responses/ResponseInputItems.d.ts.map +1 -0
  279. package/node_modules/openai/lib/responses/ResponseInputItems.js +102 -0
  280. package/node_modules/openai/lib/responses/ResponseInputItems.js.map +1 -0
  281. package/node_modules/openai/lib/responses/ResponseInputItems.mjs +98 -0
  282. package/node_modules/openai/lib/responses/ResponseInputItems.mjs.map +1 -0
  283. package/node_modules/openai/lib/responses/ResponseStream.d.mts.map +1 -1
  284. package/node_modules/openai/lib/responses/ResponseStream.d.ts.map +1 -1
  285. package/node_modules/openai/lib/responses/ResponseStream.js +5 -90
  286. package/node_modules/openai/lib/responses/ResponseStream.js.map +1 -1
  287. package/node_modules/openai/lib/responses/ResponseStream.mjs +5 -90
  288. package/node_modules/openai/lib/responses/ResponseStream.mjs.map +1 -1
  289. package/node_modules/openai/package.json +24 -1
  290. package/node_modules/openai/providers/bedrock/aws.d.mts +24 -0
  291. package/node_modules/openai/providers/bedrock/aws.d.mts.map +1 -0
  292. package/node_modules/openai/providers/bedrock/aws.d.ts +24 -0
  293. package/node_modules/openai/providers/bedrock/aws.d.ts.map +1 -0
  294. package/node_modules/openai/providers/bedrock/aws.js +170 -0
  295. package/node_modules/openai/providers/bedrock/aws.js.map +1 -0
  296. package/node_modules/openai/providers/bedrock/aws.mjs +166 -0
  297. package/node_modules/openai/providers/bedrock/aws.mjs.map +1 -0
  298. package/node_modules/openai/providers/bedrock.d.mts +7 -0
  299. package/node_modules/openai/providers/bedrock.d.mts.map +1 -0
  300. package/node_modules/openai/providers/bedrock.d.ts +7 -0
  301. package/node_modules/openai/providers/bedrock.d.ts.map +1 -0
  302. package/node_modules/openai/providers/bedrock.js +26 -0
  303. package/node_modules/openai/providers/bedrock.js.map +1 -0
  304. package/node_modules/openai/providers/bedrock.mjs +22 -0
  305. package/node_modules/openai/providers/bedrock.mjs.map +1 -0
  306. package/node_modules/openai/realtime/internal-base.d.mts +28 -1
  307. package/node_modules/openai/realtime/internal-base.d.mts.map +1 -1
  308. package/node_modules/openai/realtime/internal-base.d.ts +28 -1
  309. package/node_modules/openai/realtime/internal-base.d.ts.map +1 -1
  310. package/node_modules/openai/realtime/internal-base.js +50 -7
  311. package/node_modules/openai/realtime/internal-base.js.map +1 -1
  312. package/node_modules/openai/realtime/internal-base.mjs +49 -7
  313. package/node_modules/openai/realtime/internal-base.mjs.map +1 -1
  314. package/node_modules/openai/realtime/websocket.d.mts +4 -7
  315. package/node_modules/openai/realtime/websocket.d.mts.map +1 -1
  316. package/node_modules/openai/realtime/websocket.d.ts +4 -7
  317. package/node_modules/openai/realtime/websocket.d.ts.map +1 -1
  318. package/node_modules/openai/realtime/websocket.js +4 -8
  319. package/node_modules/openai/realtime/websocket.js.map +1 -1
  320. package/node_modules/openai/realtime/websocket.mjs +5 -9
  321. package/node_modules/openai/realtime/websocket.mjs.map +1 -1
  322. package/node_modules/openai/realtime/ws.d.mts +4 -7
  323. package/node_modules/openai/realtime/ws.d.mts.map +1 -1
  324. package/node_modules/openai/realtime/ws.d.ts +4 -7
  325. package/node_modules/openai/realtime/ws.d.ts.map +1 -1
  326. package/node_modules/openai/realtime/ws.js +4 -8
  327. package/node_modules/openai/realtime/ws.js.map +1 -1
  328. package/node_modules/openai/realtime/ws.mjs +5 -9
  329. package/node_modules/openai/realtime/ws.mjs.map +1 -1
  330. package/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts +44 -16
  331. package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/branded.ts +2 -2
  332. package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/catch.ts +2 -2
  333. package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/default.ts +6 -2
  334. package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nullable.ts +13 -5
  335. package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/optional.ts +14 -6
  336. package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/pipeline.ts +3 -2
  337. package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/promise.ts +6 -2
  338. package/node_modules/openai/src/_vendor/zod-to-json-schema/parsers/readonly.ts +2 -2
  339. package/node_modules/openai/src/auth/workload-identity-auth.ts +16 -5
  340. package/node_modules/openai/src/azure.ts +4 -1
  341. package/node_modules/openai/src/beta/realtime/internal-base.ts +43 -5
  342. package/node_modules/openai/src/beta/realtime/websocket.ts +10 -7
  343. package/node_modules/openai/src/beta/realtime/ws.ts +10 -7
  344. package/node_modules/openai/src/client.ts +80 -18
  345. package/node_modules/openai/src/helpers/zod.ts +16 -0
  346. package/node_modules/openai/src/internal/bedrock.ts +153 -0
  347. package/node_modules/openai/src/internal/provider.ts +60 -0
  348. package/node_modules/openai/src/internal/utils/log.ts +1 -0
  349. package/node_modules/openai/src/lib/AbstractChatCompletionRunner.ts +96 -45
  350. package/node_modules/openai/src/lib/AssistantStream.ts +4 -20
  351. package/node_modules/openai/src/lib/ChatCompletionRunner.ts +1 -1
  352. package/node_modules/openai/src/lib/ChatCompletionStream.ts +4 -11
  353. package/node_modules/openai/src/lib/ChatCompletionStreamingRunner.ts +1 -1
  354. package/node_modules/openai/src/lib/EventEmitter.ts +11 -2
  355. package/node_modules/openai/src/lib/EventStream.ts +20 -0
  356. package/node_modules/openai/src/lib/ResponsesParser.ts +18 -4
  357. package/node_modules/openai/src/lib/responses/ResponseAccumulator.ts +412 -0
  358. package/node_modules/openai/src/lib/responses/ResponseInputItems.ts +127 -0
  359. package/node_modules/openai/src/lib/responses/ResponseStream.ts +4 -93
  360. package/node_modules/openai/src/providers/bedrock/aws.ts +255 -0
  361. package/node_modules/openai/src/providers/bedrock.ts +33 -0
  362. package/node_modules/openai/src/realtime/internal-base.ts +90 -7
  363. package/node_modules/openai/src/realtime/websocket.ts +15 -13
  364. package/node_modules/openai/src/realtime/ws.ts +15 -13
  365. package/node_modules/openai/src/version.ts +1 -1
  366. package/node_modules/openai/version.d.mts +1 -1
  367. package/node_modules/openai/version.d.ts +1 -1
  368. package/node_modules/openai/version.js +1 -1
  369. package/node_modules/openai/version.mjs +1 -1
  370. package/node_modules/qs/CHANGELOG.md +11 -0
  371. package/node_modules/qs/dist/qs.js +17 -17
  372. package/node_modules/qs/lib/parse.js +19 -8
  373. package/node_modules/qs/lib/utils.js +47 -8
  374. package/node_modules/qs/package.json +6 -5
  375. package/node_modules/qs/test/parse.js +230 -0
  376. package/node_modules/qs/test/utils.js +194 -0
  377. package/package.json +6 -6
@@ -0,0 +1,412 @@
1
+ import {
2
+ type Response,
3
+ type ResponseOutputText,
4
+ type ResponseStreamEvent,
5
+ } from '../../resources/responses/responses';
6
+ import { OpenAIError } from '../../error';
7
+ import { addOutputText } from '../ResponsesParser';
8
+
9
+ /**
10
+ * Applies a streaming event to a response snapshot.
11
+ *
12
+ * Always use the returned snapshot. Incremental events update the supplied snapshot
13
+ * in place, while response lifecycle events return a detached replacement. Event
14
+ * payloads are cloned, so retaining or replaying the raw events is safe.
15
+ */
16
+ export function accumulateResponse(event: ResponseStreamEvent, snapshot?: Response): Response {
17
+ if (!snapshot) {
18
+ if (event.type !== 'response.created') {
19
+ throw new OpenAIError(
20
+ `When snapshot hasn't been set yet, expected 'response.created' event, got ${event.type}`,
21
+ );
22
+ }
23
+ return cloneResponse(event.response);
24
+ }
25
+
26
+ switch (event.type) {
27
+ case 'response.output_item.added': {
28
+ snapshot.output.push(structuredClone(event.item));
29
+ if (event.item.type === 'message') {
30
+ addOutputText(snapshot);
31
+ }
32
+ break;
33
+ }
34
+ case 'response.output_item.done': {
35
+ getOutput(snapshot, event.output_index);
36
+ snapshot.output[event.output_index] = structuredClone(event.item);
37
+ if (event.item.type === 'message') {
38
+ addOutputText(snapshot);
39
+ }
40
+ break;
41
+ }
42
+ case 'response.content_part.added': {
43
+ const output = getOutput(snapshot, event.output_index);
44
+ const type = output.type;
45
+ const part = event.part;
46
+ if (type === 'message' && part.type !== 'reasoning_text') {
47
+ output.content.push(structuredClone(part));
48
+ if (part.type === 'output_text') {
49
+ addOutputText(snapshot);
50
+ }
51
+ } else if (type === 'reasoning' && part.type === 'reasoning_text') {
52
+ if (!output.content) {
53
+ output.content = [];
54
+ }
55
+ output.content.push(structuredClone(part));
56
+ }
57
+ break;
58
+ }
59
+ case 'response.content_part.done': {
60
+ const output = getOutput(snapshot, event.output_index);
61
+ const part = event.part;
62
+ if (output.type === 'message' && part.type !== 'reasoning_text') {
63
+ getContent(output.content, event.content_index);
64
+ output.content[event.content_index] = structuredClone(part);
65
+ if (part.type === 'output_text') {
66
+ addOutputText(snapshot);
67
+ }
68
+ } else if (output.type === 'reasoning' && part.type === 'reasoning_text') {
69
+ const content = output.content;
70
+ if (!content) {
71
+ throw new OpenAIError(`missing content at index ${event.content_index}`);
72
+ }
73
+ getContent(content, event.content_index);
74
+ content[event.content_index] = structuredClone(part);
75
+ }
76
+ break;
77
+ }
78
+ case 'response.output_text.delta': {
79
+ const output = getOutput(snapshot, event.output_index);
80
+ if (output.type === 'message') {
81
+ const content = getContent(output.content, event.content_index);
82
+ if (content.type !== 'output_text') {
83
+ throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
84
+ }
85
+ content.text += event.delta;
86
+ snapshot.output_text += event.delta;
87
+ }
88
+ break;
89
+ }
90
+ case 'response.output_text.done': {
91
+ const output = getOutput(snapshot, event.output_index);
92
+ if (output.type === 'message') {
93
+ const content = getContent(output.content, event.content_index);
94
+ if (content.type !== 'output_text') {
95
+ throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
96
+ }
97
+ content.text = event.text;
98
+ addOutputText(snapshot);
99
+ }
100
+ break;
101
+ }
102
+ case 'response.output_text.annotation.added': {
103
+ const output = getOutput(snapshot, event.output_index);
104
+ if (output.type === 'message') {
105
+ const content = getContent(output.content, event.content_index);
106
+ if (content.type !== 'output_text') {
107
+ throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
108
+ }
109
+ content.annotations[event.annotation_index] = structuredClone(
110
+ event.annotation,
111
+ ) as ResponseOutputText['annotations'][number];
112
+ }
113
+ break;
114
+ }
115
+ case 'response.refusal.delta': {
116
+ const output = getOutput(snapshot, event.output_index);
117
+ if (output.type === 'message') {
118
+ const content = getContent(output.content, event.content_index);
119
+ if (content.type !== 'refusal') {
120
+ throw new OpenAIError(`expected content to be 'refusal', got ${content.type}`);
121
+ }
122
+ content.refusal += event.delta;
123
+ }
124
+ break;
125
+ }
126
+ case 'response.refusal.done': {
127
+ const output = getOutput(snapshot, event.output_index);
128
+ if (output.type === 'message') {
129
+ const content = getContent(output.content, event.content_index);
130
+ if (content.type !== 'refusal') {
131
+ throw new OpenAIError(`expected content to be 'refusal', got ${content.type}`);
132
+ }
133
+ content.refusal = event.refusal;
134
+ }
135
+ break;
136
+ }
137
+ case 'response.function_call_arguments.delta': {
138
+ const output = getOutput(snapshot, event.output_index);
139
+ if (output.type === 'function_call') {
140
+ output.arguments += event.delta;
141
+ }
142
+ break;
143
+ }
144
+ case 'response.function_call_arguments.done': {
145
+ const output = getOutput(snapshot, event.output_index);
146
+ if (output.type === 'function_call') {
147
+ output.arguments = event.arguments;
148
+ }
149
+ break;
150
+ }
151
+ case 'response.reasoning_text.delta': {
152
+ const output = getOutput(snapshot, event.output_index);
153
+ if (output.type === 'reasoning') {
154
+ if (!output.content) {
155
+ throw new OpenAIError(`missing content at index ${event.content_index}`);
156
+ }
157
+ const content = getContent(output.content, event.content_index);
158
+ if (content.type !== 'reasoning_text') {
159
+ throw new OpenAIError(`expected content to be 'reasoning_text', got ${content.type}`);
160
+ }
161
+ content.text += event.delta;
162
+ }
163
+ break;
164
+ }
165
+ case 'response.reasoning_text.done': {
166
+ const output = getOutput(snapshot, event.output_index);
167
+ if (output.type === 'reasoning') {
168
+ if (!output.content) {
169
+ throw new OpenAIError(`missing content at index ${event.content_index}`);
170
+ }
171
+ const content = getContent(output.content, event.content_index);
172
+ if (content.type !== 'reasoning_text') {
173
+ throw new OpenAIError(`expected content to be 'reasoning_text', got ${content.type}`);
174
+ }
175
+ content.text = event.text;
176
+ }
177
+ break;
178
+ }
179
+ case 'response.reasoning_summary_part.added': {
180
+ const output = getOutput(snapshot, event.output_index);
181
+ if (output.type === 'reasoning') {
182
+ output.summary.push(structuredClone(event.part));
183
+ }
184
+ break;
185
+ }
186
+ case 'response.reasoning_summary_part.done': {
187
+ const output = getOutput(snapshot, event.output_index);
188
+ if (output.type === 'reasoning') {
189
+ getContent(output.summary, event.summary_index);
190
+ output.summary[event.summary_index] = structuredClone(event.part);
191
+ }
192
+ break;
193
+ }
194
+ case 'response.reasoning_summary_text.delta': {
195
+ const output = getOutput(snapshot, event.output_index);
196
+ if (output.type === 'reasoning') {
197
+ const part = getContent(output.summary, event.summary_index);
198
+ part.text += event.delta;
199
+ }
200
+ break;
201
+ }
202
+ case 'response.reasoning_summary_text.done': {
203
+ const output = getOutput(snapshot, event.output_index);
204
+ if (output.type === 'reasoning') {
205
+ const part = getContent(output.summary, event.summary_index);
206
+ part.text = event.text;
207
+ }
208
+ break;
209
+ }
210
+ case 'response.custom_tool_call_input.delta': {
211
+ const output = getOutput(snapshot, event.output_index);
212
+ if (output.type === 'custom_tool_call') {
213
+ output.input += event.delta;
214
+ }
215
+ break;
216
+ }
217
+ case 'response.custom_tool_call_input.done': {
218
+ const output = getOutput(snapshot, event.output_index);
219
+ if (output.type === 'custom_tool_call') {
220
+ output.input = event.input;
221
+ }
222
+ break;
223
+ }
224
+ case 'response.mcp_call_arguments.delta': {
225
+ const output = getOutput(snapshot, event.output_index);
226
+ if (output.type === 'mcp_call') {
227
+ output.arguments += event.delta;
228
+ }
229
+ break;
230
+ }
231
+ case 'response.mcp_call_arguments.done': {
232
+ const output = getOutput(snapshot, event.output_index);
233
+ if (output.type === 'mcp_call') {
234
+ output.arguments = event.arguments;
235
+ }
236
+ break;
237
+ }
238
+ case 'response.code_interpreter_call_code.delta': {
239
+ const output = getOutput(snapshot, event.output_index);
240
+ if (output.type === 'code_interpreter_call') {
241
+ output.code = (output.code ?? '') + event.delta;
242
+ }
243
+ break;
244
+ }
245
+ case 'response.code_interpreter_call_code.done': {
246
+ const output = getOutput(snapshot, event.output_index);
247
+ if (output.type === 'code_interpreter_call') {
248
+ output.code = event.code;
249
+ }
250
+ break;
251
+ }
252
+ case 'response.code_interpreter_call.in_progress': {
253
+ const output = getOutput(snapshot, event.output_index);
254
+ if (output.type === 'code_interpreter_call') {
255
+ output.status = 'in_progress';
256
+ }
257
+ break;
258
+ }
259
+ case 'response.code_interpreter_call.interpreting': {
260
+ const output = getOutput(snapshot, event.output_index);
261
+ if (output.type === 'code_interpreter_call') {
262
+ output.status = 'interpreting';
263
+ }
264
+ break;
265
+ }
266
+ case 'response.code_interpreter_call.completed': {
267
+ const output = getOutput(snapshot, event.output_index);
268
+ if (output.type === 'code_interpreter_call') {
269
+ output.status = 'completed';
270
+ }
271
+ break;
272
+ }
273
+ case 'response.file_search_call.in_progress': {
274
+ const output = getOutput(snapshot, event.output_index);
275
+ if (output.type === 'file_search_call') {
276
+ output.status = 'in_progress';
277
+ }
278
+ break;
279
+ }
280
+ case 'response.file_search_call.searching': {
281
+ const output = getOutput(snapshot, event.output_index);
282
+ if (output.type === 'file_search_call') {
283
+ output.status = 'searching';
284
+ }
285
+ break;
286
+ }
287
+ case 'response.file_search_call.completed': {
288
+ const output = getOutput(snapshot, event.output_index);
289
+ if (output.type === 'file_search_call') {
290
+ output.status = 'completed';
291
+ }
292
+ break;
293
+ }
294
+ case 'response.web_search_call.in_progress': {
295
+ const output = getOutput(snapshot, event.output_index);
296
+ if (output.type === 'web_search_call') {
297
+ output.status = 'in_progress';
298
+ }
299
+ break;
300
+ }
301
+ case 'response.web_search_call.searching': {
302
+ const output = getOutput(snapshot, event.output_index);
303
+ if (output.type === 'web_search_call') {
304
+ output.status = 'searching';
305
+ }
306
+ break;
307
+ }
308
+ case 'response.web_search_call.completed': {
309
+ const output = getOutput(snapshot, event.output_index);
310
+ if (output.type === 'web_search_call') {
311
+ output.status = 'completed';
312
+ }
313
+ break;
314
+ }
315
+ case 'response.image_generation_call.in_progress': {
316
+ const output = getOutput(snapshot, event.output_index);
317
+ if (output.type === 'image_generation_call') {
318
+ output.status = 'in_progress';
319
+ }
320
+ break;
321
+ }
322
+ case 'response.image_generation_call.generating': {
323
+ const output = getOutput(snapshot, event.output_index);
324
+ if (output.type === 'image_generation_call') {
325
+ output.status = 'generating';
326
+ }
327
+ break;
328
+ }
329
+ case 'response.image_generation_call.completed': {
330
+ const output = getOutput(snapshot, event.output_index);
331
+ if (output.type === 'image_generation_call') {
332
+ output.status = 'completed';
333
+ }
334
+ break;
335
+ }
336
+ case 'response.mcp_call.in_progress': {
337
+ const output = getOutput(snapshot, event.output_index);
338
+ if (output.type === 'mcp_call') {
339
+ output.status = 'in_progress';
340
+ }
341
+ break;
342
+ }
343
+ case 'response.mcp_call.completed': {
344
+ const output = getOutput(snapshot, event.output_index);
345
+ if (output.type === 'mcp_call') {
346
+ output.status = 'completed';
347
+ }
348
+ break;
349
+ }
350
+ case 'response.mcp_call.failed': {
351
+ const output = getOutput(snapshot, event.output_index);
352
+ if (output.type === 'mcp_call') {
353
+ output.status = 'failed';
354
+ }
355
+ break;
356
+ }
357
+ case 'response.created':
358
+ case 'response.queued':
359
+ case 'response.in_progress':
360
+ case 'response.completed':
361
+ case 'response.failed':
362
+ case 'response.incomplete': {
363
+ snapshot = cloneResponse(event.response);
364
+ break;
365
+ }
366
+ case 'response.audio.delta':
367
+ case 'response.audio.done':
368
+ case 'response.audio.transcript.delta':
369
+ case 'response.audio.transcript.done':
370
+ case 'response.image_generation_call.partial_image':
371
+ case 'response.mcp_list_tools.in_progress':
372
+ case 'response.mcp_list_tools.completed':
373
+ case 'response.mcp_list_tools.failed':
374
+ case 'error': {
375
+ // These events do not contain state represented by the Response object.
376
+ break;
377
+ }
378
+ default: {
379
+ assertNever(event);
380
+ }
381
+ }
382
+
383
+ return snapshot;
384
+ }
385
+
386
+ function cloneResponse(response: Response): Response {
387
+ const snapshot = structuredClone(response);
388
+ if (!Object.getOwnPropertyDescriptor(snapshot, 'output_text') || snapshot.output_text == null) {
389
+ addOutputText(snapshot);
390
+ }
391
+ return snapshot;
392
+ }
393
+
394
+ function getOutput(snapshot: Response, outputIndex: number): Response['output'][number] {
395
+ const output = snapshot.output[outputIndex];
396
+ if (!output) {
397
+ throw new OpenAIError(`missing output at index ${outputIndex}`);
398
+ }
399
+ return output;
400
+ }
401
+
402
+ function getContent<T>(content: Array<T>, contentIndex: number): T {
403
+ const part = content[contentIndex];
404
+ if (!part) {
405
+ throw new OpenAIError(`missing content at index ${contentIndex}`);
406
+ }
407
+ return part;
408
+ }
409
+
410
+ function assertNever(value: never): never {
411
+ throw new OpenAIError(`Unhandled response stream event: ${JSON.stringify(value)}`);
412
+ }
@@ -0,0 +1,127 @@
1
+ import type {
2
+ ResponseFunctionShellCallOutputContent,
3
+ ResponseInputItem,
4
+ ResponseOutputItem,
5
+ } from '../../resources/responses/responses';
6
+
7
+ export type ResponseInputItemLike = ResponseInputItem | ResponseOutputItem;
8
+
9
+ type ResponseShellCallOutputInputItem = Extract<ResponseInputItem, { type: 'shell_call_output' }>;
10
+ type ResponseComputerCallOutputInputItem = Extract<ResponseInputItem, { type: 'computer_call_output' }>;
11
+ type ResponseCustomToolCallOutputInputItem = Extract<ResponseInputItem, { type: 'custom_tool_call_output' }>;
12
+ type ResponseAdditionalToolsInputItem = Extract<ResponseInputItem, { type: 'additional_tools' }>;
13
+
14
+ /**
15
+ * Normalizes a mixed array of stored response history items into clean
16
+ * `ResponseInputItem`s that can be sent back to `responses.create()`. Known items
17
+ * that cannot be replayed without changing their meaning are omitted.
18
+ *
19
+ * @throws {TypeError} If an item type is not supported by the installed SDK.
20
+ */
21
+ export function toResponseInputItems(items: Iterable<ResponseInputItemLike>): ResponseInputItem[] {
22
+ const inputItems: ResponseInputItem[] = [];
23
+ for (const item of items) {
24
+ const inputItem = toResponseInputItem(item);
25
+ if (inputItem) {
26
+ inputItems.push(inputItem);
27
+ }
28
+ }
29
+ return inputItems;
30
+ }
31
+
32
+ /**
33
+ * Normalizes a stored response history item into a clean `ResponseInputItem`, or
34
+ * returns `null` when a known item cannot be replayed without changing its
35
+ * meaning.
36
+ *
37
+ * @throws {TypeError} If the item type is not supported by the installed SDK.
38
+ */
39
+ export function toResponseInputItem(item: ResponseInputItemLike): ResponseInputItem | null {
40
+ switch (item.type) {
41
+ case 'additional_tools': {
42
+ if (item.role !== 'developer') {
43
+ return null;
44
+ }
45
+ return stripCreatedBy(item) as ResponseAdditionalToolsInputItem;
46
+ }
47
+
48
+ case 'shell_call_output': {
49
+ const output: ResponseShellCallOutputInputItem['output'] = item.output.map(
50
+ (chunk) => stripCreatedBy(chunk) as ResponseFunctionShellCallOutputContent,
51
+ );
52
+ return {
53
+ ...(stripCreatedBy(item) as ResponseShellCallOutputInputItem),
54
+ output,
55
+ };
56
+ }
57
+
58
+ case 'computer_call_output': {
59
+ const { created_by: _createdBy, ...withoutCreatedBy } = item as typeof item & {
60
+ created_by?: string;
61
+ };
62
+ if (withoutCreatedBy.status === 'failed') {
63
+ return null;
64
+ }
65
+ return withoutCreatedBy as ResponseComputerCallOutputInputItem;
66
+ }
67
+
68
+ case 'custom_tool_call_output': {
69
+ if ('status' in item && item.status !== 'completed') {
70
+ return null;
71
+ }
72
+ const {
73
+ created_by: _createdBy,
74
+ status: _status,
75
+ ...inputItem
76
+ } = item as typeof item & { created_by?: string; status?: string };
77
+ return inputItem as ResponseCustomToolCallOutputInputItem;
78
+ }
79
+
80
+ case 'apply_patch_call':
81
+ case 'apply_patch_call_output':
82
+ case 'code_interpreter_call':
83
+ case 'compaction':
84
+ case 'compaction_trigger':
85
+ case 'computer_call':
86
+ case 'custom_tool_call':
87
+ case 'file_search_call':
88
+ case 'function_call':
89
+ case 'function_call_output':
90
+ case 'image_generation_call':
91
+ case 'item_reference':
92
+ case 'local_shell_call':
93
+ case 'local_shell_call_output':
94
+ case 'mcp_approval_request':
95
+ case 'mcp_approval_response':
96
+ case 'mcp_call':
97
+ case 'mcp_list_tools':
98
+ case 'message':
99
+ case 'reasoning':
100
+ case 'shell_call':
101
+ case 'tool_search_call':
102
+ case 'tool_search_output':
103
+ case 'web_search_call':
104
+ case null:
105
+ case undefined: {
106
+ return stripCreatedBy(item) as ResponseInputItem;
107
+ }
108
+
109
+ default: {
110
+ return assertNever(item);
111
+ }
112
+ }
113
+ }
114
+
115
+ function stripCreatedBy<T extends object>(item: T): T {
116
+ if (!('created_by' in item)) {
117
+ return item;
118
+ }
119
+
120
+ const { created_by: _createdBy, ...rest } = item as T & { created_by?: string };
121
+ return rest as T;
122
+ }
123
+
124
+ function assertNever(value: never): never {
125
+ const type = (value as { type?: unknown }).type;
126
+ throw new TypeError(`Unsupported response item type: ${String(type)}`);
127
+ }
@@ -11,6 +11,7 @@ import { APIUserAbortError, OpenAIError } from '../../error';
11
11
  import OpenAI from '../../index';
12
12
  import { type BaseEvents, EventStream } from '../EventStream';
13
13
  import { type ResponseFunctionCallArgumentsDeltaEvent, type ResponseTextDeltaEvent } from './EventTypes';
14
+ import { accumulateResponse } from './ResponseAccumulator';
14
15
  import { maybeParseResponse, ParseableToolsParams } from '../ResponsesParser';
15
16
  import { Stream } from '../../streaming';
16
17
 
@@ -103,7 +104,8 @@ export class ResponseStream<ParsedT = null>
103
104
  }
104
105
  };
105
106
 
106
- const response = this.#accumulateResponse(event);
107
+ const response = accumulateResponse(event, this.#currentResponseSnapshot);
108
+ this.#currentResponseSnapshot = response;
107
109
  maybeEmit('event', event);
108
110
 
109
111
  switch (event.type) {
@@ -167,11 +169,7 @@ export class ResponseStream<ParsedT = null>
167
169
  params: ResponseStreamParams,
168
170
  options?: RequestOptions,
169
171
  ): Promise<ParsedResponse<ParsedT>> {
170
- const signal = options?.signal;
171
- if (signal) {
172
- if (signal.aborted) this.controller.abort();
173
- signal.addEventListener('abort', () => this.controller.abort());
174
- }
172
+ this._listenForAbort(options?.signal);
175
173
  this.#beginRequest();
176
174
 
177
175
  let stream: Stream<ResponseStreamEvent> | undefined;
@@ -200,93 +198,6 @@ export class ResponseStream<ParsedT = null>
200
198
  return this.#endRequest();
201
199
  }
202
200
 
203
- #accumulateResponse(event: ResponseStreamEvent): Response {
204
- let snapshot = this.#currentResponseSnapshot;
205
- if (!snapshot) {
206
- if (event.type !== 'response.created') {
207
- throw new OpenAIError(
208
- `When snapshot hasn't been set yet, expected 'response.created' event, got ${event.type}`,
209
- );
210
- }
211
- snapshot = this.#currentResponseSnapshot = event.response;
212
- return snapshot;
213
- }
214
-
215
- switch (event.type) {
216
- case 'response.output_item.added': {
217
- snapshot.output.push(event.item);
218
- break;
219
- }
220
- case 'response.content_part.added': {
221
- const output = snapshot.output[event.output_index];
222
- if (!output) {
223
- throw new OpenAIError(`missing output at index ${event.output_index}`);
224
- }
225
- const type = output.type;
226
- const part = event.part;
227
- if (type === 'message' && part.type !== 'reasoning_text') {
228
- output.content.push(part);
229
- } else if (type === 'reasoning' && part.type === 'reasoning_text') {
230
- if (!output.content) {
231
- output.content = [];
232
- }
233
- output.content.push(part);
234
- }
235
- break;
236
- }
237
- case 'response.output_text.delta': {
238
- const output = snapshot.output[event.output_index];
239
- if (!output) {
240
- throw new OpenAIError(`missing output at index ${event.output_index}`);
241
- }
242
- if (output.type === 'message') {
243
- const content = output.content[event.content_index];
244
- if (!content) {
245
- throw new OpenAIError(`missing content at index ${event.content_index}`);
246
- }
247
- if (content.type !== 'output_text') {
248
- throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
249
- }
250
- content.text += event.delta;
251
- }
252
- break;
253
- }
254
- case 'response.function_call_arguments.delta': {
255
- const output = snapshot.output[event.output_index];
256
- if (!output) {
257
- throw new OpenAIError(`missing output at index ${event.output_index}`);
258
- }
259
- if (output.type === 'function_call') {
260
- output.arguments += event.delta;
261
- }
262
- break;
263
- }
264
- case 'response.reasoning_text.delta': {
265
- const output = snapshot.output[event.output_index];
266
- if (!output) {
267
- throw new OpenAIError(`missing output at index ${event.output_index}`);
268
- }
269
- if (output.type === 'reasoning') {
270
- const content = output.content?.[event.content_index];
271
- if (!content) {
272
- throw new OpenAIError(`missing content at index ${event.content_index}`);
273
- }
274
- if (content.type !== 'reasoning_text') {
275
- throw new OpenAIError(`expected content to be 'reasoning_text', got ${content.type}`);
276
- }
277
- content.text += event.delta;
278
- }
279
- break;
280
- }
281
- case 'response.completed': {
282
- this.#currentResponseSnapshot = event.response;
283
- break;
284
- }
285
- }
286
-
287
- return snapshot;
288
- }
289
-
290
201
  [Symbol.asyncIterator](this: ResponseStream<ParsedT>): AsyncIterator<ResponseStreamEvent> {
291
202
  const pushQueue: ResponseStreamEvent[] = [];
292
203
  const readQueue: {