@genesislcap/foundation-ai 15.14.1 → 15.14.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.
@@ -7,6 +7,8 @@ export { GeminiProvider } from './providers/gemini-provider';
7
7
  export { AnthropicTransport, ResponseTruncatedError } from './transports/anthropic-transport';
8
8
  export { BUDGETED_VENDORS, BudgetExhaustedError, DEFAULT_BUDGET_EXHAUSTED_MESSAGE, isBudgetedVendor, VENDOR_LABELS, vendorTypeOfLabel, } from './transports/budget-exhausted-error';
9
9
  export { GeminiTransport, MalformedFunctionCallError } from './transports/gemini-transport';
10
+ export { DEFAULT_PROVIDER_REFUSED_MESSAGE, PROVIDER_REFUSED_CODE, ProviderRefusedError, } from './transports/provider-refused';
11
+ export type { ProviderRefusalKind } from './transports/provider-refused';
10
12
  export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
11
13
  export { ChatTemperature } from './utils/temperature';
12
14
  export { ANTHROPIC_CACHE_READ_MULTIPLIER, ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER, anthropicRatesFor, anthropicTokenCost, GEMINI_CACHED_INPUT_MULTIPLIER, GEMINI_LONG_CONTEXT_THRESHOLD, geminiRatesFor, geminiTokenCost, } from './utils/token-cost';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,8BAA8B,EAC9B,yBAAyB,EACzB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,UAAU,EACV,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,eAAe,CAAC;AAKvB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO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AAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC1E,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"post-with-retry.d.ts","sourceRoot":"","sources":["../../../src/transports/post-with-retry.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,kBAAkB,CAAC;IAChC,uFAAuF;IACvF,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,4FAA4F;IAC5F,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAID;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAuMnF"}
1
+ {"version":3,"file":"post-with-retry.d.ts","sourceRoot":"","sources":["../../../src/transports/post-with-retry.ts"],"names":[],"mappings":"AAqBA;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,kBAAkB,CAAC;IAChC,uFAAuF;IACvF,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,4FAA4F;IAC5F,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAID;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAyQnF"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * The PROVIDER wall (GENC-1506) — the upstream vendor refusing this account, as opposed to the
3
+ * ai-service proxy refusing this user's own spend budget (`budget-exhausted-error.ts`, GENC-1464).
4
+ *
5
+ * The two are constantly confused, so state the difference once: a
6
+ * {@link BudgetExhaustedError} means *we* declined to spend more on the caller's behalf and an
7
+ * administrator can raise the cap; a {@link ProviderRefusedError} means *Anthropic or Google*
8
+ * declined to serve the request at all, and no amount of budget-raising in our own system changes
9
+ * that. Both are terminal, neither is retryable, and they need different people to fix them.
10
+ *
11
+ * Lives in its own module for the same reason its sibling does: it is raised from
12
+ * `post-with-retry.ts`, which both transports import, so homing it in a transport would close an
13
+ * import cycle the repo's `circular` check rejects.
14
+ *
15
+ * ## Scope: Anthropic only, deliberately
16
+ *
17
+ * Gemini is **not** classified here yet (GENC-1506, Matt's call 2026-08-18). It is not an oversight
18
+ * and it is not because Gemini cannot fail this way — it is because Gemini's failure shapes are
19
+ * genuinely different and only partly observed:
20
+ *
21
+ * - Google's paid tiers refuse a spend cap with `429 RESOURCE_EXHAUSTED`, which is **the same status
22
+ * and the same message text** as an ordinary rate limit, and `429` is in
23
+ * `GeminiTransport.RETRYABLE_STATUSES`. A prose probe there would classify routine rate limiting as
24
+ * terminal and break the retry ladder — the exact inverse of the Anthropic situation below.
25
+ * - The discriminator that *would* work is structural — `details[].QuotaFailure.violations[].quotaId`
26
+ * names the limit's scope (`…PerMinute…` is retryable, per-day or spend-scoped is not) — but only
27
+ * the per-minute free-tier value has been observed. Guessing the others is what this module's
28
+ * history says not to do.
29
+ * - Google's Prepay balance hitting $0 stops every key on the billing account at once, and its error
30
+ * shape is neither documented nor observed.
31
+ *
32
+ * So {@link providerRefusalOf} dispatches on vendor and answers `undefined` for anything that is not
33
+ * Anthropic. Adding Gemini later is a new branch, not a rewrite — which is why the vendor is a
34
+ * parameter rather than an assumption.
35
+ *
36
+ * @packageDocumentation
37
+ */
38
+ import type { AIProviderType } from '../types/config.types';
39
+ /**
40
+ * The proxy's machine-readable code for "the upstream vendor refused this account".
41
+ *
42
+ * Deliberately distinct from `BUDGET_EXCEEDED`: the ai-service proxy stamps this when it relays a
43
+ * provider refusal, so the client can tell a relayed upstream fault from the proxy's own budget
44
+ * verdict without inspecting the body at all.
45
+ *
46
+ * Exported from the package index — unlike its `BUDGET_EXCEEDED_CODE` sibling, which is internal —
47
+ * because the SERVER side of the contract lives in another repo (genesis-create's ai-service stamps
48
+ * this code onto its proxy responses). A hand-copied string literal there would drift on the first
49
+ * rename, and the drift would be silent: the client would simply stop classifying.
50
+ *
51
+ * @beta
52
+ */
53
+ export declare const PROVIDER_REFUSED_CODE = "PROVIDER_REFUSED";
54
+ /**
55
+ * Which kind of refusal it was. **One error type, two kinds** — because the user-facing outcome is
56
+ * identical (one sentence, see {@link DEFAULT_PROVIDER_REFUSED_MESSAGE}) while the operator's fix is
57
+ * completely different.
58
+ *
59
+ * - `spend` — the account cannot spend: credit balance at zero, a workspace/organisation usage cap
60
+ * reached, or a billing/payment-information problem. Someone has to pay or raise a cap.
61
+ * - `auth` — the credential cannot be used: revoked, expired or malformed key (`401`), or a key
62
+ * without access to the requested model (`403`). Someone has to rotate a key or grant access.
63
+ *
64
+ * The alternative designs were both worse. A single type named for spend would *lie* about an
65
+ * expired key, and a debug timeline reading `provider-spend-refused` for an auth fault misleads the
66
+ * next engineer — which is precisely the trap the first draft of this feature fell into by naming
67
+ * itself `ProviderCreditExhaustedError` before a usage cap turned out to be in the same family. Two
68
+ * separate error types would duplicate a branch, a message and a wire code to express one outcome.
69
+ *
70
+ * @beta
71
+ */
72
+ export type ProviderRefusalKind = 'spend' | 'auth';
73
+ /**
74
+ * The single sentence shown to a user whose provider has refused — the transcript bubble the chat
75
+ * driver appends, and the string ai-service reuses for its own generation surfaces.
76
+ *
77
+ * **It names no cause, and that is the whole design.** Three constraints shaped it, and a rewrite
78
+ * has to clear all three:
79
+ *
80
+ * 1. **It must not sound like a cap.** The user can often see their remaining AI spend in the same
81
+ * UI, so *allowance / limit / quota / budget / usage / credit / balance* risk a visible
82
+ * self-contradiction: a message saying there is nothing left, next to a figure showing there is.
83
+ * "isn't related to your account **or your usage**" goes further than avoiding the words — it
84
+ * pre-empts the user checking that figure and concluding the message is wrong.
85
+ * 2. **It must not imply we cannot pay our bills.** *Billing / payment / funds / top up* all read as
86
+ * an unpaid invoice. Naming no cause means there is nothing to be embarrassed by and nothing for
87
+ * the user to contradict.
88
+ * 3. **It must not promise self-healing.** Clearing this needs a human to act out of band, so
89
+ * "currently" rather than "temporarily", and "so it can be restored" positively signals that
90
+ * someone must do something.
91
+ *
92
+ * It is also true of **both** {@link ProviderRefusalKind}s unchanged, which is what makes one
93
+ * sentence for two kinds honest rather than a fudge: for an expired key the provider *is* refusing,
94
+ * it *is* unrelated to the user's own account and usage, they *can* do nothing, and support *can*
95
+ * restore it.
96
+ *
97
+ * Vendor-neutral and deployment-neutral on purpose — the same bundle ships to white-labelled
98
+ * deployments where naming a vendor, or naming Genesis, would be wrong. A host that wants different
99
+ * wording sets `ChatDriverConfig.providerRefusedMessage`.
100
+ *
101
+ * @beta
102
+ */
103
+ export declare const DEFAULT_PROVIDER_REFUSED_MESSAGE: string;
104
+ /**
105
+ * Thrown when the upstream provider refuses the request because of the state of the **account**
106
+ * rather than anything about the request — see {@link ProviderRefusalKind}.
107
+ *
108
+ * Terminal and non-transient, in the same family as `ResponseTruncatedError` and
109
+ * `BudgetExhaustedError`: retrying cannot clear it, because nothing about the request is wrong. So
110
+ * both the transport retry ladder and the driver's transient-retry catch step aside for it and the
111
+ * failure surfaces immediately as the `'provider-refused'` `TurnFailureReason`.
112
+ *
113
+ * @beta
114
+ */
115
+ export declare class ProviderRefusedError extends Error {
116
+ /** Vendor label of the transport that was refused (e.g. `'Anthropic'`). */
117
+ readonly vendorLabel: string;
118
+ /** Which kind of refusal — drives the log and the operator's fix, never the user's message. */
119
+ readonly kind: ProviderRefusalKind;
120
+ /**
121
+ * The provider's own HTTP status, when known.
122
+ *
123
+ * Diagnostic only, and deliberately not part of the classification contract: the observed spend
124
+ * refusals arrive as `400` (not the `402 billing_error` the docs describe), so a consumer that
125
+ * branched on this would be encoding one snapshot of provider behaviour.
126
+ */
127
+ readonly upstreamStatus?: number;
128
+ /** The provider's own `error.type` (e.g. `'invalid_request_error'`, `'authentication_error'`). */
129
+ readonly upstreamType?: string;
130
+ /** The provider's human-readable message, verbatim, for the log. Never shown to the user. */
131
+ readonly detail?: string;
132
+ constructor(
133
+ /** Vendor label of the transport that was refused (e.g. `'Anthropic'`). */
134
+ vendorLabel: string,
135
+ /** Which kind of refusal — drives the log and the operator's fix, never the user's message. */
136
+ kind: ProviderRefusalKind,
137
+ /**
138
+ * The provider's own HTTP status, when known.
139
+ *
140
+ * Diagnostic only, and deliberately not part of the classification contract: the observed spend
141
+ * refusals arrive as `400` (not the `402 billing_error` the docs describe), so a consumer that
142
+ * branched on this would be encoding one snapshot of provider behaviour.
143
+ */
144
+ upstreamStatus?: number,
145
+ /** The provider's own `error.type` (e.g. `'invalid_request_error'`, `'authentication_error'`). */
146
+ upstreamType?: string,
147
+ /** The provider's human-readable message, verbatim, for the log. Never shown to the user. */
148
+ detail?: string);
149
+ }
150
+ /**
151
+ * Classify a rejection as a provider refusal, or `undefined` for anything else.
152
+ *
153
+ * **Every trigger is a POSITIVE signal — status alone never classifies.** That is what keeps this
154
+ * from stealing the proxy's own `402 BUDGET_EXCEEDED`: a bare `402` with no provider envelope
155
+ * carries nothing this function recognises, so it falls through to the budget classification exactly
156
+ * as it did before this module existed. A `402` that *does* carry an Anthropic envelope is a relayed
157
+ * upstream fault and is claimed here — which is the collision GENC-1506 set out to close, closed by
158
+ * ordering and positive detection rather than by loosening the budget predicate.
159
+ *
160
+ * @param vendor - which vendor's transport was refused. Anything but `'anthropic'` returns
161
+ * `undefined` today; see this module's header for why Gemini is deliberately absent.
162
+ * @param code - the proxy's machine-readable code, when there is one (`err` frame or JSON body).
163
+ * @param payload - the parsed rejection body, or the parsed `err` frame.
164
+ */
165
+ export declare function providerRefusalOf(vendor: AIProviderType | undefined, code: string | undefined, payload: unknown): ProviderRefusalKind | undefined;
166
+ /**
167
+ * Build a {@link ProviderRefusedError} from a classified rejection, pulling the provider's own
168
+ * status/type/message across for the log.
169
+ *
170
+ * `upstreamStatus` is passed in rather than read from the payload because the two wire modes carry it
171
+ * differently (HTTP status vs the err frame's `status`), and the caller is the only one that knows
172
+ * which it is looking at.
173
+ */
174
+ export declare function providerRefusedFrom(vendorLabel: string, kind: ProviderRefusalKind, upstreamStatus: number | undefined, payload: unknown, fallbackDetail?: string): ProviderRefusedError;
175
+ /**
176
+ * The {@link AIProviderType} a vendor label belongs to, for the classification call above.
177
+ *
178
+ * A thin wrapper over the label map rather than a reuse of `vendorTypeOfLabel`: this one is called
179
+ * with the transport's OWN label, which is always a literal from {@link VENDOR_LABELS}, so an exact
180
+ * match is correct and the case-insensitive, whitespace-tolerant lookup that the wire-borne label
181
+ * needs would be misleading precision here.
182
+ */
183
+ export declare function vendorOfTransportLabel(vendorLabel: string): AIProviderType | undefined;
184
+ //# sourceMappingURL=provider-refused.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-refused.d.ts","sourceRoot":"","sources":["../../../src/transports/provider-refused.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,gCAAgC,QAEwD,CAAC;AAEtG;;;;;;;;;;GAUG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM;IAC5B,+FAA+F;IAC/F,QAAQ,CAAC,IAAI,EAAE,mBAAmB;IAClC;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM;IAChC,kGAAkG;IAClG,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM;IAC9B,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;;IAfxB,2EAA2E;IAClE,WAAW,EAAE,MAAM;IAC5B,+FAA+F;IACtF,IAAI,EAAE,mBAAmB;IAClC;;;;;;OAMG;IACM,cAAc,CAAC,EAAE,MAAM;IAChC,kGAAkG;IACzF,YAAY,CAAC,EAAE,MAAM;IAC9B,6FAA6F;IACpF,MAAM,CAAC,EAAE,MAAM;CAW3B;AA+GD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,EAAE,OAAO,GACf,mBAAmB,GAAG,SAAS,CAuCjC;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,mBAAmB,EACzB,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,OAAO,EAAE,OAAO,EAChB,cAAc,CAAC,EAAE,MAAM,GACtB,oBAAoB,CAStB;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAGtF"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Server-supplied retry hints for the shared `postWithRetry` ladder (GENC-1506).
3
+ *
4
+ * ## Why this exists
5
+ *
6
+ * The ladder was `base * 2^attempt` — 1s, 2s, 4s, 8s, 16s, **31s in total** — and it read neither the
7
+ * HTTP `Retry-After` header nor Google's in-body `RetryInfo`. Measured against a real rate-limited
8
+ * Gemini key (2026-08-18), the provider asked for **53s**:
9
+ *
10
+ * ```jsonc
11
+ * {"error":{"code":429,"status":"RESOURCE_EXHAUSTED",
12
+ * "message":"… Please retry in 53.59713199s.",
13
+ * "details":[{"@type":"type.googleapis.com/google.rpc.RetryInfo","retryDelay":"53s"}]}}
14
+ * ```
15
+ *
16
+ * So a **legitimate** rate limit burned all five retries inside the window the provider had told us to
17
+ * wait, then failed opaquely — every attempt after the first guaranteed to fail, and the user waiting
18
+ * 31s to be told nothing useful. Honouring the hint turns five doomed requests into one that works.
19
+ *
20
+ * ## Scope note
21
+ *
22
+ * This is deliberately vendor-neutral and applies to **healthy traffic**, not just refusals. It is the
23
+ * one part of GENC-1506 that changes timing on a path that is working: some failures that used to give
24
+ * up after 31s will now wait longer before succeeding or failing. That is the correct behaviour and it
25
+ * is what the server asked for, but it is why the ladder keeps its own tests and its own line in the
26
+ * release notes rather than riding along silently inside a fix about error messages.
27
+ *
28
+ * @packageDocumentation
29
+ */
30
+ /**
31
+ * Ceiling on a server-requested wait, per attempt.
32
+ *
33
+ * A hint is *advice from a remote party*, so it needs a bound: without one, a mistaken or hostile
34
+ * `Retry-After: 86400` parks a turn for a day with no way out but a caller abort. 60s sits comfortably
35
+ * above the largest value observed (53s) while keeping the worst case survivable.
36
+ *
37
+ * This caps each wait, and it is the ONLY per-attempt bound — the earlier claim that the exponential
38
+ * ladder bounds a pathological sequence was simply wrong, because `resolveBackoffMs` takes the LARGER
39
+ * of the two and the ladder tops out at `baseMs * 2 ** 4` (16s at the 1s base every transport uses). A
40
+ * 60s hint therefore wins on every attempt and the ladder never contributes. That is what
41
+ * {@link MAX_TOTAL_SERVER_REQUESTED_BACKOFF_MS} is for.
42
+ */
43
+ export declare const MAX_SERVER_REQUESTED_BACKOFF_MS = 60000;
44
+ /**
45
+ * Ceiling on the server-requested wait across a WHOLE retry sequence.
46
+ *
47
+ * Without it the per-attempt cap is no real bound: five capped waits is five minutes, and nothing is
48
+ * watching during them — the attempt's own timeout is cleared before each backoff, so a provider (or a
49
+ * proxy in front of one) answering `Retry-After: 3600` five times parks the turn for the full five
50
+ * minutes with a caller abort as the only way out.
51
+ *
52
+ * 120s is chosen so the case this module was written for still works untouched: the measured Gemini
53
+ * hint was 53s, and two of those fit inside the budget with headroom. Past it we stop honouring hints
54
+ * and fall back to the ladder, so a sequence of maximal 60s hints now totals ~151s (120s of honoured
55
+ * excess plus the ladder's own 31s) rather than 300s.
56
+ *
57
+ * What it budgets is the EXCESS over the wait the ladder would have taken anyway — see
58
+ * {@link serverBackoffSpentMs}. Budgeting the raw hint instead would let the ladder's own growth eat
59
+ * the allowance late in a sequence, declining hints on the grounds of time we were always going to
60
+ * spend.
61
+ */
62
+ export declare const MAX_TOTAL_SERVER_REQUESTED_BACKOFF_MS = 120000;
63
+ /** A `Headers`-like enough to read; tests and Response-likes supply partial shapes. */
64
+ interface HeaderReader {
65
+ get?: (name: string) => string | null | undefined;
66
+ }
67
+ /**
68
+ * `true` only when the server has **explicitly** said not to retry.
69
+ *
70
+ * Absent means "no opinion" and must never be read as `true` — that asymmetry is measured, not
71
+ * cautious: the captured Anthropic `401` carries no `x-should-retry` at all, while the captured
72
+ * spend-refusal `400` carries `false`. Treating absence as a refusal to retry would silently disable
73
+ * the ladder for every provider that does not send the header, Google included.
74
+ */
75
+ export declare function shouldNotRetry(headers: HeaderReader | undefined): boolean;
76
+ /**
77
+ * The `Retry-After` header in ms, or `undefined`.
78
+ *
79
+ * Both documented forms are accepted — delta-seconds (`Retry-After: 53`) and an HTTP-date
80
+ * (`Retry-After: Wed, 21 Oct 2026 07:28:00 GMT`) — because a proxy or CDN in front of the provider may
81
+ * rewrite one into the other, and a silently unparsed hint is indistinguishable from no hint at all.
82
+ * A date already in the past clamps to 0 rather than going negative.
83
+ */
84
+ export declare function retryAfterMs(headers: HeaderReader | undefined): number | undefined;
85
+ /**
86
+ * Google's `google.rpc.RetryInfo.retryDelay` in ms, or `undefined`.
87
+ *
88
+ * Read from **two positions**, for the same reason the refusal classifier reads two: on the direct API
89
+ * the body is Google's own (`{ error: { details: [...] } }`), while through the NDJSON framed proxy that
90
+ * body is nested under the err frame's `details`. Reading one position only would honour the hint on
91
+ * exactly one of the two paths.
92
+ *
93
+ * Matched on an `@type` **suffix** rather than the full URL: the type prefix is a Google-owned constant
94
+ * that has no reason to change, but suffix-matching costs nothing and survives it if it does.
95
+ */
96
+ export declare function retryInfoMs(payload: unknown): number | undefined;
97
+ /**
98
+ * How long to wait before the next attempt: never less than our own ladder, never less than the
99
+ * server asked, never more than the ceiling.
100
+ *
101
+ * `max` rather than "prefer the server's value" is the point — a server asking for *less* than our
102
+ * backoff must not be able to talk us into hammering it, which a naive "honour the hint" would do on
103
+ * `Retry-After: 0`.
104
+ *
105
+ * @param attempt - zero-based attempt index, as the ladder counts them.
106
+ * @param baseMs - the transport's backoff base; the ladder is `baseMs * 2^attempt`.
107
+ * @param serverMs - the server's requested delay, when it supplied one.
108
+ */
109
+ export declare function resolveBackoffMs(attempt: number, baseMs: number, serverMs?: number, serverAllowanceMs?: number): number;
110
+ /**
111
+ * How much of the sequence budget a resolved wait consumed.
112
+ *
113
+ * Only the part attributable to the server counts: a wait the ladder would have taken anyway is not
114
+ * the server's doing, so it must not eat the allowance — otherwise a long ladder late in a sequence
115
+ * would exhaust the budget without a single hint having been honoured.
116
+ */
117
+ export declare function serverBackoffSpentMs(resolvedMs: number, ladderMs: number): number;
118
+ export {};
119
+ //# sourceMappingURL=retry-hints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-hints.d.ts","sourceRoot":"","sources":["../../../src/transports/retry-hints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,+BAA+B,QAAS,CAAC;AAEtD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qCAAqC,SAAU,CAAC;AAQ7D,uFAAuF;AACvF,UAAU,YAAY;IACpB,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAGzE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAQlF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAqBhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,EACjB,iBAAiB,GAAE,MAAiC,GACnD,MAAM,CAaR;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjF"}
@@ -1 +1 @@
1
- {"version":3,"file":"server-openai-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/server-openai-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAyBrE,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,WAAW;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,GAAE,2BAAgC;IAKpD,SAAS,IAAI;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE;IAQnE,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;CAkD9E"}
1
+ {"version":3,"file":"server-openai-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/server-openai-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AA0BrE,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,WAAW;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,GAAE,2BAAgC;IAKpD,SAAS,IAAI;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE;IAQnE,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;CAiE9E"}
@@ -626,7 +626,14 @@ export interface InteractionRequestOptions {
626
626
  *
627
627
  * @beta
628
628
  */
629
- export type SubAgentFailureReason = 'max_iterations' | 'malformed_tool_call' | 'empty_response' | 'unknown_tool_limit' | 'timeout' | 'response_truncated' | 'refusal' | 'budget_exhausted';
629
+ export type SubAgentFailureReason = 'max_iterations' | 'malformed_tool_call' | 'empty_response' | 'unknown_tool_limit' | 'timeout' | 'response_truncated' | 'refusal' | 'budget_exhausted'
630
+ /**
631
+ * The upstream vendor refused the account (GENC-1506). **Terminal for the PARENT turn too**, on the
632
+ * same reasoning as `budget_exhausted`: the parent cannot recover by calling the model again,
633
+ * because the very next call hits the same wall. N batched sub-agent calls would otherwise cost N
634
+ * doomed children AND a doomed parent call.
635
+ */
636
+ | 'provider_refused';
630
637
  /**
631
638
  * When a tool call's declared payload(s) become stale and should be condensed
632
639
  * out of the to-model history. The kinds form a spectrum of widening staleness
@@ -1057,10 +1064,15 @@ export interface ChatFallback {
1057
1064
  * - `budget-exhausted` — the AI-spend budget is used up and the proxy refused the request
1058
1065
  * (`BudgetExhaustedError`, HTTP 402). Terminal, not retried: the
1059
1066
  * budget must be raised out-of-band before any call can succeed.
1067
+ * - `provider-refused` — the upstream VENDOR refused this account, not this request
1068
+ * (`ProviderRefusedError`): its credit is gone, a usage cap is reached,
1069
+ * or the credential is dead. Terminal and not retried. Distinct from
1070
+ * `budget-exhausted` because the fix belongs to a different person —
1071
+ * ours is "raise the cap", this is "fix the provider account".
1060
1072
  *
1061
1073
  * @beta
1062
1074
  */
1063
- export type TurnFailureReason = 'exception' | 'malformed-function-call' | 'empty-response' | 'unknown-tool-limit' | 'max-iterations' | 'response-truncated' | 'refusal' | 'budget-exhausted';
1075
+ export type TurnFailureReason = 'exception' | 'malformed-function-call' | 'empty-response' | 'unknown-tool-limit' | 'max-iterations' | 'response-truncated' | 'refusal' | 'budget-exhausted' | 'provider-refused';
1064
1076
  /**
1065
1077
  * The result returned by a driver after processing a user turn.
1066
1078
  *
@@ -1135,6 +1147,30 @@ export type ChatDriverResult = {
1135
1147
  */
1136
1148
  otherVendorAvailable?: boolean;
1137
1149
  };
1150
+ /**
1151
+ * What the provider's refusal reported, present **only** when
1152
+ * `failureReason === 'provider-refused'` (GENC-1506).
1153
+ *
1154
+ * Carried for the caller's LOG, not for its UI. The user-facing sentence is deliberately
1155
+ * cause-free (see `DEFAULT_PROVIDER_REFUSED_MESSAGE`), which makes this the only place a
1156
+ * consumer can tell "the account cannot spend" from "the credential is dead" — and those need
1157
+ * different people to fix them. genesis-create's ai-service is the consumer this exists for:
1158
+ * its generation surfaces re-throw across a WebSocket, so without this the kind would be lost
1159
+ * at the driver boundary and the server's own Sentry alert could not say which fault it was.
1160
+ *
1161
+ * Omitted entirely (not set to `undefined`) on every other outcome, so a clean turn's shape
1162
+ * stays byte-identical to the historical `{ reason: 'done' }`.
1163
+ */
1164
+ providerRefused?: {
1165
+ /** Vendor label of the transport that was refused (e.g. `'Anthropic'`). */
1166
+ vendorLabel: string;
1167
+ /** `'spend'` (account cannot pay) or `'auth'` (credential cannot be used). */
1168
+ kind: 'spend' | 'auth';
1169
+ /** The provider's own HTTP status, when known. Diagnostic only — never branch on it. */
1170
+ upstreamStatus?: number;
1171
+ /** The provider's own `error.type`, when it sent one. */
1172
+ upstreamType?: string;
1173
+ };
1138
1174
  } | {
1139
1175
  reason: 'agent-handoff';
1140
1176
  summary: string;
@@ -1 +1 @@
1
- {"version":3,"file":"chat.types.d.ts","sourceRoot":"","sources":["../../../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AE,eAAe,CAAC;IACxB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,gEAAgE;IAChE,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IACE,gCAAgC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,+CAA+C;IAC/C,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,GACD;IACE;;;OAGG;IACH,QAAQ,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -9,6 +9,11 @@ export { GeminiProvider } from './providers/gemini-provider';
9
9
  export { AnthropicTransport, ResponseTruncatedError } from './transports/anthropic-transport';
10
10
  export { BUDGETED_VENDORS, BudgetExhaustedError, DEFAULT_BUDGET_EXHAUSTED_MESSAGE, isBudgetedVendor, VENDOR_LABELS, vendorTypeOfLabel, } from './transports/budget-exhausted-error';
11
11
  export { GeminiTransport, MalformedFunctionCallError } from './transports/gemini-transport';
12
+ // The PROVIDER wall (GENC-1506) — the upstream vendor refusing this account, as distinct from our own
13
+ // spend budget above. The message constant is exported so ai-service's generation surfaces send the
14
+ // SAME sentence as the browser driver: the copy is provisional and a second copy would drift on the
15
+ // first reword.
16
+ export { DEFAULT_PROVIDER_REFUSED_MESSAGE, PROVIDER_REFUSED_CODE, ProviderRefusedError, } from './transports/provider-refused';
12
17
  export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
13
18
  export { ChatTemperature } from './utils/temperature';
14
19
  // Request pricing. Exported so a host that prices its own calls — a server proxy, a usage ledger,
@@ -5,6 +5,8 @@ import { combineSignals } from '../utils/combine-signals';
5
5
  import { logger } from '../utils/logger';
6
6
  import { budgetExhaustedFrom, codeOf, isBudgetRejection, parseJsonOrUndefined, } from './budget-exhausted-error';
7
7
  import { readFramedBody } from './ndjson-frames';
8
+ import { providerRefusalOf, providerRefusedFrom, vendorOfTransportLabel } from './provider-refused';
9
+ import { MAX_TOTAL_SERVER_REQUESTED_BACKOFF_MS, resolveBackoffMs, retryAfterMs, retryInfoMs, serverBackoffSpentMs, shouldNotRetry, } from './retry-hints';
8
10
  const MAX_RETRIES = 5;
9
11
  /**
10
12
  * POST with the shared retry ladder, wall-clock timeout, framed-mode stall
@@ -18,10 +20,36 @@ export function postWithRetry(options) {
18
20
  return __awaiter(this, void 0, void 0, function* () {
19
21
  var _a, _b, _c, _d, _e, _f, _g;
20
22
  const { url, headers, body, credentials, vendorLabel, retryableStatuses, timeout, stallTimeout, backoffBaseMs, signal, } = options;
21
- // Exponential backoff between retries: base, 2×, 4×, 8×, 16×. Abortable on the
22
- // CALLER signal only the timeout is cleared before each backoff, so a caller
23
- // cancel mid-wait unwinds immediately while a timeout does not.
24
- const backoff = (attempt) => abortableDelay(backoffBaseMs * (1 << attempt), signal);
23
+ // The vendor behind this transport's label, resolved once the refusal classifier dispatches on
24
+ // it, and it is the only vendor knowledge this envelope needs (GENC-1506).
25
+ const vendor = vendorOfTransportLabel(vendorLabel);
26
+ // Total time this sequence has spent waiting BEYOND its own ladder because a server asked it to.
27
+ // The per-attempt cap alone is not a bound on the sequence — five capped waits is five minutes, with
28
+ // no timer running through any of them — so the allowance is tracked here and spent down across
29
+ // attempts. Per-call state, deliberately: a budget shared between concurrent requests would make one
30
+ // request's hints silently shorten another's.
31
+ let serverBackoffSpent = 0;
32
+ // Exponential backoff between retries: base, 2×, 4×, 8×, 16× — raised to whatever the server asked
33
+ // for when it asked for more (GENC-1506; see `retry-hints`). Abortable on the CALLER signal only —
34
+ // the timeout is cleared before each backoff, so a caller cancel mid-wait unwinds immediately while
35
+ // a timeout does not.
36
+ const backoff = (attempt, serverMs) => {
37
+ const ladderMs = backoffBaseMs * Math.pow(2, attempt);
38
+ const allowanceMs = MAX_TOTAL_SERVER_REQUESTED_BACKOFF_MS - serverBackoffSpent;
39
+ const waitMs = resolveBackoffMs(attempt, backoffBaseMs, serverMs, allowanceMs);
40
+ serverBackoffSpent += serverBackoffSpentMs(waitMs, ladderMs);
41
+ if (serverMs != null && waitMs > ladderMs) {
42
+ // Logged because an honoured hint is otherwise indistinguishable from a hang: a silent 53s
43
+ // pause in a log is the sort of thing someone spends an afternoon on.
44
+ logger.warn(`${vendorLabel}Transport: honouring the server's requested retry delay (${Math.round(waitMs)}ms, asked ${Math.round(serverMs)}ms)`);
45
+ }
46
+ else if (serverMs != null && serverMs > ladderMs) {
47
+ // The hint was declined, which is worth its own line: the wait about to happen is shorter than
48
+ // the server asked for, and without this the log looks like the hint was never sent.
49
+ logger.warn(`${vendorLabel}Transport: declining the server's requested retry delay (asked ${Math.round(serverMs)}ms; the ${MAX_TOTAL_SERVER_REQUESTED_BACKOFF_MS}ms sequence allowance is spent) — using the ladder's ${Math.round(waitMs)}ms`);
50
+ }
51
+ return abortableDelay(waitMs, signal);
52
+ };
25
53
  // Sequential retries are intentional — each attempt depends on the previous response.
26
54
  /* oxlint-disable no-await-in-loop -- intentional sequential retries with backoff */
27
55
  for (let attempt = 0; attempt <= MAX_RETRIES; attempt += 1) {
@@ -101,6 +129,17 @@ export function postWithRetry(options) {
101
129
  // non-retryable or already budget-shaped.
102
130
  const errText = yield response.text();
103
131
  const parsed = parseJsonOrUndefined(errText);
132
+ // The PROVIDER wall (GENC-1506) is classified BEFORE the budget wall, and the order is
133
+ // load-bearing rather than arbitrary. `isBudgetRejection` treats a bare `402` as our own
134
+ // budget verdict, and `402` is also Anthropic's documented `billing_error` status — so a
135
+ // relayed upstream billing failure would otherwise be reported as the user's own spend cap,
136
+ // locking their composer and sending them to an administrator to raise a limit that has
137
+ // headroom. Every trigger in `providerRefusalOf` is a POSITIVE signal, so a bare `402` with
138
+ // no provider envelope still falls through to the budget branch exactly as it always did.
139
+ const refusal = providerRefusalOf(vendor, codeOf(parsed), parsed);
140
+ if (refusal) {
141
+ throw providerRefusedFrom(vendorLabel, refusal, response.status, parsed, errText || undefined);
142
+ }
104
143
  // The budget wall (GENC-1464) wins over ANY status-based retry — the same
105
144
  // rule the framed branch below applies, now symmetric. It must be
106
145
  // classified BEFORE the ladder, not after it: 402 is absent from every
@@ -113,10 +152,17 @@ export function postWithRetry(options) {
113
152
  if (isBudgetRejection(response.status, codeOf(parsed))) {
114
153
  throw budgetExhaustedFrom(vendorLabel, parsed, errText || undefined);
115
154
  }
116
- if (retryableStatuses.includes(response.status) && attempt < MAX_RETRIES) {
155
+ // An explicit `x-should-retry: false` outranks our own retryable-status set (GENC-1506).
156
+ // The provider knows things the status does not — a 429 it will keep refusing, say — and
157
+ // Anthropic's own SDK honours this header. Absent means "no opinion", never `false`.
158
+ const refusedRetry = shouldNotRetry(response.headers);
159
+ if (retryableStatuses.includes(response.status) && !refusedRetry && attempt < MAX_RETRIES) {
117
160
  logger.warn(`${vendorLabel}Transport: retryable status ${response.status}, retrying (attempt ${attempt + 1}/${MAX_RETRIES})`);
118
161
  clearTimeout(timeoutId); // this attempt is over — don't let its timer tick through the backoff
119
- yield backoff(attempt);
162
+ // `||` not `??`: `retryAfterMs` returns 0 — not undefined — for `Retry-After: 0` and for an
163
+ // HTTP-date already in the past, and a 0 carries nothing the ladder does not already have.
164
+ // With `??` such a response would take the 0 and never read the in-body hint beside it.
165
+ yield backoff(attempt, retryAfterMs(response.headers) || retryInfoMs(parsed));
120
166
  continue;
121
167
  }
122
168
  throw new Error(`${vendorLabel} request error ${response.status}: ${errText}`);
@@ -144,15 +190,27 @@ export function postWithRetry(options) {
144
190
  // classification must win over any status-based retry. That ordering is
145
191
  // no longer unique to this branch — the legacy branch above now applies
146
192
  // the identical rule, so the two read as one policy rather than two.
193
+ // The PROVIDER wall, framed (GENC-1506) — the in-band twin of the classification in the
194
+ // legacy branch above, ahead of the budget wall for the same reason: the proxy relays an
195
+ // upstream `402` faithfully, so a `billing_error` would otherwise be reported as the user's
196
+ // own spend cap. On this path the upstream envelope rides in the frame's `details` while the
197
+ // frame's own `error` is the proxy's summary string — `providerRefusalOf` reads both
198
+ // positions, so the same classification serves the browser and the server.
199
+ const framedRefusal = providerRefusalOf(vendor, frame.code, frame);
200
+ if (framedRefusal) {
201
+ throw providerRefusedFrom(vendorLabel, framedRefusal, frame.status, frame, frame.error);
202
+ }
147
203
  if (isBudgetRejection(frame.status, frame.code)) {
148
204
  throw budgetExhaustedFrom(vendorLabel, frame);
149
205
  }
150
206
  // An in-band retryable status joins the same attempt/backoff ladder as
151
- // its HTTP-status equivalent (shared attempt counter).
207
+ // its HTTP-status equivalent (shared attempt counter). No `x-should-retry` to consult here —
208
+ // in framed mode the HTTP response is the proxy's own 200, so its headers say nothing about
209
+ // the upstream attempt; the in-body `RetryInfo` is the only hint that survives the hop.
152
210
  if (retryableStatuses.includes(frame.status) && attempt < MAX_RETRIES) {
153
211
  logger.warn(`${vendorLabel}Transport: retryable status ${frame.status} (err frame), retrying (attempt ${attempt + 1}/${MAX_RETRIES})`);
154
212
  clearTimeout(timeoutId); // disarm the stall timer — the stream is done, only the backoff remains
155
- yield backoff(attempt);
213
+ yield backoff(attempt, retryInfoMs(frame));
156
214
  continue;
157
215
  }
158
216
  throw new Error(`${vendorLabel} request error ${frame.status}: ${(_g = frame.error) !== null && _g !== void 0 ? _g : JSON.stringify(frame.details)}`);