@effect/ai-anthropic 4.0.0-beta.7 → 4.0.0-beta.71
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 +89 -66
- package/dist/AnthropicClient.d.ts.map +1 -1
- package/dist/AnthropicClient.js +75 -17
- package/dist/AnthropicClient.js.map +1 -1
- package/dist/AnthropicConfig.d.ts +68 -10
- package/dist/AnthropicConfig.d.ts.map +1 -1
- package/dist/AnthropicConfig.js +43 -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 +384 -71
- package/dist/AnthropicLanguageModel.d.ts.map +1 -1
- package/dist/AnthropicLanguageModel.js +102 -16
- package/dist/AnthropicLanguageModel.js.map +1 -1
- package/dist/AnthropicTelemetry.d.ts +42 -15
- package/dist/AnthropicTelemetry.d.ts.map +1 -1
- package/dist/AnthropicTelemetry.js +44 -8
- package/dist/AnthropicTelemetry.js.map +1 -1
- package/dist/AnthropicTool.d.ts +1116 -183
- package/dist/AnthropicTool.d.ts.map +1 -1
- package/dist/AnthropicTool.js +818 -129
- package/dist/AnthropicTool.js.map +1 -1
- package/dist/Generated.d.ts +11661 -5260
- package/dist/Generated.d.ts.map +1 -1
- package/dist/Generated.js +2318 -915
- package/dist/Generated.js.map +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 +119 -70
- package/src/AnthropicConfig.ts +69 -11
- package/src/AnthropicError.ts +138 -37
- package/src/AnthropicLanguageModel.ts +405 -38
- package/src/AnthropicTelemetry.ts +76 -20
- package/src/AnthropicTool.ts +1109 -176
- package/src/Generated.ts +3751 -1815
- package/src/index.ts +8 -29
- package/src/internal/errors.ts +9 -7
package/dist/AnthropicConfig.js
CHANGED
|
@@ -1,22 +1,58 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The `AnthropicConfig` module provides contextual configuration for the
|
|
3
|
+
* Anthropic AI provider integration. It is used to customize the generated
|
|
4
|
+
* Anthropic HTTP client without changing individual request code.
|
|
5
|
+
*
|
|
6
|
+
* **Common tasks**
|
|
7
|
+
*
|
|
8
|
+
* - Provide a shared `HttpClient` transformation for Anthropic requests
|
|
9
|
+
* - Add provider-specific concerns such as request instrumentation, proxying,
|
|
10
|
+
* retries, or header manipulation
|
|
11
|
+
* - Scope a client transformation to a single effect with {@link withClientTransform}
|
|
12
|
+
*
|
|
13
|
+
* **Gotchas**
|
|
14
|
+
*
|
|
15
|
+
* - Configuration is read from the Effect context, so overrides only apply to
|
|
16
|
+
* effects run inside the configured scope
|
|
17
|
+
* - `withClientTransform` replaces the current `transformClient` value while
|
|
18
|
+
* preserving any other Anthropic configuration fields
|
|
19
|
+
*
|
|
20
|
+
* @since 4.0.0
|
|
3
21
|
*/
|
|
22
|
+
import * as Context from "effect/Context";
|
|
4
23
|
import * as Effect from "effect/Effect";
|
|
5
24
|
import { dual } from "effect/Function";
|
|
6
|
-
import * as ServiceMap from "effect/ServiceMap";
|
|
7
25
|
/**
|
|
8
|
-
*
|
|
26
|
+
* Service tag for Anthropic client configuration overrides, such as transformations applied to the generated HTTP client.
|
|
27
|
+
*
|
|
28
|
+
* **When to use**
|
|
29
|
+
*
|
|
30
|
+
* Use when a layer or integration needs to provide or read Anthropic client
|
|
31
|
+
* configuration through Effect's context.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link withClientTransform} for scoping an HTTP client transformation
|
|
34
|
+
*
|
|
9
35
|
* @category services
|
|
36
|
+
* @since 4.0.0
|
|
10
37
|
*/
|
|
11
|
-
export class AnthropicConfig extends /*#__PURE__*/
|
|
38
|
+
export class AnthropicConfig extends /*#__PURE__*/Context.Service()("@effect/ai-anthropic/AnthropicConfig") {
|
|
12
39
|
/**
|
|
13
|
-
*
|
|
40
|
+
* Gets the configured Anthropic service from the current context when present.
|
|
41
|
+
*
|
|
42
|
+
* @since 4.0.0
|
|
14
43
|
*/
|
|
15
|
-
static getOrUndefined = /*#__PURE__*/Effect.map(/*#__PURE__*/Effect.
|
|
44
|
+
static getOrUndefined = /*#__PURE__*/Effect.map(/*#__PURE__*/Effect.context(), services => services.mapUnsafe.get(AnthropicConfig.key));
|
|
16
45
|
}
|
|
17
46
|
/**
|
|
18
|
-
*
|
|
47
|
+
* Runs an effect with an `AnthropicConfig` override that transforms the underlying `HttpClient` used by generated Anthropic requests.
|
|
48
|
+
*
|
|
49
|
+
* **When to use**
|
|
50
|
+
*
|
|
51
|
+
* Use when you need to apply a temporary `HttpClient` transformation, such as adding middleware or logging, to a
|
|
52
|
+
* specific scope of an effectful program.
|
|
53
|
+
*
|
|
19
54
|
* @category configuration
|
|
55
|
+
* @since 4.0.0
|
|
20
56
|
*/
|
|
21
57
|
export const withClientTransform = /*#__PURE__*/dual(2, (self, transformClient) => Effect.flatMap(AnthropicConfig.getOrUndefined, config => Effect.provideService(self, AnthropicConfig, {
|
|
22
58
|
...config,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnthropicConfig.js","names":["
|
|
1
|
+
{"version":3,"file":"AnthropicConfig.js","names":["Context","Effect","dual","AnthropicConfig","Service","getOrUndefined","map","context","services","mapUnsafe","get","key","withClientTransform","self","transformClient","flatMap","config","provideService"],"sources":["../src/AnthropicConfig.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;AAqBA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,IAAI,QAAQ,iBAAiB;AAGtC;;;;;;;;;;;;;AAaA,OAAM,MAAOC,eAAgB,sBAAQH,OAAO,CAACI,OAAO,EAGjD,CAAC,sCAAsC,CAAC;EACzC;;;;;EAKA,OAAgBC,cAAc,gBAA8DJ,MAAM,CAACK,GAAG,cACpGL,MAAM,CAACM,OAAO,EAAS,EACtBC,QAAQ,IAAKA,QAAQ,CAACC,SAAS,CAACC,GAAG,CAACP,eAAe,CAACQ,GAAG,CAAC,CAC1D;;AAwBH;;;;;;;;;;;AAWA,OAAO,MAAMC,mBAAmB,gBA4B5BV,IAAI,CAAC,CAAC,EAAE,CACVW,IAA4B,EAC5BC,eAAmD,KAEnDb,MAAM,CAACc,OAAO,CACZZ,eAAe,CAACE,cAAc,EAC7BW,MAAM,IAAKf,MAAM,CAACgB,cAAc,CAACJ,IAAI,EAAEV,eAAe,EAAE;EAAE,GAAGa,MAAM;EAAEF;AAAe,CAAE,CAAC,CACzF,CAAC","ignoreList":[]}
|
package/dist/AnthropicError.d.ts
CHANGED
|
@@ -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
|
|
7
|
+
* @since 4.0.0
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Anthropic-specific error metadata fields.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
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
|
-
*
|
|
29
|
-
*
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
1
|
+
{"version":3,"file":"AnthropicError.d.ts","sourceRoot":"","sources":["../src/AnthropicError.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;GAaG;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;;;;;;;;;GASG;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,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