@anthropic-ai/sdk 0.116.0 → 0.118.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 (246) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js +1 -1
  7. package/client.js.map +1 -1
  8. package/client.mjs +1 -1
  9. package/client.mjs.map +1 -1
  10. package/core/api-promise.d.mts +1 -0
  11. package/core/api-promise.d.mts.map +1 -1
  12. package/core/api-promise.d.ts +1 -0
  13. package/core/api-promise.d.ts.map +1 -1
  14. package/core/api-promise.js +7 -2
  15. package/core/api-promise.js.map +1 -1
  16. package/core/api-promise.mjs +8 -3
  17. package/core/api-promise.mjs.map +1 -1
  18. package/core/error.d.mts +1 -0
  19. package/core/error.d.mts.map +1 -1
  20. package/core/error.d.ts +1 -0
  21. package/core/error.d.ts.map +1 -1
  22. package/core/error.js +1 -0
  23. package/core/error.js.map +1 -1
  24. package/core/error.mjs +1 -0
  25. package/core/error.mjs.map +1 -1
  26. package/core/middleware.js +1 -1
  27. package/core/middleware.js.map +1 -1
  28. package/core/middleware.mjs +2 -2
  29. package/core/middleware.mjs.map +1 -1
  30. package/helpers/beta/zod.d.mts.map +1 -1
  31. package/helpers/beta/zod.d.ts.map +1 -1
  32. package/helpers/beta/zod.js +1 -2
  33. package/helpers/beta/zod.js.map +1 -1
  34. package/helpers/beta/zod.mjs +1 -2
  35. package/helpers/beta/zod.mjs.map +1 -1
  36. package/helpers/zod.d.mts.map +1 -1
  37. package/helpers/zod.d.ts.map +1 -1
  38. package/helpers/zod.js +1 -2
  39. package/helpers/zod.js.map +1 -1
  40. package/helpers/zod.mjs +1 -2
  41. package/helpers/zod.mjs.map +1 -1
  42. package/internal/parse.d.mts +2 -1
  43. package/internal/parse.d.mts.map +1 -1
  44. package/internal/parse.d.ts +2 -1
  45. package/internal/parse.d.ts.map +1 -1
  46. package/internal/parse.js +6 -6
  47. package/internal/parse.js.map +1 -1
  48. package/internal/parse.mjs +5 -5
  49. package/internal/parse.mjs.map +1 -1
  50. package/lib/BetaMessageStream.d.mts +2 -0
  51. package/lib/BetaMessageStream.d.mts.map +1 -1
  52. package/lib/BetaMessageStream.d.ts +2 -0
  53. package/lib/BetaMessageStream.d.ts.map +1 -1
  54. package/lib/BetaMessageStream.js +20 -7
  55. package/lib/BetaMessageStream.js.map +1 -1
  56. package/lib/BetaMessageStream.mjs +20 -7
  57. package/lib/BetaMessageStream.mjs.map +1 -1
  58. package/lib/MessageStream.d.mts +2 -0
  59. package/lib/MessageStream.d.mts.map +1 -1
  60. package/lib/MessageStream.d.ts +2 -0
  61. package/lib/MessageStream.d.ts.map +1 -1
  62. package/lib/MessageStream.js +17 -6
  63. package/lib/MessageStream.js.map +1 -1
  64. package/lib/MessageStream.mjs +17 -6
  65. package/lib/MessageStream.mjs.map +1 -1
  66. package/lib/environments/worker.d.mts +10 -6
  67. package/lib/environments/worker.d.mts.map +1 -1
  68. package/lib/environments/worker.d.ts +10 -6
  69. package/lib/environments/worker.d.ts.map +1 -1
  70. package/lib/environments/worker.js +51 -18
  71. package/lib/environments/worker.js.map +1 -1
  72. package/lib/environments/worker.mjs +51 -18
  73. package/lib/environments/worker.mjs.map +1 -1
  74. package/lib/tools/BetaRunnableTool.d.mts +20 -42
  75. package/lib/tools/BetaRunnableTool.d.mts.map +1 -1
  76. package/lib/tools/BetaRunnableTool.d.ts +20 -42
  77. package/lib/tools/BetaRunnableTool.d.ts.map +1 -1
  78. package/lib/tools/BetaRunnableTool.js +3 -17
  79. package/lib/tools/BetaRunnableTool.js.map +1 -1
  80. package/lib/tools/BetaRunnableTool.mjs +3 -17
  81. package/lib/tools/BetaRunnableTool.mjs.map +1 -1
  82. package/lib/tools/BetaToolRunner.d.mts.map +1 -1
  83. package/lib/tools/BetaToolRunner.d.ts.map +1 -1
  84. package/lib/tools/BetaToolRunner.js +11 -12
  85. package/lib/tools/BetaToolRunner.js.map +1 -1
  86. package/lib/tools/BetaToolRunner.mjs +11 -12
  87. package/lib/tools/BetaToolRunner.mjs.map +1 -1
  88. package/lib/tools/SessionToolRunner.d.mts +6 -0
  89. package/lib/tools/SessionToolRunner.d.mts.map +1 -1
  90. package/lib/tools/SessionToolRunner.d.ts +6 -0
  91. package/lib/tools/SessionToolRunner.d.ts.map +1 -1
  92. package/lib/tools/SessionToolRunner.js +37 -8
  93. package/lib/tools/SessionToolRunner.js.map +1 -1
  94. package/lib/tools/SessionToolRunner.mjs +38 -9
  95. package/lib/tools/SessionToolRunner.mjs.map +1 -1
  96. package/package.json +9 -15
  97. package/resources/beta/agents/agents.d.mts +3 -3
  98. package/resources/beta/agents/agents.d.ts +3 -3
  99. package/resources/beta/agents/agents.js +1 -1
  100. package/resources/beta/agents/agents.mjs +1 -1
  101. package/resources/beta/beta.d.mts +5 -5
  102. package/resources/beta/beta.d.mts.map +1 -1
  103. package/resources/beta/beta.d.ts +5 -5
  104. package/resources/beta/beta.d.ts.map +1 -1
  105. package/resources/beta/beta.js.map +1 -1
  106. package/resources/beta/beta.mjs.map +1 -1
  107. package/resources/beta/dreams.d.mts +48 -8
  108. package/resources/beta/dreams.d.mts.map +1 -1
  109. package/resources/beta/dreams.d.ts +48 -8
  110. package/resources/beta/dreams.d.ts.map +1 -1
  111. package/resources/beta/environments/environments.d.mts +4 -3
  112. package/resources/beta/environments/environments.d.mts.map +1 -1
  113. package/resources/beta/environments/environments.d.ts +4 -3
  114. package/resources/beta/environments/environments.d.ts.map +1 -1
  115. package/resources/beta/environments/environments.js.map +1 -1
  116. package/resources/beta/environments/environments.mjs.map +1 -1
  117. package/resources/beta/index.d.mts +2 -2
  118. package/resources/beta/index.d.mts.map +1 -1
  119. package/resources/beta/index.d.ts +2 -2
  120. package/resources/beta/index.d.ts.map +1 -1
  121. package/resources/beta/index.js.map +1 -1
  122. package/resources/beta/index.mjs.map +1 -1
  123. package/resources/beta/memory-stores/index.d.mts +1 -1
  124. package/resources/beta/memory-stores/index.d.mts.map +1 -1
  125. package/resources/beta/memory-stores/index.d.ts +1 -1
  126. package/resources/beta/memory-stores/index.d.ts.map +1 -1
  127. package/resources/beta/memory-stores/index.js.map +1 -1
  128. package/resources/beta/memory-stores/index.mjs.map +1 -1
  129. package/resources/beta/memory-stores/memory-stores.d.mts +2 -2
  130. package/resources/beta/memory-stores/memory-stores.d.mts.map +1 -1
  131. package/resources/beta/memory-stores/memory-stores.d.ts +2 -2
  132. package/resources/beta/memory-stores/memory-stores.d.ts.map +1 -1
  133. package/resources/beta/memory-stores/memory-stores.js.map +1 -1
  134. package/resources/beta/memory-stores/memory-stores.mjs.map +1 -1
  135. package/resources/beta/memory-stores/memory-versions.d.mts +17 -2
  136. package/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
  137. package/resources/beta/memory-stores/memory-versions.d.ts +17 -2
  138. package/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
  139. package/resources/beta/messages/batches.d.mts +1 -1
  140. package/resources/beta/messages/batches.d.ts +1 -1
  141. package/resources/beta/messages/batches.js +1 -1
  142. package/resources/beta/messages/batches.mjs +1 -1
  143. package/resources/beta/messages/index.d.mts +1 -1
  144. package/resources/beta/messages/index.d.mts.map +1 -1
  145. package/resources/beta/messages/index.d.ts +1 -1
  146. package/resources/beta/messages/index.d.ts.map +1 -1
  147. package/resources/beta/messages/index.js.map +1 -1
  148. package/resources/beta/messages/index.mjs.map +1 -1
  149. package/resources/beta/messages/messages.d.mts +4 -22
  150. package/resources/beta/messages/messages.d.mts.map +1 -1
  151. package/resources/beta/messages/messages.d.ts +4 -22
  152. package/resources/beta/messages/messages.d.ts.map +1 -1
  153. package/resources/beta/messages/messages.js +2 -2
  154. package/resources/beta/messages/messages.js.map +1 -1
  155. package/resources/beta/messages/messages.mjs +2 -2
  156. package/resources/beta/messages/messages.mjs.map +1 -1
  157. package/resources/beta/sessions/sessions.d.mts +1 -1
  158. package/resources/beta/sessions/sessions.d.ts +1 -1
  159. package/resources/beta/user-profiles.d.mts +37 -11
  160. package/resources/beta/user-profiles.d.mts.map +1 -1
  161. package/resources/beta/user-profiles.d.ts +37 -11
  162. package/resources/beta/user-profiles.d.ts.map +1 -1
  163. package/resources/beta/user-profiles.js +5 -5
  164. package/resources/beta/user-profiles.mjs +5 -5
  165. package/resources/index.d.mts +1 -1
  166. package/resources/index.d.mts.map +1 -1
  167. package/resources/index.d.ts +1 -1
  168. package/resources/index.d.ts.map +1 -1
  169. package/resources/index.js.map +1 -1
  170. package/resources/index.mjs.map +1 -1
  171. package/resources/messages/batches.d.mts +1 -1
  172. package/resources/messages/batches.d.ts +1 -1
  173. package/resources/messages/batches.js +1 -1
  174. package/resources/messages/batches.mjs +1 -1
  175. package/resources/messages/index.d.mts +1 -1
  176. package/resources/messages/index.d.mts.map +1 -1
  177. package/resources/messages/index.d.ts +1 -1
  178. package/resources/messages/index.d.ts.map +1 -1
  179. package/resources/messages/index.js.map +1 -1
  180. package/resources/messages/index.mjs.map +1 -1
  181. package/resources/messages/messages.d.mts +4 -22
  182. package/resources/messages/messages.d.mts.map +1 -1
  183. package/resources/messages/messages.d.ts +4 -22
  184. package/resources/messages/messages.d.ts.map +1 -1
  185. package/resources/messages/messages.js +2 -2
  186. package/resources/messages/messages.js.map +1 -1
  187. package/resources/messages/messages.mjs +2 -2
  188. package/resources/messages/messages.mjs.map +1 -1
  189. package/src/client.ts +1 -3
  190. package/src/core/api-promise.ts +14 -4
  191. package/src/core/error.ts +2 -0
  192. package/src/core/middleware.ts +2 -2
  193. package/src/helpers/beta/zod.ts +1 -3
  194. package/src/helpers/zod.ts +1 -3
  195. package/src/internal/parse.ts +6 -6
  196. package/src/lib/BetaMessageStream.ts +23 -5
  197. package/src/lib/MessageStream.ts +19 -4
  198. package/src/lib/environments/worker.ts +56 -17
  199. package/src/lib/tools/BetaRunnableTool.ts +20 -44
  200. package/src/lib/tools/BetaToolRunner.ts +11 -12
  201. package/src/lib/tools/SessionToolRunner.ts +39 -6
  202. package/src/resources/beta/agents/agents.ts +3 -3
  203. package/src/resources/beta/beta.ts +7 -2
  204. package/src/resources/beta/dreams.ts +56 -7
  205. package/src/resources/beta/environments/environments.ts +4 -3
  206. package/src/resources/beta/index.ts +3 -1
  207. package/src/resources/beta/memory-stores/index.ts +1 -0
  208. package/src/resources/beta/memory-stores/memory-stores.ts +2 -0
  209. package/src/resources/beta/memory-stores/memory-versions.ts +21 -1
  210. package/src/resources/beta/messages/batches.ts +1 -1
  211. package/src/resources/beta/messages/index.ts +0 -1
  212. package/src/resources/beta/messages/messages.ts +3 -26
  213. package/src/resources/beta/sessions/sessions.ts +1 -1
  214. package/src/resources/beta/user-profiles.ts +46 -17
  215. package/src/resources/index.ts +0 -1
  216. package/src/resources/messages/batches.ts +1 -1
  217. package/src/resources/messages/index.ts +0 -1
  218. package/src/resources/messages/messages.ts +4 -27
  219. package/src/tools/agent-toolset/fs-util.ts +43 -23
  220. package/src/tools/agent-toolset/node.ts +1 -1
  221. package/src/tools/agent-toolset/skills.ts +127 -31
  222. package/src/version.ts +1 -1
  223. package/tools/agent-toolset/fs-util.d.mts +14 -2
  224. package/tools/agent-toolset/fs-util.d.mts.map +1 -1
  225. package/tools/agent-toolset/fs-util.d.ts +14 -2
  226. package/tools/agent-toolset/fs-util.d.ts.map +1 -1
  227. package/tools/agent-toolset/fs-util.js +46 -24
  228. package/tools/agent-toolset/fs-util.js.map +1 -1
  229. package/tools/agent-toolset/fs-util.mjs +45 -24
  230. package/tools/agent-toolset/fs-util.mjs.map +1 -1
  231. package/tools/agent-toolset/node.js +1 -1
  232. package/tools/agent-toolset/node.js.map +1 -1
  233. package/tools/agent-toolset/node.mjs +1 -1
  234. package/tools/agent-toolset/node.mjs.map +1 -1
  235. package/tools/agent-toolset/skills.d.mts +26 -3
  236. package/tools/agent-toolset/skills.d.mts.map +1 -1
  237. package/tools/agent-toolset/skills.d.ts +26 -3
  238. package/tools/agent-toolset/skills.d.ts.map +1 -1
  239. package/tools/agent-toolset/skills.js +114 -29
  240. package/tools/agent-toolset/skills.js.map +1 -1
  241. package/tools/agent-toolset/skills.mjs +113 -30
  242. package/tools/agent-toolset/skills.mjs.map +1 -1
  243. package/version.d.mts +1 -1
  244. package/version.d.ts +1 -1
  245. package/version.js +1 -1
  246. package/version.mjs +1 -1
@@ -11,7 +11,7 @@ import type {
11
11
  import type { BetaToolResultContentBlockParam } from '../../resources/beta';
12
12
  import { loggerFor, type Logger } from '../../internal/utils/log';
13
13
  import { sleep } from '../../internal/utils/sleep';
14
- import { isFatal4xx } from '../../internal/utils/backoff';
14
+ import { applyJitter, backoff, isFatal4xx } from '../../internal/utils/backoff';
15
15
  import { linkAbort } from '../../internal/utils/abort';
16
16
  import { AsyncQueue } from '../../internal/utils/async-queue';
17
17
  import { buildHeaders } from '../../internal/headers';
@@ -27,7 +27,16 @@ const STREAM_BACKOFF_START_MS = 500;
27
27
  const STREAM_BACKOFF_CAP_MS = 10_000;
28
28
  const TOOL_TIMEOUT_MS = 120_000;
29
29
  const DRAIN_TIMEOUT_MS = 30_000;
30
- const SEND_RETRIES = 3;
30
+ const SEND_BACKOFF_START_MS = 1_000;
31
+ const SEND_BACKOFF_CAP_MS = 30_000;
32
+ /**
33
+ * How long a transiently failing tool-result send keeps retrying when the
34
+ * runner is used on its own: the server's default work-item lease TTL.
35
+ * `EnvironmentWorker` overrides it with the live TTL from each lease heartbeat
36
+ * (`_setSendRetryWindow`), so a send is only abandoned once the lease can no
37
+ * longer be ours.
38
+ */
39
+ const SEND_RETRY_WINDOW_MS = 5 * 60_000;
31
40
 
32
41
  /** Block type accepted in a `user.tool_result` event's content — codegen'd, stays in sync with the API. */
33
42
  type SessionContentBlock = NonNullable<BetaManagedAgentsUserToolResultEventParams['content']>[number];
@@ -310,6 +319,7 @@ export class SessionToolRunner implements AsyncIterable<DispatchedToolCall> {
310
319
  readonly #awaitingConfirmation = new Map<string, DispatchedToolUseEvent>();
311
320
  readonly #results = new AsyncQueue<DispatchedToolCall>();
312
321
  #inFlightCount = 0;
322
+ #sendRetryWindowMs = SEND_RETRY_WINDOW_MS;
313
323
  #onIdle: (() => void) | null = null;
314
324
  readonly #idleClock: IdleClock;
315
325
 
@@ -343,6 +353,15 @@ export class SessionToolRunner implements AsyncIterable<DispatchedToolCall> {
343
353
  this.#controller.abort();
344
354
  }
345
355
 
356
+ /**
357
+ * @internal
358
+ * `EnvironmentWorker` keeps this equal to the lease TTL each heartbeat
359
+ * reports; applies to a send already retrying.
360
+ */
361
+ _setSendRetryWindow(ms: number): void {
362
+ this.#sendRetryWindowMs = ms;
363
+ }
364
+
346
365
  async *[Symbol.asyncIterator](): AsyncIterator<DispatchedToolCall> {
347
366
  if (this.#consumed) {
348
367
  throw new AnthropicError('Cannot iterate over a consumed SessionToolRunner');
@@ -764,8 +783,11 @@ export class SessionToolRunner implements AsyncIterable<DispatchedToolCall> {
764
783
 
765
784
  async #sendResult(result: DispatchedToolResultParams, toolUseId: string): Promise<boolean> {
766
785
  const ctrl = this.#controller;
786
+ const start = Date.now();
767
787
  let lastErr: unknown;
768
- for (let i = 0; i < SEND_RETRIES; i++) {
788
+ let attempt = 0;
789
+ while (true) {
790
+ attempt++;
769
791
  // An abort throws to unwind the caller rather than returning a
770
792
  // `posted: false` result the iterator would carry on past.
771
793
  ctrl.signal.throwIfAborted();
@@ -782,13 +804,24 @@ export class SessionToolRunner implements AsyncIterable<DispatchedToolCall> {
782
804
  // Only short-circuit on a permanent 4xx; 408/409/429 deserve the
783
805
  // remaining retries (aligned with the core client's retry policy).
784
806
  if (isFatal4xx(e)) break;
785
- // Back off only *between* attempts never after the final one, since
786
- // there is no further try left to wait for.
787
- if (i < SEND_RETRIES - 1) await sleep((i + 1) * 1000, ctrl.signal);
807
+ const remainingMs = this.#sendRetryWindowMs - (Date.now() - start);
808
+ if (remainingMs <= 0) break;
809
+ const waitMs = Math.min(
810
+ applyJitter(backoff(attempt - 1, SEND_BACKOFF_START_MS, SEND_BACKOFF_CAP_MS)),
811
+ remainingMs,
812
+ );
813
+ this.#logger.warn('tool result send failed; retrying', {
814
+ tool_use_id: toolUseId,
815
+ attempt,
816
+ backoff_ms: waitMs,
817
+ error: String(e),
818
+ });
819
+ await sleep(waitMs, ctrl.signal);
788
820
  }
789
821
  }
790
822
  this.#logger.error('failed to send tool result', {
791
823
  tool_use_id: toolUseId,
824
+ attempts: attempt,
792
825
  error: String(lastErr),
793
826
  });
794
827
  return false;
@@ -21,7 +21,7 @@ export class Agents extends APIResource {
21
21
  * ```ts
22
22
  * const betaManagedAgentsAgent =
23
23
  * await client.beta.agents.create({
24
- * model: 'claude-sonnet-4-6',
24
+ * model: 'claude-opus-5',
25
25
  * name: 'My First Agent',
26
26
  * });
27
27
  * ```
@@ -915,7 +915,7 @@ export interface AgentCreateParams {
915
915
  /**
916
916
  * Body param: Model identifier. Accepts the
917
917
  * [model string](https://platform.claude.com/docs/en/about-claude/models/overview#latest-models-comparison),
918
- * e.g. `claude-opus-4-6`, or a `model_config` object for additional configuration
918
+ * e.g. `claude-opus-5`, or a `model_config` object for additional configuration
919
919
  * control
920
920
  */
921
921
  model: BetaManagedAgentsModel | BetaManagedAgentsModelConfigParams;
@@ -1015,7 +1015,7 @@ export interface AgentUpdateParams {
1015
1015
  /**
1016
1016
  * Body param: Model identifier. Accepts the
1017
1017
  * [model string](https://platform.claude.com/docs/en/about-claude/models/overview#latest-models-comparison),
1018
- * e.g. `claude-opus-4-6`, or a `model_config` object for additional configuration
1018
+ * e.g. `claude-opus-5`, or a `model_config` object for additional configuration
1019
1019
  * control. Omit to preserve. Cannot be cleared.
1020
1020
  */
1021
1021
  model?: BetaManagedAgentsModel | BetaManagedAgentsModelConfigParams;
@@ -89,6 +89,9 @@ import {
89
89
  BetaDreamStatus,
90
90
  BetaDreamUsage,
91
91
  BetaDreamsPageCursor,
92
+ BetaOutputBehavior,
93
+ BetaOutputBehaviorCreateNew,
94
+ BetaOutputBehaviorUpdateExisting,
92
95
  DreamArchiveParams,
93
96
  DreamCancelParams,
94
97
  DreamCreateParams,
@@ -400,7 +403,6 @@ import {
400
403
  BetaMessageParam,
401
404
  BetaMessageTokensCount,
402
405
  BetaMetadata,
403
- BetaMidConversationSystemBlockParam,
404
406
  BetaOutputConfig,
405
407
  BetaOutputTokensDetails,
406
408
  BetaPlainTextSource,
@@ -643,6 +645,7 @@ export type AnthropicBeta =
643
645
  | 'fast-mode-2026-02-01'
644
646
  | 'output-300k-2026-03-24'
645
647
  | 'user-profiles-2026-03-24'
648
+ | 'user-profiles-2026-08-18'
646
649
  | 'advisor-tool-2026-03-01'
647
650
  | 'managed-agents-2026-04-01'
648
651
  | 'cache-diagnosis-2026-04-07'
@@ -921,7 +924,6 @@ export declare namespace Beta {
921
924
  type BetaMessageParam as BetaMessageParam,
922
925
  type BetaMessageTokensCount as BetaMessageTokensCount,
923
926
  type BetaMetadata as BetaMetadata,
924
- type BetaMidConversationSystemBlockParam as BetaMidConversationSystemBlockParam,
925
927
  type BetaOutputConfig as BetaOutputConfig,
926
928
  type BetaOutputTokensDetails as BetaOutputTokensDetails,
927
929
  type BetaPlainTextSource as BetaPlainTextSource,
@@ -1361,6 +1363,9 @@ export declare namespace Beta {
1361
1363
  type BetaDreamSessionsInput as BetaDreamSessionsInput,
1362
1364
  type BetaDreamStatus as BetaDreamStatus,
1363
1365
  type BetaDreamUsage as BetaDreamUsage,
1366
+ type BetaOutputBehavior as BetaOutputBehavior,
1367
+ type BetaOutputBehaviorCreateNew as BetaOutputBehaviorCreateNew,
1368
+ type BetaOutputBehaviorUpdateExisting as BetaOutputBehaviorUpdateExisting,
1364
1369
  type BetaDreamsPageCursor as BetaDreamsPageCursor,
1365
1370
  type DreamCreateParams as DreamCreateParams,
1366
1371
  type DreamRetrieveParams as DreamRetrieveParams,
@@ -138,9 +138,10 @@ export type BetaDreamsPageCursor = PageCursor<BetaDream>;
138
138
 
139
139
  /**
140
140
  * An asynchronous memory-consolidation job that reads a memory store plus a set of
141
- * session transcripts and writes consolidated memories into a new output memory
142
- * store. The Dreams API is in research preview: the request and response shapes
143
- * are volatile and may change without the deprecation period that applies to
141
+ * session transcripts and writes consolidated memories into an output memory store
142
+ * a new store by default, or an existing store chosen via output_behavior. The
143
+ * Dreams API is in research preview: the request and response shapes are volatile
144
+ * and may change without the deprecation period that applies to
144
145
  * generally-available endpoints.
145
146
  */
146
147
  export interface BetaDream {
@@ -176,6 +177,13 @@ export interface BetaDream {
176
177
  */
177
178
  model: BetaDreamModelConfig;
178
179
 
180
+ /**
181
+ * The default destination: the job creates a new output memory store as a clone of
182
+ * the memory_store input and writes the consolidated memories into it. The input
183
+ * store is never mutated.
184
+ */
185
+ output_behavior: BetaOutputBehavior;
186
+
179
187
  outputs: Array<BetaDreamOutput>;
180
188
 
181
189
  session_id: string | null;
@@ -203,12 +211,16 @@ export interface BetaDreamError {
203
211
  }
204
212
 
205
213
  /**
206
- * An input memory store the dream reads from. The dream never mutates this store.
214
+ * An input memory store the dream reads from. The dream never mutates this store
215
+ * unless it is also the destination: with output_behavior {type:
216
+ * "update_existing"} the job consolidates this store in place.
207
217
  */
208
218
  export type BetaDreamInput = BetaDreamMemoryStoreInput | BetaDreamSessionsInput;
209
219
 
210
220
  /**
211
- * An input memory store the dream reads from. The dream never mutates this store.
221
+ * An input memory store the dream reads from. The dream never mutates this store
222
+ * unless it is also the destination: with output_behavior {type:
223
+ * "update_existing"} the job consolidates this store in place.
212
224
  */
213
225
  export interface BetaDreamMemoryStoreInput {
214
226
  memory_store_id: string;
@@ -231,7 +243,7 @@ export interface BetaDreamMemoryStoreOutput {
231
243
  */
232
244
  export interface BetaDreamModelConfig {
233
245
  /**
234
- * Model identifier, e.g. "claude-opus-4-7". 1-256 characters.
246
+ * Model identifier, e.g. "claude-opus-5". 1-256 characters.
235
247
  */
236
248
  id: string;
237
249
 
@@ -248,7 +260,7 @@ export interface BetaDreamModelConfig {
248
260
  */
249
261
  export interface BetaDreamModelConfigParam {
250
262
  /**
251
- * Model identifier, e.g. "claude-opus-4-7". 1-256 characters.
263
+ * Model identifier, e.g. "claude-opus-5". 1-256 characters.
252
264
  */
253
265
  id: string;
254
266
 
@@ -308,6 +320,33 @@ export interface BetaDreamUsage {
308
320
  output_tokens: number;
309
321
  }
310
322
 
323
+ /**
324
+ * The default destination: the job creates a new output memory store as a clone of
325
+ * the memory_store input and writes the consolidated memories into it. The input
326
+ * store is never mutated.
327
+ */
328
+ export type BetaOutputBehavior = BetaOutputBehaviorCreateNew | BetaOutputBehaviorUpdateExisting;
329
+
330
+ /**
331
+ * The default destination: the job creates a new output memory store as a clone of
332
+ * the memory_store input and writes the consolidated memories into it. The input
333
+ * store is never mutated.
334
+ */
335
+ export interface BetaOutputBehaviorCreateNew {
336
+ type: 'create_new';
337
+ }
338
+
339
+ /**
340
+ * The job writes the consolidated memories into this existing memory store instead
341
+ * of creating one. In EAP the store must be the job's own memory_store input, so
342
+ * the job consolidates the store in place.
343
+ */
344
+ export interface BetaOutputBehaviorUpdateExisting {
345
+ memory_store_id: string;
346
+
347
+ type: 'update_existing';
348
+ }
349
+
311
350
  export interface DreamCreateParams {
312
351
  /**
313
352
  * Body param
@@ -324,6 +363,13 @@ export interface DreamCreateParams {
324
363
  */
325
364
  instructions?: string | null;
326
365
 
366
+ /**
367
+ * Body param: The default destination: the job creates a new output memory store
368
+ * as a clone of the memory_store input and writes the consolidated memories into
369
+ * it. The input store is never mutated.
370
+ */
371
+ output_behavior?: BetaOutputBehavior;
372
+
327
373
  /**
328
374
  * Header param: Optional header to specify the beta version(s) you want to use.
329
375
  */
@@ -394,6 +440,9 @@ export declare namespace Dreams {
394
440
  type BetaDreamSessionsInput as BetaDreamSessionsInput,
395
441
  type BetaDreamStatus as BetaDreamStatus,
396
442
  type BetaDreamUsage as BetaDreamUsage,
443
+ type BetaOutputBehavior as BetaOutputBehavior,
444
+ type BetaOutputBehaviorCreateNew as BetaOutputBehaviorCreateNew,
445
+ type BetaOutputBehaviorUpdateExisting as BetaOutputBehaviorUpdateExisting,
397
446
  type BetaDreamsPageCursor as BetaDreamsPageCursor,
398
447
  type DreamCreateParams as DreamCreateParams,
399
448
  type DreamRetrieveParams as DreamRetrieveParams,
@@ -260,9 +260,9 @@ export interface BetaEnvironment {
260
260
  created_at: string;
261
261
 
262
262
  /**
263
- * User-provided description for the environment
263
+ * User-provided description for the environment; null when unset
264
264
  */
265
- description: string;
265
+ description: string | null;
266
266
 
267
267
  /**
268
268
  * User-provided metadata key-value pairs
@@ -525,7 +525,8 @@ export interface EnvironmentUpdateParams {
525
525
  config?: BetaCloudConfigParams | BetaSelfHostedConfigParams | null;
526
526
 
527
527
  /**
528
- * Body param: Updated description of the environment
528
+ * Body param: Updated description of the environment. Omit to preserve; null
529
+ * clears to null; an empty string is stored as an empty string.
529
530
  */
530
531
  description?: string | null;
531
532
 
@@ -156,6 +156,9 @@ export {
156
156
  type BetaDreamSessionsInput,
157
157
  type BetaDreamStatus,
158
158
  type BetaDreamUsage,
159
+ type BetaOutputBehavior,
160
+ type BetaOutputBehaviorCreateNew,
161
+ type BetaOutputBehaviorUpdateExisting,
159
162
  type DreamCreateParams,
160
163
  type DreamRetrieveParams,
161
164
  type DreamListParams,
@@ -333,7 +336,6 @@ export {
333
336
  type BetaMessageParam,
334
337
  type BetaMessageTokensCount,
335
338
  type BetaMetadata,
336
- type BetaMidConversationSystemBlockParam,
337
339
  type BetaOutputConfig,
338
340
  type BetaOutputTokensDetails,
339
341
  type BetaPlainTextSource,
@@ -38,6 +38,7 @@ export {
38
38
  type BetaManagedAgentsAPIActor,
39
39
  type BetaManagedAgentsMemoryVersion,
40
40
  type BetaManagedAgentsMemoryVersionOperation,
41
+ type BetaManagedAgentsServiceAccountActor,
41
42
  type BetaManagedAgentsSessionActor,
42
43
  type BetaManagedAgentsUserActor,
43
44
  type MemoryVersionRetrieveParams,
@@ -30,6 +30,7 @@ import {
30
30
  BetaManagedAgentsMemoryVersion,
31
31
  BetaManagedAgentsMemoryVersionOperation,
32
32
  BetaManagedAgentsMemoryVersionsPageCursor,
33
+ BetaManagedAgentsServiceAccountActor,
33
34
  BetaManagedAgentsSessionActor,
34
35
  BetaManagedAgentsUserActor,
35
36
  MemoryVersionListParams,
@@ -408,6 +409,7 @@ export declare namespace MemoryStores {
408
409
  type BetaManagedAgentsAPIActor as BetaManagedAgentsAPIActor,
409
410
  type BetaManagedAgentsMemoryVersion as BetaManagedAgentsMemoryVersion,
410
411
  type BetaManagedAgentsMemoryVersionOperation as BetaManagedAgentsMemoryVersionOperation,
412
+ type BetaManagedAgentsServiceAccountActor as BetaManagedAgentsServiceAccountActor,
411
413
  type BetaManagedAgentsSessionActor as BetaManagedAgentsSessionActor,
412
414
  type BetaManagedAgentsUserActor as BetaManagedAgentsUserActor,
413
415
  type BetaManagedAgentsMemoryVersionsPageCursor as BetaManagedAgentsMemoryVersionsPageCursor,
@@ -117,7 +117,8 @@ export type BetaManagedAgentsMemoryVersionsPageCursor = PageCursor<BetaManagedAg
117
117
  export type BetaManagedAgentsActor =
118
118
  | BetaManagedAgentsSessionActor
119
119
  | BetaManagedAgentsAPIActor
120
- | BetaManagedAgentsUserActor;
120
+ | BetaManagedAgentsUserActor
121
+ | BetaManagedAgentsServiceAccountActor;
121
122
 
122
123
  /**
123
124
  * Attribution for a write made directly via the public API (outside of any
@@ -228,6 +229,19 @@ export interface BetaManagedAgentsMemoryVersion {
228
229
  */
229
230
  export type BetaManagedAgentsMemoryVersionOperation = 'created' | 'modified' | 'deleted';
230
231
 
232
+ /**
233
+ * Attribution for a write made by a workload authenticated as a service account,
234
+ * for example via Workload Identity Federation.
235
+ */
236
+ export interface BetaManagedAgentsServiceAccountActor {
237
+ /**
238
+ * ID of the service account that performed the write (a `svac_...` value).
239
+ */
240
+ service_account_id: string;
241
+
242
+ type: 'service_account_actor';
243
+ }
244
+
231
245
  /**
232
246
  * Attribution for a write made by an agent during a session, through the mounted
233
247
  * filesystem at `/mnt/memory/`.
@@ -298,6 +312,11 @@ export interface MemoryVersionListParams extends PageCursorParams {
298
312
  */
299
313
  operation?: BetaManagedAgentsMemoryVersionOperation;
300
314
 
315
+ /**
316
+ * Query param: Query parameter for service_account_id
317
+ */
318
+ service_account_id?: string;
319
+
301
320
  /**
302
321
  * Query param: Query parameter for session_id
303
322
  */
@@ -332,6 +351,7 @@ export declare namespace MemoryVersions {
332
351
  type BetaManagedAgentsAPIActor as BetaManagedAgentsAPIActor,
333
352
  type BetaManagedAgentsMemoryVersion as BetaManagedAgentsMemoryVersion,
334
353
  type BetaManagedAgentsMemoryVersionOperation as BetaManagedAgentsMemoryVersionOperation,
354
+ type BetaManagedAgentsServiceAccountActor as BetaManagedAgentsServiceAccountActor,
335
355
  type BetaManagedAgentsSessionActor as BetaManagedAgentsSessionActor,
336
356
  type BetaManagedAgentsUserActor as BetaManagedAgentsUserActor,
337
357
  type BetaManagedAgentsMemoryVersionsPageCursor as BetaManagedAgentsMemoryVersionsPageCursor,
@@ -35,7 +35,7 @@ export class Batches extends APIResource {
35
35
  * messages: [
36
36
  * { content: 'Hello, world', role: 'user' },
37
37
  * ],
38
- * model: 'claude-opus-4-6',
38
+ * model: 'claude-opus-5',
39
39
  * },
40
40
  * },
41
41
  * ],
@@ -142,7 +142,6 @@ export {
142
142
  type BetaMessageParam,
143
143
  type BetaMessageTokensCount,
144
144
  type BetaMetadata,
145
- type BetaMidConversationSystemBlockParam,
146
145
  type BetaOutputConfig,
147
146
  type BetaOutputTokensDetails,
148
147
  type BetaPlainTextSource,
@@ -70,7 +70,7 @@ export class Messages extends APIResource {
70
70
  * const betaMessage = await client.beta.messages.create({
71
71
  * max_tokens: 1024,
72
72
  * messages: [{ content: 'Hello, world', role: 'user' }],
73
- * model: 'claude-opus-4-6',
73
+ * model: 'claude-opus-5',
74
74
  * });
75
75
  * ```
76
76
  */
@@ -110,7 +110,7 @@ export class Messages extends APIResource {
110
110
  );
111
111
  }
112
112
 
113
- let timeout = (this._client as any)._options.timeout as number | null;
113
+ let timeout = options?.timeout ?? ((this._client as any)._options.timeout as number | null);
114
114
  if (!body.stream && timeout == null) {
115
115
  const maxNonstreamingTokens = MODEL_NONSTREAMING_TOKENS[body.model] ?? undefined;
116
116
  timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
@@ -192,7 +192,7 @@ export class Messages extends APIResource {
192
192
  * const betaMessageTokensCount =
193
193
  * await client.beta.messages.countTokens({
194
194
  * messages: [{ content: 'Hello, world', role: 'user' }],
195
- * model: 'claude-opus-4-6',
195
+ * model: 'claude-opus-5',
196
196
  * });
197
197
  * ```
198
198
  */
@@ -1419,7 +1419,6 @@ export type BetaContentBlockParam =
1419
1419
  | BetaRequestMCPToolResultBlockParam
1420
1420
  | BetaContainerUploadBlockParam
1421
1421
  | BetaCompactionBlockParam
1422
- | BetaMidConversationSystemBlockParam
1423
1422
  | BetaRequestToolAdditionBlock
1424
1423
  | BetaRequestToolRemovalBlock
1425
1424
  | BetaFallbackBlockParam;
@@ -2418,27 +2417,6 @@ export interface BetaMetadata {
2418
2417
  user_id?: string | null;
2419
2418
  }
2420
2419
 
2421
- /**
2422
- * System instructions that appear mid-conversation.
2423
- *
2424
- * Use this block to provide or update system-level instructions at a specific
2425
- * point in the conversation, rather than only via the top-level `system`
2426
- * parameter.
2427
- */
2428
- export interface BetaMidConversationSystemBlockParam {
2429
- /**
2430
- * System instruction text blocks.
2431
- */
2432
- content: Array<BetaTextBlockParam | BetaRequestToolAdditionBlock | BetaRequestToolRemovalBlock>;
2433
-
2434
- type: 'mid_conv_system';
2435
-
2436
- /**
2437
- * Create a cache control breakpoint at this content block.
2438
- */
2439
- cache_control?: BetaCacheControlEphemeral | null;
2440
- }
2441
-
2442
2420
  export interface BetaOutputConfig {
2443
2421
  /**
2444
2422
  * All possible effort levels.
@@ -5560,7 +5538,6 @@ export declare namespace Messages {
5560
5538
  type BetaMessageParam as BetaMessageParam,
5561
5539
  type BetaMessageTokensCount as BetaMessageTokensCount,
5562
5540
  type BetaMetadata as BetaMetadata,
5563
- type BetaMidConversationSystemBlockParam as BetaMidConversationSystemBlockParam,
5564
5541
  type BetaOutputConfig as BetaOutputConfig,
5565
5542
  type BetaOutputTokensDetails as BetaOutputTokensDetails,
5566
5543
  type BetaPlainTextSource as BetaPlainTextSource,
@@ -370,7 +370,7 @@ export interface BetaManagedAgentsAgentWithOverridesParams {
370
370
  mcp_servers?: Array<AgentsAPI.BetaManagedAgentsURLMCPServerParams>;
371
371
 
372
372
  /**
373
- * Replacement model. Accepts the model string, e.g. `claude-opus-4-6`, or a
373
+ * Replacement model. Accepts the model string, e.g. `claude-opus-5`, or a
374
374
  * `model_config` object. Omit to use the agent's model.
375
375
  */
376
376
  model?: AgentsAPI.BetaManagedAgentsModel | AgentsAPI.BetaManagedAgentsModelConfigParams;
@@ -24,7 +24,7 @@ export class UserProfiles extends APIResource {
24
24
  body,
25
25
  ...options,
26
26
  headers: buildHeaders([
27
- { 'anthropic-beta': [...(betas ?? []), 'user-profiles-2026-03-24'].toString() },
27
+ { 'anthropic-beta': [...(betas ?? []), 'user-profiles-2026-08-18'].toString() },
28
28
  options?.headers,
29
29
  ]),
30
30
  });
@@ -50,7 +50,7 @@ export class UserProfiles extends APIResource {
50
50
  return this._client.get(path`/v1/user_profiles/${userProfileID}?beta=true`, {
51
51
  ...options,
52
52
  headers: buildHeaders([
53
- { 'anthropic-beta': [...(betas ?? []), 'user-profiles-2026-03-24'].toString() },
53
+ { 'anthropic-beta': [...(betas ?? []), 'user-profiles-2026-08-18'].toString() },
54
54
  options?.headers,
55
55
  ]),
56
56
  });
@@ -77,7 +77,7 @@ export class UserProfiles extends APIResource {
77
77
  body,
78
78
  ...options,
79
79
  headers: buildHeaders([
80
- { 'anthropic-beta': [...(betas ?? []), 'user-profiles-2026-03-24'].toString() },
80
+ { 'anthropic-beta': [...(betas ?? []), 'user-profiles-2026-08-18'].toString() },
81
81
  options?.headers,
82
82
  ]),
83
83
  });
@@ -103,7 +103,7 @@ export class UserProfiles extends APIResource {
103
103
  query,
104
104
  ...options,
105
105
  headers: buildHeaders([
106
- { 'anthropic-beta': [...(betas ?? []), 'user-profiles-2026-03-24'].toString() },
106
+ { 'anthropic-beta': [...(betas ?? []), 'user-profiles-2026-08-18'].toString() },
107
107
  options?.headers,
108
108
  ]),
109
109
  });
@@ -129,7 +129,7 @@ export class UserProfiles extends APIResource {
129
129
  return this._client.post(path`/v1/user_profiles/${userProfileID}/enrollment_url?beta=true`, {
130
130
  ...options,
131
131
  headers: buildHeaders([
132
- { 'anthropic-beta': [...(betas ?? []), 'user-profiles-2026-03-24'].toString() },
132
+ { 'anthropic-beta': [...(betas ?? []), 'user-profiles-2026-08-18'].toString() },
133
133
  options?.headers,
134
134
  ]),
135
135
  });
@@ -155,13 +155,6 @@ export interface BetaUserProfile {
155
155
  */
156
156
  metadata: { [key: string]: string };
157
157
 
158
- /**
159
- * How the entity behind a user profile relates to the platform that owns the API
160
- * key. `external`: an individual end-user of the platform. `resold`: a company the
161
- * platform resells Claude access to. `internal`: the platform's own usage.
162
- */
163
- relationship: 'external' | 'resold' | 'internal';
164
-
165
158
  /**
166
159
  * Trust grants for this profile, keyed by grant name. Key omitted when no grant is
167
160
  * active or in flight.
@@ -178,16 +171,33 @@ export interface BetaUserProfile {
178
171
  */
179
172
  updated_at: string;
180
173
 
174
+ /**
175
+ * How the platform uses the API on behalf of the entity this profile represents.
176
+ * `application`: the platform sells a product that uses the API behind the scenes,
177
+ * and the profile represents an individual end-user of that product.
178
+ * `passthrough`: the platform resells raw inference, and the profile identifies
179
+ * the resold-to company.
180
+ */
181
+ access_type?: 'application' | 'passthrough';
182
+
181
183
  /**
182
184
  * Platform's own identifier for this user. Not enforced unique.
183
185
  */
184
186
  external_id?: string | null;
185
187
 
186
188
  /**
187
- * Display name of the entity this profile represents. For `resold` this is the
188
- * resold-to company's name.
189
+ * Real-world name of the entity this profile represents (company or individual).
190
+ * For a resold-to company (`access_type` `passthrough`, or `relationship` `resold`
191
+ * under the `user-profiles-2026-03-24` header) this is that company's name.
189
192
  */
190
193
  name?: string | null;
194
+
195
+ /**
196
+ * How the entity behind a user profile relates to the platform that owns the API
197
+ * key. `external`: an individual end-user of the platform. `resold`: a company the
198
+ * platform resells Claude access to. `internal`: the platform's own usage.
199
+ */
200
+ relationship?: 'external' | 'resold' | 'internal';
191
201
  }
192
202
 
193
203
  export interface BetaUserProfileEnrollmentURL {
@@ -215,6 +225,15 @@ export interface BetaUserProfileTrustGrant {
215
225
  }
216
226
 
217
227
  export interface UserProfileCreateParams {
228
+ /**
229
+ * Body param: How the platform uses the API on behalf of the entity this profile
230
+ * represents. `application`: the platform sells a product that uses the API behind
231
+ * the scenes, and the profile represents an individual end-user of that product.
232
+ * `passthrough`: the platform resells raw inference, and the profile identifies
233
+ * the resold-to company.
234
+ */
235
+ access_type?: 'application' | 'passthrough';
236
+
218
237
  /**
219
238
  * Body param: Platform's own identifier for this user. Not enforced unique.
220
239
  * Maximum 255 characters.
@@ -229,9 +248,10 @@ export interface UserProfileCreateParams {
229
248
  metadata?: { [key: string]: string };
230
249
 
231
250
  /**
232
- * Body param: Display name of the entity this profile represents. Required when
233
- * relationship is `resold` (the resold-to company's name); optional otherwise.
234
- * Maximum 255 characters.
251
+ * Body param: Optional for all profiles. Real-world name of the entity this
252
+ * profile represents (company or individual); for a resold-to company
253
+ * (`relationship` `resold` / `access_type` `passthrough`), that company's name
254
+ * where known. Maximum 255 characters.
235
255
  */
236
256
  name?: string | null;
237
257
 
@@ -257,6 +277,15 @@ export interface UserProfileRetrieveParams {
257
277
  }
258
278
 
259
279
  export interface UserProfileUpdateParams {
280
+ /**
281
+ * Body param: How the platform uses the API on behalf of the entity this profile
282
+ * represents. `application`: the platform sells a product that uses the API behind
283
+ * the scenes, and the profile represents an individual end-user of that product.
284
+ * `passthrough`: the platform resells raw inference, and the profile identifies
285
+ * the resold-to company.
286
+ */
287
+ access_type?: 'application' | 'passthrough' | null;
288
+
260
289
  /**
261
290
  * Body param: If present, replaces the stored external_id. Omit to leave
262
291
  * unchanged. Maximum 255 characters.
@@ -94,7 +94,6 @@ export {
94
94
  type MessageStreamParams,
95
95
  type MessageTokensCount,
96
96
  type Metadata,
97
- type MidConversationSystemBlockParam,
98
97
  type Model,
99
98
  type OutputConfig,
100
99
  type OutputTokensDetails,
@@ -33,7 +33,7 @@ export class Batches extends APIResource {
33
33
  * messages: [
34
34
  * { content: 'Hello, world', role: 'user' },
35
35
  * ],
36
- * model: 'claude-opus-4-6',
36
+ * model: 'claude-opus-5',
37
37
  * },
38
38
  * },
39
39
  * ],
@@ -83,7 +83,6 @@ export {
83
83
  type MessageParam,
84
84
  type MessageTokensCount,
85
85
  type Metadata,
86
- type MidConversationSystemBlockParam,
87
86
  type Model,
88
87
  type OutputConfig,
89
88
  type OutputTokensDetails,