@effect/ai-anthropic 4.0.0-beta.8 → 4.0.0-beta.81
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/dist/AnthropicClient.d.ts +93 -74
- package/dist/AnthropicClient.d.ts.map +1 -1
- package/dist/AnthropicClient.js +51 -19
- package/dist/AnthropicClient.js.map +1 -1
- package/dist/AnthropicConfig.d.ts +55 -10
- package/dist/AnthropicConfig.d.ts.map +1 -1
- package/dist/AnthropicConfig.js +30 -7
- package/dist/AnthropicConfig.js.map +1 -1
- package/dist/AnthropicError.d.ts +136 -37
- package/dist/AnthropicError.d.ts.map +1 -1
- package/dist/AnthropicError.js +1 -1
- package/dist/AnthropicLanguageModel.d.ts +362 -52
- package/dist/AnthropicLanguageModel.d.ts.map +1 -1
- package/dist/AnthropicLanguageModel.js +88 -21
- package/dist/AnthropicLanguageModel.js.map +1 -1
- package/dist/AnthropicTelemetry.d.ts +43 -16
- package/dist/AnthropicTelemetry.d.ts.map +1 -1
- package/dist/AnthropicTelemetry.js +15 -9
- package/dist/AnthropicTelemetry.js.map +1 -1
- package/dist/AnthropicTool.d.ts +1223 -289
- package/dist/AnthropicTool.d.ts.map +1 -1
- package/dist/AnthropicTool.js +859 -201
- package/dist/AnthropicTool.js.map +1 -1
- package/dist/Generated.d.ts +1 -1
- package/dist/Generated.js +1 -1
- package/dist/index.d.ts +8 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -29
- package/dist/index.js.map +1 -1
- package/dist/internal/errors.js +7 -7
- package/dist/internal/errors.js.map +1 -1
- package/package.json +3 -3
- package/src/AnthropicClient.ts +114 -104
- package/src/AnthropicConfig.ts +56 -11
- package/src/AnthropicError.ts +138 -37
- package/src/AnthropicLanguageModel.ts +395 -43
- package/src/AnthropicTelemetry.ts +48 -22
- package/src/AnthropicTool.ts +1216 -282
- package/src/Generated.ts +1 -1
- package/src/index.ts +8 -29
- package/src/internal/errors.ts +9 -7
|
@@ -1,27 +1,33 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
1
2
|
import * as Effect from "effect/Effect";
|
|
2
3
|
import * as Layer from "effect/Layer";
|
|
3
4
|
import * as Schema from "effect/Schema";
|
|
4
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
5
5
|
import * as LanguageModel from "effect/unstable/ai/LanguageModel";
|
|
6
6
|
import * as AiModel from "effect/unstable/ai/Model";
|
|
7
7
|
import { AnthropicClient } from "./AnthropicClient.ts";
|
|
8
8
|
import type * as Generated from "./Generated.ts";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Known Anthropic Claude model identifiers exposed by the generated Anthropic schema.
|
|
11
|
+
*
|
|
12
|
+
* **Details**
|
|
13
|
+
*
|
|
14
|
+
* The Anthropic language model constructors accept `Model` values and custom
|
|
15
|
+
* string model ids, so this type is best used for autocomplete and type checking
|
|
16
|
+
* of known Claude ids.
|
|
11
17
|
*
|
|
12
|
-
* @since 1.0.0
|
|
13
18
|
* @category models
|
|
19
|
+
* @since 4.0.0
|
|
14
20
|
*/
|
|
15
21
|
export type Model = typeof Generated.Model.Type;
|
|
16
|
-
declare const Config_base:
|
|
22
|
+
declare const Config_base: Context.ServiceClass<Config, "@effect/ai-anthropic/AnthropicLanguageModel/Config", {
|
|
17
23
|
readonly model?: "claude-opus-4-6" | "claude-sonnet-4-6" | "claude-opus-4-5-20251101" | "claude-opus-4-5" | "claude-3-7-sonnet-latest" | "claude-3-7-sonnet-20250219" | "claude-3-5-haiku-latest" | "claude-3-5-haiku-20241022" | "claude-haiku-4-5" | "claude-haiku-4-5-20251001" | "claude-sonnet-4-20250514" | "claude-sonnet-4-0" | "claude-4-sonnet-20250514" | "claude-sonnet-4-5" | "claude-sonnet-4-5-20250929" | "claude-opus-4-0" | "claude-opus-4-20250514" | "claude-4-opus-20250514" | "claude-opus-4-1-20250805" | "claude-3-opus-latest" | "claude-3-opus-20240229" | "claude-3-haiku-20240307";
|
|
18
24
|
readonly thinking?: {
|
|
19
25
|
readonly type: "adaptive";
|
|
20
26
|
} | {
|
|
21
27
|
readonly type: "disabled";
|
|
22
28
|
} | {
|
|
23
|
-
readonly type: "enabled";
|
|
24
29
|
readonly budget_tokens: number;
|
|
30
|
+
readonly type: "enabled";
|
|
25
31
|
};
|
|
26
32
|
readonly max_tokens?: number;
|
|
27
33
|
readonly cache_control?: {
|
|
@@ -47,30 +53,30 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-anthropic
|
|
|
47
53
|
};
|
|
48
54
|
} | {
|
|
49
55
|
readonly type: "clear_tool_uses_20250919";
|
|
50
|
-
readonly
|
|
56
|
+
readonly clear_at_least?: {
|
|
51
57
|
readonly type: "input_tokens";
|
|
52
58
|
readonly value: number;
|
|
53
|
-
} |
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
59
|
+
} | null;
|
|
60
|
+
readonly clear_tool_inputs?: boolean | readonly string[] | null;
|
|
61
|
+
readonly exclude_tools?: readonly string[] | null;
|
|
57
62
|
readonly keep?: {
|
|
58
63
|
readonly type: "tool_uses";
|
|
59
64
|
readonly value: number;
|
|
60
65
|
};
|
|
61
|
-
readonly
|
|
66
|
+
readonly trigger?: {
|
|
62
67
|
readonly type: "input_tokens";
|
|
63
68
|
readonly value: number;
|
|
64
|
-
} |
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
} | {
|
|
70
|
+
readonly type: "tool_uses";
|
|
71
|
+
readonly value: number;
|
|
72
|
+
};
|
|
67
73
|
})[];
|
|
68
74
|
} | null;
|
|
69
75
|
readonly container?: string | {
|
|
70
76
|
readonly id?: string | null;
|
|
71
77
|
readonly skills?: readonly {
|
|
72
|
-
readonly type: "anthropic" | "custom";
|
|
73
78
|
readonly skill_id: string;
|
|
79
|
+
readonly type: "anthropic" | "custom";
|
|
74
80
|
readonly version?: string;
|
|
75
81
|
}[] | null;
|
|
76
82
|
} | null;
|
|
@@ -85,63 +91,63 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-anthropic
|
|
|
85
91
|
readonly inference_geo?: string | null;
|
|
86
92
|
readonly service_tier?: "auto" | "standard_only";
|
|
87
93
|
readonly mcp_servers?: readonly {
|
|
88
|
-
readonly type: "url";
|
|
89
94
|
readonly name: string;
|
|
95
|
+
readonly type: "url";
|
|
90
96
|
readonly url: string;
|
|
91
97
|
readonly authorization_token?: string | null;
|
|
92
98
|
readonly tool_configuration?: {
|
|
93
|
-
readonly enabled?: boolean | null;
|
|
94
99
|
readonly allowed_tools?: readonly string[] | null;
|
|
100
|
+
readonly enabled?: boolean | null;
|
|
95
101
|
} | null;
|
|
96
102
|
}[];
|
|
97
103
|
readonly output_format?: {
|
|
98
|
-
readonly type: "json_schema";
|
|
99
104
|
readonly schema: {
|
|
100
105
|
readonly [x: string]: Schema.Json;
|
|
101
106
|
};
|
|
107
|
+
readonly type: "json_schema";
|
|
102
108
|
} | null;
|
|
103
109
|
readonly system?: string | readonly {
|
|
104
|
-
readonly type: "text";
|
|
105
110
|
readonly text: string;
|
|
111
|
+
readonly type: "text";
|
|
106
112
|
readonly cache_control?: {
|
|
107
113
|
readonly type: "ephemeral";
|
|
108
114
|
readonly ttl?: "5m" | "1h";
|
|
109
115
|
} | null;
|
|
110
116
|
readonly citations?: readonly ({
|
|
111
|
-
readonly type: "char_location";
|
|
112
117
|
readonly cited_text: string;
|
|
113
118
|
readonly document_index: number;
|
|
114
119
|
readonly document_title: string | null;
|
|
115
120
|
readonly end_char_index: number;
|
|
116
121
|
readonly start_char_index: number;
|
|
122
|
+
readonly type: "char_location";
|
|
117
123
|
} | {
|
|
118
|
-
readonly type: "content_block_location";
|
|
119
124
|
readonly cited_text: string;
|
|
120
125
|
readonly document_index: number;
|
|
121
126
|
readonly document_title: string | null;
|
|
122
127
|
readonly end_block_index: number;
|
|
123
128
|
readonly start_block_index: number;
|
|
129
|
+
readonly type: "content_block_location";
|
|
124
130
|
} | {
|
|
125
|
-
readonly type: "page_location";
|
|
126
131
|
readonly cited_text: string;
|
|
127
132
|
readonly document_index: number;
|
|
128
133
|
readonly document_title: string | null;
|
|
129
134
|
readonly end_page_number: number;
|
|
130
135
|
readonly start_page_number: number;
|
|
136
|
+
readonly type: "page_location";
|
|
131
137
|
} | {
|
|
132
|
-
readonly title: string | null;
|
|
133
|
-
readonly type: "search_result_location";
|
|
134
|
-
readonly source: string;
|
|
135
138
|
readonly cited_text: string;
|
|
136
139
|
readonly end_block_index: number;
|
|
137
|
-
readonly start_block_index: number;
|
|
138
140
|
readonly search_result_index: number;
|
|
141
|
+
readonly source: string;
|
|
142
|
+
readonly start_block_index: number;
|
|
143
|
+
readonly title: string | null;
|
|
144
|
+
readonly type: "search_result_location";
|
|
139
145
|
} | {
|
|
146
|
+
readonly cited_text: string;
|
|
147
|
+
readonly encrypted_index: string;
|
|
140
148
|
readonly title: string | null;
|
|
141
149
|
readonly type: "web_search_result_location";
|
|
142
|
-
readonly cited_text: string;
|
|
143
150
|
readonly url: string;
|
|
144
|
-
readonly encrypted_index: string;
|
|
145
151
|
})[] | null;
|
|
146
152
|
}[];
|
|
147
153
|
readonly output_config?: {
|
|
@@ -151,6 +157,8 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-anthropic
|
|
|
151
157
|
/**
|
|
152
158
|
* Whether to use strict JSON schema validation for tool calls.
|
|
153
159
|
*
|
|
160
|
+
* **Details**
|
|
161
|
+
*
|
|
154
162
|
* Only applies to models that support structured outputs. Defaults to
|
|
155
163
|
* `true` when structured outputs are supported.
|
|
156
164
|
*/
|
|
@@ -158,17 +166,36 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-anthropic
|
|
|
158
166
|
readonly strictJsonSchema?: boolean | undefined | undefined;
|
|
159
167
|
}>;
|
|
160
168
|
/**
|
|
161
|
-
*
|
|
169
|
+
* Context service for Anthropic language model configuration.
|
|
170
|
+
*
|
|
171
|
+
* **When to use**
|
|
172
|
+
*
|
|
173
|
+
* Use when you need scoped Anthropic model request defaults or per-operation
|
|
174
|
+
* overrides from Effect context.
|
|
162
175
|
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
176
|
+
* **Details**
|
|
177
|
+
*
|
|
178
|
+
* The service stores request fields that are merged into Anthropic Messages API
|
|
179
|
+
* requests. Scoped configuration overrides defaults supplied to `model`,
|
|
180
|
+
* `make`, or `layer`.
|
|
165
181
|
*
|
|
166
|
-
* @since 1.0.0
|
|
167
182
|
* @category configuration
|
|
183
|
+
* @since 4.0.0
|
|
168
184
|
*/
|
|
169
185
|
export declare class Config extends Config_base {
|
|
170
186
|
}
|
|
171
187
|
declare module "effect/unstable/ai/Prompt" {
|
|
188
|
+
/**
|
|
189
|
+
* Anthropic-specific options for system messages.
|
|
190
|
+
*
|
|
191
|
+
* **Details**
|
|
192
|
+
*
|
|
193
|
+
* These options are used when translating system messages into Anthropic
|
|
194
|
+
* request content.
|
|
195
|
+
*
|
|
196
|
+
* @category request
|
|
197
|
+
* @since 4.0.0
|
|
198
|
+
*/
|
|
172
199
|
interface SystemMessageOptions extends ProviderOptions {
|
|
173
200
|
readonly anthropic?: {
|
|
174
201
|
/**
|
|
@@ -177,6 +204,17 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
177
204
|
readonly cacheControl?: typeof Generated.CacheControlEphemeral.Encoded | null;
|
|
178
205
|
} | null;
|
|
179
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Anthropic-specific options for user messages.
|
|
209
|
+
*
|
|
210
|
+
* **Details**
|
|
211
|
+
*
|
|
212
|
+
* These options are used when translating user messages into Anthropic
|
|
213
|
+
* request content.
|
|
214
|
+
*
|
|
215
|
+
* @category request
|
|
216
|
+
* @since 4.0.0
|
|
217
|
+
*/
|
|
180
218
|
interface UserMessageOptions extends ProviderOptions {
|
|
181
219
|
readonly anthropic?: {
|
|
182
220
|
/**
|
|
@@ -185,6 +223,17 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
185
223
|
readonly cacheControl?: typeof Generated.CacheControlEphemeral.Encoded | null;
|
|
186
224
|
} | null;
|
|
187
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Anthropic-specific options for assistant messages.
|
|
228
|
+
*
|
|
229
|
+
* **Details**
|
|
230
|
+
*
|
|
231
|
+
* These options are used when replaying assistant messages in Anthropic
|
|
232
|
+
* conversation history.
|
|
233
|
+
*
|
|
234
|
+
* @category request
|
|
235
|
+
* @since 4.0.0
|
|
236
|
+
*/
|
|
188
237
|
interface AssistantMessageOptions extends ProviderOptions {
|
|
189
238
|
readonly anthropic?: {
|
|
190
239
|
/**
|
|
@@ -193,6 +242,17 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
193
242
|
readonly cacheControl?: typeof Generated.CacheControlEphemeral.Encoded | null;
|
|
194
243
|
} | null;
|
|
195
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Anthropic-specific options for tool messages.
|
|
247
|
+
*
|
|
248
|
+
* **Details**
|
|
249
|
+
*
|
|
250
|
+
* These options are used when converting tool results into Anthropic user
|
|
251
|
+
* content blocks.
|
|
252
|
+
*
|
|
253
|
+
* @category request
|
|
254
|
+
* @since 4.0.0
|
|
255
|
+
*/
|
|
196
256
|
interface ToolMessageOptions extends ProviderOptions {
|
|
197
257
|
readonly anthropic?: {
|
|
198
258
|
/**
|
|
@@ -201,6 +261,16 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
201
261
|
readonly cacheControl?: typeof Generated.CacheControlEphemeral.Encoded | null;
|
|
202
262
|
} | null;
|
|
203
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Anthropic-specific options for text prompt parts.
|
|
266
|
+
*
|
|
267
|
+
* **When to use**
|
|
268
|
+
*
|
|
269
|
+
* Use when you use these options to control how text blocks are sent to Anthropic.
|
|
270
|
+
*
|
|
271
|
+
* @category request
|
|
272
|
+
* @since 4.0.0
|
|
273
|
+
*/
|
|
204
274
|
interface TextPartOptions extends ProviderOptions {
|
|
205
275
|
readonly anthropic?: {
|
|
206
276
|
/**
|
|
@@ -209,6 +279,17 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
209
279
|
readonly cacheControl?: typeof Generated.CacheControlEphemeral.Encoded | null;
|
|
210
280
|
} | null;
|
|
211
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Anthropic-specific options for reasoning prompt parts.
|
|
284
|
+
*
|
|
285
|
+
* **Details**
|
|
286
|
+
*
|
|
287
|
+
* Preserves Claude thinking metadata when reasoning content is sent back to
|
|
288
|
+
* Anthropic in later turns.
|
|
289
|
+
*
|
|
290
|
+
* @category request
|
|
291
|
+
* @since 4.0.0
|
|
292
|
+
*/
|
|
212
293
|
interface ReasoningPartOptions extends ProviderOptions {
|
|
213
294
|
readonly anthropic?: {
|
|
214
295
|
readonly info?: {
|
|
@@ -232,6 +313,17 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
232
313
|
readonly cacheControl?: typeof Generated.CacheControlEphemeral.Encoded | null;
|
|
233
314
|
} | null;
|
|
234
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Anthropic-specific options for file prompt parts.
|
|
318
|
+
*
|
|
319
|
+
* **Details**
|
|
320
|
+
*
|
|
321
|
+
* Controls document metadata, citations, and prompt caching for files sent to
|
|
322
|
+
* Anthropic.
|
|
323
|
+
*
|
|
324
|
+
* @category request
|
|
325
|
+
* @since 4.0.0
|
|
326
|
+
*/
|
|
235
327
|
interface FilePartOptions extends ProviderOptions {
|
|
236
328
|
readonly anthropic?: {
|
|
237
329
|
/**
|
|
@@ -251,11 +343,24 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
251
343
|
* Additional context about the document that will be forwarded to the
|
|
252
344
|
* large language model, but will not be used towards cited content.
|
|
253
345
|
*
|
|
254
|
-
*
|
|
346
|
+
* **When to use**
|
|
347
|
+
*
|
|
348
|
+
* Use when storing additional document metadata as text or stringified JSON.
|
|
255
349
|
*/
|
|
256
350
|
readonly documentContext?: string | null;
|
|
257
351
|
} | null;
|
|
258
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Anthropic-specific options for tool call prompt parts.
|
|
355
|
+
*
|
|
356
|
+
* **Details**
|
|
357
|
+
*
|
|
358
|
+
* Carries Anthropic tool caller metadata, MCP metadata, and cache control for
|
|
359
|
+
* tool use blocks.
|
|
360
|
+
*
|
|
361
|
+
* @category request
|
|
362
|
+
* @since 4.0.0
|
|
363
|
+
*/
|
|
259
364
|
interface ToolCallPartOptions extends ProviderOptions {
|
|
260
365
|
readonly anthropic?: {
|
|
261
366
|
readonly caller?: {
|
|
@@ -277,6 +382,16 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
277
382
|
readonly cacheControl?: typeof Generated.CacheControlEphemeral.Encoded | null;
|
|
278
383
|
} | null;
|
|
279
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Anthropic-specific options for tool result prompt parts.
|
|
387
|
+
*
|
|
388
|
+
* **Details**
|
|
389
|
+
*
|
|
390
|
+
* Controls Anthropic prompt caching for tool result content.
|
|
391
|
+
*
|
|
392
|
+
* @category request
|
|
393
|
+
* @since 4.0.0
|
|
394
|
+
*/
|
|
280
395
|
interface ToolResultPartOptions extends ProviderOptions {
|
|
281
396
|
readonly anthropic?: {
|
|
282
397
|
/**
|
|
@@ -285,6 +400,16 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
285
400
|
readonly cacheControl?: typeof Generated.CacheControlEphemeral.Encoded | null;
|
|
286
401
|
} | null;
|
|
287
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Anthropic-specific options for tool approval request prompt parts.
|
|
405
|
+
*
|
|
406
|
+
* **Details**
|
|
407
|
+
*
|
|
408
|
+
* Controls prompt caching for human approval requests in conversations.
|
|
409
|
+
*
|
|
410
|
+
* @category request
|
|
411
|
+
* @since 4.0.0
|
|
412
|
+
*/
|
|
288
413
|
interface ToolApprovalRequestPartOptions extends ProviderOptions {
|
|
289
414
|
readonly anthropic?: {
|
|
290
415
|
/**
|
|
@@ -293,14 +418,16 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
293
418
|
readonly cacheControl?: typeof Generated.CacheControlEphemeral.Encoded | null;
|
|
294
419
|
} | null;
|
|
295
420
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
421
|
+
/**
|
|
422
|
+
* Anthropic-specific options for tool approval response prompt parts.
|
|
423
|
+
*
|
|
424
|
+
* **Details**
|
|
425
|
+
*
|
|
426
|
+
* Controls prompt caching for human approval responses in conversations.
|
|
427
|
+
*
|
|
428
|
+
* @category request
|
|
429
|
+
* @since 4.0.0
|
|
430
|
+
*/
|
|
304
431
|
interface ToolApprovalResponsePartOptions extends ProviderOptions {
|
|
305
432
|
readonly anthropic?: {
|
|
306
433
|
/**
|
|
@@ -311,6 +438,17 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
311
438
|
}
|
|
312
439
|
}
|
|
313
440
|
declare module "effect/unstable/ai/Response" {
|
|
441
|
+
/**
|
|
442
|
+
* Anthropic metadata attached when a reasoning block begins.
|
|
443
|
+
*
|
|
444
|
+
* **Details**
|
|
445
|
+
*
|
|
446
|
+
* Includes Claude thinking metadata needed to continue reasoning-aware
|
|
447
|
+
* conversations.
|
|
448
|
+
*
|
|
449
|
+
* @category response
|
|
450
|
+
* @since 4.0.0
|
|
451
|
+
*/
|
|
314
452
|
interface ReasoningStartPartMetadata extends ProviderMetadata {
|
|
315
453
|
readonly anthropic?: {
|
|
316
454
|
readonly info?: {
|
|
@@ -330,6 +468,16 @@ declare module "effect/unstable/ai/Response" {
|
|
|
330
468
|
} | null;
|
|
331
469
|
} | null;
|
|
332
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Anthropic metadata attached to streaming reasoning deltas.
|
|
473
|
+
*
|
|
474
|
+
* **Details**
|
|
475
|
+
*
|
|
476
|
+
* Includes the signature for streamed Claude thinking content when available.
|
|
477
|
+
*
|
|
478
|
+
* @category response
|
|
479
|
+
* @since 4.0.0
|
|
480
|
+
*/
|
|
333
481
|
interface ReasoningDeltaPartMetadata extends ProviderMetadata {
|
|
334
482
|
readonly anthropic?: {
|
|
335
483
|
readonly info?: {
|
|
@@ -342,6 +490,16 @@ declare module "effect/unstable/ai/Response" {
|
|
|
342
490
|
} | null;
|
|
343
491
|
} | null;
|
|
344
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* Anthropic metadata attached to completed reasoning parts.
|
|
495
|
+
*
|
|
496
|
+
* **Details**
|
|
497
|
+
*
|
|
498
|
+
* Preserves Claude thinking or redacted thinking information for later turns.
|
|
499
|
+
*
|
|
500
|
+
* @category response
|
|
501
|
+
* @since 4.0.0
|
|
502
|
+
*/
|
|
345
503
|
interface ReasoningPartMetadata extends ProviderMetadata {
|
|
346
504
|
readonly anthropic?: {
|
|
347
505
|
readonly info?: {
|
|
@@ -361,6 +519,17 @@ declare module "effect/unstable/ai/Response" {
|
|
|
361
519
|
} | null;
|
|
362
520
|
} | null;
|
|
363
521
|
}
|
|
522
|
+
/**
|
|
523
|
+
* Anthropic metadata attached to tool call response parts.
|
|
524
|
+
*
|
|
525
|
+
* **Details**
|
|
526
|
+
*
|
|
527
|
+
* Identifies Anthropic caller details and MCP tool metadata emitted by the
|
|
528
|
+
* provider.
|
|
529
|
+
*
|
|
530
|
+
* @category response
|
|
531
|
+
* @since 4.0.0
|
|
532
|
+
*/
|
|
364
533
|
interface ToolCallPartMetadata extends ProviderMetadata {
|
|
365
534
|
readonly anthropic?: {
|
|
366
535
|
readonly caller?: {
|
|
@@ -378,6 +547,17 @@ declare module "effect/unstable/ai/Response" {
|
|
|
378
547
|
} | null;
|
|
379
548
|
} | null;
|
|
380
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* Anthropic metadata attached to tool result response parts.
|
|
552
|
+
*
|
|
553
|
+
* **Details**
|
|
554
|
+
*
|
|
555
|
+
* Identifies MCP tool metadata associated with provider-executed tool
|
|
556
|
+
* results.
|
|
557
|
+
*
|
|
558
|
+
* @category response
|
|
559
|
+
* @since 4.0.0
|
|
560
|
+
*/
|
|
381
561
|
interface ToolResultPartMetadata extends ProviderMetadata {
|
|
382
562
|
readonly anthropic?: {
|
|
383
563
|
/**
|
|
@@ -391,6 +571,16 @@ declare module "effect/unstable/ai/Response" {
|
|
|
391
571
|
} | null;
|
|
392
572
|
} | null;
|
|
393
573
|
}
|
|
574
|
+
/**
|
|
575
|
+
* Anthropic metadata for document citations in model responses.
|
|
576
|
+
*
|
|
577
|
+
* **Details**
|
|
578
|
+
*
|
|
579
|
+
* Records the cited document span by character position or page number.
|
|
580
|
+
*
|
|
581
|
+
* @category response
|
|
582
|
+
* @since 4.0.0
|
|
583
|
+
*/
|
|
394
584
|
interface DocumentSourcePartMetadata extends ProviderMetadata {
|
|
395
585
|
readonly anthropic?: {
|
|
396
586
|
readonly source: "document";
|
|
@@ -424,6 +614,16 @@ declare module "effect/unstable/ai/Response" {
|
|
|
424
614
|
readonly endPageNumber: number;
|
|
425
615
|
} | null;
|
|
426
616
|
}
|
|
617
|
+
/**
|
|
618
|
+
* Anthropic metadata for URL and web citations in model responses.
|
|
619
|
+
*
|
|
620
|
+
* **Details**
|
|
621
|
+
*
|
|
622
|
+
* Records cited URL text or web-search source freshness information.
|
|
623
|
+
*
|
|
624
|
+
* @category response
|
|
625
|
+
* @since 4.0.0
|
|
626
|
+
*/
|
|
427
627
|
interface UrlSourcePartMetadata extends ProviderMetadata {
|
|
428
628
|
readonly anthropic?: {
|
|
429
629
|
readonly source: "url";
|
|
@@ -442,6 +642,17 @@ declare module "effect/unstable/ai/Response" {
|
|
|
442
642
|
readonly pageAge: string | null;
|
|
443
643
|
} | null;
|
|
444
644
|
}
|
|
645
|
+
/**
|
|
646
|
+
* Anthropic metadata attached to the finish part of a response.
|
|
647
|
+
*
|
|
648
|
+
* **Details**
|
|
649
|
+
*
|
|
650
|
+
* Includes container state, context management information, stop details, and
|
|
651
|
+
* token usage reported by Anthropic.
|
|
652
|
+
*
|
|
653
|
+
* @category response
|
|
654
|
+
* @since 4.0.0
|
|
655
|
+
*/
|
|
445
656
|
interface FinishPartMetadata extends ProviderMetadata {
|
|
446
657
|
readonly anthropic?: {
|
|
447
658
|
readonly container: typeof Generated.BetaContainer.Encoded | null;
|
|
@@ -450,6 +661,16 @@ declare module "effect/unstable/ai/Response" {
|
|
|
450
661
|
readonly usage: typeof Generated.BetaMessage.Encoded["usage"] | null;
|
|
451
662
|
} | null;
|
|
452
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* Anthropic metadata attached to error response parts.
|
|
666
|
+
*
|
|
667
|
+
* **Details**
|
|
668
|
+
*
|
|
669
|
+
* Includes the provider request identifier when Anthropic returns one.
|
|
670
|
+
*
|
|
671
|
+
* @category response
|
|
672
|
+
* @since 4.0.0
|
|
673
|
+
*/
|
|
453
674
|
interface ErrorPartMetadata extends ProviderMetadata {
|
|
454
675
|
readonly anthropic?: {
|
|
455
676
|
requestId?: string | null;
|
|
@@ -457,17 +678,39 @@ declare module "effect/unstable/ai/Response" {
|
|
|
457
678
|
}
|
|
458
679
|
}
|
|
459
680
|
/**
|
|
460
|
-
* Creates an Anthropic
|
|
681
|
+
* Creates an Anthropic model descriptor that can be provided with `Effect.provide`.
|
|
682
|
+
*
|
|
683
|
+
* **When to use**
|
|
684
|
+
*
|
|
685
|
+
* Use when you want an Anthropic Claude model value that carries provider and
|
|
686
|
+
* model metadata and can be supplied directly to an Effect program.
|
|
687
|
+
*
|
|
688
|
+
* @see {@link layer} for creating a `LanguageModel.LanguageModel` layer directly
|
|
689
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
461
690
|
*
|
|
462
|
-
* @since 1.0.0
|
|
463
691
|
* @category constructors
|
|
692
|
+
* @since 4.0.0
|
|
464
693
|
*/
|
|
465
694
|
export declare const model: (model: (string & {}) | Model, config?: Omit<typeof Config.Service, "model">) => AiModel.Model<"anthropic", LanguageModel.LanguageModel, AnthropicClient>;
|
|
466
695
|
/**
|
|
467
|
-
* Creates an Anthropic
|
|
696
|
+
* Creates an Anthropic `LanguageModel` service from a model identifier and optional request defaults.
|
|
697
|
+
*
|
|
698
|
+
* **When to use**
|
|
699
|
+
*
|
|
700
|
+
* Use when you need to construct a `LanguageModel.Service` value backed by
|
|
701
|
+
* `AnthropicClient` inside an Effect.
|
|
702
|
+
*
|
|
703
|
+
* **Details**
|
|
704
|
+
*
|
|
705
|
+
* The returned effect requires `AnthropicClient`. Request defaults from the
|
|
706
|
+
* `config` option are merged with any `Config` service in the context, with
|
|
707
|
+
* context values taking precedence.
|
|
708
|
+
*
|
|
709
|
+
* @see {@link layer} for providing the service as a `Layer`
|
|
710
|
+
* @see {@link model} for creating a model descriptor for `AiModel.provide`
|
|
468
711
|
*
|
|
469
|
-
* @since 1.0.0
|
|
470
712
|
* @category constructors
|
|
713
|
+
* @since 4.0.0
|
|
471
714
|
*/
|
|
472
715
|
export declare const make: (args_0: {
|
|
473
716
|
readonly model: (string & {}) | Model;
|
|
@@ -476,8 +719,17 @@ export declare const make: (args_0: {
|
|
|
476
719
|
/**
|
|
477
720
|
* Creates a layer for the Anthropic language model.
|
|
478
721
|
*
|
|
479
|
-
*
|
|
722
|
+
* **When to use**
|
|
723
|
+
*
|
|
724
|
+
* Use when composing application layers and you want Anthropic to satisfy
|
|
725
|
+
* `LanguageModel.LanguageModel` while supplying `AnthropicClient` from another
|
|
726
|
+
* layer.
|
|
727
|
+
*
|
|
728
|
+
* @see {@link make} for constructing the language model service effectfully
|
|
729
|
+
* @see {@link model} for creating a model service directly
|
|
730
|
+
*
|
|
480
731
|
* @category layers
|
|
732
|
+
* @since 4.0.0
|
|
481
733
|
*/
|
|
482
734
|
export declare const layer: (options: {
|
|
483
735
|
readonly model: (string & {}) | Model;
|
|
@@ -486,40 +738,98 @@ export declare const layer: (options: {
|
|
|
486
738
|
/**
|
|
487
739
|
* Provides config overrides for Anthropic language model operations.
|
|
488
740
|
*
|
|
489
|
-
*
|
|
741
|
+
* **When to use**
|
|
742
|
+
*
|
|
743
|
+
* Use to apply Anthropic request configuration to one effect without changing
|
|
744
|
+
* the model's default configuration.
|
|
745
|
+
*
|
|
746
|
+
* **Details**
|
|
747
|
+
*
|
|
748
|
+
* The overrides are merged with any existing `Config` service for the duration
|
|
749
|
+
* of the supplied effect. Fields in `overrides` take precedence over existing
|
|
750
|
+
* config, and the helper supports both `effect.pipe(withConfigOverride(overrides))`
|
|
751
|
+
* and `withConfigOverride(effect, overrides)`.
|
|
752
|
+
*
|
|
753
|
+
* @see {@link Config} for available Anthropic request configuration fields
|
|
754
|
+
*
|
|
490
755
|
* @category configuration
|
|
756
|
+
* @since 4.0.0
|
|
491
757
|
*/
|
|
492
758
|
export declare const withConfigOverride: {
|
|
493
759
|
/**
|
|
494
760
|
* Provides config overrides for Anthropic language model operations.
|
|
495
761
|
*
|
|
496
|
-
*
|
|
762
|
+
* **When to use**
|
|
763
|
+
*
|
|
764
|
+
* Use to apply Anthropic request configuration to one effect without changing
|
|
765
|
+
* the model's default configuration.
|
|
766
|
+
*
|
|
767
|
+
* **Details**
|
|
768
|
+
*
|
|
769
|
+
* The overrides are merged with any existing `Config` service for the duration
|
|
770
|
+
* of the supplied effect. Fields in `overrides` take precedence over existing
|
|
771
|
+
* config, and the helper supports both `effect.pipe(withConfigOverride(overrides))`
|
|
772
|
+
* and `withConfigOverride(effect, overrides)`.
|
|
773
|
+
*
|
|
774
|
+
* @see {@link Config} for available Anthropic request configuration fields
|
|
775
|
+
*
|
|
497
776
|
* @category configuration
|
|
777
|
+
* @since 4.0.0
|
|
498
778
|
*/
|
|
499
779
|
(overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>;
|
|
500
780
|
/**
|
|
501
781
|
* Provides config overrides for Anthropic language model operations.
|
|
502
782
|
*
|
|
503
|
-
*
|
|
783
|
+
* **When to use**
|
|
784
|
+
*
|
|
785
|
+
* Use to apply Anthropic request configuration to one effect without changing
|
|
786
|
+
* the model's default configuration.
|
|
787
|
+
*
|
|
788
|
+
* **Details**
|
|
789
|
+
*
|
|
790
|
+
* The overrides are merged with any existing `Config` service for the duration
|
|
791
|
+
* of the supplied effect. Fields in `overrides` take precedence over existing
|
|
792
|
+
* config, and the helper supports both `effect.pipe(withConfigOverride(overrides))`
|
|
793
|
+
* and `withConfigOverride(effect, overrides)`.
|
|
794
|
+
*
|
|
795
|
+
* @see {@link Config} for available Anthropic request configuration fields
|
|
796
|
+
*
|
|
504
797
|
* @category configuration
|
|
798
|
+
* @since 4.0.0
|
|
505
799
|
*/
|
|
506
800
|
<A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>;
|
|
507
801
|
};
|
|
508
802
|
/**
|
|
509
|
-
*
|
|
803
|
+
* Encoded Anthropic custom tool definition that can be sent in a Messages API request.
|
|
804
|
+
*
|
|
805
|
+
* **When to use**
|
|
806
|
+
*
|
|
807
|
+
* Use when you need to type or inspect the provider-specific request payload for
|
|
808
|
+
* a custom Anthropic tool.
|
|
809
|
+
*
|
|
810
|
+
* **Details**
|
|
811
|
+
*
|
|
812
|
+
* This type aliases the encoded `Generated.BetaTool` schema used for Effect
|
|
813
|
+
* user-defined and dynamic tools after conversion. It contains the tool `name`,
|
|
814
|
+
* optional `description`, and `input_schema`, plus Anthropic-specific fields
|
|
815
|
+
* such as `strict` and `cache_control`.
|
|
816
|
+
*
|
|
817
|
+
* @see {@link AnthropicProviderDefinedTool} for the request shape used by Anthropic built-in provider tools
|
|
510
818
|
*
|
|
511
|
-
* @since 1.0.0
|
|
512
819
|
* @category tools
|
|
820
|
+
* @since 4.0.0
|
|
513
821
|
*/
|
|
514
822
|
export type AnthropicUserDefinedTool = typeof Generated.BetaTool.Encoded;
|
|
515
823
|
/**
|
|
516
824
|
* Represents a provider-defined tool that can be passed to the Anthropic API.
|
|
517
825
|
*
|
|
826
|
+
* **Details**
|
|
827
|
+
*
|
|
518
828
|
* These include Anthropic's built-in tools like computer use, code execution,
|
|
519
829
|
* web search, and text editing.
|
|
520
830
|
*
|
|
521
|
-
* @since 1.0.0
|
|
522
831
|
* @category tools
|
|
832
|
+
* @since 4.0.0
|
|
523
833
|
*/
|
|
524
834
|
export type AnthropicProviderDefinedTool = typeof Generated.BetaBashTool_20241022.Encoded | typeof Generated.BetaBashTool_20250124.Encoded | typeof Generated.BetaCodeExecutionTool_20250522.Encoded | typeof Generated.BetaCodeExecutionTool_20250825.Encoded | typeof Generated.BetaComputerUseTool_20241022.Encoded | typeof Generated.BetaComputerUseTool_20250124.Encoded | typeof Generated.BetaComputerUseTool_20251124.Encoded | typeof Generated.BetaMemoryTool_20250818.Encoded | typeof Generated.BetaTextEditor_20241022.Encoded | typeof Generated.BetaTextEditor_20250124.Encoded | typeof Generated.BetaTextEditor_20250429.Encoded | typeof Generated.BetaTextEditor_20250728.Encoded | typeof Generated.BetaToolSearchToolBM25_20251119.Encoded | typeof Generated.BetaToolSearchToolRegex_20251119.Encoded | typeof Generated.BetaWebFetchTool_20250910.Encoded | typeof Generated.BetaWebSearchTool_20250305.Encoded;
|
|
525
835
|
export {};
|