@anthropic-ai/sdk 0.125.0 → 0.127.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 (417) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/client.d.mts +12 -11
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +12 -11
  5. package/client.d.ts.map +1 -1
  6. package/client.js +865 -845
  7. package/client.js.map +1 -1
  8. package/client.mjs +866 -840
  9. package/client.mjs.map +1 -1
  10. package/core/api-promise.js +71 -68
  11. package/core/api-promise.js.map +1 -1
  12. package/core/api-promise.mjs +71 -64
  13. package/core/api-promise.mjs.map +1 -1
  14. package/core/error.js +5 -2
  15. package/core/error.js.map +1 -1
  16. package/core/error.mjs +5 -2
  17. package/core/error.mjs.map +1 -1
  18. package/core/pagination.js +56 -50
  19. package/core/pagination.js.map +1 -1
  20. package/core/pagination.mjs +56 -41
  21. package/core/pagination.mjs.map +1 -1
  22. package/core/streaming.js +212 -209
  23. package/core/streaming.js.map +1 -1
  24. package/core/streaming.mjs +212 -209
  25. package/core/streaming.mjs.map +1 -1
  26. package/helpers/beta/mcp.js +14 -19
  27. package/helpers/beta/mcp.js.map +1 -1
  28. package/helpers/beta/mcp.mjs +14 -13
  29. package/helpers/beta/mcp.mjs.map +1 -1
  30. package/internal/constants.js +1 -1
  31. package/internal/constants.js.map +1 -1
  32. package/internal/decoders/jsonl.js +27 -24
  33. package/internal/decoders/jsonl.js.map +1 -1
  34. package/internal/decoders/jsonl.mjs +27 -24
  35. package/internal/decoders/jsonl.mjs.map +1 -1
  36. package/internal/decoders/line.js +52 -49
  37. package/internal/decoders/line.js.map +1 -1
  38. package/internal/decoders/line.mjs +52 -43
  39. package/internal/decoders/line.mjs.map +1 -1
  40. package/internal/file-store.js +256 -258
  41. package/internal/file-store.js.map +1 -1
  42. package/internal/file-store.mjs +256 -243
  43. package/internal/file-store.mjs.map +1 -1
  44. package/internal/node.browser.d.mts.map +1 -1
  45. package/internal/node.browser.d.ts.map +1 -1
  46. package/internal/node.browser.js.map +1 -1
  47. package/internal/node.browser.mjs +7 -7
  48. package/internal/node.browser.mjs.map +1 -1
  49. package/internal/parse.d.mts.map +1 -1
  50. package/internal/parse.d.ts.map +1 -1
  51. package/internal/parse.js +2 -2
  52. package/internal/parse.js.map +1 -1
  53. package/internal/parse.mjs +3 -3
  54. package/internal/parse.mjs.map +1 -1
  55. package/internal/shim-types.js +0 -6
  56. package/internal/shim-types.js.map +1 -1
  57. package/internal/shim-types.mjs +0 -6
  58. package/internal/shim-types.mjs.map +1 -1
  59. package/internal/shims.d.mts +3 -3
  60. package/internal/shims.d.mts.map +1 -1
  61. package/internal/shims.d.ts +3 -3
  62. package/internal/shims.d.ts.map +1 -1
  63. package/internal/shims.js +0 -6
  64. package/internal/shims.js.map +1 -1
  65. package/internal/shims.mjs +0 -6
  66. package/internal/shims.mjs.map +1 -1
  67. package/internal/stainless-helper-header.js +6 -6
  68. package/internal/stainless-helper-header.js.map +1 -1
  69. package/internal/utils/async-queue.js +66 -63
  70. package/internal/utils/async-queue.js.map +1 -1
  71. package/internal/utils/async-queue.mjs +66 -56
  72. package/internal/utils/async-queue.mjs.map +1 -1
  73. package/internal/utils/bytes.d.mts +1 -1
  74. package/internal/utils/bytes.d.mts.map +1 -1
  75. package/internal/utils/bytes.d.ts +1 -1
  76. package/internal/utils/bytes.d.ts.map +1 -1
  77. package/internal/utils/log.d.mts +7 -12
  78. package/internal/utils/log.d.mts.map +1 -1
  79. package/internal/utils/log.d.ts +7 -12
  80. package/internal/utils/log.d.ts.map +1 -1
  81. package/internal/utils/log.js +12 -0
  82. package/internal/utils/log.js.map +1 -1
  83. package/internal/utils/log.mjs +11 -0
  84. package/internal/utils/log.mjs.map +1 -1
  85. package/lib/BetaMessageStream.d.mts.map +1 -1
  86. package/lib/BetaMessageStream.d.ts.map +1 -1
  87. package/lib/BetaMessageStream.js +595 -590
  88. package/lib/BetaMessageStream.js.map +1 -1
  89. package/lib/BetaMessageStream.mjs +595 -590
  90. package/lib/BetaMessageStream.mjs.map +1 -1
  91. package/lib/MessageStream.js +544 -541
  92. package/lib/MessageStream.js.map +1 -1
  93. package/lib/MessageStream.mjs +544 -541
  94. package/lib/MessageStream.mjs.map +1 -1
  95. package/lib/beta-parser.d.mts +1 -3
  96. package/lib/beta-parser.d.mts.map +1 -1
  97. package/lib/beta-parser.d.ts +1 -3
  98. package/lib/beta-parser.d.ts.map +1 -1
  99. package/lib/beta-parser.js.map +1 -1
  100. package/lib/beta-parser.mjs.map +1 -1
  101. package/lib/environments/poller.js +180 -174
  102. package/lib/environments/poller.js.map +1 -1
  103. package/lib/environments/poller.mjs +180 -153
  104. package/lib/environments/poller.mjs.map +1 -1
  105. package/lib/environments/worker.js +375 -369
  106. package/lib/environments/worker.js.map +1 -1
  107. package/lib/environments/worker.mjs +374 -329
  108. package/lib/environments/worker.mjs.map +1 -1
  109. package/lib/internal/stub.d.mts +2 -0
  110. package/lib/internal/stub.d.mts.map +1 -0
  111. package/lib/internal/stub.d.ts +2 -0
  112. package/lib/internal/stub.d.ts.map +1 -0
  113. package/lib/internal/stub.js +6 -0
  114. package/lib/internal/stub.js.map +1 -0
  115. package/lib/internal/stub.mjs +3 -0
  116. package/lib/internal/stub.mjs.map +1 -0
  117. package/lib/internal/types.d.mts +5 -0
  118. package/lib/internal/types.d.mts.map +1 -0
  119. package/lib/internal/types.d.ts +5 -0
  120. package/lib/internal/types.d.ts.map +1 -0
  121. package/lib/internal/types.js +3 -0
  122. package/lib/internal/types.js.map +1 -0
  123. package/lib/internal/types.mjs +2 -0
  124. package/lib/internal/types.mjs.map +1 -0
  125. package/lib/middleware.js +6 -1
  126. package/lib/middleware.js.map +1 -1
  127. package/lib/middleware.mjs +6 -1
  128. package/lib/middleware.mjs.map +1 -1
  129. package/lib/parser.d.mts +1 -3
  130. package/lib/parser.d.mts.map +1 -1
  131. package/lib/parser.d.ts +1 -3
  132. package/lib/parser.d.ts.map +1 -1
  133. package/lib/parser.js.map +1 -1
  134. package/lib/parser.mjs.map +1 -1
  135. package/lib/tools/BetaToolRunner.d.mts +21 -6
  136. package/lib/tools/BetaToolRunner.d.mts.map +1 -1
  137. package/lib/tools/BetaToolRunner.d.ts +21 -6
  138. package/lib/tools/BetaToolRunner.d.ts.map +1 -1
  139. package/lib/tools/BetaToolRunner.js +415 -310
  140. package/lib/tools/BetaToolRunner.js.map +1 -1
  141. package/lib/tools/BetaToolRunner.mjs +414 -303
  142. package/lib/tools/BetaToolRunner.mjs.map +1 -1
  143. package/lib/tools/SessionToolRunner.js +241 -235
  144. package/lib/tools/SessionToolRunner.js.map +1 -1
  145. package/lib/tools/SessionToolRunner.mjs +241 -192
  146. package/lib/tools/SessionToolRunner.mjs.map +1 -1
  147. package/lib/tools/ToolError.js +39 -36
  148. package/lib/tools/ToolError.js.map +1 -1
  149. package/lib/tools/ToolError.mjs +39 -13
  150. package/lib/tools/ToolError.mjs.map +1 -1
  151. package/lib/transform-json-schema.js +7 -5
  152. package/lib/transform-json-schema.js.map +1 -1
  153. package/lib/transform-json-schema.mjs +7 -5
  154. package/lib/transform-json-schema.mjs.map +1 -1
  155. package/package.json +4 -3
  156. package/resources/beta/agents/agents.js +135 -132
  157. package/resources/beta/agents/agents.js.map +1 -1
  158. package/resources/beta/agents/agents.mjs +135 -132
  159. package/resources/beta/agents/agents.mjs.map +1 -1
  160. package/resources/beta/beta.d.mts +5 -5
  161. package/resources/beta/beta.d.mts.map +1 -1
  162. package/resources/beta/beta.d.ts +5 -5
  163. package/resources/beta/beta.d.ts.map +1 -1
  164. package/resources/beta/beta.js +39 -36
  165. package/resources/beta/beta.js.map +1 -1
  166. package/resources/beta/beta.mjs +39 -36
  167. package/resources/beta/beta.mjs.map +1 -1
  168. package/resources/beta/deployment-runs.d.mts +4 -0
  169. package/resources/beta/deployment-runs.d.mts.map +1 -1
  170. package/resources/beta/deployment-runs.d.ts +4 -0
  171. package/resources/beta/deployment-runs.d.ts.map +1 -1
  172. package/resources/beta/deployments.d.mts +5 -0
  173. package/resources/beta/deployments.d.mts.map +1 -1
  174. package/resources/beta/deployments.d.ts +5 -0
  175. package/resources/beta/deployments.d.ts.map +1 -1
  176. package/resources/beta/dreams.d.mts +19 -28
  177. package/resources/beta/dreams.d.mts.map +1 -1
  178. package/resources/beta/dreams.d.ts +19 -28
  179. package/resources/beta/dreams.d.ts.map +1 -1
  180. package/resources/beta/environments/environments.js +157 -154
  181. package/resources/beta/environments/environments.js.map +1 -1
  182. package/resources/beta/environments/environments.mjs +157 -154
  183. package/resources/beta/environments/environments.mjs.map +1 -1
  184. package/resources/beta/environments/work.js +255 -252
  185. package/resources/beta/environments/work.js.map +1 -1
  186. package/resources/beta/environments/work.mjs +255 -252
  187. package/resources/beta/environments/work.mjs.map +1 -1
  188. package/resources/beta/index.d.mts +2 -2
  189. package/resources/beta/index.d.mts.map +1 -1
  190. package/resources/beta/index.d.ts +2 -2
  191. package/resources/beta/index.d.ts.map +1 -1
  192. package/resources/beta/index.js.map +1 -1
  193. package/resources/beta/index.mjs.map +1 -1
  194. package/resources/beta/memory-stores/memories.d.mts +6 -0
  195. package/resources/beta/memory-stores/memories.d.mts.map +1 -1
  196. package/resources/beta/memory-stores/memories.d.ts +6 -0
  197. package/resources/beta/memory-stores/memories.d.ts.map +1 -1
  198. package/resources/beta/memory-stores/memory-stores.js +150 -147
  199. package/resources/beta/memory-stores/memory-stores.js.map +1 -1
  200. package/resources/beta/memory-stores/memory-stores.mjs +150 -147
  201. package/resources/beta/memory-stores/memory-stores.mjs.map +1 -1
  202. package/resources/beta/memory-stores/memory-versions.d.mts +7 -0
  203. package/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
  204. package/resources/beta/memory-stores/memory-versions.d.ts +7 -0
  205. package/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
  206. package/resources/beta/messages/batches.d.mts +12 -1
  207. package/resources/beta/messages/batches.d.mts.map +1 -1
  208. package/resources/beta/messages/batches.d.ts +12 -1
  209. package/resources/beta/messages/batches.d.ts.map +1 -1
  210. package/resources/beta/messages/index.d.mts +1 -1
  211. package/resources/beta/messages/index.d.mts.map +1 -1
  212. package/resources/beta/messages/index.d.ts +1 -1
  213. package/resources/beta/messages/index.d.ts.map +1 -1
  214. package/resources/beta/messages/index.js.map +1 -1
  215. package/resources/beta/messages/index.mjs.map +1 -1
  216. package/resources/beta/messages/messages.d.mts +239 -101
  217. package/resources/beta/messages/messages.d.mts.map +1 -1
  218. package/resources/beta/messages/messages.d.ts +239 -101
  219. package/resources/beta/messages/messages.d.ts.map +1 -1
  220. package/resources/beta/messages/messages.js +113 -110
  221. package/resources/beta/messages/messages.js.map +1 -1
  222. package/resources/beta/messages/messages.mjs +113 -110
  223. package/resources/beta/messages/messages.mjs.map +1 -1
  224. package/resources/beta/models.d.mts +22 -1
  225. package/resources/beta/models.d.mts.map +1 -1
  226. package/resources/beta/models.d.ts +22 -1
  227. package/resources/beta/models.d.ts.map +1 -1
  228. package/resources/beta/organization/federation/federation.js +11 -8
  229. package/resources/beta/organization/federation/federation.js.map +1 -1
  230. package/resources/beta/organization/federation/federation.mjs +11 -8
  231. package/resources/beta/organization/federation/federation.mjs.map +1 -1
  232. package/resources/beta/organization/federation/rules/rules.js +187 -184
  233. package/resources/beta/organization/federation/rules/rules.js.map +1 -1
  234. package/resources/beta/organization/federation/rules/rules.mjs +187 -184
  235. package/resources/beta/organization/federation/rules/rules.mjs.map +1 -1
  236. package/resources/beta/organization/index.d.mts +1 -1
  237. package/resources/beta/organization/index.d.mts.map +1 -1
  238. package/resources/beta/organization/index.d.ts +1 -1
  239. package/resources/beta/organization/index.d.ts.map +1 -1
  240. package/resources/beta/organization/index.js.map +1 -1
  241. package/resources/beta/organization/index.mjs.map +1 -1
  242. package/resources/beta/organization/organization.d.mts +2 -2
  243. package/resources/beta/organization/organization.d.mts.map +1 -1
  244. package/resources/beta/organization/organization.d.ts +2 -2
  245. package/resources/beta/organization/organization.d.ts.map +1 -1
  246. package/resources/beta/organization/organization.js +38 -35
  247. package/resources/beta/organization/organization.js.map +1 -1
  248. package/resources/beta/organization/organization.mjs +38 -35
  249. package/resources/beta/organization/organization.mjs.map +1 -1
  250. package/resources/beta/organization/rate-limits.d.mts +87 -5
  251. package/resources/beta/organization/rate-limits.d.mts.map +1 -1
  252. package/resources/beta/organization/rate-limits.d.ts +87 -5
  253. package/resources/beta/organization/rate-limits.d.ts.map +1 -1
  254. package/resources/beta/organization/service-accounts/service-accounts.js +163 -160
  255. package/resources/beta/organization/service-accounts/service-accounts.js.map +1 -1
  256. package/resources/beta/organization/service-accounts/service-accounts.mjs +163 -160
  257. package/resources/beta/organization/service-accounts/service-accounts.mjs.map +1 -1
  258. package/resources/beta/organization/workspaces/rate-limits.d.mts +9 -4
  259. package/resources/beta/organization/workspaces/rate-limits.d.mts.map +1 -1
  260. package/resources/beta/organization/workspaces/rate-limits.d.ts +9 -4
  261. package/resources/beta/organization/workspaces/rate-limits.d.ts.map +1 -1
  262. package/resources/beta/organization/workspaces/rate-limits.js.map +1 -1
  263. package/resources/beta/organization/workspaces/rate-limits.mjs.map +1 -1
  264. package/resources/beta/organization/workspaces/workspaces.d.mts +3 -3
  265. package/resources/beta/organization/workspaces/workspaces.d.mts.map +1 -1
  266. package/resources/beta/organization/workspaces/workspaces.d.ts +3 -3
  267. package/resources/beta/organization/workspaces/workspaces.d.ts.map +1 -1
  268. package/resources/beta/organization/workspaces/workspaces.js +97 -94
  269. package/resources/beta/organization/workspaces/workspaces.js.map +1 -1
  270. package/resources/beta/organization/workspaces/workspaces.mjs +97 -94
  271. package/resources/beta/organization/workspaces/workspaces.mjs.map +1 -1
  272. package/resources/beta/sessions/events.d.mts +12 -21
  273. package/resources/beta/sessions/events.d.mts.map +1 -1
  274. package/resources/beta/sessions/events.d.ts +12 -21
  275. package/resources/beta/sessions/events.d.ts.map +1 -1
  276. package/resources/beta/sessions/events.js +118 -115
  277. package/resources/beta/sessions/events.js.map +1 -1
  278. package/resources/beta/sessions/events.mjs +118 -115
  279. package/resources/beta/sessions/events.mjs.map +1 -1
  280. package/resources/beta/sessions/resources.d.mts +0 -3
  281. package/resources/beta/sessions/resources.d.mts.map +1 -1
  282. package/resources/beta/sessions/resources.d.ts +0 -3
  283. package/resources/beta/sessions/resources.d.ts.map +1 -1
  284. package/resources/beta/sessions/sessions.d.mts +8 -2
  285. package/resources/beta/sessions/sessions.d.mts.map +1 -1
  286. package/resources/beta/sessions/sessions.d.ts +8 -2
  287. package/resources/beta/sessions/sessions.d.ts.map +1 -1
  288. package/resources/beta/sessions/sessions.js +161 -158
  289. package/resources/beta/sessions/sessions.js.map +1 -1
  290. package/resources/beta/sessions/sessions.mjs +161 -158
  291. package/resources/beta/sessions/sessions.mjs.map +1 -1
  292. package/resources/beta/sessions/threads/threads.js +86 -83
  293. package/resources/beta/sessions/threads/threads.js.map +1 -1
  294. package/resources/beta/sessions/threads/threads.mjs +86 -83
  295. package/resources/beta/sessions/threads/threads.mjs.map +1 -1
  296. package/resources/beta/skills/skills.js +104 -101
  297. package/resources/beta/skills/skills.js.map +1 -1
  298. package/resources/beta/skills/skills.mjs +104 -101
  299. package/resources/beta/skills/skills.mjs.map +1 -1
  300. package/resources/beta/tunnels/certificates.d.mts +2 -2
  301. package/resources/beta/tunnels/certificates.d.ts +2 -2
  302. package/resources/beta/tunnels/tunnels.js +188 -185
  303. package/resources/beta/tunnels/tunnels.js.map +1 -1
  304. package/resources/beta/tunnels/tunnels.mjs +188 -185
  305. package/resources/beta/tunnels/tunnels.mjs.map +1 -1
  306. package/resources/beta/user-profiles.d.mts +45 -0
  307. package/resources/beta/user-profiles.d.mts.map +1 -1
  308. package/resources/beta/user-profiles.d.ts +45 -0
  309. package/resources/beta/user-profiles.d.ts.map +1 -1
  310. package/resources/beta/user-profiles.js +25 -10
  311. package/resources/beta/user-profiles.js.map +1 -1
  312. package/resources/beta/user-profiles.mjs +25 -10
  313. package/resources/beta/user-profiles.mjs.map +1 -1
  314. package/resources/beta/vaults/credentials.d.mts +19 -19
  315. package/resources/beta/vaults/credentials.d.mts.map +1 -1
  316. package/resources/beta/vaults/credentials.d.ts +19 -19
  317. package/resources/beta/vaults/credentials.d.ts.map +1 -1
  318. package/resources/beta/vaults/vaults.js +156 -153
  319. package/resources/beta/vaults/vaults.js.map +1 -1
  320. package/resources/beta/vaults/vaults.mjs +156 -153
  321. package/resources/beta/vaults/vaults.mjs.map +1 -1
  322. package/resources/completions.d.mts +1 -1
  323. package/resources/completions.d.ts +1 -1
  324. package/resources/index.d.mts +1 -1
  325. package/resources/index.d.mts.map +1 -1
  326. package/resources/index.d.ts +1 -1
  327. package/resources/index.d.ts.map +1 -1
  328. package/resources/index.js.map +1 -1
  329. package/resources/index.mjs.map +1 -1
  330. package/resources/messages/index.d.mts +1 -1
  331. package/resources/messages/index.d.mts.map +1 -1
  332. package/resources/messages/index.d.ts +1 -1
  333. package/resources/messages/index.d.ts.map +1 -1
  334. package/resources/messages/index.js.map +1 -1
  335. package/resources/messages/index.mjs.map +1 -1
  336. package/resources/messages/messages.d.mts +100 -63
  337. package/resources/messages/messages.d.mts.map +1 -1
  338. package/resources/messages/messages.d.ts +100 -63
  339. package/resources/messages/messages.d.ts.map +1 -1
  340. package/resources/messages/messages.js +115 -112
  341. package/resources/messages/messages.js.map +1 -1
  342. package/resources/messages/messages.mjs +115 -112
  343. package/resources/messages/messages.mjs.map +1 -1
  344. package/resources/skills/skills.js +88 -85
  345. package/resources/skills/skills.js.map +1 -1
  346. package/resources/skills/skills.mjs +88 -85
  347. package/resources/skills/skills.mjs.map +1 -1
  348. package/resources/top-level.js +0 -1
  349. package/resources/top-level.js.map +1 -1
  350. package/resources/top-level.mjs +0 -1
  351. package/resources/top-level.mjs.map +1 -1
  352. package/src/client.ts +95 -72
  353. package/src/internal/node.browser.ts +7 -7
  354. package/src/internal/parse.ts +8 -11
  355. package/src/internal/shims.ts +4 -3
  356. package/src/internal/utils/bytes.ts +1 -1
  357. package/src/internal/utils/log.ts +16 -2
  358. package/src/lib/BetaMessageStream.ts +7 -5
  359. package/src/lib/beta-parser.ts +1 -3
  360. package/src/lib/internal/stub.ts +2 -0
  361. package/src/lib/internal/types.ts +2 -0
  362. package/src/lib/middleware.ts +6 -1
  363. package/src/lib/parser.ts +1 -3
  364. package/src/lib/tools/BetaToolRunner.ts +157 -24
  365. package/src/lib/transform-json-schema.ts +8 -6
  366. package/src/resources/beta/beta.ts +24 -1
  367. package/src/resources/beta/deployment-runs.ts +4 -0
  368. package/src/resources/beta/deployments.ts +5 -0
  369. package/src/resources/beta/dreams.ts +19 -28
  370. package/src/resources/beta/index.ts +11 -0
  371. package/src/resources/beta/memory-stores/memories.ts +6 -0
  372. package/src/resources/beta/memory-stores/memory-versions.ts +7 -0
  373. package/src/resources/beta/messages/batches.ts +13 -1
  374. package/src/resources/beta/messages/index.ts +10 -0
  375. package/src/resources/beta/messages/messages.ts +289 -100
  376. package/src/resources/beta/models.ts +25 -0
  377. package/src/resources/beta/organization/index.ts +6 -0
  378. package/src/resources/beta/organization/organization.ts +12 -0
  379. package/src/resources/beta/organization/rate-limits.ts +112 -4
  380. package/src/resources/beta/organization/workspaces/rate-limits.ts +16 -4
  381. package/src/resources/beta/organization/workspaces/workspaces.ts +3 -3
  382. package/src/resources/beta/sessions/events.ts +12 -21
  383. package/src/resources/beta/sessions/resources.ts +0 -3
  384. package/src/resources/beta/sessions/sessions.ts +8 -2
  385. package/src/resources/beta/tunnels/certificates.ts +2 -2
  386. package/src/resources/beta/user-profiles.ts +75 -10
  387. package/src/resources/beta/vaults/credentials.ts +19 -19
  388. package/src/resources/completions.ts +1 -1
  389. package/src/resources/index.ts +6 -0
  390. package/src/resources/messages/index.ts +6 -0
  391. package/src/resources/messages/messages.ts +128 -62
  392. package/src/tsconfig.json +13 -3
  393. package/src/version.ts +1 -1
  394. package/tools/agent-toolset/fs-util.js +0 -6
  395. package/tools/agent-toolset/fs-util.js.map +1 -1
  396. package/tools/agent-toolset/fs-util.mjs +0 -6
  397. package/tools/agent-toolset/fs-util.mjs.map +1 -1
  398. package/tools/agent-toolset/memories.js +4 -4
  399. package/tools/agent-toolset/memories.js.map +1 -1
  400. package/tools/agent-toolset/memories.mjs +2 -2
  401. package/tools/agent-toolset/memories.mjs.map +1 -1
  402. package/tools/agent-toolset/node.browser.js +12 -12
  403. package/tools/agent-toolset/node.browser.js.map +1 -1
  404. package/tools/agent-toolset/node.js +142 -139
  405. package/tools/agent-toolset/node.js.map +1 -1
  406. package/tools/agent-toolset/node.mjs +132 -125
  407. package/tools/agent-toolset/node.mjs.map +1 -1
  408. package/tools/agent-toolset/skills.js +5 -5
  409. package/tools/agent-toolset/skills.js.map +1 -1
  410. package/tools/agent-toolset/sync-interval.js +3 -3
  411. package/tools/agent-toolset/sync-interval.js.map +1 -1
  412. package/tools/memory/node.browser.js +2 -2
  413. package/tools/memory/node.browser.js.map +1 -1
  414. package/version.d.mts +1 -1
  415. package/version.d.ts +1 -1
  416. package/version.js +1 -1
  417. package/version.mjs +1 -1
@@ -10,123 +10,126 @@ const parser_1 = require("../../lib/parser.js");
10
10
  const BatchesAPI = tslib_1.__importStar(require("./batches.js"));
11
11
  const batches_1 = require("./batches.js");
12
12
  const constants_1 = require("../../internal/constants.js");
13
- class Messages extends resource_1.APIResource {
14
- constructor() {
15
- super(...arguments);
16
- this.batches = new BatchesAPI.Batches(this._client);
17
- }
18
- create(params, options) {
19
- const { user_profile_id, workspace_id, ...body } = params;
20
- if (body.model in DEPRECATED_MODELS) {
21
- console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
13
+ var Messages = /* @__PURE__ */ (() => {
14
+ class Messages extends resource_1.APIResource {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.batches = new BatchesAPI.Batches(this._client);
22
18
  }
23
- if (MODELS_TO_WARN_WITH_THINKING_ENABLED.includes(body.model) &&
24
- body.thinking &&
25
- body.thinking.type === 'enabled') {
26
- console.warn(`Using Claude with ${body.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);
19
+ create(params, options) {
20
+ const { user_profile_id, workspace_id, ...body } = params;
21
+ if (body.model in DEPRECATED_MODELS) {
22
+ console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
23
+ }
24
+ if (MODELS_TO_WARN_WITH_THINKING_ENABLED.includes(body.model) &&
25
+ body.thinking &&
26
+ body.thinking.type === 'enabled') {
27
+ console.warn(`Using Claude with ${body.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);
28
+ }
29
+ let timeout = options?.timeout ?? this._client._options.timeout;
30
+ if (!body.stream && timeout == null) {
31
+ const maxNonstreamingTokens = constants_1.MODEL_NONSTREAMING_TOKENS[body.model] ?? undefined;
32
+ timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
33
+ }
34
+ // Collect helper info from tools and messages
35
+ const helperHeader = (0, stainless_helper_header_1.stainlessHelperHeader)(body.tools, body.messages);
36
+ return this._client.post('/v1/messages', {
37
+ body,
38
+ timeout: timeout ?? 600000,
39
+ ...options,
40
+ headers: (0, headers_1.buildHeaders)([
41
+ {
42
+ ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
43
+ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
44
+ },
45
+ helperHeader,
46
+ options?.headers,
47
+ ]),
48
+ stream: params.stream ?? false,
49
+ });
27
50
  }
28
- let timeout = options?.timeout ?? this._client._options.timeout;
29
- if (!body.stream && timeout == null) {
30
- const maxNonstreamingTokens = constants_1.MODEL_NONSTREAMING_TOKENS[body.model] ?? undefined;
31
- timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
51
+ /**
52
+ * Send a structured list of input messages with text and/or image content, along with an expected `output_config.format` and
53
+ * the response will be automatically parsed and available in the `parsed_output` property of the message.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const message = await client.messages.parse({
58
+ * model: 'claude-sonnet-4-5-20250929',
59
+ * max_tokens: 1024,
60
+ * messages: [{ role: 'user', content: 'What is 2+2?' }],
61
+ * output_config: {
62
+ * format: zodOutputFormat(z.object({ answer: z.number() })),
63
+ * },
64
+ * });
65
+ *
66
+ * console.log(message.parsed_output?.answer); // 4
67
+ * ```
68
+ */
69
+ parse(params, options) {
70
+ return this.create(params, options).then((message) => (0, parser_1.parseMessage)(message, params, { logger: this._client.logger ?? console }));
71
+ }
72
+ /**
73
+ * Create a Message stream.
74
+ *
75
+ * If `output_config.format` is provided with a parseable format (like `zodOutputFormat()`),
76
+ * the final message will include a `parsed_output` property with the parsed content.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * const stream = client.messages.stream({
81
+ * model: 'claude-sonnet-4-5-20250929',
82
+ * max_tokens: 1024,
83
+ * messages: [{ role: 'user', content: 'What is 2+2?' }],
84
+ * output_config: {
85
+ * format: zodOutputFormat(z.object({ answer: z.number() })),
86
+ * },
87
+ * });
88
+ *
89
+ * const message = await stream.finalMessage();
90
+ * console.log(message.parsed_output?.answer); // 4
91
+ * ```
92
+ */
93
+ stream(body, options) {
94
+ return MessageStream_1.MessageStream.createMessage(this, body, options, { logger: this._client.logger ?? console });
95
+ }
96
+ /**
97
+ * Count the number of tokens in a Message.
98
+ *
99
+ * The Token Count API can be used to count the number of tokens in a Message,
100
+ * including tools, images, and documents, without creating it.
101
+ *
102
+ * Learn more about token counting in our
103
+ * [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * const messageTokensCount =
108
+ * await client.messages.countTokens({
109
+ * messages: [{ content: 'Hello, world', role: 'user' }],
110
+ * model: 'claude-opus-5',
111
+ * });
112
+ * ```
113
+ */
114
+ countTokens(params, options) {
115
+ const { user_profile_id, workspace_id, ...body } = params;
116
+ return this._client.post('/v1/messages/count_tokens', {
117
+ body,
118
+ ...options,
119
+ headers: (0, headers_1.buildHeaders)([
120
+ {
121
+ ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
122
+ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
123
+ },
124
+ options?.headers,
125
+ ]),
126
+ });
32
127
  }
33
- // Collect helper info from tools and messages
34
- const helperHeader = (0, stainless_helper_header_1.stainlessHelperHeader)(body.tools, body.messages);
35
- return this._client.post('/v1/messages', {
36
- body,
37
- timeout: timeout ?? 600000,
38
- ...options,
39
- headers: (0, headers_1.buildHeaders)([
40
- {
41
- ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
42
- ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
43
- },
44
- helperHeader,
45
- options?.headers,
46
- ]),
47
- stream: params.stream ?? false,
48
- });
49
- }
50
- /**
51
- * Send a structured list of input messages with text and/or image content, along with an expected `output_config.format` and
52
- * the response will be automatically parsed and available in the `parsed_output` property of the message.
53
- *
54
- * @example
55
- * ```ts
56
- * const message = await client.messages.parse({
57
- * model: 'claude-sonnet-4-5-20250929',
58
- * max_tokens: 1024,
59
- * messages: [{ role: 'user', content: 'What is 2+2?' }],
60
- * output_config: {
61
- * format: zodOutputFormat(z.object({ answer: z.number() })),
62
- * },
63
- * });
64
- *
65
- * console.log(message.parsed_output?.answer); // 4
66
- * ```
67
- */
68
- parse(params, options) {
69
- return this.create(params, options).then((message) => (0, parser_1.parseMessage)(message, params, { logger: this._client.logger ?? console }));
70
- }
71
- /**
72
- * Create a Message stream.
73
- *
74
- * If `output_config.format` is provided with a parseable format (like `zodOutputFormat()`),
75
- * the final message will include a `parsed_output` property with the parsed content.
76
- *
77
- * @example
78
- * ```ts
79
- * const stream = client.messages.stream({
80
- * model: 'claude-sonnet-4-5-20250929',
81
- * max_tokens: 1024,
82
- * messages: [{ role: 'user', content: 'What is 2+2?' }],
83
- * output_config: {
84
- * format: zodOutputFormat(z.object({ answer: z.number() })),
85
- * },
86
- * });
87
- *
88
- * const message = await stream.finalMessage();
89
- * console.log(message.parsed_output?.answer); // 4
90
- * ```
91
- */
92
- stream(body, options) {
93
- return MessageStream_1.MessageStream.createMessage(this, body, options, { logger: this._client.logger ?? console });
94
- }
95
- /**
96
- * Count the number of tokens in a Message.
97
- *
98
- * The Token Count API can be used to count the number of tokens in a Message,
99
- * including tools, images, and documents, without creating it.
100
- *
101
- * Learn more about token counting in our
102
- * [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)
103
- *
104
- * @example
105
- * ```ts
106
- * const messageTokensCount =
107
- * await client.messages.countTokens({
108
- * messages: [{ content: 'Hello, world', role: 'user' }],
109
- * model: 'claude-opus-5',
110
- * });
111
- * ```
112
- */
113
- countTokens(params, options) {
114
- const { user_profile_id, workspace_id, ...body } = params;
115
- return this._client.post('/v1/messages/count_tokens', {
116
- body,
117
- ...options,
118
- headers: (0, headers_1.buildHeaders)([
119
- {
120
- ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
121
- ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
122
- },
123
- options?.headers,
124
- ]),
125
- });
126
128
  }
127
- }
129
+ Messages.Batches = batches_1.Batches;
130
+ return Messages;
131
+ })();
128
132
  exports.Messages = Messages;
129
133
  const DEPRECATED_MODELS = {};
130
134
  const MODELS_TO_WARN_WITH_THINKING_ENABLED = ['claude-mythos-preview', 'claude-opus-4-6'];
131
- Messages.Batches = batches_1.Batches;
132
135
  //# sourceMappingURL=messages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":";;;;AACA,qDAAkD;AAElD,uDAA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AC;QACL,CAAC;KACF;IAg1JD,QAAQ,CAAC,OAAO,GAAG,iBAAO,CAAC;;;AAz/J3B,4BAyKC;AA26ED,MAAM,iBAAiB,GAEnB,EAAE,CAAC;AAEP,MAAM,oCAAoC,GAAY,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAC"}
@@ -6,122 +6,125 @@ import { parseMessage, } from "../../lib/parser.mjs";
6
6
  import * as BatchesAPI from "./batches.mjs";
7
7
  import { Batches, } from "./batches.mjs";
8
8
  import { MODEL_NONSTREAMING_TOKENS } from "../../internal/constants.mjs";
9
- export class Messages extends APIResource {
10
- constructor() {
11
- super(...arguments);
12
- this.batches = new BatchesAPI.Batches(this._client);
13
- }
14
- create(params, options) {
15
- const { user_profile_id, workspace_id, ...body } = params;
16
- if (body.model in DEPRECATED_MODELS) {
17
- console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
9
+ export var Messages = /* @__PURE__ */ (() => {
10
+ class Messages extends APIResource {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.batches = new BatchesAPI.Batches(this._client);
18
14
  }
19
- if (MODELS_TO_WARN_WITH_THINKING_ENABLED.includes(body.model) &&
20
- body.thinking &&
21
- body.thinking.type === 'enabled') {
22
- console.warn(`Using Claude with ${body.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);
15
+ create(params, options) {
16
+ const { user_profile_id, workspace_id, ...body } = params;
17
+ if (body.model in DEPRECATED_MODELS) {
18
+ console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
19
+ }
20
+ if (MODELS_TO_WARN_WITH_THINKING_ENABLED.includes(body.model) &&
21
+ body.thinking &&
22
+ body.thinking.type === 'enabled') {
23
+ console.warn(`Using Claude with ${body.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);
24
+ }
25
+ let timeout = options?.timeout ?? this._client._options.timeout;
26
+ if (!body.stream && timeout == null) {
27
+ const maxNonstreamingTokens = MODEL_NONSTREAMING_TOKENS[body.model] ?? undefined;
28
+ timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
29
+ }
30
+ // Collect helper info from tools and messages
31
+ const helperHeader = stainlessHelperHeader(body.tools, body.messages);
32
+ return this._client.post('/v1/messages', {
33
+ body,
34
+ timeout: timeout ?? 600000,
35
+ ...options,
36
+ headers: buildHeaders([
37
+ {
38
+ ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
39
+ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
40
+ },
41
+ helperHeader,
42
+ options?.headers,
43
+ ]),
44
+ stream: params.stream ?? false,
45
+ });
23
46
  }
24
- let timeout = options?.timeout ?? this._client._options.timeout;
25
- if (!body.stream && timeout == null) {
26
- const maxNonstreamingTokens = MODEL_NONSTREAMING_TOKENS[body.model] ?? undefined;
27
- timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
47
+ /**
48
+ * Send a structured list of input messages with text and/or image content, along with an expected `output_config.format` and
49
+ * the response will be automatically parsed and available in the `parsed_output` property of the message.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const message = await client.messages.parse({
54
+ * model: 'claude-sonnet-4-5-20250929',
55
+ * max_tokens: 1024,
56
+ * messages: [{ role: 'user', content: 'What is 2+2?' }],
57
+ * output_config: {
58
+ * format: zodOutputFormat(z.object({ answer: z.number() })),
59
+ * },
60
+ * });
61
+ *
62
+ * console.log(message.parsed_output?.answer); // 4
63
+ * ```
64
+ */
65
+ parse(params, options) {
66
+ return this.create(params, options).then((message) => parseMessage(message, params, { logger: this._client.logger ?? console }));
67
+ }
68
+ /**
69
+ * Create a Message stream.
70
+ *
71
+ * If `output_config.format` is provided with a parseable format (like `zodOutputFormat()`),
72
+ * the final message will include a `parsed_output` property with the parsed content.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const stream = client.messages.stream({
77
+ * model: 'claude-sonnet-4-5-20250929',
78
+ * max_tokens: 1024,
79
+ * messages: [{ role: 'user', content: 'What is 2+2?' }],
80
+ * output_config: {
81
+ * format: zodOutputFormat(z.object({ answer: z.number() })),
82
+ * },
83
+ * });
84
+ *
85
+ * const message = await stream.finalMessage();
86
+ * console.log(message.parsed_output?.answer); // 4
87
+ * ```
88
+ */
89
+ stream(body, options) {
90
+ return MessageStream.createMessage(this, body, options, { logger: this._client.logger ?? console });
91
+ }
92
+ /**
93
+ * Count the number of tokens in a Message.
94
+ *
95
+ * The Token Count API can be used to count the number of tokens in a Message,
96
+ * including tools, images, and documents, without creating it.
97
+ *
98
+ * Learn more about token counting in our
99
+ * [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * const messageTokensCount =
104
+ * await client.messages.countTokens({
105
+ * messages: [{ content: 'Hello, world', role: 'user' }],
106
+ * model: 'claude-opus-5',
107
+ * });
108
+ * ```
109
+ */
110
+ countTokens(params, options) {
111
+ const { user_profile_id, workspace_id, ...body } = params;
112
+ return this._client.post('/v1/messages/count_tokens', {
113
+ body,
114
+ ...options,
115
+ headers: buildHeaders([
116
+ {
117
+ ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
118
+ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
119
+ },
120
+ options?.headers,
121
+ ]),
122
+ });
28
123
  }
29
- // Collect helper info from tools and messages
30
- const helperHeader = stainlessHelperHeader(body.tools, body.messages);
31
- return this._client.post('/v1/messages', {
32
- body,
33
- timeout: timeout ?? 600000,
34
- ...options,
35
- headers: buildHeaders([
36
- {
37
- ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
38
- ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
39
- },
40
- helperHeader,
41
- options?.headers,
42
- ]),
43
- stream: params.stream ?? false,
44
- });
45
- }
46
- /**
47
- * Send a structured list of input messages with text and/or image content, along with an expected `output_config.format` and
48
- * the response will be automatically parsed and available in the `parsed_output` property of the message.
49
- *
50
- * @example
51
- * ```ts
52
- * const message = await client.messages.parse({
53
- * model: 'claude-sonnet-4-5-20250929',
54
- * max_tokens: 1024,
55
- * messages: [{ role: 'user', content: 'What is 2+2?' }],
56
- * output_config: {
57
- * format: zodOutputFormat(z.object({ answer: z.number() })),
58
- * },
59
- * });
60
- *
61
- * console.log(message.parsed_output?.answer); // 4
62
- * ```
63
- */
64
- parse(params, options) {
65
- return this.create(params, options).then((message) => parseMessage(message, params, { logger: this._client.logger ?? console }));
66
- }
67
- /**
68
- * Create a Message stream.
69
- *
70
- * If `output_config.format` is provided with a parseable format (like `zodOutputFormat()`),
71
- * the final message will include a `parsed_output` property with the parsed content.
72
- *
73
- * @example
74
- * ```ts
75
- * const stream = client.messages.stream({
76
- * model: 'claude-sonnet-4-5-20250929',
77
- * max_tokens: 1024,
78
- * messages: [{ role: 'user', content: 'What is 2+2?' }],
79
- * output_config: {
80
- * format: zodOutputFormat(z.object({ answer: z.number() })),
81
- * },
82
- * });
83
- *
84
- * const message = await stream.finalMessage();
85
- * console.log(message.parsed_output?.answer); // 4
86
- * ```
87
- */
88
- stream(body, options) {
89
- return MessageStream.createMessage(this, body, options, { logger: this._client.logger ?? console });
90
- }
91
- /**
92
- * Count the number of tokens in a Message.
93
- *
94
- * The Token Count API can be used to count the number of tokens in a Message,
95
- * including tools, images, and documents, without creating it.
96
- *
97
- * Learn more about token counting in our
98
- * [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)
99
- *
100
- * @example
101
- * ```ts
102
- * const messageTokensCount =
103
- * await client.messages.countTokens({
104
- * messages: [{ content: 'Hello, world', role: 'user' }],
105
- * model: 'claude-opus-5',
106
- * });
107
- * ```
108
- */
109
- countTokens(params, options) {
110
- const { user_profile_id, workspace_id, ...body } = params;
111
- return this._client.post('/v1/messages/count_tokens', {
112
- body,
113
- ...options,
114
- headers: buildHeaders([
115
- {
116
- ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
117
- ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
118
- },
119
- options?.headers,
120
- ]),
121
- });
122
124
  }
123
- }
125
+ Messages.Batches = Batches;
126
+ return Messages;
127
+ })();
124
128
  const DEPRECATED_MODELS = {};
125
129
  const MODELS_TO_WARN_WITH_THINKING_ENABLED = ['claude-mythos-preview', 'claude-opus-4-6'];
126
- Messages.Batches = Batches;
127
130
  //# sourceMappingURL=messages.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAElD,OAAO,EAAE,YAAY,EAAE,mCAA+B;AAEtD,OAAO,EAAE,qBAAqB,EAAE,mDAA+C;AAC/E,OAAO,EAAE,aAAa,EAAE,oCAAgC;AACxD,OAAO,EACL,YAAY,GAIb,6BAAyB;AAC1B,OAAO,KAAK,UAAU,sBAAkB;AACxC,OAAO,EAOL,OAAO,GAWR,sBAAkB;AAGnB,OAAO,EAAE,yBAAyB,EAAE,qCAAiC;AAErE,MAAM,OAAO,QAAS,SAAQ,WAAW;IAAzC;;QACE,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAwKrE,CAAC;IA1IC,MAAM,CACJ,MAA2B,EAC3B,OAAwB;QAExB,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC1D,IAAI,IAAI,CAAC,KAAK,I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