@anthropic-ai/sdk 0.120.0 → 0.121.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 (364) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/helpers/beta/standard-schema.d.mts +45 -0
  3. package/helpers/beta/standard-schema.d.mts.map +1 -0
  4. package/helpers/beta/standard-schema.d.ts +45 -0
  5. package/helpers/beta/standard-schema.d.ts.map +1 -0
  6. package/helpers/beta/standard-schema.js +58 -0
  7. package/helpers/beta/standard-schema.js.map +1 -0
  8. package/helpers/beta/standard-schema.mjs +54 -0
  9. package/helpers/beta/standard-schema.mjs.map +1 -0
  10. package/internal/detect-platform.js +1 -1
  11. package/internal/detect-platform.js.map +1 -1
  12. package/internal/detect-platform.mjs +1 -1
  13. package/internal/detect-platform.mjs.map +1 -1
  14. package/internal/utils/values.d.mts +6 -0
  15. package/internal/utils/values.d.mts.map +1 -1
  16. package/internal/utils/values.d.ts +6 -0
  17. package/internal/utils/values.d.ts.map +1 -1
  18. package/internal/utils/values.js +7 -0
  19. package/internal/utils/values.js.map +1 -1
  20. package/internal/utils/values.mjs +6 -0
  21. package/internal/utils/values.mjs.map +1 -1
  22. package/lib/BetaMessageStream.d.mts.map +1 -1
  23. package/lib/BetaMessageStream.d.ts.map +1 -1
  24. package/lib/BetaMessageStream.js +3 -4
  25. package/lib/BetaMessageStream.js.map +1 -1
  26. package/lib/BetaMessageStream.mjs +1 -2
  27. package/lib/BetaMessageStream.mjs.map +1 -1
  28. package/lib/MessageStream.d.mts.map +1 -1
  29. package/lib/MessageStream.d.ts.map +1 -1
  30. package/lib/MessageStream.js +3 -4
  31. package/lib/MessageStream.js.map +1 -1
  32. package/lib/MessageStream.mjs +1 -2
  33. package/lib/MessageStream.mjs.map +1 -1
  34. package/lib/sessions/accumulate.d.mts.map +1 -1
  35. package/lib/sessions/accumulate.d.ts.map +1 -1
  36. package/lib/sessions/accumulate.js +3 -4
  37. package/lib/sessions/accumulate.js.map +1 -1
  38. package/lib/sessions/accumulate.mjs +1 -2
  39. package/lib/sessions/accumulate.mjs.map +1 -1
  40. package/lib/standard-schema.d.mts +131 -0
  41. package/lib/standard-schema.d.mts.map +1 -0
  42. package/lib/standard-schema.d.ts +131 -0
  43. package/lib/standard-schema.d.ts.map +1 -0
  44. package/lib/standard-schema.js +45 -0
  45. package/lib/standard-schema.js.map +1 -0
  46. package/lib/standard-schema.mjs +41 -0
  47. package/lib/standard-schema.mjs.map +1 -0
  48. package/lib/tools/BetaToolRunner.d.mts.map +1 -1
  49. package/lib/tools/BetaToolRunner.d.ts.map +1 -1
  50. package/lib/tools/BetaToolRunner.js +35 -6
  51. package/lib/tools/BetaToolRunner.js.map +1 -1
  52. package/lib/tools/BetaToolRunner.mjs +35 -6
  53. package/lib/tools/BetaToolRunner.mjs.map +1 -1
  54. package/package.json +2 -11
  55. package/resources/beta/beta.d.mts +5 -1
  56. package/resources/beta/beta.d.mts.map +1 -1
  57. package/resources/beta/beta.d.ts +5 -1
  58. package/resources/beta/beta.d.ts.map +1 -1
  59. package/resources/beta/beta.js +4 -0
  60. package/resources/beta/beta.js.map +1 -1
  61. package/resources/beta/beta.mjs +4 -0
  62. package/resources/beta/beta.mjs.map +1 -1
  63. package/resources/beta/environments/environments.d.mts +8 -1
  64. package/resources/beta/environments/environments.d.mts.map +1 -1
  65. package/resources/beta/environments/environments.d.ts +8 -1
  66. package/resources/beta/environments/environments.d.ts.map +1 -1
  67. package/resources/beta/environments/environments.js.map +1 -1
  68. package/resources/beta/environments/environments.mjs.map +1 -1
  69. package/resources/beta/index.d.mts +1 -0
  70. package/resources/beta/index.d.mts.map +1 -1
  71. package/resources/beta/index.d.ts +1 -0
  72. package/resources/beta/index.d.ts.map +1 -1
  73. package/resources/beta/index.js +11 -9
  74. package/resources/beta/index.js.map +1 -1
  75. package/resources/beta/index.mjs +1 -0
  76. package/resources/beta/index.mjs.map +1 -1
  77. package/resources/beta/memory-stores/memories.d.mts +6 -5
  78. package/resources/beta/memory-stores/memories.d.mts.map +1 -1
  79. package/resources/beta/memory-stores/memories.d.ts +6 -5
  80. package/resources/beta/memory-stores/memories.d.ts.map +1 -1
  81. package/resources/beta/memory-stores/memory-versions.d.mts +8 -5
  82. package/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
  83. package/resources/beta/memory-stores/memory-versions.d.ts +8 -5
  84. package/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
  85. package/resources/beta/messages/messages.d.mts +50 -8
  86. package/resources/beta/messages/messages.d.mts.map +1 -1
  87. package/resources/beta/messages/messages.d.ts +50 -8
  88. package/resources/beta/messages/messages.d.ts.map +1 -1
  89. package/resources/beta/messages/messages.js.map +1 -1
  90. package/resources/beta/messages/messages.mjs.map +1 -1
  91. package/resources/beta/organization/api-keys.d.mts +177 -0
  92. package/resources/beta/organization/api-keys.d.mts.map +1 -0
  93. package/resources/beta/organization/api-keys.d.ts +177 -0
  94. package/resources/beta/organization/api-keys.d.ts.map +1 -0
  95. package/resources/beta/organization/api-keys.js +56 -0
  96. package/resources/beta/organization/api-keys.js.map +1 -0
  97. package/resources/beta/organization/api-keys.mjs +52 -0
  98. package/resources/beta/organization/api-keys.mjs.map +1 -0
  99. package/resources/beta/organization/external-keys.d.mts +269 -0
  100. package/resources/beta/organization/external-keys.d.mts.map +1 -0
  101. package/resources/beta/organization/external-keys.d.ts +269 -0
  102. package/resources/beta/organization/external-keys.d.ts.map +1 -0
  103. package/resources/beta/organization/external-keys.js +119 -0
  104. package/resources/beta/organization/external-keys.js.map +1 -0
  105. package/resources/beta/organization/external-keys.mjs +115 -0
  106. package/resources/beta/organization/external-keys.mjs.map +1 -0
  107. package/resources/beta/organization/federation/federation.d.mts +14 -0
  108. package/resources/beta/organization/federation/federation.d.mts.map +1 -0
  109. package/resources/beta/organization/federation/federation.d.ts +14 -0
  110. package/resources/beta/organization/federation/federation.d.ts.map +1 -0
  111. package/resources/beta/organization/federation/federation.js +21 -0
  112. package/resources/beta/organization/federation/federation.js.map +1 -0
  113. package/resources/beta/organization/federation/federation.mjs +16 -0
  114. package/resources/beta/organization/federation/federation.mjs.map +1 -0
  115. package/resources/beta/organization/federation/index.d.mts +4 -0
  116. package/resources/beta/organization/federation/index.d.mts.map +1 -0
  117. package/resources/beta/organization/federation/index.d.ts +4 -0
  118. package/resources/beta/organization/federation/index.d.ts.map +1 -0
  119. package/resources/beta/organization/federation/index.js +11 -0
  120. package/resources/beta/organization/federation/index.js.map +1 -0
  121. package/resources/beta/organization/federation/index.mjs +5 -0
  122. package/resources/beta/organization/federation/index.mjs.map +1 -0
  123. package/resources/beta/organization/federation/issuers.d.mts +353 -0
  124. package/resources/beta/organization/federation/issuers.d.mts.map +1 -0
  125. package/resources/beta/organization/federation/issuers.d.ts +353 -0
  126. package/resources/beta/organization/federation/issuers.d.ts.map +1 -0
  127. package/resources/beta/organization/federation/issuers.js +169 -0
  128. package/resources/beta/organization/federation/issuers.js.map +1 -0
  129. package/resources/beta/organization/federation/issuers.mjs +165 -0
  130. package/resources/beta/organization/federation/issuers.mjs.map +1 -0
  131. package/resources/beta/organization/federation/rules/index.d.mts +3 -0
  132. package/resources/beta/organization/federation/rules/index.d.mts.map +1 -0
  133. package/resources/beta/organization/federation/rules/index.d.ts +3 -0
  134. package/resources/beta/organization/federation/rules/index.d.ts.map +1 -0
  135. package/resources/beta/organization/federation/rules/index.js +9 -0
  136. package/resources/beta/organization/federation/rules/index.js.map +1 -0
  137. package/resources/beta/organization/federation/rules/index.mjs +4 -0
  138. package/resources/beta/organization/federation/rules/index.mjs.map +1 -0
  139. package/resources/beta/organization/federation/rules/rules.d.mts +468 -0
  140. package/resources/beta/organization/federation/rules/rules.d.mts.map +1 -0
  141. package/resources/beta/organization/federation/rules/rules.d.ts +468 -0
  142. package/resources/beta/organization/federation/rules/rules.d.ts.map +1 -0
  143. package/resources/beta/organization/federation/rules/rules.js +198 -0
  144. package/resources/beta/organization/federation/rules/rules.js.map +1 -0
  145. package/resources/beta/organization/federation/rules/rules.mjs +193 -0
  146. package/resources/beta/organization/federation/rules/rules.mjs.map +1 -0
  147. package/resources/beta/organization/federation/rules/workspaces.d.mts +124 -0
  148. package/resources/beta/organization/federation/rules/workspaces.d.mts.map +1 -0
  149. package/resources/beta/organization/federation/rules/workspaces.d.ts +124 -0
  150. package/resources/beta/organization/federation/rules/workspaces.d.ts.map +1 -0
  151. package/resources/beta/organization/federation/rules/workspaces.js +114 -0
  152. package/resources/beta/organization/federation/rules/workspaces.js.map +1 -0
  153. package/resources/beta/organization/federation/rules/workspaces.mjs +110 -0
  154. package/resources/beta/organization/federation/rules/workspaces.mjs.map +1 -0
  155. package/resources/beta/organization/federation/rules.d.mts +2 -0
  156. package/resources/beta/organization/federation/rules.d.mts.map +1 -0
  157. package/resources/beta/organization/federation/rules.d.ts +2 -0
  158. package/resources/beta/organization/federation/rules.d.ts.map +1 -0
  159. package/resources/beta/organization/federation/rules.js +6 -0
  160. package/resources/beta/organization/federation/rules.js.map +1 -0
  161. package/resources/beta/organization/federation/rules.mjs +3 -0
  162. package/resources/beta/organization/federation/rules.mjs.map +1 -0
  163. package/resources/beta/organization/federation.d.mts +2 -0
  164. package/resources/beta/organization/federation.d.mts.map +1 -0
  165. package/resources/beta/organization/federation.d.ts +2 -0
  166. package/resources/beta/organization/federation.d.ts.map +1 -0
  167. package/resources/beta/organization/federation.js +6 -0
  168. package/resources/beta/organization/federation.js.map +1 -0
  169. package/resources/beta/organization/federation.mjs +3 -0
  170. package/resources/beta/organization/federation.mjs.map +1 -0
  171. package/resources/beta/organization/index.d.mts +10 -0
  172. package/resources/beta/organization/index.d.mts.map +1 -0
  173. package/resources/beta/organization/index.d.ts +10 -0
  174. package/resources/beta/organization/index.d.ts.map +1 -0
  175. package/resources/beta/organization/index.js +23 -0
  176. package/resources/beta/organization/index.js.map +1 -0
  177. package/resources/beta/organization/index.mjs +11 -0
  178. package/resources/beta/organization/index.mjs.map +1 -0
  179. package/resources/beta/organization/invites.d.mts +162 -0
  180. package/resources/beta/organization/invites.d.mts.map +1 -0
  181. package/resources/beta/organization/invites.d.ts +162 -0
  182. package/resources/beta/organization/invites.d.ts.map +1 -0
  183. package/resources/beta/organization/invites.js +76 -0
  184. package/resources/beta/organization/invites.js.map +1 -0
  185. package/resources/beta/organization/invites.mjs +72 -0
  186. package/resources/beta/organization/invites.mjs.map +1 -0
  187. package/resources/beta/organization/organization.d.mts +69 -0
  188. package/resources/beta/organization/organization.d.mts.map +1 -0
  189. package/resources/beta/organization/organization.d.ts +69 -0
  190. package/resources/beta/organization/organization.d.ts.map +1 -0
  191. package/resources/beta/organization/organization.js +58 -0
  192. package/resources/beta/organization/organization.js.map +1 -0
  193. package/resources/beta/organization/organization.mjs +53 -0
  194. package/resources/beta/organization/organization.mjs.map +1 -0
  195. package/resources/beta/organization/rate-limits.d.mts +78 -0
  196. package/resources/beta/organization/rate-limits.d.mts.map +1 -0
  197. package/resources/beta/organization/rate-limits.d.ts +78 -0
  198. package/resources/beta/organization/rate-limits.d.ts.map +1 -0
  199. package/resources/beta/organization/rate-limits.js +32 -0
  200. package/resources/beta/organization/rate-limits.js.map +1 -0
  201. package/resources/beta/organization/rate-limits.mjs +28 -0
  202. package/resources/beta/organization/rate-limits.mjs.map +1 -0
  203. package/resources/beta/organization/service-accounts/index.d.mts +3 -0
  204. package/resources/beta/organization/service-accounts/index.d.mts.map +1 -0
  205. package/resources/beta/organization/service-accounts/index.d.ts +3 -0
  206. package/resources/beta/organization/service-accounts/index.d.ts.map +1 -0
  207. package/resources/beta/organization/service-accounts/index.js +9 -0
  208. package/resources/beta/organization/service-accounts/index.js.map +1 -0
  209. package/resources/beta/organization/service-accounts/index.mjs +4 -0
  210. package/resources/beta/organization/service-accounts/index.mjs.map +1 -0
  211. package/resources/beta/organization/service-accounts/service-accounts.d.mts +258 -0
  212. package/resources/beta/organization/service-accounts/service-accounts.d.mts.map +1 -0
  213. package/resources/beta/organization/service-accounts/service-accounts.d.ts +258 -0
  214. package/resources/beta/organization/service-accounts/service-accounts.d.ts.map +1 -0
  215. package/resources/beta/organization/service-accounts/service-accounts.js +174 -0
  216. package/resources/beta/organization/service-accounts/service-accounts.js.map +1 -0
  217. package/resources/beta/organization/service-accounts/service-accounts.mjs +169 -0
  218. package/resources/beta/organization/service-accounts/service-accounts.mjs.map +1 -0
  219. package/resources/beta/organization/service-accounts/workspaces.d.mts +141 -0
  220. package/resources/beta/organization/service-accounts/workspaces.d.mts.map +1 -0
  221. package/resources/beta/organization/service-accounts/workspaces.d.ts +141 -0
  222. package/resources/beta/organization/service-accounts/workspaces.d.ts.map +1 -0
  223. package/resources/beta/organization/service-accounts/workspaces.js +125 -0
  224. package/resources/beta/organization/service-accounts/workspaces.js.map +1 -0
  225. package/resources/beta/organization/service-accounts/workspaces.mjs +121 -0
  226. package/resources/beta/organization/service-accounts/workspaces.mjs.map +1 -0
  227. package/resources/beta/organization/service-accounts.d.mts +2 -0
  228. package/resources/beta/organization/service-accounts.d.mts.map +1 -0
  229. package/resources/beta/organization/service-accounts.d.ts +2 -0
  230. package/resources/beta/organization/service-accounts.d.ts.map +1 -0
  231. package/resources/beta/organization/service-accounts.js +6 -0
  232. package/resources/beta/organization/service-accounts.js.map +1 -0
  233. package/resources/beta/organization/service-accounts.mjs +3 -0
  234. package/resources/beta/organization/service-accounts.mjs.map +1 -0
  235. package/resources/beta/organization/users.d.mts +124 -0
  236. package/resources/beta/organization/users.d.mts.map +1 -0
  237. package/resources/beta/organization/users.d.ts +124 -0
  238. package/resources/beta/organization/users.d.ts.map +1 -0
  239. package/resources/beta/organization/users.js +67 -0
  240. package/resources/beta/organization/users.js.map +1 -0
  241. package/resources/beta/organization/users.mjs +63 -0
  242. package/resources/beta/organization/users.mjs.map +1 -0
  243. package/resources/beta/organization/workspaces/index.d.mts +5 -0
  244. package/resources/beta/organization/workspaces/index.d.mts.map +1 -0
  245. package/resources/beta/organization/workspaces/index.d.ts +5 -0
  246. package/resources/beta/organization/workspaces/index.d.ts.map +1 -0
  247. package/resources/beta/organization/workspaces/index.js +13 -0
  248. package/resources/beta/organization/workspaces/index.js.map +1 -0
  249. package/resources/beta/organization/workspaces/index.mjs +6 -0
  250. package/resources/beta/organization/workspaces/index.mjs.map +1 -0
  251. package/resources/beta/organization/workspaces/members.d.mts +135 -0
  252. package/resources/beta/organization/workspaces/members.d.mts.map +1 -0
  253. package/resources/beta/organization/workspaces/members.d.ts +135 -0
  254. package/resources/beta/organization/workspaces/members.d.ts.map +1 -0
  255. package/resources/beta/organization/workspaces/members.js +102 -0
  256. package/resources/beta/organization/workspaces/members.js.map +1 -0
  257. package/resources/beta/organization/workspaces/members.mjs +98 -0
  258. package/resources/beta/organization/workspaces/members.mjs.map +1 -0
  259. package/resources/beta/organization/workspaces/rate-limits.d.mts +84 -0
  260. package/resources/beta/organization/workspaces/rate-limits.d.mts.map +1 -0
  261. package/resources/beta/organization/workspaces/rate-limits.d.ts +84 -0
  262. package/resources/beta/organization/workspaces/rate-limits.d.ts.map +1 -0
  263. package/resources/beta/organization/workspaces/rate-limits.js +35 -0
  264. package/resources/beta/organization/workspaces/rate-limits.js.map +1 -0
  265. package/resources/beta/organization/workspaces/rate-limits.mjs +31 -0
  266. package/resources/beta/organization/workspaces/rate-limits.mjs.map +1 -0
  267. package/resources/beta/organization/workspaces/service-accounts.d.mts +210 -0
  268. package/resources/beta/organization/workspaces/service-accounts.d.mts.map +1 -0
  269. package/resources/beta/organization/workspaces/service-accounts.d.ts +210 -0
  270. package/resources/beta/organization/workspaces/service-accounts.d.ts.map +1 -0
  271. package/resources/beta/organization/workspaces/service-accounts.js +189 -0
  272. package/resources/beta/organization/workspaces/service-accounts.js.map +1 -0
  273. package/resources/beta/organization/workspaces/service-accounts.mjs +185 -0
  274. package/resources/beta/organization/workspaces/service-accounts.mjs.map +1 -0
  275. package/resources/beta/organization/workspaces/workspaces.d.mts +287 -0
  276. package/resources/beta/organization/workspaces/workspaces.d.mts.map +1 -0
  277. package/resources/beta/organization/workspaces/workspaces.d.ts +287 -0
  278. package/resources/beta/organization/workspaces/workspaces.d.ts.map +1 -0
  279. package/resources/beta/organization/workspaces/workspaces.js +112 -0
  280. package/resources/beta/organization/workspaces/workspaces.js.map +1 -0
  281. package/resources/beta/organization/workspaces/workspaces.mjs +107 -0
  282. package/resources/beta/organization/workspaces/workspaces.mjs.map +1 -0
  283. package/resources/beta/organization/workspaces.d.mts +2 -0
  284. package/resources/beta/organization/workspaces.d.mts.map +1 -0
  285. package/resources/beta/organization/workspaces.d.ts +2 -0
  286. package/resources/beta/organization/workspaces.d.ts.map +1 -0
  287. package/resources/beta/organization/workspaces.js +6 -0
  288. package/resources/beta/organization/workspaces.js.map +1 -0
  289. package/resources/beta/organization/workspaces.mjs +3 -0
  290. package/resources/beta/organization/workspaces.mjs.map +1 -0
  291. package/resources/beta/organization.d.mts +2 -0
  292. package/resources/beta/organization.d.mts.map +1 -0
  293. package/resources/beta/organization.d.ts +2 -0
  294. package/resources/beta/organization.d.ts.map +1 -0
  295. package/resources/beta/organization.js +6 -0
  296. package/resources/beta/organization.js.map +1 -0
  297. package/resources/beta/organization.mjs +3 -0
  298. package/resources/beta/organization.mjs.map +1 -0
  299. package/resources/beta/sessions/threads/threads.d.mts +2 -1
  300. package/resources/beta/sessions/threads/threads.d.mts.map +1 -1
  301. package/resources/beta/sessions/threads/threads.d.ts +2 -1
  302. package/resources/beta/sessions/threads/threads.d.ts.map +1 -1
  303. package/resources/beta/sessions/threads/threads.js.map +1 -1
  304. package/resources/beta/sessions/threads/threads.mjs.map +1 -1
  305. package/src/helpers/beta/standard-schema.ts +99 -0
  306. package/src/internal/detect-platform.ts +1 -1
  307. package/src/internal/utils/values.ts +7 -0
  308. package/src/lib/BetaMessageStream.ts +1 -3
  309. package/src/lib/MessageStream.ts +1 -3
  310. package/src/lib/sessions/accumulate.ts +1 -3
  311. package/src/lib/standard-schema.ts +209 -0
  312. package/src/lib/tools/BetaToolRunner.ts +38 -6
  313. package/src/resources/beta/beta.ts +18 -1
  314. package/src/resources/beta/environments/environments.ts +8 -1
  315. package/src/resources/beta/index.ts +1 -0
  316. package/src/resources/beta/memory-stores/memories.ts +6 -5
  317. package/src/resources/beta/memory-stores/memory-versions.ts +8 -5
  318. package/src/resources/beta/messages/messages.ts +50 -8
  319. package/src/resources/beta/organization/api-keys.ts +231 -0
  320. package/src/resources/beta/organization/external-keys.ts +362 -0
  321. package/src/resources/beta/organization/federation/federation.ts +71 -0
  322. package/src/resources/beta/organization/federation/index.ts +31 -0
  323. package/src/resources/beta/organization/federation/issuers.ts +486 -0
  324. package/src/resources/beta/organization/federation/rules/index.ts +23 -0
  325. package/src/resources/beta/organization/federation/rules/rules.ts +624 -0
  326. package/src/resources/beta/organization/federation/rules/workspaces.ts +196 -0
  327. package/src/resources/beta/organization/federation/rules.ts +3 -0
  328. package/src/resources/beta/organization/federation.ts +3 -0
  329. package/src/resources/beta/organization/index.ts +83 -0
  330. package/src/resources/beta/organization/invites.ts +207 -0
  331. package/src/resources/beta/organization/organization.ts +245 -0
  332. package/src/resources/beta/organization/rate-limits.ts +105 -0
  333. package/src/resources/beta/organization/service-accounts/index.ts +21 -0
  334. package/src/resources/beta/organization/service-accounts/service-accounts.ts +389 -0
  335. package/src/resources/beta/organization/service-accounts/workspaces.ts +217 -0
  336. package/src/resources/beta/organization/service-accounts.ts +3 -0
  337. package/src/resources/beta/organization/users.ts +163 -0
  338. package/src/resources/beta/organization/workspaces/index.ts +43 -0
  339. package/src/resources/beta/organization/workspaces/members.ts +209 -0
  340. package/src/resources/beta/organization/workspaces/rate-limits.ts +114 -0
  341. package/src/resources/beta/organization/workspaces/service-accounts.ts +325 -0
  342. package/src/resources/beta/organization/workspaces/workspaces.ts +434 -0
  343. package/src/resources/beta/organization/workspaces.ts +3 -0
  344. package/src/resources/beta/organization.ts +3 -0
  345. package/src/resources/beta/sessions/threads/threads.ts +2 -1
  346. package/src/tools/agent-toolset/node.browser.ts +1 -1
  347. package/src/tools/agent-toolset/node.ts +4 -4
  348. package/src/version.ts +1 -1
  349. package/tools/agent-toolset/node.browser.d.mts +1 -1
  350. package/tools/agent-toolset/node.browser.d.mts.map +1 -1
  351. package/tools/agent-toolset/node.browser.d.ts +1 -1
  352. package/tools/agent-toolset/node.browser.d.ts.map +1 -1
  353. package/tools/agent-toolset/node.browser.js.map +1 -1
  354. package/tools/agent-toolset/node.browser.mjs.map +1 -1
  355. package/tools/agent-toolset/node.d.mts +2 -2
  356. package/tools/agent-toolset/node.d.mts.map +1 -1
  357. package/tools/agent-toolset/node.d.ts +2 -2
  358. package/tools/agent-toolset/node.d.ts.map +1 -1
  359. package/tools/agent-toolset/node.js.map +1 -1
  360. package/tools/agent-toolset/node.mjs.map +1 -1
  361. package/version.d.mts +1 -1
  362. package/version.d.ts +1 -1
  363. package/version.js +1 -1
  364. package/version.mjs +1 -1
@@ -0,0 +1,209 @@
1
+ import { AnthropicError } from '../core/error';
2
+
3
+ // Standard Schema spec types, copied from `@standard-schema/spec@1.1.0` (MIT) as the spec
4
+ // recommends. See https://standardschema.dev
5
+
6
+ /** The Standard Typed interface. This is a base type extended by other specs. */
7
+ export interface StandardTypedV1<Input = unknown, Output = Input> {
8
+ /** The Standard properties. */
9
+ readonly '~standard': StandardTypedV1.Props<Input, Output>;
10
+ }
11
+
12
+ export declare namespace StandardTypedV1 {
13
+ /** The Standard Typed properties interface. */
14
+ interface Props<Input = unknown, Output = Input> {
15
+ /** The version number of the standard. */
16
+ readonly version: 1;
17
+ /** The vendor name of the schema library. */
18
+ readonly vendor: string;
19
+ /** Inferred types associated with the schema. */
20
+ readonly types?: Types<Input, Output> | undefined;
21
+ }
22
+
23
+ /** The Standard Typed types interface. */
24
+ interface Types<Input = unknown, Output = Input> {
25
+ /** The input type of the schema. */
26
+ readonly input: Input;
27
+ /** The output type of the schema. */
28
+ readonly output: Output;
29
+ }
30
+
31
+ /** Infers the input type of a Standard Typed. */
32
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema['~standard']['types']>['input'];
33
+
34
+ /** Infers the output type of a Standard Typed. */
35
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema['~standard']['types']>['output'];
36
+ }
37
+
38
+ /** The Standard Schema interface. */
39
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
40
+ /** The Standard Schema properties. */
41
+ readonly '~standard': StandardSchemaV1.Props<Input, Output>;
42
+ }
43
+
44
+ export declare namespace StandardSchemaV1 {
45
+ /** The Standard Schema properties interface. */
46
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
47
+ /** Validates unknown input values. */
48
+ readonly validate: (
49
+ value: unknown,
50
+ options?: StandardSchemaV1.Options | undefined,
51
+ ) => Result<Output> | Promise<Result<Output>>;
52
+ }
53
+
54
+ /** The result interface of the validate function. */
55
+ type Result<Output> = SuccessResult<Output> | FailureResult;
56
+
57
+ /** The result interface if validation succeeds. */
58
+ interface SuccessResult<Output> {
59
+ /** The typed output value. */
60
+ readonly value: Output;
61
+ /** A falsy value for `issues` indicates success. */
62
+ readonly issues?: undefined;
63
+ }
64
+
65
+ interface Options {
66
+ /** Explicit support for additional vendor-specific parameters, if needed. */
67
+ readonly libraryOptions?: Record<string, unknown> | undefined;
68
+ }
69
+
70
+ /** The result interface if validation fails. */
71
+ interface FailureResult {
72
+ /** The issues of failed validation. */
73
+ readonly issues: ReadonlyArray<Issue>;
74
+ }
75
+
76
+ /** The issue interface of the failure output. */
77
+ interface Issue {
78
+ /** The error message of the issue. */
79
+ readonly message: string;
80
+ /** The path of the issue, if any. */
81
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
82
+ }
83
+
84
+ /** The path segment interface of the issue. */
85
+ interface PathSegment {
86
+ /** The key representing a path segment. */
87
+ readonly key: PropertyKey;
88
+ }
89
+
90
+ /** The Standard types interface. */
91
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
92
+
93
+ /** Infers the input type of a Standard. */
94
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
95
+
96
+ /** Infers the output type of a Standard. */
97
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
98
+ }
99
+
100
+ /** The Standard JSON Schema interface. */
101
+ export interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
102
+ /** The Standard JSON Schema properties. */
103
+ readonly '~standard': StandardJSONSchemaV1.Props<Input, Output>;
104
+ }
105
+
106
+ export declare namespace StandardJSONSchemaV1 {
107
+ /** The Standard JSON Schema properties interface. */
108
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
109
+ /** Methods for generating the input/output JSON Schema. */
110
+ readonly jsonSchema: StandardJSONSchemaV1.Converter;
111
+ }
112
+
113
+ /** The Standard JSON Schema converter interface. */
114
+ interface Converter {
115
+ /** Converts the input type to JSON Schema. May throw if conversion is not supported. */
116
+ readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
117
+ /** Converts the output type to JSON Schema. May throw if conversion is not supported. */
118
+ readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
119
+ }
120
+
121
+ /**
122
+ * The target version of the generated JSON Schema.
123
+ *
124
+ * It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they
125
+ * are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should
126
+ * throw if they don't support a specified target.
127
+ *
128
+ * The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a
129
+ * superset of JSON Schema `"draft-04"`.
130
+ */
131
+ type Target = 'draft-2020-12' | 'draft-07' | 'openapi-3.0' | ({} & string);
132
+
133
+ /** The options for the input/output methods. */
134
+ interface Options {
135
+ /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
136
+ readonly target: Target;
137
+ /** Explicit support for additional vendor-specific parameters, if needed. */
138
+ readonly libraryOptions?: Record<string, unknown> | undefined;
139
+ }
140
+
141
+ /** The Standard types interface. */
142
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
143
+
144
+ /** Infers the input type of a Standard. */
145
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
146
+
147
+ /** Infers the output type of a Standard. */
148
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
149
+ }
150
+
151
+ /**
152
+ * Returns `jsonSchema` if given, otherwise the schema's Standard JSON Schema `input`
153
+ * representation (the model produces the value that the validator consumes).
154
+ */
155
+ export function standardSchemaToJSONSchema(
156
+ schema: StandardSchemaV1,
157
+ jsonSchema?: Record<string, unknown> | undefined,
158
+ ): Record<string, unknown> {
159
+ if (jsonSchema) {
160
+ return jsonSchema;
161
+ }
162
+
163
+ const std: StandardSchemaV1.Props & Partial<StandardJSONSchemaV1.Props> = schema['~standard'];
164
+ if (std.jsonSchema) {
165
+ return std.jsonSchema.input({ target: 'draft-2020-12' });
166
+ }
167
+
168
+ throw new AnthropicError(
169
+ `Could not derive a JSON Schema from this ${std.vendor} schema as it does not implement Standard JSON Schema (\`~standard.jsonSchema\`). Pass the \`jsonSchema\` option, or use a library version that implements it (e.g. zod >= 4.2, or valibot via \`toStandardJsonSchema()\`).`,
170
+ );
171
+ }
172
+
173
+ /**
174
+ * Validates `value` with `~standard.validate` and returns the typed output, throwing an
175
+ * `AnthropicError` on issues. Validation must be synchronous because `parse` hooks are.
176
+ */
177
+ export function parseWithStandardSchema<Schema extends StandardSchemaV1>(
178
+ schema: Schema,
179
+ value: unknown,
180
+ ): StandardSchemaV1.InferOutput<Schema> {
181
+ const result = schema['~standard'].validate(value);
182
+
183
+ if (result instanceof Promise) {
184
+ // avoid an unhandled rejection from the discarded result
185
+ result.catch(() => {});
186
+ throw new AnthropicError(
187
+ `Async validation is not supported: the ${schema['~standard'].vendor} schema's \`~standard.validate()\` returned a Promise.`,
188
+ );
189
+ }
190
+
191
+ if (result.issues) {
192
+ const formattedIssues = result.issues.slice(0, 5).map(formatIssue).join('\n');
193
+ const issueCount = result.issues.length;
194
+ const suffix = issueCount > 5 ? `\n ... and ${issueCount - 5} more issue(s)` : '';
195
+
196
+ throw new AnthropicError(
197
+ `Schema validation failed with ${issueCount} issue(s):\n${formattedIssues}${suffix}`,
198
+ );
199
+ }
200
+
201
+ return result.value;
202
+ }
203
+
204
+ function formatIssue(issue: StandardSchemaV1.Issue): string {
205
+ const path = (issue.path ?? [])
206
+ .map((segment) => String(typeof segment === 'object' ? segment.key : segment))
207
+ .join('.');
208
+ return path ? ` - ${path}: ${issue.message}` : ` - ${issue.message}`;
209
+ }
@@ -8,6 +8,7 @@ import {
8
8
  BetaMessageParam,
9
9
  BetaRequestToolAdditionBlock,
10
10
  BetaRequestToolRemovalBlock,
11
+ BetaStopReason,
11
12
  BetaToolChangeMCPToolReference,
12
13
  BetaToolChangeMCPToolsetReference,
13
14
  BetaToolChangeToolReference,
@@ -18,6 +19,7 @@ import { BetaMessageStream } from '../BetaMessageStream';
18
19
  import { RequestOptions } from '../../internal/request-options';
19
20
  import { buildHeaders } from '../../internal/headers';
20
21
  import { promiseWithResolvers } from '../../internal/utils/promise';
22
+ import { checkNever } from '../../internal/utils/values';
21
23
  import { CompactionControl, DEFAULT_SUMMARY_PROMPT, DEFAULT_TOKEN_THRESHOLD } from './CompactionControl';
22
24
  import {
23
25
  collectStainlessHelpers,
@@ -220,6 +222,7 @@ export class BetaToolRunner<Stream extends boolean> {
220
222
  if (!isCompacted) {
221
223
  if (!this.#mutated) {
222
224
  const message = await this.#message;
225
+ const nextStep = determineNextStepFromStopReason(message.stop_reason);
223
226
  this.#state.params.messages.push({ role: message.role, content: message.content });
224
227
 
225
228
  // Container-bound server tools reject a follow-up request that omits the container the
@@ -233,14 +236,12 @@ export class BetaToolRunner<Stream extends boolean> {
233
236
  }
234
237
  }
235
238
 
236
- // Refusal-terminated turns are terminal: the refusal may have cut a tool_use off
237
- // with partial input, so executing this turn's tools would fire side effects the
238
- // model never confirmed — and once middleware strips the refusal turn, their
239
- // tool_results could never be replayed coherently. Surface the refusal as the
240
- // final message instead.
241
- if (message.stop_reason === 'refusal') {
239
+ if (nextStep === 'stop') {
242
240
  break;
243
241
  }
242
+ if (nextStep === 'resume') {
243
+ continue;
244
+ }
244
245
  }
245
246
 
246
247
  const toolMessage = await this.#generateToolResponse(this.#state.params.messages.at(-1)!);
@@ -612,6 +613,37 @@ function referencedToolName(
612
613
  }
613
614
  }
614
615
 
616
+ type NextStep = 'run_tools' | 'resume' | 'stop';
617
+
618
+ /**
619
+ * Sorts every stop reason into one of three buckets: `run_tools` turns run their client tool
620
+ * calls and continue the loop; `resume` turns are sent back unchanged so the server continues
621
+ * them; `stop` turns end the loop without running any tool calls.
622
+ */
623
+ function determineNextStepFromStopReason(stopReason: BetaStopReason | null): NextStep {
624
+ if (stopReason === null) return 'stop';
625
+ switch (stopReason) {
626
+ case 'tool_use':
627
+ return 'run_tools';
628
+ case 'pause_turn':
629
+ // pause_after_compaction hands the turn back before the model answers; sending it back
630
+ // unchanged continues it.
631
+ case 'compaction':
632
+ return 'resume';
633
+ case 'end_turn':
634
+ case 'stop_sequence':
635
+ case 'max_tokens':
636
+ case 'model_context_window_exceeded':
637
+ case 'refusal':
638
+ return 'stop';
639
+ default:
640
+ // The union is forward-compatible, so a stop reason this SDK doesn't know yet ends the
641
+ // loop rather than throwing; the `never` check makes tsc reject an unclassified member.
642
+ checkNever(stopReason);
643
+ return 'stop';
644
+ }
645
+ }
646
+
615
647
  // vendored from typefest just to make things look a bit nicer on hover
616
648
  type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
617
649
 
@@ -595,6 +595,8 @@ import {
595
595
  BetaMCPToolConfig,
596
596
  BetaMCPToolDefaultConfig,
597
597
  } from './messages/messages';
598
+ import * as OrganizationAPI from './organization/organization';
599
+ import { BetaOrganization, BetaOrganizationRole, Organization } from './organization/organization';
598
600
  import * as SessionsAPI from './sessions/sessions';
599
601
  import {
600
602
  BetaManagedAgentsAdvisorParams,
@@ -696,6 +698,7 @@ export class Beta extends APIResource {
696
698
  userProfiles: UserProfilesAPI.UserProfiles = new UserProfilesAPI.UserProfiles(this._client);
697
699
  dreams: DreamsAPI.Dreams = new DreamsAPI.Dreams(this._client);
698
700
  tunnels: TunnelsAPI.Tunnels = new TunnelsAPI.Tunnels(this._client);
701
+ organization: OrganizationAPI.Organization = new OrganizationAPI.Organization(this._client);
699
702
  }
700
703
 
701
704
  export type AnthropicBeta =
@@ -733,7 +736,14 @@ export type AnthropicBeta =
733
736
  | 'fallback-credit-2026-06-01'
734
737
  | 'fallback-credit-2026-07-01'
735
738
  | 'agent-memory-2026-07-22'
736
- | 'mid-conversation-tool-changes-2026-07-01';
739
+ | 'mid-conversation-tool-changes-2026-07-01'
740
+ | 'compact-2026-01-12'
741
+ | 'computer-use-2025-11-24'
742
+ | 'mcp-tunnels-2026-06-22'
743
+ | 'structured-outputs-2025-11-13'
744
+ | 'task-budgets-2026-03-13'
745
+ | 'thinking-display-updates-2026-08-18'
746
+ | 'ce-user-management-2026-07-13';
737
747
 
738
748
  export interface BetaAPIError {
739
749
  message: string;
@@ -844,6 +854,7 @@ Beta.Webhooks = Webhooks;
844
854
  Beta.UserProfiles = UserProfiles;
845
855
  Beta.Dreams = Dreams;
846
856
  Beta.Tunnels = Tunnels;
857
+ Beta.Organization = Organization;
847
858
 
848
859
  export declare namespace Beta {
849
860
  export {
@@ -1540,4 +1551,10 @@ export declare namespace Beta {
1540
1551
  type TunnelRevealTokenParams as TunnelRevealTokenParams,
1541
1552
  type TunnelRotateTokenParams as TunnelRotateTokenParams,
1542
1553
  };
1554
+
1555
+ export {
1556
+ Organization as Organization,
1557
+ type BetaOrganization as BetaOrganization,
1558
+ type BetaOrganizationRole as BetaOrganizationRole,
1559
+ };
1543
1560
  }
@@ -231,6 +231,9 @@ export interface BetaCloudConfigParams {
231
231
  * When versioning, use the version semantics relevant for the package manager,
232
232
  * e.g. for `pip` use `package==1.0.0`. You are responsible for validating the
233
233
  * package and version exist. Unversioned installs the latest.
234
+ *
235
+ * Under `limited` networking, requires `networking.allow_package_managers` to be
236
+ * `true`.
234
237
  */
235
238
  packages?: BetaPackagesParams | null;
236
239
  }
@@ -352,7 +355,8 @@ export interface BetaLimitedNetworkParams {
352
355
 
353
356
  /**
354
357
  * Permits outbound access to public package registries (PyPI, npm, etc.) beyond
355
- * those listed in the `allowed_hosts` array. Defaults to `false`.
358
+ * those listed in the `allowed_hosts` array. Defaults to `false` on creation. Must
359
+ * be `true` when `packages` are specified.
356
360
  */
357
361
  allow_package_managers?: boolean | null;
358
362
 
@@ -408,6 +412,9 @@ export interface BetaPackages {
408
412
  * When versioning, use the version semantics relevant for the package manager,
409
413
  * e.g. for `pip` use `package==1.0.0`. You are responsible for validating the
410
414
  * package and version exist. Unversioned installs the latest.
415
+ *
416
+ * Under `limited` networking, requires `networking.allow_package_managers` to be
417
+ * `true`.
411
418
  */
412
419
  export interface BetaPackagesParams {
413
420
  /**
@@ -548,6 +548,7 @@ export {
548
548
  type ModelListParams,
549
549
  type BetaModelInfosPage,
550
550
  } from './models';
551
+ export { Organization, type BetaOrganization, type BetaOrganizationRole } from './organization/index';
551
552
  export {
552
553
  Sessions,
553
554
  type BetaManagedAgentsAdvisorParams,
@@ -187,10 +187,11 @@ export interface BetaManagedAgentsContentSha256Precondition {
187
187
 
188
188
  /**
189
189
  * Tombstone returned by
190
- * [Delete a memory](/en/api/beta/memory_stores/memories/delete). The memory's
191
- * version history persists and remains listable via
192
- * [List memory versions](/en/api/beta/memory_stores/memory_versions/list) until
193
- * the store itself is deleted.
190
+ * [Delete a memory](/en/api/beta/memory_stores/memories/delete). Deleting a memory
191
+ * does not erase its version history: its versions remain listable via
192
+ * [List memory versions](/en/api/beta/memory_stores/memory_versions/list) while
193
+ * they are retained (each version is kept for at least the version retention
194
+ * period after it was written, unless the store itself is deleted).
194
195
  */
195
196
  export interface BetaManagedAgentsDeletedMemory {
196
197
  /**
@@ -258,7 +259,7 @@ export interface BetaManagedAgentsMemory {
258
259
  * ID of the `memory_version` representing this memory's current content (a
259
260
  * `memver_...` value). This is the authoritative head pointer; `memory_version`
260
261
  * objects do not carry an `is_latest` flag, so compare against this field instead.
261
- * Enumerate the full history via
262
+ * Enumerate the history via
262
263
  * [List memory versions](/en/api/beta/memory_stores/memory_versions/list).
263
264
  */
264
265
  memory_version_id: string;
@@ -137,10 +137,12 @@ export interface BetaManagedAgentsAPIActor {
137
137
  /**
138
138
  * A `memory_version` object: one immutable, attributed row in a memory's
139
139
  * append-only history. Every non-no-op mutation to a memory produces a new
140
- * version. Versions belong to the store (not the individual memory) and persist
141
- * after the memory is deleted. Retrieving a redacted version returns 200 with
142
- * `content`, `path`, `content_size_bytes`, and `content_sha256` set to `null`;
143
- * branch on `redacted_at`, not HTTP status.
140
+ * version. Versions belong to the store (not the individual memory) and are not
141
+ * deleted with the memory; each version is retained for at least the version
142
+ * retention period after it was written, unless the store itself is deleted.
143
+ * Retrieving a redacted version returns 200 with `content`, `path`,
144
+ * `content_size_bytes`, and `content_sha256` set to `null`; branch on
145
+ * `redacted_at`, not HTTP status.
144
146
  */
145
147
  export interface BetaManagedAgentsMemoryVersion {
146
148
  /**
@@ -157,7 +159,8 @@ export interface BetaManagedAgentsMemoryVersion {
157
159
  * ID of the memory this version snapshots (a `mem_...` value). Remains valid after
158
160
  * the memory is deleted; pass it as `memory_id` to
159
161
  * [List memory versions](/en/api/beta/memory_stores/memory_versions/list) to
160
- * retrieve the full lineage including the `deleted` row.
162
+ * retrieve the memory's retained versions, including the `deleted` row while the
163
+ * lineage is retained.
161
164
  */
162
165
  memory_id: string;
163
166
 
@@ -3256,11 +3256,25 @@ export interface BetaInputTokensTrigger {
3256
3256
  * Per-iteration token usage breakdown.
3257
3257
  *
3258
3258
  * Each entry represents one sampling iteration, with its own input/output token
3259
- * counts and cache statistics. This allows you to:
3259
+ * counts and cache statistics, discriminated by `type`. For `message` entries
3260
+ * (model sampling iterations, such as the turns of a server-side tool use loop),
3261
+ * this allows you to:
3260
3262
  *
3261
3263
  * - Determine which iterations exceeded long context thresholds (>=200k tokens)
3262
- * - Calculate the true context window size from the last iteration
3264
+ * - Calculate the context window size from the last `message` entry
3263
3265
  * - Understand token accumulation across server-side tool use loops
3266
+ *
3267
+ * A `compaction` entry reports the token usage of the compaction operation itself
3268
+ * — the server-side request that summarizes the context being closed — NOT the
3269
+ * size of the context that was compacted away, and its token counts can be much
3270
+ * smaller than that closed context (for example, a compaction that closes a
3271
+ * ~200k-token context can report only a few thousand tokens). Do not derive the
3272
+ * context window size from a `compaction` entry, even when it is the last entry. A
3273
+ * `compaction` entry's tokens are not included in the top-level `usage` fields.
3274
+ * When an input-token trigger is in effect (the default — 150,000 tokens unless
3275
+ * configured otherwise), each `compaction` entry closes a context that had reached
3276
+ * at least that threshold, though the context can exceed it by the final
3277
+ * iteration's output and tool results.
3264
3278
  */
3265
3279
  export type BetaIterationsUsage = Array<
3266
3280
  | BetaMessageIterationUsage
@@ -3685,11 +3699,25 @@ export interface BetaMessageDeltaUsage {
3685
3699
  * Per-iteration token usage breakdown.
3686
3700
  *
3687
3701
  * Each entry represents one sampling iteration, with its own input/output token
3688
- * counts and cache statistics. This allows you to:
3702
+ * counts and cache statistics, discriminated by `type`. For `message` entries
3703
+ * (model sampling iterations, such as the turns of a server-side tool use loop),
3704
+ * this allows you to:
3689
3705
  *
3690
3706
  * - Determine which iterations exceeded long context thresholds (>=200k tokens)
3691
- * - Calculate the true context window size from the last iteration
3707
+ * - Calculate the context window size from the last `message` entry
3692
3708
  * - Understand token accumulation across server-side tool use loops
3709
+ *
3710
+ * A `compaction` entry reports the token usage of the compaction operation itself
3711
+ * — the server-side request that summarizes the context being closed — NOT the
3712
+ * size of the context that was compacted away, and its token counts can be much
3713
+ * smaller than that closed context (for example, a compaction that closes a
3714
+ * ~200k-token context can report only a few thousand tokens). Do not derive the
3715
+ * context window size from a `compaction` entry, even when it is the last entry. A
3716
+ * `compaction` entry's tokens are not included in the top-level `usage` fields.
3717
+ * When an input-token trigger is in effect (the default — 150,000 tokens unless
3718
+ * configured otherwise), each `compaction` entry closes a context that had reached
3719
+ * at least that threshold, though the context can exceed it by the final
3720
+ * iteration's output and tool results.
3693
3721
  */
3694
3722
  iterations: BetaIterationsUsage | null;
3695
3723
 
@@ -4536,7 +4564,7 @@ export interface BetaThinkingConfigAdaptive {
4536
4564
  * redacted but a signature is returned for multi-turn continuity. Defaults to
4537
4565
  * `summarized`.
4538
4566
  */
4539
- display?: 'summarized' | 'omitted' | null;
4567
+ display?: 'summarized' | 'omitted' | 'updates' | null;
4540
4568
  }
4541
4569
 
4542
4570
  export interface BetaThinkingConfigDisabled {
@@ -4565,7 +4593,7 @@ export interface BetaThinkingConfigEnabled {
4565
4593
  * redacted but a signature is returned for multi-turn continuity. Defaults to
4566
4594
  * `summarized`.
4567
4595
  */
4568
- display?: 'summarized' | 'omitted' | null;
4596
+ display?: 'summarized' | 'omitted' | 'updates' | null;
4569
4597
  }
4570
4598
 
4571
4599
  /**
@@ -5460,11 +5488,25 @@ export interface BetaUsage {
5460
5488
  * Per-iteration token usage breakdown.
5461
5489
  *
5462
5490
  * Each entry represents one sampling iteration, with its own input/output token
5463
- * counts and cache statistics. This allows you to:
5491
+ * counts and cache statistics, discriminated by `type`. For `message` entries
5492
+ * (model sampling iterations, such as the turns of a server-side tool use loop),
5493
+ * this allows you to:
5464
5494
  *
5465
5495
  * - Determine which iterations exceeded long context thresholds (>=200k tokens)
5466
- * - Calculate the true context window size from the last iteration
5496
+ * - Calculate the context window size from the last `message` entry
5467
5497
  * - Understand token accumulation across server-side tool use loops
5498
+ *
5499
+ * A `compaction` entry reports the token usage of the compaction operation itself
5500
+ * — the server-side request that summarizes the context being closed — NOT the
5501
+ * size of the context that was compacted away, and its token counts can be much
5502
+ * smaller than that closed context (for example, a compaction that closes a
5503
+ * ~200k-token context can report only a few thousand tokens). Do not derive the
5504
+ * context window size from a `compaction` entry, even when it is the last entry. A
5505
+ * `compaction` entry's tokens are not included in the top-level `usage` fields.
5506
+ * When an input-token trigger is in effect (the default — 150,000 tokens unless
5507
+ * configured otherwise), each `compaction` entry closes a context that had reached
5508
+ * at least that threshold, though the context can exceed it by the final
5509
+ * iteration's output and tool results.
5468
5510
  */
5469
5511
  iterations: BetaIterationsUsage | null;
5470
5512