@tensorcost/sdk 1.3.3 → 1.5.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +226 -1
  2. package/README.md +35 -16
  3. package/dist/admit-client.d.ts +56 -0
  4. package/dist/admit-client.d.ts.map +1 -1
  5. package/dist/admit-client.js +93 -11
  6. package/dist/admit-client.js.map +1 -1
  7. package/dist/applied.d.ts +114 -0
  8. package/dist/applied.d.ts.map +1 -1
  9. package/dist/applied.js +40 -50
  10. package/dist/applied.js.map +1 -1
  11. package/dist/errors.d.ts +179 -24
  12. package/dist/errors.d.ts.map +1 -1
  13. package/dist/errors.js +165 -23
  14. package/dist/errors.js.map +1 -1
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +2 -2
  18. package/dist/index.js.map +1 -1
  19. package/dist/provider-errors.d.ts +15 -0
  20. package/dist/provider-errors.d.ts.map +1 -0
  21. package/dist/provider-errors.js +69 -0
  22. package/dist/provider-errors.js.map +1 -0
  23. package/dist/providers/anthropic.d.ts +54 -0
  24. package/dist/providers/anthropic.d.ts.map +1 -1
  25. package/dist/providers/anthropic.js +57 -14
  26. package/dist/providers/anthropic.js.map +1 -1
  27. package/dist/providers/bedrock.d.ts +4 -1
  28. package/dist/providers/bedrock.d.ts.map +1 -1
  29. package/dist/providers/bedrock.js +3 -2
  30. package/dist/providers/bedrock.js.map +1 -1
  31. package/dist/providers/detect.d.ts.map +1 -1
  32. package/dist/providers/detect.js +9 -6
  33. package/dist/providers/detect.js.map +1 -1
  34. package/dist/providers/openai.d.ts.map +1 -1
  35. package/dist/providers/openai.js +21 -44
  36. package/dist/providers/openai.js.map +1 -1
  37. package/dist/providers/vertex.d.ts +17 -0
  38. package/dist/providers/vertex.d.ts.map +1 -1
  39. package/dist/providers/vertex.js +5 -2
  40. package/dist/providers/vertex.js.map +1 -1
  41. package/dist/proxy-client.d.ts +157 -0
  42. package/dist/proxy-client.d.ts.map +1 -1
  43. package/dist/proxy-client.js +189 -175
  44. package/dist/proxy-client.js.map +1 -1
  45. package/dist/refusal.d.ts +43 -0
  46. package/dist/refusal.d.ts.map +1 -0
  47. package/dist/refusal.js +154 -0
  48. package/dist/refusal.js.map +1 -0
  49. package/dist/transport.d.ts.map +1 -1
  50. package/dist/transport.js +45 -13
  51. package/dist/transport.js.map +1 -1
  52. package/dist/types.d.ts +15 -1
  53. package/dist/types.d.ts.map +1 -1
  54. package/dist/version.d.ts +1 -1
  55. package/dist/version.js +1 -1
  56. package/dist/wrap-overhead.d.ts +43 -0
  57. package/dist/wrap-overhead.d.ts.map +1 -1
  58. package/dist/wrap-overhead.js +28 -1
  59. package/dist/wrap-overhead.js.map +1 -1
  60. package/dist/wrap.d.ts +25 -0
  61. package/dist/wrap.d.ts.map +1 -1
  62. package/dist/wrap.js +51 -8
  63. package/dist/wrap.js.map +1 -1
  64. package/package.json +1 -1
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Applied-mode wiring — Layer 2.
3
+ *
4
+ * When the customer opts into applied mode, the SDK routes every inference
5
+ * request through the TensorCost inference-proxy instead of directly to the
6
+ * upstream AI provider. The proxy decides per-request whether to re-route
7
+ * or pass through unchanged; the SDK doesn't make that call.
8
+ *
9
+ * The mechanism is straightforward: at `wrap()` time we read the
10
+ * provider's original baseURL and auth from the client, permanently
11
+ * redirect the client's baseURL to the proxy endpoint, and inject two
12
+ * custom headers the proxy expects:
13
+ *
14
+ * x-tc-provider-url — the original provider base URL
15
+ * x-tc-provider-auth — the auth header value to forward upstream
16
+ *
17
+ * Both the OpenAI SDK and the Anthropic SDK expose `baseURL` and
18
+ * `defaultHeaders` as first-class properties, so we can set them
19
+ * without monkey-patching the HTTP layer.
20
+ *
21
+ * Bedrock is not supported in v1. The AWS SDK uses SigV4 signing on
22
+ * regional endpoints and doesn't expose baseURL / defaultHeaders in
23
+ * the same shape. Passing a Bedrock-shaped client with appliedMode=true
24
+ * throws `TensorCostConfigError` at wrap time.
25
+ *
26
+ * Observe-only telemetry (the 0.2.x substrate) continues to fire
27
+ * after every call regardless of this setting.
28
+ */
29
+ /**
30
+ * Client shapes we understand. All detection is duck-typed; no import
31
+ * of the actual openai or @anthropic-ai/sdk packages.
32
+ */
33
+ /** Header value the proxy expects for OpenAI + Azure OpenAI. */
34
+ declare function bearerAuth(apiKey: string): string;
35
+ /** Header value the proxy expects for Anthropic. */
36
+ declare function anthropicAuth(apiKey: string): string;
37
+ /**
38
+ * Read the original baseURL from a duck-typed client. Both the OpenAI
39
+ * and Anthropic SDKs expose a `baseURL` string property on the client
40
+ * instance (the actual HTTP origin, e.g. "https://api.openai.com/v1").
41
+ * Returns null when the property is absent or not a string.
42
+ */
43
+ declare function readBaseUrl(client: Record<string, unknown>): string | null;
44
+ /**
45
+ * Read the API key from the client. OpenAI SDK exposes `client.apiKey`;
46
+ * Anthropic SDK exposes `client.apiKey` too. Returns null when absent.
47
+ */
48
+ declare function readApiKey(client: Record<string, unknown>): string | null;
49
+ /**
50
+ * Detect whether this client looks like an Azure OpenAI client (the
51
+ * openai package's `AzureOpenAI` subclass). Azure uses `api-key` header
52
+ * auth and a custom endpoint URL, so the auth value we forward differs
53
+ * from vanilla OpenAI.
54
+ *
55
+ * Detection: Azure clients have an `azure` property set to true, OR
56
+ * their baseURL contains `.openai.azure.com`.
57
+ */
58
+ declare function isAzureOpenAI(client: Record<string, unknown>): boolean;
59
+ /**
60
+ * Azure OpenAI uses an `api-key` header rather than `Authorization: Bearer`.
61
+ * The proxy forwards `x-tc-provider-auth` verbatim as the upstream auth
62
+ * header, so we need to format it as the proxy expects: "api-key <value>".
63
+ *
64
+ * Note: The proxy currently only supports `Authorization` and `api-key`
65
+ * style headers. This value is forwarded in the `x-tc-provider-auth`
66
+ * header and then sent by the proxy as the upstream Authorization.
67
+ */
68
+ declare function azureAuth(apiKey: string): string;
69
+ /**
70
+ * Check a client can be used in applied mode. Called once by `wrap()`.
71
+ *
72
+ * Since 1.5.0 it changes nothing on the client (see the note at the end);
73
+ * the wrapper sends the proxied call itself with the values from
74
+ * `providerTarget()`.
75
+ *
76
+ * @param client - The customer's AI SDK client (duck-typed).
77
+ * @param proxyUrl - The TensorCost proxy base URL (already stripped of trailing slash).
78
+ * @param provider - "openai" | "anthropic", as detected by detectProvider().
79
+ *
80
+ * @throws TensorCostConfigError
81
+ * - If the client doesn't expose `baseURL` (can't determine the original
82
+ * provider URL to forward in `x-tc-provider-url`).
83
+ * - If the client doesn't expose `apiKey` (can't build `x-tc-provider-auth`).
84
+ * - If the provider is "bedrock" (not yet supported in v1).
85
+ */
86
+ export declare function installAppliedMode(client: unknown, proxyUrl: string, provider: "openai" | "anthropic", scope?: {
87
+ application?: string | null;
88
+ tags?: string[];
89
+ customer?: string | null;
90
+ feature?: string | null;
91
+ teamId?: string | null;
92
+ }): void;
93
+ /**
94
+ * Where the proxy should forward this client's call: the client's own base
95
+ * URL and its auth, formatted for `x-tc-provider-url` / `x-tc-provider-auth`.
96
+ *
97
+ * A client that already carries those as plain `defaultHeaders` entries
98
+ * (callers who set them by hand) keeps them.
99
+ */
100
+ export declare function providerTarget(client: unknown, provider: "openai" | "anthropic", defaultUrl: string): {
101
+ providerUrl: string;
102
+ providerAuth: string;
103
+ };
104
+ export declare const PROXY_PATH_SUFFIX = "/api/inference-proxy/v1/chat/completions";
105
+ export declare const __test__: {
106
+ readBaseUrl: typeof readBaseUrl;
107
+ readApiKey: typeof readApiKey;
108
+ isAzureOpenAI: typeof isAzureOpenAI;
109
+ bearerAuth: typeof bearerAuth;
110
+ anthropicAuth: typeof anthropicAuth;
111
+ azureAuth: typeof azureAuth;
112
+ };
113
+ export {};
114
+ //# sourceMappingURL=applied.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"applied.d.ts","sourceRoot":"","sources":["../src/applied.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAOH;;;GAGG;AAEH,gE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O,MAAM,QAAQ;;;;;;;CAOpB,CAAC"}
package/dist/applied.js CHANGED
@@ -90,12 +90,11 @@ function azureAuth(apiKey) {
90
90
  return `api-key ${apiKey}`;
91
91
  }
92
92
  /**
93
- * Install applied-mode routing on the client. Called once by `wrap()`.
93
+ * Check a client can be used in applied mode. Called once by `wrap()`.
94
94
  *
95
- * Mutates `client.baseURL` to point at the proxy endpoint and injects
96
- * `x-tc-provider-url` / `x-tc-provider-auth` into `client.defaultHeaders`.
97
- * These headers survive for the lifetime of the client — every subsequent
98
- * request automatically carries them.
95
+ * Since 1.5.0 it changes nothing on the client (see the note at the end);
96
+ * the wrapper sends the proxied call itself with the values from
97
+ * `providerTarget()`.
99
98
  *
100
99
  * @param client - The customer's AI SDK client (duck-typed).
101
100
  * @param proxyUrl - The TensorCost proxy base URL (already stripped of trailing slash).
@@ -131,51 +130,42 @@ export function installAppliedMode(client, proxyUrl, provider, scope) {
131
130
  "property to forward provider auth. The client passed to wrap() does " +
132
131
  "not expose one.");
133
132
  }
134
- // Build the auth header value to forward. The proxy sends this value
135
- // as the upstream Authorization (or api-key) header verbatim.
136
- let providerAuth;
137
- if (provider === "anthropic") {
138
- providerAuth = anthropicAuth(apiKey);
139
- }
140
- else if (isAzureOpenAI(c)) {
141
- providerAuth = azureAuth(apiKey);
142
- }
143
- else {
144
- providerAuth = bearerAuth(apiKey);
145
- }
146
- // Redirect the client's base URL to the proxy. The path suffix
147
- // (/api/inference-proxy/v1) is appended here so that the OpenAI-compatible
148
- // client doesn't double-prepend its own /v1 path. Both the OpenAI and
149
- // Anthropic SDKs append the method path to baseURL; the proxy endpoint is
150
- // OpenAI-compatible, so the client will build:
151
- // baseURL + "/chat/completions"
152
- // We set baseURL to the proxy's parent path to get the right URL.
153
- const cleanProxyUrl = proxyUrl.replace(/\/+$/, "");
154
- c["baseURL"] = `${cleanProxyUrl}/api/inference-proxy/v1`;
155
- // Inject the custom headers into the client's defaultHeaders object.
156
- // Both SDKs merge defaultHeaders with every outgoing request.
157
- const existing = c["defaultHeaders"];
158
- const headers = existing && typeof existing === "object" && !Array.isArray(existing)
159
- ? existing
160
- : {};
161
- headers["x-tc-provider-url"] = originalBaseUrl;
162
- headers["x-tc-provider-auth"] = providerAuth;
163
- if (scope?.application) {
164
- headers["x-tc-application"] = scope.application;
165
- }
166
- if (scope?.tags && scope.tags.length > 0) {
167
- headers["x-tc-tags"] = scope.tags.join(",");
168
- }
169
- if (scope?.customer) {
170
- headers["x-tc-customer"] = scope.customer;
171
- }
172
- if (scope?.feature) {
173
- headers["x-tc-feature"] = scope.feature;
174
- }
175
- if (scope?.teamId) {
176
- headers["x-tc-team-id"] = scope.teamId;
177
- }
178
- c["defaultHeaders"] = headers;
133
+ // Nothing on the client is changed. Until 1.5.0 this rewrote
134
+ // `client.baseURL` to the proxy and replaced `client.defaultHeaders` with
135
+ // a plain object. openai@4 has `defaultHeaders()` as a method, so every
136
+ // call that reached the client's own request path (the fail-open
137
+ // fallback, and every call below steer) died with "this.defaultHeaders is
138
+ // not a function"; and the fallback, when it worked, went to the proxy
139
+ // URL rather than the provider. The SDK sends the proxied call itself, so
140
+ // the client only needs to be read, and `providerTarget()` reads it per
141
+ // call so a rotated key is picked up.
142
+ void scope;
143
+ }
144
+ function providerAuthFor(c, provider, apiKey) {
145
+ if (provider === "anthropic")
146
+ return anthropicAuth(apiKey);
147
+ if (isAzureOpenAI(c))
148
+ return azureAuth(apiKey);
149
+ return bearerAuth(apiKey);
150
+ }
151
+ /**
152
+ * Where the proxy should forward this client's call: the client's own base
153
+ * URL and its auth, formatted for `x-tc-provider-url` / `x-tc-provider-auth`.
154
+ *
155
+ * A client that already carries those as plain `defaultHeaders` entries
156
+ * (callers who set them by hand) keeps them.
157
+ */
158
+ export function providerTarget(client, provider, defaultUrl) {
159
+ const c = (client && typeof client === "object" ? client : {});
160
+ const dh = c["defaultHeaders"];
161
+ const manual = dh && typeof dh === "object" && !Array.isArray(dh) ? dh : {};
162
+ const manualUrl = typeof manual["x-tc-provider-url"] === "string" ? manual["x-tc-provider-url"] : null;
163
+ const manualAuth = typeof manual["x-tc-provider-auth"] === "string" ? manual["x-tc-provider-auth"] : null;
164
+ const apiKey = readApiKey(c);
165
+ return {
166
+ providerUrl: manualUrl ?? readBaseUrl(c) ?? defaultUrl,
167
+ providerAuth: manualAuth ?? (apiKey ? providerAuthFor(c, provider, apiKey) : ""),
168
+ };
179
169
  }
180
170
  export const PROXY_PATH_SUFFIX = PROXY_PATH;
181
171
  export const __test__ = {
@@ -1 +1 @@
1
- {"version":3,"file":"applied.js","sourceRoot":"","sources":["../src/applied.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,iDAAiD;AACjD,MAAM,UAAU,GAAG,0CAA0C,CAAC;AAE9D;;;GAGG;AAEH,gEAAgE;AAChE,SAAS,UAAU,CAAC,MAAc;IAChC,OAAO,UAAU,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED,oDAAoD;AACpD,SAAS,aAAa,CAAC,MAAc;IACnC,OAAO,aAAa,MAAM,EAAE,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,MAA+B;IAClD,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IAC9B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9C,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,MAA+B;IACjD,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,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AM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO;QACL,WAAW,EAAE,SAAS,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,UAAU;QACtD,YAAY,EAAE,UAAU,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACjF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAE5C,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,WAAW;IACX,UAAU;IACV,aAAa;IACb,UAAU;IACV,aAAa;IACb,SAAS;CACV,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -8,11 +8,27 @@
8
8
  * Hierarchy:
9
9
  *
10
10
  * TensorCostError (base)
11
- * ├── TensorCostNetworkError couldn't reach the proxy at all
12
- * ├── TensorCostTimeoutError request or idle window exceeded limit
13
- * ├── TensorCostProxyError proxy responded with 5xx
14
- * ├── TensorCostQuotaError proxy responded with 429
15
- * └── TensorCostProviderError proxy forwarded an upstream provider error
11
+ * ├── TensorCostNetworkError couldn't reach the proxy at all ┐
12
+ * ├── TensorCostTimeoutError request or idle window exceeded limit │ outages: the only
13
+ * ├── TensorCostProxyError proxy responded with 5xx │ errors that may fall
14
+ * ├── TensorCostQuotaError proxy 429, or 402 plan ceiling ┘ back to the provider
15
+ * ├── TensorCostProviderError proxy relayed an upstream provider 4xx
16
+ * │ (rethrown as the provider SDK's own error
17
+ * │ type when the client can build one)
18
+ * ├── TensorCostGatewayRejectedError non-JSON 4xx from in front of TensorCost
19
+ * ├── TensorCostKeyRejectedError token exchange rejected the API key
20
+ * └── TensorCostRefusedError TensorCost refused the call (terminal)
21
+ * ├── TensorCostRunBudgetExceededError
22
+ * ├── TensorCostRunStoppedError
23
+ * ├── TensorCostPeriodBudgetExceededError
24
+ * │ └── TensorCostBudgetHardCapError
25
+ * ├── TensorCostModelGovernanceDeniedError
26
+ * ├── TensorCostGuardrailHardStopError
27
+ * ├── TensorCostComplianceDeniedError
28
+ * └── TensorCostComplianceTeamMismatchError
29
+ *
30
+ * A refusal code this SDK version doesn't model still arrives as a plain
31
+ * TensorCostRefusedError with its `code`, `reason` and message intact.
16
32
  *
17
33
  * All subclasses carry:
18
34
  * - `rootCause` the underlying Error, if any (avoids clash with ES2022 Error.cause)
@@ -49,7 +65,9 @@ export declare class TensorCostProxyError extends TensorCostError {
49
65
  constructor(message: string, opts?: TensorCostErrorOptions);
50
66
  }
51
67
  /**
52
- * The proxy returned 429 Too Many Requests.
68
+ * The proxy returned 429 Too Many Requests (TensorCost's own rate limit),
69
+ * or 402 with no refusal body (the plan's monthly proxy-request ceiling;
70
+ * `status` says which). Neither carries a refusal, so both may fall back.
53
71
  * `retryAfterMs` is set when the response included a `Retry-After` header.
54
72
  */
55
73
  export declare class TensorCostQuotaError extends TensorCostError {
@@ -57,12 +75,63 @@ export declare class TensorCostQuotaError extends TensorCostError {
57
75
  constructor(message: string, retryAfterMs: number | null, opts?: TensorCostErrorOptions);
58
76
  }
59
77
  /**
60
- * The proxy successfully reached the upstream provider, but the provider
61
- * itself returned an error (4xx/5xx from OpenAI, Anthropic, etc.). The
62
- * proxy's response still carries the provider's status in `status`.
78
+ * The proxy reached the upstream provider and relayed the provider's own
79
+ * 4xx (OpenAI 400 invalid request, Anthropic 401, and so on). `status` is
80
+ * the provider's status and `body` is what the provider sent, parsed as
81
+ * JSON when it was JSON. Never falls back: the provider would only answer
82
+ * the same way again.
63
83
  */
64
84
  export declare class TensorCostProviderError extends TensorCostError {
65
- constructor(message: string, opts?: TensorCostErrorOptions);
85
+ readonly body: unknown;
86
+ /** Response headers of the relayed error, lower-cased. */
87
+ readonly headers: Record<string, string>;
88
+ constructor(message: string, opts?: TensorCostErrorOptions & {
89
+ body?: unknown;
90
+ headers?: Record<string, string>;
91
+ });
92
+ }
93
+ /**
94
+ * Something in front of TensorCost turned the request away: a 4xx whose
95
+ * body isn't JSON (an HTML page from a firewall or load balancer, or
96
+ * nothing at all). Neither TensorCost nor the provider saw the call.
97
+ * Terminal: going around it would mean going around whatever put the
98
+ * firewall there, and the next call would most likely meet it too.
99
+ */
100
+ export declare class TensorCostGatewayRejectedError extends TensorCostError {
101
+ /** The first 500 characters of what came back, if anything did. */
102
+ readonly bodyText: string | null;
103
+ constructor(status: number, bodyText: string | null, opts?: TensorCostErrorOptions);
104
+ }
105
+ /**
106
+ * The token exchange rejected the TensorCost API key (401 or 403): revoked,
107
+ * mistyped, or issued for a different tenant than the one configured. Not
108
+ * an outage, so it never fails open.
109
+ */
110
+ export declare class TensorCostKeyRejectedError extends TensorCostError {
111
+ constructor(status: number, opts?: TensorCostErrorOptions);
112
+ }
113
+ /**
114
+ * TensorCost answered and the answer is no: a budget, a stop, a policy.
115
+ *
116
+ * Every refusal is terminal. It never retries and never falls back to the
117
+ * provider, because the proxy that sent it is healthy and the refusal is
118
+ * the product. `code` is the server's refusal code (null when the server
119
+ * refused without naming one), `reason` its optional sub-reason, and
120
+ * `detail` the refusal object as the server sent it.
121
+ *
122
+ * Subclasses cover the codes this SDK version models. Anything else, a
123
+ * code added on the server after this release included, is thrown as this
124
+ * class directly so it is still terminal.
125
+ */
126
+ export declare class TensorCostRefusedError extends TensorCostError {
127
+ readonly code: string | null;
128
+ readonly reason: string | null;
129
+ readonly detail: Record<string, unknown> | null;
130
+ constructor(message: string, refusal?: {
131
+ code?: string | null;
132
+ reason?: string | null;
133
+ detail?: Record<string, unknown> | null;
134
+ }, opts?: TensorCostErrorOptions);
66
135
  }
67
136
  /**
68
137
  * The agent run this call belongs to has hit its spend cap, and the proxy
@@ -76,53 +145,139 @@ export declare class TensorCostProviderError extends TensorCostError {
76
145
  * anyway, bill the customer, and reduce the cap to a suggestion.
77
146
  *
78
147
  * See `shouldFallBackToProvider()` in proxy-client.ts, which is the single
79
- * predicate every provider wrapper consults before falling back.
148
+ * predicate every provider wrapper consults before falling back. Since
149
+ * 1.5.0 it is an allow-list of outages, so a refusal can't slip past it.
80
150
  */
81
- export declare class TensorCostRunBudgetExceededError extends TensorCostError {
151
+ export declare class TensorCostRunBudgetExceededError extends TensorCostRefusedError {
82
152
  readonly workflowId: string | null;
83
153
  readonly capCents: number | null;
84
154
  readonly spentCents: number | null;
85
- constructor(message: string, workflowId: string | null, capCents: number | null, spentCents: number | null, opts?: TensorCostErrorOptions);
155
+ constructor(message: string, workflowId: string | null, capCents: number | null, spentCents: number | null, opts?: TensorCostErrorOptions & {
156
+ detail?: Record<string, unknown> | null;
157
+ });
158
+ }
159
+ /**
160
+ * An operator stopped the agent run this call belongs to, and the proxy
161
+ * refused the request (HTTP 403, `code: "RUN_STOPPED"`).
162
+ *
163
+ * Terminal for the same reason as the budget refusals: a stop is a decision
164
+ * from a healthy proxy, so falling back to the provider would simply undo
165
+ * it. Carries the who / when / why the proxy recorded.
166
+ */
167
+ export declare class TensorCostRunStoppedError extends TensorCostRefusedError {
168
+ /**
169
+ * Build the error from the proxy's 403 `error` object. Shared by the
170
+ * chat-completions client and the govern-layer admit client, which both
171
+ * receive the same body.
172
+ */
173
+ static fromProxyBody(detail: Record<string, unknown> | undefined, opts?: TensorCostErrorOptions): TensorCostRunStoppedError;
174
+ readonly code = "RUN_STOPPED";
175
+ readonly workflowId: string | null;
176
+ readonly stoppedBy: string | null;
177
+ readonly stoppedAt: string | null;
178
+ constructor(message: string, detail?: {
179
+ workflowId?: string | null;
180
+ stoppedBy?: string | null;
181
+ stoppedAt?: string | null;
182
+ reason?: string | null;
183
+ }, opts?: TensorCostErrorOptions & {
184
+ detail?: Record<string, unknown> | null;
185
+ });
86
186
  }
87
187
  /**
88
188
  * Daily or monthly agent/team spend cap exceeded (HTTP 403,
89
189
  * `code: "PERIOD_BUDGET_EXCEEDED"`). Terminal — must not fall back to the
90
190
  * provider or the cap becomes a suggestion.
91
191
  */
92
- export declare class TensorCostPeriodBudgetExceededError extends TensorCostError {
192
+ export declare class TensorCostPeriodBudgetExceededError extends TensorCostRefusedError {
93
193
  readonly scope: string | null;
94
194
  readonly period: string | null;
95
195
  readonly capCents: number | null;
96
196
  readonly spentCents: number | null;
97
- constructor(message: string, scope: string | null, period: string | null, capCents: number | null, spentCents: number | null, opts?: TensorCostErrorOptions);
197
+ constructor(message: string, scope: string | null, period: string | null, capCents: number | null, spentCents: number | null, opts?: TensorCostErrorOptions & {
198
+ code?: string | null;
199
+ reason?: string | null;
200
+ detail?: Record<string, unknown> | null;
201
+ });
202
+ }
203
+ /**
204
+ * A money budget's hard cap refused the call (HTTP 403).
205
+ *
206
+ * The server sends `error.code: "PERIOD_BUDGET_EXCEEDED"` with
207
+ * `error.budget_code: "BUDGET_HARD_CAP"` (that code is what made 1.4.0
208
+ * treat it as terminal), and older servers sent `error.code:
209
+ * "BUDGET_HARD_CAP"`. Both map here. `code` keeps whichever the server
210
+ * sent; `budgetCode` is always "BUDGET_HARD_CAP".
211
+ *
212
+ * It extends TensorCostPeriodBudgetExceededError because 1.4.0 already
213
+ * raised that class for the current wire shape, so an existing `catch` for
214
+ * it keeps working, and scope / period / capCents / spentCents are filled
215
+ * the same way.
216
+ *
217
+ * `reason: "spend_not_known_yet"` (with `retryable: true` on the wire)
218
+ * means the budget hasn't been counted yet, usually for a few seconds after
219
+ * it is created or its scope changes, so the cap holds calls until the
220
+ * first count lands. That case is `retryable`, and `retryAfterSeconds`
221
+ * comes from the Retry-After header or the body's `retry_after_seconds`.
222
+ * The SDK does not retry on its own.
223
+ */
224
+ export declare class TensorCostBudgetHardCapError extends TensorCostPeriodBudgetExceededError {
225
+ readonly budgetCode = "BUDGET_HARD_CAP";
226
+ readonly budgetId: string | null;
227
+ readonly budgetName: string | null;
228
+ readonly burnPct: number | null;
229
+ readonly retryable: boolean;
230
+ readonly retryAfterSeconds: number | null;
231
+ constructor(message: string, fields?: {
232
+ code?: string | null;
233
+ budgetId?: string | null;
234
+ budgetName?: string | null;
235
+ burnPct?: number | null;
236
+ scope?: string | null;
237
+ period?: string | null;
238
+ capCents?: number | null;
239
+ spentCents?: number | null;
240
+ reason?: string | null;
241
+ retryable?: boolean | null;
242
+ retryAfterSeconds?: number | null;
243
+ detail?: Record<string, unknown> | null;
244
+ }, opts?: TensorCostErrorOptions);
98
245
  }
99
246
  /**
100
247
  * Tenant model governance refused this model (HTTP 403,
101
248
  * `code: "MODEL_GOVERNANCE_DENIED"`). Terminal — must not fall back to the
102
249
  * provider, or Enforce would become a suggestion.
103
250
  */
104
- export declare class TensorCostModelGovernanceDeniedError extends TensorCostError {
251
+ export declare class TensorCostModelGovernanceDeniedError extends TensorCostRefusedError {
105
252
  readonly provider: string | null;
106
253
  readonly model: string | null;
107
254
  readonly governanceStatus: string | null;
108
- constructor(message: string, provider: string | null, model: string | null, governanceStatus: string | null, opts?: TensorCostErrorOptions);
255
+ constructor(message: string, provider: string | null, model: string | null, governanceStatus: string | null, opts?: TensorCostErrorOptions & {
256
+ detail?: Record<string, unknown> | null;
257
+ });
109
258
  }
110
259
  /**
111
260
  * Guardrail hard_stop refused this call (HTTP 403,
112
261
  * `code: "GUARDRAIL_HARD_STOP"`). Terminal — same fail-closed contract as
113
262
  * run-budget and model governance denials.
114
263
  */
115
- export declare class TensorCostGuardrailHardStopError extends TensorCostError {
264
+ export declare class TensorCostGuardrailHardStopError extends TensorCostRefusedError {
116
265
  readonly policyId: string | null;
117
- constructor(message: string, policyId: string | null, opts?: TensorCostErrorOptions);
266
+ constructor(message: string, policyId: string | null, opts?: TensorCostErrorOptions & {
267
+ reason?: string | null;
268
+ detail?: Record<string, unknown> | null;
269
+ });
118
270
  }
119
271
  /** Compliance policy refused this call (metadata or in-process DLP). */
120
- export declare class TensorCostComplianceDeniedError extends TensorCostError {
121
- readonly reason: string | null;
122
- constructor(message: string, reason: string | null, opts?: TensorCostErrorOptions);
272
+ export declare class TensorCostComplianceDeniedError extends TensorCostRefusedError {
273
+ constructor(message: string, reason: string | null, opts?: TensorCostErrorOptions & {
274
+ detail?: Record<string, unknown> | null;
275
+ });
123
276
  }
124
277
  /** Client team_id does not match token-bound team scope. */
125
- export declare class TensorCostComplianceTeamMismatchError extends TensorCostError {
126
- constructor(message: string, opts?: TensorCostErrorOptions);
278
+ export declare class TensorCostComplianceTeamMismatchError extends TensorCostRefusedError {
279
+ constructor(message: string, opts?: TensorCostErrorOptions & {
280
+ detail?: Record<string, unknown> | null;
281
+ });
127
282
  }
128
283
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8BAAsB,eAAgB,SAAQ,KAAK;IACjD,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,KAAK,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,sBAA2B;CAqB/D;AAED,oEAAoE;AACpE,qBAAa,sBAAuB,SAAQ,eAAe;gBAC7C,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,sBAA2B;CAG/D;AAED,6EAA6E;AAC7E,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,sFAAsF;IACtF,QAAQ,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;gBAGjD,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,OAAO,GAAG,MAAM,GAAG,SA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