@ainative/cody-sdk 0.1.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 (770) hide show
  1. package/.github/logo.svg +3 -0
  2. package/CHANGELOG.md +2345 -0
  3. package/LICENSE +8 -0
  4. package/README.md +45 -0
  5. package/_vendor/partial-json-parser/parser.d.mts +3 -0
  6. package/_vendor/partial-json-parser/parser.d.mts.map +1 -0
  7. package/_vendor/partial-json-parser/parser.d.ts +3 -0
  8. package/_vendor/partial-json-parser/parser.d.ts.map +1 -0
  9. package/_vendor/partial-json-parser/parser.js +226 -0
  10. package/_vendor/partial-json-parser/parser.js.map +1 -0
  11. package/_vendor/partial-json-parser/parser.mjs +223 -0
  12. package/_vendor/partial-json-parser/parser.mjs.map +1 -0
  13. package/ainative.d.mts +32 -0
  14. package/ainative.d.mts.map +1 -0
  15. package/ainative.d.ts +32 -0
  16. package/ainative.d.ts.map +1 -0
  17. package/ainative.js +78 -0
  18. package/ainative.js.map +1 -0
  19. package/ainative.mjs +71 -0
  20. package/ainative.mjs.map +1 -0
  21. package/api-promise.d.mts +2 -0
  22. package/api-promise.d.mts.map +1 -0
  23. package/api-promise.d.ts +2 -0
  24. package/api-promise.d.ts.map +1 -0
  25. package/api-promise.js +6 -0
  26. package/api-promise.js.map +1 -0
  27. package/api-promise.mjs +2 -0
  28. package/api-promise.mjs.map +1 -0
  29. package/bin/cli +53 -0
  30. package/bin/migration-config.json +82 -0
  31. package/client.d.mts +247 -0
  32. package/client.d.mts.map +1 -0
  33. package/client.d.ts +247 -0
  34. package/client.d.ts.map +1 -0
  35. package/client.js +567 -0
  36. package/client.js.map +1 -0
  37. package/client.mjs +562 -0
  38. package/client.mjs.map +1 -0
  39. package/core/api-promise.d.mts +49 -0
  40. package/core/api-promise.d.mts.map +1 -0
  41. package/core/api-promise.d.ts +49 -0
  42. package/core/api-promise.d.ts.map +1 -0
  43. package/core/api-promise.js +76 -0
  44. package/core/api-promise.js.map +1 -0
  45. package/core/api-promise.mjs +72 -0
  46. package/core/api-promise.mjs.map +1 -0
  47. package/core/error.d.mts +50 -0
  48. package/core/error.d.mts.map +1 -0
  49. package/core/error.d.ts +50 -0
  50. package/core/error.d.ts.map +1 -0
  51. package/core/error.js +116 -0
  52. package/core/error.js.map +1 -0
  53. package/core/error.mjs +100 -0
  54. package/core/error.mjs.map +1 -0
  55. package/core/pagination.d.mts +105 -0
  56. package/core/pagination.d.mts.map +1 -0
  57. package/core/pagination.d.ts +105 -0
  58. package/core/pagination.d.ts.map +1 -0
  59. package/core/pagination.js +185 -0
  60. package/core/pagination.js.map +1 -0
  61. package/core/pagination.mjs +177 -0
  62. package/core/pagination.mjs.map +1 -0
  63. package/core/resource.d.mts +6 -0
  64. package/core/resource.d.mts.map +1 -0
  65. package/core/resource.d.ts +6 -0
  66. package/core/resource.d.ts.map +1 -0
  67. package/core/resource.js +11 -0
  68. package/core/resource.js.map +1 -0
  69. package/core/resource.mjs +7 -0
  70. package/core/resource.mjs.map +1 -0
  71. package/core/streaming.d.mts +33 -0
  72. package/core/streaming.d.mts.map +1 -0
  73. package/core/streaming.d.ts +33 -0
  74. package/core/streaming.d.ts.map +1 -0
  75. package/core/streaming.js +290 -0
  76. package/core/streaming.js.map +1 -0
  77. package/core/streaming.mjs +285 -0
  78. package/core/streaming.mjs.map +1 -0
  79. package/core/uploads.d.mts +3 -0
  80. package/core/uploads.d.mts.map +1 -0
  81. package/core/uploads.d.ts +3 -0
  82. package/core/uploads.d.ts.map +1 -0
  83. package/core/uploads.js +6 -0
  84. package/core/uploads.js.map +1 -0
  85. package/core/uploads.mjs +2 -0
  86. package/core/uploads.mjs.map +1 -0
  87. package/error.d.mts +2 -0
  88. package/error.d.mts.map +1 -0
  89. package/error.d.ts +2 -0
  90. package/error.d.ts.map +1 -0
  91. package/error.js +6 -0
  92. package/error.js.map +1 -0
  93. package/error.mjs +2 -0
  94. package/error.mjs.map +1 -0
  95. package/helpers/beta/json-schema.d.mts +31 -0
  96. package/helpers/beta/json-schema.d.mts.map +1 -0
  97. package/helpers/beta/json-schema.d.ts +31 -0
  98. package/helpers/beta/json-schema.d.ts.map +1 -0
  99. package/helpers/beta/json-schema.js +56 -0
  100. package/helpers/beta/json-schema.js.map +1 -0
  101. package/helpers/beta/json-schema.mjs +52 -0
  102. package/helpers/beta/json-schema.mjs.map +1 -0
  103. package/helpers/beta/mcp.d.mts +303 -0
  104. package/helpers/beta/mcp.d.mts.map +1 -0
  105. package/helpers/beta/mcp.d.ts +303 -0
  106. package/helpers/beta/mcp.d.ts.map +1 -0
  107. package/helpers/beta/mcp.js +419 -0
  108. package/helpers/beta/mcp.js.map +1 -0
  109. package/helpers/beta/mcp.mjs +406 -0
  110. package/helpers/beta/mcp.mjs.map +1 -0
  111. package/helpers/beta/memory.d.mts +11 -0
  112. package/helpers/beta/memory.d.mts.map +1 -0
  113. package/helpers/beta/memory.d.ts +11 -0
  114. package/helpers/beta/memory.d.ts.map +1 -0
  115. package/helpers/beta/memory.js +18 -0
  116. package/helpers/beta/memory.js.map +1 -0
  117. package/helpers/beta/memory.mjs +15 -0
  118. package/helpers/beta/memory.mjs.map +1 -0
  119. package/helpers/beta/zod.d.mts +27 -0
  120. package/helpers/beta/zod.d.mts.map +1 -0
  121. package/helpers/beta/zod.d.ts +27 -0
  122. package/helpers/beta/zod.d.ts.map +1 -0
  123. package/helpers/beta/zod.js +57 -0
  124. package/helpers/beta/zod.js.map +1 -0
  125. package/helpers/beta/zod.mjs +52 -0
  126. package/helpers/beta/zod.mjs.map +1 -0
  127. package/helpers/index.d.mts +3 -0
  128. package/helpers/index.d.mts.map +1 -0
  129. package/helpers/index.d.ts +3 -0
  130. package/helpers/index.d.ts.map +1 -0
  131. package/helpers/index.js +8 -0
  132. package/helpers/index.js.map +1 -0
  133. package/helpers/index.mjs +3 -0
  134. package/helpers/index.mjs.map +1 -0
  135. package/helpers/json-schema.d.mts +18 -0
  136. package/helpers/json-schema.d.mts.map +1 -0
  137. package/helpers/json-schema.d.ts +18 -0
  138. package/helpers/json-schema.d.ts.map +1 -0
  139. package/helpers/json-schema.js +37 -0
  140. package/helpers/json-schema.js.map +1 -0
  141. package/helpers/json-schema.mjs +34 -0
  142. package/helpers/json-schema.mjs.map +1 -0
  143. package/helpers/zod.d.mts +13 -0
  144. package/helpers/zod.d.mts.map +1 -0
  145. package/helpers/zod.d.ts +13 -0
  146. package/helpers/zod.d.ts.map +1 -0
  147. package/helpers/zod.js +47 -0
  148. package/helpers/zod.js.map +1 -0
  149. package/helpers/zod.mjs +43 -0
  150. package/helpers/zod.mjs.map +1 -0
  151. package/index.d.mts +9 -0
  152. package/index.d.mts.map +1 -0
  153. package/index.d.ts +9 -0
  154. package/index.d.ts.map +1 -0
  155. package/index.js +42 -0
  156. package/index.js.map +1 -0
  157. package/index.mjs +9 -0
  158. package/index.mjs.map +1 -0
  159. package/internal/builtin-types.d.mts +73 -0
  160. package/internal/builtin-types.d.mts.map +1 -0
  161. package/internal/builtin-types.d.ts +73 -0
  162. package/internal/builtin-types.d.ts.map +1 -0
  163. package/internal/builtin-types.js +4 -0
  164. package/internal/builtin-types.js.map +1 -0
  165. package/internal/builtin-types.mjs +3 -0
  166. package/internal/builtin-types.mjs.map +1 -0
  167. package/internal/constants.d.mts +5 -0
  168. package/internal/constants.d.mts.map +1 -0
  169. package/internal/constants.d.ts +5 -0
  170. package/internal/constants.d.ts.map +1 -0
  171. package/internal/constants.js +18 -0
  172. package/internal/constants.js.map +1 -0
  173. package/internal/constants.mjs +15 -0
  174. package/internal/constants.mjs.map +1 -0
  175. package/internal/decoders/jsonl.d.mts +10 -0
  176. package/internal/decoders/jsonl.d.mts.map +1 -0
  177. package/internal/decoders/jsonl.d.ts +10 -0
  178. package/internal/decoders/jsonl.d.ts.map +1 -0
  179. package/internal/decoders/jsonl.js +39 -0
  180. package/internal/decoders/jsonl.js.map +1 -0
  181. package/internal/decoders/jsonl.mjs +35 -0
  182. package/internal/decoders/jsonl.mjs.map +1 -0
  183. package/internal/decoders/line.d.mts +17 -0
  184. package/internal/decoders/line.d.mts.map +1 -0
  185. package/internal/decoders/line.d.ts +17 -0
  186. package/internal/decoders/line.d.ts.map +1 -0
  187. package/internal/decoders/line.js +113 -0
  188. package/internal/decoders/line.js.map +1 -0
  189. package/internal/decoders/line.mjs +108 -0
  190. package/internal/decoders/line.mjs.map +1 -0
  191. package/internal/detect-platform.d.mts +15 -0
  192. package/internal/detect-platform.d.mts.map +1 -0
  193. package/internal/detect-platform.d.ts +15 -0
  194. package/internal/detect-platform.d.ts.map +1 -0
  195. package/internal/detect-platform.js +162 -0
  196. package/internal/detect-platform.js.map +1 -0
  197. package/internal/detect-platform.mjs +157 -0
  198. package/internal/detect-platform.mjs.map +1 -0
  199. package/internal/errors.d.mts +3 -0
  200. package/internal/errors.d.mts.map +1 -0
  201. package/internal/errors.d.ts +3 -0
  202. package/internal/errors.d.ts.map +1 -0
  203. package/internal/errors.js +41 -0
  204. package/internal/errors.js.map +1 -0
  205. package/internal/errors.mjs +36 -0
  206. package/internal/errors.mjs.map +1 -0
  207. package/internal/headers.d.mts +22 -0
  208. package/internal/headers.d.mts.map +1 -0
  209. package/internal/headers.d.ts +22 -0
  210. package/internal/headers.d.ts.map +1 -0
  211. package/internal/headers.js +79 -0
  212. package/internal/headers.js.map +1 -0
  213. package/internal/headers.mjs +74 -0
  214. package/internal/headers.mjs.map +1 -0
  215. package/internal/parse.d.mts +17 -0
  216. package/internal/parse.d.mts.map +1 -0
  217. package/internal/parse.d.ts +17 -0
  218. package/internal/parse.d.ts.map +1 -0
  219. package/internal/parse.js +60 -0
  220. package/internal/parse.js.map +1 -0
  221. package/internal/parse.mjs +56 -0
  222. package/internal/parse.mjs.map +1 -0
  223. package/internal/request-options.d.mts +77 -0
  224. package/internal/request-options.d.mts.map +1 -0
  225. package/internal/request-options.d.ts +77 -0
  226. package/internal/request-options.d.ts.map +1 -0
  227. package/internal/request-options.js +14 -0
  228. package/internal/request-options.js.map +1 -0
  229. package/internal/request-options.mjs +10 -0
  230. package/internal/request-options.mjs.map +1 -0
  231. package/internal/shim-types.d.mts +17 -0
  232. package/internal/shim-types.d.mts.map +1 -0
  233. package/internal/shim-types.d.ts +17 -0
  234. package/internal/shim-types.d.ts.map +1 -0
  235. package/internal/shim-types.js +4 -0
  236. package/internal/shim-types.js.map +1 -0
  237. package/internal/shim-types.mjs +3 -0
  238. package/internal/shim-types.mjs.map +1 -0
  239. package/internal/shims.d.mts +20 -0
  240. package/internal/shims.d.mts.map +1 -0
  241. package/internal/shims.d.ts +20 -0
  242. package/internal/shims.d.ts.map +1 -0
  243. package/internal/shims.js +92 -0
  244. package/internal/shims.js.map +1 -0
  245. package/internal/shims.mjs +85 -0
  246. package/internal/shims.mjs.map +1 -0
  247. package/internal/stream-utils.d.mts +8 -0
  248. package/internal/stream-utils.d.mts.map +1 -0
  249. package/internal/stream-utils.d.ts +8 -0
  250. package/internal/stream-utils.d.ts.map +1 -0
  251. package/internal/stream-utils.js +38 -0
  252. package/internal/stream-utils.js.map +1 -0
  253. package/internal/stream-utils.mjs +35 -0
  254. package/internal/stream-utils.mjs.map +1 -0
  255. package/internal/to-file.d.mts +45 -0
  256. package/internal/to-file.d.mts.map +1 -0
  257. package/internal/to-file.d.ts +45 -0
  258. package/internal/to-file.d.ts.map +1 -0
  259. package/internal/to-file.js +96 -0
  260. package/internal/to-file.js.map +1 -0
  261. package/internal/to-file.mjs +93 -0
  262. package/internal/to-file.mjs.map +1 -0
  263. package/internal/tslib.js +81 -0
  264. package/internal/tslib.mjs +17 -0
  265. package/internal/types.d.mts +69 -0
  266. package/internal/types.d.mts.map +1 -0
  267. package/internal/types.d.ts +69 -0
  268. package/internal/types.d.ts.map +1 -0
  269. package/internal/types.js +4 -0
  270. package/internal/types.js.map +1 -0
  271. package/internal/types.mjs +3 -0
  272. package/internal/types.mjs.map +1 -0
  273. package/internal/uploads.d.mts +42 -0
  274. package/internal/uploads.d.mts.map +1 -0
  275. package/internal/uploads.d.ts +42 -0
  276. package/internal/uploads.d.ts.map +1 -0
  277. package/internal/uploads.js +145 -0
  278. package/internal/uploads.js.map +1 -0
  279. package/internal/uploads.mjs +135 -0
  280. package/internal/uploads.mjs.map +1 -0
  281. package/internal/utils/base64.d.mts +3 -0
  282. package/internal/utils/base64.d.mts.map +1 -0
  283. package/internal/utils/base64.d.ts +3 -0
  284. package/internal/utils/base64.d.ts.map +1 -0
  285. package/internal/utils/base64.js +38 -0
  286. package/internal/utils/base64.js.map +1 -0
  287. package/internal/utils/base64.mjs +33 -0
  288. package/internal/utils/base64.mjs.map +1 -0
  289. package/internal/utils/bytes.d.mts +4 -0
  290. package/internal/utils/bytes.d.mts.map +1 -0
  291. package/internal/utils/bytes.d.ts +4 -0
  292. package/internal/utils/bytes.d.ts.map +1 -0
  293. package/internal/utils/bytes.js +31 -0
  294. package/internal/utils/bytes.js.map +1 -0
  295. package/internal/utils/bytes.mjs +26 -0
  296. package/internal/utils/bytes.mjs.map +1 -0
  297. package/internal/utils/env.d.mts +9 -0
  298. package/internal/utils/env.d.mts.map +1 -0
  299. package/internal/utils/env.d.ts +9 -0
  300. package/internal/utils/env.d.ts.map +1 -0
  301. package/internal/utils/env.js +22 -0
  302. package/internal/utils/env.js.map +1 -0
  303. package/internal/utils/env.mjs +18 -0
  304. package/internal/utils/env.mjs.map +1 -0
  305. package/internal/utils/log.d.mts +37 -0
  306. package/internal/utils/log.d.mts.map +1 -0
  307. package/internal/utils/log.d.ts +37 -0
  308. package/internal/utils/log.d.ts.map +1 -0
  309. package/internal/utils/log.js +86 -0
  310. package/internal/utils/log.js.map +1 -0
  311. package/internal/utils/log.mjs +80 -0
  312. package/internal/utils/log.mjs.map +1 -0
  313. package/internal/utils/path.d.mts +15 -0
  314. package/internal/utils/path.d.mts.map +1 -0
  315. package/internal/utils/path.d.ts +15 -0
  316. package/internal/utils/path.d.ts.map +1 -0
  317. package/internal/utils/path.js +79 -0
  318. package/internal/utils/path.js.map +1 -0
  319. package/internal/utils/path.mjs +74 -0
  320. package/internal/utils/path.mjs.map +1 -0
  321. package/internal/utils/query.d.mts +5 -0
  322. package/internal/utils/query.d.mts.map +1 -0
  323. package/internal/utils/query.d.ts +5 -0
  324. package/internal/utils/query.d.ts.map +1 -0
  325. package/internal/utils/query.js +23 -0
  326. package/internal/utils/query.js.map +1 -0
  327. package/internal/utils/query.mjs +20 -0
  328. package/internal/utils/query.mjs.map +1 -0
  329. package/internal/utils/sleep.d.mts +2 -0
  330. package/internal/utils/sleep.d.mts.map +1 -0
  331. package/internal/utils/sleep.d.ts +2 -0
  332. package/internal/utils/sleep.d.ts.map +1 -0
  333. package/internal/utils/sleep.js +7 -0
  334. package/internal/utils/sleep.js.map +1 -0
  335. package/internal/utils/sleep.mjs +3 -0
  336. package/internal/utils/sleep.mjs.map +1 -0
  337. package/internal/utils/uuid.d.mts +5 -0
  338. package/internal/utils/uuid.d.mts.map +1 -0
  339. package/internal/utils/uuid.d.ts +5 -0
  340. package/internal/utils/uuid.d.ts.map +1 -0
  341. package/internal/utils/uuid.js +19 -0
  342. package/internal/utils/uuid.js.map +1 -0
  343. package/internal/utils/uuid.mjs +15 -0
  344. package/internal/utils/uuid.mjs.map +1 -0
  345. package/internal/utils/values.d.mts +19 -0
  346. package/internal/utils/values.d.mts.map +1 -0
  347. package/internal/utils/values.d.ts +19 -0
  348. package/internal/utils/values.d.ts.map +1 -0
  349. package/internal/utils/values.js +119 -0
  350. package/internal/utils/values.js.map +1 -0
  351. package/internal/utils/values.mjs +100 -0
  352. package/internal/utils/values.mjs.map +1 -0
  353. package/internal/utils.d.mts +8 -0
  354. package/internal/utils.d.mts.map +1 -0
  355. package/internal/utils.d.ts +8 -0
  356. package/internal/utils.d.ts.map +1 -0
  357. package/internal/utils.js +12 -0
  358. package/internal/utils.js.map +1 -0
  359. package/internal/utils.mjs +9 -0
  360. package/internal/utils.mjs.map +1 -0
  361. package/lib/BetaMessageStream.d.mts +122 -0
  362. package/lib/BetaMessageStream.d.mts.map +1 -0
  363. package/lib/BetaMessageStream.d.ts +122 -0
  364. package/lib/BetaMessageStream.d.ts.map +1 -0
  365. package/lib/BetaMessageStream.js +620 -0
  366. package/lib/BetaMessageStream.js.map +1 -0
  367. package/lib/BetaMessageStream.mjs +616 -0
  368. package/lib/BetaMessageStream.mjs.map +1 -0
  369. package/lib/MessageStream.d.mts +121 -0
  370. package/lib/MessageStream.d.mts.map +1 -0
  371. package/lib/MessageStream.d.ts +121 -0
  372. package/lib/MessageStream.d.ts.map +1 -0
  373. package/lib/MessageStream.js +595 -0
  374. package/lib/MessageStream.js.map +1 -0
  375. package/lib/MessageStream.mjs +591 -0
  376. package/lib/MessageStream.mjs.map +1 -0
  377. package/lib/beta-parser.d.mts +37 -0
  378. package/lib/beta-parser.d.mts.map +1 -0
  379. package/lib/beta-parser.d.ts +37 -0
  380. package/lib/beta-parser.d.ts.map +1 -0
  381. package/lib/beta-parser.js +79 -0
  382. package/lib/beta-parser.js.map +1 -0
  383. package/lib/beta-parser.mjs +75 -0
  384. package/lib/beta-parser.mjs.map +1 -0
  385. package/lib/parser.d.mts +32 -0
  386. package/lib/parser.d.mts.map +1 -0
  387. package/lib/parser.d.ts +32 -0
  388. package/lib/parser.d.ts.map +1 -0
  389. package/lib/parser.js +66 -0
  390. package/lib/parser.js.map +1 -0
  391. package/lib/parser.mjs +62 -0
  392. package/lib/parser.mjs.map +1 -0
  393. package/lib/stainless-helper-header.d.mts +34 -0
  394. package/lib/stainless-helper-header.d.mts.map +1 -0
  395. package/lib/stainless-helper-header.d.ts +34 -0
  396. package/lib/stainless-helper-header.d.ts.map +1 -0
  397. package/lib/stainless-helper-header.js +70 -0
  398. package/lib/stainless-helper-header.js.map +1 -0
  399. package/lib/stainless-helper-header.mjs +63 -0
  400. package/lib/stainless-helper-header.mjs.map +1 -0
  401. package/lib/tools/BetaRunnableTool.d.mts +12 -0
  402. package/lib/tools/BetaRunnableTool.d.mts.map +1 -0
  403. package/lib/tools/BetaRunnableTool.d.ts +12 -0
  404. package/lib/tools/BetaRunnableTool.d.ts.map +1 -0
  405. package/lib/tools/BetaRunnableTool.js +3 -0
  406. package/lib/tools/BetaRunnableTool.js.map +1 -0
  407. package/lib/tools/BetaRunnableTool.mjs +2 -0
  408. package/lib/tools/BetaRunnableTool.mjs.map +1 -0
  409. package/lib/tools/BetaToolRunner.d.mts +141 -0
  410. package/lib/tools/BetaToolRunner.d.mts.map +1 -0
  411. package/lib/tools/BetaToolRunner.d.ts +141 -0
  412. package/lib/tools/BetaToolRunner.d.ts.map +1 -0
  413. package/lib/tools/BetaToolRunner.js +381 -0
  414. package/lib/tools/BetaToolRunner.js.map +1 -0
  415. package/lib/tools/BetaToolRunner.mjs +377 -0
  416. package/lib/tools/BetaToolRunner.mjs.map +1 -0
  417. package/lib/tools/CompactionControl.d.mts +30 -0
  418. package/lib/tools/CompactionControl.d.mts.map +1 -0
  419. package/lib/tools/CompactionControl.d.ts +30 -0
  420. package/lib/tools/CompactionControl.d.ts.map +1 -0
  421. package/lib/tools/CompactionControl.js +28 -0
  422. package/lib/tools/CompactionControl.js.map +1 -0
  423. package/lib/tools/CompactionControl.mjs +25 -0
  424. package/lib/tools/CompactionControl.mjs.map +1 -0
  425. package/lib/tools/ToolError.d.mts +33 -0
  426. package/lib/tools/ToolError.d.mts.map +1 -0
  427. package/lib/tools/ToolError.d.ts +33 -0
  428. package/lib/tools/ToolError.d.ts.map +1 -0
  429. package/lib/tools/ToolError.js +42 -0
  430. package/lib/tools/ToolError.js.map +1 -0
  431. package/lib/tools/ToolError.mjs +38 -0
  432. package/lib/tools/ToolError.mjs.map +1 -0
  433. package/lib/tools/ToolRunner.d.mts +132 -0
  434. package/lib/tools/ToolRunner.d.mts.map +1 -0
  435. package/lib/tools/ToolRunner.d.ts +132 -0
  436. package/lib/tools/ToolRunner.d.ts.map +1 -0
  437. package/lib/tools/ToolRunner.js +294 -0
  438. package/lib/tools/ToolRunner.js.map +1 -0
  439. package/lib/tools/ToolRunner.mjs +290 -0
  440. package/lib/tools/ToolRunner.mjs.map +1 -0
  441. package/lib/transform-json-schema.d.mts +3 -0
  442. package/lib/transform-json-schema.d.mts.map +1 -0
  443. package/lib/transform-json-schema.d.ts +3 -0
  444. package/lib/transform-json-schema.d.ts.map +1 -0
  445. package/lib/transform-json-schema.js +114 -0
  446. package/lib/transform-json-schema.js.map +1 -0
  447. package/lib/transform-json-schema.mjs +111 -0
  448. package/lib/transform-json-schema.mjs.map +1 -0
  449. package/package.json +246 -0
  450. package/pagination.d.mts +2 -0
  451. package/pagination.d.mts.map +1 -0
  452. package/pagination.d.ts +2 -0
  453. package/pagination.d.ts.map +1 -0
  454. package/pagination.js +6 -0
  455. package/pagination.js.map +1 -0
  456. package/pagination.mjs +2 -0
  457. package/pagination.mjs.map +1 -0
  458. package/resource.d.mts +2 -0
  459. package/resource.d.mts.map +1 -0
  460. package/resource.d.ts +2 -0
  461. package/resource.d.ts.map +1 -0
  462. package/resource.js +6 -0
  463. package/resource.js.map +1 -0
  464. package/resource.mjs +2 -0
  465. package/resource.mjs.map +1 -0
  466. package/resources/beta/beta.d.mts +66 -0
  467. package/resources/beta/beta.d.mts.map +1 -0
  468. package/resources/beta/beta.d.ts +66 -0
  469. package/resources/beta/beta.d.ts.map +1 -0
  470. package/resources/beta/beta.js +29 -0
  471. package/resources/beta/beta.js.map +1 -0
  472. package/resources/beta/beta.mjs +24 -0
  473. package/resources/beta/beta.mjs.map +1 -0
  474. package/resources/beta/files.d.mts +151 -0
  475. package/resources/beta/files.d.mts.map +1 -0
  476. package/resources/beta/files.d.ts +151 -0
  477. package/resources/beta/files.d.ts.map +1 -0
  478. package/resources/beta/files.js +124 -0
  479. package/resources/beta/files.js.map +1 -0
  480. package/resources/beta/files.mjs +120 -0
  481. package/resources/beta/files.mjs.map +1 -0
  482. package/resources/beta/index.d.mts +6 -0
  483. package/resources/beta/index.d.mts.map +1 -0
  484. package/resources/beta/index.d.ts +6 -0
  485. package/resources/beta/index.d.ts.map +1 -0
  486. package/resources/beta/index.js +15 -0
  487. package/resources/beta/index.js.map +1 -0
  488. package/resources/beta/index.mjs +7 -0
  489. package/resources/beta/index.mjs.map +1 -0
  490. package/resources/beta/messages/batches.d.mts +646 -0
  491. package/resources/beta/messages/batches.d.mts.map +1 -0
  492. package/resources/beta/messages/batches.d.ts +646 -0
  493. package/resources/beta/messages/batches.d.ts.map +1 -0
  494. package/resources/beta/messages/batches.js +204 -0
  495. package/resources/beta/messages/batches.js.map +1 -0
  496. package/resources/beta/messages/batches.mjs +200 -0
  497. package/resources/beta/messages/batches.mjs.map +1 -0
  498. package/resources/beta/messages/index.d.mts +4 -0
  499. package/resources/beta/messages/index.d.mts.map +1 -0
  500. package/resources/beta/messages/index.d.ts +4 -0
  501. package/resources/beta/messages/index.d.ts.map +1 -0
  502. package/resources/beta/messages/index.js +12 -0
  503. package/resources/beta/messages/index.js.map +1 -0
  504. package/resources/beta/messages/index.mjs +5 -0
  505. package/resources/beta/messages/index.mjs.map +1 -0
  506. package/resources/beta/messages/messages.d.mts +2993 -0
  507. package/resources/beta/messages/messages.d.mts.map +1 -0
  508. package/resources/beta/messages/messages.d.ts +2993 -0
  509. package/resources/beta/messages/messages.d.ts.map +1 -0
  510. package/resources/beta/messages/messages.js +163 -0
  511. package/resources/beta/messages/messages.js.map +1 -0
  512. package/resources/beta/messages/messages.mjs +156 -0
  513. package/resources/beta/messages/messages.mjs.map +1 -0
  514. package/resources/beta/messages.d.mts +2 -0
  515. package/resources/beta/messages.d.mts.map +1 -0
  516. package/resources/beta/messages.d.ts +2 -0
  517. package/resources/beta/messages.d.ts.map +1 -0
  518. package/resources/beta/messages.js +6 -0
  519. package/resources/beta/messages.js.map +1 -0
  520. package/resources/beta/messages.mjs +3 -0
  521. package/resources/beta/messages.mjs.map +1 -0
  522. package/resources/beta/models.d.mts +208 -0
  523. package/resources/beta/models.d.mts.map +1 -0
  524. package/resources/beta/models.d.ts +208 -0
  525. package/resources/beta/models.d.ts.map +1 -0
  526. package/resources/beta/models.js +60 -0
  527. package/resources/beta/models.js.map +1 -0
  528. package/resources/beta/models.mjs +56 -0
  529. package/resources/beta/models.mjs.map +1 -0
  530. package/resources/beta/skills/index.d.mts +3 -0
  531. package/resources/beta/skills/index.d.mts.map +1 -0
  532. package/resources/beta/skills/index.d.ts +3 -0
  533. package/resources/beta/skills/index.d.ts.map +1 -0
  534. package/resources/beta/skills/index.js +9 -0
  535. package/resources/beta/skills/index.js.map +1 -0
  536. package/resources/beta/skills/index.mjs +4 -0
  537. package/resources/beta/skills/index.mjs.map +1 -0
  538. package/resources/beta/skills/skills.d.mts +249 -0
  539. package/resources/beta/skills/skills.d.mts.map +1 -0
  540. package/resources/beta/skills/skills.d.ts +249 -0
  541. package/resources/beta/skills/skills.d.ts.map +1 -0
  542. package/resources/beta/skills/skills.js +98 -0
  543. package/resources/beta/skills/skills.js.map +1 -0
  544. package/resources/beta/skills/skills.mjs +93 -0
  545. package/resources/beta/skills/skills.mjs.map +1 -0
  546. package/resources/beta/skills/versions.d.mts +257 -0
  547. package/resources/beta/skills/versions.d.mts.map +1 -0
  548. package/resources/beta/skills/versions.d.ts +257 -0
  549. package/resources/beta/skills/versions.d.ts.map +1 -0
  550. package/resources/beta/skills/versions.js +100 -0
  551. package/resources/beta/skills/versions.js.map +1 -0
  552. package/resources/beta/skills/versions.mjs +96 -0
  553. package/resources/beta/skills/versions.mjs.map +1 -0
  554. package/resources/beta/skills.d.mts +2 -0
  555. package/resources/beta/skills.d.mts.map +1 -0
  556. package/resources/beta/skills.d.ts +2 -0
  557. package/resources/beta/skills.d.ts.map +1 -0
  558. package/resources/beta/skills.js +6 -0
  559. package/resources/beta/skills.js.map +1 -0
  560. package/resources/beta/skills.mjs +3 -0
  561. package/resources/beta/skills.mjs.map +1 -0
  562. package/resources/beta.d.mts +2 -0
  563. package/resources/beta.d.mts.map +1 -0
  564. package/resources/beta.d.ts +2 -0
  565. package/resources/beta.d.ts.map +1 -0
  566. package/resources/beta.js +6 -0
  567. package/resources/beta.js.map +1 -0
  568. package/resources/beta.mjs +3 -0
  569. package/resources/beta.mjs.map +1 -0
  570. package/resources/completions.d.mts +182 -0
  571. package/resources/completions.d.mts.map +1 -0
  572. package/resources/completions.d.ts +182 -0
  573. package/resources/completions.d.ts.map +1 -0
  574. package/resources/completions.js +23 -0
  575. package/resources/completions.js.map +1 -0
  576. package/resources/completions.mjs +19 -0
  577. package/resources/completions.mjs.map +1 -0
  578. package/resources/index.d.mts +6 -0
  579. package/resources/index.d.mts.map +1 -0
  580. package/resources/index.d.ts +6 -0
  581. package/resources/index.d.ts.map +1 -0
  582. package/resources/index.js +15 -0
  583. package/resources/index.js.map +1 -0
  584. package/resources/index.mjs +7 -0
  585. package/resources/index.mjs.map +1 -0
  586. package/resources/messages/batches.d.mts +304 -0
  587. package/resources/messages/batches.d.mts.map +1 -0
  588. package/resources/messages/batches.d.ts +304 -0
  589. package/resources/messages/batches.d.ts.map +1 -0
  590. package/resources/messages/batches.js +153 -0
  591. package/resources/messages/batches.js.map +1 -0
  592. package/resources/messages/batches.mjs +149 -0
  593. package/resources/messages/batches.mjs.map +1 -0
  594. package/resources/messages/index.d.mts +3 -0
  595. package/resources/messages/index.d.mts.map +1 -0
  596. package/resources/messages/index.d.ts +3 -0
  597. package/resources/messages/index.d.ts.map +1 -0
  598. package/resources/messages/index.js +9 -0
  599. package/resources/messages/index.js.map +1 -0
  600. package/resources/messages/index.mjs +4 -0
  601. package/resources/messages/index.mjs.map +1 -0
  602. package/resources/messages/messages.d.mts +2285 -0
  603. package/resources/messages/messages.d.mts.map +1 -0
  604. package/resources/messages/messages.d.ts +2285 -0
  605. package/resources/messages/messages.d.ts.map +1 -0
  606. package/resources/messages/messages.js +128 -0
  607. package/resources/messages/messages.js.map +1 -0
  608. package/resources/messages/messages.mjs +123 -0
  609. package/resources/messages/messages.mjs.map +1 -0
  610. package/resources/messages.d.mts +2 -0
  611. package/resources/messages.d.mts.map +1 -0
  612. package/resources/messages.d.ts +2 -0
  613. package/resources/messages.d.ts.map +1 -0
  614. package/resources/messages.js +6 -0
  615. package/resources/messages.js.map +1 -0
  616. package/resources/messages.mjs +3 -0
  617. package/resources/messages.mjs.map +1 -0
  618. package/resources/models.d.mts +193 -0
  619. package/resources/models.d.mts.map +1 -0
  620. package/resources/models.d.ts +193 -0
  621. package/resources/models.d.ts.map +1 -0
  622. package/resources/models.js +45 -0
  623. package/resources/models.js.map +1 -0
  624. package/resources/models.mjs +41 -0
  625. package/resources/models.mjs.map +1 -0
  626. package/resources/shared.d.mts +44 -0
  627. package/resources/shared.d.mts.map +1 -0
  628. package/resources/shared.d.ts +44 -0
  629. package/resources/shared.d.ts.map +1 -0
  630. package/resources/shared.js +4 -0
  631. package/resources/shared.js.map +1 -0
  632. package/resources/shared.mjs +3 -0
  633. package/resources/shared.mjs.map +1 -0
  634. package/resources/top-level.d.mts +2 -0
  635. package/resources/top-level.d.mts.map +1 -0
  636. package/resources/top-level.d.ts +2 -0
  637. package/resources/top-level.d.ts.map +1 -0
  638. package/resources/top-level.js +4 -0
  639. package/resources/top-level.js.map +1 -0
  640. package/resources/top-level.mjs +3 -0
  641. package/resources/top-level.mjs.map +1 -0
  642. package/resources.d.mts +2 -0
  643. package/resources.d.mts.map +1 -0
  644. package/resources.d.ts +2 -0
  645. package/resources.d.ts.map +1 -0
  646. package/resources.js +5 -0
  647. package/resources.js.map +1 -0
  648. package/resources.mjs +2 -0
  649. package/resources.mjs.map +1 -0
  650. package/src/_vendor/partial-json-parser/README.md +3 -0
  651. package/src/_vendor/partial-json-parser/parser.ts +264 -0
  652. package/src/ainative.ts +85 -0
  653. package/src/api-promise.ts +2 -0
  654. package/src/client.ts +1326 -0
  655. package/src/core/README.md +3 -0
  656. package/src/core/api-promise.ts +101 -0
  657. package/src/core/error.ts +145 -0
  658. package/src/core/pagination.ts +331 -0
  659. package/src/core/resource.ts +11 -0
  660. package/src/core/streaming.ts +348 -0
  661. package/src/core/uploads.ts +2 -0
  662. package/src/error.ts +2 -0
  663. package/src/helpers/beta/json-schema.ts +75 -0
  664. package/src/helpers/beta/mcp.ts +624 -0
  665. package/src/helpers/beta/memory.ts +28 -0
  666. package/src/helpers/beta/zod.ts +72 -0
  667. package/src/helpers/index.ts +2 -0
  668. package/src/helpers/json-schema.ts +48 -0
  669. package/src/helpers/zod.ts +58 -0
  670. package/src/index.ts +40 -0
  671. package/src/internal/README.md +3 -0
  672. package/src/internal/builtin-types.ts +93 -0
  673. package/src/internal/constants.ts +15 -0
  674. package/src/internal/decoders/jsonl.ts +48 -0
  675. package/src/internal/decoders/line.ts +135 -0
  676. package/src/internal/detect-platform.ts +196 -0
  677. package/src/internal/errors.ts +33 -0
  678. package/src/internal/headers.ts +99 -0
  679. package/src/internal/parse.ts +90 -0
  680. package/src/internal/request-options.ts +93 -0
  681. package/src/internal/shim-types.ts +26 -0
  682. package/src/internal/shims.ts +107 -0
  683. package/src/internal/stream-utils.ts +32 -0
  684. package/src/internal/to-file.ts +159 -0
  685. package/src/internal/types.ts +95 -0
  686. package/src/internal/uploads.ts +204 -0
  687. package/src/internal/utils/base64.ts +40 -0
  688. package/src/internal/utils/bytes.ts +32 -0
  689. package/src/internal/utils/env.ts +18 -0
  690. package/src/internal/utils/log.ts +127 -0
  691. package/src/internal/utils/path.ts +88 -0
  692. package/src/internal/utils/query.ts +23 -0
  693. package/src/internal/utils/sleep.ts +3 -0
  694. package/src/internal/utils/uuid.ts +17 -0
  695. package/src/internal/utils/values.ts +112 -0
  696. package/src/internal/utils.ts +9 -0
  697. package/src/lib/.keep +4 -0
  698. package/src/lib/BetaMessageStream.ts +764 -0
  699. package/src/lib/MessageStream.ts +743 -0
  700. package/src/lib/beta-parser.ts +148 -0
  701. package/src/lib/parser.ts +125 -0
  702. package/src/lib/stainless-helper-header.ts +80 -0
  703. package/src/lib/tools/BetaRunnableTool.ts +40 -0
  704. package/src/lib/tools/BetaToolRunner.ts +494 -0
  705. package/src/lib/tools/CompactionControl.ts +57 -0
  706. package/src/lib/tools/ToolError.ts +47 -0
  707. package/src/lib/tools/ToolRunner.ts +381 -0
  708. package/src/lib/transform-json-schema.ts +124 -0
  709. package/src/pagination.ts +2 -0
  710. package/src/resource.ts +2 -0
  711. package/src/resources/beta/beta.ts +603 -0
  712. package/src/resources/beta/files.ts +261 -0
  713. package/src/resources/beta/index.ts +259 -0
  714. package/src/resources/beta/messages/batches.ts +827 -0
  715. package/src/resources/beta/messages/index.ts +229 -0
  716. package/src/resources/beta/messages/messages.ts +4372 -0
  717. package/src/resources/beta/messages.ts +3 -0
  718. package/src/resources/beta/models.ts +284 -0
  719. package/src/resources/beta/skills/index.ts +26 -0
  720. package/src/resources/beta/skills/skills.ts +384 -0
  721. package/src/resources/beta/skills/versions.ts +374 -0
  722. package/src/resources/beta/skills.ts +3 -0
  723. package/src/resources/beta.ts +3 -0
  724. package/src/resources/completions.ts +230 -0
  725. package/src/resources/index.ts +206 -0
  726. package/src/resources/messages/batches.ts +396 -0
  727. package/src/resources/messages/index.ts +189 -0
  728. package/src/resources/messages/messages.ts +3361 -0
  729. package/src/resources/messages.ts +3 -0
  730. package/src/resources/models.ts +269 -0
  731. package/src/resources/shared.ts +85 -0
  732. package/src/resources/top-level.ts +3 -0
  733. package/src/resources.ts +1 -0
  734. package/src/streaming.ts +2 -0
  735. package/src/tools/memory/node.ts +392 -0
  736. package/src/tsconfig.json +11 -0
  737. package/src/uploads.ts +2 -0
  738. package/src/version.ts +1 -0
  739. package/streaming.d.mts +2 -0
  740. package/streaming.d.mts.map +1 -0
  741. package/streaming.d.ts +2 -0
  742. package/streaming.d.ts.map +1 -0
  743. package/streaming.js +6 -0
  744. package/streaming.js.map +1 -0
  745. package/streaming.mjs +2 -0
  746. package/streaming.mjs.map +1 -0
  747. package/tools/memory/node.d.mts +18 -0
  748. package/tools/memory/node.d.mts.map +1 -0
  749. package/tools/memory/node.d.ts +18 -0
  750. package/tools/memory/node.d.ts.map +1 -0
  751. package/tools/memory/node.js +324 -0
  752. package/tools/memory/node.js.map +1 -0
  753. package/tools/memory/node.mjs +318 -0
  754. package/tools/memory/node.mjs.map +1 -0
  755. package/uploads.d.mts +2 -0
  756. package/uploads.d.mts.map +1 -0
  757. package/uploads.d.ts +2 -0
  758. package/uploads.d.ts.map +1 -0
  759. package/uploads.js +6 -0
  760. package/uploads.js.map +1 -0
  761. package/uploads.mjs +2 -0
  762. package/uploads.mjs.map +1 -0
  763. package/version.d.mts +2 -0
  764. package/version.d.mts.map +1 -0
  765. package/version.d.ts +2 -0
  766. package/version.d.ts.map +1 -0
  767. package/version.js +5 -0
  768. package/version.js.map +1 -0
  769. package/version.mjs +2 -0
  770. package/version.mjs.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beta-parser.d.mts","sourceRoot":"","sources":["../src/lib/beta-parser.ts"],"names":[],"mappings":"OAAO,KAAK,EAAE,MAAM,EAAE;OAEf,EACL,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACpB;AAGD,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;CAAE,GAAG,EAAE,CAAC;AAE7D,KAAK,6BAA6B,GAAG,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAAG;IACtE,MAAM,CAAC,EAAE,oBAAoB,GAAG,6BAA6B,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;CAC3E,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG,QAAQ,CACrD,IAAI,CAAC,mBAAmB,EAAE,eAAe,GAAG,eAAe,CAAC,GAAG;IAC7D;;;OAGG;IACH,aAAa,CAAC,EAAE,oBAAoB,GAAG,6BAA6B,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACjF,aAAa,CAAC,EAAE,6BAA6B,GAAG,IAAI,CAAC;CACtD,CACF,CAAC;AAEF,MAAM,MAAM,kCAAkC,CAAC,MAAM,SAAS,gCAAgC,IAC5F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BetaTextBlock, MessageCreateParams } from "../resources/beta/messages/messages.js";
3
+ type Simplify<T> = {
4
+ [KeyType in keyof T]: T[KeyType];
5
+ } & {};
6
+ type AutoParseableBetaOutputConfig = Omit<BetaOutputConfig, 'format'> & {
7
+ format?: BetaJSONOutputFormat | AutoParseableBetaOutputFormat<any> | null;
8
+ };
9
+ export type BetaParseableMessageCreateParams = Simplify<Omit<MessageCreateParams, 'output_format' | 'output_config'> & {
10
+ /**
11
+ * @deprecated Use `output_config.format` instead. This parameter will be removed in a future
12
+ * release.
13
+ */
14
+ output_format?: BetaJSONOutputFormat | AutoParseableBetaOutputFormat<any> | null;
15
+ output_config?: AutoParseableBetaOutputConfig | null;
16
+ }>;
17
+ export type ExtractParsedContentFromBetaParams<Params extends BetaParseableMessageCreateParams> = Params['output_format'] extends AutoParseableBetaOutputFormat<infer P> ? P : Params['output_config'] extends {
18
+ format: AutoParseableBetaOutputFormat<infer P>;
19
+ } ? P : null;
20
+ export type AutoParseableBetaOutputFormat<ParsedT> = BetaJSONOutputFormat & {
21
+ parse(content: string): ParsedT;
22
+ };
23
+ export type ParsedBetaMessage<ParsedT> = BetaMessage & {
24
+ content: Array<ParsedBetaContentBlock<ParsedT>>;
25
+ parsed_output: ParsedT | null;
26
+ };
27
+ export type ParsedBetaContentBlock<ParsedT> = (BetaTextBlock & {
28
+ parsed_output: ParsedT | null;
29
+ }) | Exclude<BetaContentBlock, BetaTextBlock>;
30
+ export declare function maybeParseBetaMessage<Params extends BetaParseableMessageCreateParams | null>(message: BetaMessage, params: Params, opts: {
31
+ logger: Logger;
32
+ }): ParsedBetaMessage<ExtractParsedContentFromBetaParams<NonNullable<Params>>>;
33
+ export declare function parseBetaMessage<Params extends BetaParseableMessageCreateParams>(message: BetaMessage, params: Params, opts: {
34
+ logger: Logger;
35
+ }): ParsedBetaMessage<ExtractParsedContentFromBetaParams<Params>>;
36
+ export {};
37
+ //# sourceMappingURL=beta-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {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B,CAAC,OAAO,CAAC,CAAC,CAAC;IAChD,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,OAAO,IACtC,CAAC,aAAa,GAAG;IAAE,aAAa,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC,GACnD,OAAO,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;AAS7C,wBAAgB,qBAAqB,CAAC,MAAM,SAAS,gCAAgC,GAAG,IAAI,EAC1F,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GACvB,iBAAiB,CAAC,kCAAkC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CA6B5E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,gCAAgC,EAC9E,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GACvB,iBAAiB,CAAC,kCAAkC,CAAC,MAAM,CAAC,CAAC,CAkC/D"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maybeParseBetaMessage = maybeParseBetaMessage;
4
+ exports.parseBetaMessage = parseBetaMessage;
5
+ const error_1 = require("../core/error.js");
6
+ function getOutputFormat(params) {
7
+ // Prefer output_format (deprecated) over output_config.format for backward compatibility
8
+ return params?.output_format ?? params?.output_config?.format;
9
+ }
10
+ function maybeParseBetaMessage(message, params, opts) {
11
+ const outputFormat = getOutputFormat(params);
12
+ if (!params || !('parse' in (outputFormat ?? {}))) {
13
+ return {
14
+ ...message,
15
+ content: message.content.map((block) => {
16
+ if (block.type === 'text') {
17
+ const parsedBlock = Object.defineProperty({ ...block }, 'parsed_output', {
18
+ value: null,
19
+ enumerable: false,
20
+ });
21
+ return Object.defineProperty(parsedBlock, 'parsed', {
22
+ get() {
23
+ opts.logger.warn('The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead.');
24
+ return null;
25
+ },
26
+ enumerable: false,
27
+ });
28
+ }
29
+ return block;
30
+ }),
31
+ parsed_output: null,
32
+ };
33
+ }
34
+ return parseBetaMessage(message, params, opts);
35
+ }
36
+ function parseBetaMessage(message, params, opts) {
37
+ let firstParsedOutput = null;
38
+ const content = message.content.map((block) => {
39
+ if (block.type === 'text') {
40
+ const parsedOutput = parseBetaOutputFormat(params, block.text);
41
+ if (firstParsedOutput === null) {
42
+ firstParsedOutput = parsedOutput;
43
+ }
44
+ const parsedBlock = Object.defineProperty({ ...block }, 'parsed_output', {
45
+ value: parsedOutput,
46
+ enumerable: false,
47
+ });
48
+ return Object.defineProperty(parsedBlock, 'parsed', {
49
+ get() {
50
+ opts.logger.warn('The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead.');
51
+ return parsedOutput;
52
+ },
53
+ enumerable: false,
54
+ });
55
+ }
56
+ return block;
57
+ });
58
+ return {
59
+ ...message,
60
+ content,
61
+ parsed_output: firstParsedOutput,
62
+ };
63
+ }
64
+ function parseBetaOutputFormat(params, content) {
65
+ const outputFormat = getOutputFormat(params);
66
+ if (outputFormat?.type !== 'json_schema') {
67
+ return null;
68
+ }
69
+ try {
70
+ if ('parse' in outputFormat) {
71
+ return outputFormat.parse(content);
72
+ }
73
+ return JSON.parse(content);
74
+ }
75
+ catch (error) {
76
+ throw new error_1.AnthropicError(`Failed to parse structured output: ${error}`);
77
+ }
78
+ }
79
+ //# sourceMappingURL=beta-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beta-parser.js","sourceRoot":"","sources":["../src/lib/beta-parser.ts"],"names":[],"mappings":";;AAsDA,sDAiCC;AAED,4CAsCC;AA9HD,4CAA+C;AA8C/C,SAAS,eAAe,CACtB,MAA+C;IAE/C,yFAAyF;IACzF,OAAO,MAAM,EAAE,aAAa,IAAI,MAAM,EAAE,aAAa,EAAE,MAA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 // Prefer output_format (deprecated) over output_config.format for backward compatibility
4
+ return params?.output_format ?? params?.output_config?.format;
5
+ }
6
+ export function maybeParseBetaMessage(message, params, opts) {
7
+ const outputFormat = getOutputFormat(params);
8
+ if (!params || !('parse' in (outputFormat ?? {}))) {
9
+ return {
10
+ ...message,
11
+ content: message.content.map((block) => {
12
+ if (block.type === 'text') {
13
+ const parsedBlock = Object.defineProperty({ ...block }, 'parsed_output', {
14
+ value: null,
15
+ enumerable: false,
16
+ });
17
+ return Object.defineProperty(parsedBlock, 'parsed', {
18
+ get() {
19
+ opts.logger.warn('The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead.');
20
+ return null;
21
+ },
22
+ enumerable: false,
23
+ });
24
+ }
25
+ return block;
26
+ }),
27
+ parsed_output: null,
28
+ };
29
+ }
30
+ return parseBetaMessage(message, params, opts);
31
+ }
32
+ export function parseBetaMessage(message, params, opts) {
33
+ let firstParsedOutput = null;
34
+ const content = message.content.map((block) => {
35
+ if (block.type === 'text') {
36
+ const parsedOutput = parseBetaOutputFormat(params, block.text);
37
+ if (firstParsedOutput === null) {
38
+ firstParsedOutput = parsedOutput;
39
+ }
40
+ const parsedBlock = Object.defineProperty({ ...block }, 'parsed_output', {
41
+ value: parsedOutput,
42
+ enumerable: false,
43
+ });
44
+ return Object.defineProperty(parsedBlock, 'parsed', {
45
+ get() {
46
+ opts.logger.warn('The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead.');
47
+ return parsedOutput;
48
+ },
49
+ enumerable: false,
50
+ });
51
+ }
52
+ return block;
53
+ });
54
+ return {
55
+ ...message,
56
+ content,
57
+ parsed_output: firstParsedOutput,
58
+ };
59
+ }
60
+ function parseBetaOutputFormat(params, content) {
61
+ const outputFormat = getOutputFormat(params);
62
+ if (outputFormat?.type !== 'json_schema') {
63
+ return null;
64
+ }
65
+ try {
66
+ if ('parse' in outputFormat) {
67
+ return outputFormat.parse(content);
68
+ }
69
+ return JSON.parse(content);
70
+ }
71
+ catch (error) {
72
+ throw new AnthropicError(`Failed to parse structured output: ${error}`);
73
+ }
74
+ }
75
+ //# sourceMappingURL=beta-parser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beta-parser.mjs","sourceRoot":"","sources":["../src/lib/beta-parser.ts"],"names":[],"mappings":"OACO,EAAE,cAAc,EAAE;AA8CzB,SAAS,eAAe,CACtB,MAA+C;IAE/C,yFAAyF;IACzF,OAAO,MAAM,EAAE,aAAa,IAAI,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAAoB,EACpB,MAAc,EACd,IAAwB;IAExB,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAClD,OAAO;YACL,GAAG,OAAO;YACV,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBACrC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oBAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,EAAE;wBACvE,KAAK,EAAE,IAAI;wBACX,UAAU,EAAE,KAAK;qBAClB,CAAoF,CAAC;oBAEtF,OAAO,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,QAAQ,EAAE;wBAClD,GAAG;4BACD,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,2FAA2F,CAC5F,CAAC;4BACF,OAAO,IAAI,CAAC;wBACd,CAAC;wBACD,UAAU,EAAE,KAAK;qBAClB,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC,CAAC;YACF,aAAa,EAAE,IAAI;SAC0D,CAAC;IAClF,CAAC;IAED,OAAO,gBAAgB,CAAC,OAAO,E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AC5B,OAAO,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,cAAc,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { Logger } from "../client.mjs";
2
+ import { ContentBlock, JSONOutputFormat, Message, OutputConfig, TextBlock, MessageCreateParams } from "../resources/messages/messages.mjs";
3
+ type Simplify<T> = {
4
+ [KeyType in keyof T]: T[KeyType];
5
+ } & {};
6
+ type AutoParseableOutputConfig = Omit<OutputConfig, 'format'> & {
7
+ format?: JSONOutputFormat | AutoParseableOutputFormat<any> | null;
8
+ };
9
+ export type ParseableMessageCreateParams = Simplify<Omit<MessageCreateParams, 'output_config'> & {
10
+ output_config?: AutoParseableOutputConfig | null;
11
+ }>;
12
+ export type ExtractParsedContentFromParams<Params extends ParseableMessageCreateParams> = Params['output_config'] extends {
13
+ format: AutoParseableOutputFormat<infer P>;
14
+ } ? P : null;
15
+ export type AutoParseableOutputFormat<ParsedT> = JSONOutputFormat & {
16
+ parse(content: string): ParsedT;
17
+ };
18
+ export type ParsedMessage<ParsedT> = Message & {
19
+ content: Array<ParsedContentBlock<ParsedT>>;
20
+ parsed_output: ParsedT | null;
21
+ };
22
+ export type ParsedContentBlock<ParsedT> = (TextBlock & {
23
+ parsed_output: ParsedT | null;
24
+ }) | Exclude<ContentBlock, TextBlock>;
25
+ export declare function maybeParseMessage<Params extends ParseableMessageCreateParams | null>(message: Message, params: Params, opts: {
26
+ logger: Logger;
27
+ }): ParsedMessage<ExtractParsedContentFromParams<NonNullable<Params>>>;
28
+ export declare function parseMessage<Params extends ParseableMessageCreateParams>(message: Message, params: Params, opts: {
29
+ logger: Logger;
30
+ }): ParsedMessage<ExtractParsedContentFromParams<Params>>;
31
+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GAAG;IAAE,aAAa,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC,GAC/C,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAQrC,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,4BAA4B,GAAG,IAAI,EAClF,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GACvB,aAAa,CAAC,8BAA8B,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAqBpE;AAED,wBAAgB,YAAY,CAAC,MAAM,SAAS,4BAA4B,EACtE,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GACvB,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC,CA2BvD"}
@@ -0,0 +1,32 @@
1
+ import type { Logger } from "../client.js";
2
+ import { ContentBlock, JSONOutputFormat, Message, OutputConfig, TextBlock, MessageCreateParams } from "../resources/messages/messages.js";
3
+ type Simplify<T> = {
4
+ [KeyType in keyof T]: T[KeyType];
5
+ } & {};
6
+ type AutoParseableOutputConfig = Omit<OutputConfig, 'format'> & {
7
+ format?: JSONOutputFormat | AutoParseableOutputFormat<any> | null;
8
+ };
9
+ export type ParseableMessageCreateParams = Simplify<Omit<MessageCreateParams, 'output_config'> & {
10
+ output_config?: AutoParseableOutputConfig | null;
11
+ }>;
12
+ export type ExtractParsedContentFromParams<Params extends ParseableMessageCreateParams> = Params['output_config'] extends {
13
+ format: AutoParseableOutputFormat<infer P>;
14
+ } ? P : null;
15
+ export type AutoParseableOutputFormat<ParsedT> = JSONOutputFormat & {
16
+ parse(content: string): ParsedT;
17
+ };
18
+ export type ParsedMessage<ParsedT> = Message & {
19
+ content: Array<ParsedContentBlock<ParsedT>>;
20
+ parsed_output: ParsedT | null;
21
+ };
22
+ export type ParsedContentBlock<ParsedT> = (TextBlock & {
23
+ parsed_output: ParsedT | null;
24
+ }) | Exclude<ContentBlock, TextBlock>;
25
+ export declare function maybeParseMessage<Params extends ParseableMessageCreateParams | null>(message: Message, params: Params, opts: {
26
+ logger: Logger;
27
+ }): ParsedMessage<ExtractParsedContentFromParams<NonNullable<Params>>>;
28
+ export declare function parseMessage<Params extends ParseableMessageCreateParams>(message: Message, params: Params, opts: {
29
+ logger: Logger;
30
+ }): ParsedMessage<ExtractParsedContentFromParams<Params>>;
31
+ export {};
32
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/lib/parser.ts"],"names":[],"mappings":"OAAO,KAAK,EAAE,MAAM,EAAE;OAEf,EACL,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,SAAS,EACT,mBAAmB,EACpB;AAGD,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;CAAE,GAAG,EAAE,CAAC;AAE7D,KAAK,yBAAyB,GAAG,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG;IAC9D,MAAM,CAAC,EAAE,gBAAgB,GAAG,yBAAyB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;CACnE,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CACjD,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,GAAG;IAC3C,aAAa,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;CAClD,CACF,CAAC;AAEF,MAAM,MAAM,8BAA8B,CAAC,MAAM,SAAS,4BAA4B,IACpF,MAAM,CAAC,eAAe,CAAC,SAAS;IAAE,MAAM,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,IAAI,CAAC;AAE5F,MAAM,MAAM,yBAAyB,CAAC,OAAO,IAAI,gBAAgB,GAAG;IAClE,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,OAAO,IAAI,OAAO,GAAG;IAC7C,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5C,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,OAAO,IAClC,CAAC,SAAS,GAAG;IAAE,aAAa,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC,GAC/C,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAQrC,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,4BAA4B,GAAG,IAAI,EAClF,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GACvB,aAAa,CAAC,8BAA8B,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAqBpE;AAED,wBAAgB,YAAY,CAAC,MAAM,SAAS,4BAA4B,EACtE,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GACvB,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC,CA2BvD"}
package/lib/parser.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maybeParseMessage = maybeParseMessage;
4
+ exports.parseMessage = parseMessage;
5
+ const error_1 = require("../core/error.js");
6
+ function getOutputFormat(params) {
7
+ return params?.output_config?.format;
8
+ }
9
+ function maybeParseMessage(message, params, opts) {
10
+ const outputFormat = getOutputFormat(params);
11
+ if (!params || !('parse' in (outputFormat ?? {}))) {
12
+ return {
13
+ ...message,
14
+ content: message.content.map((block) => {
15
+ if (block.type === 'text') {
16
+ const parsedBlock = Object.defineProperty({ ...block }, 'parsed_output', {
17
+ value: null,
18
+ enumerable: false,
19
+ });
20
+ return parsedBlock;
21
+ }
22
+ return block;
23
+ }),
24
+ parsed_output: null,
25
+ };
26
+ }
27
+ return parseMessage(message, params, opts);
28
+ }
29
+ function parseMessage(message, params, opts) {
30
+ let firstParsedOutput = null;
31
+ const content = message.content.map((block) => {
32
+ if (block.type === 'text') {
33
+ const parsedOutput = parseOutputFormat(params, block.text);
34
+ if (firstParsedOutput === null) {
35
+ firstParsedOutput = parsedOutput;
36
+ }
37
+ const parsedBlock = Object.defineProperty({ ...block }, 'parsed_output', {
38
+ value: parsedOutput,
39
+ enumerable: false,
40
+ });
41
+ return parsedBlock;
42
+ }
43
+ return block;
44
+ });
45
+ return {
46
+ ...message,
47
+ content,
48
+ parsed_output: firstParsedOutput,
49
+ };
50
+ }
51
+ function parseOutputFormat(params, content) {
52
+ const outputFormat = getOutputFormat(params);
53
+ if (outputFormat?.type !== 'json_schema') {
54
+ return null;
55
+ }
56
+ try {
57
+ if ('parse' in outputFormat) {
58
+ return outputFormat.parse(content);
59
+ }
60
+ return JSON.parse(content);
61
+ }
62
+ catch (error) {
63
+ throw new error_1.AnthropicError(`Failed to parse structured output: ${error}`);
64
+ }
65
+ }
66
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/lib/parser.ts"],"names":[],"mappings":";;AA8CA,8CAyBC;AAED,oCA+BC;AAvGD,4CAA+C;AAuC/C,SAAS,eAAe,CACtB,MAA2C;IAE3C,OAAO,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC;AACvC,CAAC;AAED,SAAgB,iBAAiB,CAC/B,OAAgB,EAChB,MAAc,EACd,IAAwB;IAExB,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,C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AO;QACP,aAAa,EAAE,iBAAiB;KACwB,CAAC;AAC7D,CAAC;AAED,SAAS,iBAAiB,CACxB,MAAc,EACd,OAAe;IAEf,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,YAAY,EAAE,IAAI,KAAK,aAAa,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,IAAI,OAAO,IAAI,YAAY,EAAE,CAAC;YAC5B,OAAO,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,sBAAc,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
package/lib/parser.mjs ADDED
@@ -0,0 +1,62 @@
1
+ import { AnthropicError } from "../core/error.mjs";
2
+ function getOutputFormat(params) {
3
+ return params?.output_config?.format;
4
+ }
5
+ export function maybeParseMessage(message, params, opts) {
6
+ const outputFormat = getOutputFormat(params);
7
+ if (!params || !('parse' in (outputFormat ?? {}))) {
8
+ return {
9
+ ...message,
10
+ content: message.content.map((block) => {
11
+ if (block.type === 'text') {
12
+ const parsedBlock = Object.defineProperty({ ...block }, 'parsed_output', {
13
+ value: null,
14
+ enumerable: false,
15
+ });
16
+ return parsedBlock;
17
+ }
18
+ return block;
19
+ }),
20
+ parsed_output: null,
21
+ };
22
+ }
23
+ return parseMessage(message, params, opts);
24
+ }
25
+ export function parseMessage(message, params, opts) {
26
+ let firstParsedOutput = null;
27
+ const content = message.content.map((block) => {
28
+ if (block.type === 'text') {
29
+ const parsedOutput = parseOutputFormat(params, block.text);
30
+ if (firstParsedOutput === null) {
31
+ firstParsedOutput = parsedOutput;
32
+ }
33
+ const parsedBlock = Object.defineProperty({ ...block }, 'parsed_output', {
34
+ value: parsedOutput,
35
+ enumerable: false,
36
+ });
37
+ return parsedBlock;
38
+ }
39
+ return block;
40
+ });
41
+ return {
42
+ ...message,
43
+ content,
44
+ parsed_output: firstParsedOutput,
45
+ };
46
+ }
47
+ function parseOutputFormat(params, content) {
48
+ const outputFormat = getOutputFormat(params);
49
+ if (outputFormat?.type !== 'json_schema') {
50
+ return null;
51
+ }
52
+ try {
53
+ if ('parse' in outputFormat) {
54
+ return outputFormat.parse(content);
55
+ }
56
+ return JSON.parse(content);
57
+ }
58
+ catch (error) {
59
+ throw new AnthropicError(`Failed to parse structured output: ${error}`);
60
+ }
61
+ }
62
+ //# sourceMappingURL=parser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.mjs","sourceRoot":"","sources":["../src/lib/parser.ts"],"names":[],"mappings":"OACO,EAAE,cAAc,EAAE;AAuCzB,SAAS,eAAe,CACtB,MAA2C;IAE3C,OAAO,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,OAAgB,EAChB,MAAc,EACd,IAAwB;IAExB,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAClD,OAAO;YACL,GAAG,OAAO;YACV,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBACrC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oBAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,EAAE;wBACvE,KAAK,EAAE,IAAI;wBACX,UAAU,EAAE,KAAK;qBAClB,CAA4E,CAAC;oBAE9E,OAAO,WAAW,CAAC;gBACrB,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC,CAA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AAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,cAAc,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Shared utilities for tracking SDK helper usage.
3
+ */
4
+ import type { BetaMessageParam, BetaToolUnion } from "../resources/beta.mjs";
5
+ /**
6
+ * Symbol used to mark objects created by SDK helpers for tracking.
7
+ * The value is the helper name (e.g., 'mcpTool', 'betaZodTool').
8
+ */
9
+ export declare const SDK_HELPER_SYMBOL: unique symbol;
10
+ type StainlessHelperObject = {
11
+ [SDK_HELPER_SYMBOL]: string;
12
+ };
13
+ export declare function wasCreatedByStainlessHelper(value: unknown): value is StainlessHelperObject;
14
+ /**
15
+ * Collects helper names from tools and messages arrays.
16
+ * Returns a deduplicated array of helper names found.
17
+ */
18
+ export declare function collectStainlessHelpers(tools: BetaToolUnion[] | undefined, messages: BetaMessageParam[] | undefined): string[];
19
+ /**
20
+ * Builds x-stainless-helper header value from tools and messages.
21
+ * Returns an empty object if no helpers are found.
22
+ */
23
+ export declare function stainlessHelperHeader(tools: BetaToolUnion[] | undefined, messages: BetaMessageParam[] | undefined): {
24
+ 'x-stainless-helper'?: string;
25
+ };
26
+ /**
27
+ * Builds x-stainless-helper header value from a file object.
28
+ * Returns an empty object if the file is not marked with a helper.
29
+ */
30
+ export declare function stainlessHelperHeaderFromFile(file: unknown): {
31
+ 'x-stainless-helper'?: string;
32
+ };
33
+ export {};
34
+ //# sourceMappingURL=stainless-helper-header.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stainless-helper-header.d.mts","sourceRoot":"","sources":["../src/lib/stainless-helper-header.ts"],"names":[],"mappings":"AAAA;;GAEG;OAEI,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE;AAE/C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,eAA0C,CAAC;AAEzE,KAAK,qBAAqB,GAAG;IAAE,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAE1F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,SAAS,GACvC,MAAM,EAAE,CA8BV;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,SAAS,GACvC;IAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAAE,CAInC;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG;IAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAAE,CAK9F"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Shared utilities for tracking SDK helper usage.
3
+ */
4
+ import type { BetaMessageParam, BetaToolUnion } from "../resources/beta.js";
5
+ /**
6
+ * Symbol used to mark objects created by SDK helpers for tracking.
7
+ * The value is the helper name (e.g., 'mcpTool', 'betaZodTool').
8
+ */
9
+ export declare const SDK_HELPER_SYMBOL: unique symbol;
10
+ type StainlessHelperObject = {
11
+ [SDK_HELPER_SYMBOL]: string;
12
+ };
13
+ export declare function wasCreatedByStainlessHelper(value: unknown): value is StainlessHelperObject;
14
+ /**
15
+ * Collects helper names from tools and messages arrays.
16
+ * Returns a deduplicated array of helper names found.
17
+ */
18
+ export declare function collectStainlessHelpers(tools: BetaToolUnion[] | undefined, messages: BetaMessageParam[] | undefined): string[];
19
+ /**
20
+ * Builds x-stainless-helper header value from tools and messages.
21
+ * Returns an empty object if no helpers are found.
22
+ */
23
+ export declare function stainlessHelperHeader(tools: BetaToolUnion[] | undefined, messages: BetaMessageParam[] | undefined): {
24
+ 'x-stainless-helper'?: string;
25
+ };
26
+ /**
27
+ * Builds x-stainless-helper header value from a file object.
28
+ * Returns an empty object if the file is not marked with a helper.
29
+ */
30
+ export declare function stainlessHelperHeaderFromFile(file: unknown): {
31
+ 'x-stainless-helper'?: string;
32
+ };
33
+ export {};
34
+ //# sourceMappingURL=stainless-helper-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stainless-helper-header.d.ts","sourceRoot":"","sources":["../src/lib/stainless-helper-header.ts"],"names":[],"mappings":"AAAA;;GAEG;OAEI,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE;AAE/C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,eAA0C,CAAC;AAEzE,KAAK,qBAAqB,GAAG;IAAE,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAE1F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,SAAS,GACvC,MAAM,EAAE,CA8BV;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAClC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,SAAS,GACvC;IAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAAE,CAInC;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG;IAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAAE,CAK9F"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /**
3
+ * Shared utilities for tracking SDK helper usage.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SDK_HELPER_SYMBOL = void 0;
7
+ exports.wasCreatedByStainlessHelper = wasCreatedByStainlessHelper;
8
+ exports.collectStainlessHelpers = collectStainlessHelpers;
9
+ exports.stainlessHelperHeader = stainlessHelperHeader;
10
+ exports.stainlessHelperHeaderFromFile = stainlessHelperHeaderFromFile;
11
+ /**
12
+ * Symbol used to mark objects created by SDK helpers for tracking.
13
+ * The value is the helper name (e.g., 'mcpTool', 'betaZodTool').
14
+ */
15
+ exports.SDK_HELPER_SYMBOL = Symbol('anthropic.sdk.stainlessHelper');
16
+ function wasCreatedByStainlessHelper(value) {
17
+ return typeof value === 'object' && value !== null && exports.SDK_HELPER_SYMBOL in value;
18
+ }
19
+ /**
20
+ * Collects helper names from tools and messages arrays.
21
+ * Returns a deduplicated array of helper names found.
22
+ */
23
+ function collectStainlessHelpers(tools, messages) {
24
+ const helpers = new Set();
25
+ // Collect from tools
26
+ if (tools) {
27
+ for (const tool of tools) {
28
+ if (wasCreatedByStainlessHelper(tool)) {
29
+ helpers.add(tool[exports.SDK_HELPER_SYMBOL]);
30
+ }
31
+ }
32
+ }
33
+ // Collect from messages and their content blocks
34
+ if (messages) {
35
+ for (const message of messages) {
36
+ if (wasCreatedByStainlessHelper(message)) {
37
+ helpers.add(message[exports.SDK_HELPER_SYMBOL]);
38
+ }
39
+ if (Array.isArray(message.content)) {
40
+ for (const block of message.content) {
41
+ if (wasCreatedByStainlessHelper(block)) {
42
+ helpers.add(block[exports.SDK_HELPER_SYMBOL]);
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ return Array.from(helpers);
49
+ }
50
+ /**
51
+ * Builds x-stainless-helper header value from tools and messages.
52
+ * Returns an empty object if no helpers are found.
53
+ */
54
+ function stainlessHelperHeader(tools, messages) {
55
+ const helpers = collectStainlessHelpers(tools, messages);
56
+ if (helpers.length === 0)
57
+ return {};
58
+ return { 'x-stainless-helper': helpers.join(', ') };
59
+ }
60
+ /**
61
+ * Builds x-stainless-helper header value from a file object.
62
+ * Returns an empty object if the file is not marked with a helper.
63
+ */
64
+ function stainlessHelperHeaderFromFile(file) {
65
+ if (wasCreatedByStainlessHelper(file)) {
66
+ return { 'x-stainless-helper': file[exports.SDK_HELPER_SYMBOL] };
67
+ }
68
+ return {};
69
+ }
70
+ //# sourceMappingURL=stainless-helper-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stainless-helper-header.js","sourceRoot":"","sources":["../src/lib/stainless-helper-header.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAYH,kEAEC;AAMD,0DAiCC;AAMD,sDAOC;AAMD,sEAKC;AAzED;;;GAGG;AACU,QAAA,iBAAiB,GAAG,MAAM,CAAC,+BAA+B,CAAC,CAAC;AAIzE,SAAgB,2BAA2B,CAAC,KAAc;IACxD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,yBAAiB,IAAI,KAAK,CAAC;AACnF,CAAC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,KAAkC,EAClC,QAAwC;IAExC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAElC,qBAAqB;IACrB,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,yBAAiB,CAAC,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IAED,iDAAiD;IACjD,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,2BAA2B,CAAC,OAAO,CAAC,EAAE,CAAC;gBACzC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,yBAAiB,CAAC,CAAC,CAAC;YAC1C,CAAC;YAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;oBACpC,IAAI,2BAA2B,CAAC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