@effect/ai-anthropic 4.0.0-beta.8 → 4.0.0-beta.80

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 (41) hide show
  1. package/dist/AnthropicClient.d.ts +92 -69
  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 +362 -52
  13. package/dist/AnthropicLanguageModel.d.ts.map +1 -1
  14. package/dist/AnthropicLanguageModel.js +88 -21
  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 +1223 -289
  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/index.d.ts +8 -29
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +8 -29
  29. package/dist/index.js.map +1 -1
  30. package/dist/internal/errors.js +7 -7
  31. package/dist/internal/errors.js.map +1 -1
  32. package/package.json +3 -3
  33. package/src/AnthropicClient.ts +97 -74
  34. package/src/AnthropicConfig.ts +56 -11
  35. package/src/AnthropicError.ts +138 -37
  36. package/src/AnthropicLanguageModel.ts +395 -43
  37. package/src/AnthropicTelemetry.ts +48 -22
  38. package/src/AnthropicTool.ts +1216 -282
  39. package/src/Generated.ts +1 -1
  40. package/src/index.ts +8 -29
  41. package/src/internal/errors.ts +9 -7
@@ -4,13 +4,21 @@
4
4
  * Provides Anthropic-specific metadata fields for AI error types through module
5
5
  * augmentation, enabling typed access to Anthropic error details.
6
6
  *
7
- * @since 1.0.0
7
+ * @since 4.0.0
8
8
  */
9
9
  /**
10
10
  * Anthropic-specific error metadata fields.
11
11
  *
12
- * @since 1.0.0
12
+ * **Details**
13
+ *
14
+ * Contains the Anthropic error type and request identifier copied from provider
15
+ * error responses when available. Either field may be `null` when Anthropic
16
+ * does not include it or the response cannot be decoded.
17
+ *
18
+ * @see {@link AnthropicRateLimitMetadata} for rate-limit responses that also include parsed Anthropic rate-limit headers
19
+ *
13
20
  * @category models
21
+ * @since 4.0.0
14
22
  */
15
23
  export type AnthropicErrorMetadata = {
16
24
  /**
@@ -25,11 +33,12 @@ export type AnthropicErrorMetadata = {
25
33
  /**
26
34
  * Anthropic-specific rate limit metadata fields.
27
35
  *
28
- * Extends base error metadata with rate limit specific information from
29
- * Anthropic's rate limit headers.
36
+ * **Details**
37
+ *
38
+ * Extends base error metadata with rate limit-specific information from Anthropic's rate limit headers.
30
39
  *
31
- * @since 1.0.0
32
40
  * @category models
41
+ * @since 4.0.0
33
42
  */
34
43
  export type AnthropicRateLimitMetadata = AnthropicErrorMetadata & {
35
44
  /**
@@ -58,45 +67,135 @@ export type AnthropicRateLimitMetadata = AnthropicErrorMetadata & {
58
67
  readonly tokensReset: string | null;
59
68
  };
60
69
  declare module "effect/unstable/ai/AiError" {
61
- interface RateLimitError {
62
- readonly metadata: {
63
- readonly anthropic?: AnthropicRateLimitMetadata | null;
64
- };
70
+ /**
71
+ * Anthropic metadata attached to `RateLimitError` values.
72
+ *
73
+ * **Details**
74
+ *
75
+ * Includes request identifiers, Anthropic error types, and parsed request or token limit headers when the provider rejects a request due to rate limits.
76
+ *
77
+ * @category configuration
78
+ * @since 4.0.0
79
+ */
80
+ interface RateLimitErrorMetadata {
81
+ readonly anthropic?: AnthropicRateLimitMetadata | null;
65
82
  }
66
- interface QuotaExhaustedError {
67
- readonly metadata: {
68
- readonly anthropic?: AnthropicErrorMetadata | null;
69
- };
83
+ /**
84
+ * Anthropic metadata attached to `QuotaExhaustedError` values.
85
+ *
86
+ * **Details**
87
+ *
88
+ * Captures the Anthropic error type and request identifier for failures where the account or workspace has exhausted its available quota.
89
+ *
90
+ * @category configuration
91
+ * @since 4.0.0
92
+ */
93
+ interface QuotaExhaustedErrorMetadata {
94
+ readonly anthropic?: AnthropicErrorMetadata | null;
95
+ }
96
+ /**
97
+ * Anthropic metadata attached to `AuthenticationError` values.
98
+ *
99
+ * **Details**
100
+ *
101
+ * Preserves Anthropic error details for missing, invalid, or unauthorized API credentials while keeping the error in the shared AI error model.
102
+ *
103
+ * @category configuration
104
+ * @since 4.0.0
105
+ */
106
+ interface AuthenticationErrorMetadata {
107
+ readonly anthropic?: AnthropicErrorMetadata | null;
108
+ }
109
+ /**
110
+ * Anthropic metadata attached to `ContentPolicyError` values.
111
+ *
112
+ * **Details**
113
+ *
114
+ * Records Anthropic error details returned when a request or response is rejected by Anthropic safety or content policy enforcement.
115
+ *
116
+ * @category configuration
117
+ * @since 4.0.0
118
+ */
119
+ interface ContentPolicyErrorMetadata {
120
+ readonly anthropic?: AnthropicErrorMetadata | null;
70
121
  }
71
- interface AuthenticationError {
72
- readonly metadata: {
73
- readonly anthropic?: AnthropicErrorMetadata | null;
74
- };
122
+ /**
123
+ * Anthropic metadata attached to `InvalidRequestError` values.
124
+ *
125
+ * **Details**
126
+ *
127
+ * Provides the Anthropic error type and request identifier for malformed or unsupported requests rejected before model execution.
128
+ *
129
+ * @category configuration
130
+ * @since 4.0.0
131
+ */
132
+ interface InvalidRequestErrorMetadata {
133
+ readonly anthropic?: AnthropicErrorMetadata | null;
75
134
  }
76
- interface ContentPolicyError {
77
- readonly metadata: {
78
- readonly anthropic?: AnthropicErrorMetadata | null;
79
- };
135
+ /**
136
+ * Anthropic metadata attached to `InternalProviderError` values.
137
+ *
138
+ * **Details**
139
+ *
140
+ * Preserves Anthropic request correlation data for provider-side failures that should be reported or investigated with Anthropic support.
141
+ *
142
+ * @category configuration
143
+ * @since 4.0.0
144
+ */
145
+ interface InternalProviderErrorMetadata {
146
+ readonly anthropic?: AnthropicErrorMetadata | null;
80
147
  }
81
- interface InvalidRequestError {
82
- readonly metadata: {
83
- readonly anthropic?: AnthropicErrorMetadata | null;
84
- };
148
+ /**
149
+ * Anthropic metadata attached to `InvalidOutputError` values.
150
+ *
151
+ * **Details**
152
+ *
153
+ * Describes Anthropic-specific context for responses that could not be decoded or interpreted as valid AI output.
154
+ *
155
+ * @category configuration
156
+ * @since 4.0.0
157
+ */
158
+ interface InvalidOutputErrorMetadata {
159
+ readonly anthropic?: AnthropicErrorMetadata | null;
85
160
  }
86
- interface InternalProviderError {
87
- readonly metadata: {
88
- readonly anthropic?: AnthropicErrorMetadata | null;
89
- };
161
+ /**
162
+ * Anthropic metadata attached to `StructuredOutputError` values.
163
+ *
164
+ * **Details**
165
+ *
166
+ * Captures Anthropic error details for structured-output failures, including request correlation data useful when diagnosing schema-related responses.
167
+ *
168
+ * @category configuration
169
+ * @since 4.0.0
170
+ */
171
+ interface StructuredOutputErrorMetadata {
172
+ readonly anthropic?: AnthropicErrorMetadata | null;
90
173
  }
91
- interface InvalidOutputError {
92
- readonly metadata: {
93
- readonly anthropic?: AnthropicErrorMetadata | null;
94
- };
174
+ /**
175
+ * Anthropic metadata attached to `UnsupportedSchemaError` values.
176
+ *
177
+ * **Details**
178
+ *
179
+ * Provides Anthropic error details for schemas that cannot be represented by or submitted to the Anthropic API.
180
+ *
181
+ * @category configuration
182
+ * @since 4.0.0
183
+ */
184
+ interface UnsupportedSchemaErrorMetadata {
185
+ readonly anthropic?: AnthropicErrorMetadata | null;
95
186
  }
96
- interface UnknownError {
97
- readonly metadata: {
98
- readonly anthropic?: AnthropicErrorMetadata | null;
99
- };
187
+ /**
188
+ * Anthropic metadata attached to `UnknownError` values.
189
+ *
190
+ * **Details**
191
+ *
192
+ * Retains the Anthropic error type and request identifier when a provider response cannot be classified as a more specific AI error.
193
+ *
194
+ * @category configuration
195
+ * @since 4.0.0
196
+ */
197
+ interface UnknownErrorMetadata {
198
+ readonly anthropic?: AnthropicErrorMetadata | null;
100
199
  }
101
200
  }
102
201
  //# sourceMappingURL=AnthropicError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnthropicError.d.ts","sourceRoot":"","sources":["../src/AnthropicError.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,GAAG,sBAAsB,GAAG;IAChE;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC;;OAEG;IACH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;IACzC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IACnC;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IACvC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC,CAAA;AAED,OAAO,QAAQ,4BAA4B,CAAC;IAC1C,UAAiB,cAAc;QAC7B,QAAQ,CAAC,QAAQ,EAAE;YACjB,QAAQ,CAAC,SAAS,CAAC,EAAE,0BAA0B,GAAG,IAAI,CAAA;SACvD,CAAA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0B;QACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAA;KACnD;IAED;;;;;;;;;OASG;IACH,UAAiB,6BAA6B;QAC5C,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAA;KACnD;IAED;;;;;;;;;OASG;IACH,UAAiB,8BAA8B;QAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAA;KACnD;IAED;;;;;;;;;OASG;IACH,UAAiB,oBAAoB;QACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAA;KACnD;CACF"}
@@ -4,7 +4,7 @@
4
4
  * Provides Anthropic-specific metadata fields for AI error types through module
5
5
  * augmentation, enabling typed access to Anthropic error details.
6
6
  *
7
- * @since 1.0.0
7
+ * @since 4.0.0
8
8
  */
9
9
  export {};
10
10
  //# sourceMappingURL=AnthropicError.js.map