@mccaskie-labs/workbench-ai 0.1.2 → 0.1.3
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/CHANGELOG.md +6 -0
- package/dist/errors.d.ts +5 -1
- package/dist/errors.js +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @mccaskie-labs/workbench-ai
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Two new error codes for the Workbench content rules (`docs/spec.md` §2.7): `content_refused` (never retryable; `details.rule`, `details.stage` and `details.rulesVersion` say which rule refused it and where) and `content_check_unavailable` (retryable). Before this a streamed refusal surfaced as a retryable `network` error.
|
|
8
|
+
|
|
3
9
|
## 0.1.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type AiErrorCode = "refused" | "truncated" | "invalid_output" | "unexpected_stop" | "unauthorised" | "forbidden_scope" | "invalid_request" | "model_not_allowed" | "budget_exceeded" | "rate_limited" | "not_found" | "not_available" | "upstream_error" | "upstream_timeout" | "internal_error" | "network" | "invalid_config";
|
|
1
|
+
export type AiErrorCode = "refused" | "truncated" | "invalid_output" | "unexpected_stop" | "unauthorised" | "forbidden_scope" | "invalid_request" | "model_not_allowed" | "budget_exceeded" | "content_refused" | "content_check_unavailable" | "rate_limited" | "not_found" | "not_available" | "upstream_error" | "upstream_timeout" | "internal_error" | "network" | "invalid_config";
|
|
2
2
|
export interface AiErrorDetails {
|
|
3
3
|
requestId?: string;
|
|
4
4
|
upstreamStatus?: number;
|
|
@@ -12,6 +12,10 @@ export interface AiErrorDetails {
|
|
|
12
12
|
month?: string;
|
|
13
13
|
spentUsd?: number;
|
|
14
14
|
capUsd?: number;
|
|
15
|
+
/** For `content_refused`: the rule (`R2`, or `vendor` for a vendor's own safety block), the stage and the rules version. */
|
|
16
|
+
rule?: string;
|
|
17
|
+
stage?: "input" | "output";
|
|
18
|
+
rulesVersion?: string;
|
|
15
19
|
}
|
|
16
20
|
export declare class WorkbenchAiError extends Error {
|
|
17
21
|
readonly code: AiErrorCode;
|
package/dist/errors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Every failure the package raises is a WorkbenchAiError with a stable code
|
|
2
2
|
// (docs/spec.md §3). Callers branch on `code`, never on the message. A refusal
|
|
3
3
|
// or a max_tokens truncation is an error, never a partial success (audit F18).
|
|
4
|
-
const RETRYABLE = new Set(["rate_limited", "upstream_error", "upstream_timeout", "network"]);
|
|
4
|
+
const RETRYABLE = new Set(["rate_limited", "content_check_unavailable", "upstream_error", "upstream_timeout", "network"]);
|
|
5
5
|
export class WorkbenchAiError extends Error {
|
|
6
6
|
code;
|
|
7
7
|
retryable;
|
|
@@ -26,6 +26,8 @@ const KNOWN = new Set([
|
|
|
26
26
|
"invalid_request",
|
|
27
27
|
"model_not_allowed",
|
|
28
28
|
"budget_exceeded",
|
|
29
|
+
"content_refused",
|
|
30
|
+
"content_check_unavailable",
|
|
29
31
|
"rate_limited",
|
|
30
32
|
"not_found",
|
|
31
33
|
"not_available",
|
|
@@ -96,5 +98,11 @@ export function errorFromGateway(status, body, requestId) {
|
|
|
96
98
|
details.spentUsd = err["spent_usd"];
|
|
97
99
|
if (typeof err["cap_usd"] === "number")
|
|
98
100
|
details.capUsd = err["cap_usd"];
|
|
101
|
+
if (typeof err["rule"] === "string")
|
|
102
|
+
details.rule = err["rule"];
|
|
103
|
+
if (err["stage"] === "input" || err["stage"] === "output")
|
|
104
|
+
details.stage = err["stage"];
|
|
105
|
+
if (typeof err["rules_version"] === "string")
|
|
106
|
+
details.rulesVersion = err["rules_version"];
|
|
99
107
|
return new WorkbenchAiError(code, message, details);
|
|
100
108
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-ai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Claude through the Workbench Gateway: text, structured output, streaming and budget status, with no Anthropic key in the app. Refusals and truncations throw; createFakeAi for tests.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|