@anthropic-ai/claude-code 0.2.9

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 (424) hide show
  1. package/LICENSE.md +3 -0
  2. package/README.md +55 -0
  3. package/cli.mjs +1398 -0
  4. package/package.json +31 -0
  5. package/vendor/ripgrep/COPYING +3 -0
  6. package/vendor/ripgrep/arm64-darwin/rg +0 -0
  7. package/vendor/ripgrep/arm64-linux/rg +0 -0
  8. package/vendor/ripgrep/x64-darwin/rg +0 -0
  9. package/vendor/ripgrep/x64-linux/rg +0 -0
  10. package/vendor/ripgrep/x64-win32/rg.exe +0 -0
  11. package/vendor/sdk/CHANGELOG.md +1421 -0
  12. package/vendor/sdk/LICENSE +8 -0
  13. package/vendor/sdk/README.md +536 -0
  14. package/vendor/sdk/_shims/MultipartBody.d.ts +9 -0
  15. package/vendor/sdk/_shims/MultipartBody.d.ts.map +1 -0
  16. package/vendor/sdk/_shims/MultipartBody.js +16 -0
  17. package/vendor/sdk/_shims/MultipartBody.js.map +1 -0
  18. package/vendor/sdk/_shims/MultipartBody.mjs +12 -0
  19. package/vendor/sdk/_shims/MultipartBody.mjs.map +1 -0
  20. package/vendor/sdk/_shims/README.md +46 -0
  21. package/vendor/sdk/_shims/auto/runtime-bun.d.ts +5 -0
  22. package/vendor/sdk/_shims/auto/runtime-bun.d.ts.map +1 -0
  23. package/vendor/sdk/_shims/auto/runtime-bun.js +21 -0
  24. package/vendor/sdk/_shims/auto/runtime-bun.js.map +1 -0
  25. package/vendor/sdk/_shims/auto/runtime-bun.mjs +2 -0
  26. package/vendor/sdk/_shims/auto/runtime-bun.mjs.map +1 -0
  27. package/vendor/sdk/_shims/auto/runtime-node.d.ts +5 -0
  28. package/vendor/sdk/_shims/auto/runtime-node.d.ts.map +1 -0
  29. package/vendor/sdk/_shims/auto/runtime-node.js +21 -0
  30. package/vendor/sdk/_shims/auto/runtime-node.js.map +1 -0
  31. package/vendor/sdk/_shims/auto/runtime-node.mjs +2 -0
  32. package/vendor/sdk/_shims/auto/runtime-node.mjs.map +1 -0
  33. package/vendor/sdk/_shims/auto/runtime.d.ts +5 -0
  34. package/vendor/sdk/_shims/auto/runtime.d.ts.map +1 -0
  35. package/vendor/sdk/_shims/auto/runtime.js +21 -0
  36. package/vendor/sdk/_shims/auto/runtime.js.map +1 -0
  37. package/vendor/sdk/_shims/auto/runtime.mjs +2 -0
  38. package/vendor/sdk/_shims/auto/runtime.mjs.map +1 -0
  39. package/vendor/sdk/_shims/auto/types-node.d.ts +5 -0
  40. package/vendor/sdk/_shims/auto/types-node.d.ts.map +1 -0
  41. package/vendor/sdk/_shims/auto/types-node.js +21 -0
  42. package/vendor/sdk/_shims/auto/types-node.js.map +1 -0
  43. package/vendor/sdk/_shims/auto/types-node.mjs +2 -0
  44. package/vendor/sdk/_shims/auto/types-node.mjs.map +1 -0
  45. package/vendor/sdk/_shims/auto/types.d.ts +101 -0
  46. package/vendor/sdk/_shims/auto/types.js +3 -0
  47. package/vendor/sdk/_shims/auto/types.mjs +3 -0
  48. package/vendor/sdk/_shims/bun-runtime.d.ts +6 -0
  49. package/vendor/sdk/_shims/bun-runtime.d.ts.map +1 -0
  50. package/vendor/sdk/_shims/bun-runtime.js +14 -0
  51. package/vendor/sdk/_shims/bun-runtime.js.map +1 -0
  52. package/vendor/sdk/_shims/bun-runtime.mjs +10 -0
  53. package/vendor/sdk/_shims/bun-runtime.mjs.map +1 -0
  54. package/vendor/sdk/_shims/index.d.ts +81 -0
  55. package/vendor/sdk/_shims/index.js +13 -0
  56. package/vendor/sdk/_shims/index.mjs +7 -0
  57. package/vendor/sdk/_shims/manual-types.d.ts +12 -0
  58. package/vendor/sdk/_shims/manual-types.js +3 -0
  59. package/vendor/sdk/_shims/manual-types.mjs +3 -0
  60. package/vendor/sdk/_shims/node-runtime.d.ts +3 -0
  61. package/vendor/sdk/_shims/node-runtime.d.ts.map +1 -0
  62. package/vendor/sdk/_shims/node-runtime.js +89 -0
  63. package/vendor/sdk/_shims/node-runtime.js.map +1 -0
  64. package/vendor/sdk/_shims/node-runtime.mjs +56 -0
  65. package/vendor/sdk/_shims/node-runtime.mjs.map +1 -0
  66. package/vendor/sdk/_shims/node-types.d.ts +42 -0
  67. package/vendor/sdk/_shims/node-types.js +3 -0
  68. package/vendor/sdk/_shims/node-types.mjs +3 -0
  69. package/vendor/sdk/_shims/registry.d.ts +37 -0
  70. package/vendor/sdk/_shims/registry.d.ts.map +1 -0
  71. package/vendor/sdk/_shims/registry.js +41 -0
  72. package/vendor/sdk/_shims/registry.js.map +1 -0
  73. package/vendor/sdk/_shims/registry.mjs +37 -0
  74. package/vendor/sdk/_shims/registry.mjs.map +1 -0
  75. package/vendor/sdk/_shims/web-runtime.d.ts +5 -0
  76. package/vendor/sdk/_shims/web-runtime.d.ts.map +1 -0
  77. package/vendor/sdk/_shims/web-runtime.js +78 -0
  78. package/vendor/sdk/_shims/web-runtime.js.map +1 -0
  79. package/vendor/sdk/_shims/web-runtime.mjs +71 -0
  80. package/vendor/sdk/_shims/web-runtime.mjs.map +1 -0
  81. package/vendor/sdk/_shims/web-types.d.ts +83 -0
  82. package/vendor/sdk/_shims/web-types.js +3 -0
  83. package/vendor/sdk/_shims/web-types.mjs +3 -0
  84. package/vendor/sdk/_vendor/partial-json-parser/parser.d.ts +3 -0
  85. package/vendor/sdk/_vendor/partial-json-parser/parser.d.ts.map +1 -0
  86. package/vendor/sdk/_vendor/partial-json-parser/parser.js +226 -0
  87. package/vendor/sdk/_vendor/partial-json-parser/parser.js.map +1 -0
  88. package/vendor/sdk/_vendor/partial-json-parser/parser.mjs +223 -0
  89. package/vendor/sdk/_vendor/partial-json-parser/parser.mjs.map +1 -0
  90. package/vendor/sdk/core.d.ts +248 -0
  91. package/vendor/sdk/core.d.ts.map +1 -0
  92. package/vendor/sdk/core.js +935 -0
  93. package/vendor/sdk/core.js.map +1 -0
  94. package/vendor/sdk/core.mjs +903 -0
  95. package/vendor/sdk/core.mjs.map +1 -0
  96. package/vendor/sdk/error.d.ts +48 -0
  97. package/vendor/sdk/error.d.ts.map +1 -0
  98. package/vendor/sdk/error.js +114 -0
  99. package/vendor/sdk/error.js.map +1 -0
  100. package/vendor/sdk/error.mjs +98 -0
  101. package/vendor/sdk/error.mjs.map +1 -0
  102. package/vendor/sdk/index.d.mts +152 -0
  103. package/vendor/sdk/index.d.ts +152 -0
  104. package/vendor/sdk/index.d.ts.map +1 -0
  105. package/vendor/sdk/index.js +179 -0
  106. package/vendor/sdk/index.js.map +1 -0
  107. package/vendor/sdk/index.mjs +136 -0
  108. package/vendor/sdk/index.mjs.map +1 -0
  109. package/vendor/sdk/internal/decoders/jsonl.d.ts +12 -0
  110. package/vendor/sdk/internal/decoders/jsonl.d.ts.map +1 -0
  111. package/vendor/sdk/internal/decoders/jsonl.js +35 -0
  112. package/vendor/sdk/internal/decoders/jsonl.js.map +1 -0
  113. package/vendor/sdk/internal/decoders/jsonl.mjs +31 -0
  114. package/vendor/sdk/internal/decoders/jsonl.mjs.map +1 -0
  115. package/vendor/sdk/internal/decoders/line.d.ts +20 -0
  116. package/vendor/sdk/internal/decoders/line.d.ts.map +1 -0
  117. package/vendor/sdk/internal/decoders/line.js +123 -0
  118. package/vendor/sdk/internal/decoders/line.js.map +1 -0
  119. package/vendor/sdk/internal/decoders/line.mjs +119 -0
  120. package/vendor/sdk/internal/decoders/line.mjs.map +1 -0
  121. package/vendor/sdk/internal/stream-utils.d.ts +8 -0
  122. package/vendor/sdk/internal/stream-utils.d.ts.map +1 -0
  123. package/vendor/sdk/internal/stream-utils.js +39 -0
  124. package/vendor/sdk/internal/stream-utils.js.map +1 -0
  125. package/vendor/sdk/internal/stream-utils.mjs +35 -0
  126. package/vendor/sdk/internal/stream-utils.mjs.map +1 -0
  127. package/vendor/sdk/lib/BetaMessageStream.d.ts +114 -0
  128. package/vendor/sdk/lib/BetaMessageStream.d.ts.map +1 -0
  129. package/vendor/sdk/lib/BetaMessageStream.js +547 -0
  130. package/vendor/sdk/lib/BetaMessageStream.js.map +1 -0
  131. package/vendor/sdk/lib/BetaMessageStream.mjs +543 -0
  132. package/vendor/sdk/lib/BetaMessageStream.mjs.map +1 -0
  133. package/vendor/sdk/lib/MessageStream.d.ts +114 -0
  134. package/vendor/sdk/lib/MessageStream.d.ts.map +1 -0
  135. package/vendor/sdk/lib/MessageStream.js +547 -0
  136. package/vendor/sdk/lib/MessageStream.js.map +1 -0
  137. package/vendor/sdk/lib/MessageStream.mjs +543 -0
  138. package/vendor/sdk/lib/MessageStream.mjs.map +1 -0
  139. package/vendor/sdk/node_modules/@types/node/LICENSE +21 -0
  140. package/vendor/sdk/node_modules/@types/node/README.md +15 -0
  141. package/vendor/sdk/node_modules/@types/node/assert/strict.d.ts +8 -0
  142. package/vendor/sdk/node_modules/@types/node/assert.d.ts +985 -0
  143. package/vendor/sdk/node_modules/@types/node/async_hooks.d.ts +522 -0
  144. package/vendor/sdk/node_modules/@types/node/buffer.buffer.d.ts +385 -0
  145. package/vendor/sdk/node_modules/@types/node/buffer.d.ts +1903 -0
  146. package/vendor/sdk/node_modules/@types/node/child_process.d.ts +1549 -0
  147. package/vendor/sdk/node_modules/@types/node/cluster.d.ts +578 -0
  148. package/vendor/sdk/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
  149. package/vendor/sdk/node_modules/@types/node/compatibility/index.d.ts +9 -0
  150. package/vendor/sdk/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  151. package/vendor/sdk/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
  152. package/vendor/sdk/node_modules/@types/node/console.d.ts +452 -0
  153. package/vendor/sdk/node_modules/@types/node/constants.d.ts +19 -0
  154. package/vendor/sdk/node_modules/@types/node/crypto.d.ts +4453 -0
  155. package/vendor/sdk/node_modules/@types/node/dgram.d.ts +596 -0
  156. package/vendor/sdk/node_modules/@types/node/diagnostics_channel.d.ts +546 -0
  157. package/vendor/sdk/node_modules/@types/node/dns/promises.d.ts +475 -0
  158. package/vendor/sdk/node_modules/@types/node/dns.d.ts +853 -0
  159. package/vendor/sdk/node_modules/@types/node/dom-events.d.ts +124 -0
  160. package/vendor/sdk/node_modules/@types/node/domain.d.ts +170 -0
  161. package/vendor/sdk/node_modules/@types/node/events.d.ts +819 -0
  162. package/vendor/sdk/node_modules/@types/node/fs/promises.d.ts +1205 -0
  163. package/vendor/sdk/node_modules/@types/node/fs.d.ts +4237 -0
  164. package/vendor/sdk/node_modules/@types/node/globals.d.ts +442 -0
  165. package/vendor/sdk/node_modules/@types/node/globals.typedarray.d.ts +21 -0
  166. package/vendor/sdk/node_modules/@types/node/http.d.ts +1839 -0
  167. package/vendor/sdk/node_modules/@types/node/http2.d.ts +2517 -0
  168. package/vendor/sdk/node_modules/@types/node/https.d.ts +544 -0
  169. package/vendor/sdk/node_modules/@types/node/index.d.ts +90 -0
  170. package/vendor/sdk/node_modules/@types/node/inspector.d.ts +2775 -0
  171. package/vendor/sdk/node_modules/@types/node/module.d.ts +291 -0
  172. package/vendor/sdk/node_modules/@types/node/net.d.ts +924 -0
  173. package/vendor/sdk/node_modules/@types/node/os.d.ts +473 -0
  174. package/vendor/sdk/node_modules/@types/node/package.json +225 -0
  175. package/vendor/sdk/node_modules/@types/node/path.d.ts +191 -0
  176. package/vendor/sdk/node_modules/@types/node/perf_hooks.d.ts +753 -0
  177. package/vendor/sdk/node_modules/@types/node/process.d.ts +1553 -0
  178. package/vendor/sdk/node_modules/@types/node/punycode.d.ts +117 -0
  179. package/vendor/sdk/node_modules/@types/node/querystring.d.ts +141 -0
  180. package/vendor/sdk/node_modules/@types/node/readline/promises.d.ts +154 -0
  181. package/vendor/sdk/node_modules/@types/node/readline.d.ts +715 -0
  182. package/vendor/sdk/node_modules/@types/node/repl.d.ts +430 -0
  183. package/vendor/sdk/node_modules/@types/node/stream/consumers.d.ts +12 -0
  184. package/vendor/sdk/node_modules/@types/node/stream/promises.d.ts +90 -0
  185. package/vendor/sdk/node_modules/@types/node/stream/web.d.ts +523 -0
  186. package/vendor/sdk/node_modules/@types/node/stream.d.ts +1731 -0
  187. package/vendor/sdk/node_modules/@types/node/string_decoder.d.ts +67 -0
  188. package/vendor/sdk/node_modules/@types/node/test.d.ts +1245 -0
  189. package/vendor/sdk/node_modules/@types/node/timers/promises.d.ts +93 -0
  190. package/vendor/sdk/node_modules/@types/node/timers.d.ts +126 -0
  191. package/vendor/sdk/node_modules/@types/node/tls.d.ts +1203 -0
  192. package/vendor/sdk/node_modules/@types/node/trace_events.d.ts +171 -0
  193. package/vendor/sdk/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
  194. package/vendor/sdk/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
  195. package/vendor/sdk/node_modules/@types/node/ts5.6/index.d.ts +90 -0
  196. package/vendor/sdk/node_modules/@types/node/tty.d.ts +206 -0
  197. package/vendor/sdk/node_modules/@types/node/url.d.ts +957 -0
  198. package/vendor/sdk/node_modules/@types/node/util.d.ts +2083 -0
  199. package/vendor/sdk/node_modules/@types/node/v8.d.ts +753 -0
  200. package/vendor/sdk/node_modules/@types/node/vm.d.ts +666 -0
  201. package/vendor/sdk/node_modules/@types/node/wasi.d.ts +160 -0
  202. package/vendor/sdk/node_modules/@types/node/worker_threads.d.ts +695 -0
  203. package/vendor/sdk/node_modules/@types/node/zlib.d.ts +517 -0
  204. package/vendor/sdk/node_modules/undici-types/README.md +6 -0
  205. package/vendor/sdk/node_modules/undici-types/agent.d.ts +31 -0
  206. package/vendor/sdk/node_modules/undici-types/api.d.ts +43 -0
  207. package/vendor/sdk/node_modules/undici-types/balanced-pool.d.ts +18 -0
  208. package/vendor/sdk/node_modules/undici-types/cache.d.ts +36 -0
  209. package/vendor/sdk/node_modules/undici-types/client.d.ts +97 -0
  210. package/vendor/sdk/node_modules/undici-types/connector.d.ts +34 -0
  211. package/vendor/sdk/node_modules/undici-types/content-type.d.ts +21 -0
  212. package/vendor/sdk/node_modules/undici-types/cookies.d.ts +28 -0
  213. package/vendor/sdk/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
  214. package/vendor/sdk/node_modules/undici-types/dispatcher.d.ts +241 -0
  215. package/vendor/sdk/node_modules/undici-types/errors.d.ts +128 -0
  216. package/vendor/sdk/node_modules/undici-types/fetch.d.ts +209 -0
  217. package/vendor/sdk/node_modules/undici-types/file.d.ts +39 -0
  218. package/vendor/sdk/node_modules/undici-types/filereader.d.ts +54 -0
  219. package/vendor/sdk/node_modules/undici-types/formdata.d.ts +108 -0
  220. package/vendor/sdk/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  221. package/vendor/sdk/node_modules/undici-types/global-origin.d.ts +7 -0
  222. package/vendor/sdk/node_modules/undici-types/handlers.d.ts +9 -0
  223. package/vendor/sdk/node_modules/undici-types/header.d.ts +4 -0
  224. package/vendor/sdk/node_modules/undici-types/index.d.ts +63 -0
  225. package/vendor/sdk/node_modules/undici-types/interceptors.d.ts +5 -0
  226. package/vendor/sdk/node_modules/undici-types/mock-agent.d.ts +50 -0
  227. package/vendor/sdk/node_modules/undici-types/mock-client.d.ts +25 -0
  228. package/vendor/sdk/node_modules/undici-types/mock-errors.d.ts +12 -0
  229. package/vendor/sdk/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  230. package/vendor/sdk/node_modules/undici-types/mock-pool.d.ts +25 -0
  231. package/vendor/sdk/node_modules/undici-types/package.json +55 -0
  232. package/vendor/sdk/node_modules/undici-types/patch.d.ts +71 -0
  233. package/vendor/sdk/node_modules/undici-types/pool-stats.d.ts +19 -0
  234. package/vendor/sdk/node_modules/undici-types/pool.d.ts +28 -0
  235. package/vendor/sdk/node_modules/undici-types/proxy-agent.d.ts +30 -0
  236. package/vendor/sdk/node_modules/undici-types/readable.d.ts +61 -0
  237. package/vendor/sdk/node_modules/undici-types/webidl.d.ts +220 -0
  238. package/vendor/sdk/node_modules/undici-types/websocket.d.ts +131 -0
  239. package/vendor/sdk/package.json +124 -0
  240. package/vendor/sdk/pagination.d.ts +27 -0
  241. package/vendor/sdk/pagination.d.ts.map +1 -0
  242. package/vendor/sdk/pagination.js +60 -0
  243. package/vendor/sdk/pagination.js.map +1 -0
  244. package/vendor/sdk/pagination.mjs +56 -0
  245. package/vendor/sdk/pagination.mjs.map +1 -0
  246. package/vendor/sdk/resource.d.ts +6 -0
  247. package/vendor/sdk/resource.d.ts.map +1 -0
  248. package/vendor/sdk/resource.js +11 -0
  249. package/vendor/sdk/resource.js.map +1 -0
  250. package/vendor/sdk/resource.mjs +7 -0
  251. package/vendor/sdk/resource.mjs.map +1 -0
  252. package/vendor/sdk/resources/beta/beta.d.ts +57 -0
  253. package/vendor/sdk/resources/beta/beta.d.ts.map +1 -0
  254. package/vendor/sdk/resources/beta/beta.js +44 -0
  255. package/vendor/sdk/resources/beta/beta.js.map +1 -0
  256. package/vendor/sdk/resources/beta/beta.mjs +17 -0
  257. package/vendor/sdk/resources/beta/beta.mjs.map +1 -0
  258. package/vendor/sdk/resources/beta/index.d.ts +4 -0
  259. package/vendor/sdk/resources/beta/index.d.ts.map +1 -0
  260. package/vendor/sdk/resources/beta/index.js +12 -0
  261. package/vendor/sdk/resources/beta/index.js.map +1 -0
  262. package/vendor/sdk/resources/beta/index.mjs +5 -0
  263. package/vendor/sdk/resources/beta/index.mjs.map +1 -0
  264. package/vendor/sdk/resources/beta/messages/batches.d.ts +289 -0
  265. package/vendor/sdk/resources/beta/messages/batches.d.ts.map +1 -0
  266. package/vendor/sdk/resources/beta/messages/batches.js +112 -0
  267. package/vendor/sdk/resources/beta/messages/batches.js.map +1 -0
  268. package/vendor/sdk/resources/beta/messages/batches.mjs +107 -0
  269. package/vendor/sdk/resources/beta/messages/batches.mjs.map +1 -0
  270. package/vendor/sdk/resources/beta/messages/index.d.ts +3 -0
  271. package/vendor/sdk/resources/beta/messages/index.d.ts.map +1 -0
  272. package/vendor/sdk/resources/beta/messages/index.js +10 -0
  273. package/vendor/sdk/resources/beta/messages/index.js.map +1 -0
  274. package/vendor/sdk/resources/beta/messages/index.mjs +4 -0
  275. package/vendor/sdk/resources/beta/messages/index.mjs.map +1 -0
  276. package/vendor/sdk/resources/beta/messages/messages.d.ts +1038 -0
  277. package/vendor/sdk/resources/beta/messages/messages.d.ts.map +1 -0
  278. package/vendor/sdk/resources/beta/messages/messages.js +93 -0
  279. package/vendor/sdk/resources/beta/messages/messages.js.map +1 -0
  280. package/vendor/sdk/resources/beta/messages/messages.mjs +66 -0
  281. package/vendor/sdk/resources/beta/messages/messages.mjs.map +1 -0
  282. package/vendor/sdk/resources/beta/models.d.ts +49 -0
  283. package/vendor/sdk/resources/beta/models.d.ts.map +1 -0
  284. package/vendor/sdk/resources/beta/models.js +30 -0
  285. package/vendor/sdk/resources/beta/models.js.map +1 -0
  286. package/vendor/sdk/resources/beta/models.mjs +25 -0
  287. package/vendor/sdk/resources/beta/models.mjs.map +1 -0
  288. package/vendor/sdk/resources/completions.d.ts +166 -0
  289. package/vendor/sdk/resources/completions.d.ts.map +1 -0
  290. package/vendor/sdk/resources/completions.js +17 -0
  291. package/vendor/sdk/resources/completions.js.map +1 -0
  292. package/vendor/sdk/resources/completions.mjs +13 -0
  293. package/vendor/sdk/resources/completions.mjs.map +1 -0
  294. package/vendor/sdk/resources/index.d.ts +6 -0
  295. package/vendor/sdk/resources/index.d.ts.map +1 -0
  296. package/vendor/sdk/resources/index.js +29 -0
  297. package/vendor/sdk/resources/index.js.map +1 -0
  298. package/vendor/sdk/resources/index.mjs +7 -0
  299. package/vendor/sdk/resources/index.mjs.map +1 -0
  300. package/vendor/sdk/resources/messages/batches.d.ts +253 -0
  301. package/vendor/sdk/resources/messages/batches.d.ts.map +1 -0
  302. package/vendor/sdk/resources/messages/batches.js +102 -0
  303. package/vendor/sdk/resources/messages/batches.js.map +1 -0
  304. package/vendor/sdk/resources/messages/batches.mjs +97 -0
  305. package/vendor/sdk/resources/messages/batches.mjs.map +1 -0
  306. package/vendor/sdk/resources/messages/index.d.ts +3 -0
  307. package/vendor/sdk/resources/messages/index.d.ts.map +1 -0
  308. package/vendor/sdk/resources/messages/index.js +10 -0
  309. package/vendor/sdk/resources/messages/index.js.map +1 -0
  310. package/vendor/sdk/resources/messages/index.mjs +4 -0
  311. package/vendor/sdk/resources/messages/index.mjs.map +1 -0
  312. package/vendor/sdk/resources/messages/messages.d.ts +1028 -0
  313. package/vendor/sdk/resources/messages/messages.d.ts.map +1 -0
  314. package/vendor/sdk/resources/messages/messages.js +82 -0
  315. package/vendor/sdk/resources/messages/messages.js.map +1 -0
  316. package/vendor/sdk/resources/messages/messages.mjs +54 -0
  317. package/vendor/sdk/resources/messages/messages.mjs.map +1 -0
  318. package/vendor/sdk/resources/models.d.ts +49 -0
  319. package/vendor/sdk/resources/models.d.ts.map +1 -0
  320. package/vendor/sdk/resources/models.js +30 -0
  321. package/vendor/sdk/resources/models.js.map +1 -0
  322. package/vendor/sdk/resources/models.mjs +25 -0
  323. package/vendor/sdk/resources/models.mjs.map +1 -0
  324. package/vendor/sdk/resources/shared.d.ts +42 -0
  325. package/vendor/sdk/resources/shared.d.ts.map +1 -0
  326. package/vendor/sdk/resources/shared.js +4 -0
  327. package/vendor/sdk/resources/shared.js.map +1 -0
  328. package/vendor/sdk/resources/shared.mjs +3 -0
  329. package/vendor/sdk/resources/shared.mjs.map +1 -0
  330. package/vendor/sdk/resources/top-level.d.ts +2 -0
  331. package/vendor/sdk/resources/top-level.d.ts.map +1 -0
  332. package/vendor/sdk/resources/top-level.js +4 -0
  333. package/vendor/sdk/resources/top-level.js.map +1 -0
  334. package/vendor/sdk/resources/top-level.mjs +3 -0
  335. package/vendor/sdk/resources/top-level.mjs.map +1 -0
  336. package/vendor/sdk/shims/node.d.ts +30 -0
  337. package/vendor/sdk/shims/node.d.ts.map +1 -0
  338. package/vendor/sdk/shims/node.js +31 -0
  339. package/vendor/sdk/shims/node.js.map +1 -0
  340. package/vendor/sdk/shims/node.mjs +5 -0
  341. package/vendor/sdk/shims/node.mjs.map +1 -0
  342. package/vendor/sdk/shims/web.d.ts +26 -0
  343. package/vendor/sdk/shims/web.d.ts.map +1 -0
  344. package/vendor/sdk/shims/web.js +31 -0
  345. package/vendor/sdk/shims/web.js.map +1 -0
  346. package/vendor/sdk/shims/web.mjs +5 -0
  347. package/vendor/sdk/shims/web.mjs.map +1 -0
  348. package/vendor/sdk/src/_shims/MultipartBody.ts +9 -0
  349. package/vendor/sdk/src/_shims/README.md +46 -0
  350. package/vendor/sdk/src/_shims/auto/runtime-bun.ts +4 -0
  351. package/vendor/sdk/src/_shims/auto/runtime-node.ts +4 -0
  352. package/vendor/sdk/src/_shims/auto/runtime.ts +4 -0
  353. package/vendor/sdk/src/_shims/auto/types-node.ts +4 -0
  354. package/vendor/sdk/src/_shims/auto/types.d.ts +101 -0
  355. package/vendor/sdk/src/_shims/auto/types.js +3 -0
  356. package/vendor/sdk/src/_shims/auto/types.mjs +3 -0
  357. package/vendor/sdk/src/_shims/bun-runtime.ts +14 -0
  358. package/vendor/sdk/src/_shims/index.d.ts +81 -0
  359. package/vendor/sdk/src/_shims/index.js +13 -0
  360. package/vendor/sdk/src/_shims/index.mjs +7 -0
  361. package/vendor/sdk/src/_shims/manual-types.d.ts +12 -0
  362. package/vendor/sdk/src/_shims/manual-types.js +3 -0
  363. package/vendor/sdk/src/_shims/manual-types.mjs +3 -0
  364. package/vendor/sdk/src/_shims/node-runtime.ts +81 -0
  365. package/vendor/sdk/src/_shims/node-types.d.ts +42 -0
  366. package/vendor/sdk/src/_shims/node-types.js +3 -0
  367. package/vendor/sdk/src/_shims/node-types.mjs +3 -0
  368. package/vendor/sdk/src/_shims/registry.ts +67 -0
  369. package/vendor/sdk/src/_shims/web-runtime.ts +103 -0
  370. package/vendor/sdk/src/_shims/web-types.d.ts +83 -0
  371. package/vendor/sdk/src/_shims/web-types.js +3 -0
  372. package/vendor/sdk/src/_shims/web-types.mjs +3 -0
  373. package/vendor/sdk/src/_vendor/partial-json-parser/README.md +3 -0
  374. package/vendor/sdk/src/_vendor/partial-json-parser/parser.ts +264 -0
  375. package/vendor/sdk/src/core.ts +1250 -0
  376. package/vendor/sdk/src/error.ts +133 -0
  377. package/vendor/sdk/src/index.ts +465 -0
  378. package/vendor/sdk/src/internal/decoders/jsonl.ts +41 -0
  379. package/vendor/sdk/src/internal/decoders/line.ts +145 -0
  380. package/vendor/sdk/src/internal/stream-utils.ts +32 -0
  381. package/vendor/sdk/src/lib/.keep +4 -0
  382. package/vendor/sdk/src/lib/BetaMessageStream.ts +661 -0
  383. package/vendor/sdk/src/lib/MessageStream.ts +662 -0
  384. package/vendor/sdk/src/pagination.ts +92 -0
  385. package/vendor/sdk/src/resource.ts +11 -0
  386. package/vendor/sdk/src/resources/beta/beta.ts +249 -0
  387. package/vendor/sdk/src/resources/beta/index.ts +83 -0
  388. package/vendor/sdk/src/resources/beta/messages/batches.ts +486 -0
  389. package/vendor/sdk/src/resources/beta/messages/index.ts +87 -0
  390. package/vendor/sdk/src/resources/beta/messages/messages.ts +1444 -0
  391. package/vendor/sdk/src/resources/beta/models.ts +78 -0
  392. package/vendor/sdk/src/resources/completions.ts +210 -0
  393. package/vendor/sdk/src/resources/index.ts +95 -0
  394. package/vendor/sdk/src/resources/messages/batches.ts +352 -0
  395. package/vendor/sdk/src/resources/messages/index.ts +85 -0
  396. package/vendor/sdk/src/resources/messages/messages.ts +1412 -0
  397. package/vendor/sdk/src/resources/models.ts +75 -0
  398. package/vendor/sdk/src/resources/shared.ts +72 -0
  399. package/vendor/sdk/src/resources/top-level.ts +3 -0
  400. package/vendor/sdk/src/shims/node.ts +50 -0
  401. package/vendor/sdk/src/shims/web.ts +50 -0
  402. package/vendor/sdk/src/streaming.ts +372 -0
  403. package/vendor/sdk/src/tsconfig.json +11 -0
  404. package/vendor/sdk/src/uploads.ts +255 -0
  405. package/vendor/sdk/src/version.ts +1 -0
  406. package/vendor/sdk/streaming.d.ts +36 -0
  407. package/vendor/sdk/streaming.d.ts.map +1 -0
  408. package/vendor/sdk/streaming.js +316 -0
  409. package/vendor/sdk/streaming.js.map +1 -0
  410. package/vendor/sdk/streaming.mjs +310 -0
  411. package/vendor/sdk/streaming.mjs.map +1 -0
  412. package/vendor/sdk/uploads.d.ts +75 -0
  413. package/vendor/sdk/uploads.d.ts.map +1 -0
  414. package/vendor/sdk/uploads.js +171 -0
  415. package/vendor/sdk/uploads.js.map +1 -0
  416. package/vendor/sdk/uploads.mjs +158 -0
  417. package/vendor/sdk/uploads.mjs.map +1 -0
  418. package/vendor/sdk/version.d.ts +2 -0
  419. package/vendor/sdk/version.d.ts.map +1 -0
  420. package/vendor/sdk/version.js +5 -0
  421. package/vendor/sdk/version.js.map +1 -0
  422. package/vendor/sdk/version.mjs +2 -0
  423. package/vendor/sdk/version.mjs.map +1 -0
  424. package/yoga.wasm +0 -0
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _LineDecoder_carriageReturnIndex;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.LineDecoder = void 0;
16
+ const error_1 = require("../../error.js");
17
+ /**
18
+ * A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
19
+ * reading lines from text.
20
+ *
21
+ * https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
22
+ */
23
+ class LineDecoder {
24
+ constructor() {
25
+ _LineDecoder_carriageReturnIndex.set(this, void 0);
26
+ this.buffer = new Uint8Array();
27
+ __classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
28
+ }
29
+ decode(chunk) {
30
+ if (chunk == null) {
31
+ return [];
32
+ }
33
+ const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
34
+ : typeof chunk === 'string' ? new TextEncoder().encode(chunk)
35
+ : chunk;
36
+ let newData = new Uint8Array(this.buffer.length + binaryChunk.length);
37
+ newData.set(this.buffer);
38
+ newData.set(binaryChunk, this.buffer.length);
39
+ this.buffer = newData;
40
+ const lines = [];
41
+ let patternIndex;
42
+ while ((patternIndex = findNewlineIndex(this.buffer, __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f"))) != null) {
43
+ if (patternIndex.carriage && __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") == null) {
44
+ // skip until we either get a corresponding `\n`, a new `\r` or nothing
45
+ __classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, patternIndex.index, "f");
46
+ continue;
47
+ }
48
+ // we got double \r or \rtext\n
49
+ if (__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") != null &&
50
+ (patternIndex.index !== __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") + 1 || patternIndex.carriage)) {
51
+ lines.push(this.decodeText(this.buffer.slice(0, __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") - 1)));
52
+ this.buffer = this.buffer.slice(__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f"));
53
+ __classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
54
+ continue;
55
+ }
56
+ const endIndex = __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
57
+ const line = this.decodeText(this.buffer.slice(0, endIndex));
58
+ lines.push(line);
59
+ this.buffer = this.buffer.slice(patternIndex.index);
60
+ __classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
61
+ }
62
+ return lines;
63
+ }
64
+ decodeText(bytes) {
65
+ if (bytes == null)
66
+ return '';
67
+ if (typeof bytes === 'string')
68
+ return bytes;
69
+ // Node:
70
+ if (typeof Buffer !== 'undefined') {
71
+ if (bytes instanceof Buffer) {
72
+ return bytes.toString();
73
+ }
74
+ if (bytes instanceof Uint8Array) {
75
+ return Buffer.from(bytes).toString();
76
+ }
77
+ throw new error_1.AnthropicError(`Unexpected: received non-Uint8Array (${bytes.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`);
78
+ }
79
+ // Browser
80
+ if (typeof TextDecoder !== 'undefined') {
81
+ if (bytes instanceof Uint8Array || bytes instanceof ArrayBuffer) {
82
+ this.textDecoder ?? (this.textDecoder = new TextDecoder('utf8'));
83
+ return this.textDecoder.decode(bytes);
84
+ }
85
+ throw new error_1.AnthropicError(`Unexpected: received non-Uint8Array/ArrayBuffer (${bytes.constructor.name}) in a web platform. Please report this error.`);
86
+ }
87
+ throw new error_1.AnthropicError(`Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.`);
88
+ }
89
+ flush() {
90
+ if (!this.buffer.length) {
91
+ return [];
92
+ }
93
+ return this.decode('\n');
94
+ }
95
+ }
96
+ exports.LineDecoder = LineDecoder;
97
+ _LineDecoder_carriageReturnIndex = new WeakMap();
98
+ // prettier-ignore
99
+ LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r']);
100
+ LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
101
+ /**
102
+ * This function searches the buffer for the end patterns, (\r or \n)
103
+ * and returns an object with the index preceding the matched newline and the
104
+ * index after the newline char. `null` is returned if no new line is found.
105
+ *
106
+ * ```ts
107
+ * findNewLineIndex('abc\ndef') -> { preceding: 2, index: 3 }
108
+ * ```
109
+ */
110
+ function findNewlineIndex(buffer, startIndex) {
111
+ const newline = 0x0a; // \n
112
+ const carriage = 0x0d; // \r
113
+ for (let i = startIndex ?? 0; i < buffer.length; i++) {
114
+ if (buffer[i] === newline) {
115
+ return { preceding: i, index: i + 1, carriage: false };
116
+ }
117
+ if (buffer[i] === carriage) {
118
+ return { preceding: i, index: i + 1, carriage: true };
119
+ }
120
+ }
121
+ return null;
122
+ }
123
+ //# sourceMappingURL=line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line.js","sourceRoot":"","sources":["../../src/internal/decoders/line.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0CAA6C;AAI7C;;;;;GAKG;AACH,MAAa,WAAW;IAStB;QAHA,mDAAoC;QAIlC,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC/B,uBAAA,IAAI,oCAAwB,IAAI,MAAA,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,KAAY;QACjB,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,OAAO,EAAE,CAAC;SACX;QAED,MAAM,WAAW,GACf,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC;YACpD,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC7D,CAAC,CAAC,KAAK,CAAC;QAEV,IAAI,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QAEtB,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,I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,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACtC,0BAAc,GAAG,cAAc,CAAC;AAwGzC;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CACvB,MAAkB,EAClB,UAAyB;IAEzB,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,KAAK;IAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,KAAK;IAE5B,KAAK,IAAI,CAAC,GAAG,UAAU,IAAI,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpD,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;YACzB,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;SACxD;QAED,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YAC1B,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SACvD;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,119 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _LineDecoder_carriageReturnIndex;
13
+ import { AnthropicError } from "../../error.mjs";
14
+ /**
15
+ * A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
16
+ * reading lines from text.
17
+ *
18
+ * https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
19
+ */
20
+ export class LineDecoder {
21
+ constructor() {
22
+ _LineDecoder_carriageReturnIndex.set(this, void 0);
23
+ this.buffer = new Uint8Array();
24
+ __classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
25
+ }
26
+ decode(chunk) {
27
+ if (chunk == null) {
28
+ return [];
29
+ }
30
+ const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
31
+ : typeof chunk === 'string' ? new TextEncoder().encode(chunk)
32
+ : chunk;
33
+ let newData = new Uint8Array(this.buffer.length + binaryChunk.length);
34
+ newData.set(this.buffer);
35
+ newData.set(binaryChunk, this.buffer.length);
36
+ this.buffer = newData;
37
+ const lines = [];
38
+ let patternIndex;
39
+ while ((patternIndex = findNewlineIndex(this.buffer, __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f"))) != null) {
40
+ if (patternIndex.carriage && __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") == null) {
41
+ // skip until we either get a corresponding `\n`, a new `\r` or nothing
42
+ __classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, patternIndex.index, "f");
43
+ continue;
44
+ }
45
+ // we got double \r or \rtext\n
46
+ if (__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") != null &&
47
+ (patternIndex.index !== __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") + 1 || patternIndex.carriage)) {
48
+ lines.push(this.decodeText(this.buffer.slice(0, __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") - 1)));
49
+ this.buffer = this.buffer.slice(__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f"));
50
+ __classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
51
+ continue;
52
+ }
53
+ const endIndex = __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
54
+ const line = this.decodeText(this.buffer.slice(0, endIndex));
55
+ lines.push(line);
56
+ this.buffer = this.buffer.slice(patternIndex.index);
57
+ __classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
58
+ }
59
+ return lines;
60
+ }
61
+ decodeText(bytes) {
62
+ if (bytes == null)
63
+ return '';
64
+ if (typeof bytes === 'string')
65
+ return bytes;
66
+ // Node:
67
+ if (typeof Buffer !== 'undefined') {
68
+ if (bytes instanceof Buffer) {
69
+ return bytes.toString();
70
+ }
71
+ if (bytes instanceof Uint8Array) {
72
+ return Buffer.from(bytes).toString();
73
+ }
74
+ throw new AnthropicError(`Unexpected: received non-Uint8Array (${bytes.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`);
75
+ }
76
+ // Browser
77
+ if (typeof TextDecoder !== 'undefined') {
78
+ if (bytes instanceof Uint8Array || bytes instanceof ArrayBuffer) {
79
+ this.textDecoder ?? (this.textDecoder = new TextDecoder('utf8'));
80
+ return this.textDecoder.decode(bytes);
81
+ }
82
+ throw new AnthropicError(`Unexpected: received non-Uint8Array/ArrayBuffer (${bytes.constructor.name}) in a web platform. Please report this error.`);
83
+ }
84
+ throw new AnthropicError(`Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.`);
85
+ }
86
+ flush() {
87
+ if (!this.buffer.length) {
88
+ return [];
89
+ }
90
+ return this.decode('\n');
91
+ }
92
+ }
93
+ _LineDecoder_carriageReturnIndex = new WeakMap();
94
+ // prettier-ignore
95
+ LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r']);
96
+ LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
97
+ /**
98
+ * This function searches the buffer for the end patterns, (\r or \n)
99
+ * and returns an object with the index preceding the matched newline and the
100
+ * index after the newline char. `null` is returned if no new line is found.
101
+ *
102
+ * ```ts
103
+ * findNewLineIndex('abc\ndef') -> { preceding: 2, index: 3 }
104
+ * ```
105
+ */
106
+ function findNewlineIndex(buffer, startIndex) {
107
+ const newline = 0x0a; // \n
108
+ const carriage = 0x0d; // \r
109
+ for (let i = startIndex ?? 0; i < buffer.length; i++) {
110
+ if (buffer[i] === newline) {
111
+ return { preceding: i, index: i + 1, carriage: false };
112
+ }
113
+ if (buffer[i] === carriage) {
114
+ return { preceding: i, index: i + 1, carriage: true };
115
+ }
116
+ }
117
+ return null;
118
+ }
119
+ //# sourceMappingURL=line.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line.mjs","sourceRoot":"","sources":["../../src/internal/decoders/line.ts"],"names":[],"mappings":";;;;;;;;;;;;OAAO,EAAE,cAAc,EAAE;AAIzB;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IAStB;QAHA,mDAAoC;QAIlC,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC/B,uBAAA,IAAI,oCAAwB,IAAI,MAAA,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,KAAY;QACjB,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,OAAO,EAAE,CAAC;SACX;QAED,MAAM,WAAW,GACf,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC;YACpD,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC7D,CAAC,CAAC,KAAK,CAAC;QAEV,IAAI,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,IAAI,CAA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C,MAAM,CAAC,MAAM,EAAE;YACvB,OAAO,EAAE,CAAC;SACX;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;;;AAvGD,kBAAkB;AACX,yBAAa,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACtC,0BAAc,GAAG,cAAc,CAAC;AAwGzC;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CACvB,MAAkB,EAClB,UAAyB;IAEzB,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,KAAK;IAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,KAAK;IAE5B,KAAK,IAAI,CAAC,GAAG,UAAU,IAAI,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpD,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;YACzB,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;SACxD;QAED,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YAC1B,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SACvD;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Most browsers don't yet have async iterable support for ReadableStream,
3
+ * and Node has a very different way of reading bytes from its "ReadableStream".
4
+ *
5
+ * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
6
+ */
7
+ export declare function ReadableStreamToAsyncIterable<T>(stream: any): AsyncIterableIterator<T>;
8
+ //# sourceMappingURL=stream-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-utils.d.ts","sourceRoot":"","sources":["../src/internal/stream-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAyBtF"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReadableStreamToAsyncIterable = void 0;
4
+ /**
5
+ * Most browsers don't yet have async iterable support for ReadableStream,
6
+ * and Node has a very different way of reading bytes from its "ReadableStream".
7
+ *
8
+ * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
9
+ */
10
+ function ReadableStreamToAsyncIterable(stream) {
11
+ if (stream[Symbol.asyncIterator])
12
+ return stream;
13
+ const reader = stream.getReader();
14
+ return {
15
+ async next() {
16
+ try {
17
+ const result = await reader.read();
18
+ if (result?.done)
19
+ reader.releaseLock(); // release lock when stream becomes closed
20
+ return result;
21
+ }
22
+ catch (e) {
23
+ reader.releaseLock(); // release lock when stream becomes errored
24
+ throw e;
25
+ }
26
+ },
27
+ async return() {
28
+ const cancelPromise = reader.cancel();
29
+ reader.releaseLock();
30
+ await cancelPromise;
31
+ return { done: true, value: undefined };
32
+ },
33
+ [Symbol.asyncIterator]() {
34
+ return this;
35
+ },
36
+ };
37
+ }
38
+ exports.ReadableStreamToAsyncIterable = ReadableStreamToAsyncIterable;
39
+ //# sourceMappingURL=stream-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-utils.js","sourceRoot":"","sources":["../src/internal/stream-utils.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,6BAA6B,CAAI,MAAW;IAC1D,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;QAAE,OAAO,MAAM,CAAC;IAEhD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAClC,OAAO;QACL,KAAK,CAAC,IAAI;YACR,IAAI;gBACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBACnC,IAAI,MAAM,EAAE,IAAI;oBAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,0CAA0C;gBAClF,OAAO,MAAM,CAAC;aACf;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,2CAA2C;gBACjE,MAAM,CAAC,CAAC;aACT;QACH,CAAC;QACD,KAAK,CAAC,MAAM;YACV,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YACtC,MAAM,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,aAAa,CAAC;YACpB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAC1C,CAAC;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAzBD,sEAyBC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Most browsers don't yet have async iterable support for ReadableStream,
3
+ * and Node has a very different way of reading bytes from its "ReadableStream".
4
+ *
5
+ * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
6
+ */
7
+ export function ReadableStreamToAsyncIterable(stream) {
8
+ if (stream[Symbol.asyncIterator])
9
+ return stream;
10
+ const reader = stream.getReader();
11
+ return {
12
+ async next() {
13
+ try {
14
+ const result = await reader.read();
15
+ if (result?.done)
16
+ reader.releaseLock(); // release lock when stream becomes closed
17
+ return result;
18
+ }
19
+ catch (e) {
20
+ reader.releaseLock(); // release lock when stream becomes errored
21
+ throw e;
22
+ }
23
+ },
24
+ async return() {
25
+ const cancelPromise = reader.cancel();
26
+ reader.releaseLock();
27
+ await cancelPromise;
28
+ return { done: true, value: undefined };
29
+ },
30
+ [Symbol.asyncIterator]() {
31
+ return this;
32
+ },
33
+ };
34
+ }
35
+ //# sourceMappingURL=stream-utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-utils.mjs","sourceRoot":"","sources":["../src/internal/stream-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAI,MAAW;IAC1D,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;QAAE,OAAO,MAAM,CAAC;IAEhD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAClC,OAAO;QACL,KAAK,CAAC,IAAI;YACR,IAAI;gBACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBACnC,IAAI,MAAM,EAAE,IAAI;oBAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,0CAA0C;gBAClF,OAAO,MAAM,CAAC;aACf;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,2CAA2C;gBACjE,MAAM,CAAC,CAAC;aACT;QACH,CAAC;QACD,KAAK,CAAC,MAAM;YACV,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YACtC,MAAM,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,aAAa,CAAC;YACpB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAC1C,CAAC;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,114 @@
1
+
2
+ import * as Core from '@anthropic-ai/sdk/core';
3
+ import { AnthropicError, APIUserAbortError } from '@anthropic-ai/sdk/error';
4
+ import { type BetaContentBlock, Messages as BetaMessages, type BetaMessage, type BetaRawMessageStreamEvent as BetaMessageStreamEvent, type BetaMessageParam, type MessageCreateParams as BetaMessageCreateParams, type MessageCreateParamsBase as BetaMessageCreateParamsBase, type BetaTextCitation } from '@anthropic-ai/sdk/resources/beta/messages/messages';
5
+ import { type ReadableStream, type Response } from '@anthropic-ai/sdk/_shims/index';
6
+ export interface MessageStreamEvents {
7
+ connect: () => void;
8
+ streamEvent: (event: BetaMessageStreamEvent, snapshot: BetaMessage) => void;
9
+ text: (textDelta: string, textSnapshot: string) => void;
10
+ citation: (citation: BetaTextCitation, citationsSnapshot: BetaTextCitation[]) => void;
11
+ inputJson: (partialJson: string, jsonSnapshot: unknown) => void;
12
+ thinking: (thinkingDelta: string, thinkingSnapshot: string) => void;
13
+ message: (message: BetaMessage) => void;
14
+ contentBlock: (content: BetaContentBlock) => void;
15
+ finalMessage: (message: BetaMessage) => void;
16
+ error: (error: AnthropicError) => void;
17
+ abort: (error: APIUserAbortError) => void;
18
+ end: () => void;
19
+ }
20
+ export declare class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent> {
21
+ #private;
22
+ messages: BetaMessageParam[];
23
+ receivedMessages: BetaMessage[];
24
+ controller: AbortController;
25
+ constructor();
26
+ get response(): Response | null | undefined;
27
+ get request_id(): string | null | undefined;
28
+ /**
29
+ * Returns the `MessageStream` data, the raw `Response` instance and the ID of the request,
30
+ * returned vie the `request-id` header which is useful for debugging requests and resporting
31
+ * issues to Anthropic.
32
+ *
33
+ * This is the same as the `APIPromise.withResponse()` method.
34
+ *
35
+ * This method will raise an error if you created the stream using `MessageStream.fromReadableStream`
36
+ * as no `Response` is available.
37
+ */
38
+ withResponse(): Promise<{
39
+ data: BetaMessageStream;
40
+ response: Response;
41
+ request_id: string | null | undefined;
42
+ }>;
43
+ /**
44
+ * Intended for use on the frontend, consuming a stream produced with
45
+ * `.toReadableStream()` on the backend.
46
+ *
47
+ * Note that messages sent to the model do not appear in `.on('message')`
48
+ * in this context.
49
+ */
50
+ static fromReadableStream(stream: ReadableStream): BetaMessageStream;
51
+ static createMessage(messages: BetaMessages, params: BetaMessageCreateParamsBase, options?: Core.RequestOptions): BetaMessageStream;
52
+ protected _run(executor: () => Promise<any>): void;
53
+ protected _addMessageParam(message: BetaMessageParam): void;
54
+ protected _addMessage(message: BetaMessage, emit?: boolean): void;
55
+ protected _createMessage(messages: BetaMessages, params: BetaMessageCreateParams, options?: Core.RequestOptions): Promise<void>;
56
+ protected _connected(response: Response | null): void;
57
+ get ended(): boolean;
58
+ get errored(): boolean;
59
+ get aborted(): boolean;
60
+ abort(): void;
61
+ /**
62
+ * Adds the listener function to the end of the listeners array for the event.
63
+ * No checks are made to see if the listener has already been added. Multiple calls passing
64
+ * the same combination of event and listener will result in the listener being added, and
65
+ * called, multiple times.
66
+ * @returns this MessageStream, so that calls can be chained
67
+ */
68
+ on<Event extends keyof MessageStreamEvents>(event: Event, listener: MessageStreamEvents[Event]): this;
69
+ /**
70
+ * Removes the specified listener from the listener array for the event.
71
+ * off() will remove, at most, one instance of a listener from the listener array. If any single
72
+ * listener has been added multiple times to the listener array for the specified event, then
73
+ * off() must be called multiple times to remove each instance.
74
+ * @returns this MessageStream, so that calls can be chained
75
+ */
76
+ off<Event extends keyof MessageStreamEvents>(event: Event, listener: MessageStreamEvents[Event]): this;
77
+ /**
78
+ * Adds a one-time listener function for the event. The next time the event is triggered,
79
+ * this listener is removed and then invoked.
80
+ * @returns this MessageStream, so that calls can be chained
81
+ */
82
+ once<Event extends keyof MessageStreamEvents>(event: Event, listener: MessageStreamEvents[Event]): this;
83
+ /**
84
+ * This is similar to `.once()`, but returns a Promise that resolves the next time
85
+ * the event is triggered, instead of calling a listener callback.
86
+ * @returns a Promise that resolves the next time given event is triggered,
87
+ * or rejects if an error is emitted. (If you request the 'error' event,
88
+ * returns a promise that resolves with the error).
89
+ *
90
+ * Example:
91
+ *
92
+ * const message = await stream.emitted('message') // rejects if the stream errors
93
+ */
94
+ emitted<Event extends keyof MessageStreamEvents>(event: Event): Promise<Parameters<MessageStreamEvents[Event]> extends [infer Param] ? Param : Parameters<MessageStreamEvents[Event]> extends [] ? void : Parameters<MessageStreamEvents[Event]>>;
95
+ done(): Promise<void>;
96
+ get currentMessage(): BetaMessage | undefined;
97
+ /**
98
+ * @returns a promise that resolves with the the final assistant Message response,
99
+ * or rejects if an error occurred or the stream ended prematurely without producing a Message.
100
+ */
101
+ finalMessage(): Promise<BetaMessage>;
102
+ /**
103
+ * @returns a promise that resolves with the the final assistant Message's text response, concatenated
104
+ * together if there are more than one text blocks.
105
+ * Rejects if an error occurred or the stream ended prematurely without producing a Message.
106
+ */
107
+ finalText(): Promise<string>;
108
+ protected _emit<Event extends keyof MessageStreamEvents>(event: Event, ...args: Parameters<MessageStreamEvents[Event]>): void;
109
+ protected _emitFinal(): void;
110
+ protected _fromReadableStream(readableStream: ReadableStream, options?: Core.RequestOptions): Promise<void>;
111
+ [Symbol.asyncIterator](): AsyncIterator<BetaMessageStreamEvent>;
112
+ toReadableStream(): ReadableStream;
113
+ }
114
+ //# sourceMappingURL=BetaMessageStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BetaMessageStream.d.ts","sourceRoot":"","sources":["../src/lib/BetaMessageStream.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EACL,KAAK,gBAAgB,EACrB,QAAQ,IAAI,YAAY,EACxB,KAAK,WAAW,EAChB,KAAK,yBAAyB,IAAI,sBAAsB,EACxD,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,IAAI,uBAAuB,EACnD,KAAK,uBAAuB,IAAI,2BAA2B,EAE3D,KAAK,gBAAgB,EACtB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAIpF,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,CAAC,KAAK,EAAE,sBAAsB,EAAE,QAAQ,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5E,IA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