@providerkit/core 0.1.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/LICENSE +21 -0
- package/README.md +245 -0
- package/dist/context.d.ts +69 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +132 -0
- package/dist/context.js.map +1 -0
- package/dist/errors.d.ts +86 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +356 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/anthropic.d.ts +26 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +245 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/openai.d.ts +30 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +185 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/retry.d.ts +79 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +200 -0
- package/dist/retry.js.map +1 -0
- package/dist/schema.d.ts +2 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +48 -0
- package/dist/schema.js.map +1 -0
- package/dist/tool-args.d.ts +12 -0
- package/dist/tool-args.d.ts.map +1 -0
- package/dist/tool-args.js +113 -0
- package/dist/tool-args.js.map +1 -0
- package/dist/tools.d.ts +82 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +155 -0
- package/dist/tools.js.map +1 -0
- package/dist/transport.d.ts +31 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +157 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +168 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +75 -0
- package/dist/types.js.map +1 -0
- package/dist/usage.d.ts +50 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +71 -0
- package/dist/usage.js.map +1 -0
- package/dist/watchdog.d.ts +34 -0
- package/dist/watchdog.d.ts.map +1 -0
- package/dist/watchdog.js +85 -0
- package/dist/watchdog.js.map +1 -0
- package/dist/zod.d.ts +32 -0
- package/dist/zod.d.ts.map +1 -0
- package/dist/zod.js +49 -0
- package/dist/zod.js.map +1 -0
- package/package.json +76 -0
- package/src/context.ts +150 -0
- package/src/errors.ts +398 -0
- package/src/index.ts +12 -0
- package/src/providers/anthropic.ts +315 -0
- package/src/providers/openai.ts +246 -0
- package/src/retry.ts +246 -0
- package/src/schema.ts +67 -0
- package/src/tool-args.ts +117 -0
- package/src/tools.ts +237 -0
- package/src/transport.ts +162 -0
- package/src/types.ts +231 -0
- package/src/usage.ts +106 -0
- package/src/watchdog.ts +119 -0
- package/src/zod.ts +74 -0
package/dist/errors.js
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
// One error shape for every provider, classified once.
|
|
2
|
+
//
|
|
3
|
+
// `kind` drives the four decisions a caller actually makes — retry it? try a
|
|
4
|
+
// different model? rotate the key? what do we tell the user? — so no call site
|
|
5
|
+
// ever string-matches an SDK message again.
|
|
6
|
+
//
|
|
7
|
+
// The ordering is the hard-won part. Providers file the same root cause under
|
|
8
|
+
// whatever status they like: quota exhaustion arrives as 429 (OpenAI), 402
|
|
9
|
+
// (DeepSeek), 403 (xAI) and 400 (Anthropic). So for the 4xx family the BODY is
|
|
10
|
+
// read before the status — status alone gives the wrong advice ("retry" for an
|
|
11
|
+
// empty balance, "check your key" for a plan that never included the API).
|
|
12
|
+
/** Worth a cheap retry on the same key and model. */
|
|
13
|
+
const TRANSIENT = new Set([
|
|
14
|
+
"timeout",
|
|
15
|
+
"network",
|
|
16
|
+
"overload",
|
|
17
|
+
"rate",
|
|
18
|
+
]);
|
|
19
|
+
/** Worth walking to a backup MODEL rather than just waiting. A throttle and an
|
|
20
|
+
* overload are per-model-endpoint; nothing else on this list is. */
|
|
21
|
+
const BACKUP_ELIGIBLE = new Set(["overload", "rate"]);
|
|
22
|
+
export function isTransient(kind) {
|
|
23
|
+
return TRANSIENT.has(kind);
|
|
24
|
+
}
|
|
25
|
+
export function isBackupEligible(kind) {
|
|
26
|
+
return BACKUP_ELIGIBLE.has(kind);
|
|
27
|
+
}
|
|
28
|
+
export class ProviderError extends Error {
|
|
29
|
+
provider;
|
|
30
|
+
kind;
|
|
31
|
+
status;
|
|
32
|
+
code;
|
|
33
|
+
/** Honoured when the provider said how long to wait (Retry-After, or
|
|
34
|
+
* Gemini's RetryInfo.retryDelay). */
|
|
35
|
+
retryAfterMs;
|
|
36
|
+
/** The provider's own response body, truncated — the actual reason, which is
|
|
37
|
+
* otherwise lost behind "400 status code (no body)". */
|
|
38
|
+
body;
|
|
39
|
+
constructor(provider, kind, message, opts = {}) {
|
|
40
|
+
super(message, { cause: opts.cause });
|
|
41
|
+
this.name = "ProviderError";
|
|
42
|
+
this.provider = provider;
|
|
43
|
+
this.kind = kind;
|
|
44
|
+
this.status = opts.status;
|
|
45
|
+
this.code = opts.code;
|
|
46
|
+
this.retryAfterMs = opts.retryAfterMs;
|
|
47
|
+
this.body = opts.body;
|
|
48
|
+
}
|
|
49
|
+
get isTransient() {
|
|
50
|
+
return isTransient(this.kind);
|
|
51
|
+
}
|
|
52
|
+
get isBackupEligible() {
|
|
53
|
+
return isBackupEligible(this.kind);
|
|
54
|
+
}
|
|
55
|
+
/** Wrap anything thrown into a classified ProviderError. Already-wrapped
|
|
56
|
+
* errors pass through untouched, so classification happens exactly once. */
|
|
57
|
+
static from(provider, err) {
|
|
58
|
+
if (err instanceof ProviderError)
|
|
59
|
+
return err;
|
|
60
|
+
const status = readNumber(err, "status");
|
|
61
|
+
const code = readString(err, "code") ?? readString(err, "type");
|
|
62
|
+
const message = messageOf(err);
|
|
63
|
+
const body = bodyTextOf(err);
|
|
64
|
+
return new ProviderError(provider, classify(err, status, body), message, {
|
|
65
|
+
status,
|
|
66
|
+
code,
|
|
67
|
+
retryAfterMs: parseRetryAfterMs(err, body),
|
|
68
|
+
body: body.slice(0, 2_000) || undefined,
|
|
69
|
+
cause: err,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// ── reading whatever shape was thrown ─────────────────────────────────────
|
|
74
|
+
function readNumber(err, key) {
|
|
75
|
+
if (typeof err !== "object" || err === null)
|
|
76
|
+
return undefined;
|
|
77
|
+
const value = err[key];
|
|
78
|
+
return typeof value === "number" ? value : undefined;
|
|
79
|
+
}
|
|
80
|
+
function readString(err, key) {
|
|
81
|
+
if (typeof err !== "object" || err === null)
|
|
82
|
+
return undefined;
|
|
83
|
+
const value = err[key];
|
|
84
|
+
return typeof value === "string" ? value : undefined;
|
|
85
|
+
}
|
|
86
|
+
export function messageOf(err) {
|
|
87
|
+
if (err instanceof Error)
|
|
88
|
+
return err.message;
|
|
89
|
+
if (typeof err === "string")
|
|
90
|
+
return err;
|
|
91
|
+
const message = readString(err, "message");
|
|
92
|
+
if (message !== undefined)
|
|
93
|
+
return message;
|
|
94
|
+
try {
|
|
95
|
+
return JSON.stringify(err) ?? String(err);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return String(err);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Everything readable about the failure as one searchable string: the message
|
|
103
|
+
* plus the parsed provider body. SDKs park the parsed body on `.error`, and
|
|
104
|
+
* that is where the real reason lives ("max_tokens too large", the quotaId,
|
|
105
|
+
* `"type": "billing_error"`). Scanned as TEXT — the error-type strings
|
|
106
|
+
* serialize into it, so no JSON walking is needed.
|
|
107
|
+
*/
|
|
108
|
+
function bodyTextOf(err) {
|
|
109
|
+
const message = messageOf(err);
|
|
110
|
+
if (typeof err !== "object" || err === null)
|
|
111
|
+
return message;
|
|
112
|
+
const body = err.error;
|
|
113
|
+
if (body === undefined)
|
|
114
|
+
return message;
|
|
115
|
+
try {
|
|
116
|
+
return `${message} ${typeof body === "string" ? body : JSON.stringify(body)}`;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return message;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// ── transport: the failure with no status at all ──────────────────────────
|
|
123
|
+
/** Node/undici codes meaning "the socket died", not "the request was wrong".
|
|
124
|
+
* They usually sit on `cause`, not on the thrown error itself. */
|
|
125
|
+
const TRANSPORT_CODES = new Set([
|
|
126
|
+
"ECONNRESET",
|
|
127
|
+
"ECONNREFUSED",
|
|
128
|
+
"ECONNABORTED",
|
|
129
|
+
"ETIMEDOUT",
|
|
130
|
+
"EPIPE",
|
|
131
|
+
"ENETUNREACH",
|
|
132
|
+
"ENETDOWN",
|
|
133
|
+
"ENOTFOUND",
|
|
134
|
+
"EHOSTUNREACH",
|
|
135
|
+
"EAI_AGAIN",
|
|
136
|
+
"ERR_STREAM_PREMATURE_CLOSE",
|
|
137
|
+
]);
|
|
138
|
+
/**
|
|
139
|
+
* The same faults when only a message survives. Engine wordings differ:
|
|
140
|
+
* Chromium says "Failed to fetch", Firefox "NetworkError when attempting to
|
|
141
|
+
* fetch resource", Safari "Load failed", Node/Bun "fetch failed".
|
|
142
|
+
*/
|
|
143
|
+
const TRANSPORT_MESSAGES = /failed to fetch|fetch failed|network\s?error|load failed|unable to connect|socket hang up|socket (?:connection )?(?:was )?closed|connection (?:error|closed|refused|reset)|premature close|stream (?:ended|closed) unexpectedly|und_err/i;
|
|
144
|
+
/** How far up the `cause` chain to look before giving up. */
|
|
145
|
+
const CAUSE_DEPTH = 5;
|
|
146
|
+
function isAbort(err) {
|
|
147
|
+
const name = readString(err, "name");
|
|
148
|
+
const code = readString(err, "code");
|
|
149
|
+
return name === "AbortError" || name === "APIUserAbortError" || code === "ABORT_ERR";
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A transport fault: the socket died before or during the response, so there
|
|
153
|
+
* is NO status and no body for the patterns below to read.
|
|
154
|
+
*
|
|
155
|
+
* The chain is walked because the useful code is rarely on the thrown error —
|
|
156
|
+
* it sits on `cause`, sometimes several wrappers deep. Without this walk every
|
|
157
|
+
* network blip classifies as permanent, and a long run dies on its first
|
|
158
|
+
* hiccup, which is the single likeliest way to lose a minutes-long job.
|
|
159
|
+
*
|
|
160
|
+
* A deliberate abort short-circuits to false: the caller pressed Stop, and
|
|
161
|
+
* retrying that just re-fails against the same dead signal.
|
|
162
|
+
*/
|
|
163
|
+
export function isTransportFailure(err) {
|
|
164
|
+
let current = err;
|
|
165
|
+
for (let depth = 0; current != null && depth < CAUSE_DEPTH; depth++) {
|
|
166
|
+
if (typeof current !== "object")
|
|
167
|
+
return false;
|
|
168
|
+
if (isAbort(current))
|
|
169
|
+
return false;
|
|
170
|
+
const name = readString(current, "name");
|
|
171
|
+
const code = readString(current, "code");
|
|
172
|
+
const message = readString(current, "message");
|
|
173
|
+
if (name === "APIConnectionError" || name === "APIConnectionTimeoutError")
|
|
174
|
+
return true;
|
|
175
|
+
if (code !== undefined && TRANSPORT_CODES.has(code))
|
|
176
|
+
return true;
|
|
177
|
+
// A bare TypeError is also what a real bug throws ("x is not a function"),
|
|
178
|
+
// so the MESSAGE is checked, not just the type — misfiling one of those
|
|
179
|
+
// would retry a genuine bug three times and hide it.
|
|
180
|
+
if (message !== undefined && TRANSPORT_MESSAGES.test(message))
|
|
181
|
+
return true;
|
|
182
|
+
current = current.cause;
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
// ── body patterns, most-specific first ────────────────────────────────────
|
|
187
|
+
// The request outgrew the model's window. Distinct from quota in the one way
|
|
188
|
+
// that matters: nothing about the account is wrong and waiting fixes nothing —
|
|
189
|
+
// the fix is to send less, which is what compaction does.
|
|
190
|
+
const CONTEXT_PATTERNS = [
|
|
191
|
+
/context[_\s]length[_\s]exceeded/i,
|
|
192
|
+
/maximum context length/i,
|
|
193
|
+
/context window/i,
|
|
194
|
+
/prompt is too long/i,
|
|
195
|
+
/input is too long/i,
|
|
196
|
+
/too many (?:input )?tokens/i,
|
|
197
|
+
/reduce the length of the (?:messages|prompt|input)/i,
|
|
198
|
+
// Scoped to the thing that overflowed: a bare "exceeds the maximum" also
|
|
199
|
+
// covers image counts and per-minute token rates, which compaction can't fix.
|
|
200
|
+
/exceeds? the (?:model'?s? )?maximum (?:input |prompt |context )?(?:tokens?|length|context)/i,
|
|
201
|
+
];
|
|
202
|
+
// A plan that never included this API — neither a new key nor a top-up fixes
|
|
203
|
+
// it, and its wording overlaps both other categories ("plan" appears in all
|
|
204
|
+
// three), so it is checked first.
|
|
205
|
+
const ENTITLEMENT_PATTERNS = [
|
|
206
|
+
/plan does(?:n't| not) (?:include|support)/i,
|
|
207
|
+
/not included (?:in|with) your .{0,40}plan/i,
|
|
208
|
+
/upgrade to [\w ]{1,30}(?:or higher|plan)/i,
|
|
209
|
+
/no api access/i,
|
|
210
|
+
];
|
|
211
|
+
// Balance or usage window used up. Chinese-market providers report it in
|
|
212
|
+
// Chinese, which is why the literal strings are here rather than a rule.
|
|
213
|
+
const QUOTA_PATTERNS = [
|
|
214
|
+
/insufficient[_\s]quota/i,
|
|
215
|
+
/exceeded your current quota/i,
|
|
216
|
+
/insufficient (?:balance|credits?)/i,
|
|
217
|
+
/credit balance is too low/i,
|
|
218
|
+
/(?:no|out of) credits/i,
|
|
219
|
+
// Both word orders occur in the wild.
|
|
220
|
+
/usage limits? (?:reached|exceeded|hit)/i,
|
|
221
|
+
/reached your (?:usage|weekly|monthly|daily) limit/i,
|
|
222
|
+
/(?:weekly|monthly|daily|plan) usage limit/i,
|
|
223
|
+
/purchase extra usage/i,
|
|
224
|
+
/upgrade your plan/i,
|
|
225
|
+
/quota\b[^.]{0,40}\b(?:exhausted|exceeded|will be refreshed)/i,
|
|
226
|
+
/balance (?:is )?(?:too low|not enough|insufficient)/i,
|
|
227
|
+
/per\s*day|PerDay|insufficient_quota|billing/i,
|
|
228
|
+
/余额不足/,
|
|
229
|
+
/欠费/,
|
|
230
|
+
/额度(?:不足|已用完)/,
|
|
231
|
+
];
|
|
232
|
+
const MODEL_PATTERNS = [
|
|
233
|
+
/(?:model|models\/)[^.{\n]{0,40}(?:not found|does not exist|unknown)/i,
|
|
234
|
+
/no model named/i,
|
|
235
|
+
/unsupported model/i,
|
|
236
|
+
];
|
|
237
|
+
const AUTH_PATTERNS = [
|
|
238
|
+
/invalid (?:x-api-key|api[ _-]?key|token|credentials?)/i,
|
|
239
|
+
/api[ _-]?key (?:is )?(?:not valid|invalid|incorrect)/i,
|
|
240
|
+
/unauthorized|UNAUTHENTICATED|PERMISSION_DENIED/i,
|
|
241
|
+
/authentication[_\s](?:failed|invalid|error)/i,
|
|
242
|
+
/account (?:disabled|suspended|deactivated|banned)/i,
|
|
243
|
+
];
|
|
244
|
+
const CONTENT_PATTERNS = [
|
|
245
|
+
/content[_\s]filter/i,
|
|
246
|
+
/content policy/i,
|
|
247
|
+
/safety|PROHIBITED_CONTENT|blocked|refusal/i,
|
|
248
|
+
];
|
|
249
|
+
/** Theirs and temporary, said in words rather than a status. Gemini reports
|
|
250
|
+
* UNAVAILABLE/INTERNAL in the body; gateways say "capacity". */
|
|
251
|
+
const OVERLOAD_PATTERNS = [
|
|
252
|
+
/overloaded|overloaded_error/i,
|
|
253
|
+
/\bunavailable\b|UNAVAILABLE/,
|
|
254
|
+
/internal error|INTERNAL/,
|
|
255
|
+
/\bcapacity\b/i,
|
|
256
|
+
/"code"\s*:\s*5\d\d/,
|
|
257
|
+
];
|
|
258
|
+
const matches = (patterns, text) => patterns.some((pattern) => pattern.test(text));
|
|
259
|
+
/**
|
|
260
|
+
* The kind of failure, from whatever was thrown.
|
|
261
|
+
*
|
|
262
|
+
* Body patterns outrank status for the 4xx family; within them, context beats
|
|
263
|
+
* entitlement beats quota beats auth — each earlier category's fix is useless
|
|
264
|
+
* for the later ones.
|
|
265
|
+
*/
|
|
266
|
+
export function classify(err, status, body) {
|
|
267
|
+
if (isAbort(err))
|
|
268
|
+
return "aborted";
|
|
269
|
+
if (isTransportFailure(err))
|
|
270
|
+
return "network";
|
|
271
|
+
const code = status ?? readNumber(err, "status");
|
|
272
|
+
const text = body ?? bodyTextOf(err);
|
|
273
|
+
const name = readString(err, "name");
|
|
274
|
+
if (name === "TimeoutError" || code === 408)
|
|
275
|
+
return "timeout";
|
|
276
|
+
// Context first: a 429 whose body says "too many tokens" is either a
|
|
277
|
+
// per-minute rate limit or an oversized prompt, and only the wordings here —
|
|
278
|
+
// which name the WINDOW, not the rate — land on context. Compaction is the
|
|
279
|
+
// fix, and unlike "wait" it is one the caller can act on immediately.
|
|
280
|
+
const clientError = code === undefined || code < 500;
|
|
281
|
+
if (clientError && matches(CONTEXT_PATTERNS, text))
|
|
282
|
+
return "context";
|
|
283
|
+
if (clientError && matches(ENTITLEMENT_PATTERNS, text))
|
|
284
|
+
return "entitlement";
|
|
285
|
+
if (clientError && matches(QUOTA_PATTERNS, text))
|
|
286
|
+
return "quota";
|
|
287
|
+
if (matches(MODEL_PATTERNS, text))
|
|
288
|
+
return "model";
|
|
289
|
+
if (code === 401 || code === 403 || matches(AUTH_PATTERNS, text))
|
|
290
|
+
return "auth";
|
|
291
|
+
if (code === 402)
|
|
292
|
+
return "quota";
|
|
293
|
+
if (code === 404)
|
|
294
|
+
return "model";
|
|
295
|
+
if (code === 429)
|
|
296
|
+
return "rate";
|
|
297
|
+
if (matches(CONTENT_PATTERNS, text))
|
|
298
|
+
return "content";
|
|
299
|
+
// 529 is Anthropic's own "overloaded". 409 is how several gateways say
|
|
300
|
+
// "the model is still loading" — both are worth another attempt.
|
|
301
|
+
if (code === 529 || code === 409)
|
|
302
|
+
return "overload";
|
|
303
|
+
if (code !== undefined && code >= 500)
|
|
304
|
+
return "overload";
|
|
305
|
+
if (matches(OVERLOAD_PATTERNS, text))
|
|
306
|
+
return "overload";
|
|
307
|
+
if (/timed out|timeout/i.test(text))
|
|
308
|
+
return "timeout";
|
|
309
|
+
if (code !== undefined && code >= 400)
|
|
310
|
+
return "invalid";
|
|
311
|
+
return "unknown";
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* How long the provider asked us to wait, in ms. Two dialects: Gemini's
|
|
315
|
+
* RetryInfo (`"retryDelay": "52s"`, inside the body) and the `Retry-After`
|
|
316
|
+
* header, which SDKs keep on the error. Honouring it beats guessing — a
|
|
317
|
+
* backoff shorter than the window just burns an attempt.
|
|
318
|
+
*/
|
|
319
|
+
export function parseRetryAfterMs(err, body) {
|
|
320
|
+
const text = body ?? bodyTextOf(err);
|
|
321
|
+
const delay = text.match(/"?retryDelay"?\s*[:=]\s*"?(\d+(?:\.\d+)?)s"?/i);
|
|
322
|
+
if (delay?.[1])
|
|
323
|
+
return Math.round(parseFloat(delay[1]) * 1000);
|
|
324
|
+
if (typeof err !== "object" || err === null)
|
|
325
|
+
return undefined;
|
|
326
|
+
const headers = err.headers;
|
|
327
|
+
const value = headers instanceof Headers
|
|
328
|
+
? headers.get("retry-after")
|
|
329
|
+
: typeof headers === "object" && headers !== null
|
|
330
|
+
? headers["retry-after"]
|
|
331
|
+
: undefined;
|
|
332
|
+
if (typeof value !== "string")
|
|
333
|
+
return undefined;
|
|
334
|
+
// Seconds, or an HTTP-date — both are legal per RFC 9110.
|
|
335
|
+
if (/^\d+$/.test(value))
|
|
336
|
+
return Number(value) * 1000;
|
|
337
|
+
const date = Date.parse(value);
|
|
338
|
+
return Number.isNaN(date) ? undefined : Math.max(0, date - Date.now());
|
|
339
|
+
}
|
|
340
|
+
/** The loggable surface of a failure — so a dead run never reads
|
|
341
|
+
* "400 status code (no body)". */
|
|
342
|
+
export function describeProviderError(err) {
|
|
343
|
+
if (err instanceof ProviderError) {
|
|
344
|
+
return {
|
|
345
|
+
provider: err.provider,
|
|
346
|
+
kind: err.kind,
|
|
347
|
+
status: err.status,
|
|
348
|
+
code: err.code,
|
|
349
|
+
retryAfterMs: err.retryAfterMs,
|
|
350
|
+
error: err.message,
|
|
351
|
+
body: err.body,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
return { error: messageOf(err), kind: classify(err) };
|
|
355
|
+
}
|
|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EAAE,GAAG,CAAC,IAAI;YACd,YAAY,EAAE,GAAG,CAAC,YAAY;YAC9B,KAAK,EAAE,GAAG,CAAC,OAAO;YAClB,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;AACxD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./types.ts";
|
|
2
|
+
export * from "./errors.ts";
|
|
3
|
+
export * from "./retry.ts";
|
|
4
|
+
export * from "./watchdog.ts";
|
|
5
|
+
export * from "./usage.ts";
|
|
6
|
+
export * from "./transport.ts";
|
|
7
|
+
export * from "./tool-args.ts";
|
|
8
|
+
export * from "./tools.ts";
|
|
9
|
+
export * from "./schema.ts";
|
|
10
|
+
export * from "./context.ts";
|
|
11
|
+
export * from "./providers/anthropic.ts";
|
|
12
|
+
export * from "./providers/openai.ts";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * from "./retry.js";
|
|
4
|
+
export * from "./watchdog.js";
|
|
5
|
+
export * from "./usage.js";
|
|
6
|
+
export * from "./transport.js";
|
|
7
|
+
export * from "./tool-args.js";
|
|
8
|
+
export * from "./tools.js";
|
|
9
|
+
export * from "./schema.js";
|
|
10
|
+
export * from "./context.js";
|
|
11
|
+
export * from "./providers/anthropic.js";
|
|
12
|
+
export * from "./providers/openai.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ChatMessage, Effort, Provider } from "../types.ts";
|
|
2
|
+
export interface AnthropicConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
model: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Bound default; a per-call `effort` overrides it. */
|
|
7
|
+
effort?: Effort;
|
|
8
|
+
/** Anthropic requires an output ceiling on every request. */
|
|
9
|
+
maxTokens?: number;
|
|
10
|
+
version?: string;
|
|
11
|
+
fetchImpl?: typeof fetch;
|
|
12
|
+
/** Send the key as a Bearer instead of `x-api-key` — what a subscription
|
|
13
|
+
* access token needs. */
|
|
14
|
+
bearer?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Anthropic takes `system` at the top level and expects tool RESULTS as user
|
|
18
|
+
* turns carrying `tool_result` blocks — not as a role of their own. Consecutive
|
|
19
|
+
* tool results are merged into one user turn, which the API requires.
|
|
20
|
+
*/
|
|
21
|
+
export declare function toAnthropicMessages(messages: readonly ChatMessage[]): {
|
|
22
|
+
system?: string;
|
|
23
|
+
messages: unknown[];
|
|
24
|
+
};
|
|
25
|
+
export declare function createAnthropicProvider(config: AnthropicConfig): Provider;
|
|
26
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EAEN,QAAQ,EAIT,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB;8BAC0B;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AA+CD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAoDA;AAiCD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,QAAQ,CAmJzE"}
|