@anthropic-ai/sdk 0.105.0 → 0.107.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 +44 -0
- package/README.md +16 -1
- package/client.d.mts +2 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +2 -2
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts.map +1 -1
- package/core/streaming.d.ts.map +1 -1
- package/core/streaming.js +2 -1
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +2 -1
- package/core/streaming.mjs.map +1 -1
- package/helpers/beta/mcp.d.mts +1 -1
- package/helpers/beta/mcp.d.mts.map +1 -1
- package/helpers/beta/mcp.d.ts +1 -1
- package/helpers/beta/mcp.d.ts.map +1 -1
- package/helpers/beta/mcp.js +1 -1
- package/helpers/beta/mcp.js.map +1 -1
- package/helpers/beta/mcp.mjs +1 -1
- package/helpers/beta/mcp.mjs.map +1 -1
- package/internal/headers.d.mts +7 -0
- package/internal/headers.d.mts.map +1 -1
- package/internal/headers.d.ts +7 -0
- package/internal/headers.d.ts.map +1 -1
- package/internal/headers.js +45 -4
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +43 -3
- package/internal/headers.mjs.map +1 -1
- package/internal/stainless-helper-header.d.mts +60 -0
- package/internal/stainless-helper-header.d.mts.map +1 -0
- package/internal/stainless-helper-header.d.ts +60 -0
- package/internal/stainless-helper-header.d.ts.map +1 -0
- package/{lib → internal}/stainless-helper-header.js +27 -6
- package/internal/stainless-helper-header.js.map +1 -0
- package/{lib → internal}/stainless-helper-header.mjs +25 -5
- package/internal/stainless-helper-header.mjs.map +1 -0
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +2 -1
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +2 -1
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.d.mts.map +1 -1
- package/lib/MessageStream.d.ts.map +1 -1
- package/lib/MessageStream.js +2 -1
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +2 -1
- package/lib/MessageStream.mjs.map +1 -1
- package/lib/helper-client.d.mts +2 -20
- package/lib/helper-client.d.mts.map +1 -1
- package/lib/helper-client.d.ts +2 -20
- package/lib/helper-client.d.ts.map +1 -1
- package/lib/helper-client.js +2 -1
- package/lib/helper-client.js.map +1 -1
- package/lib/helper-client.mjs +2 -1
- package/lib/helper-client.mjs.map +1 -1
- package/lib/middleware.d.mts.map +1 -1
- package/lib/middleware.d.ts.map +1 -1
- package/lib/middleware.js +7 -5
- package/lib/middleware.js.map +1 -1
- package/lib/middleware.mjs +7 -5
- package/lib/middleware.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 +11 -5
- package/lib/tools/BetaToolRunner.js.map +1 -1
- package/lib/tools/BetaToolRunner.mjs +11 -5
- package/lib/tools/BetaToolRunner.mjs.map +1 -1
- package/lib/tools/SessionToolRunner.d.mts.map +1 -1
- package/lib/tools/SessionToolRunner.d.ts.map +1 -1
- package/lib/tools/SessionToolRunner.js +2 -3
- package/lib/tools/SessionToolRunner.js.map +1 -1
- package/lib/tools/SessionToolRunner.mjs +2 -3
- package/lib/tools/SessionToolRunner.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/agents/agents.d.mts +7 -2
- package/resources/beta/agents/agents.d.mts.map +1 -1
- package/resources/beta/agents/agents.d.ts +7 -2
- package/resources/beta/agents/agents.d.ts.map +1 -1
- package/resources/beta/agents/agents.js.map +1 -1
- package/resources/beta/agents/agents.mjs.map +1 -1
- package/resources/beta/beta.d.mts +2 -2
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +2 -2
- 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/deployments.d.mts +18 -6
- package/resources/beta/deployments.d.mts.map +1 -1
- package/resources/beta/deployments.d.ts +18 -6
- package/resources/beta/deployments.d.ts.map +1 -1
- package/resources/beta/deployments.js +18 -6
- package/resources/beta/deployments.js.map +1 -1
- package/resources/beta/deployments.mjs +18 -6
- package/resources/beta/deployments.mjs.map +1 -1
- package/resources/beta/files.js +1 -1
- package/resources/beta/files.js.map +1 -1
- package/resources/beta/files.mjs +1 -1
- package/resources/beta/files.mjs.map +1 -1
- package/resources/beta/index.d.mts +1 -1
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +1 -1
- 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/messages/batches.d.mts +37 -26
- package/resources/beta/messages/batches.d.mts.map +1 -1
- package/resources/beta/messages/batches.d.ts +37 -26
- package/resources/beta/messages/batches.d.ts.map +1 -1
- package/resources/beta/messages/batches.js +11 -8
- package/resources/beta/messages/batches.js.map +1 -1
- package/resources/beta/messages/batches.mjs +11 -8
- package/resources/beta/messages/batches.mjs.map +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 +170 -39
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +170 -39
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +12 -6
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +12 -6
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/completions.d.mts +12 -7
- package/resources/completions.d.mts.map +1 -1
- package/resources/completions.d.ts +12 -7
- package/resources/completions.d.ts.map +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/messages/batches.d.mts +19 -10
- package/resources/messages/batches.d.mts.map +1 -1
- package/resources/messages/batches.d.ts +19 -10
- package/resources/messages/batches.d.ts.map +1 -1
- package/resources/messages/batches.js +16 -8
- package/resources/messages/batches.js.map +1 -1
- package/resources/messages/batches.mjs +16 -8
- package/resources/messages/batches.mjs.map +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 +209 -68
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +209 -68
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +20 -7
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +20 -7
- package/resources/messages/messages.mjs.map +1 -1
- package/src/client.ts +4 -0
- package/src/core/streaming.ts +2 -1
- package/src/helpers/beta/mcp.ts +1 -1
- package/src/internal/headers.ts +47 -4
- package/src/internal/stainless-helper-header.ts +122 -0
- package/src/lib/BetaMessageStream.ts +2 -1
- package/src/lib/MessageStream.ts +2 -1
- package/src/lib/helper-client.ts +6 -9
- package/src/lib/middleware.ts +10 -4
- package/src/lib/tools/BetaToolRunner.ts +15 -6
- package/src/lib/tools/SessionToolRunner.ts +2 -4
- package/src/resources/beta/agents/agents.ts +7 -2
- package/src/resources/beta/beta.ts +4 -0
- package/src/resources/beta/deployments.ts +18 -6
- package/src/resources/beta/files.ts +1 -1
- package/src/resources/beta/index.ts +2 -0
- package/src/resources/beta/messages/batches.ts +43 -29
- package/src/resources/beta/messages/index.ts +2 -0
- package/src/resources/beta/messages/messages.ts +213 -41
- package/src/resources/completions.ts +12 -7
- package/src/resources/index.ts +2 -0
- package/src/resources/messages/batches.ts +29 -11
- package/src/resources/messages/index.ts +2 -0
- package/src/resources/messages/messages.ts +260 -71
- package/src/tools/agent-toolset/fs-util.ts +7 -1
- package/src/tools/agent-toolset/node.ts +19 -3
- package/src/version.ts +1 -1
- package/tools/agent-toolset/fs-util.d.mts.map +1 -1
- package/tools/agent-toolset/fs-util.d.ts.map +1 -1
- package/tools/agent-toolset/fs-util.js +7 -1
- package/tools/agent-toolset/fs-util.js.map +1 -1
- package/tools/agent-toolset/fs-util.mjs +7 -1
- package/tools/agent-toolset/fs-util.mjs.map +1 -1
- package/tools/agent-toolset/node.d.mts.map +1 -1
- package/tools/agent-toolset/node.d.ts.map +1 -1
- package/tools/agent-toolset/node.js +21 -4
- package/tools/agent-toolset/node.js.map +1 -1
- package/tools/agent-toolset/node.mjs +21 -4
- package/tools/agent-toolset/node.mjs.map +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/lib/stainless-helper-header.d.mts +0 -34
- package/lib/stainless-helper-header.d.mts.map +0 -1
- package/lib/stainless-helper-header.d.ts +0 -34
- package/lib/stainless-helper-header.d.ts.map +0 -1
- package/lib/stainless-helper-header.js.map +0 -1
- package/lib/stainless-helper-header.mjs.map +0 -1
- package/src/lib/stainless-helper-header.ts +0 -80
package/src/lib/helper-client.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { AnthropicError } from '../core/error';
|
|
2
2
|
import type { Anthropic } from '../client';
|
|
3
3
|
import { buildHeaders, type HeadersLike, type NullableHeaders } from '../internal/headers';
|
|
4
|
+
import {
|
|
5
|
+
STAINLESS_HELPER_HEADER,
|
|
6
|
+
type StainlessHelperHeaderValue,
|
|
7
|
+
} from '../internal/stainless-helper-header';
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* Shared util for building a runner-helper-bound sub-client.
|
|
@@ -16,13 +20,6 @@ import { buildHeaders, type HeadersLike, type NullableHeaders } from '../interna
|
|
|
16
20
|
* {@link copyClientForHelper} is the one shared construction.
|
|
17
21
|
*/
|
|
18
22
|
|
|
19
|
-
/**
|
|
20
|
-
* The closed set of `x-stainless-helper` telemetry tags the runner helpers
|
|
21
|
-
* stamp on outgoing requests. Constrained as a string union so a typo at any
|
|
22
|
-
* call site is a type error rather than silently mistagged telemetry.
|
|
23
|
-
*/
|
|
24
|
-
export type HelperTag = 'environments-work-poller' | 'environments-worker' | 'session-tool-runner';
|
|
25
|
-
|
|
26
23
|
interface ClientInternalAccess {
|
|
27
24
|
_options: { defaultHeaders?: HeadersLike };
|
|
28
25
|
_authState?: { extraHeaders?: Record<string, string> };
|
|
@@ -54,7 +51,7 @@ interface ClientInternalAccess {
|
|
|
54
51
|
*/
|
|
55
52
|
export function copyClientForHelper<T extends Anthropic>(
|
|
56
53
|
client: T,
|
|
57
|
-
{ authToken, helper }: { authToken: string; helper:
|
|
54
|
+
{ authToken, helper }: { authToken: string; helper: StainlessHelperHeaderValue },
|
|
58
55
|
): T {
|
|
59
56
|
if (!authToken) {
|
|
60
57
|
throw new AnthropicError(
|
|
@@ -77,7 +74,7 @@ export function copyClientForHelper<T extends Anthropic>(
|
|
|
77
74
|
const defaultHeaders: NullableHeaders = buildHeaders([
|
|
78
75
|
inheritedAuthExtraHeaders,
|
|
79
76
|
parentDefaults,
|
|
80
|
-
{
|
|
77
|
+
{ [STAINLESS_HELPER_HEADER]: helper },
|
|
81
78
|
]);
|
|
82
79
|
return client.withOptions({
|
|
83
80
|
apiKey: null,
|
package/src/lib/middleware.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { AnthropicError } from '../core/error';
|
|
|
3
3
|
import type { Middleware, MiddlewareContext, MiddlewareNext } from '../core/middleware';
|
|
4
4
|
import { Stream, type ServerSentEvent } from '../core/streaming';
|
|
5
5
|
import { isAbortError } from '../internal/errors';
|
|
6
|
+
import { appendHeaderValue } from '../internal/headers';
|
|
7
|
+
import { STAINLESS_HELPER_HEADER } from '../internal/stainless-helper-header';
|
|
6
8
|
import { safeJSON } from '../internal/utils/values';
|
|
7
9
|
import type { AnthropicBeta } from '../resources/beta/beta';
|
|
8
10
|
import type {
|
|
@@ -179,8 +181,9 @@ export function betaRefusalFallbackMiddleware(
|
|
|
179
181
|
((error: BetaRefusalFallbackError) =>
|
|
180
182
|
ctx.logger.error(`anthropic-sdk: betaRefusalFallbackMiddleware: ${error.message}`));
|
|
181
183
|
|
|
182
|
-
// Send the configured betas on this and every hop request derived from it
|
|
183
|
-
|
|
184
|
+
// Send the configured betas on this and every hop request derived from it,
|
|
185
|
+
// and tag this and every hop with the middleware's helper telemetry.
|
|
186
|
+
request = withMiddlewareHeaders(request, options.betas ?? DEFAULT_BETAS);
|
|
184
187
|
|
|
185
188
|
const body = stripFallbackBlocks(ctx.options.body as MessageCreateParams);
|
|
186
189
|
const state = ctx.options.fallbackState;
|
|
@@ -851,8 +854,7 @@ function toPrefillBlocks(responseBlocks: any[]): BetaContentBlockParam[] {
|
|
|
851
854
|
* A copy of `request` with `betas` appended to its `anthropic-beta` header,
|
|
852
855
|
* skipping values already present (set by the caller or another middleware).
|
|
853
856
|
*/
|
|
854
|
-
function
|
|
855
|
-
if (!betas.length) return request;
|
|
857
|
+
function withMiddlewareHeaders(request: APIRequest, betas: readonly AnthropicBeta[]): APIRequest {
|
|
856
858
|
const headers = new Headers(request.headers);
|
|
857
859
|
const existing = new Set(
|
|
858
860
|
headers
|
|
@@ -866,6 +868,10 @@ function appendBetas(request: APIRequest, betas: readonly AnthropicBeta[]): APIR
|
|
|
866
868
|
existing.add(beta);
|
|
867
869
|
}
|
|
868
870
|
}
|
|
871
|
+
headers.set(
|
|
872
|
+
STAINLESS_HELPER_HEADER,
|
|
873
|
+
appendHeaderValue(headers.get(STAINLESS_HELPER_HEADER), 'fallback-refusal-middleware'),
|
|
874
|
+
);
|
|
869
875
|
return { ...request, headers };
|
|
870
876
|
}
|
|
871
877
|
|
|
@@ -8,7 +8,11 @@ import { RequestOptions } from '../../internal/request-options';
|
|
|
8
8
|
import { buildHeaders } from '../../internal/headers';
|
|
9
9
|
import { promiseWithResolvers } from '../../internal/utils/promise';
|
|
10
10
|
import { CompactionControl, DEFAULT_SUMMARY_PROMPT, DEFAULT_TOKEN_THRESHOLD } from './CompactionControl';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
collectStainlessHelpers,
|
|
13
|
+
helperHeader,
|
|
14
|
+
STAINLESS_HELPER_HEADER,
|
|
15
|
+
} from '../../internal/stainless-helper-header';
|
|
12
16
|
|
|
13
17
|
/**
|
|
14
18
|
* A ToolRunner handles the automatic conversation loop between the assistant and tools.
|
|
@@ -52,12 +56,17 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
52
56
|
},
|
|
53
57
|
};
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
// structuredClone drops symbol-keyed properties, so collect helper marks
|
|
60
|
+
// from the original params here — the create()-side collector won't see
|
|
61
|
+
// them on the cloned messages.
|
|
62
|
+
const collected = collectStainlessHelpers(params.tools, params.messages);
|
|
58
63
|
this.#options = {
|
|
59
64
|
...options,
|
|
60
|
-
headers: buildHeaders([
|
|
65
|
+
headers: buildHeaders([
|
|
66
|
+
helperHeader('BetaToolRunner'),
|
|
67
|
+
collected.length ? { [STAINLESS_HELPER_HEADER]: collected.join(', ') } : undefined,
|
|
68
|
+
options?.headers,
|
|
69
|
+
]),
|
|
61
70
|
};
|
|
62
71
|
this.#completion = promiseWithResolvers();
|
|
63
72
|
|
|
@@ -137,7 +146,7 @@ export class BetaToolRunner<Stream extends boolean> {
|
|
|
137
146
|
},
|
|
138
147
|
{
|
|
139
148
|
signal: this.#options.signal,
|
|
140
|
-
headers: buildHeaders([this.#options.headers,
|
|
149
|
+
headers: buildHeaders([this.#options.headers, helperHeader('compaction')]),
|
|
141
150
|
},
|
|
142
151
|
);
|
|
143
152
|
|
|
@@ -15,6 +15,7 @@ import { 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';
|
|
18
|
+
import { helperHeader } from '../../internal/stainless-helper-header';
|
|
18
19
|
import type { RequestOptions } from '../../internal/request-options';
|
|
19
20
|
import { runRunnableTool, toolName, type BetaRunnableTool } from './BetaRunnableTool';
|
|
20
21
|
import type { BetaToolRunnerRequestOptions } from './BetaToolRunner';
|
|
@@ -22,9 +23,6 @@ import type { BetaToolRunnerRequestOptions } from './BetaToolRunner';
|
|
|
22
23
|
/** Beta header for the managed-agents API. */
|
|
23
24
|
export const MANAGED_AGENTS_BETA = 'managed-agents-2026-04-01';
|
|
24
25
|
|
|
25
|
-
/** `x-stainless-helper` value identifying this helper in SDK telemetry. */
|
|
26
|
-
const HELPER_NAME = 'SessionToolRunner';
|
|
27
|
-
|
|
28
26
|
const STREAM_BACKOFF_START_MS = 500;
|
|
29
27
|
const STREAM_BACKOFF_CAP_MS = 10_000;
|
|
30
28
|
const TOOL_TIMEOUT_MS = 120_000;
|
|
@@ -287,7 +285,7 @@ export class SessionToolRunner implements AsyncIterable<DispatchedToolCall> {
|
|
|
287
285
|
#requestOptions(): RequestOptions {
|
|
288
286
|
return {
|
|
289
287
|
...this.#requestOpts,
|
|
290
|
-
headers: buildHeaders([
|
|
288
|
+
headers: buildHeaders([helperHeader('session-tool-runner'), this.#requestOpts?.headers]),
|
|
291
289
|
signal: this.#controller.signal,
|
|
292
290
|
};
|
|
293
291
|
}
|
|
@@ -840,7 +840,9 @@ export interface AgentCreateParams {
|
|
|
840
840
|
|
|
841
841
|
/**
|
|
842
842
|
* Body param: MCP servers this agent connects to. Maximum 20. Names must be unique
|
|
843
|
-
* within the array.
|
|
843
|
+
* within the array. Every server must be referenced by an `mcp_toolset` in
|
|
844
|
+
* `tools`; unreferenced servers are rejected. See the
|
|
845
|
+
* [MCP connector guide](https://platform.claude.com/docs/en/managed-agents/mcp-connector).
|
|
844
846
|
*/
|
|
845
847
|
mcp_servers?: Array<BetaManagedAgentsURLMCPServerParams>;
|
|
846
848
|
|
|
@@ -911,7 +913,10 @@ export interface AgentUpdateParams {
|
|
|
911
913
|
|
|
912
914
|
/**
|
|
913
915
|
* Body param: MCP servers. Full replacement. Omit to preserve; send empty array or
|
|
914
|
-
* null to clear. Names must be unique. Maximum 20.
|
|
916
|
+
* `null` to clear. Names must be unique. Maximum 20. Every server must be
|
|
917
|
+
* referenced by an `mcp_toolset` in the agent's resulting `tools`; unreferenced
|
|
918
|
+
* servers are rejected. See the
|
|
919
|
+
* [MCP connector guide](https://platform.claude.com/docs/en/managed-agents/mcp-connector).
|
|
915
920
|
*/
|
|
916
921
|
mcp_servers?: Array<BetaManagedAgentsURLMCPServerParams> | null;
|
|
917
922
|
|
|
@@ -432,6 +432,7 @@ import {
|
|
|
432
432
|
BetaWebFetchTool20250910,
|
|
433
433
|
BetaWebFetchTool20260209,
|
|
434
434
|
BetaWebFetchTool20260309,
|
|
435
|
+
BetaWebFetchTool20260318,
|
|
435
436
|
BetaWebFetchToolResultBlock,
|
|
436
437
|
BetaWebFetchToolResultBlockParam,
|
|
437
438
|
BetaWebFetchToolResultErrorBlock,
|
|
@@ -441,6 +442,7 @@ import {
|
|
|
441
442
|
BetaWebSearchResultBlockParam,
|
|
442
443
|
BetaWebSearchTool20250305,
|
|
443
444
|
BetaWebSearchTool20260209,
|
|
445
|
+
BetaWebSearchTool20260318,
|
|
444
446
|
BetaWebSearchToolRequestError,
|
|
445
447
|
BetaWebSearchToolResultBlock,
|
|
446
448
|
BetaWebSearchToolResultBlockContent,
|
|
@@ -884,6 +886,7 @@ export declare namespace Beta {
|
|
|
884
886
|
type BetaWebFetchTool20250910 as BetaWebFetchTool20250910,
|
|
885
887
|
type BetaWebFetchTool20260209 as BetaWebFetchTool20260209,
|
|
886
888
|
type BetaWebFetchTool20260309 as BetaWebFetchTool20260309,
|
|
889
|
+
type BetaWebFetchTool20260318 as BetaWebFetchTool20260318,
|
|
887
890
|
type BetaWebFetchToolResultBlock as BetaWebFetchToolResultBlock,
|
|
888
891
|
type BetaWebFetchToolResultBlockParam as BetaWebFetchToolResultBlockParam,
|
|
889
892
|
type BetaWebFetchToolResultErrorBlock as BetaWebFetchToolResultErrorBlock,
|
|
@@ -893,6 +896,7 @@ export declare namespace Beta {
|
|
|
893
896
|
type BetaWebSearchResultBlockParam as BetaWebSearchResultBlockParam,
|
|
894
897
|
type BetaWebSearchTool20250305 as BetaWebSearchTool20250305,
|
|
895
898
|
type BetaWebSearchTool20260209 as BetaWebSearchTool20260209,
|
|
899
|
+
type BetaWebSearchTool20260318 as BetaWebSearchTool20260318,
|
|
896
900
|
type BetaWebSearchToolRequestError as BetaWebSearchToolRequestError,
|
|
897
901
|
type BetaWebSearchToolResultBlock as BetaWebSearchToolResultBlock,
|
|
898
902
|
type BetaWebSearchToolResultBlockContent as BetaWebSearchToolResultBlockContent,
|
|
@@ -55,7 +55,9 @@ export class Deployments extends APIResource {
|
|
|
55
55
|
* @example
|
|
56
56
|
* ```ts
|
|
57
57
|
* const betaManagedAgentsDeployment =
|
|
58
|
-
* await client.beta.deployments.retrieve(
|
|
58
|
+
* await client.beta.deployments.retrieve(
|
|
59
|
+
* 'depl_011CZkZcDH3vPqd7xnEfwTai',
|
|
60
|
+
* );
|
|
59
61
|
* ```
|
|
60
62
|
*/
|
|
61
63
|
retrieve(
|
|
@@ -79,7 +81,9 @@ export class Deployments extends APIResource {
|
|
|
79
81
|
* @example
|
|
80
82
|
* ```ts
|
|
81
83
|
* const betaManagedAgentsDeployment =
|
|
82
|
-
* await client.beta.deployments.update(
|
|
84
|
+
* await client.beta.deployments.update(
|
|
85
|
+
* 'depl_011CZkZcDH3vPqd7xnEfwTai',
|
|
86
|
+
* );
|
|
83
87
|
* ```
|
|
84
88
|
*/
|
|
85
89
|
update(
|
|
@@ -130,7 +134,9 @@ export class Deployments extends APIResource {
|
|
|
130
134
|
* @example
|
|
131
135
|
* ```ts
|
|
132
136
|
* const betaManagedAgentsDeployment =
|
|
133
|
-
* await client.beta.deployments.archive(
|
|
137
|
+
* await client.beta.deployments.archive(
|
|
138
|
+
* 'depl_011CZkZcDH3vPqd7xnEfwTai',
|
|
139
|
+
* );
|
|
134
140
|
* ```
|
|
135
141
|
*/
|
|
136
142
|
archive(
|
|
@@ -154,7 +160,9 @@ export class Deployments extends APIResource {
|
|
|
154
160
|
* @example
|
|
155
161
|
* ```ts
|
|
156
162
|
* const betaManagedAgentsDeployment =
|
|
157
|
-
* await client.beta.deployments.pause(
|
|
163
|
+
* await client.beta.deployments.pause(
|
|
164
|
+
* 'depl_011CZkZcDH3vPqd7xnEfwTai',
|
|
165
|
+
* );
|
|
158
166
|
* ```
|
|
159
167
|
*/
|
|
160
168
|
pause(
|
|
@@ -178,7 +186,9 @@ export class Deployments extends APIResource {
|
|
|
178
186
|
* @example
|
|
179
187
|
* ```ts
|
|
180
188
|
* const betaManagedAgentsDeploymentRun =
|
|
181
|
-
* await client.beta.deployments.run(
|
|
189
|
+
* await client.beta.deployments.run(
|
|
190
|
+
* 'depl_011CZkZcDH3vPqd7xnEfwTai',
|
|
191
|
+
* );
|
|
182
192
|
* ```
|
|
183
193
|
*/
|
|
184
194
|
run(
|
|
@@ -202,7 +212,9 @@ export class Deployments extends APIResource {
|
|
|
202
212
|
* @example
|
|
203
213
|
* ```ts
|
|
204
214
|
* const betaManagedAgentsDeployment =
|
|
205
|
-
* await client.beta.deployments.unpause(
|
|
215
|
+
* await client.beta.deployments.unpause(
|
|
216
|
+
* 'depl_011CZkZcDH3vPqd7xnEfwTai',
|
|
217
|
+
* );
|
|
206
218
|
* ```
|
|
207
219
|
*/
|
|
208
220
|
unpause(
|
|
@@ -7,7 +7,7 @@ import { Page, type PageParams, PagePromise } from '../../core/pagination';
|
|
|
7
7
|
import { type Uploadable } from '../../core/uploads';
|
|
8
8
|
import { buildHeaders } from '../../internal/headers';
|
|
9
9
|
import { RequestOptions } from '../../internal/request-options';
|
|
10
|
-
import { stainlessHelperHeaderFromFile } from '../../
|
|
10
|
+
import { stainlessHelperHeaderFromFile } from '../../internal/stainless-helper-header';
|
|
11
11
|
import { multipartFormRequestOptions } from '../../internal/uploads';
|
|
12
12
|
import { path } from '../../internal/utils/path';
|
|
13
13
|
|
|
@@ -393,6 +393,7 @@ export {
|
|
|
393
393
|
type BetaWebFetchTool20250910,
|
|
394
394
|
type BetaWebFetchTool20260209,
|
|
395
395
|
type BetaWebFetchTool20260309,
|
|
396
|
+
type BetaWebFetchTool20260318,
|
|
396
397
|
type BetaWebFetchToolResultBlock,
|
|
397
398
|
type BetaWebFetchToolResultBlockParam,
|
|
398
399
|
type BetaWebFetchToolResultErrorBlock,
|
|
@@ -402,6 +403,7 @@ export {
|
|
|
402
403
|
type BetaWebSearchResultBlockParam,
|
|
403
404
|
type BetaWebSearchTool20250305,
|
|
404
405
|
type BetaWebSearchTool20260209,
|
|
406
|
+
type BetaWebSearchTool20260318,
|
|
405
407
|
type BetaWebSearchToolRequestError,
|
|
406
408
|
type BetaWebSearchToolResultBlock,
|
|
407
409
|
type BetaWebSearchToolResultBlockContent,
|
|
@@ -21,7 +21,7 @@ export class Batches extends APIResource {
|
|
|
21
21
|
* can take up to 24 hours to complete.
|
|
22
22
|
*
|
|
23
23
|
* Learn more about the Message Batches API in our
|
|
24
|
-
* [user guide](https://
|
|
24
|
+
* [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```ts
|
|
@@ -43,12 +43,15 @@ export class Batches extends APIResource {
|
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
create(params: BatchCreateParams, options?: RequestOptions): APIPromise<BetaMessageBatch> {
|
|
46
|
-
const { betas, ...body } = params;
|
|
46
|
+
const { betas, user_profile_id, ...body } = params;
|
|
47
47
|
return this._client.post('/v1/messages/batches?beta=true', {
|
|
48
48
|
body,
|
|
49
49
|
...options,
|
|
50
50
|
headers: buildHeaders([
|
|
51
|
-
{
|
|
51
|
+
{
|
|
52
|
+
'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString(),
|
|
53
|
+
...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
|
|
54
|
+
},
|
|
52
55
|
options?.headers,
|
|
53
56
|
]),
|
|
54
57
|
});
|
|
@@ -60,7 +63,7 @@ export class Batches extends APIResource {
|
|
|
60
63
|
* `results_url` field in the response.
|
|
61
64
|
*
|
|
62
65
|
* Learn more about the Message Batches API in our
|
|
63
|
-
* [user guide](https://
|
|
66
|
+
* [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
|
|
64
67
|
*
|
|
65
68
|
* @example
|
|
66
69
|
* ```ts
|
|
@@ -90,7 +93,7 @@ export class Batches extends APIResource {
|
|
|
90
93
|
* returned first.
|
|
91
94
|
*
|
|
92
95
|
* Learn more about the Message Batches API in our
|
|
93
|
-
* [user guide](https://
|
|
96
|
+
* [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
|
|
94
97
|
*
|
|
95
98
|
* @example
|
|
96
99
|
* ```ts
|
|
@@ -122,7 +125,7 @@ export class Batches extends APIResource {
|
|
|
122
125
|
* like to delete an in-progress batch, you must first cancel it.
|
|
123
126
|
*
|
|
124
127
|
* Learn more about the Message Batches API in our
|
|
125
|
-
* [user guide](https://
|
|
128
|
+
* [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
|
|
126
129
|
*
|
|
127
130
|
* @example
|
|
128
131
|
* ```ts
|
|
@@ -159,7 +162,7 @@ export class Batches extends APIResource {
|
|
|
159
162
|
* non-interruptible.
|
|
160
163
|
*
|
|
161
164
|
* Learn more about the Message Batches API in our
|
|
162
|
-
* [user guide](https://
|
|
165
|
+
* [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
|
|
163
166
|
*
|
|
164
167
|
* @example
|
|
165
168
|
* ```ts
|
|
@@ -192,7 +195,7 @@ export class Batches extends APIResource {
|
|
|
192
195
|
* requests. Use the `custom_id` field to match results to requests.
|
|
193
196
|
*
|
|
194
197
|
* Learn more about the Message Batches API in our
|
|
195
|
-
* [user guide](https://
|
|
198
|
+
* [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
|
|
196
199
|
*
|
|
197
200
|
* @example
|
|
198
201
|
* ```ts
|
|
@@ -424,6 +427,15 @@ export interface BatchCreateParams {
|
|
|
424
427
|
* Header param: Optional header to specify the beta version(s) you want to use.
|
|
425
428
|
*/
|
|
426
429
|
betas?: Array<BetaAPI.AnthropicBeta>;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Header param: The user profile ID to attribute the requests in this batch to.
|
|
433
|
+
* Use when acting on behalf of a party other than your organization. Requires the
|
|
434
|
+
* `user-profiles` beta header. Applies to every request in the batch; an
|
|
435
|
+
* individual request whose `user_profile_id` body field conflicts with this header
|
|
436
|
+
* is errored.
|
|
437
|
+
*/
|
|
438
|
+
user_profile_id?: string;
|
|
427
439
|
}
|
|
428
440
|
|
|
429
441
|
export namespace BatchCreateParams {
|
|
@@ -439,7 +451,8 @@ export namespace BatchCreateParams {
|
|
|
439
451
|
/**
|
|
440
452
|
* Messages API creation parameters for the individual request.
|
|
441
453
|
*
|
|
442
|
-
* See the
|
|
454
|
+
* See the
|
|
455
|
+
* [Messages API reference](https://platform.claude.com/docs/en/api/messages) for
|
|
443
456
|
* full documentation on available parameters.
|
|
444
457
|
*/
|
|
445
458
|
params: Request.Params;
|
|
@@ -449,7 +462,8 @@ export namespace BatchCreateParams {
|
|
|
449
462
|
/**
|
|
450
463
|
* Messages API creation parameters for the individual request.
|
|
451
464
|
*
|
|
452
|
-
* See the
|
|
465
|
+
* See the
|
|
466
|
+
* [Messages API reference](https://platform.claude.com/docs/en/api/messages) for
|
|
453
467
|
* full documentation on available parameters.
|
|
454
468
|
*/
|
|
455
469
|
export interface Params {
|
|
@@ -460,11 +474,12 @@ export namespace BatchCreateParams {
|
|
|
460
474
|
* only specifies the absolute maximum number of tokens to generate.
|
|
461
475
|
*
|
|
462
476
|
* Set to `0` to populate the
|
|
463
|
-
* [prompt cache](https://
|
|
477
|
+
* [prompt cache](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pre-warming-the-cache)
|
|
464
478
|
* without generating a response.
|
|
465
479
|
*
|
|
466
480
|
* Different models have different maximum values for this parameter. See
|
|
467
|
-
* [models](https://
|
|
481
|
+
* [models](https://platform.claude.com/docs/en/about-claude/models/overview) for
|
|
482
|
+
* details.
|
|
468
483
|
*/
|
|
469
484
|
max_tokens: number;
|
|
470
485
|
|
|
@@ -526,12 +541,13 @@ export namespace BatchCreateParams {
|
|
|
526
541
|
* { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
|
527
542
|
* ```
|
|
528
543
|
*
|
|
529
|
-
* See
|
|
544
|
+
* See
|
|
545
|
+
* [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages).
|
|
530
546
|
*
|
|
531
547
|
* Note that if you want to include a
|
|
532
|
-
* [system prompt](https://
|
|
533
|
-
* top-level `system` parameter — there is no `"system"` role for
|
|
534
|
-
* the Messages API.
|
|
548
|
+
* [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role),
|
|
549
|
+
* you can use the top-level `system` parameter — there is no `"system"` role for
|
|
550
|
+
* input messages in the Messages API.
|
|
535
551
|
*
|
|
536
552
|
* There is a limit of 100,000 messages in a single request.
|
|
537
553
|
*/
|
|
@@ -635,7 +651,8 @@ export namespace BatchCreateParams {
|
|
|
635
651
|
* for this request.
|
|
636
652
|
*
|
|
637
653
|
* Anthropic offers different levels of service for your API requests. See
|
|
638
|
-
* [service-tiers](https://
|
|
654
|
+
* [service-tiers](https://platform.claude.com/docs/en/api/service-tiers) for
|
|
655
|
+
* details.
|
|
639
656
|
*/
|
|
640
657
|
service_tier?: 'auto' | 'standard_only';
|
|
641
658
|
|
|
@@ -661,7 +678,8 @@ export namespace BatchCreateParams {
|
|
|
661
678
|
/**
|
|
662
679
|
* Whether to incrementally stream the response using server-sent events.
|
|
663
680
|
*
|
|
664
|
-
* See [streaming](https://
|
|
681
|
+
* See [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming)
|
|
682
|
+
* for details.
|
|
665
683
|
*/
|
|
666
684
|
stream?: boolean;
|
|
667
685
|
|
|
@@ -670,7 +688,7 @@ export namespace BatchCreateParams {
|
|
|
670
688
|
*
|
|
671
689
|
* A system prompt is a way of providing context and instructions to Claude, such
|
|
672
690
|
* as specifying a particular goal or role. See our
|
|
673
|
-
* [guide to system prompts](https://
|
|
691
|
+
* [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).
|
|
674
692
|
*/
|
|
675
693
|
system?: string | Array<BetaMessagesAPI.BetaTextBlockParam>;
|
|
676
694
|
|
|
@@ -689,7 +707,7 @@ export namespace BatchCreateParams {
|
|
|
689
707
|
* tokens and counts towards your `max_tokens` limit.
|
|
690
708
|
*
|
|
691
709
|
* See
|
|
692
|
-
* [extended thinking](https://
|
|
710
|
+
* [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking)
|
|
693
711
|
* for details.
|
|
694
712
|
*/
|
|
695
713
|
thinking?: BetaMessagesAPI.BetaThinkingConfigParam;
|
|
@@ -710,9 +728,9 @@ export namespace BatchCreateParams {
|
|
|
710
728
|
*
|
|
711
729
|
* There are two types of tools: **client tools** and **server tools**. The
|
|
712
730
|
* behavior described below applies to client tools. For
|
|
713
|
-
* [server tools](https://
|
|
731
|
+
* [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools),
|
|
714
732
|
* see their individual documentation as each has its own behavior (e.g., the
|
|
715
|
-
* [web search tool](https://
|
|
733
|
+
* [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)).
|
|
716
734
|
*
|
|
717
735
|
* Each tool definition includes:
|
|
718
736
|
*
|
|
@@ -775,7 +793,9 @@ export namespace BatchCreateParams {
|
|
|
775
793
|
* functions, or more generally whenever you want the model to produce a particular
|
|
776
794
|
* JSON structure of output.
|
|
777
795
|
*
|
|
778
|
-
* See our
|
|
796
|
+
* See our
|
|
797
|
+
* [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview)
|
|
798
|
+
* for more details.
|
|
779
799
|
*/
|
|
780
800
|
tools?: Array<BetaMessagesAPI.BetaToolUnion>;
|
|
781
801
|
|
|
@@ -791,12 +811,6 @@ export namespace BatchCreateParams {
|
|
|
791
811
|
* other values will be rejected with a 400 error.
|
|
792
812
|
*/
|
|
793
813
|
top_p?: number;
|
|
794
|
-
|
|
795
|
-
/**
|
|
796
|
-
* The user profile ID to attribute this request to. Use when acting on behalf of a
|
|
797
|
-
* party other than your organization.
|
|
798
|
-
*/
|
|
799
|
-
user_profile_id?: string | null;
|
|
800
814
|
}
|
|
801
815
|
}
|
|
802
816
|
}
|
|
@@ -222,6 +222,7 @@ export {
|
|
|
222
222
|
type BetaWebFetchTool20250910,
|
|
223
223
|
type BetaWebFetchTool20260209,
|
|
224
224
|
type BetaWebFetchTool20260309,
|
|
225
|
+
type BetaWebFetchTool20260318,
|
|
225
226
|
type BetaWebFetchToolResultBlock,
|
|
226
227
|
type BetaWebFetchToolResultBlockParam,
|
|
227
228
|
type BetaWebFetchToolResultErrorBlock,
|
|
@@ -231,6 +232,7 @@ export {
|
|
|
231
232
|
type BetaWebSearchResultBlockParam,
|
|
232
233
|
type BetaWebSearchTool20250305,
|
|
233
234
|
type BetaWebSearchTool20260209,
|
|
235
|
+
type BetaWebSearchTool20260318,
|
|
234
236
|
type BetaWebSearchToolRequestError,
|
|
235
237
|
type BetaWebSearchToolResultBlock,
|
|
236
238
|
type BetaWebSearchToolResultBlockContent,
|