@effect/ai-anthropic 4.0.0-beta.9 → 4.0.0-beta.91

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