@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,8 @@
1
+ Copyright 2023 Anthropic, PBC.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+
@@ -0,0 +1,536 @@
1
+ > [!IMPORTANT]
2
+ > We're actively working on a new alpha version that migrates from `node-fetch` to builtin fetch.
3
+ >
4
+ > Please try it out and let us know if you run into any issues!
5
+ > https://github.com/anthropics/anthropic-sdk-typescript/issues/645
6
+
7
+ # Anthropic TypeScript API Library
8
+
9
+ [![NPM version](https://img.shields.io/npm/v/@anthropic-ai/sdk.svg)](https://npmjs.org/package/@anthropic-ai/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@anthropic-ai/sdk)
10
+
11
+ This library provides convenient access to the Anthropic REST API from server-side TypeScript or JavaScript.
12
+
13
+ The REST API documentation can be found on [docs.anthropic.com](https://docs.anthropic.com/claude/reference/). The full API of this library can be found in [api.md](api.md).
14
+
15
+ ## Installation
16
+
17
+ ```sh
18
+ npm install @anthropic-ai/sdk
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ The full API of this library can be found in [api.md](api.md).
24
+
25
+ <!-- prettier-ignore -->
26
+ ```js
27
+ import Anthropic from '@anthropic-ai/sdk';
28
+
29
+ const client = new Anthropic({
30
+ apiKey: process.env['ANTHROPIC_API_KEY'], // This is the default and can be omitted
31
+ });
32
+
33
+ async function main() {
34
+ const message = await client.messages.create({
35
+ max_tokens: 1024,
36
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
37
+ model: 'claude-3-5-sonnet-latest',
38
+ });
39
+
40
+ console.log(message.content);
41
+ }
42
+
43
+ main();
44
+ ```
45
+
46
+ ## Streaming responses
47
+
48
+ We provide support for streaming responses using Server Sent Events (SSE).
49
+
50
+ ```ts
51
+ import Anthropic from '@anthropic-ai/sdk';
52
+
53
+ const client = new Anthropic();
54
+
55
+ const stream = await client.messages.create({
56
+ max_tokens: 1024,
57
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
58
+ model: 'claude-3-5-sonnet-latest',
59
+ stream: true,
60
+ });
61
+ for await (const messageStreamEvent of stream) {
62
+ console.log(messageStreamEvent.type);
63
+ }
64
+ ```
65
+
66
+ If you need to cancel a stream, you can `break` from the loop
67
+ or call `stream.controller.abort()`.
68
+
69
+ ### Request & Response types
70
+
71
+ This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:
72
+
73
+ <!-- prettier-ignore -->
74
+ ```ts
75
+ import Anthropic from '@anthropic-ai/sdk';
76
+
77
+ const client = new Anthropic({
78
+ apiKey: process.env['ANTHROPIC_API_KEY'], // This is the default and can be omitted
79
+ });
80
+
81
+ async function main() {
82
+ const params: Anthropic.MessageCreateParams = {
83
+ max_tokens: 1024,
84
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
85
+ model: 'claude-3-5-sonnet-latest',
86
+ };
87
+ const message: Anthropic.Message = await client.messages.create(params);
88
+ }
89
+
90
+ main();
91
+ ```
92
+
93
+ Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
94
+
95
+ ## Counting Tokens
96
+
97
+ You can see the exact usage for a given request through the `usage` response property, e.g.
98
+
99
+ ```ts
100
+ const message = await client.messages.create(...)
101
+ console.log(message.usage)
102
+ // { input_tokens: 25, output_tokens: 13 }
103
+ ```
104
+
105
+ ## Streaming Helpers
106
+
107
+ This library provides several conveniences for streaming messages, for example:
108
+
109
+ ```ts
110
+ import Anthropic from '@anthropic-ai/sdk';
111
+
112
+ const anthropic = new Anthropic();
113
+
114
+ async function main() {
115
+ const stream = anthropic.messages
116
+ .stream({
117
+ model: 'claude-3-5-sonnet-latest',
118
+ max_tokens: 1024,
119
+ messages: [
120
+ {
121
+ role: 'user',
122
+ content: 'Say hello there!',
123
+ },
124
+ ],
125
+ })
126
+ .on('text', (text) => {
127
+ console.log(text);
128
+ });
129
+
130
+ const message = await stream.finalMessage();
131
+ console.log(message);
132
+ }
133
+
134
+ main();
135
+ ```
136
+
137
+ Streaming with `client.messages.stream(...)` exposes [various helpers for your convenience](helpers.md) including event handlers and accumulation.
138
+
139
+ Alternatively, you can use `client.messages.create({ ..., stream: true })` which only returns an async iterable of the events in the stream and thus uses less memory (it does not build up a final message object for you).
140
+
141
+ ## Message Batches
142
+
143
+ This SDK provides beta support for the [Message Batches API](https://docs.anthropic.com/en/docs/build-with-claude/message-batches) under the `client.beta.messages.batches` namespace.
144
+
145
+ ### Creating a batch
146
+
147
+ Message Batches takes an array of requests, where each object has a `custom_id` identifier, and the exact same request `params` as the standard Messages API:
148
+
149
+ ```ts
150
+ await anthropic.beta.messages.batches.create({
151
+ requests: [
152
+ {
153
+ custom_id: 'my-first-request',
154
+ params: {
155
+ model: 'claude-3-5-sonnet-latest',
156
+ max_tokens: 1024,
157
+ messages: [{ role: 'user', content: 'Hello, world' }],
158
+ },
159
+ },
160
+ {
161
+ custom_id: 'my-second-request',
162
+ params: {
163
+ model: 'claude-3-5-sonnet-latest',
164
+ max_tokens: 1024,
165
+ messages: [{ role: 'user', content: 'Hi again, friend' }],
166
+ },
167
+ },
168
+ ],
169
+ });
170
+ ```
171
+
172
+
173
+ ### Getting results from a batch
174
+
175
+ Once a Message Batch has been processed, indicated by `.processing_status === 'ended'`, you can access the results with `.batches.results()`
176
+
177
+ ```ts
178
+ const results = await anthropic.beta.messages.batches.results(batch_id);
179
+ for await (const entry of results) {
180
+ if (entry.result.type === 'succeeded') {
181
+ console.log(entry.result.message.content)
182
+ }
183
+ }
184
+ ```
185
+
186
+ ## Tool use beta
187
+
188
+ This SDK provides beta support for tool use, aka function calling. More details can be found in [the documentation](https://docs.anthropic.com/claude/docs/tool-use).
189
+
190
+ ## AWS Bedrock
191
+
192
+ We provide support for the [Anthropic Bedrock API](https://aws.amazon.com/bedrock/claude/) through a [separate package](https://github.com/anthropics/anthropic-sdk-typescript/tree/main/packages/bedrock-sdk).
193
+
194
+ ## Handling errors
195
+
196
+ When the library is unable to connect to the API,
197
+ or if the API returns a non-success status code (i.e., 4xx or 5xx response),
198
+ a subclass of `APIError` will be thrown:
199
+
200
+ <!-- prettier-ignore -->
201
+ ```ts
202
+ async function main() {
203
+ const message = await client.messages
204
+ .create({
205
+ max_tokens: 1024,
206
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
207
+ model: 'claude-3-5-sonnet-latest',
208
+ })
209
+ .catch(async (err) => {
210
+ if (err instanceof Anthropic.APIError) {
211
+ console.log(err.status); // 400
212
+ console.log(err.name); // BadRequestError
213
+ console.log(err.headers); // {server: 'nginx', ...}
214
+ } else {
215
+ throw err;
216
+ }
217
+ });
218
+ }
219
+
220
+ main();
221
+ ```
222
+
223
+ Error codes are as followed:
224
+
225
+ | Status Code | Error Type |
226
+ | ----------- | -------------------------- |
227
+ | 400 | `BadRequestError` |
228
+ | 401 | `AuthenticationError` |
229
+ | 403 | `PermissionDeniedError` |
230
+ | 404 | `NotFoundError` |
231
+ | 422 | `UnprocessableEntityError` |
232
+ | 429 | `RateLimitError` |
233
+ | >=500 | `InternalServerError` |
234
+ | N/A | `APIConnectionError` |
235
+
236
+ ## Request IDs
237
+
238
+ > For more information on debugging requests, see [these docs](https://docs.anthropic.com/en/api/errors#request-id)
239
+
240
+ All object responses in the SDK provide a `_request_id` property which is added from the `request-id` response header so that you can quickly log failing requests and report them back to Anthropic.
241
+
242
+ ```ts
243
+ const message = await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-5-sonnet-latest' });
244
+ console.log(message._request_id) // req_018EeWyXxfu5pfWkrYcMdjWG
245
+ ```
246
+
247
+
248
+ ### Retries
249
+
250
+ Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
251
+ Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
252
+ 429 Rate Limit, and >=500 Internal errors will all be retried by default.
253
+
254
+ You can use the `maxRetries` option to configure or disable this:
255
+
256
+ <!-- prettier-ignore -->
257
+ ```js
258
+ // Configure the default for all requests:
259
+ const client = new Anthropic({
260
+ maxRetries: 0, // default is 2
261
+ });
262
+
263
+ // Or, configure per-request:
264
+ await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-5-sonnet-latest' }, {
265
+ maxRetries: 5,
266
+ });
267
+ ```
268
+
269
+ ### Timeouts
270
+
271
+ Requests time out after 10 minutes by default. You can configure this with a `timeout` option:
272
+
273
+ <!-- prettier-ignore -->
274
+ ```ts
275
+ // Configure the default for all requests:
276
+ const client = new Anthropic({
277
+ timeout: 20 * 1000, // 20 seconds (default is 10 minutes)
278
+ });
279
+
280
+ // Override per-request:
281
+ await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-5-sonnet-latest' }, {
282
+ timeout: 5 * 1000,
283
+ });
284
+ ```
285
+
286
+ On timeout, an `APIConnectionTimeoutError` is thrown.
287
+
288
+ Note that requests which time out will be [retried twice by default](#retries).
289
+
290
+ ## Auto-pagination
291
+
292
+ List methods in the Anthropic API are paginated.
293
+ You can use the `for await … of` syntax to iterate through items across all pages:
294
+
295
+ ```ts
296
+ async function fetchAllBetaMessagesBatches(params) {
297
+ const allBetaMessagesBatches = [];
298
+ // Automatically fetches more pages as needed.
299
+ for await (const betaMessageBatch of client.beta.messages.batches.list({ limit: 20 })) {
300
+ allBetaMessagesBatches.push(betaMessageBatch);
301
+ }
302
+ return allBetaMessagesBatches;
303
+ }
304
+ ```
305
+
306
+ Alternatively, you can request a single page at a time:
307
+
308
+ ```ts
309
+ let page = await client.beta.messages.batches.list({ limit: 20 });
310
+ for (const betaMessageBatch of page.data) {
311
+ console.log(betaMessageBatch);
312
+ }
313
+
314
+ // Convenience methods are provided for manually paginating:
315
+ while (page.hasNextPage()) {
316
+ page = await page.getNextPage();
317
+ // ...
318
+ }
319
+ ```
320
+
321
+ ## Default Headers
322
+
323
+ We automatically send the `anthropic-version` header set to `2023-06-01`.
324
+
325
+ If you need to, you can override it by setting default headers on a per-request basis.
326
+
327
+ Be aware that doing so may result in incorrect types and other unexpected or undefined behavior in the SDK.
328
+
329
+ ```ts
330
+ import Anthropic from '@anthropic-ai/sdk';
331
+
332
+ const client = new Anthropic();
333
+
334
+ const message = await client.messages.create(
335
+ {
336
+ max_tokens: 1024,
337
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
338
+ model: 'claude-3-5-sonnet-latest',
339
+ },
340
+ { headers: { 'anthropic-version': 'My-Custom-Value' } },
341
+ );
342
+ ```
343
+
344
+ ## Advanced Usage
345
+
346
+ ### Accessing raw Response data (e.g., headers)
347
+
348
+ The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.
349
+
350
+ You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
351
+
352
+ <!-- prettier-ignore -->
353
+ ```ts
354
+ const client = new Anthropic();
355
+
356
+ const response = await client.messages
357
+ .create({
358
+ max_tokens: 1024,
359
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
360
+ model: 'claude-3-5-sonnet-latest',
361
+ })
362
+ .asResponse();
363
+ console.log(response.headers.get('X-My-Header'));
364
+ console.log(response.statusText); // access the underlying Response object
365
+
366
+ const { data: message, response: raw } = await client.messages
367
+ .create({
368
+ max_tokens: 1024,
369
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
370
+ model: 'claude-3-5-sonnet-latest',
371
+ })
372
+ .withResponse();
373
+ console.log(raw.headers.get('X-My-Header'));
374
+ console.log(message.content);
375
+ ```
376
+
377
+ ### Making custom/undocumented requests
378
+
379
+ This library is typed for convenient access to the documented API. If you need to access undocumented
380
+ endpoints, params, or response properties, the library can still be used.
381
+
382
+ #### Undocumented endpoints
383
+
384
+ To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.
385
+ Options on the client, such as retries, will be respected when making these requests.
386
+
387
+ ```ts
388
+ await client.post('/some/path', {
389
+ body: { some_prop: 'foo' },
390
+ query: { some_query_arg: 'bar' },
391
+ });
392
+ ```
393
+
394
+ #### Undocumented request params
395
+
396
+ To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
397
+ parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you
398
+ send will be sent as-is.
399
+
400
+ ```ts
401
+ client.foo.create({
402
+ foo: 'my_param',
403
+ bar: 12,
404
+ // @ts-expect-error baz is not yet public
405
+ baz: 'undocumented option',
406
+ });
407
+ ```
408
+
409
+ For requests with the `GET` verb, any extra params will be in the query, all other requests will send the
410
+ extra param in the body.
411
+
412
+ If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request
413
+ options.
414
+
415
+ #### Undocumented response properties
416
+
417
+ To access undocumented response properties, you may access the response object with `// @ts-expect-error` on
418
+ the response object, or cast the response object to the requisite type. Like the request params, we do not
419
+ validate or strip extra properties from the response from the API.
420
+
421
+ ### Customizing the fetch client
422
+
423
+ By default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments.
424
+
425
+ If you would prefer to use a global, web-standards-compliant `fetch` function even in a Node environment,
426
+ (for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`),
427
+ add the following import before your first import `from "Anthropic"`:
428
+
429
+ ```ts
430
+ // Tell TypeScript and the package to use the global web fetch instead of node-fetch.
431
+ // Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
432
+ import '@anthropic-ai/sdk/shims/web';
433
+ import Anthropic from '@anthropic-ai/sdk';
434
+ ```
435
+
436
+ To do the inverse, add `import "@anthropic-ai/sdk/shims/node"` (which does import polyfills).
437
+ This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/anthropics/anthropic-sdk-typescript/tree/main/src/_shims#readme)).
438
+
439
+ ### Logging and middleware
440
+
441
+ You may also provide a custom `fetch` function when instantiating the client,
442
+ which can be used to inspect or alter the `Request` or `Response` before/after each request:
443
+
444
+ ```ts
445
+ import { fetch } from 'undici'; // as one example
446
+ import Anthropic from '@anthropic-ai/sdk';
447
+
448
+ const client = new Anthropic({
449
+ fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
450
+ console.log('About to make a request', url, init);
451
+ const response = await fetch(url, init);
452
+ console.log('Got response', response);
453
+ return response;
454
+ },
455
+ });
456
+ ```
457
+
458
+ Note that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically.
459
+ This is intended for debugging purposes only and may change in the future without notice.
460
+
461
+ ### Configuring an HTTP(S) Agent (e.g., for proxies)
462
+
463
+ By default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes and shaving around 100ms off most requests.
464
+
465
+ If you would like to disable or customize this behavior, for example to use the API behind a proxy, you can pass an `httpAgent` which is used for all requests (be they http or https), for example:
466
+
467
+ <!-- prettier-ignore -->
468
+ ```ts
469
+ import http from 'http';
470
+ import { HttpsProxyAgent } from 'https-proxy-agent';
471
+
472
+ // Configure the default for all requests:
473
+ const client = new Anthropic({
474
+ httpAgent: new HttpsProxyAgent(process.env.PROXY_URL),
475
+ });
476
+
477
+ // Override per-request:
478
+ await client.messages.create(
479
+ {
480
+ max_tokens: 1024,
481
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
482
+ model: 'claude-3-5-sonnet-latest',
483
+ },
484
+ {
485
+ httpAgent: new http.Agent({ keepAlive: false }),
486
+ },
487
+ );
488
+ ```
489
+
490
+ ## Semantic versioning
491
+
492
+ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
493
+
494
+ 1. Changes that only affect static types, without breaking runtime behavior.
495
+ 2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
496
+ 3. Changes that we do not expect to impact the vast majority of users in practice.
497
+
498
+ We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
499
+
500
+ We are keen for your feedback; please open an [issue](https://www.github.com/anthropics/anthropic-sdk-typescript/issues) with questions, bugs, or suggestions.
501
+
502
+ ## Requirements
503
+
504
+ TypeScript >= 4.5 is supported.
505
+
506
+ The following runtimes are supported:
507
+
508
+ - Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
509
+ - Deno v1.28.0 or higher.
510
+ - Bun 1.0 or later.
511
+ - Cloudflare Workers.
512
+ - Vercel Edge Runtime.
513
+ - Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
514
+ - Nitro v2.6 or greater.
515
+ - Web browsers: disabled by default to avoid exposing your secret API credentials (see our help center for [best practices](https://support.anthropic.com/en/articles/9767949-api-key-best-practices-keeping-your-keys-safe-and-secure)). Enable browser support by explicitly setting `dangerouslyAllowBrowser` to `true`.
516
+
517
+ <details>
518
+ <summary><b>More explanation</b></summary>
519
+ <h3>Why is this dangerous?</h3>
520
+ Enabling the <code>dangerouslyAllowBrowser</code> option can be dangerous because it exposes your secret API credentials in the client-side code. Web browsers are inherently less secure than server environments,
521
+ any user with access to the browser can potentially inspect, extract, and misuse these credentials. This could lead to unauthorized access using your credentials and potentially compromise sensitive data or functionality.
522
+ <h3>When might this not be dangerous?</h3>
523
+ In certain scenarios where enabling browser support might not pose significant risks:
524
+ <ul>
525
+ <li>Internal Tools: If the application is used solely within a controlled internal environment where the users are trusted, the risk of credential exposure can be mitigated.</li>
526
+ <li>Development or debugging purpose: Enabling this feature temporarily might be acceptable, provided the credentials are short-lived, aren't also used in production environments, or are frequently rotated.</li>
527
+ </ul>
528
+ </details>
529
+
530
+ Note that React Native is not supported at this time.
531
+
532
+ If you are interested in other runtime environments, please open or upvote an issue on GitHub.
533
+
534
+ ## Contributing
535
+
536
+ See [the contributing documentation](./CONTRIBUTING.md).
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ export declare class MultipartBody {
5
+ body: any;
6
+ constructor(body: any);
7
+ get [Symbol.toStringTag](): string;
8
+ }
9
+ //# sourceMappingURL=MultipartBody.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultipartBody.d.ts","sourceRoot":"","sources":["../src/_shims/MultipartBody.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,aAAa;IACL,IAAI,EAAE,GAAG;gBAAT,IAAI,EAAE,GAAG;IAC5B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;CACF"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MultipartBody = void 0;
4
+ /**
5
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
6
+ */
7
+ class MultipartBody {
8
+ constructor(body) {
9
+ this.body = body;
10
+ }
11
+ get [Symbol.toStringTag]() {
12
+ return 'MultipartBody';
13
+ }
14
+ }
15
+ exports.MultipartBody = MultipartBody;
16
+ //# sourceMappingURL=MultipartBody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultipartBody.js","sourceRoot":"","sources":["../src/_shims/MultipartBody.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,aAAa;IACxB,YAAmB,IAAS;QAAT,SAAI,GAAJ,IAAI,CAAK;IAAG,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AALD,sCAKC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ export class MultipartBody {
5
+ constructor(body) {
6
+ this.body = body;
7
+ }
8
+ get [Symbol.toStringTag]() {
9
+ return 'MultipartBody';
10
+ }
11
+ }
12
+ //# sourceMappingURL=MultipartBody.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultipartBody.mjs","sourceRoot":"","sources":["../src/_shims/MultipartBody.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,aAAa;IACxB,YAAmB,IAAS;QAAT,SAAI,GAAJ,IAAI,CAAK;IAAG,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,46 @@
1
+ # 👋 Wondering what everything in here does?
2
+
3
+ `@anthropic-ai/sdk` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
4
+ edge runtimes, as well as both CommonJS (CJS) and EcmaScript Modules (ESM).
5
+
6
+ To do this, `@anthropic-ai/sdk` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node.
7
+
8
+ It uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to
9
+ automatically select the correct shims for each environment. However, conditional exports are a fairly new
10
+ feature and not supported everywhere. For instance, the TypeScript `"moduleResolution": "node"`
11
+
12
+ setting doesn't consult the `exports` map, compared to `"moduleResolution": "nodeNext"`, which does.
13
+ Unfortunately that's still the default setting, and it can result in errors like
14
+ getting the wrong raw `Response` type from `.asResponse()`, for example.
15
+
16
+ The user can work around these issues by manually importing one of:
17
+
18
+ - `import '@anthropic-ai/sdk/shims/node'`
19
+ - `import '@anthropic-ai/sdk/shims/web'`
20
+
21
+ All of the code here in `_shims` handles selecting the automatic default shims or manual overrides.
22
+
23
+ ### How it works - Runtime
24
+
25
+ Runtime shims get installed by calling `setShims` exported by `@anthropic-ai/sdk/_shims/registry`.
26
+
27
+ Manually importing `@anthropic-ai/sdk/shims/node` or `@anthropic-ai/sdk/shims/web`, calls `setShims` with the respective runtime shims.
28
+
29
+ All client code imports shims from `@anthropic-ai/sdk/_shims/index`, which:
30
+
31
+ - checks if shims have been set manually
32
+ - if not, calls `setShims` with the shims from `@anthropic-ai/sdk/_shims/auto/runtime`
33
+ - re-exports the installed shims from `@anthropic-ai/sdk/_shims/registry`.
34
+
35
+ `@anthropic-ai/sdk/_shims/auto/runtime` exports web runtime shims.
36
+ If the `node` export condition is set, the export map replaces it with `@anthropic-ai/sdk/_shims/auto/runtime-node`.
37
+
38
+ ### How it works - Type time
39
+
40
+ All client code imports shim types from `@anthropic-ai/sdk/_shims/index`, which selects the manual types from `@anthropic-ai/sdk/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `@anthropic-ai/sdk/_shims/auto/types`.
41
+
42
+ `@anthropic-ai/sdk/_shims/manual-types` exports an empty namespace.
43
+ Manually importing `@anthropic-ai/sdk/shims/node` or `@anthropic-ai/sdk/shims/web` merges declarations into this empty namespace, so they get picked up by `@anthropic-ai/sdk/_shims/index`.
44
+
45
+ `@anthropic-ai/sdk/_shims/auto/types` exports web type definitions.
46
+ If the `node` export condition is set, the export map replaces it with `@anthropic-ai/sdk/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ export * from "../bun-runtime.js";
5
+ //# sourceMappingURL=runtime-bun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-bun.d.ts","sourceRoot":"","sources":["../../src/_shims/auto/runtime-bun.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
19
+ */
20
+ __exportStar(require("../bun-runtime.js"), exports);
21
+ //# sourceMappingURL=runtime-bun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-bun.js","sourceRoot":"","sources":["../../src/_shims/auto/runtime-bun.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,oDAA+B"}
@@ -0,0 +1,2 @@
1
+ export * from "../bun-runtime.mjs";
2
+ //# sourceMappingURL=runtime-bun.mjs.map