@2kw/ai 6.2.0-dev.13 → 6.2.0-dev.23
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/lib/client.d.ts +2 -0
- package/dist/lib/client.js +9 -2
- package/dist/lib/errors.d.ts +9 -2
- package/package.json +1 -1
package/dist/lib/client.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface SessionAuthDeps {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Error-handling middleware: intercepts non-ok responses and throws BackboneApiError.
|
|
26
|
+
* The api-key filter now returns the OpenAI envelope (#658); the surface
|
|
27
|
+
* filter still sends the flat shape, so both are normalized here.
|
|
26
28
|
*/
|
|
27
29
|
export declare const errorMiddleware: Middleware;
|
|
28
30
|
/**
|
package/dist/lib/client.js
CHANGED
|
@@ -9,6 +9,8 @@ import { BackboneApiError, handleError } from "./errors.js";
|
|
|
9
9
|
export const RETRY_MARKER = "x-2kw-auth-retried";
|
|
10
10
|
/**
|
|
11
11
|
* Error-handling middleware: intercepts non-ok responses and throws BackboneApiError.
|
|
12
|
+
* The api-key filter now returns the OpenAI envelope (#658); the surface
|
|
13
|
+
* filter still sends the flat shape, so both are normalized here.
|
|
12
14
|
*/
|
|
13
15
|
export const errorMiddleware = {
|
|
14
16
|
async onResponse({ response }) {
|
|
@@ -23,8 +25,13 @@ export const errorMiddleware = {
|
|
|
23
25
|
}
|
|
24
26
|
throw new BackboneApiError({
|
|
25
27
|
status: body.status ?? response.status,
|
|
26
|
-
error:
|
|
27
|
-
|
|
28
|
+
error: typeof body.error === "string"
|
|
29
|
+
? body.error
|
|
30
|
+
: (body.error?.code ?? body.error?.type ?? body.title ?? response.statusText),
|
|
31
|
+
message: body.detail ??
|
|
32
|
+
body.message ??
|
|
33
|
+
body.error?.message ??
|
|
34
|
+
`HTTP ${response.status}: ${response.statusText}`,
|
|
28
35
|
timestamp: body.timestamp ?? new Date().toISOString(),
|
|
29
36
|
});
|
|
30
37
|
},
|
package/dist/lib/errors.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export interface ApiErrorBody {
|
|
2
2
|
status: number;
|
|
3
|
-
error
|
|
3
|
+
error?: string | {
|
|
4
|
+
message?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
param?: string | null;
|
|
7
|
+
code?: string | null;
|
|
8
|
+
};
|
|
4
9
|
message: string;
|
|
5
10
|
timestamp: string;
|
|
6
11
|
}
|
|
@@ -8,7 +13,9 @@ export declare class BackboneApiError extends Error {
|
|
|
8
13
|
readonly status: number;
|
|
9
14
|
readonly errorType: string;
|
|
10
15
|
readonly timestamp: string;
|
|
11
|
-
constructor(body: ApiErrorBody
|
|
16
|
+
constructor(body: Omit<ApiErrorBody, "error"> & {
|
|
17
|
+
error: string;
|
|
18
|
+
});
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* Discriminated cause of a failed credential check. Lets callers give a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2kw/ai",
|
|
3
|
-
"version": "6.2.0-dev.
|
|
3
|
+
"version": "6.2.0-dev.23",
|
|
4
4
|
"description": "CLI for 2kw.ai — schema-driven document extraction, an OpenAI-compatible EU LLM gateway, transcription, prompts, datasets, and experiments from your terminal or agentic workflows. Ships as 2kw, backbone, and bb.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|