@anthropic-ai/sdk 0.117.1 → 0.119.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.
- package/CHANGELOG.md +36 -0
- package/client.d.mts +8 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +8 -2
- package/client.d.ts.map +1 -1
- package/client.js +7 -1
- package/client.js.map +1 -1
- package/client.mjs +7 -1
- package/client.mjs.map +1 -1
- package/core/api-promise.d.mts +1 -0
- package/core/api-promise.d.mts.map +1 -1
- package/core/api-promise.d.ts +1 -0
- package/core/api-promise.d.ts.map +1 -1
- package/core/api-promise.js +7 -2
- package/core/api-promise.js.map +1 -1
- package/core/api-promise.mjs +8 -3
- package/core/api-promise.mjs.map +1 -1
- package/core/error.d.mts +1 -0
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts +1 -0
- package/core/error.d.ts.map +1 -1
- package/core/error.js +1 -0
- package/core/error.js.map +1 -1
- package/core/error.mjs +1 -0
- package/core/error.mjs.map +1 -1
- package/core/middleware.js +1 -1
- package/core/middleware.js.map +1 -1
- package/core/middleware.mjs +2 -2
- package/core/middleware.mjs.map +1 -1
- package/helpers/beta/zod.d.mts.map +1 -1
- package/helpers/beta/zod.d.ts.map +1 -1
- package/helpers/beta/zod.js +1 -2
- package/helpers/beta/zod.js.map +1 -1
- package/helpers/beta/zod.mjs +1 -2
- package/helpers/beta/zod.mjs.map +1 -1
- package/helpers/zod.d.mts.map +1 -1
- package/helpers/zod.d.ts.map +1 -1
- package/helpers/zod.js +1 -2
- package/helpers/zod.js.map +1 -1
- package/helpers/zod.mjs +1 -2
- package/helpers/zod.mjs.map +1 -1
- package/internal/parse.d.mts +2 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts +2 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +6 -6
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -5
- package/internal/parse.mjs.map +1 -1
- package/lib/BetaMessageStream.d.mts +2 -0
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts +2 -0
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +8 -2
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +8 -2
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.d.mts +2 -0
- package/lib/MessageStream.d.mts.map +1 -1
- package/lib/MessageStream.d.ts +2 -0
- package/lib/MessageStream.d.ts.map +1 -1
- package/lib/MessageStream.js +8 -2
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +8 -2
- package/lib/MessageStream.mjs.map +1 -1
- package/lib/environments/worker.d.mts +10 -6
- package/lib/environments/worker.d.mts.map +1 -1
- package/lib/environments/worker.d.ts +10 -6
- package/lib/environments/worker.d.ts.map +1 -1
- package/lib/environments/worker.js +22 -15
- package/lib/environments/worker.js.map +1 -1
- package/lib/environments/worker.mjs +22 -15
- package/lib/environments/worker.mjs.map +1 -1
- package/lib/tools/BetaRunnableTool.d.mts +21 -40
- package/lib/tools/BetaRunnableTool.d.mts.map +1 -1
- package/lib/tools/BetaRunnableTool.d.ts +21 -40
- package/lib/tools/BetaRunnableTool.d.ts.map +1 -1
- package/lib/tools/BetaRunnableTool.js +7 -16
- package/lib/tools/BetaRunnableTool.js.map +1 -1
- package/lib/tools/BetaRunnableTool.mjs +7 -16
- package/lib/tools/BetaRunnableTool.mjs.map +1 -1
- package/lib/tools/BetaToolRunner.d.mts.map +1 -1
- package/lib/tools/BetaToolRunner.d.ts.map +1 -1
- package/lib/tools/BetaToolRunner.js +3 -13
- package/lib/tools/BetaToolRunner.js.map +1 -1
- package/lib/tools/BetaToolRunner.mjs +3 -13
- package/lib/tools/BetaToolRunner.mjs.map +1 -1
- package/lib/tools/SessionToolRunner.d.mts +6 -0
- package/lib/tools/SessionToolRunner.d.mts.map +1 -1
- package/lib/tools/SessionToolRunner.d.ts +6 -0
- package/lib/tools/SessionToolRunner.d.ts.map +1 -1
- package/lib/tools/SessionToolRunner.js +37 -8
- package/lib/tools/SessionToolRunner.js.map +1 -1
- package/lib/tools/SessionToolRunner.mjs +38 -9
- package/lib/tools/SessionToolRunner.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/agents/agents.d.mts +3 -3
- package/resources/beta/agents/agents.d.ts +3 -3
- package/resources/beta/agents/agents.js +1 -1
- package/resources/beta/agents/agents.mjs +1 -1
- package/resources/beta/beta.d.mts +5 -5
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +5 -5
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/dreams.d.mts +2 -2
- package/resources/beta/dreams.d.ts +2 -2
- package/resources/beta/environments/environments.d.mts +4 -3
- package/resources/beta/environments/environments.d.mts.map +1 -1
- package/resources/beta/environments/environments.d.ts +4 -3
- package/resources/beta/environments/environments.d.ts.map +1 -1
- package/resources/beta/environments/environments.js.map +1 -1
- package/resources/beta/environments/environments.mjs.map +1 -1
- package/resources/beta/files.d.mts +22 -22
- package/resources/beta/files.d.mts.map +1 -1
- package/resources/beta/files.d.ts +22 -22
- package/resources/beta/files.d.ts.map +1 -1
- package/resources/beta/files.js +4 -4
- package/resources/beta/files.js.map +1 -1
- package/resources/beta/files.mjs +4 -4
- package/resources/beta/files.mjs.map +1 -1
- package/resources/beta/index.d.mts +2 -2
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +2 -2
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/memory-stores/index.d.mts +1 -1
- package/resources/beta/memory-stores/index.d.mts.map +1 -1
- package/resources/beta/memory-stores/index.d.ts +1 -1
- package/resources/beta/memory-stores/index.d.ts.map +1 -1
- package/resources/beta/memory-stores/index.js.map +1 -1
- package/resources/beta/memory-stores/index.mjs.map +1 -1
- package/resources/beta/memory-stores/memory-stores.d.mts +2 -2
- package/resources/beta/memory-stores/memory-stores.d.mts.map +1 -1
- package/resources/beta/memory-stores/memory-stores.d.ts +2 -2
- package/resources/beta/memory-stores/memory-stores.d.ts.map +1 -1
- package/resources/beta/memory-stores/memory-stores.js.map +1 -1
- package/resources/beta/memory-stores/memory-stores.mjs.map +1 -1
- package/resources/beta/memory-stores/memory-versions.d.mts +17 -2
- package/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
- package/resources/beta/memory-stores/memory-versions.d.ts +17 -2
- package/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
- package/resources/beta/messages/batches.d.mts +1 -1
- package/resources/beta/messages/batches.d.ts +1 -1
- package/resources/beta/messages/batches.js +1 -1
- package/resources/beta/messages/batches.mjs +1 -1
- package/resources/beta/messages/index.d.mts +1 -1
- package/resources/beta/messages/index.d.mts.map +1 -1
- package/resources/beta/messages/index.d.ts +1 -1
- package/resources/beta/messages/index.d.ts.map +1 -1
- package/resources/beta/messages/index.js.map +1 -1
- package/resources/beta/messages/index.mjs.map +1 -1
- package/resources/beta/messages/messages.d.mts +1204 -25
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +1204 -25
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +1 -1
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +1 -1
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/beta/sessions/sessions.d.mts +1 -1
- package/resources/beta/sessions/sessions.d.ts +1 -1
- package/resources/beta/user-profiles.d.mts +35 -9
- package/resources/beta/user-profiles.d.mts.map +1 -1
- package/resources/beta/user-profiles.d.ts +35 -9
- package/resources/beta/user-profiles.d.ts.map +1 -1
- package/resources/beta/user-profiles.js +5 -5
- package/resources/beta/user-profiles.mjs +5 -5
- package/resources/files.d.mts +105 -0
- package/resources/files.d.mts.map +1 -0
- package/resources/files.d.ts +105 -0
- package/resources/files.d.ts.map +1 -0
- package/resources/files.js +52 -0
- package/resources/files.js.map +1 -0
- package/resources/files.mjs +48 -0
- package/resources/files.mjs.map +1 -0
- package/resources/index.d.mts +3 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +3 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +5 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -0
- package/resources/index.mjs.map +1 -1
- package/resources/messages/batches.d.mts +1 -1
- package/resources/messages/batches.d.ts +1 -1
- package/resources/messages/batches.js +1 -1
- package/resources/messages/batches.mjs +1 -1
- package/resources/messages/index.d.mts +1 -1
- package/resources/messages/index.d.mts.map +1 -1
- package/resources/messages/index.d.ts +1 -1
- package/resources/messages/index.d.ts.map +1 -1
- package/resources/messages/index.js.map +1 -1
- package/resources/messages/index.mjs.map +1 -1
- package/resources/messages/messages.d.mts +1270 -28
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +1270 -28
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +1 -1
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +1 -1
- package/resources/messages/messages.mjs.map +1 -1
- package/resources/skills/index.d.mts +3 -0
- package/resources/skills/index.d.mts.map +1 -0
- package/resources/skills/index.d.ts +3 -0
- package/resources/skills/index.d.ts.map +1 -0
- package/resources/skills/index.js +9 -0
- package/resources/skills/index.js.map +1 -0
- package/resources/skills/index.mjs +4 -0
- package/resources/skills/index.mjs.map +1 -0
- package/resources/skills/skills.d.mts +129 -0
- package/resources/skills/skills.d.mts.map +1 -0
- package/resources/skills/skills.d.ts +129 -0
- package/resources/skills/skills.d.ts.map +1 -0
- package/resources/skills/skills.js +44 -0
- package/resources/skills/skills.js.map +1 -0
- package/resources/skills/skills.mjs +39 -0
- package/resources/skills/skills.mjs.map +1 -0
- package/resources/skills/versions.d.mts +104 -0
- package/resources/skills/versions.d.mts.map +1 -0
- package/resources/skills/versions.d.ts +104 -0
- package/resources/skills/versions.d.ts.map +1 -0
- package/resources/skills/versions.js +41 -0
- package/resources/skills/versions.js.map +1 -0
- package/resources/skills/versions.mjs +37 -0
- package/resources/skills/versions.mjs.map +1 -0
- package/resources/skills.d.mts +2 -0
- package/resources/skills.d.mts.map +1 -0
- package/resources/skills.d.ts +2 -0
- package/resources/skills.d.ts.map +1 -0
- package/resources/skills.js +6 -0
- package/resources/skills.js.map +1 -0
- package/resources/skills.mjs +3 -0
- package/resources/skills.mjs.map +1 -0
- package/src/client.ts +173 -3
- package/src/core/api-promise.ts +14 -4
- package/src/core/error.ts +2 -0
- package/src/core/middleware.ts +2 -2
- package/src/helpers/beta/zod.ts +1 -3
- package/src/helpers/zod.ts +1 -3
- package/src/internal/parse.ts +6 -6
- package/src/lib/BetaMessageStream.ts +8 -0
- package/src/lib/MessageStream.ts +8 -0
- package/src/lib/environments/worker.ts +28 -14
- package/src/lib/tools/BetaRunnableTool.ts +26 -43
- package/src/lib/tools/BetaToolRunner.ts +6 -13
- package/src/lib/tools/SessionToolRunner.ts +39 -6
- package/src/resources/beta/agents/agents.ts +3 -3
- package/src/resources/beta/beta.ts +127 -8
- package/src/resources/beta/dreams.ts +2 -2
- package/src/resources/beta/environments/environments.ts +4 -3
- package/src/resources/beta/files.ts +27 -27
- package/src/resources/beta/index.ts +63 -4
- package/src/resources/beta/memory-stores/index.ts +1 -0
- package/src/resources/beta/memory-stores/memory-stores.ts +2 -0
- package/src/resources/beta/memory-stores/memory-versions.ts +21 -1
- package/src/resources/beta/messages/batches.ts +1 -1
- package/src/resources/beta/messages/index.ts +60 -1
- package/src/resources/beta/messages/messages.ts +1862 -435
- package/src/resources/beta/sessions/sessions.ts +1 -1
- package/src/resources/beta/user-profiles.ts +44 -15
- package/src/resources/files.ts +163 -0
- package/src/resources/index.ts +83 -1
- package/src/resources/messages/batches.ts +1 -1
- package/src/resources/messages/index.ts +66 -1
- package/src/resources/messages/messages.ts +1830 -320
- package/src/resources/skills/index.ts +21 -0
- package/src/resources/skills/skills.ts +194 -0
- package/src/resources/skills/versions.ts +160 -0
- package/src/resources/skills.ts +3 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -22,10 +22,7 @@ import { ToolError } from './ToolError';
|
|
|
22
22
|
|
|
23
23
|
export type Promisable<T> = T | Promise<T>;
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Tool types that can be implemented on the client.
|
|
27
|
-
* Excludes server-side tools like code execution, web search, and MCP toolsets.
|
|
28
|
-
*/
|
|
25
|
+
/** Tools that run on the client. Server-side tools (code execution, web search, MCP toolsets) are not included. */
|
|
29
26
|
export type BetaClientRunnableToolType =
|
|
30
27
|
| BetaTool
|
|
31
28
|
| BetaMemoryTool20250818
|
|
@@ -40,15 +37,9 @@ export type BetaClientRunnableToolType =
|
|
|
40
37
|
| BetaToolTextEditor20250728;
|
|
41
38
|
|
|
42
39
|
/**
|
|
43
|
-
* The tool
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* - from `client.beta.sessions.events.toolRunner`, the `agent.tool_use` /
|
|
47
|
-
* `agent.custom_tool_use` session event.
|
|
48
|
-
*
|
|
49
|
-
* The shapes overlap on the common fields (`id`, `name`, `input`), so code that
|
|
50
|
-
* only reads those works without narrowing; narrow on the shape (e.g. `'type' in
|
|
51
|
-
* x`) when you need surface-specific properties.
|
|
40
|
+
* The tool call being served: a Messages `tool_use` block, or a session
|
|
41
|
+
* `agent.tool_use` / `agent.custom_tool_use` event. All three carry `id`,
|
|
42
|
+
* `name` and `input`.
|
|
52
43
|
*/
|
|
53
44
|
export type BetaToolUse =
|
|
54
45
|
| BetaToolUseBlock
|
|
@@ -56,65 +47,57 @@ export type BetaToolUse =
|
|
|
56
47
|
| BetaManagedAgentsAgentCustomToolUseEvent;
|
|
57
48
|
|
|
58
49
|
export type BetaToolRunContext = {
|
|
59
|
-
/** The tool-use that triggered this run. See {@link BetaToolUse}. */
|
|
60
50
|
toolUse: BetaToolUse;
|
|
51
|
+
/** @deprecated Use `toolUse`. */
|
|
52
|
+
toolUseBlock: BetaToolUse;
|
|
61
53
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* name — which is why it was renamed.
|
|
54
|
+
* Aborted when the runner is aborted or, in the session runner, when the
|
|
55
|
+
* per-tool timeout fires. The runner still waits for `run` to return, so
|
|
56
|
+
* check it in long-running work.
|
|
66
57
|
*/
|
|
67
|
-
toolUseBlock: BetaToolUse;
|
|
68
58
|
signal?: AbortSignal | null | undefined;
|
|
69
59
|
};
|
|
70
60
|
|
|
71
|
-
|
|
72
|
-
// that will be called by `toolRunner()` helpers
|
|
61
|
+
/** A tool definition plus the `run` and `parse` the tool runners call. */
|
|
73
62
|
export type BetaRunnableTool<Input = any> = BetaClientRunnableToolType & {
|
|
63
|
+
/**
|
|
64
|
+
* Runs on the event loop: a body that blocks synchronously stalls the runner
|
|
65
|
+
* and, in an `EnvironmentWorker`, the lease heartbeat. Await async work or
|
|
66
|
+
* move it to a worker thread.
|
|
67
|
+
*/
|
|
74
68
|
run: (
|
|
75
69
|
args: Input,
|
|
76
70
|
context?: BetaToolRunContext,
|
|
77
71
|
) => Promisable<string | Array<BetaToolResultContentBlockParam>>;
|
|
78
72
|
parse: (content: unknown) => Input;
|
|
79
|
-
/**
|
|
80
|
-
* Optional cleanup hook for tools that hold process-level resources (e.g. a
|
|
81
|
-
* persistent shell). `SessionToolRunner` (`client.beta.sessions.events.toolRunner`)
|
|
82
|
-
* calls it once when iteration ends.
|
|
83
|
-
*/
|
|
73
|
+
/** Called once by the session runner when it stops. Release held resources here (e.g. a shell). */
|
|
84
74
|
close?: () => Promisable<void>;
|
|
85
75
|
};
|
|
86
76
|
|
|
87
77
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* Shared so the tool-name lookup is identical across `toolRunner()` surfaces.
|
|
78
|
+
* The name the model calls a tool by: `mcp_server_name` for MCP toolsets, `type` for nameless server
|
|
79
|
+
* toolsets (browser/computer), `name` for everything else.
|
|
91
80
|
*/
|
|
92
81
|
export function toolName(tool: BetaToolUnion | BetaRunnableTool): string {
|
|
93
|
-
return
|
|
82
|
+
return (
|
|
83
|
+
'name' in tool ? tool.name
|
|
84
|
+
: 'mcp_server_name' in tool ? tool.mcp_server_name
|
|
85
|
+
: tool.type
|
|
86
|
+
);
|
|
94
87
|
}
|
|
95
88
|
|
|
96
|
-
/**
|
|
97
|
-
* Format a thrown value into tool-result content: a {@link ToolError} carries
|
|
98
|
-
* its own structured content, anything else becomes an `Error: <message>`
|
|
99
|
-
* string. Shared so every `toolRunner()` surface reports tool failures the
|
|
100
|
-
* same way to the model.
|
|
101
|
-
*/
|
|
89
|
+
/** Tool-result content for a thrown value: a {@link ToolError}'s own content, otherwise `Error: <message>`. */
|
|
102
90
|
export function toolErrorContent(e: unknown): string | Array<BetaToolResultContentBlockParam> {
|
|
103
91
|
return e instanceof ToolError ? e.content : `Error: ${e instanceof Error ? e.message : String(e)}`;
|
|
104
92
|
}
|
|
105
93
|
|
|
106
|
-
/**
|
|
94
|
+
/** What a tool run produced, and whether it failed. */
|
|
107
95
|
export interface RunnableToolOutcome {
|
|
108
96
|
content: string | Array<BetaToolResultContentBlockParam>;
|
|
109
97
|
isError: boolean;
|
|
110
98
|
}
|
|
111
99
|
|
|
112
|
-
/**
|
|
113
|
-
* Run a {@link BetaRunnableTool} end-to-end: parse the raw input, invoke `run`,
|
|
114
|
-
* and format any thrown value via {@link toolErrorContent}. Shared so the
|
|
115
|
-
* parse → run → catch → format pipeline is identical across `toolRunner()`
|
|
116
|
-
* surfaces.
|
|
117
|
-
*/
|
|
100
|
+
/** Parse the input, run the tool, and turn anything thrown into an error result. */
|
|
118
101
|
export async function runRunnableTool(
|
|
119
102
|
tool: BetaRunnableTool,
|
|
120
103
|
rawInput: unknown,
|
|
@@ -492,7 +492,12 @@ async function generateToolResponse(
|
|
|
492
492
|
const available = availableToolNames(params);
|
|
493
493
|
const toolResults = await Promise.all(
|
|
494
494
|
toolUseBlocks.map(async (toolUse) => {
|
|
495
|
-
const tool = params.tools.find(
|
|
495
|
+
const tool = params.tools.find(
|
|
496
|
+
(t) =>
|
|
497
|
+
('name' in t ? t.name
|
|
498
|
+
: 'mcp_server_name' in t ? t.mcp_server_name
|
|
499
|
+
: t.type) === toolUse.name,
|
|
500
|
+
);
|
|
496
501
|
// A `tool_removal` is only a hint to the model, which may still emit a tool_use for a
|
|
497
502
|
// withdrawn tool — treat those exactly like a tool that was never defined.
|
|
498
503
|
if (!tool || !('run' in tool) || !available.has(toolUse.name)) {
|
|
@@ -578,18 +583,6 @@ function applyToolChange(block: BetaContentBlockParam, available: Set<string>):
|
|
|
578
583
|
case 'tool_addition':
|
|
579
584
|
applyToolReference(block, available);
|
|
580
585
|
break;
|
|
581
|
-
case 'mid_conv_system':
|
|
582
|
-
// A `mid_conv_system` block's content is limited by the API schema to
|
|
583
|
-
// text / tool_addition / tool_removal, so we walk exactly one level — no recursion.
|
|
584
|
-
for (const inner of block.content) {
|
|
585
|
-
if (inner.type === 'tool_removal' || inner.type === 'tool_addition') {
|
|
586
|
-
applyToolReference(inner, available);
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
break;
|
|
590
|
-
default:
|
|
591
|
-
// Other and unknown/newer block types leave the set untouched (forward compatibility).
|
|
592
|
-
break;
|
|
593
586
|
}
|
|
594
587
|
}
|
|
595
588
|
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
786
|
-
|
|
787
|
-
|
|
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-
|
|
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-
|
|
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-
|
|
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;
|
|
@@ -101,13 +101,13 @@ import {
|
|
|
101
101
|
} from './dreams';
|
|
102
102
|
import * as FilesAPI from './files';
|
|
103
103
|
import {
|
|
104
|
+
BetaDeletedFile,
|
|
105
|
+
BetaFileMetadata,
|
|
106
|
+
BetaFileMetadataPage,
|
|
104
107
|
BetaFileScope,
|
|
105
|
-
DeletedFile,
|
|
106
108
|
FileDeleteParams,
|
|
107
109
|
FileDownloadParams,
|
|
108
110
|
FileListParams,
|
|
109
|
-
FileMetadata,
|
|
110
|
-
FileMetadataPage,
|
|
111
111
|
FileRetrieveMetadataParams,
|
|
112
112
|
FileUploadParams,
|
|
113
113
|
Files,
|
|
@@ -304,6 +304,46 @@ import {
|
|
|
304
304
|
BetaBashCodeExecutionToolResultBlockParam,
|
|
305
305
|
BetaBashCodeExecutionToolResultError,
|
|
306
306
|
BetaBashCodeExecutionToolResultErrorParam,
|
|
307
|
+
BetaBrowserCloseTabConfig,
|
|
308
|
+
BetaBrowserDoubleClickConfig,
|
|
309
|
+
BetaBrowserFileUploadConfig,
|
|
310
|
+
BetaBrowserFindConfig,
|
|
311
|
+
BetaBrowserFormInputConfig,
|
|
312
|
+
BetaBrowserGetPageTextConfig,
|
|
313
|
+
BetaBrowserHoldKeyConfig,
|
|
314
|
+
BetaBrowserHoverConfig,
|
|
315
|
+
BetaBrowserJavascriptExecConfig,
|
|
316
|
+
BetaBrowserKeyConfig,
|
|
317
|
+
BetaBrowserLeftClickConfig,
|
|
318
|
+
BetaBrowserLeftClickDragConfig,
|
|
319
|
+
BetaBrowserLeftMouseDownConfig,
|
|
320
|
+
BetaBrowserLeftMouseUpConfig,
|
|
321
|
+
BetaBrowserListTabsConfig,
|
|
322
|
+
BetaBrowserMiddleClickConfig,
|
|
323
|
+
BetaBrowserMouseMoveConfig,
|
|
324
|
+
BetaBrowserNavigateConfig,
|
|
325
|
+
BetaBrowserNewTabConfig,
|
|
326
|
+
BetaBrowserReadConsoleConfig,
|
|
327
|
+
BetaBrowserReadNetworkConfig,
|
|
328
|
+
BetaBrowserReadPageConfig,
|
|
329
|
+
BetaBrowserRightClickConfig,
|
|
330
|
+
BetaBrowserScreenshotConfig,
|
|
331
|
+
BetaBrowserScrollConfig,
|
|
332
|
+
BetaBrowserScrollToConfig,
|
|
333
|
+
BetaBrowserStateBlockParam,
|
|
334
|
+
BetaBrowserStateChange,
|
|
335
|
+
BetaBrowserStateChangeDownloadCompleted,
|
|
336
|
+
BetaBrowserStateChangeDownloadFailed,
|
|
337
|
+
BetaBrowserStateChangeDownloadStarted,
|
|
338
|
+
BetaBrowserStateChangeTabOpened,
|
|
339
|
+
BetaBrowserStateTabEntry,
|
|
340
|
+
BetaBrowserSwitchTabConfig,
|
|
341
|
+
BetaBrowserToolset20260801,
|
|
342
|
+
BetaBrowserToolsetConfigs,
|
|
343
|
+
BetaBrowserTripleClickConfig,
|
|
344
|
+
BetaBrowserTypeConfig,
|
|
345
|
+
BetaBrowserWaitConfig,
|
|
346
|
+
BetaBrowserZoomConfig,
|
|
307
347
|
BetaCacheControlEphemeral,
|
|
308
348
|
BetaCacheCreation,
|
|
309
349
|
BetaCacheMissMessagesChanged,
|
|
@@ -349,6 +389,25 @@ import {
|
|
|
349
389
|
BetaCompactionBlockParam,
|
|
350
390
|
BetaCompactionContentBlockDelta,
|
|
351
391
|
BetaCompactionIterationUsage,
|
|
392
|
+
BetaComputerCursorPositionConfig,
|
|
393
|
+
BetaComputerDoubleClickConfig,
|
|
394
|
+
BetaComputerHoldKeyConfig,
|
|
395
|
+
BetaComputerKeyConfig,
|
|
396
|
+
BetaComputerLeftClickConfig,
|
|
397
|
+
BetaComputerLeftClickDragConfig,
|
|
398
|
+
BetaComputerLeftMouseDownConfig,
|
|
399
|
+
BetaComputerLeftMouseUpConfig,
|
|
400
|
+
BetaComputerMiddleClickConfig,
|
|
401
|
+
BetaComputerMouseMoveConfig,
|
|
402
|
+
BetaComputerRightClickConfig,
|
|
403
|
+
BetaComputerScreenshotConfig,
|
|
404
|
+
BetaComputerScrollConfig,
|
|
405
|
+
BetaComputerToolset20260801,
|
|
406
|
+
BetaComputerToolsetConfigs,
|
|
407
|
+
BetaComputerTripleClickConfig,
|
|
408
|
+
BetaComputerTypeConfig,
|
|
409
|
+
BetaComputerWaitConfig,
|
|
410
|
+
BetaComputerZoomConfig,
|
|
352
411
|
BetaContainer,
|
|
353
412
|
BetaContainerParams,
|
|
354
413
|
BetaContainerUploadBlock,
|
|
@@ -381,6 +440,7 @@ import {
|
|
|
381
440
|
BetaFileDocumentSource,
|
|
382
441
|
BetaFileImageSource,
|
|
383
442
|
BetaImageBlockParam,
|
|
443
|
+
BetaImageTransformationsParam,
|
|
384
444
|
BetaInputJSONDelta,
|
|
385
445
|
BetaJSONOutputFormat,
|
|
386
446
|
BetaInputTokensClearAtLeast,
|
|
@@ -403,7 +463,6 @@ import {
|
|
|
403
463
|
BetaMessageParam,
|
|
404
464
|
BetaMessageTokensCount,
|
|
405
465
|
BetaMetadata,
|
|
406
|
-
BetaMidConversationSystemBlockParam,
|
|
407
466
|
BetaOutputConfig,
|
|
408
467
|
BetaOutputTokensDetails,
|
|
409
468
|
BetaPlainTextSource,
|
|
@@ -646,6 +705,7 @@ export type AnthropicBeta =
|
|
|
646
705
|
| 'fast-mode-2026-02-01'
|
|
647
706
|
| 'output-300k-2026-03-24'
|
|
648
707
|
| 'user-profiles-2026-03-24'
|
|
708
|
+
| 'user-profiles-2026-08-18'
|
|
649
709
|
| 'advisor-tool-2026-03-01'
|
|
650
710
|
| 'managed-agents-2026-04-01'
|
|
651
711
|
| 'cache-diagnosis-2026-04-07'
|
|
@@ -823,6 +883,46 @@ export declare namespace Beta {
|
|
|
823
883
|
type BetaBashCodeExecutionToolResultBlockParam as BetaBashCodeExecutionToolResultBlockParam,
|
|
824
884
|
type BetaBashCodeExecutionToolResultError as BetaBashCodeExecutionToolResultError,
|
|
825
885
|
type BetaBashCodeExecutionToolResultErrorParam as BetaBashCodeExecutionToolResultErrorParam,
|
|
886
|
+
type BetaBrowserCloseTabConfig as BetaBrowserCloseTabConfig,
|
|
887
|
+
type BetaBrowserDoubleClickConfig as BetaBrowserDoubleClickConfig,
|
|
888
|
+
type BetaBrowserFileUploadConfig as BetaBrowserFileUploadConfig,
|
|
889
|
+
type BetaBrowserFindConfig as BetaBrowserFindConfig,
|
|
890
|
+
type BetaBrowserFormInputConfig as BetaBrowserFormInputConfig,
|
|
891
|
+
type BetaBrowserGetPageTextConfig as BetaBrowserGetPageTextConfig,
|
|
892
|
+
type BetaBrowserHoldKeyConfig as BetaBrowserHoldKeyConfig,
|
|
893
|
+
type BetaBrowserHoverConfig as BetaBrowserHoverConfig,
|
|
894
|
+
type BetaBrowserJavascriptExecConfig as BetaBrowserJavascriptExecConfig,
|
|
895
|
+
type BetaBrowserKeyConfig as BetaBrowserKeyConfig,
|
|
896
|
+
type BetaBrowserLeftClickConfig as BetaBrowserLeftClickConfig,
|
|
897
|
+
type BetaBrowserLeftClickDragConfig as BetaBrowserLeftClickDragConfig,
|
|
898
|
+
type BetaBrowserLeftMouseDownConfig as BetaBrowserLeftMouseDownConfig,
|
|
899
|
+
type BetaBrowserLeftMouseUpConfig as BetaBrowserLeftMouseUpConfig,
|
|
900
|
+
type BetaBrowserListTabsConfig as BetaBrowserListTabsConfig,
|
|
901
|
+
type BetaBrowserMiddleClickConfig as BetaBrowserMiddleClickConfig,
|
|
902
|
+
type BetaBrowserMouseMoveConfig as BetaBrowserMouseMoveConfig,
|
|
903
|
+
type BetaBrowserNavigateConfig as BetaBrowserNavigateConfig,
|
|
904
|
+
type BetaBrowserNewTabConfig as BetaBrowserNewTabConfig,
|
|
905
|
+
type BetaBrowserReadConsoleConfig as BetaBrowserReadConsoleConfig,
|
|
906
|
+
type BetaBrowserReadNetworkConfig as BetaBrowserReadNetworkConfig,
|
|
907
|
+
type BetaBrowserReadPageConfig as BetaBrowserReadPageConfig,
|
|
908
|
+
type BetaBrowserRightClickConfig as BetaBrowserRightClickConfig,
|
|
909
|
+
type BetaBrowserScreenshotConfig as BetaBrowserScreenshotConfig,
|
|
910
|
+
type BetaBrowserScrollConfig as BetaBrowserScrollConfig,
|
|
911
|
+
type BetaBrowserScrollToConfig as BetaBrowserScrollToConfig,
|
|
912
|
+
type BetaBrowserStateBlockParam as BetaBrowserStateBlockParam,
|
|
913
|
+
type BetaBrowserStateChange as BetaBrowserStateChange,
|
|
914
|
+
type BetaBrowserStateChangeDownloadCompleted as BetaBrowserStateChangeDownloadCompleted,
|
|
915
|
+
type BetaBrowserStateChangeDownloadFailed as BetaBrowserStateChangeDownloadFailed,
|
|
916
|
+
type BetaBrowserStateChangeDownloadStarted as BetaBrowserStateChangeDownloadStarted,
|
|
917
|
+
type BetaBrowserStateChangeTabOpened as BetaBrowserStateChangeTabOpened,
|
|
918
|
+
type BetaBrowserStateTabEntry as BetaBrowserStateTabEntry,
|
|
919
|
+
type BetaBrowserSwitchTabConfig as BetaBrowserSwitchTabConfig,
|
|
920
|
+
type BetaBrowserToolset20260801 as BetaBrowserToolset20260801,
|
|
921
|
+
type BetaBrowserToolsetConfigs as BetaBrowserToolsetConfigs,
|
|
922
|
+
type BetaBrowserTripleClickConfig as BetaBrowserTripleClickConfig,
|
|
923
|
+
type BetaBrowserTypeConfig as BetaBrowserTypeConfig,
|
|
924
|
+
type BetaBrowserWaitConfig as BetaBrowserWaitConfig,
|
|
925
|
+
type BetaBrowserZoomConfig as BetaBrowserZoomConfig,
|
|
826
926
|
type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
|
|
827
927
|
type BetaCacheCreation as BetaCacheCreation,
|
|
828
928
|
type BetaCacheMissMessagesChanged as BetaCacheMissMessagesChanged,
|
|
@@ -868,6 +968,25 @@ export declare namespace Beta {
|
|
|
868
968
|
type BetaCompactionBlockParam as BetaCompactionBlockParam,
|
|
869
969
|
type BetaCompactionContentBlockDelta as BetaCompactionContentBlockDelta,
|
|
870
970
|
type BetaCompactionIterationUsage as BetaCompactionIterationUsage,
|
|
971
|
+
type BetaComputerCursorPositionConfig as BetaComputerCursorPositionConfig,
|
|
972
|
+
type BetaComputerDoubleClickConfig as BetaComputerDoubleClickConfig,
|
|
973
|
+
type BetaComputerHoldKeyConfig as BetaComputerHoldKeyConfig,
|
|
974
|
+
type BetaComputerKeyConfig as BetaComputerKeyConfig,
|
|
975
|
+
type BetaComputerLeftClickConfig as BetaComputerLeftClickConfig,
|
|
976
|
+
type BetaComputerLeftClickDragConfig as BetaComputerLeftClickDragConfig,
|
|
977
|
+
type BetaComputerLeftMouseDownConfig as BetaComputerLeftMouseDownConfig,
|
|
978
|
+
type BetaComputerLeftMouseUpConfig as BetaComputerLeftMouseUpConfig,
|
|
979
|
+
type BetaComputerMiddleClickConfig as BetaComputerMiddleClickConfig,
|
|
980
|
+
type BetaComputerMouseMoveConfig as BetaComputerMouseMoveConfig,
|
|
981
|
+
type BetaComputerRightClickConfig as BetaComputerRightClickConfig,
|
|
982
|
+
type BetaComputerScreenshotConfig as BetaComputerScreenshotConfig,
|
|
983
|
+
type BetaComputerScrollConfig as BetaComputerScrollConfig,
|
|
984
|
+
type BetaComputerToolset20260801 as BetaComputerToolset20260801,
|
|
985
|
+
type BetaComputerToolsetConfigs as BetaComputerToolsetConfigs,
|
|
986
|
+
type BetaComputerTripleClickConfig as BetaComputerTripleClickConfig,
|
|
987
|
+
type BetaComputerTypeConfig as BetaComputerTypeConfig,
|
|
988
|
+
type BetaComputerWaitConfig as BetaComputerWaitConfig,
|
|
989
|
+
type BetaComputerZoomConfig as BetaComputerZoomConfig,
|
|
871
990
|
type BetaContainer as BetaContainer,
|
|
872
991
|
type BetaContainerParams as BetaContainerParams,
|
|
873
992
|
type BetaContainerUploadBlock as BetaContainerUploadBlock,
|
|
@@ -900,6 +1019,7 @@ export declare namespace Beta {
|
|
|
900
1019
|
type BetaFileDocumentSource as BetaFileDocumentSource,
|
|
901
1020
|
type BetaFileImageSource as BetaFileImageSource,
|
|
902
1021
|
type BetaImageBlockParam as BetaImageBlockParam,
|
|
1022
|
+
type BetaImageTransformationsParam as BetaImageTransformationsParam,
|
|
903
1023
|
type BetaInputJSONDelta as BetaInputJSONDelta,
|
|
904
1024
|
type BetaJSONOutputFormat as BetaJSONOutputFormat,
|
|
905
1025
|
type BetaInputTokensClearAtLeast as BetaInputTokensClearAtLeast,
|
|
@@ -924,7 +1044,6 @@ export declare namespace Beta {
|
|
|
924
1044
|
type BetaMessageParam as BetaMessageParam,
|
|
925
1045
|
type BetaMessageTokensCount as BetaMessageTokensCount,
|
|
926
1046
|
type BetaMetadata as BetaMetadata,
|
|
927
|
-
type BetaMidConversationSystemBlockParam as BetaMidConversationSystemBlockParam,
|
|
928
1047
|
type BetaOutputConfig as BetaOutputConfig,
|
|
929
1048
|
type BetaOutputTokensDetails as BetaOutputTokensDetails,
|
|
930
1049
|
type BetaPlainTextSource as BetaPlainTextSource,
|
|
@@ -1263,10 +1382,10 @@ export declare namespace Beta {
|
|
|
1263
1382
|
|
|
1264
1383
|
export {
|
|
1265
1384
|
Files as Files,
|
|
1385
|
+
type BetaDeletedFile as BetaDeletedFile,
|
|
1386
|
+
type BetaFileMetadata as BetaFileMetadata,
|
|
1266
1387
|
type BetaFileScope as BetaFileScope,
|
|
1267
|
-
type
|
|
1268
|
-
type FileMetadata as FileMetadata,
|
|
1269
|
-
type FileMetadataPage as FileMetadataPage,
|
|
1388
|
+
type BetaFileMetadataPage as BetaFileMetadataPage,
|
|
1270
1389
|
type FileListParams as FileListParams,
|
|
1271
1390
|
type FileDeleteParams as FileDeleteParams,
|
|
1272
1391
|
type FileDownloadParams as FileDownloadParams,
|
|
@@ -243,7 +243,7 @@ export interface BetaDreamMemoryStoreOutput {
|
|
|
243
243
|
*/
|
|
244
244
|
export interface BetaDreamModelConfig {
|
|
245
245
|
/**
|
|
246
|
-
* Model identifier, e.g. "claude-opus-
|
|
246
|
+
* Model identifier, e.g. "claude-opus-5". 1-256 characters.
|
|
247
247
|
*/
|
|
248
248
|
id: string;
|
|
249
249
|
|
|
@@ -260,7 +260,7 @@ export interface BetaDreamModelConfig {
|
|
|
260
260
|
*/
|
|
261
261
|
export interface BetaDreamModelConfigParam {
|
|
262
262
|
/**
|
|
263
|
-
* Model identifier, e.g. "claude-opus-
|
|
263
|
+
* Model identifier, e.g. "claude-opus-5". 1-256 characters.
|
|
264
264
|
*/
|
|
265
265
|
id: string;
|
|
266
266
|
|
|
@@ -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
|
|
|
@@ -18,7 +18,7 @@ export class Files extends APIResource {
|
|
|
18
18
|
* @example
|
|
19
19
|
* ```ts
|
|
20
20
|
* // Automatically fetches more pages as needed.
|
|
21
|
-
* for await (const
|
|
21
|
+
* for await (const betaFileMetadata of client.beta.files.list()) {
|
|
22
22
|
* // ...
|
|
23
23
|
* }
|
|
24
24
|
* ```
|
|
@@ -26,9 +26,9 @@ export class Files extends APIResource {
|
|
|
26
26
|
list(
|
|
27
27
|
params: FileListParams | null | undefined = {},
|
|
28
28
|
options?: RequestOptions,
|
|
29
|
-
): PagePromise<
|
|
29
|
+
): PagePromise<BetaFileMetadataPage, BetaFileMetadata> {
|
|
30
30
|
const { betas, ...query } = params ?? {};
|
|
31
|
-
return this._client.getAPIList('/v1/files?beta=true', Page<
|
|
31
|
+
return this._client.getAPIList('/v1/files?beta=true', Page<BetaFileMetadata>, {
|
|
32
32
|
query,
|
|
33
33
|
...options,
|
|
34
34
|
headers: buildHeaders([
|
|
@@ -43,7 +43,7 @@ export class Files extends APIResource {
|
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts
|
|
46
|
-
* const
|
|
46
|
+
* const betaDeletedFile = await client.beta.files.delete(
|
|
47
47
|
* 'file_id',
|
|
48
48
|
* );
|
|
49
49
|
* ```
|
|
@@ -52,7 +52,7 @@ export class Files extends APIResource {
|
|
|
52
52
|
fileID: string,
|
|
53
53
|
params: FileDeleteParams | null | undefined = {},
|
|
54
54
|
options?: RequestOptions,
|
|
55
|
-
): APIPromise<
|
|
55
|
+
): APIPromise<BetaDeletedFile> {
|
|
56
56
|
const { betas } = params ?? {};
|
|
57
57
|
return this._client.delete(path`/v1/files/${fileID}?beta=true`, {
|
|
58
58
|
...options,
|
|
@@ -100,7 +100,7 @@ export class Files extends APIResource {
|
|
|
100
100
|
*
|
|
101
101
|
* @example
|
|
102
102
|
* ```ts
|
|
103
|
-
* const
|
|
103
|
+
* const betaFileMetadata =
|
|
104
104
|
* await client.beta.files.retrieveMetadata('file_id');
|
|
105
105
|
* ```
|
|
106
106
|
*/
|
|
@@ -108,7 +108,7 @@ export class Files extends APIResource {
|
|
|
108
108
|
fileID: string,
|
|
109
109
|
params: FileRetrieveMetadataParams | null | undefined = {},
|
|
110
110
|
options?: RequestOptions,
|
|
111
|
-
): APIPromise<
|
|
111
|
+
): APIPromise<BetaFileMetadata> {
|
|
112
112
|
const { betas } = params ?? {};
|
|
113
113
|
return this._client.get(path`/v1/files/${fileID}?beta=true`, {
|
|
114
114
|
...options,
|
|
@@ -124,12 +124,12 @@ export class Files extends APIResource {
|
|
|
124
124
|
*
|
|
125
125
|
* @example
|
|
126
126
|
* ```ts
|
|
127
|
-
* const
|
|
127
|
+
* const betaFileMetadata = await client.beta.files.upload({
|
|
128
128
|
* file: fs.createReadStream('path/to/file'),
|
|
129
129
|
* });
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
132
|
-
upload(params: FileUploadParams, options?: RequestOptions): APIPromise<
|
|
132
|
+
upload(params: FileUploadParams, options?: RequestOptions): APIPromise<BetaFileMetadata> {
|
|
133
133
|
const { betas, ...body } = params;
|
|
134
134
|
|
|
135
135
|
return this._client.post(
|
|
@@ -150,21 +150,9 @@ export class Files extends APIResource {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
export type
|
|
153
|
+
export type BetaFileMetadataPage = Page<BetaFileMetadata>;
|
|
154
154
|
|
|
155
|
-
export interface
|
|
156
|
-
/**
|
|
157
|
-
* The ID of the scoping resource (e.g., the session ID).
|
|
158
|
-
*/
|
|
159
|
-
id: string;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* The type of scope (e.g., `"session"`).
|
|
163
|
-
*/
|
|
164
|
-
type: 'session';
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export interface DeletedFile {
|
|
155
|
+
export interface BetaDeletedFile {
|
|
168
156
|
/**
|
|
169
157
|
* ID of the deleted file.
|
|
170
158
|
*/
|
|
@@ -178,7 +166,7 @@ export interface DeletedFile {
|
|
|
178
166
|
type?: 'file_deleted';
|
|
179
167
|
}
|
|
180
168
|
|
|
181
|
-
export interface
|
|
169
|
+
export interface BetaFileMetadata {
|
|
182
170
|
/**
|
|
183
171
|
* Unique object identifier.
|
|
184
172
|
*
|
|
@@ -225,6 +213,18 @@ export interface FileMetadata {
|
|
|
225
213
|
scope?: BetaFileScope | null;
|
|
226
214
|
}
|
|
227
215
|
|
|
216
|
+
export interface BetaFileScope {
|
|
217
|
+
/**
|
|
218
|
+
* The ID of the scoping resource (e.g., the session ID).
|
|
219
|
+
*/
|
|
220
|
+
id: string;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The type of scope (e.g., `"session"`).
|
|
224
|
+
*/
|
|
225
|
+
type: 'session';
|
|
226
|
+
}
|
|
227
|
+
|
|
228
228
|
export interface FileListParams extends PageParams {
|
|
229
229
|
/**
|
|
230
230
|
* Query param: Filter by scope ID. Only returns files associated with the
|
|
@@ -273,10 +273,10 @@ export interface FileUploadParams {
|
|
|
273
273
|
|
|
274
274
|
export declare namespace Files {
|
|
275
275
|
export {
|
|
276
|
+
type BetaDeletedFile as BetaDeletedFile,
|
|
277
|
+
type BetaFileMetadata as BetaFileMetadata,
|
|
276
278
|
type BetaFileScope as BetaFileScope,
|
|
277
|
-
type
|
|
278
|
-
type FileMetadata as FileMetadata,
|
|
279
|
-
type FileMetadataPage as FileMetadataPage,
|
|
279
|
+
type BetaFileMetadataPage as BetaFileMetadataPage,
|
|
280
280
|
type FileListParams as FileListParams,
|
|
281
281
|
type FileDeleteParams as FileDeleteParams,
|
|
282
282
|
type FileDownloadParams as FileDownloadParams,
|