@puku-ai/sdk 1.0.0

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 (336) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +251 -0
  3. package/dist/index.cjs +7 -0
  4. package/dist/index.d.ts +23 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +26 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/vendor/_vendor/partial-json-parser/parser.d.ts +3 -0
  9. package/dist/vendor/_vendor/partial-json-parser/parser.d.ts.map +1 -0
  10. package/dist/vendor/_vendor/partial-json-parser/parser.js +223 -0
  11. package/dist/vendor/_vendor/partial-json-parser/parser.js.map +1 -0
  12. package/dist/vendor/api-promise.d.ts +3 -0
  13. package/dist/vendor/api-promise.d.ts.map +1 -0
  14. package/dist/vendor/api-promise.js +3 -0
  15. package/dist/vendor/api-promise.js.map +1 -0
  16. package/dist/vendor/client.d.ts +248 -0
  17. package/dist/vendor/client.d.ts.map +1 -0
  18. package/dist/vendor/client.js +567 -0
  19. package/dist/vendor/client.js.map +1 -0
  20. package/dist/vendor/core/api-promise.d.ts +49 -0
  21. package/dist/vendor/core/api-promise.d.ts.map +1 -0
  22. package/dist/vendor/core/api-promise.js +72 -0
  23. package/dist/vendor/core/api-promise.js.map +1 -0
  24. package/dist/vendor/core/error.d.ts +50 -0
  25. package/dist/vendor/core/error.d.ts.map +1 -0
  26. package/dist/vendor/core/error.js +109 -0
  27. package/dist/vendor/core/error.js.map +1 -0
  28. package/dist/vendor/core/pagination.d.ts +105 -0
  29. package/dist/vendor/core/pagination.d.ts.map +1 -0
  30. package/dist/vendor/core/pagination.js +188 -0
  31. package/dist/vendor/core/pagination.js.map +1 -0
  32. package/dist/vendor/core/resource.d.ts +6 -0
  33. package/dist/vendor/core/resource.d.ts.map +1 -0
  34. package/dist/vendor/core/resource.js +8 -0
  35. package/dist/vendor/core/resource.js.map +1 -0
  36. package/dist/vendor/core/streaming.d.ts +33 -0
  37. package/dist/vendor/core/streaming.d.ts.map +1 -0
  38. package/dist/vendor/core/streaming.js +288 -0
  39. package/dist/vendor/core/streaming.js.map +1 -0
  40. package/dist/vendor/core/uploads.d.ts +3 -0
  41. package/dist/vendor/core/uploads.d.ts.map +1 -0
  42. package/dist/vendor/core/uploads.js +2 -0
  43. package/dist/vendor/core/uploads.js.map +1 -0
  44. package/dist/vendor/error.d.ts +3 -0
  45. package/dist/vendor/error.d.ts.map +1 -0
  46. package/dist/vendor/error.js +3 -0
  47. package/dist/vendor/error.js.map +1 -0
  48. package/dist/vendor/helpers/beta/json-schema.d.ts +31 -0
  49. package/dist/vendor/helpers/beta/json-schema.d.ts.map +1 -0
  50. package/dist/vendor/helpers/beta/json-schema.js +52 -0
  51. package/dist/vendor/helpers/beta/json-schema.js.map +1 -0
  52. package/dist/vendor/helpers/beta/mcp.d.ts +303 -0
  53. package/dist/vendor/helpers/beta/mcp.d.ts.map +1 -0
  54. package/dist/vendor/helpers/beta/mcp.js +406 -0
  55. package/dist/vendor/helpers/beta/mcp.js.map +1 -0
  56. package/dist/vendor/helpers/beta/memory.d.ts +11 -0
  57. package/dist/vendor/helpers/beta/memory.d.ts.map +1 -0
  58. package/dist/vendor/helpers/beta/memory.js +15 -0
  59. package/dist/vendor/helpers/beta/memory.js.map +1 -0
  60. package/dist/vendor/helpers/beta/zod.d.ts +7 -0
  61. package/dist/vendor/helpers/beta/zod.d.ts.map +1 -0
  62. package/dist/vendor/helpers/beta/zod.js +15 -0
  63. package/dist/vendor/helpers/beta/zod.js.map +1 -0
  64. package/dist/vendor/helpers/index.d.ts +3 -0
  65. package/dist/vendor/helpers/index.d.ts.map +1 -0
  66. package/dist/vendor/helpers/index.js +3 -0
  67. package/dist/vendor/helpers/index.js.map +1 -0
  68. package/dist/vendor/helpers/json-schema.d.ts +18 -0
  69. package/dist/vendor/helpers/json-schema.d.ts.map +1 -0
  70. package/dist/vendor/helpers/json-schema.js +34 -0
  71. package/dist/vendor/helpers/json-schema.js.map +1 -0
  72. package/dist/vendor/helpers/zod.d.ts +13 -0
  73. package/dist/vendor/helpers/zod.d.ts.map +1 -0
  74. package/dist/vendor/helpers/zod.js +21 -0
  75. package/dist/vendor/helpers/zod.js.map +1 -0
  76. package/dist/vendor/index.d.ts +8 -0
  77. package/dist/vendor/index.d.ts.map +1 -0
  78. package/dist/vendor/index.js +8 -0
  79. package/dist/vendor/index.js.map +1 -0
  80. package/dist/vendor/internal/builtin-types.d.ts +73 -0
  81. package/dist/vendor/internal/builtin-types.d.ts.map +1 -0
  82. package/dist/vendor/internal/builtin-types.js +3 -0
  83. package/dist/vendor/internal/builtin-types.js.map +1 -0
  84. package/dist/vendor/internal/constants.d.ts +5 -0
  85. package/dist/vendor/internal/constants.d.ts.map +1 -0
  86. package/dist/vendor/internal/constants.js +15 -0
  87. package/dist/vendor/internal/constants.js.map +1 -0
  88. package/dist/vendor/internal/decoders/jsonl.d.ts +10 -0
  89. package/dist/vendor/internal/decoders/jsonl.d.ts.map +1 -0
  90. package/dist/vendor/internal/decoders/jsonl.js +37 -0
  91. package/dist/vendor/internal/decoders/jsonl.js.map +1 -0
  92. package/dist/vendor/internal/decoders/line.d.ts +17 -0
  93. package/dist/vendor/internal/decoders/line.d.ts.map +1 -0
  94. package/dist/vendor/internal/decoders/line.js +105 -0
  95. package/dist/vendor/internal/decoders/line.js.map +1 -0
  96. package/dist/vendor/internal/detect-platform.d.ts +15 -0
  97. package/dist/vendor/internal/detect-platform.d.ts.map +1 -0
  98. package/dist/vendor/internal/detect-platform.js +157 -0
  99. package/dist/vendor/internal/detect-platform.js.map +1 -0
  100. package/dist/vendor/internal/errors.d.ts +3 -0
  101. package/dist/vendor/internal/errors.d.ts.map +1 -0
  102. package/dist/vendor/internal/errors.js +36 -0
  103. package/dist/vendor/internal/errors.js.map +1 -0
  104. package/dist/vendor/internal/headers.d.ts +22 -0
  105. package/dist/vendor/internal/headers.d.ts.map +1 -0
  106. package/dist/vendor/internal/headers.js +74 -0
  107. package/dist/vendor/internal/headers.js.map +1 -0
  108. package/dist/vendor/internal/parse.d.ts +17 -0
  109. package/dist/vendor/internal/parse.d.ts.map +1 -0
  110. package/dist/vendor/internal/parse.js +56 -0
  111. package/dist/vendor/internal/parse.js.map +1 -0
  112. package/dist/vendor/internal/request-options.d.ts +77 -0
  113. package/dist/vendor/internal/request-options.d.ts.map +1 -0
  114. package/dist/vendor/internal/request-options.js +10 -0
  115. package/dist/vendor/internal/request-options.js.map +1 -0
  116. package/dist/vendor/internal/shim-types.d.ts +17 -0
  117. package/dist/vendor/internal/shim-types.d.ts.map +1 -0
  118. package/dist/vendor/internal/shim-types.js +3 -0
  119. package/dist/vendor/internal/shim-types.js.map +1 -0
  120. package/dist/vendor/internal/shims.d.ts +26 -0
  121. package/dist/vendor/internal/shims.d.ts.map +1 -0
  122. package/dist/vendor/internal/shims.js +85 -0
  123. package/dist/vendor/internal/shims.js.map +1 -0
  124. package/dist/vendor/internal/stream-utils.d.ts +8 -0
  125. package/dist/vendor/internal/stream-utils.d.ts.map +1 -0
  126. package/dist/vendor/internal/stream-utils.js +35 -0
  127. package/dist/vendor/internal/stream-utils.js.map +1 -0
  128. package/dist/vendor/internal/to-file.d.ts +45 -0
  129. package/dist/vendor/internal/to-file.d.ts.map +1 -0
  130. package/dist/vendor/internal/to-file.js +93 -0
  131. package/dist/vendor/internal/to-file.js.map +1 -0
  132. package/dist/vendor/internal/types.d.ts +69 -0
  133. package/dist/vendor/internal/types.d.ts.map +1 -0
  134. package/dist/vendor/internal/types.js +3 -0
  135. package/dist/vendor/internal/types.js.map +1 -0
  136. package/dist/vendor/internal/uploads.d.ts +42 -0
  137. package/dist/vendor/internal/uploads.d.ts.map +1 -0
  138. package/dist/vendor/internal/uploads.js +135 -0
  139. package/dist/vendor/internal/uploads.js.map +1 -0
  140. package/dist/vendor/internal/utils/base64.d.ts +3 -0
  141. package/dist/vendor/internal/utils/base64.d.ts.map +1 -0
  142. package/dist/vendor/internal/utils/base64.js +33 -0
  143. package/dist/vendor/internal/utils/base64.js.map +1 -0
  144. package/dist/vendor/internal/utils/bytes.d.ts +4 -0
  145. package/dist/vendor/internal/utils/bytes.d.ts.map +1 -0
  146. package/dist/vendor/internal/utils/bytes.js +26 -0
  147. package/dist/vendor/internal/utils/bytes.js.map +1 -0
  148. package/dist/vendor/internal/utils/env.d.ts +9 -0
  149. package/dist/vendor/internal/utils/env.d.ts.map +1 -0
  150. package/dist/vendor/internal/utils/env.js +18 -0
  151. package/dist/vendor/internal/utils/env.js.map +1 -0
  152. package/dist/vendor/internal/utils/log.d.ts +37 -0
  153. package/dist/vendor/internal/utils/log.d.ts.map +1 -0
  154. package/dist/vendor/internal/utils/log.js +80 -0
  155. package/dist/vendor/internal/utils/log.js.map +1 -0
  156. package/dist/vendor/internal/utils/path.d.ts +15 -0
  157. package/dist/vendor/internal/utils/path.d.ts.map +1 -0
  158. package/dist/vendor/internal/utils/path.js +74 -0
  159. package/dist/vendor/internal/utils/path.js.map +1 -0
  160. package/dist/vendor/internal/utils/query.d.ts +5 -0
  161. package/dist/vendor/internal/utils/query.d.ts.map +1 -0
  162. package/dist/vendor/internal/utils/query.js +20 -0
  163. package/dist/vendor/internal/utils/query.js.map +1 -0
  164. package/dist/vendor/internal/utils/sleep.d.ts +2 -0
  165. package/dist/vendor/internal/utils/sleep.d.ts.map +1 -0
  166. package/dist/vendor/internal/utils/sleep.js +3 -0
  167. package/dist/vendor/internal/utils/sleep.js.map +1 -0
  168. package/dist/vendor/internal/utils/uuid.d.ts +5 -0
  169. package/dist/vendor/internal/utils/uuid.d.ts.map +1 -0
  170. package/dist/vendor/internal/utils/uuid.js +15 -0
  171. package/dist/vendor/internal/utils/uuid.js.map +1 -0
  172. package/dist/vendor/internal/utils/values.d.ts +19 -0
  173. package/dist/vendor/internal/utils/values.d.ts.map +1 -0
  174. package/dist/vendor/internal/utils/values.js +100 -0
  175. package/dist/vendor/internal/utils/values.js.map +1 -0
  176. package/dist/vendor/internal/utils.d.ts +8 -0
  177. package/dist/vendor/internal/utils.d.ts.map +1 -0
  178. package/dist/vendor/internal/utils.js +9 -0
  179. package/dist/vendor/internal/utils.js.map +1 -0
  180. package/dist/vendor/lib/BetaMessageStream.d.ts +122 -0
  181. package/dist/vendor/lib/BetaMessageStream.d.ts.map +1 -0
  182. package/dist/vendor/lib/BetaMessageStream.js +624 -0
  183. package/dist/vendor/lib/BetaMessageStream.js.map +1 -0
  184. package/dist/vendor/lib/MessageStream.d.ts +121 -0
  185. package/dist/vendor/lib/MessageStream.d.ts.map +1 -0
  186. package/dist/vendor/lib/MessageStream.js +599 -0
  187. package/dist/vendor/lib/MessageStream.js.map +1 -0
  188. package/dist/vendor/lib/beta-parser.d.ts +37 -0
  189. package/dist/vendor/lib/beta-parser.d.ts.map +1 -0
  190. package/dist/vendor/lib/beta-parser.js +75 -0
  191. package/dist/vendor/lib/beta-parser.js.map +1 -0
  192. package/dist/vendor/lib/parser.d.ts +32 -0
  193. package/dist/vendor/lib/parser.d.ts.map +1 -0
  194. package/dist/vendor/lib/parser.js +62 -0
  195. package/dist/vendor/lib/parser.js.map +1 -0
  196. package/dist/vendor/lib/stainless-helper-header.d.ts +34 -0
  197. package/dist/vendor/lib/stainless-helper-header.d.ts.map +1 -0
  198. package/dist/vendor/lib/stainless-helper-header.js +63 -0
  199. package/dist/vendor/lib/stainless-helper-header.js.map +1 -0
  200. package/dist/vendor/lib/tools/BetaRunnableTool.d.ts +12 -0
  201. package/dist/vendor/lib/tools/BetaRunnableTool.d.ts.map +1 -0
  202. package/dist/vendor/lib/tools/BetaRunnableTool.js +2 -0
  203. package/dist/vendor/lib/tools/BetaRunnableTool.js.map +1 -0
  204. package/dist/vendor/lib/tools/BetaToolRunner.d.ts +136 -0
  205. package/dist/vendor/lib/tools/BetaToolRunner.d.ts.map +1 -0
  206. package/dist/vendor/lib/tools/BetaToolRunner.js +370 -0
  207. package/dist/vendor/lib/tools/BetaToolRunner.js.map +1 -0
  208. package/dist/vendor/lib/tools/CompactionControl.d.ts +25 -0
  209. package/dist/vendor/lib/tools/CompactionControl.d.ts.map +1 -0
  210. package/dist/vendor/lib/tools/CompactionControl.js +25 -0
  211. package/dist/vendor/lib/tools/CompactionControl.js.map +1 -0
  212. package/dist/vendor/lib/tools/ToolError.d.ts +33 -0
  213. package/dist/vendor/lib/tools/ToolError.d.ts.map +1 -0
  214. package/dist/vendor/lib/tools/ToolError.js +43 -0
  215. package/dist/vendor/lib/tools/ToolError.js.map +1 -0
  216. package/dist/vendor/lib/tools/ToolRunner.d.ts +132 -0
  217. package/dist/vendor/lib/tools/ToolRunner.d.ts.map +1 -0
  218. package/dist/vendor/lib/tools/ToolRunner.js +287 -0
  219. package/dist/vendor/lib/tools/ToolRunner.js.map +1 -0
  220. package/dist/vendor/lib/transform-json-schema.d.ts +3 -0
  221. package/dist/vendor/lib/transform-json-schema.d.ts.map +1 -0
  222. package/dist/vendor/lib/transform-json-schema.js +111 -0
  223. package/dist/vendor/lib/transform-json-schema.js.map +1 -0
  224. package/dist/vendor/pagination.d.ts +3 -0
  225. package/dist/vendor/pagination.d.ts.map +1 -0
  226. package/dist/vendor/pagination.js +3 -0
  227. package/dist/vendor/pagination.js.map +1 -0
  228. package/dist/vendor/resource.d.ts +3 -0
  229. package/dist/vendor/resource.d.ts.map +1 -0
  230. package/dist/vendor/resource.js +3 -0
  231. package/dist/vendor/resource.js.map +1 -0
  232. package/dist/vendor/resources/beta/beta.d.ts +66 -0
  233. package/dist/vendor/resources/beta/beta.d.ts.map +1 -0
  234. package/dist/vendor/resources/beta/beta.js +21 -0
  235. package/dist/vendor/resources/beta/beta.js.map +1 -0
  236. package/dist/vendor/resources/beta/files.d.ts +151 -0
  237. package/dist/vendor/resources/beta/files.d.ts.map +1 -0
  238. package/dist/vendor/resources/beta/files.js +120 -0
  239. package/dist/vendor/resources/beta/files.js.map +1 -0
  240. package/dist/vendor/resources/beta/index.d.ts +6 -0
  241. package/dist/vendor/resources/beta/index.d.ts.map +1 -0
  242. package/dist/vendor/resources/beta/index.js +7 -0
  243. package/dist/vendor/resources/beta/index.js.map +1 -0
  244. package/dist/vendor/resources/beta/messages/batches.d.ts +646 -0
  245. package/dist/vendor/resources/beta/messages/batches.d.ts.map +1 -0
  246. package/dist/vendor/resources/beta/messages/batches.js +200 -0
  247. package/dist/vendor/resources/beta/messages/batches.js.map +1 -0
  248. package/dist/vendor/resources/beta/messages/index.d.ts +4 -0
  249. package/dist/vendor/resources/beta/messages/index.d.ts.map +1 -0
  250. package/dist/vendor/resources/beta/messages/index.js +5 -0
  251. package/dist/vendor/resources/beta/messages/index.js.map +1 -0
  252. package/dist/vendor/resources/beta/messages/messages.d.ts +2966 -0
  253. package/dist/vendor/resources/beta/messages/messages.d.ts.map +1 -0
  254. package/dist/vendor/resources/beta/messages/messages.js +153 -0
  255. package/dist/vendor/resources/beta/messages/messages.js.map +1 -0
  256. package/dist/vendor/resources/beta/messages.d.ts +2 -0
  257. package/dist/vendor/resources/beta/messages.d.ts.map +1 -0
  258. package/dist/vendor/resources/beta/messages.js +3 -0
  259. package/dist/vendor/resources/beta/messages.js.map +1 -0
  260. package/dist/vendor/resources/beta/models.d.ts +208 -0
  261. package/dist/vendor/resources/beta/models.d.ts.map +1 -0
  262. package/dist/vendor/resources/beta/models.js +56 -0
  263. package/dist/vendor/resources/beta/models.js.map +1 -0
  264. package/dist/vendor/resources/beta/skills/index.d.ts +3 -0
  265. package/dist/vendor/resources/beta/skills/index.d.ts.map +1 -0
  266. package/dist/vendor/resources/beta/skills/index.js +4 -0
  267. package/dist/vendor/resources/beta/skills/index.js.map +1 -0
  268. package/dist/vendor/resources/beta/skills/skills.d.ts +249 -0
  269. package/dist/vendor/resources/beta/skills/skills.d.ts.map +1 -0
  270. package/dist/vendor/resources/beta/skills/skills.js +90 -0
  271. package/dist/vendor/resources/beta/skills/skills.js.map +1 -0
  272. package/dist/vendor/resources/beta/skills/versions.d.ts +257 -0
  273. package/dist/vendor/resources/beta/skills/versions.d.ts.map +1 -0
  274. package/dist/vendor/resources/beta/skills/versions.js +96 -0
  275. package/dist/vendor/resources/beta/skills/versions.js.map +1 -0
  276. package/dist/vendor/resources/beta/skills.d.ts +2 -0
  277. package/dist/vendor/resources/beta/skills.d.ts.map +1 -0
  278. package/dist/vendor/resources/beta/skills.js +3 -0
  279. package/dist/vendor/resources/beta/skills.js.map +1 -0
  280. package/dist/vendor/resources/beta.d.ts +2 -0
  281. package/dist/vendor/resources/beta.d.ts.map +1 -0
  282. package/dist/vendor/resources/beta.js +3 -0
  283. package/dist/vendor/resources/beta.js.map +1 -0
  284. package/dist/vendor/resources/completions.d.ts +182 -0
  285. package/dist/vendor/resources/completions.d.ts.map +1 -0
  286. package/dist/vendor/resources/completions.js +19 -0
  287. package/dist/vendor/resources/completions.js.map +1 -0
  288. package/dist/vendor/resources/index.d.ts +6 -0
  289. package/dist/vendor/resources/index.d.ts.map +1 -0
  290. package/dist/vendor/resources/index.js +7 -0
  291. package/dist/vendor/resources/index.js.map +1 -0
  292. package/dist/vendor/resources/messages/batches.d.ts +304 -0
  293. package/dist/vendor/resources/messages/batches.d.ts.map +1 -0
  294. package/dist/vendor/resources/messages/batches.js +149 -0
  295. package/dist/vendor/resources/messages/batches.js.map +1 -0
  296. package/dist/vendor/resources/messages/index.d.ts +3 -0
  297. package/dist/vendor/resources/messages/index.d.ts.map +1 -0
  298. package/dist/vendor/resources/messages/index.js +4 -0
  299. package/dist/vendor/resources/messages/index.js.map +1 -0
  300. package/dist/vendor/resources/messages/messages.d.ts +2258 -0
  301. package/dist/vendor/resources/messages/messages.d.ts.map +1 -0
  302. package/dist/vendor/resources/messages/messages.js +120 -0
  303. package/dist/vendor/resources/messages/messages.js.map +1 -0
  304. package/dist/vendor/resources/messages.d.ts +2 -0
  305. package/dist/vendor/resources/messages.d.ts.map +1 -0
  306. package/dist/vendor/resources/messages.js +3 -0
  307. package/dist/vendor/resources/messages.js.map +1 -0
  308. package/dist/vendor/resources/models.d.ts +193 -0
  309. package/dist/vendor/resources/models.d.ts.map +1 -0
  310. package/dist/vendor/resources/models.js +41 -0
  311. package/dist/vendor/resources/models.js.map +1 -0
  312. package/dist/vendor/resources/shared.d.ts +44 -0
  313. package/dist/vendor/resources/shared.d.ts.map +1 -0
  314. package/dist/vendor/resources/shared.js +3 -0
  315. package/dist/vendor/resources/shared.js.map +1 -0
  316. package/dist/vendor/resources/top-level.d.ts +2 -0
  317. package/dist/vendor/resources/top-level.d.ts.map +1 -0
  318. package/dist/vendor/resources/top-level.js +3 -0
  319. package/dist/vendor/resources/top-level.js.map +1 -0
  320. package/dist/vendor/streaming.d.ts +3 -0
  321. package/dist/vendor/streaming.d.ts.map +1 -0
  322. package/dist/vendor/streaming.js +3 -0
  323. package/dist/vendor/streaming.js.map +1 -0
  324. package/dist/vendor/tools/memory/node.d.ts +18 -0
  325. package/dist/vendor/tools/memory/node.d.ts.map +1 -0
  326. package/dist/vendor/tools/memory/node.js +320 -0
  327. package/dist/vendor/tools/memory/node.js.map +1 -0
  328. package/dist/vendor/uploads.d.ts +3 -0
  329. package/dist/vendor/uploads.d.ts.map +1 -0
  330. package/dist/vendor/uploads.js +3 -0
  331. package/dist/vendor/uploads.js.map +1 -0
  332. package/dist/vendor/version.d.ts +2 -0
  333. package/dist/vendor/version.d.ts.map +1 -0
  334. package/dist/vendor/version.js +2 -0
  335. package/dist/vendor/version.js.map +1 -0
  336. package/package.json +66 -0
@@ -0,0 +1,567 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { uuid4 } from './internal/utils/uuid.js';
3
+ import { validatePositiveInteger, isAbsoluteURL, safeJSON } from './internal/utils/values.js';
4
+ import { sleep } from './internal/utils/sleep.js';
5
+ import { castToError, isAbortError } from './internal/errors.js';
6
+ import { getPlatformHeaders } from './internal/detect-platform.js';
7
+ import * as Shims from './internal/shims.js';
8
+ import * as Opts from './internal/request-options.js';
9
+ import { stringifyQuery } from './internal/utils/query.js';
10
+ import { VERSION } from './version.js';
11
+ import * as Errors from './core/error.js';
12
+ import * as Pagination from './core/pagination.js';
13
+ import * as Uploads from './core/uploads.js';
14
+ import * as API from './resources/index.js';
15
+ import { APIPromise } from './core/api-promise.js';
16
+ import { Completions, } from './resources/completions.js';
17
+ import { Models, } from './resources/models.js';
18
+ import { Beta, } from './resources/beta/beta.js';
19
+ import { Messages, } from './resources/messages/messages.js';
20
+ import { isRunningInBrowser } from './internal/detect-platform.js';
21
+ import { buildHeaders } from './internal/headers.js';
22
+ import { readEnv } from './internal/utils/env.js';
23
+ import { formatRequestDetails, loggerFor, parseLogLevel, } from './internal/utils/log.js';
24
+ import { isEmptyObj } from './internal/utils/values.js';
25
+ export const HUMAN_PROMPT = '\\n\\nHuman:';
26
+ export const AI_PROMPT = '\\n\\nAssistant:';
27
+ /**
28
+ * Base class for Anthropic API clients.
29
+ */
30
+ export class BaseAnthropic {
31
+ apiKey;
32
+ baseURL;
33
+ maxRetries;
34
+ timeout;
35
+ logger;
36
+ logLevel;
37
+ fetchOptions;
38
+ fetch;
39
+ #encoder;
40
+ idempotencyHeader;
41
+ _options;
42
+ /**
43
+ * API Client for interfacing with the Puku AI gateway.
44
+ *
45
+ * @param {string | null | undefined} [opts.apiKey=process.env['PUKU_API_KEY'] ?? null]
46
+ * @param {string} [opts.baseURL=process.env['PUKU_BASE_URL']] - Override the base URL for the API. Required.
47
+ * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
48
+ * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
49
+ * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
50
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
51
+ * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
52
+ * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
53
+ * @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
54
+ */
55
+ constructor({ baseURL = readEnv('PUKU_BASE_URL'), apiKey = readEnv('PUKU_API_KEY') ?? null, ...opts } = {}) {
56
+ if (!baseURL) {
57
+ throw new Errors.AnthropicError("Missing baseURL: pass `baseURL` to the constructor or set the PUKU_BASE_URL environment variable.");
58
+ }
59
+ const options = {
60
+ apiKey,
61
+ ...opts,
62
+ baseURL,
63
+ };
64
+ if (!options.dangerouslyAllowBrowser && isRunningInBrowser()) {
65
+ throw new Errors.AnthropicError("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Anthropic({ apiKey, dangerouslyAllowBrowser: true });\n");
66
+ }
67
+ this.baseURL = options.baseURL;
68
+ // Normalize: strip a trailing `/v1` so the SDK can append Anthropic-style
69
+ // paths (`/v1/messages`, etc.) without doubling the prefix.
70
+ if (this.baseURL.endsWith("/v1")) {
71
+ this.baseURL = this.baseURL.slice(0, -3);
72
+ }
73
+ this.timeout = options.timeout ?? BaseAnthropic.DEFAULT_TIMEOUT /* 10 minutes */;
74
+ this.logger = options.logger ?? console;
75
+ const defaultLogLevel = 'warn';
76
+ // Set default logLevel early so that we can log a warning in parseLogLevel.
77
+ this.logLevel = defaultLogLevel;
78
+ this.logLevel =
79
+ parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ??
80
+ parseLogLevel(readEnv('ANTHROPIC_LOG'), "process.env['ANTHROPIC_LOG']", this) ??
81
+ defaultLogLevel;
82
+ this.fetchOptions = options.fetchOptions;
83
+ this.maxRetries = options.maxRetries ?? 2;
84
+ this.fetch = options.fetch ?? Shims.getDefaultFetch();
85
+ this.#encoder = Opts.FallbackEncoder;
86
+ this._options = options;
87
+ this.apiKey = typeof apiKey === 'string' ? apiKey : null;
88
+ }
89
+ /**
90
+ * Create a new client instance re-using the same options given to the current client with optional overriding.
91
+ */
92
+ withOptions(options) {
93
+ const client = new this.constructor({
94
+ ...this._options,
95
+ baseURL: this.baseURL,
96
+ maxRetries: this.maxRetries,
97
+ timeout: this.timeout,
98
+ logger: this.logger,
99
+ logLevel: this.logLevel,
100
+ fetch: this.fetch,
101
+ fetchOptions: this.fetchOptions,
102
+ apiKey: this.apiKey,
103
+ ...options,
104
+ });
105
+ return client;
106
+ }
107
+ /**
108
+ * Check whether the base URL is set to its default.
109
+ */
110
+ #baseURLOverridden() {
111
+ // baseURL is required at construction time, so it's always overridden
112
+ // relative to any built-in default.
113
+ return true;
114
+ }
115
+ defaultQuery() {
116
+ return this._options.defaultQuery;
117
+ }
118
+ validateHeaders({ values, nulls }) {
119
+ if (values.get('x-api-key')) {
120
+ return;
121
+ }
122
+ if (this.apiKey && values.get('x-api-key')) {
123
+ return;
124
+ }
125
+ if (nulls.has('x-api-key')) {
126
+ return;
127
+ }
128
+ throw new Error('Could not resolve authentication method. Expected apiKey to be set, or for the "X-Api-Key" header to be explicitly omitted');
129
+ }
130
+ async authHeaders(opts) {
131
+ return buildHeaders([await this.apiKeyAuth(opts)]);
132
+ }
133
+ async apiKeyAuth(opts) {
134
+ if (this.apiKey == null) {
135
+ return undefined;
136
+ }
137
+ return buildHeaders([{ 'X-Api-Key': this.apiKey }]);
138
+ }
139
+ /**
140
+ * Basic re-implementation of `qs.stringify` for primitive types.
141
+ */
142
+ stringifyQuery(query) {
143
+ return stringifyQuery(query);
144
+ }
145
+ getUserAgent() {
146
+ return `${this.constructor.name}/JS ${VERSION}`;
147
+ }
148
+ defaultIdempotencyKey() {
149
+ return `stainless-node-retry-${uuid4()}`;
150
+ }
151
+ makeStatusError(status, error, message, headers) {
152
+ return Errors.APIError.generate(status, error, message, headers);
153
+ }
154
+ buildURL(path, query, defaultBaseURL) {
155
+ const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL;
156
+ const url = isAbsoluteURL(path) ?
157
+ new URL(path)
158
+ : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
159
+ const defaultQuery = this.defaultQuery();
160
+ const pathQuery = Object.fromEntries(url.searchParams);
161
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
162
+ query = { ...pathQuery, ...defaultQuery, ...query };
163
+ }
164
+ if (typeof query === 'object' && query && !Array.isArray(query)) {
165
+ url.search = this.stringifyQuery(query);
166
+ }
167
+ return url.toString();
168
+ }
169
+ _calculateNonstreamingTimeout(maxTokens) {
170
+ const defaultTimeout = 10 * 60;
171
+ const expectedTimeout = (60 * 60 * maxTokens) / 128_000;
172
+ if (expectedTimeout > defaultTimeout) {
173
+ throw new Errors.AnthropicError('Streaming is required for operations that may take longer than 10 minutes. ' +
174
+ 'See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details');
175
+ }
176
+ return defaultTimeout * 1000;
177
+ }
178
+ /**
179
+ * Used as a callback for mutating the given `FinalRequestOptions` object.
180
+ */
181
+ async prepareOptions(options) { }
182
+ /**
183
+ * Used as a callback for mutating the given `RequestInit` object.
184
+ *
185
+ * This is useful for cases where you want to add certain headers based off of
186
+ * the request properties, e.g. `method` or `url`.
187
+ */
188
+ async prepareRequest(request, { url, options }) { }
189
+ get(path, opts) {
190
+ return this.methodRequest('get', path, opts);
191
+ }
192
+ post(path, opts) {
193
+ return this.methodRequest('post', path, opts);
194
+ }
195
+ patch(path, opts) {
196
+ return this.methodRequest('patch', path, opts);
197
+ }
198
+ put(path, opts) {
199
+ return this.methodRequest('put', path, opts);
200
+ }
201
+ delete(path, opts) {
202
+ return this.methodRequest('delete', path, opts);
203
+ }
204
+ methodRequest(method, path, opts) {
205
+ return this.request(Promise.resolve(opts).then((opts) => {
206
+ return { method, path, ...opts };
207
+ }));
208
+ }
209
+ request(options, remainingRetries = null) {
210
+ return new APIPromise(this, this.makeRequest(options, remainingRetries, undefined));
211
+ }
212
+ async makeRequest(optionsInput, retriesRemaining, retryOfRequestLogID) {
213
+ const options = await optionsInput;
214
+ const maxRetries = options.maxRetries ?? this.maxRetries;
215
+ if (retriesRemaining == null) {
216
+ retriesRemaining = maxRetries;
217
+ }
218
+ await this.prepareOptions(options);
219
+ const { req, url, timeout } = await this.buildRequest(options, {
220
+ retryCount: maxRetries - retriesRemaining,
221
+ });
222
+ await this.prepareRequest(req, { url, options });
223
+ /** Not an API request ID, just for correlating local log entries. */
224
+ const requestLogID = 'log_' + ((Math.random() * (1 << 24)) | 0).toString(16).padStart(6, '0');
225
+ const retryLogStr = retryOfRequestLogID === undefined ? '' : `, retryOf: ${retryOfRequestLogID}`;
226
+ const startTime = Date.now();
227
+ loggerFor(this).debug(`[${requestLogID}] sending request`, formatRequestDetails({
228
+ retryOfRequestLogID,
229
+ method: options.method,
230
+ url,
231
+ options,
232
+ headers: req.headers,
233
+ }));
234
+ if (options.signal?.aborted) {
235
+ throw new Errors.APIUserAbortError();
236
+ }
237
+ const controller = new AbortController();
238
+ const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
239
+ const headersTime = Date.now();
240
+ if (response instanceof globalThis.Error) {
241
+ const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
242
+ if (options.signal?.aborted) {
243
+ throw new Errors.APIUserAbortError();
244
+ }
245
+ // detect native connection timeout errors
246
+ // deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)"
247
+ // undici throws "TypeError: fetch failed" with cause "ConnectTimeoutError: Connect Timeout Error (attempted address: example:443, timeout: 1ms)"
248
+ // others do not provide enough information to distinguish timeouts from other connection errors
249
+ const isTimeout = isAbortError(response) ||
250
+ /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : ''));
251
+ if (retriesRemaining) {
252
+ loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`);
253
+ loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, formatRequestDetails({
254
+ retryOfRequestLogID,
255
+ url,
256
+ durationMs: headersTime - startTime,
257
+ message: response.message,
258
+ }));
259
+ return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID);
260
+ }
261
+ loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`);
262
+ loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, formatRequestDetails({
263
+ retryOfRequestLogID,
264
+ url,
265
+ durationMs: headersTime - startTime,
266
+ message: response.message,
267
+ }));
268
+ if (isTimeout) {
269
+ throw new Errors.APIConnectionTimeoutError();
270
+ }
271
+ throw new Errors.APIConnectionError({ cause: response });
272
+ }
273
+ const specialHeaders = [...response.headers.entries()]
274
+ .filter(([name]) => name === 'request-id')
275
+ .map(([name, value]) => ', ' + name + ': ' + JSON.stringify(value))
276
+ .join('');
277
+ const responseInfo = `[${requestLogID}${retryLogStr}${specialHeaders}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
278
+ if (!response.ok) {
279
+ const shouldRetry = await this.shouldRetry(response);
280
+ if (retriesRemaining && shouldRetry) {
281
+ const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
282
+ // We don't need the body of this response.
283
+ await Shims.CancelReadableStream(response.body);
284
+ loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
285
+ loggerFor(this).debug(`[${requestLogID}] response error (${retryMessage})`, formatRequestDetails({
286
+ retryOfRequestLogID,
287
+ url: response.url,
288
+ status: response.status,
289
+ headers: response.headers,
290
+ durationMs: headersTime - startTime,
291
+ }));
292
+ return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, response.headers);
293
+ }
294
+ const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`;
295
+ loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
296
+ const errText = await response.text().catch((err) => castToError(err).message);
297
+ const errJSON = safeJSON(errText);
298
+ const errMessage = errJSON ? undefined : errText;
299
+ loggerFor(this).debug(`[${requestLogID}] response error (${retryMessage})`, formatRequestDetails({
300
+ retryOfRequestLogID,
301
+ url: response.url,
302
+ status: response.status,
303
+ headers: response.headers,
304
+ message: errMessage,
305
+ durationMs: Date.now() - startTime,
306
+ }));
307
+ const err = this.makeStatusError(response.status, errJSON, errMessage, response.headers);
308
+ throw err;
309
+ }
310
+ loggerFor(this).info(responseInfo);
311
+ loggerFor(this).debug(`[${requestLogID}] response start`, formatRequestDetails({
312
+ retryOfRequestLogID,
313
+ url: response.url,
314
+ status: response.status,
315
+ headers: response.headers,
316
+ durationMs: headersTime - startTime,
317
+ }));
318
+ return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
319
+ }
320
+ getAPIList(path, Page, opts) {
321
+ return this.requestAPIList(Page, opts && 'then' in opts ?
322
+ opts.then((opts) => ({ method: 'get', path, ...opts }))
323
+ : { method: 'get', path, ...opts });
324
+ }
325
+ requestAPIList(Page, options) {
326
+ const request = this.makeRequest(options, null, undefined);
327
+ return new Pagination.PagePromise(this, request, Page);
328
+ }
329
+ async fetchWithTimeout(url, init, ms, controller) {
330
+ const { signal, method, ...options } = init || {};
331
+ // Avoid creating a closure over `this`, `init`, or `options` to prevent memory leaks.
332
+ // An arrow function like `() => controller.abort()` captures the surrounding scope,
333
+ // which includes the request body and other large objects. When the user passes a
334
+ // long-lived AbortSignal, the listener prevents those objects from being GC'd for
335
+ // the lifetime of the signal. Using `.bind()` only retains a reference to the
336
+ // controller itself.
337
+ const abort = this._makeAbort(controller);
338
+ if (signal)
339
+ signal.addEventListener('abort', abort, { once: true });
340
+ const timeout = setTimeout(abort, ms);
341
+ const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) ||
342
+ (typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body);
343
+ const fetchOptions = {
344
+ signal: controller.signal,
345
+ ...(isReadableBody ? { duplex: 'half' } : {}),
346
+ method: 'GET',
347
+ ...options,
348
+ };
349
+ if (method) {
350
+ // Custom methods like 'patch' need to be uppercased
351
+ // See https://github.com/nodejs/undici/issues/2294
352
+ fetchOptions.method = method.toUpperCase();
353
+ }
354
+ try {
355
+ // use undefined this binding; fetch errors if bound to something else in browser/cloudflare
356
+ return await this.fetch.call(undefined, url, fetchOptions);
357
+ }
358
+ finally {
359
+ clearTimeout(timeout);
360
+ }
361
+ }
362
+ async shouldRetry(response) {
363
+ // Note this is not a standard header.
364
+ const shouldRetryHeader = response.headers.get('x-should-retry');
365
+ // If the server explicitly says whether or not to retry, obey.
366
+ if (shouldRetryHeader === 'true')
367
+ return true;
368
+ if (shouldRetryHeader === 'false')
369
+ return false;
370
+ // Retry on request timeouts.
371
+ if (response.status === 408)
372
+ return true;
373
+ // Retry on lock timeouts.
374
+ if (response.status === 409)
375
+ return true;
376
+ // Retry on rate limits.
377
+ if (response.status === 429)
378
+ return true;
379
+ // Retry internal errors.
380
+ if (response.status >= 500)
381
+ return true;
382
+ return false;
383
+ }
384
+ async retryRequest(options, retriesRemaining, requestLogID, responseHeaders) {
385
+ let timeoutMillis;
386
+ // Note the `retry-after-ms` header may not be standard, but is a good idea and we'd like proactive support for it.
387
+ const retryAfterMillisHeader = responseHeaders?.get('retry-after-ms');
388
+ if (retryAfterMillisHeader) {
389
+ const timeoutMs = parseFloat(retryAfterMillisHeader);
390
+ if (!Number.isNaN(timeoutMs)) {
391
+ timeoutMillis = timeoutMs;
392
+ }
393
+ }
394
+ // About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
395
+ const retryAfterHeader = responseHeaders?.get('retry-after');
396
+ if (retryAfterHeader && !timeoutMillis) {
397
+ const timeoutSeconds = parseFloat(retryAfterHeader);
398
+ if (!Number.isNaN(timeoutSeconds)) {
399
+ timeoutMillis = timeoutSeconds * 1000;
400
+ }
401
+ else {
402
+ timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
403
+ }
404
+ }
405
+ // If the API asks us to wait a certain amount of time, just do what it
406
+ // says, but otherwise calculate a default
407
+ if (timeoutMillis === undefined) {
408
+ const maxRetries = options.maxRetries ?? this.maxRetries;
409
+ timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
410
+ }
411
+ await sleep(timeoutMillis);
412
+ return this.makeRequest(options, retriesRemaining - 1, requestLogID);
413
+ }
414
+ calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries) {
415
+ const initialRetryDelay = 0.5;
416
+ const maxRetryDelay = 8.0;
417
+ const numRetries = maxRetries - retriesRemaining;
418
+ // Apply exponential backoff, but not more than the max.
419
+ const sleepSeconds = Math.min(initialRetryDelay * Math.pow(2, numRetries), maxRetryDelay);
420
+ // Apply some jitter, take up to at most 25 percent of the retry time.
421
+ const jitter = 1 - Math.random() * 0.25;
422
+ return sleepSeconds * jitter * 1000;
423
+ }
424
+ calculateNonstreamingTimeout(maxTokens, maxNonstreamingTokens) {
425
+ const maxTime = 60 * 60 * 1000; // 60 minutes
426
+ const defaultTime = 60 * 10 * 1000; // 10 minutes
427
+ const expectedTime = (maxTime * maxTokens) / 128000;
428
+ if (expectedTime > defaultTime || (maxNonstreamingTokens != null && maxTokens > maxNonstreamingTokens)) {
429
+ throw new Errors.AnthropicError('Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details');
430
+ }
431
+ return defaultTime;
432
+ }
433
+ async buildRequest(inputOptions, { retryCount = 0 } = {}) {
434
+ const options = { ...inputOptions };
435
+ const { method, path, query, defaultBaseURL } = options;
436
+ const url = this.buildURL(path, query, defaultBaseURL);
437
+ if ('timeout' in options)
438
+ validatePositiveInteger('timeout', options.timeout);
439
+ options.timeout = options.timeout ?? this.timeout;
440
+ const { bodyHeaders, body } = this.buildBody({ options });
441
+ const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
442
+ const req = {
443
+ method,
444
+ headers: reqHeaders,
445
+ ...(options.signal && { signal: options.signal }),
446
+ ...(globalThis.ReadableStream &&
447
+ body instanceof globalThis.ReadableStream && { duplex: 'half' }),
448
+ ...(body && { body }),
449
+ ...(this.fetchOptions ?? {}),
450
+ ...(options.fetchOptions ?? {}),
451
+ };
452
+ return { req, url, timeout: options.timeout };
453
+ }
454
+ async buildHeaders({ options, method, bodyHeaders, retryCount, }) {
455
+ let idempotencyHeaders = {};
456
+ if (this.idempotencyHeader && method !== 'get') {
457
+ if (!options.idempotencyKey)
458
+ options.idempotencyKey = this.defaultIdempotencyKey();
459
+ idempotencyHeaders[this.idempotencyHeader] = options.idempotencyKey;
460
+ }
461
+ const headers = buildHeaders([
462
+ idempotencyHeaders,
463
+ {
464
+ Accept: 'application/json',
465
+ 'User-Agent': this.getUserAgent(),
466
+ 'X-Stainless-Retry-Count': String(retryCount),
467
+ ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}),
468
+ ...getPlatformHeaders(),
469
+ ...(this._options.dangerouslyAllowBrowser ?
470
+ { 'anthropic-dangerous-direct-browser-access': 'true' }
471
+ : undefined),
472
+ 'anthropic-version': '2023-06-01',
473
+ },
474
+ await this.authHeaders(options),
475
+ this._options.defaultHeaders,
476
+ bodyHeaders,
477
+ options.headers,
478
+ ]);
479
+ this.validateHeaders(headers);
480
+ return headers.values;
481
+ }
482
+ _makeAbort(controller) {
483
+ // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
484
+ // would capture all request options, and cause a memory leak.
485
+ return () => controller.abort();
486
+ }
487
+ buildBody({ options: { body, headers: rawHeaders } }) {
488
+ if (!body) {
489
+ return { bodyHeaders: undefined, body: undefined };
490
+ }
491
+ const headers = buildHeaders([rawHeaders]);
492
+ if (
493
+ // Pass raw type verbatim
494
+ ArrayBuffer.isView(body) ||
495
+ body instanceof ArrayBuffer ||
496
+ body instanceof DataView ||
497
+ (typeof body === 'string' &&
498
+ // Preserve legacy string encoding behavior for now
499
+ headers.values.has('content-type')) ||
500
+ // `Blob` is superset of `File`
501
+ (globalThis.Blob && body instanceof globalThis.Blob) ||
502
+ // `FormData` -> `multipart/form-data`
503
+ body instanceof FormData ||
504
+ // `URLSearchParams` -> `application/x-www-form-urlencoded`
505
+ body instanceof URLSearchParams ||
506
+ // Send chunked stream (each chunk has own `length`)
507
+ (globalThis.ReadableStream && body instanceof globalThis.ReadableStream)) {
508
+ return { bodyHeaders: undefined, body: body };
509
+ }
510
+ else if (typeof body === 'object' &&
511
+ (Symbol.asyncIterator in body ||
512
+ (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
513
+ return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body) };
514
+ }
515
+ else if (typeof body === 'object' &&
516
+ headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
517
+ return {
518
+ bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
519
+ body: this.stringifyQuery(body),
520
+ };
521
+ }
522
+ else {
523
+ return this.#encoder({ body, headers });
524
+ }
525
+ }
526
+ static Anthropic = this;
527
+ static PukuAI = this;
528
+ static HUMAN_PROMPT = HUMAN_PROMPT;
529
+ static AI_PROMPT = AI_PROMPT;
530
+ static DEFAULT_TIMEOUT = 600000; // 10 minutes
531
+ static AnthropicError = Errors.AnthropicError;
532
+ static APIError = Errors.APIError;
533
+ static APIConnectionError = Errors.APIConnectionError;
534
+ static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
535
+ static APIUserAbortError = Errors.APIUserAbortError;
536
+ static NotFoundError = Errors.NotFoundError;
537
+ static ConflictError = Errors.ConflictError;
538
+ static RateLimitError = Errors.RateLimitError;
539
+ static BadRequestError = Errors.BadRequestError;
540
+ static AuthenticationError = Errors.AuthenticationError;
541
+ static InternalServerError = Errors.InternalServerError;
542
+ static PermissionDeniedError = Errors.PermissionDeniedError;
543
+ static UnprocessableEntityError = Errors.UnprocessableEntityError;
544
+ static toFile = Uploads.toFile;
545
+ }
546
+ /**
547
+ * API Client for interfacing with the Anthropic API.
548
+ *
549
+ * Public-facing name: `PukuAI`. The vendored SDK originally declared this
550
+ * as `Anthropic`; renamed to `PukuAI` so consumers of @puku-ai/sdk can do
551
+ * `import PukuAI from "@puku-ai/sdk"`. `Anthropic` is kept as a static
552
+ * property pointing to the same class for source-compat.
553
+ */
554
+ export class PukuAI extends BaseAnthropic {
555
+ completions = new API.Completions(this);
556
+ messages = new API.Messages(this);
557
+ models = new API.Models(this);
558
+ beta = new API.Beta(this);
559
+ }
560
+ PukuAI.Completions = Completions;
561
+ PukuAI.Messages = Messages;
562
+ PukuAI.Models = Models;
563
+ PukuAI.Beta = Beta;
564
+ // Backwards-compat: previous versions of this SDK exported the class as
565
+ // `Anthropic`. We expose it under both names.
566
+ PukuAI.Anthropic = PukuAI;
567
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/vendor/client.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAItF,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,IAAI,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AASnD,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,GAA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AED,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;AACjC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC3B,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;AACvB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;AAEnB,wEAAwE;AACxE,+CAA+C;AAC/C,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { type BaseAnthropic } from '../client.js';
2
+ import { type PromiseOrValue } from '../internal/types.js';
3
+ import { type APIResponseProps, type WithRequestID } from '../internal/parse.js';
4
+ /**
5
+ * A subclass of `Promise` providing additional helper methods
6
+ * for interacting with the SDK.
7
+ */
8
+ export declare class APIPromise<T> extends Promise<WithRequestID<T>> {
9
+ #private;
10
+ private responsePromise;
11
+ private parseResponse;
12
+ private parsedPromise;
13
+ constructor(client: BaseAnthropic, responsePromise: Promise<APIResponseProps>, parseResponse?: (client: BaseAnthropic, props: APIResponseProps) => PromiseOrValue<WithRequestID<T>>);
14
+ _thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
15
+ /**
16
+ * Gets the raw `Response` instance instead of parsing the response
17
+ * data.
18
+ *
19
+ * If you want to parse the response body but still get the `Response`
20
+ * instance, you can use {@link withResponse()}.
21
+ *
22
+ * 👋 Getting the wrong TypeScript type for `Response`?
23
+ * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
24
+ * to your `tsconfig.json`.
25
+ */
26
+ asResponse(): Promise<Response>;
27
+ /**
28
+ * Gets the parsed response data, the raw `Response` instance and the ID of the request,
29
+ * returned via the `request-id` header which is useful for debugging requests and resporting
30
+ * issues to Anthropic.
31
+ *
32
+ * If you just want to get the raw `Response` instance without parsing it,
33
+ * you can use {@link asResponse()}.
34
+ *
35
+ * 👋 Getting the wrong TypeScript type for `Response`?
36
+ * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
37
+ * to your `tsconfig.json`.
38
+ */
39
+ withResponse(): Promise<{
40
+ data: T;
41
+ response: Response;
42
+ request_id: string | null | undefined;
43
+ }>;
44
+ private parse;
45
+ then<TResult1 = WithRequestID<T>, TResult2 = never>(onfulfilled?: ((value: WithRequestID<T>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
46
+ catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<WithRequestID<T> | TResult>;
47
+ finally(onfinally?: (() => void) | undefined | null): Promise<WithRequestID<T>>;
48
+ }
49
+ //# sourceMappingURL=api-promise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-promise.d.ts","sourceRoot":"","sources":["../../../src/vendor/core/api-promise.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAGnB,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,qBAAa,UAAU,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;;IAMxD,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,aAAa;IANvB,OAAO,CAAC,aAAa,CAAwC;gBAI3D,MAAM,EAAE,aAAa,EACb,eAAe,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAC1C,aAAa,GAAE,CACrB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,gBAAgB,KACpB,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAwB;IAW9D,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,KAAK,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAMjF;;;;;;;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