@anthropic-ai/sdk 0.122.0 → 0.123.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 (206) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/core/credentials.d.mts.map +1 -1
  3. package/core/credentials.d.ts.map +1 -1
  4. package/core/credentials.js +5 -7
  5. package/core/credentials.js.map +1 -1
  6. package/core/credentials.mjs +5 -7
  7. package/core/credentials.mjs.map +1 -1
  8. package/internal/file-store.d.mts.map +1 -1
  9. package/internal/file-store.d.ts.map +1 -1
  10. package/internal/file-store.js +23 -25
  11. package/internal/file-store.js.map +1 -1
  12. package/internal/file-store.mjs +5 -6
  13. package/internal/file-store.mjs.map +1 -1
  14. package/internal/node.browser.d.mts +9 -0
  15. package/internal/node.browser.d.mts.map +1 -0
  16. package/internal/node.browser.d.ts +9 -0
  17. package/internal/node.browser.d.ts.map +1 -0
  18. package/internal/node.browser.js +22 -0
  19. package/internal/node.browser.js.map +1 -0
  20. package/internal/node.browser.mjs +19 -0
  21. package/internal/node.browser.mjs.map +1 -0
  22. package/internal/node.d.mts +14 -0
  23. package/internal/node.d.mts.map +1 -0
  24. package/internal/node.d.ts +14 -0
  25. package/internal/node.d.ts.map +1 -0
  26. package/internal/node.js +24 -0
  27. package/internal/node.js.map +1 -0
  28. package/internal/node.mjs +14 -0
  29. package/internal/node.mjs.map +1 -0
  30. package/lib/BetaMessageStream.d.mts.map +1 -1
  31. package/lib/BetaMessageStream.d.ts.map +1 -1
  32. package/lib/BetaMessageStream.js +3 -0
  33. package/lib/BetaMessageStream.js.map +1 -1
  34. package/lib/BetaMessageStream.mjs +3 -0
  35. package/lib/BetaMessageStream.mjs.map +1 -1
  36. package/lib/credentials/credential-chain.js +1 -1
  37. package/lib/credentials/credential-chain.js.map +1 -1
  38. package/lib/credentials/credential-chain.mjs +1 -1
  39. package/lib/credentials/credential-chain.mjs.map +1 -1
  40. package/lib/credentials/identity-token.js +1 -1
  41. package/lib/credentials/identity-token.js.map +1 -1
  42. package/lib/credentials/identity-token.mjs +1 -1
  43. package/lib/credentials/identity-token.mjs.map +1 -1
  44. package/lib/credentials/types.d.mts.map +1 -1
  45. package/lib/credentials/types.d.ts.map +1 -1
  46. package/lib/credentials/types.js +2 -3
  47. package/lib/credentials/types.js.map +1 -1
  48. package/lib/credentials/types.mjs +2 -3
  49. package/lib/credentials/types.mjs.map +1 -1
  50. package/lib/credentials/user-oauth.js +1 -1
  51. package/lib/credentials/user-oauth.js.map +1 -1
  52. package/lib/credentials/user-oauth.mjs +1 -1
  53. package/lib/credentials/user-oauth.mjs.map +1 -1
  54. package/lib/middleware.d.mts.map +1 -1
  55. package/lib/middleware.d.ts.map +1 -1
  56. package/lib/middleware.js +30 -7
  57. package/lib/middleware.js.map +1 -1
  58. package/lib/middleware.mjs +30 -7
  59. package/lib/middleware.mjs.map +1 -1
  60. package/package.json +3 -1
  61. package/resources/beta/agents/agents.d.mts +1 -1
  62. package/resources/beta/agents/agents.d.mts.map +1 -1
  63. package/resources/beta/agents/agents.d.ts +1 -1
  64. package/resources/beta/agents/agents.d.ts.map +1 -1
  65. package/resources/beta/agents/agents.js.map +1 -1
  66. package/resources/beta/agents/agents.mjs.map +1 -1
  67. package/resources/beta/beta.d.mts +5 -5
  68. package/resources/beta/beta.d.mts.map +1 -1
  69. package/resources/beta/beta.d.ts +5 -5
  70. package/resources/beta/beta.d.ts.map +1 -1
  71. package/resources/beta/beta.js.map +1 -1
  72. package/resources/beta/beta.mjs.map +1 -1
  73. package/resources/beta/deployment-runs.d.mts +6 -6
  74. package/resources/beta/deployment-runs.d.ts +6 -6
  75. package/resources/beta/deployments.d.mts +3 -2
  76. package/resources/beta/deployments.d.mts.map +1 -1
  77. package/resources/beta/deployments.d.ts +3 -2
  78. package/resources/beta/deployments.d.ts.map +1 -1
  79. package/resources/beta/dreams.d.mts +28 -1
  80. package/resources/beta/dreams.d.mts.map +1 -1
  81. package/resources/beta/dreams.d.ts +28 -1
  82. package/resources/beta/dreams.d.ts.map +1 -1
  83. package/resources/beta/index.d.mts +2 -2
  84. package/resources/beta/index.d.mts.map +1 -1
  85. package/resources/beta/index.d.ts +2 -2
  86. package/resources/beta/index.d.ts.map +1 -1
  87. package/resources/beta/index.js.map +1 -1
  88. package/resources/beta/index.mjs.map +1 -1
  89. package/resources/beta/memory-stores/memories.d.mts +6 -4
  90. package/resources/beta/memory-stores/memories.d.mts.map +1 -1
  91. package/resources/beta/memory-stores/memories.d.ts +6 -4
  92. package/resources/beta/memory-stores/memories.d.ts.map +1 -1
  93. package/resources/beta/messages/index.d.mts +1 -1
  94. package/resources/beta/messages/index.d.mts.map +1 -1
  95. package/resources/beta/messages/index.d.ts +1 -1
  96. package/resources/beta/messages/index.d.ts.map +1 -1
  97. package/resources/beta/messages/index.js.map +1 -1
  98. package/resources/beta/messages/index.mjs.map +1 -1
  99. package/resources/beta/messages/messages.d.mts +130 -3
  100. package/resources/beta/messages/messages.d.mts.map +1 -1
  101. package/resources/beta/messages/messages.d.ts +130 -3
  102. package/resources/beta/messages/messages.d.ts.map +1 -1
  103. package/resources/beta/messages/messages.js.map +1 -1
  104. package/resources/beta/messages/messages.mjs.map +1 -1
  105. package/resources/beta/organization/compliance-settings.d.mts +74 -0
  106. package/resources/beta/organization/compliance-settings.d.mts.map +1 -0
  107. package/resources/beta/organization/compliance-settings.d.ts +74 -0
  108. package/resources/beta/organization/compliance-settings.d.ts.map +1 -0
  109. package/resources/beta/organization/compliance-settings.js +52 -0
  110. package/resources/beta/organization/compliance-settings.js.map +1 -0
  111. package/resources/beta/organization/compliance-settings.mjs +48 -0
  112. package/resources/beta/organization/compliance-settings.mjs.map +1 -0
  113. package/resources/beta/organization/external-keys.d.mts +6 -3
  114. package/resources/beta/organization/external-keys.d.mts.map +1 -1
  115. package/resources/beta/organization/external-keys.d.ts +6 -3
  116. package/resources/beta/organization/external-keys.d.ts.map +1 -1
  117. package/resources/beta/organization/index.d.mts +1 -0
  118. package/resources/beta/organization/index.d.mts.map +1 -1
  119. package/resources/beta/organization/index.d.ts +1 -0
  120. package/resources/beta/organization/index.d.ts.map +1 -1
  121. package/resources/beta/organization/index.js +3 -1
  122. package/resources/beta/organization/index.js.map +1 -1
  123. package/resources/beta/organization/index.mjs +1 -0
  124. package/resources/beta/organization/index.mjs.map +1 -1
  125. package/resources/beta/organization/organization.d.mts +4 -0
  126. package/resources/beta/organization/organization.d.mts.map +1 -1
  127. package/resources/beta/organization/organization.d.ts +4 -0
  128. package/resources/beta/organization/organization.d.ts.map +1 -1
  129. package/resources/beta/organization/organization.js +4 -0
  130. package/resources/beta/organization/organization.js.map +1 -1
  131. package/resources/beta/organization/organization.mjs +4 -0
  132. package/resources/beta/organization/organization.mjs.map +1 -1
  133. package/resources/beta/organization/workspaces/workspaces.d.mts +28 -12
  134. package/resources/beta/organization/workspaces/workspaces.d.mts.map +1 -1
  135. package/resources/beta/organization/workspaces/workspaces.d.ts +28 -12
  136. package/resources/beta/organization/workspaces/workspaces.d.ts.map +1 -1
  137. package/resources/beta/organization/workspaces/workspaces.js.map +1 -1
  138. package/resources/beta/organization/workspaces/workspaces.mjs.map +1 -1
  139. package/resources/beta/sessions/events.d.mts +1 -1
  140. package/resources/beta/sessions/events.d.ts +1 -1
  141. package/resources/beta/sessions/sessions.d.mts +10 -10
  142. package/resources/beta/sessions/sessions.d.ts +10 -10
  143. package/resources/beta/user-profiles.d.mts +21 -25
  144. package/resources/beta/user-profiles.d.mts.map +1 -1
  145. package/resources/beta/user-profiles.d.ts +21 -25
  146. package/resources/beta/user-profiles.d.ts.map +1 -1
  147. package/resources/messages/messages.d.mts +1 -3
  148. package/resources/messages/messages.d.mts.map +1 -1
  149. package/resources/messages/messages.d.ts +1 -3
  150. package/resources/messages/messages.d.ts.map +1 -1
  151. package/resources/messages/messages.js.map +1 -1
  152. package/resources/messages/messages.mjs.map +1 -1
  153. package/src/core/credentials.ts +5 -7
  154. package/src/internal/file-store.ts +11 -10
  155. package/src/internal/node.browser.ts +22 -0
  156. package/src/internal/node.ts +14 -0
  157. package/src/lib/BetaMessageStream.ts +4 -0
  158. package/src/lib/credentials/credential-chain.ts +1 -1
  159. package/src/lib/credentials/identity-token.ts +1 -1
  160. package/src/lib/credentials/types.ts +2 -3
  161. package/src/lib/credentials/user-oauth.ts +1 -1
  162. package/src/lib/middleware.ts +33 -9
  163. package/src/resources/beta/agents/agents.ts +1 -0
  164. package/src/resources/beta/beta.ts +16 -1
  165. package/src/resources/beta/deployment-runs.ts +6 -6
  166. package/src/resources/beta/deployments.ts +3 -2
  167. package/src/resources/beta/dreams.ts +42 -0
  168. package/src/resources/beta/index.ts +6 -0
  169. package/src/resources/beta/memory-stores/memories.ts +6 -4
  170. package/src/resources/beta/messages/index.ts +4 -0
  171. package/src/resources/beta/messages/messages.ts +149 -8
  172. package/src/resources/beta/organization/compliance-settings.ts +96 -0
  173. package/src/resources/beta/organization/external-keys.ts +6 -3
  174. package/src/resources/beta/organization/index.ts +9 -0
  175. package/src/resources/beta/organization/organization.ts +24 -0
  176. package/src/resources/beta/organization/workspaces/workspaces.ts +28 -12
  177. package/src/resources/beta/sessions/events.ts +1 -1
  178. package/src/resources/beta/sessions/sessions.ts +10 -10
  179. package/src/resources/beta/user-profiles.ts +24 -27
  180. package/src/resources/messages/messages.ts +2 -8
  181. package/src/tools/agent-toolset/fs-util.ts +6 -5
  182. package/src/tools/agent-toolset/memories.ts +5 -3
  183. package/src/tools/agent-toolset/skills.ts +5 -10
  184. package/src/version.ts +1 -1
  185. package/tools/agent-toolset/fs-util.d.mts.map +1 -1
  186. package/tools/agent-toolset/fs-util.d.ts.map +1 -1
  187. package/tools/agent-toolset/fs-util.js +13 -15
  188. package/tools/agent-toolset/fs-util.js.map +1 -1
  189. package/tools/agent-toolset/fs-util.mjs +3 -4
  190. package/tools/agent-toolset/fs-util.mjs.map +1 -1
  191. package/tools/agent-toolset/memories.d.mts.map +1 -1
  192. package/tools/agent-toolset/memories.d.ts.map +1 -1
  193. package/tools/agent-toolset/memories.js +6 -4
  194. package/tools/agent-toolset/memories.js.map +1 -1
  195. package/tools/agent-toolset/memories.mjs +5 -3
  196. package/tools/agent-toolset/memories.mjs.map +1 -1
  197. package/tools/agent-toolset/skills.d.mts.map +1 -1
  198. package/tools/agent-toolset/skills.d.ts.map +1 -1
  199. package/tools/agent-toolset/skills.js +15 -21
  200. package/tools/agent-toolset/skills.js.map +1 -1
  201. package/tools/agent-toolset/skills.mjs +4 -9
  202. package/tools/agent-toolset/skills.mjs.map +1 -1
  203. package/version.d.mts +1 -1
  204. package/version.d.ts +1 -1
  205. package/version.js +1 -1
  206. package/version.mjs +1 -1
@@ -146,8 +146,7 @@ export const loadConfigWithSource = async (profile?: string): Promise<LoadedConf
146
146
  }
147
147
  validateProfileName(profileName);
148
148
 
149
- const fs = await import('node:fs');
150
- const path = await import('node:path');
149
+ const { fs, path } = await import('../internal/node');
151
150
  const configPath = path.join(rootConfigPath, 'configs', `${profileName}.json`);
152
151
  let configRaw: string | null;
153
152
  try {
@@ -252,7 +251,7 @@ export const loadCredentials = async (): Promise<AnthropicCredentials | null> =>
252
251
  return null;
253
252
  }
254
253
 
255
- const fs = await import('node:fs');
254
+ const { fs } = await import('../internal/node');
256
255
  let raw: string;
257
256
  try {
258
257
  raw = await fs.promises.readFile(credentialsPath, 'utf-8');
@@ -304,7 +303,7 @@ export const getCredentialsPath = async (
304
303
  }
305
304
  validateProfileName(profileName);
306
305
 
307
- const path = await import('node:path');
306
+ const { path } = await import('../internal/node');
308
307
  return path.join(rootConfigPath, 'credentials', `${profileName}.json`);
309
308
  };
310
309
 
@@ -313,7 +312,7 @@ const getRootConfigPath = async (): Promise<string | null> => {
313
312
  return null;
314
313
  }
315
314
 
316
- const path = await import('node:path');
315
+ const { path } = await import('../internal/node');
317
316
 
318
317
  // ANTHROPIC_CONFIG_DIR is treated as a trusted path: it is set by the
319
318
  // process operator, not by remote input, so it is not validated.
@@ -365,8 +364,7 @@ const getActiveProfileName = async (): Promise<string | null> => {
365
364
  return profileName;
366
365
  }
367
366
 
368
- const fs = await import('node:fs');
369
- const path = await import('node:path');
367
+ const { fs, path } = await import('../internal/node');
370
368
  const filePath = path.join(rootConfigPath, 'active_config');
371
369
  try {
372
370
  return (await fs.promises.readFile(filePath, 'utf-8')).trim() || 'default';
@@ -7,14 +7,15 @@
7
7
  * scope.
8
8
  */
9
9
 
10
- import * as fsp from 'node:fs/promises';
11
- import * as path from 'node:path';
12
- import { constants as C } from 'node:fs';
13
10
  import type { BigIntStats, Dirent } from 'node:fs';
11
+ import type { FileHandle } from 'node:fs/promises';
14
12
  import type * as util from 'node:util';
15
- import { createHash, randomBytes } from 'node:crypto';
13
+ import { crypto, fs, path } from './node';
16
14
  import { encodeUTF8 } from './utils/bytes';
17
15
 
16
+ const fsp = fs.promises;
17
+ const C = fs.constants;
18
+
18
19
  // Owner-only regardless of umask: the store holds downloaded user/model content.
19
20
  const OWNER_ONLY_DIR_MODE = 0o700;
20
21
  const OWNER_ONLY_FILE_MODE = 0o600;
@@ -182,7 +183,7 @@ export class FileStore {
182
183
  /** The file's bytes; `null` when absent. */
183
184
  async get(relPath: string): Promise<Uint8Array | null> {
184
185
  const dest = this.resolveUnderRoot(relPath);
185
- let handle: fsp.FileHandle;
186
+ let handle: FileHandle;
186
187
  try {
187
188
  handle = await openRegularFile(relPath, dest);
188
189
  } catch (e) {
@@ -388,8 +389,8 @@ async function makeDirsBelowRoot(root: string, dir: string): Promise<void> {
388
389
 
389
390
  async function replaceViaTemp(dest: string, data: Uint8Array, isExecutable: boolean): Promise<void> {
390
391
  const mode = isExecutable ? OWNER_ONLY_EXEC_MODE : OWNER_ONLY_FILE_MODE;
391
- const tmp = path.join(path.dirname(dest), `.fs-${randomBytes(8).toString('hex')}.tmp`);
392
- let handle: fsp.FileHandle | undefined;
392
+ const tmp = path.join(path.dirname(dest), `.fs-${crypto.randomBytes(8).toString('hex')}.tmp`);
393
+ let handle: FileHandle | undefined;
393
394
  try {
394
395
  handle = await fsp.open(tmp, C.O_WRONLY | C.O_CREAT | C.O_EXCL | O_NOFOLLOW, mode);
395
396
  await handle.writeFile(data);
@@ -404,9 +405,9 @@ async function replaceViaTemp(dest: string, data: Uint8Array, isExecutable: bool
404
405
  }
405
406
  }
406
407
 
407
- async function openRegularFile(relPath: string, dest: string): Promise<fsp.FileHandle> {
408
+ async function openRegularFile(relPath: string, dest: string): Promise<FileHandle> {
408
409
  // O_NONBLOCK: a FIFO fails the fstat check below instead of blocking the open.
409
- let handle: fsp.FileHandle;
410
+ let handle: FileHandle;
410
411
  try {
411
412
  handle = await fsp.open(dest, C.O_RDONLY | O_NOFOLLOW | O_NONBLOCK);
412
413
  } catch (e) {
@@ -429,7 +430,7 @@ async function openRegularFile(relPath: string, dest: string): Promise<fsp.FileH
429
430
 
430
431
  /** sha256 of a file's contents, streamed — constant memory on any file size. */
431
432
  async function hashFile(full: string): Promise<string> {
432
- const digest = createHash('sha256');
433
+ const digest = crypto.createHash('sha256');
433
434
  const handle = await openRegularFile(path.basename(full), full);
434
435
  const buf = new Uint8Array(1024 * 1024);
435
436
  try {
@@ -0,0 +1,22 @@
1
+ import { AnthropicError } from '../core/error';
2
+ import type * as node from './node';
3
+
4
+ /** Substituted for `./node` by the package.json `browser` field; every property access throws. */
5
+ function unavailable<T extends object>(module: string): T {
6
+ return new Proxy({} as T, {
7
+ get(_target, property) {
8
+ if (typeof property === 'symbol') return undefined;
9
+ throw new AnthropicError(
10
+ `\`${module}.${property}\` is not available in this environment; it needs a Node.js-compatible runtime`,
11
+ );
12
+ },
13
+ });
14
+ }
15
+
16
+ export const child_process: typeof node.child_process = unavailable('child_process');
17
+ export const crypto: typeof node.crypto = unavailable('crypto');
18
+ export const fs: typeof node.fs = unavailable('fs');
19
+ export const os: typeof node.os = unavailable('os');
20
+ export const path: typeof node.path = unavailable('path');
21
+ export const stream: typeof node.stream = unavailable('stream');
22
+ export const util: typeof node.util = unavailable('util');
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The one module under `src/` that may import Node built-ins (eslint enforces this).
3
+ * The package.json `browser` field swaps it for `./node.browser`, so only touch its
4
+ * exports on code paths that run on Node-compatible runtimes.
5
+ */
6
+ import * as child_process from 'node:child_process';
7
+ import * as crypto from 'node:crypto';
8
+ import * as fs from 'node:fs';
9
+ import * as os from 'node:os';
10
+ import * as path from 'node:path';
11
+ import * as stream from 'node:stream';
12
+ import * as util from 'node:util';
13
+
14
+ export { child_process, crypto, fs, os, path, stream, util };
@@ -603,6 +603,10 @@ export class BetaMessageStream<ParsedT = null> implements AsyncIterable<BetaMess
603
603
  snapshot.context_management = event.context_management;
604
604
  }
605
605
 
606
+ if (event.input_transformations != null) {
607
+ snapshot.input_transformations = event.input_transformations;
608
+ }
609
+
606
610
  // The remaining usage counters are cumulative whole-message totals that are
607
611
  // omitted when they don't apply, so overwrite when present and never add.
608
612
  if (event.usage.input_tokens != null) {
@@ -240,7 +240,7 @@ function cachedExchangeProvider(
240
240
  onSafetyWarning: ((msg: string) => void) | undefined,
241
241
  ): AccessTokenProvider {
242
242
  return async (opts) => {
243
- const fs = await import('node:fs');
243
+ const { fs } = await import('../../internal/node');
244
244
 
245
245
  await checkCredentialsFileSafety(credentialsPath, onSafetyWarning);
246
246
 
@@ -11,7 +11,7 @@ export function identityTokenFromFile(path: string): IdentityTokenProvider {
11
11
  }
12
12
 
13
13
  return async () => {
14
- const fs = await import('node:fs');
14
+ const { fs } = await import('../../internal/node');
15
15
  let content: string;
16
16
  try {
17
17
  content = await fs.promises.readFile(path, 'utf-8');
@@ -170,7 +170,7 @@ export async function checkCredentialsFileSafety(
170
170
  onWarn: (msg: string) => void = (m) => console.warn(`anthropic-sdk: ${m}`),
171
171
  ): Promise<void> {
172
172
  if (typeof process === 'undefined' || process.platform === 'win32') return;
173
- const fs = await import('node:fs');
173
+ const { fs } = await import('../../internal/node');
174
174
  let resolved = path;
175
175
  let st;
176
176
  try {
@@ -208,8 +208,7 @@ export async function checkCredentialsFileSafety(
208
208
  * Creates the parent directory with mode 0700 and the file with mode 0600.
209
209
  */
210
210
  export async function writeCredentialsFileAtomic(targetPath: string, data: unknown): Promise<void> {
211
- const fs = await import('node:fs');
212
- const path = await import('node:path');
211
+ const { fs, path } = await import('../../internal/node');
213
212
  const dir = path.dirname(targetPath);
214
213
  await fs.promises.mkdir(dir, { recursive: true, mode: 0o700 });
215
214
  // Unique temp name avoids two concurrent writers (different processes or
@@ -36,7 +36,7 @@ export type UserOAuthConfig = {
36
36
  */
37
37
  export function userOAuthProvider(config: UserOAuthConfig): AccessTokenProvider {
38
38
  return async (opts) => {
39
- const fs = await import('node:fs');
39
+ const { fs } = await import('../../internal/node');
40
40
 
41
41
  await checkCredentialsFileSafety(config.credentialsPath, config.onSafetyWarning);
42
42
 
@@ -38,16 +38,17 @@ const DEFAULT_BETAS: readonly AnthropicBeta[] = ['fallback-credit-2026-07-01'];
38
38
  * Remove `fallback` blocks replayed in history. They only parse under the
39
39
  * server-side fallback beta, which belongs to the caller-owned server-side
40
40
  * `fallbacks` feature — this middleware never sends it, so a request
41
- * replaying them would 400. An assistant turn left empty is dropped whole.
41
+ * replaying them would 400. A turn the strip leaves empty is dropped whole;
42
+ * a turn that was already empty is kept — it may carry other payload (e.g. a
43
+ * directive-only system message's `output_config`).
42
44
  */
43
45
  function stripFallbackBlocks(body: MessageCreateParams): MessageCreateParams {
44
- const messages = body.messages
45
- .map((message) =>
46
- Array.isArray(message.content) ?
47
- { ...message, content: message.content.filter((block) => block.type !== 'fallback') }
48
- : message,
49
- )
50
- .filter((message) => !Array.isArray(message.content) || message.content.length > 0);
46
+ const messages = body.messages.flatMap((message) => {
47
+ if (!Array.isArray(message.content)) return [message];
48
+ const content = message.content.filter((block) => block.type !== 'fallback');
49
+ if (content.length === message.content.length) return [message];
50
+ return content.length > 0 ? [{ ...message, content }] : [];
51
+ });
51
52
  return { ...body, messages };
52
53
  }
53
54
 
@@ -453,6 +454,9 @@ async function* splicedEvents(
453
454
  // The refusal whose token is currently in flight — surfaced verbatim (with a
454
455
  // recommended_model added) if every fallback request fails and we degrade.
455
456
  let refusalDetails = a.refused.stopDetails;
457
+ // That refused hop's suppressed message_start `input_transformations`, which
458
+ // ride on the surfaced refusal delta (none for A: its start reached the client).
459
+ let refusalInputTransformations = a.refused.inputTransformations;
456
460
 
457
461
  // One `message` entry per refused hop, in order — A first. Failed hops are
458
462
  // skipped (no usage came back); the serving hop is appended as
@@ -559,6 +563,9 @@ async function* splicedEvents(
559
563
  stop_details: stopDetails,
560
564
  },
561
565
  usage: (lastUsage ?? {}) as BetaMessageDeltaUsage,
566
+ ...(refusalInputTransformations !== undefined && {
567
+ input_transformations: refusalInputTransformations,
568
+ }),
562
569
  });
563
570
  yield emit<BetaRawMessageStopEvent>('message_stop', { type: 'message_stop' });
564
571
  return;
@@ -580,6 +587,7 @@ async function* splicedEvents(
580
587
  // continues.
581
588
  token = b.refused.token;
582
589
  refusalDetails = b.refused.stopDetails;
590
+ refusalInputTransformations = b.refused.inputTransformations;
583
591
  base = continuation;
584
592
  partial = b.refused.hasPrefillClaim ? toPrefillBlocks(b.blocks) : [];
585
593
  iterations.push(toIterationUsage('message', model, b.refused.usage));
@@ -598,6 +606,12 @@ interface HopOutcome {
598
606
  usage: BetaMessageDeltaUsage;
599
607
  /** The refusal's stop_details verbatim, surfaced if the whole chain degrades. */
600
608
  stopDetails: BetaRefusalStopDetails;
609
+ /**
610
+ * A spliced hop's suppressed message_start `input_transformations`, forwarded
611
+ * on the surfaced refusal delta if the whole chain degrades; `undefined` for
612
+ * stream A (its start reached the client) or when the start had none.
613
+ */
614
+ inputTransformations: BetaMessage['input_transformations'] | undefined;
601
615
  } | null;
602
616
  /** The hop's serving model, from its message_start. */
603
617
  model: string | undefined;
@@ -615,7 +629,8 @@ interface HopOutcome {
615
629
  * spliced hop (`splice` set) has its message_start suppressed (the client
616
630
  * already saw A's), its block indices shifted by `indexBase`, and its
617
631
  * terminal message_delta's usage rewritten to the `usage.iterations`
618
- * chain shape.
632
+ * chain shape, with the suppressed message_start's `input_transformations`
633
+ * forwarded onto it.
619
634
  *
620
635
  * A refusal that can be chained — it carries a `fallback_credit_token` and a
621
636
  * fallback entry remains — ends the hop early: open blocks are closed, the
@@ -638,6 +653,10 @@ async function* consumeHop(args: {
638
653
  const tracker = new BlockTracker(indexBase);
639
654
  let model: string | undefined;
640
655
  let startUsage: BetaUsage | null = null;
656
+ // A spliced hop's message_start is suppressed, so its `input_transformations`
657
+ // must ride on the re-emitted terminal message_delta — the way a server-side
658
+ // fallback reports the serving model's list.
659
+ let startInputTransformations: BetaMessage['input_transformations'];
641
660
 
642
661
  for await (const sse of Stream.rawEvents(response, controller)) {
643
662
  const p = safeJSON(sse.data) as BetaRawMessageStreamEvent | undefined;
@@ -645,6 +664,7 @@ async function* consumeHop(args: {
645
664
  case 'message_start': {
646
665
  model = p.message.model;
647
666
  startUsage = p.message.usage;
667
+ if ('input_transformations' in p.message) startInputTransformations = p.message.input_transformations;
648
668
  if (splice) continue;
649
669
  break;
650
670
  }
@@ -687,6 +707,7 @@ async function* consumeHop(args: {
687
707
  hasPrefillClaim: details.fallback_has_prefill_claim === true,
688
708
  usage,
689
709
  stopDetails: details,
710
+ inputTransformations: splice ? startInputTransformations : undefined,
690
711
  },
691
712
  model,
692
713
  blocks: tracker.contentBlocks(),
@@ -721,6 +742,9 @@ async function* consumeHop(args: {
721
742
  toIterationUsage('fallback_message', splice.model, usage),
722
743
  ];
723
744
  p.usage = usage;
745
+ if (!('input_transformations' in p) && startInputTransformations !== undefined) {
746
+ p.input_transformations = startInputTransformations;
747
+ }
724
748
  yield emit('message_delta', p);
725
749
  continue;
726
750
  }
@@ -862,6 +862,7 @@ export interface BetaManagedAgentsMCPToolsetParams {
862
862
  * details and options.
863
863
  */
864
864
  export type BetaManagedAgentsModel =
865
+ | 'claude-fable-5-1'
865
866
  | 'claude-sonnet-5'
866
867
  | 'claude-fable-5'
867
868
  | 'claude-opus-5'
@@ -88,10 +88,12 @@ import {
88
88
  BetaDreamSessionsInput,
89
89
  BetaDreamStatus,
90
90
  BetaDreamUsage,
91
+ BetaDreamingError,
91
92
  BetaDreamsPageCursor,
92
93
  BetaOutputBehavior,
93
94
  BetaOutputBehaviorCreateNew,
94
95
  BetaOutputBehaviorUpdateExisting,
96
+ BetaTargetStoreHeldError,
95
97
  DreamArchiveParams,
96
98
  DreamCancelParams,
97
99
  DreamCreateParams,
@@ -510,6 +512,7 @@ import {
510
512
  BetaSignatureDelta,
511
513
  BetaSkillParams,
512
514
  BetaStopReason,
515
+ BetaSystemMessageOutputConfig,
513
516
  BetaTextBlock,
514
517
  BetaTextBlockParam,
515
518
  BetaTextCitation,
@@ -526,12 +529,15 @@ import {
526
529
  BetaTextEditorCodeExecutionViewResultBlock,
527
530
  BetaTextEditorCodeExecutionViewResultBlockParam,
528
531
  BetaThinkingBlock,
532
+ BetaThinkingBlockBinding,
529
533
  BetaThinkingBlockParam,
530
534
  BetaThinkingConfigAdaptive,
531
535
  BetaThinkingConfigDisabled,
532
536
  BetaThinkingConfigEnabled,
533
537
  BetaThinkingConfigParam,
534
538
  BetaThinkingDelta,
539
+ BetaThinkingDroppedInputTransformation,
540
+ BetaThinkingPrefixMismatchBehavior,
535
541
  BetaThinkingTurns,
536
542
  BetaTokenTaskBudget,
537
543
  BetaTool,
@@ -742,7 +748,10 @@ export type AnthropicBeta =
742
748
  | 'structured-outputs-2025-11-13'
743
749
  | 'task-budgets-2026-03-13'
744
750
  | 'thinking-display-updates-2026-08-18'
745
- | 'ce-user-management-2026-07-13';
751
+ | 'ce-user-management-2026-07-13'
752
+ | 'mid-conversation-output-config-2026-07-01'
753
+ | 'thinking-binding-controls-2026-08-01'
754
+ | 'mid-conversation-system-clear-at-2026-08-21';
746
755
 
747
756
  export interface BetaAPIError {
748
757
  message: string;
@@ -1101,6 +1110,7 @@ export declare namespace Beta {
1101
1110
  type BetaSignatureDelta as BetaSignatureDelta,
1102
1111
  type BetaSkillParams as BetaSkillParams,
1103
1112
  type BetaStopReason as BetaStopReason,
1113
+ type BetaSystemMessageOutputConfig as BetaSystemMessageOutputConfig,
1104
1114
  type BetaTextBlock as BetaTextBlock,
1105
1115
  type BetaTextBlockParam as BetaTextBlockParam,
1106
1116
  type BetaTextCitation as BetaTextCitation,
@@ -1117,12 +1127,15 @@ export declare namespace Beta {
1117
1127
  type BetaTextEditorCodeExecutionViewResultBlock as BetaTextEditorCodeExecutionViewResultBlock,
1118
1128
  type BetaTextEditorCodeExecutionViewResultBlockParam as BetaTextEditorCodeExecutionViewResultBlockParam,
1119
1129
  type BetaThinkingBlock as BetaThinkingBlock,
1130
+ type BetaThinkingBlockBinding as BetaThinkingBlockBinding,
1120
1131
  type BetaThinkingBlockParam as BetaThinkingBlockParam,
1121
1132
  type BetaThinkingConfigAdaptive as BetaThinkingConfigAdaptive,
1122
1133
  type BetaThinkingConfigDisabled as BetaThinkingConfigDisabled,
1123
1134
  type BetaThinkingConfigEnabled as BetaThinkingConfigEnabled,
1124
1135
  type BetaThinkingConfigParam as BetaThinkingConfigParam,
1125
1136
  type BetaThinkingDelta as BetaThinkingDelta,
1137
+ type BetaThinkingDroppedInputTransformation as BetaThinkingDroppedInputTransformation,
1138
+ type BetaThinkingPrefixMismatchBehavior as BetaThinkingPrefixMismatchBehavior,
1126
1139
  type BetaThinkingTurns as BetaThinkingTurns,
1127
1140
  type BetaTokenTaskBudget as BetaTokenTaskBudget,
1128
1141
  type BetaTool as BetaTool,
@@ -1526,9 +1539,11 @@ export declare namespace Beta {
1526
1539
  type BetaDreamSessionsInput as BetaDreamSessionsInput,
1527
1540
  type BetaDreamStatus as BetaDreamStatus,
1528
1541
  type BetaDreamUsage as BetaDreamUsage,
1542
+ type BetaDreamingError as BetaDreamingError,
1529
1543
  type BetaOutputBehavior as BetaOutputBehavior,
1530
1544
  type BetaOutputBehaviorCreateNew as BetaOutputBehaviorCreateNew,
1531
1545
  type BetaOutputBehaviorUpdateExisting as BetaOutputBehaviorUpdateExisting,
1546
+ type BetaTargetStoreHeldError as BetaTargetStoreHeldError,
1532
1547
  type BetaDreamsPageCursor as BetaDreamsPageCursor,
1533
1548
  type DreamCreateParams as DreamCreateParams,
1534
1549
  type DreamRetrieveParams as DreamRetrieveParams,
@@ -130,8 +130,8 @@ export interface BetaManagedAgentsDeploymentRun {
130
130
  | null;
131
131
 
132
132
  /**
133
- * Populated on success. Null on creation failure. Exactly one of session_id or
134
- * error is non-null.
133
+ * Populated on success. Null on creation failure. Exactly one of `session_id` or
134
+ * `error` is non-null.
135
135
  */
136
136
  session_id: string | null;
137
137
 
@@ -389,14 +389,14 @@ export interface DeploymentRunListParams extends PageCursorParams {
389
389
 
390
390
  /**
391
391
  * Query param: Filter to a specific deployment. Omit to list across all
392
- * deployments in the workspace. Filtering by a non-existent deployment_id returns
393
- * 200 with empty data.
392
+ * deployments in the workspace. Filtering by a non-existent `deployment_id`
393
+ * returns 200 with empty data.
394
394
  */
395
395
  deployment_id?: string;
396
396
 
397
397
  /**
398
- * Query param: Filter: true for runs with non-null error, false for runs with
399
- * non-null session_id. Omit for all.
398
+ * Query param: Filter: true for runs with non-null `error`, false for runs with
399
+ * non-null `session_id`. Omit for all.
400
400
  */
401
401
  has_error?: boolean;
402
402
 
@@ -909,8 +909,9 @@ export interface DeploymentListParams extends PageCursorParams {
909
909
  include_archived?: boolean;
910
910
 
911
911
  /**
912
- * Query param: Filter by status: active or paused. Omit for both. To include
913
- * archived deployments, use include_archived instead; the two cannot be combined.
912
+ * Query param: Filter by status: `active` or `paused`. Omit for both. To include
913
+ * archived deployments, use `include_archived` instead; the two cannot be
914
+ * combined.
914
915
  */
915
916
  status?: BetaManagedAgentsDeploymentStatus;
916
917
 
@@ -320,6 +320,27 @@ export interface BetaDreamUsage {
320
320
  output_tokens: number;
321
321
  }
322
322
 
323
+ /**
324
+ * The `output_behavior.memory_store_id` target is still held by a prior
325
+ * `{type: "update_existing"}` dream — one that is `pending` or `running`, or was
326
+ * canceled with its final writes still landing. Rarely the named dream has just
327
+ * finished (`completed`/`failed`) and its execution is still closing; an immediate
328
+ * retry then almost always succeeds. The message names the holding dream when the
329
+ * server can identify it (rarely omitted); poll it to a terminal state or cancel
330
+ * it, then retry. Carried with `x-should-retry: false`.
331
+ */
332
+ export type BetaDreamingError =
333
+ | BetaAPI.BetaInvalidRequestError
334
+ | BetaAPI.BetaAuthenticationError
335
+ | BetaAPI.BetaBillingError
336
+ | BetaAPI.BetaPermissionError
337
+ | BetaAPI.BetaNotFoundError
338
+ | BetaAPI.BetaRateLimitError
339
+ | BetaAPI.BetaGatewayTimeoutError
340
+ | BetaAPI.BetaAPIError
341
+ | BetaAPI.BetaOverloadedError
342
+ | BetaTargetStoreHeldError;
343
+
323
344
  /**
324
345
  * The default destination: the job creates a new output memory store as a clone of
325
346
  * the memory_store input and writes the consolidated memories into it. The input
@@ -347,6 +368,25 @@ export interface BetaOutputBehaviorUpdateExisting {
347
368
  type: 'update_existing';
348
369
  }
349
370
 
371
+ /**
372
+ * The `output_behavior.memory_store_id` target is still held by a prior
373
+ * `{type: "update_existing"}` dream — one that is `pending` or `running`, or was
374
+ * canceled with its final writes still landing. Rarely the named dream has just
375
+ * finished (`completed`/`failed`) and its execution is still closing; an immediate
376
+ * retry then almost always succeeds. The message names the holding dream when the
377
+ * server can identify it (rarely omitted); poll it to a terminal state or cancel
378
+ * it, then retry. Carried with `x-should-retry: false`.
379
+ */
380
+ export interface BetaTargetStoreHeldError {
381
+ type: 'conflict_error';
382
+
383
+ /**
384
+ * Human-readable description of the conflict, naming the dream that holds the
385
+ * target store when the server can identify it.
386
+ */
387
+ message?: string;
388
+ }
389
+
350
390
  export interface DreamCreateParams {
351
391
  /**
352
392
  * Body param
@@ -440,9 +480,11 @@ export declare namespace Dreams {
440
480
  type BetaDreamSessionsInput as BetaDreamSessionsInput,
441
481
  type BetaDreamStatus as BetaDreamStatus,
442
482
  type BetaDreamUsage as BetaDreamUsage,
483
+ type BetaDreamingError as BetaDreamingError,
443
484
  type BetaOutputBehavior as BetaOutputBehavior,
444
485
  type BetaOutputBehaviorCreateNew as BetaOutputBehaviorCreateNew,
445
486
  type BetaOutputBehaviorUpdateExisting as BetaOutputBehaviorUpdateExisting,
487
+ type BetaTargetStoreHeldError as BetaTargetStoreHeldError,
446
488
  type BetaDreamsPageCursor as BetaDreamsPageCursor,
447
489
  type DreamCreateParams as DreamCreateParams,
448
490
  type DreamRetrieveParams as DreamRetrieveParams,
@@ -173,9 +173,11 @@ export {
173
173
  type BetaDreamSessionsInput,
174
174
  type BetaDreamStatus,
175
175
  type BetaDreamUsage,
176
+ type BetaDreamingError,
176
177
  type BetaOutputBehavior,
177
178
  type BetaOutputBehaviorCreateNew,
178
179
  type BetaOutputBehaviorUpdateExisting,
180
+ type BetaTargetStoreHeldError,
179
181
  type DreamCreateParams,
180
182
  type DreamRetrieveParams,
181
183
  type DreamListParams,
@@ -443,6 +445,7 @@ export {
443
445
  type BetaSignatureDelta,
444
446
  type BetaSkillParams,
445
447
  type BetaStopReason,
448
+ type BetaSystemMessageOutputConfig,
446
449
  type BetaTextBlock,
447
450
  type BetaTextBlockParam,
448
451
  type BetaTextCitation,
@@ -459,12 +462,15 @@ export {
459
462
  type BetaTextEditorCodeExecutionViewResultBlock,
460
463
  type BetaTextEditorCodeExecutionViewResultBlockParam,
461
464
  type BetaThinkingBlock,
465
+ type BetaThinkingBlockBinding,
462
466
  type BetaThinkingBlockParam,
463
467
  type BetaThinkingConfigAdaptive,
464
468
  type BetaThinkingConfigDisabled,
465
469
  type BetaThinkingConfigEnabled,
466
470
  type BetaThinkingConfigParam,
467
471
  type BetaThinkingDelta,
472
+ type BetaThinkingDroppedInputTransformation,
473
+ type BetaThinkingPrefixMismatchBehavior,
468
474
  type BetaThinkingTurns,
469
475
  type BetaTokenTaskBudget,
470
476
  type BetaTool,
@@ -367,7 +367,8 @@ export interface MemoryCreateParams {
367
367
  * Body param: Hierarchical path for the new memory, e.g. `/projects/foo/notes.md`.
368
368
  * Must start with `/`, contain at least one non-empty segment, and be at most
369
369
  * 1,024 bytes. Must not contain empty segments, `.` or `..` segments, control or
370
- * format characters, and must be NFC-normalized. Paths are case-sensitive.
370
+ * format characters, or the Unicode line and paragraph separators (U+2028,
371
+ * U+2029), and must be NFC-normalized. Paths are case-sensitive.
371
372
  */
372
373
  path: string;
373
374
 
@@ -419,9 +420,10 @@ export interface MemoryUpdateParams {
419
420
  /**
420
421
  * Body param: New path for the memory (a rename). Must start with `/`, contain at
421
422
  * least one non-empty segment, and be at most 1,024 bytes. Must not contain empty
422
- * segments, `.` or `..` segments, control or format characters, and must be
423
- * NFC-normalized. Paths are case-sensitive. The memory's `id` is preserved across
424
- * renames. Omit to leave the path unchanged.
423
+ * segments, `.` or `..` segments, control or format characters, or the Unicode
424
+ * line and paragraph separators (U+2028, U+2029), and must be NFC-normalized.
425
+ * Paths are case-sensitive. The memory's `id` is preserved across renames. Omit to
426
+ * leave the path unchanged.
425
427
  */
426
428
  path?: string | null;
427
429
 
@@ -232,6 +232,7 @@ export {
232
232
  type BetaSignatureDelta,
233
233
  type BetaSkillParams,
234
234
  type BetaStopReason,
235
+ type BetaSystemMessageOutputConfig,
235
236
  type BetaTextBlock,
236
237
  type BetaTextBlockParam,
237
238
  type BetaTextCitation,
@@ -248,12 +249,15 @@ export {
248
249
  type BetaTextEditorCodeExecutionViewResultBlock,
249
250
  type BetaTextEditorCodeExecutionViewResultBlockParam,
250
251
  type BetaThinkingBlock,
252
+ type BetaThinkingBlockBinding,
251
253
  type BetaThinkingBlockParam,
252
254
  type BetaThinkingConfigAdaptive,
253
255
  type BetaThinkingConfigDisabled,
254
256
  type BetaThinkingConfigEnabled,
255
257
  type BetaThinkingConfigParam,
256
258
  type BetaThinkingDelta,
259
+ type BetaThinkingDroppedInputTransformation,
260
+ type BetaThinkingPrefixMismatchBehavior,
257
261
  type BetaThinkingTurns,
258
262
  type BetaTokenTaskBudget,
259
263
  type BetaTool,