@absolutejs/ai 0.2.9 → 0.2.11

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 CHANGED
@@ -6,6 +6,18 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.2.11 — 2026-09-27
10
+
11
+ ### Changed
12
+
13
+ - **Name capacity HTTP metadata providerStatus instead of status so application HTTP frameworks do not treat an upstream billing/auth 4xx as a caller error and skip server-error capture. Preserve provider diagnostics and request IDs. Supersedes 0.2.10.** (`AIInputError`, `inspectAIInput`)
14
+
15
+ ## 0.2.10 — 2026-09-27
16
+
17
+ ### Changed
18
+
19
+ - **Add optional HTTP status and request ID to AIInputError and preserve bounded provider failure reasons across capacity checks and bundled provider entry points, so billing and rate-limit failures remain diagnosable.** (`AIInputError`, `inspectAIInput`, `anthropic`, `gemini`, `openaiResponses`)
20
+
9
21
  ## 0.2.9 — 2026-09-25
10
22
 
11
23
  ### Added
package/changelog.json CHANGED
@@ -2,6 +2,37 @@
2
2
  "contract": 1,
3
3
  "name": "@absolutejs/ai",
4
4
  "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "changed",
9
+ "summary": "Name capacity HTTP metadata providerStatus instead of status so application HTTP frameworks do not treat an upstream billing/auth 4xx as a caller error and skip server-error capture. Preserve provider diagnostics and request IDs. Supersedes 0.2.10.",
10
+ "symbols": [
11
+ "AIInputError",
12
+ "inspectAIInput"
13
+ ]
14
+ }
15
+ ],
16
+ "date": "2026-09-27",
17
+ "version": "0.2.11"
18
+ },
19
+ {
20
+ "changes": [
21
+ {
22
+ "kind": "changed",
23
+ "summary": "Add optional HTTP status and request ID to AIInputError and preserve bounded provider failure reasons across capacity checks and bundled provider entry points, so billing and rate-limit failures remain diagnosable.",
24
+ "symbols": [
25
+ "AIInputError",
26
+ "inspectAIInput",
27
+ "anthropic",
28
+ "gemini",
29
+ "openaiResponses"
30
+ ]
31
+ }
32
+ ],
33
+ "date": "2026-09-27",
34
+ "version": "0.2.10"
35
+ },
5
36
  {
6
37
  "changes": [
7
38
  {
package/dist/ai/index.js CHANGED
@@ -4,9 +4,13 @@ var __require = import.meta.require;
4
4
  // src/ai/inputCapacity.ts
5
5
  class AIInputError extends Error {
6
6
  code;
7
- constructor(code, message) {
7
+ providerStatus;
8
+ requestId;
9
+ constructor(code, message, providerStatus, requestId) {
8
10
  super(message);
9
11
  this.code = code;
12
+ this.providerStatus = providerStatus;
13
+ this.requestId = requestId;
10
14
  this.name = "AIInputError";
11
15
  }
12
16
  }
@@ -29,7 +33,7 @@ var inspectAIInput = async (provider, params) => {
29
33
  provider.inputCapacity.countTokens(params)
30
34
  ]).catch((error) => {
31
35
  if (error instanceof Error && error.name === "AIInputError" && "code" in error && (error.code === "capacity_unavailable" || error.code === "input_too_large" || error.code === "unsupported_content"))
32
- throw new AIInputError(error.code, error.message);
36
+ throw new AIInputError(error.code, error.message, "providerStatus" in error && typeof error.providerStatus === "number" ? error.providerStatus : undefined, "requestId" in error && typeof error.requestId === "string" ? error.requestId : undefined);
33
37
  throw error;
34
38
  });
35
39
  const inputTokens = inputTokenCount(tokens);
@@ -62,8 +66,18 @@ var cacheModelLimits = (load, ttlMs = 300000) => {
62
66
  };
63
67
  };
64
68
  var capacityJson = async (response) => {
65
- if (!response.ok)
66
- throw new AIInputError("capacity_unavailable", `Model capacity request failed (${response.status}).`);
69
+ if (!response.ok) {
70
+ const payload = await response.json().catch(() => {
71
+ return;
72
+ });
73
+ const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : undefined;
74
+ const providerError = record?.error;
75
+ const nested = providerError && typeof providerError === "object" && !Array.isArray(providerError) ? providerError : undefined;
76
+ const message = nested?.message ?? record?.message;
77
+ const detail = typeof message === "string" ? message.slice(0, 1000) : undefined;
78
+ const id = response.headers.get("request-id") ?? response.headers.get("x-request-id") ?? record?.request_id;
79
+ throw new AIInputError("capacity_unavailable", `Model capacity request failed (${response.status}).${detail ? ` ${detail}` : ""}`, response.status, typeof id === "string" ? id.slice(0, 200) : undefined);
80
+ }
67
81
  const value = await response.json();
68
82
  if (!value || typeof value !== "object" || Array.isArray(value))
69
83
  throw new AIInputError("capacity_unavailable", "Model capacity response was invalid.");
@@ -8909,5 +8923,5 @@ export {
8909
8923
  xai
8910
8924
  };
8911
8925
 
8912
- //# debugId=E09A768F1F0FB95564756E2164756E21
8926
+ //# debugId=DDEEE4C7832FA25964756E2164756E21
8913
8927
  //# sourceMappingURL=index.js.map