@genesislcap/foundation-ai 15.6.2 → 15.7.0-ts7.1

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 (34) hide show
  1. package/dist/dts/ai-provider.d.ts.map +1 -1
  2. package/dist/dts/index.d.ts +1 -0
  3. package/dist/dts/index.d.ts.map +1 -1
  4. package/dist/dts/interactions/criteria-interpretation.d.ts +40 -40
  5. package/dist/dts/interactions/criteria-interpretation.d.ts.map +1 -1
  6. package/dist/dts/providers/anthropic-provider.d.ts.map +1 -1
  7. package/dist/dts/providers/chrome-provider.d.ts.map +1 -1
  8. package/dist/dts/providers/default-provider.d.ts.map +1 -1
  9. package/dist/dts/providers/gemini-provider.d.ts.map +1 -1
  10. package/dist/dts/providers/openai-provider.d.ts.map +1 -1
  11. package/dist/dts/transports/anthropic-transport.d.ts.map +1 -1
  12. package/dist/dts/transports/budget-exhausted-error.d.ts +254 -0
  13. package/dist/dts/transports/budget-exhausted-error.d.ts.map +1 -0
  14. package/dist/dts/transports/chrome-prompt-transport.d.ts.map +1 -1
  15. package/dist/dts/transports/default-transport.d.ts.map +1 -1
  16. package/dist/dts/transports/gemini-transport.d.ts.map +1 -1
  17. package/dist/dts/transports/post-with-retry.d.ts +6 -1
  18. package/dist/dts/transports/post-with-retry.d.ts.map +1 -1
  19. package/dist/dts/transports/server-openai-transport.d.ts.map +1 -1
  20. package/dist/dts/types/chat.types.d.ts +74 -2
  21. package/dist/dts/types/chat.types.d.ts.map +1 -1
  22. package/dist/dts/utils/temperature.d.ts.map +1 -1
  23. package/dist/esm/ai-provider.js +14 -14
  24. package/dist/esm/index.js +1 -0
  25. package/dist/esm/interactions/criteria-interpretation.js +3 -6
  26. package/dist/esm/transports/anthropic-transport.js +6 -4
  27. package/dist/esm/transports/budget-exhausted-error.js +277 -0
  28. package/dist/esm/transports/chrome-prompt-transport.js +3 -2
  29. package/dist/esm/transports/gemini-transport.js +18 -13
  30. package/dist/esm/transports/post-with-retry.js +49 -9
  31. package/dist/esm/transports/server-openai-transport.js +19 -0
  32. package/dist/foundation-ai.api.json +533 -6
  33. package/dist/foundation-ai.d.ts +247 -2
  34. package/package.json +11 -11
@@ -532,10 +532,20 @@ export interface InteractionRequestOptions {
532
532
  * an incomplete tool call; deterministic, so it is not retried.
533
533
  * - `refusal` — a safety-classifier decline (e.g. Fable 5 `stop_reason: 'refusal'`),
534
534
  * which returns empty content; deterministic, so it is not retried.
535
+ * - `budget_exhausted` — the AI-spend budget is used up and the proxy refused the
536
+ * request (HTTP 402). **Terminal for the parent too, and enforced**: the parent
537
+ * driver ends its own turn as soon as this outcome comes back, instead of
538
+ * appending it as a tool result and calling the model again into the same wall.
539
+ * So a handler that receives it will not be called a second time this turn, and
540
+ * the parent turn reports `'budget-exhausted'` in its own right.
541
+ *
542
+ * Recovery guidance differs sharply by reason — see `docs/sub_agent.md`. Only
543
+ * `budget_exhausted` and `refusal` are terminal; retrying either just reproduces
544
+ * it. The rest are worth a retry or a question to the user.
535
545
  *
536
546
  * @beta
537
547
  */
538
- export type SubAgentFailureReason = 'max_iterations' | 'malformed_tool_call' | 'empty_response' | 'unknown_tool_limit' | 'timeout' | 'response_truncated' | 'refusal';
548
+ export type SubAgentFailureReason = 'max_iterations' | 'malformed_tool_call' | 'empty_response' | 'unknown_tool_limit' | 'timeout' | 'response_truncated' | 'refusal' | 'budget_exhausted';
539
549
  /**
540
550
  * When a tool call's declared payload(s) become stale and should be condensed
541
551
  * out of the to-model history. The kinds form a spectrum of widening staleness
@@ -910,10 +920,13 @@ export interface ChatFallback {
910
920
  * incomplete tool call; deterministic, so it bails without retry.
911
921
  * - `refusal` — a safety-classifier decline (e.g. Fable 5 `stop_reason: 'refusal'`),
912
922
  * which returns empty content; deterministic, so it is not retried.
923
+ * - `budget-exhausted` — the AI-spend budget is used up and the proxy refused the request
924
+ * (`BudgetExhaustedError`, HTTP 402). Terminal, not retried: the
925
+ * budget must be raised out-of-band before any call can succeed.
913
926
  *
914
927
  * @beta
915
928
  */
916
- export type TurnFailureReason = 'exception' | 'malformed-function-call' | 'empty-response' | 'unknown-tool-limit' | 'max-iterations' | 'response-truncated' | 'refusal';
929
+ export type TurnFailureReason = 'exception' | 'malformed-function-call' | 'empty-response' | 'unknown-tool-limit' | 'max-iterations' | 'response-truncated' | 'refusal' | 'budget-exhausted';
917
930
  /**
918
931
  * The result returned by a driver after processing a user turn.
919
932
  *
@@ -929,6 +942,65 @@ export type ChatDriverResult = {
929
942
  * successful turn, a user cancel, and a driver dispose (none are failures).
930
943
  */
931
944
  failureReason?: TurnFailureReason;
945
+ /**
946
+ * Budget figures reported by the proxy, present **only** when
947
+ * `failureReason === 'budget-exhausted'` and the rejection carried them.
948
+ * Lifted off `BudgetExhaustedError` so a host can render the real numbers
949
+ * ("$25.40 of $25") without catching the transport error itself — before
950
+ * this the figures reached the debug log but not the caller, so the
951
+ * assistant's blocked banner could only ever show generic copy.
952
+ *
953
+ * Present whenever the wall carried anything worth reporting — figures, or
954
+ * an attributable vendor. Omitted entirely (not set to `undefined`) when
955
+ * it carried neither, and absent from every non-budget result — a clean
956
+ * turn's shape stays byte-identical to the historical `{ reason: 'done' }`.
957
+ */
958
+ budget?: {
959
+ /** The configured spend cap in USD, when the proxy reported one. */
960
+ budgetUsd?: number;
961
+ /** Spend already booked against that cap in USD, when reported. */
962
+ spentUsd?: number;
963
+ /**
964
+ * Vendor label of the transport that was refused (e.g. `'Anthropic'`).
965
+ * Always present when `budget` is: it is the one field that keeps a
966
+ * per-vendor budget model open without a breaking change later.
967
+ */
968
+ vendorLabel: string;
969
+ /**
970
+ * The refusing vendor as a typed {@link AIProviderType}: the normalised
971
+ * key of `vendorLabel` where that label is one a vendor claims, otherwise
972
+ * the normalised key of the proxy's own `vendor` field on the 402.
973
+ *
974
+ * So it is **not** always a normalisation of `vendorLabel`, and the two
975
+ * fields can legitimately disagree — a white-labelled or multiplexing
976
+ * gateway stamps one static transport label in front of several upstreams,
977
+ * and only the proxy can say which of them refused. The fallback is
978
+ * deliberate: it is what keeps attribution working for those deployments
979
+ * instead of degrading them all to "unattributable".
980
+ *
981
+ * Optional because a label no vendor claims and a 402 that names no vendor
982
+ * must degrade to "unattributable" rather than to a wrong attribution.
983
+ * Derived from the label first, rather than from the driver's
984
+ * last-resolved provider, **on purpose**: the label originates at the
985
+ * transport that was actually refused, whereas the last-resolved provider
986
+ * is stale on the classification seam (an orchestrated turn classifies
987
+ * against the registry default, which the chat driver may never have
988
+ * resolved).
989
+ */
990
+ vendor?: AIProviderType;
991
+ /**
992
+ * The proxy's verdict on whether any OTHER vendor it meters still has
993
+ * headroom (the 402's `otherVendorAvailable`).
994
+ *
995
+ * The only field here a client cannot re-derive, and the reason it is
996
+ * carried: a client can infer "another vendor exists" from registry
997
+ * membership, but never "another vendor has budget left". A `false` is
998
+ * therefore server-known truth that must beat that inference —
999
+ * `FoundationAiAssistant` uses it to stop advising a switch to a vendor
1000
+ * whose pot is already empty. `undefined` means the proxy did not say.
1001
+ */
1002
+ otherVendorAvailable?: boolean;
1003
+ };
932
1004
  } | {
933
1005
  reason: 'agent-handoff';
934
1006
  summary: string;
@@ -1 +1 @@
1
- {"version":3,"file":"chat.types.d.ts","sourceRoot":"","sources":["../../../src/types/chat.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,MAAM,GACN,cAAc,GACd,gBAAgB,GAChB,mBAAmB,CAAC;AAExB;;;;GAIG;AACH,KAAK,gBAAgB,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,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;;;;GAcG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,EAAE,CAAC,EAAE,YAAY,CAAC;IAClB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,iFAAiF;IACjF,KAAK,CAAC,EAAE,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"temperature.d.ts","sourceRoot":"","sources":["../../../src/utils/temperature.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACjE,MAAM,CAKR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe;;;;;;CAMlB,CAAC"}
1
+ {"version":3,"file":"temperature.d.ts","sourceRoot":"","sources":["../../../src/utils/temperature.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACjE,MAAM,CAKR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe;aAC1B,aAAa,EAAE,CAAC;aAChB,OAAO,EAAE,IAAI;aACb,QAAQ,EAAE,GAAG;aACb,QAAQ,EAAE,IAAI;aACd,OAAO,EAAE,CAAC;CACF,CAAC"}
@@ -156,16 +156,18 @@ export class EmptyAIProviderRegistry {
156
156
  }
157
157
  getStatus(name) {
158
158
  return __awaiter(this, void 0, void 0, function* () {
159
- var _a, _b, _c;
159
+ var _a, _b;
160
+ var _c;
160
161
  if (name !== undefined && name !== EmptyAIProviderRegistry.DEFAULT_NAME)
161
162
  return null;
162
- return (_c = (yield ((_b = (_a = this.noopProvider).getStatus) === null || _b === void 0 ? void 0 : _b.call(_a)))) !== null && _c !== void 0 ? _c : null;
163
+ return (_c = (yield (_b = (_a = this.noopProvider).getStatus) === null || _b === void 0 ? void 0 : _b.call(_a))) !== null && _c !== void 0 ? _c : null;
163
164
  });
164
165
  }
165
166
  listStatuses() {
166
167
  return __awaiter(this, void 0, void 0, function* () {
167
- var _a, _b, _c;
168
- const status = (_c = (yield ((_b = (_a = this.noopProvider).getStatus) === null || _b === void 0 ? void 0 : _b.call(_a)))) !== null && _c !== void 0 ? _c : null;
168
+ var _a, _b;
169
+ var _c;
170
+ const status = (_c = (yield (_b = (_a = this.noopProvider).getStatus) === null || _b === void 0 ? void 0 : _b.call(_a))) !== null && _c !== void 0 ? _c : null;
169
171
  return [{ name: EmptyAIProviderRegistry.DEFAULT_NAME, isDefault: true, status }];
170
172
  });
171
173
  }
@@ -228,24 +230,22 @@ export class MutableAIProviderRegistry {
228
230
  }
229
231
  getStatus(name) {
230
232
  return __awaiter(this, void 0, void 0, function* () {
231
- var _a, _b;
233
+ var _a;
234
+ var _b;
232
235
  const provider = name === undefined ? this.default() : this.providers.get(name);
233
236
  if (!provider)
234
237
  return null;
235
- return (_b = (yield ((_a = provider.getStatus) === null || _a === void 0 ? void 0 : _a.call(provider)))) !== null && _b !== void 0 ? _b : null;
238
+ return (_b = (yield (_a = provider.getStatus) === null || _a === void 0 ? void 0 : _a.call(provider))) !== null && _b !== void 0 ? _b : null;
236
239
  });
237
240
  }
238
241
  listStatuses() {
239
242
  return __awaiter(this, void 0, void 0, function* () {
240
243
  const entries = [...this.providers.entries()];
241
- return Promise.all(entries.map((_a) => __awaiter(this, [_a], void 0, function* ([name, provider]) {
242
- var _b, _c;
243
- return ({
244
- name,
245
- isDefault: name === this._defaultName,
246
- status: (_c = (yield ((_b = provider.getStatus) === null || _b === void 0 ? void 0 : _b.call(provider)))) !== null && _c !== void 0 ? _c : null,
247
- });
248
- })));
244
+ return Promise.all(entries.map((_a) => __awaiter(this, [_a], void 0, function* ([name, provider]) { var _b; var _c; return ({
245
+ name,
246
+ isDefault: name === this._defaultName,
247
+ status: (_c = (yield (_b = provider.getStatus) === null || _b === void 0 ? void 0 : _b.call(provider))) !== null && _c !== void 0 ? _c : null,
248
+ }); })));
249
249
  });
250
250
  }
251
251
  /**
package/dist/esm/index.js CHANGED
@@ -7,6 +7,7 @@ export { AIProviderRegistry, registerAIProviderRegistry, registerAIProviders, }
7
7
  export { AnthropicProvider } from './providers/anthropic-provider';
8
8
  export { GeminiProvider } from './providers/gemini-provider';
9
9
  export { AnthropicTransport, ResponseTruncatedError } from './transports/anthropic-transport';
10
+ export { BUDGETED_VENDORS, BudgetExhaustedError, DEFAULT_BUDGET_EXHAUSTED_MESSAGE, isBudgetedVendor, VENDOR_LABELS, vendorTypeOfLabel, } from './transports/budget-exhausted-error';
10
11
  export { GeminiTransport, MalformedFunctionCallError } from './transports/gemini-transport';
11
12
  export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
12
13
  export { ChatTemperature } from './utils/temperature';
@@ -99,12 +99,9 @@ Use dateIsToday with value null for "today" queries. Use yyyyMMdd for dates, yyy
99
99
  */
100
100
  export function buildCriteriaSystemPrompt(fields = [], customInstructions) {
101
101
  const fieldList = fields
102
- .map((f) => {
103
- var _a, _b, _c, _d;
104
- return typeof f === 'string'
105
- ? f
106
- : ((_d = (_c = (_b = (_a = f === null || f === void 0 ? void 0 : f.NAME) !== null && _a !== void 0 ? _a : f === null || f === void 0 ? void 0 : f.name) !== null && _b !== void 0 ? _b : f === null || f === void 0 ? void 0 : f.field) !== null && _c !== void 0 ? _c : f === null || f === void 0 ? void 0 : f.label) !== null && _d !== void 0 ? _d : '');
107
- })
102
+ .map((f) => { var _a, _b, _c, _d; return typeof f === 'string'
103
+ ? f
104
+ : ((_d = (_c = (_b = (_a = f === null || f === void 0 ? void 0 : f.NAME) !== null && _a !== void 0 ? _a : f === null || f === void 0 ? void 0 : f.name) !== null && _b !== void 0 ? _b : f === null || f === void 0 ? void 0 : f.field) !== null && _c !== void 0 ? _c : f === null || f === void 0 ? void 0 : f.label) !== null && _d !== void 0 ? _d : ''); })
108
105
  .filter(Boolean)
109
106
  .join(', ');
110
107
  const basePrompt = customInstructions !== null && customInstructions !== void 0 ? customInstructions : DEFAULT_SYSTEM_PROMPT;
@@ -2,6 +2,7 @@ import { __awaiter } from "tslib";
2
2
  import { SUPPORTED_ANTHROPIC_MODEL_IDS, } from '../types';
3
3
  import { logger } from '../utils/logger';
4
4
  import { scaleTemperature } from '../utils/temperature';
5
+ import { VENDOR_LABELS } from './budget-exhausted-error';
5
6
  import { postWithRetry } from './post-with-retry';
6
7
  const ANTHROPIC_DIRECT_URL = 'https://api.anthropic.com/v1/messages';
7
8
  const ANTHROPIC_API_VERSION = '2023-06-01';
@@ -470,7 +471,8 @@ export class AnthropicTransport {
470
471
  * the payload tidy.
471
472
  */
472
473
  toAnthropicMessages(history, userMessage, attachments) {
473
- var _a, _b, _c;
474
+ var _a, _b;
475
+ var _c;
474
476
  const messages = [];
475
477
  const pushBlock = (role, block) => {
476
478
  const last = messages[messages.length - 1];
@@ -507,13 +509,13 @@ export class AnthropicTransport {
507
509
  type: 'tool_use',
508
510
  id: tc.id,
509
511
  name: tc.name,
510
- input: (_b = tc.args) !== null && _b !== void 0 ? _b : {},
512
+ input: (_c = tc.args) !== null && _c !== void 0 ? _c : {},
511
513
  });
512
514
  }
513
515
  continue;
514
516
  }
515
517
  const role = msg.role === 'user' ? 'user' : 'assistant';
516
- if (role === 'user' && ((_c = msg.attachments) === null || _c === void 0 ? void 0 : _c.length)) {
518
+ if (role === 'user' && ((_b = msg.attachments) === null || _b === void 0 ? void 0 : _b.length)) {
517
519
  pushBlock(role, { type: 'text', text: msg.content });
518
520
  for (const att of msg.attachments) {
519
521
  pushBlock(role, { type: 'text', text: `[File: ${att.name}]\n${att.content}` });
@@ -670,7 +672,7 @@ export class AnthropicTransport {
670
672
  headers: requestHeaders,
671
673
  body,
672
674
  credentials,
673
- vendorLabel: 'Anthropic',
675
+ vendorLabel: VENDOR_LABELS.anthropic,
674
676
  retryableStatuses: AnthropicTransport.RETRYABLE_STATUSES,
675
677
  timeout: this.timeout,
676
678
  stallTimeout: this.stallTimeout,
@@ -0,0 +1,277 @@
1
+ /**
2
+ * The AI-spend budget wall (GENC-1464 workstream C/D).
3
+ *
4
+ * Lives in its own module rather than beside `ResponseTruncatedError` in
5
+ * `anthropic-transport.ts` because it is raised from `post-with-retry.ts`, which
6
+ * both transports import — homing it in a transport would close an import cycle
7
+ * (transport → post-with-retry → transport) that the repo's `circular` check
8
+ * rejects.
9
+ */
10
+ /** The proxy's machine-readable rejection code for an exhausted AI budget. */
11
+ export const BUDGET_EXCEEDED_CODE = 'BUDGET_EXCEEDED';
12
+ /**
13
+ * Display name for each concrete AI vendor: the **single source** every
14
+ * transport's `vendorLabel` is read from, and the only place a vendor's name is
15
+ * spelled for a user.
16
+ *
17
+ * This map is the hinge of the per-vendor budget model (GENC-1464). A wall is
18
+ * attributed to a vendor by reverse-looking-up the label the refused transport
19
+ * stamped on its {@link BudgetExhaustedError} — so a label that drifts from this
20
+ * map (a literal typo, a casing change, a new vendor added with a hardcoded
21
+ * string) silently degrades every wall from that transport to "unattributable"
22
+ * and re-locks the whole session instead of just that vendor. It fails safe, but
23
+ * the feature quietly stops working, which is why the transports read their label
24
+ * from here rather than restating it.
25
+ *
26
+ * The map has **two kinds of entry**, and the difference matters:
27
+ *
28
+ * - The {@link BUDGETED_VENDORS} — `anthropic` and `gemini` — reach the model
29
+ * through the ai-service proxy, are metered by it, and stamp their label on a
30
+ * {@link BudgetExhaustedError}. For these the label is both an attribution key
31
+ * and display copy.
32
+ * - `chrome` and `openai` are **display-only**. `ChromeProvider` talks to the
33
+ * on-device Prompt API and the proxy refuses `openai` outright, so neither can
34
+ * be refused for budget or stamp a label — but both report a `provider` from
35
+ * `getStatus()`, which puts them in the assistant's reachable set, which is
36
+ * what the blocked banner names when it tells a walled user where they can
37
+ * still go ("Switch to Chrome to keep going."). Dropping either entry would
38
+ * print the raw type there.
39
+ *
40
+ * `'none'` is excluded deliberately: it is the "no provider configured" sentinel,
41
+ * not a vendor, and nothing can be refused by it — nor switched to.
42
+ *
43
+ * @beta
44
+ */
45
+ export const VENDOR_LABELS = Object.freeze({
46
+ anthropic: 'Anthropic',
47
+ gemini: 'Gemini',
48
+ openai: 'OpenAI',
49
+ chrome: 'Chrome',
50
+ });
51
+ /**
52
+ * The vendors whose spend the ai-service proxy meters — i.e. the only vendors
53
+ * that can raise a {@link BudgetExhaustedError}, and therefore the only ones a
54
+ * 402's `otherVendorAvailable: false` is a statement about.
55
+ *
56
+ * Deliberately narrower than the keys of {@link VENDOR_LABELS}, and it must stay
57
+ * exactly the proxy's own list — `VENDORS` in ai-service's `utils/aiVendor.js`.
58
+ * A vendor listed here that the proxy does not meter gets walled by the
59
+ * `otherVendorAvailable: false` sweep on a verdict that says nothing about it,
60
+ * and if it is reachable, `blocked` then derives true and locks a composer with
61
+ * headroom left.
62
+ *
63
+ * Two vendors are excluded for that reason:
64
+ * - `chrome` runs on-device — no pot to exhaust, and free.
65
+ * - `openai` is **not budgeted by the proxy**. ai-service rejects it up front
66
+ * with `400 UNSUPPORTED_PROVIDER` (`SUPPORTED_PROVIDERS` in `aiVendor.js`), no
67
+ * `MODEL_PRICING` row names it, and `otherVendorAvailable` is computed over
68
+ * Anthropic and Gemini alone. So it can never raise a 402, and a 402 is never
69
+ * a statement about it.
70
+ *
71
+ * @beta
72
+ */
73
+ export const BUDGETED_VENDORS = Object.freeze([
74
+ 'anthropic',
75
+ 'gemini',
76
+ ]);
77
+ /**
78
+ * Whether this vendor's spend is metered by the proxy — see
79
+ * {@link BUDGETED_VENDORS}.
80
+ *
81
+ * A HOST-FACING helper with, deliberately, no internal caller: the library's
82
+ * own consumers iterate {@link BUDGETED_VENDORS} directly (structural, cannot
83
+ * drift), while a host writing its own budget pre-flight or status surface
84
+ * needs the membership test in predicate form. Kept exported for that use —
85
+ * genesis-create's pre-flight is the shape of consumer it exists for.
86
+ *
87
+ * @beta
88
+ */
89
+ export const isBudgetedVendor = (vendor) => vendor != null && BUDGETED_VENDORS.includes(vendor);
90
+ /** Reverse index of {@link VENDOR_LABELS}, lower-cased, built once. */
91
+ const VENDOR_TYPE_BY_LABEL = new Map(Object.entries(VENDOR_LABELS).map(([type, label]) => [
92
+ label.toLowerCase(),
93
+ type,
94
+ ]));
95
+ /**
96
+ * The {@link AIProviderType} behind a vendor label, or `undefined` for a label
97
+ * no vendor claims.
98
+ *
99
+ * Case-insensitive and whitespace-tolerant, because the label travels as free
100
+ * text on the wire (the driver contract carries `vendorLabel`, not the type) and
101
+ * an unrecognised label must degrade to "unattributable" rather than to a wrong
102
+ * attribution — blocking the wrong vendor is worse than blocking none.
103
+ *
104
+ * @beta
105
+ */
106
+ export function vendorTypeOfLabel(label) {
107
+ if (typeof label !== 'string')
108
+ return undefined;
109
+ return VENDOR_TYPE_BY_LABEL.get(label.trim().toLowerCase());
110
+ }
111
+ /**
112
+ * HTTP status the ai-service proxy rejects an over-budget request with, in both
113
+ * the legacy JSON mode (the response status) and the NDJSON framed mode (the
114
+ * `status` on the terminal `err` frame).
115
+ *
116
+ * Deliberately **absent** from every transport's `RETRYABLE_STATUSES`: the budget
117
+ * does not refill on a backoff ladder, so retrying only delays the inevitable
118
+ * five times over.
119
+ */
120
+ export const BUDGET_EXCEEDED_STATUS = 402;
121
+ /**
122
+ * The single copy shown to a user whose AI budget is gone — the transcript bubble
123
+ * the chat driver appends, and the default text of the assistant's blocked banner.
124
+ *
125
+ * Deliberately **vendor-neutral**: the same bundle ships to white-labelled
126
+ * deployments where "contact Genesis" is simply wrong. A host that wants
127
+ * branded wording overrides both surfaces — the banner via
128
+ * `FoundationAiAssistant.setBlocked(true, reason)`, the transcript bubble via
129
+ * `ChatDriverConfig.budgetExhaustedMessage` — so neither is stuck with this
130
+ * default while the other is customised.
131
+ *
132
+ * @beta
133
+ */
134
+ export const DEFAULT_BUDGET_EXHAUSTED_MESSAGE = "You've reached your AI usage limit. Contact your administrator to raise it.";
135
+ /**
136
+ * Thrown when the AI-spend budget for the caller (user, tenant, or project) is
137
+ * exhausted and the ai-service proxy refuses the request outright — HTTP `402`
138
+ * with `code: 'BUDGET_EXCEEDED'`, in either the legacy JSON or the NDJSON framed
139
+ * mode.
140
+ *
141
+ * This is a **terminal, non-transient** condition, in the same family as
142
+ * `ResponseTruncatedError`: no amount of retrying clears it, because nothing
143
+ * about the request is wrong. The budget has to be raised out-of-band before any
144
+ * further call can succeed, so both the transport retry ladder and the driver's
145
+ * transient-retry catch step aside for it and the failure surfaces immediately
146
+ * as the `'budget-exhausted'` `TurnFailureReason`.
147
+ *
148
+ * `budgetUsd`/`spentUsd` are populated from the rejection body when the proxy
149
+ * supplies them (the workstream-C contract does); they are optional because a
150
+ * plain-text or truncated 402 from an older proxy still has to classify.
151
+ *
152
+ * @beta
153
+ */
154
+ export class BudgetExhaustedError extends Error {
155
+ constructor(
156
+ /** Vendor label of the transport that was refused (e.g. `'Anthropic'`). */
157
+ vendorLabel,
158
+ /** The configured spend cap in USD, when the proxy reported one. */
159
+ budgetUsd,
160
+ /** Spend already booked against that cap in USD, when the proxy reported it. */
161
+ spentUsd,
162
+ /** The proxy's human-readable rejection message, when present. */
163
+ detail,
164
+ /**
165
+ * The fields the proxy reports about the wider budget picture. An object
166
+ * rather than two more positional arguments: the four above are already the
167
+ * limit of what reads at a call site, and these two are set together or not
168
+ * at all.
169
+ */
170
+ extra) {
171
+ super(`${vendorLabel} request refused: the AI usage budget is exhausted` +
172
+ (budgetUsd != null
173
+ ? ` (spent ${spentUsd != null ? `$${spentUsd}` : 'an unknown amount'} of a $${budgetUsd} budget)`
174
+ : '') +
175
+ (detail ? `: ${detail}` : '') +
176
+ '. Retrying will not clear this — the budget must be raised.');
177
+ this.vendorLabel = vendorLabel;
178
+ this.budgetUsd = budgetUsd;
179
+ this.spentUsd = spentUsd;
180
+ this.detail = detail;
181
+ this.name = 'BudgetExhaustedError';
182
+ this.otherVendorAvailable = extra === null || extra === void 0 ? void 0 : extra.otherVendorAvailable;
183
+ this.serverVendor = extra === null || extra === void 0 ? void 0 : extra.serverVendor;
184
+ }
185
+ }
186
+ /**
187
+ * True for a budget rejection in either wire mode: the contracted `402`, or the
188
+ * `BUDGET_EXCEEDED` code under **any** status.
189
+ *
190
+ * Both keys are load-bearing, and they are not redundant:
191
+ *
192
+ * - `status` is the key the workstream-C contract guarantees ("402 always"), and
193
+ * the only one a plain-text or unparseable rejection carries.
194
+ * - `code` is the cheap defence against that contract drifting. Nothing stops a
195
+ * proxy from mapping the refusal onto `403` or `429` — and `429` is in *both*
196
+ * transports' `RETRYABLE_STATUSES`, so a status-only check would hand the user
197
+ * the exact bug GENC-1464 exists to fix: five doomed requests and ~31s of backoff
198
+ * before an opaque failure. A well-formed `{ t: 'err', status: 429, code:
199
+ * 'BUDGET_EXCEEDED' }` frame is accepted by `readFramedBody` (it only rejects a
200
+ * non-numeric status), so this is a reachable shape, not a hypothetical one.
201
+ *
202
+ * The false-positive cost is a proxy sending `code: 'BUDGET_EXCEEDED'` on a
203
+ * genuinely retryable failure — a shape the contract does not permit.
204
+ *
205
+ * Internal to the transports (unlike `BudgetExhaustedError`, which hosts branch
206
+ * on): deliberately **not** re-exported from the package index.
207
+ *
208
+ * @internal
209
+ */
210
+ export const isBudgetRejection = (status, code) => status === BUDGET_EXCEEDED_STATUS || code === BUDGET_EXCEEDED_CODE;
211
+ /**
212
+ * Best-effort JSON parse of an error body — `undefined` rather than a throw.
213
+ * Shared by every caller that has to classify a rejection body before it knows
214
+ * whether the body is JSON at all.
215
+ *
216
+ * @internal
217
+ */
218
+ export const parseJsonOrUndefined = (text) => {
219
+ try {
220
+ return JSON.parse(text);
221
+ }
222
+ catch (_a) {
223
+ return undefined;
224
+ }
225
+ };
226
+ /**
227
+ * Read the `code` field off an already-parsed rejection body, ignoring anything
228
+ * that is not a string. Pairs with {@link isBudgetRejection} at the legacy call
229
+ * sites, which have a parsed body rather than a typed frame.
230
+ *
231
+ * @internal
232
+ */
233
+ export const codeOf = (payload) => {
234
+ const code = payload === null || payload === void 0 ? void 0 : payload.code;
235
+ return typeof code === 'string' ? code : undefined;
236
+ };
237
+ /** Narrow an unknown JSON value to a number, ignoring anything else. */
238
+ const numberOrUndefined = (value) => typeof value === 'number' && Number.isFinite(value) ? value : undefined;
239
+ /** Narrow an unknown JSON value to a boolean, ignoring anything else. */
240
+ const booleanOrUndefined = (value) => typeof value === 'boolean' ? value : undefined;
241
+ /** Narrow an unknown JSON value to a non-empty string, ignoring anything else. */
242
+ const stringOrUndefined = (value) => typeof value === 'string' && value.trim() !== '' ? value : undefined;
243
+ /**
244
+ * Build a {@link BudgetExhaustedError} from a rejection payload of either shape:
245
+ * the legacy body `{ error, code, budgetUsd, spentUsd, vendor,
246
+ * otherVendorAvailable }` or the framed err frame's `details` (the same fields
247
+ * minus `error`) plus its top-level `error`.
248
+ *
249
+ * The fields read off the wire, and why each is here:
250
+ *
251
+ * | field | used for |
252
+ * | ---------------------- | ----------------------------------------------------- |
253
+ * | `budgetUsd` | the cap in the banner's figures |
254
+ * | `spentUsd` | the spend in the banner's figures |
255
+ * | `error` | the proxy's human-readable detail |
256
+ * | `vendor` | attribution when the transport's own label is unclaimed |
257
+ * | `otherVendorAvailable` | whether "switch vendor" is honest advice at all |
258
+ *
259
+ * Tolerant by design — a `402` classifies even when the payload is missing,
260
+ * unparseable, or carries none of these. Each field is narrowed independently,
261
+ * so a proxy that sends `null` for a figure it does not know (which the
262
+ * ai-service side now does, in preference to a misleading `0`) still yields the
263
+ * vendor and the availability verdict.
264
+ */
265
+ export function budgetExhaustedFrom(vendorLabel, payload, fallbackDetail) {
266
+ var _a, _b, _c, _d;
267
+ const body = (typeof payload === 'object' && payload !== null ? payload : {});
268
+ // The framed shape nests everything but `error` under `details`; the legacy
269
+ // body has it all at the top level. Read both so one helper serves both call
270
+ // sites.
271
+ const details = (typeof body.details === 'object' && body.details !== null ? body.details : {});
272
+ const detail = typeof body.error === 'string' ? body.error : fallbackDetail;
273
+ return new BudgetExhaustedError(vendorLabel, (_a = numberOrUndefined(body.budgetUsd)) !== null && _a !== void 0 ? _a : numberOrUndefined(details.budgetUsd), (_b = numberOrUndefined(body.spentUsd)) !== null && _b !== void 0 ? _b : numberOrUndefined(details.spentUsd), detail, {
274
+ otherVendorAvailable: (_c = booleanOrUndefined(body.otherVendorAvailable)) !== null && _c !== void 0 ? _c : booleanOrUndefined(details.otherVendorAvailable),
275
+ serverVendor: (_d = stringOrUndefined(body.vendor)) !== null && _d !== void 0 ? _d : stringOrUndefined(details.vendor),
276
+ });
277
+ }
@@ -16,11 +16,12 @@ const CHROME_AVAILABILITY_OPTIONS = {
16
16
  */
17
17
  export class ChromePromptTransport {
18
18
  static getLanguageModel() {
19
- var _a, _b, _c;
19
+ var _a;
20
+ var _b, _c;
20
21
  if (typeof globalThis === 'undefined')
21
22
  return undefined;
22
23
  const g = globalThis;
23
- return (_b = (_a = g.LanguageModel) !== null && _a !== void 0 ? _a : g.languageModel) !== null && _b !== void 0 ? _b : (_c = g.ai) === null || _c === void 0 ? void 0 : _c.languageModel;
24
+ return (_c = (_b = g.LanguageModel) !== null && _b !== void 0 ? _b : g.languageModel) !== null && _c !== void 0 ? _c : (_a = g.ai) === null || _a === void 0 ? void 0 : _a.languageModel;
24
25
  }
25
26
  /**
26
27
  * Returns the raw Chrome availability state.