@vincemakes/kiso-provider-anthropic 0.26.0 → 0.26.2
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/index.js +12 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* The id in the start block IS the callId the kernel echoes back.
|
|
14
14
|
*/
|
|
15
15
|
import Anthropic from "@anthropic-ai/sdk";
|
|
16
|
-
import { mapApiError } from "@vincemakes/kiso-core";
|
|
16
|
+
import { mapApiError, parseRetryAfter } from "@vincemakes/kiso-core";
|
|
17
17
|
/**
|
|
18
18
|
* High-level factory (round 7): builds the adapter FROM CONFIG, owning the SDK
|
|
19
19
|
* inside this package. Consumers (and the runtime's lazy provider path)
|
|
@@ -25,6 +25,8 @@ export function createAnthropicProvider(config = {}) {
|
|
|
25
25
|
const client = new Anthropic({
|
|
26
26
|
...(config.apiKey !== undefined ? { apiKey: config.apiKey } : {}),
|
|
27
27
|
...(config.baseUrl !== undefined ? { baseURL: config.baseUrl } : {}),
|
|
28
|
+
// CX-1 F8: ONE retry authority — the kernel (see the openai factory).
|
|
29
|
+
maxRetries: 0,
|
|
28
30
|
});
|
|
29
31
|
return createAnthropicAdapter(client, { ...(config.promptCaching !== undefined ? { promptCaching: config.promptCaching } : {}) });
|
|
30
32
|
}
|
|
@@ -379,6 +381,13 @@ function toAnthropicTools(tools) {
|
|
|
379
381
|
input_schema: t.inputSchema,
|
|
380
382
|
}));
|
|
381
383
|
}
|
|
384
|
+
function retryAfterOf(headers) {
|
|
385
|
+
if (headers === null || typeof headers !== "object")
|
|
386
|
+
return undefined;
|
|
387
|
+
const h = headers;
|
|
388
|
+
const raw = typeof h.get === "function" ? h.get("retry-after") : (h["retry-after"] ?? h["Retry-After"]);
|
|
389
|
+
return parseRetryAfter(typeof raw === "string" ? raw : undefined);
|
|
390
|
+
}
|
|
382
391
|
function toAnthropicError(err) {
|
|
383
392
|
// P3 (0.1.42): the honest label — every real-provider error names its
|
|
384
393
|
// provider, so a terminal never reads as a scripted-model failure.
|
|
@@ -391,7 +400,8 @@ function toAnthropicError(err) {
|
|
|
391
400
|
return { code: "network", retryable: true, message: label + err.message };
|
|
392
401
|
}
|
|
393
402
|
if (err instanceof Anthropic.APIError) {
|
|
394
|
-
|
|
403
|
+
// CX-1 F8: the kernel owns retries — Retry-After travels with the error
|
|
404
|
+
return mapApiError(err.status, label + err.message, retryAfterOf(err.headers));
|
|
395
405
|
}
|
|
396
406
|
return err;
|
|
397
407
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vincemakes/kiso-provider-anthropic",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
4
4
|
"description": "kiso Anthropic adapter — official SDK wire events mapped to the kiso event union.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@anthropic-ai/sdk": "^0.115.0",
|
|
25
|
-
"@vincemakes/kiso-core": "0.26.
|
|
25
|
+
"@vincemakes/kiso-core": "0.26.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^26.1.2",
|