@genesislcap/ai-assistant 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 (100) hide show
  1. package/dist/ai-assistant.api.json +392 -6
  2. package/dist/ai-assistant.d.ts +616 -24
  3. package/dist/chat-driver.cjs +315 -46
  4. package/dist/chat-driver.cjs.map +3 -3
  5. package/dist/chat-driver.mjs +315 -46
  6. package/dist/chat-driver.mjs.map +3 -3
  7. package/dist/custom-elements.json +254 -10
  8. package/dist/dts/channel/ai-activity-bus.d.ts.map +1 -1
  9. package/dist/dts/channel/ai-activity-channel.d.ts +51 -1
  10. package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
  11. package/dist/dts/components/activity-halo/activity-halo.d.ts.map +1 -1
  12. package/dist/dts/components/agent-picker/agent-picker.d.ts.map +1 -1
  13. package/dist/dts/components/agent-picker/agent-picker.template.d.ts.map +1 -1
  14. package/dist/dts/components/chat-bubble/chat-bubble.d.ts.map +1 -1
  15. package/dist/dts/components/chat-driver/chat-driver.d.ts +99 -1
  16. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  17. package/dist/dts/components/chat-driver/chat-driver.test.d.ts.map +1 -1
  18. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts.map +1 -1
  19. package/dist/dts/components/chat-markdown/chat-markdown.d.ts.map +1 -1
  20. package/dist/dts/components/flowing-waves-indicator.d.ts.map +1 -1
  21. package/dist/dts/components/halo-overlay.d.ts.map +1 -1
  22. package/dist/dts/components/orchestrating-driver/orchestrating-driver.budget.test.d.ts +2 -0
  23. package/dist/dts/components/orchestrating-driver/orchestrating-driver.budget.test.d.ts.map +1 -0
  24. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +14 -0
  25. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
  26. package/dist/dts/components/popout-manager/popout-manager.d.ts.map +1 -1
  27. package/dist/dts/components/settings-modal/settings-modal.template.d.ts.map +1 -1
  28. package/dist/dts/components/waves-indicator.d.ts.map +1 -1
  29. package/dist/dts/main/blocked-state.test.d.ts +2 -0
  30. package/dist/dts/main/blocked-state.test.d.ts.map +1 -0
  31. package/dist/dts/main/main.d.ts +394 -6
  32. package/dist/dts/main/main.d.ts.map +1 -1
  33. package/dist/dts/main/main.styles.d.ts.map +1 -1
  34. package/dist/dts/main/main.styles.test.d.ts +2 -0
  35. package/dist/dts/main/main.styles.test.d.ts.map +1 -0
  36. package/dist/dts/main/main.template.d.ts +53 -0
  37. package/dist/dts/main/main.template.d.ts.map +1 -1
  38. package/dist/dts/main/main.types.d.ts +2 -2
  39. package/dist/dts/main/main.types.d.ts.map +1 -1
  40. package/dist/dts/state/ai-assistant-slice.d.ts +163 -7
  41. package/dist/dts/state/ai-assistant-slice.d.ts.map +1 -1
  42. package/dist/dts/state/debug-event-log.d.ts +6 -1
  43. package/dist/dts/state/debug-event-log.d.ts.map +1 -1
  44. package/dist/dts/state/persistence/session-persistence-provider.d.ts.map +1 -1
  45. package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
  46. package/dist/dts/state/session-store.d.ts +12 -1
  47. package/dist/dts/state/session-store.d.ts.map +1 -1
  48. package/dist/dts/suggestions/chat-suggestions.d.ts.map +1 -1
  49. package/dist/dts/utils/animated-panel-toggle.d.ts.map +1 -1
  50. package/dist/dts/utils/message-partition.d.ts.map +1 -1
  51. package/dist/esm/components/agent-picker/agent-picker.js +2 -1
  52. package/dist/esm/components/agent-picker/agent-picker.template.js +2 -2
  53. package/dist/esm/components/chat-bubble/chat-bubble.js +2 -1
  54. package/dist/esm/components/chat-driver/align-event-globals.js +1 -0
  55. package/dist/esm/components/chat-driver/chat-driver.js +281 -38
  56. package/dist/esm/components/chat-driver/chat-driver.test.js +471 -14
  57. package/dist/esm/components/orchestrating-driver/orchestrating-driver.budget.test.js +312 -0
  58. package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +94 -9
  59. package/dist/esm/components/popout-manager/popout-manager.js +4 -1
  60. package/dist/esm/components/settings-modal/settings-modal.template.js +5 -8
  61. package/dist/esm/main/blocked-state.test.js +969 -0
  62. package/dist/esm/main/main.js +834 -104
  63. package/dist/esm/main/main.styles.js +47 -0
  64. package/dist/esm/main/main.styles.test.js +87 -0
  65. package/dist/esm/main/main.template.js +131 -20
  66. package/dist/esm/state/ai-assistant-slice.js +145 -7
  67. package/dist/esm/state/ai-assistant-slice.test.js +138 -1
  68. package/dist/esm/state/debug-event-log.js +9 -3
  69. package/dist/esm/state/debug-event-log.test.js +49 -1
  70. package/dist/esm/state/persistence/session-persister.js +13 -10
  71. package/dist/esm/state/persistence/session-snapshot.js +3 -2
  72. package/dist/esm/state/persistence/session-snapshot.test.js +18 -0
  73. package/dist/esm/utils/collect-session-models.test.js +2 -1
  74. package/dist/esm/utils/condense-history.js +6 -4
  75. package/dist/esm/utils/condense-history.test.js +15 -21
  76. package/dist/esm/utils/flatten-sub-agent-messages.js +4 -3
  77. package/dist/esm/utils/history-transform.js +2 -1
  78. package/dist/esm/utils/resolve-cost-history-config.js +4 -3
  79. package/dist/esm/utils/resolve-preference-baseline.js +2 -1
  80. package/dist/esm/utils/sum-usage.js +7 -6
  81. package/dist/tsconfig.tsbuildinfo +1 -1
  82. package/docs/migration-GENC-1464.md +562 -0
  83. package/docs/sub_agent.md +20 -3
  84. package/package.json +17 -17
  85. package/src/channel/ai-activity-channel.ts +56 -2
  86. package/src/components/chat-driver/chat-driver.test.ts +549 -0
  87. package/src/components/chat-driver/chat-driver.ts +324 -14
  88. package/src/components/orchestrating-driver/orchestrating-driver.budget.test.ts +438 -0
  89. package/src/components/orchestrating-driver/orchestrating-driver.ts +101 -6
  90. package/src/main/blocked-state.test.ts +1316 -0
  91. package/src/main/main.styles.test.ts +103 -0
  92. package/src/main/main.styles.ts +47 -0
  93. package/src/main/main.template.ts +131 -4
  94. package/src/main/main.ts +704 -10
  95. package/src/state/ai-assistant-slice.test.ts +215 -0
  96. package/src/state/ai-assistant-slice.ts +218 -8
  97. package/src/state/debug-event-log.test.ts +63 -0
  98. package/src/state/debug-event-log.ts +7 -2
  99. package/src/state/persistence/session-snapshot.test.ts +22 -0
  100. package/tsconfig.json +1 -0
@@ -3,6 +3,7 @@ import type { AggregateUsage } from '@genesislcap/foundation-ai';
3
3
  import { AIProviderRegistry } from '@genesislcap/foundation-ai';
4
4
  import type { AIProviderRegistryStatusEntry } from '@genesislcap/foundation-ai';
5
5
  import type { AIProviderType } from '@genesislcap/foundation-ai';
6
+ import { BudgetExhaustedError } from '@genesislcap/foundation-ai';
6
7
  import type { CachePolicy } from '@genesislcap/foundation-ai';
7
8
  import type { ChatAttachment } from '@genesislcap/foundation-ai';
8
9
  import type { ChatConfig } from '@genesislcap/foundation-ai';
@@ -15,6 +16,7 @@ import type { ChatToolDefinition } from '@genesislcap/foundation-ai';
15
16
  import type { ChatToolHandlers } from '@genesislcap/foundation-ai';
16
17
  import { ElementStyles } from '@genesislcap/web-core';
17
18
  import { GenesisElement } from '@genesislcap/web-core';
19
+ import { InputOverride } from '../state/ai-assistant-slice';
18
20
  import type { InteractionRequestOptions } from '@genesislcap/foundation-ai';
19
21
  import type { InteractionResult } from '@genesislcap/foundation-ai';
20
22
  import { InterfaceSymbol } from '@microsoft/fast-foundation';
@@ -219,9 +221,59 @@ export declare interface AgenticActivityEvents {
219
221
  * driver dispose, and an agent handoff the detail is `undefined` — the historical shape,
220
222
  * kept byte-identical so subscribers that only care about the boundary can keep ignoring
221
223
  * it. Structured-cloneable so it survives the cross-tab BroadcastChannel hop.
224
+ *
225
+ * A `'budget-exhausted'` failure additionally carries `vendor` — the concrete
226
+ * vendor the walled turn resolved to (GENC-1464), which is NOT the same thing as
227
+ * the registry alias recorded on the debug-log entry. Optional and additive: a
228
+ * subscriber reading only `failureReason` is unaffected, and every other
229
+ * failure still emits the historical `{ failureReason }` with no `vendor` key.
230
+ * It exists so a later per-vendor budget model is an additive change rather
231
+ * than a retrofit — the vendor is known at the transport and at the driver, and
232
+ * was previously discarded between them.
233
+ *
234
+ * Note this topic is forwarded on the tab-scoped channel, so a wall hit in a
235
+ * popped-out window reaches the main window's subscribers too — which is why
236
+ * the assistant's blocked latch fires there as well. Correct for a shared spend
237
+ * cap; see `docs/migration-GENC-1464.md` §Scope.
222
238
  */
223
239
  'tool-loop-end': {
224
240
  failureReason?: TurnFailureReason;
241
+ vendor?: AIProviderType;
242
+ /**
243
+ * Proxy-reported spend figures, present only on `budget-exhausted`. Carried
244
+ * here because this event — not the driver's return value — is what latches
245
+ * the blocked state for a wall hit INSIDE the tool loop (the common case):
246
+ * the publish happens in `sendMessage`'s `finally`, so it lands before the
247
+ * return-value seam and wins the latch. Without these the banner would fall
248
+ * back to the generic copy in exactly the path the figures were added for.
249
+ * Plain numbers + string keep the detail structured-cloneable for the
250
+ * cross-tab hop.
251
+ */
252
+ budget?: {
253
+ budgetUsd?: number;
254
+ spentUsd?: number;
255
+ vendorLabel: string;
256
+ /**
257
+ * The refusing vendor as a typed value: normalised from `vendorLabel`
258
+ * where a vendor claims that label, otherwise from the proxy's own
259
+ * `vendor` field on the 402 — so it can disagree with `vendorLabel`,
260
+ * which is what keeps attribution working behind a white-labelled or
261
+ * multiplexing gateway.
262
+ *
263
+ * Distinct from the detail's top-level `vendor` (the driver's
264
+ * last-resolved provider): this one comes from the transport that was
265
+ * actually refused, so it is the one a per-vendor latch trusts first.
266
+ */
267
+ vendor?: AIProviderType;
268
+ /**
269
+ * The proxy's verdict on whether any OTHER vendor it meters still has
270
+ * headroom. The one fact here a subscriber cannot work out for itself:
271
+ * the registry says which vendors EXIST, never which still have
272
+ * budget. A `false` is what stops the banner advising a switch to a
273
+ * vendor that is equally spent.
274
+ */
275
+ otherVendorAvailable?: boolean;
276
+ };
225
277
  } | undefined;
226
278
  /**
227
279
  * Fired when a tool handler hands a widget to the user mid-loop and parks awaiting it
@@ -405,9 +457,9 @@ export declare interface AiAssistantAnimationDef {
405
457
  */
406
458
  export declare const AiAssistantEvent: {
407
459
  /** Session wiped via the lifecycle menu's Clear. `detail`: `SessionClearedDetail`. */
408
- readonly SessionCleared: "session-cleared";
460
+ readonly SessionCleared: 'session-cleared';
409
461
  /** Header pressed in `popout-mode="expand"` (drag-to-popout hosts). `detail`: `ChatHeaderMouseDownDetail`. */
410
- readonly ChatHeaderMouseDown: "chat-header-mousedown";
462
+ readonly ChatHeaderMouseDown: 'chat-header-mousedown';
411
463
  };
412
464
 
413
465
  /**
@@ -1053,6 +1105,45 @@ declare interface BaseAgentConfig {
1053
1105
  notResumableMessage?: string;
1054
1106
  }
1055
1107
 
1108
+ /**
1109
+ * Id of the blocked banner, referenced by the composer controls'
1110
+ * `aria-describedby`. Shadow-DOM-scoped, so a fixed string cannot collide with
1111
+ * the host page — and IDREF resolution is same-root, which is exactly where both
1112
+ * ends of this reference live.
1113
+ *
1114
+ * @internal
1115
+ */
1116
+ export declare const BLOCKED_BANNER_ID = "blocked-banner";
1117
+
1118
+ /**
1119
+ * Class list for the banner below, joined rather than interpolated so an
1120
+ * inapplicable modifier contributes nothing. Two interpolations directly in the
1121
+ * attribute emitted `class="blocked-banner "` in the common (unblocked) case —
1122
+ * harmless to the browser, but it shows up in every DOM snapshot and every
1123
+ * innerHTML assertion a host writes against this element.
1124
+ *
1125
+ * The two modifiers name what they actually gate, which is why neither is
1126
+ * `is-blocked`: `is-visible` means the banner has something to say, and that
1127
+ * includes PARTIAL exhaustion — one vendor walled, composer still live, `blocked`
1128
+ * false. `is-partial` then softens the treatment for exactly that case. Naming
1129
+ * the first after `blocked` read as a contradiction beside the second, and made
1130
+ * the styles say `.blocked-banner.is-blocked` to mean "visible".
1131
+ *
1132
+ * Exported for the unit test that pins the attribute; not part of the element
1133
+ * API.
1134
+ *
1135
+ * @internal
1136
+ */
1137
+ export declare const blockedBannerClasses: (x: FoundationAiAssistant) => string;
1138
+
1139
+ /**
1140
+ * The `budget` payload carried on a `'budget-exhausted'` {@link ChatDriverResult}.
1141
+ * Derived from the type rather than restated so the two cannot drift.
1142
+ */
1143
+ declare type BudgetDetail = NonNullable<Extract<ChatDriverResult, {
1144
+ reason: 'done';
1145
+ }>['budget']>;
1146
+
1056
1147
  export { CachePolicy }
1057
1148
 
1058
1149
  /**
@@ -1235,6 +1326,10 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
1235
1326
  * Set when a sub-agent's tool loop ends without `completeSubAgent` being
1236
1327
  * called. Read by the parent's `invokeSubAgent` to build the `{ ok: false }`
1237
1328
  * branch of `requestSubAgent`. Only ever set when `isSubAgent` is true.
1329
+ *
1330
+ * `budget` rides along on a `'budget_exhausted'` failure so the parent inherits
1331
+ * the child's ATTRIBUTION, not just the fact of a wall — see
1332
+ * `budgetWallDetail`.
1238
1333
  */
1239
1334
  private subAgentFailure;
1240
1335
  /**
@@ -1383,6 +1478,39 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
1383
1478
  private readonly sessionKey;
1384
1479
  /** Injected activity bus; defaults to a no-op off-browser (Node/tests/headless). */
1385
1480
  private readonly activityBus;
1481
+ /** Transcript copy for a budget wall — see `ChatDriverConfig.budgetExhaustedMessage`. */
1482
+ private readonly budgetExhaustedMessage;
1483
+ /**
1484
+ * Set the moment a budget wall is observed anywhere in this turn — this
1485
+ * driver's own 402, or a sub-agent's (which surfaces here only as a
1486
+ * `'budget_exhausted'` tool result). Read at the top of the tool loop to end
1487
+ * the turn before issuing another model call that would hit the same wall.
1488
+ * Reset per turn alongside the other per-turn counters.
1489
+ */
1490
+ private budgetExhaustedThisTurn;
1491
+ /**
1492
+ * The refusing vendor's own attribution for the wall `budgetExhaustedThisTurn`
1493
+ * records, when it was knowable. Kept SEPARATE from the flag rather than
1494
+ * replacing it: a figure-less 402 from a transport no vendor claims yields no
1495
+ * detail at all (`budgetDetailOf` returns `undefined`), and folding the two
1496
+ * would make that case stop ending the turn.
1497
+ *
1498
+ * It matters most for a sub-agent's wall. The child can sit on a different
1499
+ * vendor from its parent — `applyAgent` reads `config.provider` — so without
1500
+ * this the parent's short-circuit reports `lastResolvedProvider`, i.e. the one
1501
+ * vendor that did NOT refuse. Under a mixed registry that walls Gemini because
1502
+ * an Anthropic child 402'd, and if those are the only two reachable vendors the
1503
+ * host then derives `blocked` and locks a composer that still had headroom.
1504
+ */
1505
+ private budgetWallDetail?;
1506
+ /**
1507
+ * Whether this turn's budget wall came from a SUB-AGENT rather than this
1508
+ * driver's own request. Decides whether `lastResolvedProvider` is a valid
1509
+ * attribution fallback: for an own wall it is the refusing vendor, for a
1510
+ * child's wall it is the parent's vendor — the one known NOT to have refused.
1511
+ * Reset per turn alongside `budgetWallDetail`.
1512
+ */
1513
+ private budgetWallViaSubAgent;
1386
1514
  constructor(providerRegistry: AIProviderRegistry, config?: ChatDriverConfig);
1387
1515
  /**
1388
1516
  * Tear down the driver: aborts the lifecycle signal so any in-flight provider
@@ -1429,14 +1557,49 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
1429
1557
  * the historical `{ reason: 'done' }`.
1430
1558
  */
1431
1559
  private turnDone;
1560
+ /**
1561
+ * Terminal budget outcome for a wall hit **outside** the tool loop — today,
1562
+ * `OrchestratingDriver`'s classification phase, which calls the provider
1563
+ * directly and so never enters `runToolLoop`.
1564
+ *
1565
+ * Does **not** publish `tool-loop-end`: no `tool-loop-start` was published for
1566
+ * the classify phase, and an unbalanced end would break start/end pairing for
1567
+ * subscribers that rely on it. The driver **return value** is what reports this
1568
+ * case — see `FoundationAiAssistant`'s latch, which reads both seams for
1569
+ * exactly this reason.
1570
+ *
1571
+ * The non-sub-agent tail of the in-loop `BudgetExhaustedError` branch lives
1572
+ * here so there is one copy of the log line, the debug-log entry, the
1573
+ * transcript bubble and the result shape rather than two that can drift.
1574
+ *
1575
+ * @param pendingUserMessage - a user message that has NOT yet been appended,
1576
+ * appended first so the answer does not end up replying to nothing. Only the
1577
+ * classification seam passes it: `OrchestratingDriver` dispatches the user's
1578
+ * text as an optimistic `history-updated` detail and leaves the real append
1579
+ * to `chatDriver.sendMessage`, which never runs when `classify()` throws — so
1580
+ * the bubble below would re-dispatch a history the user's own message was
1581
+ * never in, and it would vanish from the transcript on the next render. The
1582
+ * in-loop caller has already appended it and passes nothing.
1583
+ *
1584
+ * @internal
1585
+ */
1586
+ reportBudgetExhausted(e: BudgetExhaustedError, pendingUserMessage?: ChatMessage): ChatDriverResult;
1432
1587
  /** The typed failure reason on a loop result, or `undefined` for a clean turn / handoff. */
1433
1588
  private static failureReasonOf;
1434
1589
  /**
1435
1590
  * Build the `tool-loop-end` event detail for a turn's result. A failure carries a
1436
1591
  * `{ failureReason }` detail; a clean turn emits `undefined` — the historical shape,
1437
1592
  * kept byte-identical so subscribers see exactly what they always have.
1593
+ *
1594
+ * A budget failure additionally carries `vendor` — the concrete vendor
1595
+ * (`'anthropic'`/`'gemini'`) the walled turn resolved to, which the driver knows
1596
+ * and used to discard. Optional and additive: a subscriber reading only
1597
+ * `failureReason` is unaffected, a non-budget failure still emits the historical
1598
+ * `{ failureReason }` with no `vendor` key, and the value is a plain string so
1599
+ * the detail stays structured-cloneable for the cross-tab hop. It is the field a
1600
+ * per-vendor budget model needs and the one that would be awkward to retrofit.
1438
1601
  */
1439
- private static loopEndDetail;
1602
+ private loopEndDetail;
1440
1603
  /**
1441
1604
  * Swap in a new agent's configuration. Called by OrchestratingDriver before
1442
1605
  * each specialist turn so the shared driver runs with the right tools and prompt.
@@ -1503,6 +1666,7 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
1503
1666
  */
1504
1667
  getSubAgentFailure(): {
1505
1668
  reason: SubAgentFailureReason;
1669
+ budget?: BudgetDetail;
1506
1670
  } | undefined;
1507
1671
  /**
1508
1672
  * Record a sub-agent failure reason (first one wins). No-op for top-level
@@ -1735,6 +1899,22 @@ export declare interface ChatDriverConfig {
1735
1899
  * it defaults to {@link NOOP_ACTIVITY_BUS} so no `BroadcastChannel` is ever opened.
1736
1900
  */
1737
1901
  activityBus?: ActivityBus;
1902
+ /**
1903
+ * Transcript copy appended when the AI-spend budget wall is hit (GENC-1464).
1904
+ * Defaults to `DEFAULT_BUDGET_EXHAUSTED_MESSAGE`.
1905
+ *
1906
+ * The assistant element already lets a host override the blocked **banner**
1907
+ * via `setBlocked(true, reason)`; without this the transcript **bubble** stayed
1908
+ * on the default, so a white-labelled host got its own copy in the banner and
1909
+ * the shipped default directly below it. Passing the same effective copy here
1910
+ * keeps the two surfaces saying one thing.
1911
+ *
1912
+ * Deliberately a driver-config field rather than something read off a chat
1913
+ * config: `ChatDriver` has no `chatConfig` and is used standalone (see
1914
+ * `chat-driver-node`), so threading one in would be a much larger and less
1915
+ * reversible change.
1916
+ */
1917
+ budgetExhaustedMessage?: string;
1738
1918
  }
1739
1919
 
1740
1920
  export { ChatFallback }
@@ -1766,6 +1946,31 @@ declare type ChatInteractionEventsMap = {
1766
1946
 
1767
1947
  export { ChatToolChoice }
1768
1948
 
1949
+ /**
1950
+ * `aria-describedby` for the composer's textarea, send button and attach button:
1951
+ * the banner's id whenever the banner has something to say, otherwise `null` (so
1952
+ * the attribute is omitted rather than emitted empty).
1953
+ *
1954
+ * Keyed on `bannerVisible`, NOT on `blocked`, and that is the point. The
1955
+ * PARTIAL state — some vendor walled, composer still live — is the state this
1956
+ * feature exists to create, and it was the one state with no accessible
1957
+ * explanation at all: `aria-disabled` and `aria-label` bind only on `blocked`, and
1958
+ * a live composer keeps the host's own placeholder, so a screen-reader user
1959
+ * arriving at the textarea heard "Type a message" with no hint that the next turn
1960
+ * might be refused. The banner's `role="status"` announces the text when it
1961
+ * CHANGES; this is what makes the same explanation reachable afterwards, on
1962
+ * demand, from the control it is about.
1963
+ *
1964
+ * Applied in the fully blocked state too, where it is additive: the `aria-label`
1965
+ * there states the reason as the control's name, and this restates it as its
1966
+ * description for the send/attach buttons, which carry neither.
1967
+ *
1968
+ * Exported for the unit test that pins it; not part of the element API.
1969
+ *
1970
+ * @internal
1971
+ */
1972
+ export declare const composerDescribedBy: (x: FoundationAiAssistant) => string | null;
1973
+
1769
1974
  /** A model used during a recorded cost session. */
1770
1975
  export declare interface CostSessionModelEntry {
1771
1976
  model: string;
@@ -1997,6 +2202,24 @@ export declare interface FallbackAgentConfig extends BaseAgentConfig {
1997
2202
  description?: never;
1998
2203
  }
1999
2204
 
2205
+ /**
2206
+ * Banner copy built from the figures a 402 actually reported, or `undefined`
2207
+ * when the proxy sent none.
2208
+ *
2209
+ * `undefined` is the meaningful return, not a fallback: paired with the
2210
+ * slice's "a re-latch without a reason keeps the existing explanation" rule, it
2211
+ * makes a figureless driver latch leave a host-supplied reason intact rather
2212
+ * than blanking it back to the default at the exact moment the wall is hit.
2213
+ *
2214
+ * Exported for the unit test that pins the formatting; not part of the element
2215
+ * API.
2216
+ *
2217
+ * @internal
2218
+ */
2219
+ export declare function formatBlockedReason(budget?: Extract<ChatDriverResult, {
2220
+ reason: 'done';
2221
+ }>['budget'], vendor?: AIProviderType): string | undefined;
2222
+
2000
2223
  /**
2001
2224
  * Foundation AI Assistant component.
2002
2225
  *
@@ -2127,13 +2350,22 @@ export declare class FoundationAiAssistant extends GenesisElement {
2127
2350
  get busy(): boolean;
2128
2351
  /**
2129
2352
  * True when a new send must be refused: a turn is running (`busy`), a page-reload
2130
- * restore is loading history that would clobber it (`restoring`), or a manual
2131
- * compaction is rewriting history (`compacting`). Mirrors the composer's
2132
- * `?disabled` gate so a **programmatic** `send`/`submitMessage` (e.g. a host's
2133
- * custom input while the built-in composer is hidden) can't slip past it and have
2134
- * its message wiped when the restored/compacted history lands (GENC-1351 §6).
2353
+ * restore is loading history that would clobber it (`restoring`), a manual
2354
+ * compaction is rewriting history (`compacting`), or a backend condition has
2355
+ * locked the assistant outright (`blocked` — e.g. an exhausted AI budget).
2356
+ * Mirrors the composer's `?disabled` gate so a **programmatic**
2357
+ * `send`/`submitMessage` (e.g. a host's custom input while the built-in composer
2358
+ * is hidden) can't slip past it and have its message wiped when the
2359
+ * restored/compacted history lands (GENC-1351 §6).
2135
2360
  */
2136
2361
  private get sendBlocked();
2362
+ /**
2363
+ * Why a programmatic send was refused, for `submitMessage`'s `errors`. A
2364
+ * backend block is called out distinctly because — unlike the transient
2365
+ * "busy" cases — waiting and retrying will never clear it, and a caller
2366
+ * looping on "Assistant is busy" would spin forever.
2367
+ */
2368
+ private sendRefusalReason;
2137
2369
  /**
2138
2370
  * Re-runs `agentsChanged` if the live `agents` array no longer matches the
2139
2371
  * fingerprint of the currently installed driver. Used to apply swaps that
@@ -2204,6 +2436,366 @@ export declare class FoundationAiAssistant extends GenesisElement {
2204
2436
  */
2205
2437
  get restoring(): boolean;
2206
2438
  set restoring(value: boolean);
2439
+ /**
2440
+ * Whether the assistant is blocked by a backend condition and cannot send —
2441
+ * today, an exhausted AI-spend budget (GENC-1464). While true the composer is
2442
+ * disabled, `send`/`submitMessage` refuse, suggestions stop being fetched, and
2443
+ * a persistent banner (`part="blocked-banner"`) sits above the composer
2444
+ * explaining why. The transcript stays visible and scrollable throughout —
2445
+ * unlike `compacting` and `restoring`, this does not replace the conversation.
2446
+ *
2447
+ * **Latched.** Nothing in the element clears it: not a new turn, not "Clear"
2448
+ * / "New chat", not a pop-in/out. It stays set until the host writes
2449
+ * `false` — because nothing the user can do inside the assistant refills a
2450
+ * budget. Hosts typically set it from their own pre-flight budget check on
2451
+ * mount, and clear it once a later check shows headroom again.
2452
+ *
2453
+ * The driver also latches it automatically when a turn ends with the
2454
+ * `'budget-exhausted'` failure reason — off the `tool-loop-end` activity bus
2455
+ * (which also covers a sub-agent wall, a turn this element did not start, and
2456
+ * an element swapped in mid-turn) and off the driver's return value (which
2457
+ * covers a wall hit during multi-agent classification, where no tool loop ran
2458
+ * and so no bus event fires). So a host that does no pre-flight at all still
2459
+ * gets a correct locked UI the moment the first 402 lands. The bus topic is
2460
+ * tab-scoped, so a wall hit in a popped-out window latches the main window
2461
+ * too — correct for a shared spend cap.
2462
+ *
2463
+ * **Lifetime — read this before relying on it as your source of truth.** The
2464
+ * latch is in-memory and per-`stateKey`:
2465
+ *
2466
+ * - It does **not** survive `switchSession`. Switching away tears the outgoing
2467
+ * session's store down entirely, so switching back yields a fresh, unblocked
2468
+ * store.
2469
+ * - It does **not** survive a page reload. It is deliberately absent from the
2470
+ * persisted session snapshot: the snapshot is long-lived, so a persisted
2471
+ * latch would outlive an out-of-band budget raise with no in-element way to
2472
+ * clear it — a stale lock is worse than re-deriving the state.
2473
+ *
2474
+ * The durable source of truth is therefore the **host's pre-flight**, which
2475
+ * should run on mount and on every session switch. See
2476
+ * `docs/migration-GENC-1464.md` §"How to adopt", Option B.
2477
+ *
2478
+ * @beta
2479
+ */
2480
+ get blocked(): boolean;
2481
+ set blocked(value: boolean);
2482
+ /**
2483
+ * The distinct vendors the registry can currently reach, from the provider
2484
+ * statuses this element already loads on connect and refreshes on every
2485
+ * observable-registry change.
2486
+ *
2487
+ * This is the element's answer to "which vendor would the next turn use" — a
2488
+ * question that has **no** correct answer and deliberately gets no API. The
2489
+ * provider is resolved per turn AND per agent: `activeProviderInput` may be an
2490
+ * async function of the turn's context, an orchestrated turn picks its agent
2491
+ * with an LLM `classify()` call, and sub-agents resolve their own providers.
2492
+ * Any pre-turn "peek" would therefore be a guess that is wrong precisely on the
2493
+ * multi-agent hosts per-vendor budgets exist for.
2494
+ *
2495
+ * Asking instead which vendors are REACHABLE is answerable, synchronous, and
2496
+ * free — and it is enough: the composer must stay live while any reachable
2497
+ * vendor has headroom, and must lock when none does. It also makes vendor-switch
2498
+ * recovery a derivation rather than a mutation: a host that swaps its registry
2499
+ * to another vendor fires the observable, the statuses reload, the walled vendor
2500
+ * drops out of this set, and `blocked` goes false with every latch left intact.
2501
+ *
2502
+ * @beta
2503
+ */
2504
+ get reachableVendors(): readonly AIProviderType[];
2505
+ /**
2506
+ * Vendors currently walled by the AI-spend budget, in the order they were
2507
+ * walled. Empty for a host that never adopts the per-vendor API.
2508
+ *
2509
+ * May include a vendor this registry cannot reach — either because the registry
2510
+ * moved on after the wall was latched, or because a 402's
2511
+ * `otherVendorAvailable: false` walls every vendor the proxy meters (which is
2512
+ * what that verdict is a statement about; see
2513
+ * {@link FoundationAiAssistant.latchBlockedFrom}). Neither costs anything
2514
+ * internally — {@link FoundationAiAssistant.blocked} asks only about the
2515
+ * reachable set, and the banner reads the reachability-filtered
2516
+ * {@link FoundationAiAssistant.relevantBlockedVendors} — but a host rendering
2517
+ * this list itself should filter it against its own registry.
2518
+ *
2519
+ * Read-only on purpose: a settable array would let a host write a partial list
2520
+ * and silently orphan the per-vendor banner copy.
2521
+ * {@link FoundationAiAssistant.setVendorBlocked} is the write path.
2522
+ *
2523
+ * @beta
2524
+ */
2525
+ get blockedVendors(): readonly AIProviderType[];
2526
+ /**
2527
+ * Whether this specific vendor's budget is walled — regardless of whether any
2528
+ * other vendor still has headroom.
2529
+ *
2530
+ * @beta
2531
+ */
2532
+ isVendorBlocked(vendor: AIProviderType): boolean;
2533
+ /**
2534
+ * Wall (or release) one vendor's budget, optionally with banner copy for it.
2535
+ * The per-vendor mirror of {@link FoundationAiAssistant.setBlocked}.
2536
+ *
2537
+ * Walling a vendor does **not** on its own disable the composer: while another
2538
+ * reachable vendor has headroom the assistant stays usable and the banner tells
2539
+ * the user to switch. Only when every reachable vendor is walled does `blocked`
2540
+ * become true.
2541
+ *
2542
+ * `reason` is composed into the banner sentence for that vendor, **however many
2543
+ * vendors are walled** — see {@link FoundationAiAssistant.effectiveBlockedReason}.
2544
+ * It is per-vendor copy, not a whole-banner override; {@link FoundationAiAssistant.blockedReason}
2545
+ * is the override. Omitting it keeps whatever explanation that vendor already
2546
+ * carried, so a driver latch landing after a host one cannot blank it.
2547
+ *
2548
+ * `'none'` is rejected with a warning rather than accepted: it is the "no
2549
+ * provider configured" sentinel, not a vendor. Latching it would put the raw
2550
+ * sentinel in the banner ("none's AI usage limit is reached") and could never
2551
+ * be undone by derivation, because `'none'` never appears in
2552
+ * {@link FoundationAiAssistant.reachableVendors} — so `blocked` could never
2553
+ * become derivable from it either. Use {@link FoundationAiAssistant.setBlocked}
2554
+ * for a vendor-agnostic block.
2555
+ *
2556
+ * @beta
2557
+ */
2558
+ /** Whether this vendor's wall came from the sweep alone — see the slice's `sweptVendors`. */
2559
+ private isVendorSwept;
2560
+ setVendorBlocked(vendor: AIProviderType, blocked: boolean, reason?: string | null): void;
2561
+ /**
2562
+ * The walled vendors the user can still be routed to — i.e.
2563
+ * {@link FoundationAiAssistant.blockedVendors} narrowed to the reachable set,
2564
+ * which is the only set the banner may name.
2565
+ *
2566
+ * A wall the registry can no longer reach is not news: it cannot be hit, and
2567
+ * naming it puts a vendor in front of the user that is not theirs. The concrete
2568
+ * failure this exists to stop: a host ships Anthropic-only, Anthropic walls, the
2569
+ * host swaps its registry to Gemini, Gemini walls — and the banner reads "AI
2570
+ * usage limits are reached for Anthropic and Gemini" to a user who has never
2571
+ * had an Anthropic key. The spurious second name also flips the copy onto the
2572
+ * plural branch, so even the closing sentence is wrong.
2573
+ *
2574
+ * When nothing is reachable YET (the statuses are still loading — the exact
2575
+ * window the pre-flight and the cross-tab bus latch into), the fallback keeps
2576
+ * every wall for LOCKING (`blocked` still derives true) but names only the
2577
+ * vendors walled by a REFUSAL, dropping the ones the `otherVendorAvailable`
2578
+ * sweep added. A refusal is a fact about a vendor this user just used; a sweep
2579
+ * entry is the proxy's headroom verdict about a vendor the host may not even
2580
+ * ship — naming it here reproduced the exact failure above from the other
2581
+ * direction ("Gemini's AI usage limit is reached" to an Anthropic-only user),
2582
+ * and flipped the copy onto the plural branch with it. Self-corrects when the
2583
+ * statuses land: from then on reachability, not provenance, decides.
2584
+ *
2585
+ * @internal
2586
+ */
2587
+ private get relevantBlockedVendors();
2588
+ /**
2589
+ * Whether the blocked banner has anything to say — a vendor-agnostic block, OR
2590
+ * at least one walled vendor the registry can still reach. Broader than
2591
+ * {@link FoundationAiAssistant.blocked} on purpose: partial exhaustion leaves
2592
+ * the composer live but still needs to be announced, because the next turn may
2593
+ * route to the walled vendor and fail.
2594
+ *
2595
+ * Reads the reachability-filtered list for the same reason the copy does — a
2596
+ * host that has swapped its registry away from the walled vendor has nothing
2597
+ * left to announce, and would otherwise get a banner that falls through to the
2598
+ * generic default copy over a perfectly usable composer.
2599
+ *
2600
+ * @internal
2601
+ */
2602
+ get bannerVisible(): boolean;
2603
+ /**
2604
+ * Whether a suggestions fetch would hit a wall.
2605
+ *
2606
+ * Unlike a chat turn, this one CAN be resolved exactly: both suggestion paths
2607
+ * go to the registry **default** and never to a per-agent override
2608
+ * (`ChatDriver.getSuggestions` calls `providerRegistry.default()`, and
2609
+ * `OrchestratingDriver.getSuggestions` just delegates to it). So the vendor a
2610
+ * suggestions call would use is knowable, and this is the one place in the
2611
+ * feature where that is true.
2612
+ *
2613
+ * Same rationale as the guard it replaces: a doomed suggestions call burns a
2614
+ * `suggestions.failed` meta event and parks a raw transport error in
2615
+ * `suggestionsState` for hosts to find.
2616
+ *
2617
+ * @internal
2618
+ */
2619
+ get suggestionsBlocked(): boolean;
2620
+ /**
2621
+ * Explanation shown in the blocked banner, or `null` for the element's default
2622
+ * copy. Only meaningful while {@link FoundationAiAssistant.blocked} is true;
2623
+ * setting `blocked = false` clears it.
2624
+ *
2625
+ * Writable, and symmetric with every other store-backed accessor on this
2626
+ * class: writing it re-latches with the CURRENT `blocked` value, so it changes
2627
+ * the copy without disturbing the flag. Assigning `null` clears the
2628
+ * explanation while staying blocked (the banner falls back to the default
2629
+ * copy). {@link FoundationAiAssistant.setBlocked} remains the way to write
2630
+ * both in one atomic action.
2631
+ *
2632
+ * @beta
2633
+ */
2634
+ get blockedReason(): string | null;
2635
+ set blockedReason(value: string | null);
2636
+ /**
2637
+ * Latch the backend block off a turn outcome. The single decision point for
2638
+ * both latch sites (the `tool-loop-end` bus subscription and `send()`'s
2639
+ * return-value check), so the rule cannot diverge between them.
2640
+ *
2641
+ * Idempotent and one-way **per vendor**: it never unblocks, and it never
2642
+ * re-writes an existing wall. That guard is load-bearing, not just an
2643
+ * optimisation — the bus fires from the driver's `finally`, i.e. BEFORE
2644
+ * `sendMessage()` resolves, so a host subscribed to `tool-loop-end` (what the
2645
+ * migration guide's Option C recommends) sets its own detailed reason and the
2646
+ * return-value latch would otherwise land a moment later and blank it.
2647
+ *
2648
+ * The guard being per-vendor rather than global is the whole difference. A
2649
+ * single global "already blocked, do nothing" would swallow a second vendor's
2650
+ * wall — so a session walled on Anthropic could never record that Gemini went
2651
+ * too, and under a mixed registry an Anthropic-only wall would lock a composer
2652
+ * that Gemini could still serve.
2653
+ *
2654
+ * **Which field is authoritative**, in order:
2655
+ *
2656
+ * 1. `budget.vendorLabel` — stamped by the transport that was actually refused,
2657
+ * so it can never be stale. But it is a static per-transport string, so a
2658
+ * white-labelled or multiplexing gateway fronting several upstreams leaves
2659
+ * it unclaimed by any vendor.
2660
+ * 2. `budget.vendor` — which the driver resolved from the label where it could,
2661
+ * and otherwise from the proxy's own `vendor` field on the 402. It is
2662
+ * therefore NOT simply `vendorLabel` normalised, and the two can disagree;
2663
+ * that fallback is the only attribution on offer for the gateway case above.
2664
+ * 3. `vendorHint` — the bus detail's top-level vendor, i.e. the driver's
2665
+ * last-resolved provider. Last resort because it CAN be stale: an
2666
+ * orchestrated turn classifies against the registry default, a provider the
2667
+ * chat driver may never have resolved, so its last-resolved provider there is
2668
+ * the previous turn's vendor or nothing at all.
2669
+ *
2670
+ * A wall that names no recognised vendor falls back to the vendor-agnostic
2671
+ * block — fail-safe, and identical to the pre-per-vendor behaviour.
2672
+ *
2673
+ * **`otherVendorAvailable: false` is server-known truth and outranks every
2674
+ * inference made here.** The proxy meters the pots, so only it can say whether
2675
+ * anything else has headroom; this element can only observe which vendors the
2676
+ * registry can REACH, which says nothing about their remaining spend. So when
2677
+ * the proxy says no, every other *budgeted* vendor is walled in the same pass.
2678
+ * That is what makes `blocked` derive true — locking the composer on the first
2679
+ * response instead of after a second doomed turn — and what empties the "free"
2680
+ * set the banner would otherwise have advised switching to.
2681
+ *
2682
+ * The sweep runs over `BUDGETED_VENDORS`, deliberately **not** over
2683
+ * {@link FoundationAiAssistant.reachableVendors}. Reachability is loaded
2684
+ * asynchronously (`activateSession` kicks off `loadProviderStatuses()` and does
2685
+ * not await it), so a wall landing before the statuses resolve would have swept
2686
+ * an empty set — silently discarding the one fact on the 402 the client cannot
2687
+ * re-derive, with nothing to re-run it when the statuses arrived. Worse, it let
2688
+ * the verdict effectively un-latch: the single wall derived `blocked` only
2689
+ * while the reachable set was empty, so the moment the statuses landed the
2690
+ * composer came back to life against a budget the proxy had already said was
2691
+ * gone. Sweeping the metered vendor list instead makes the verdict independent
2692
+ * of load order and of registry membership, which is exactly what it is: a
2693
+ * statement about the proxy's pots, not about this user's registry.
2694
+ *
2695
+ * Walling a vendor the registry cannot reach costs nothing: `blocked` only asks
2696
+ * whether every REACHABLE vendor is walled, and the banner reads
2697
+ * {@link FoundationAiAssistant.relevantBlockedVendors}, which filters the walls
2698
+ * back down to the reachable set before naming any of them.
2699
+ *
2700
+ * One boundary remains on the sweep: it walls only vendors the proxy meters,
2701
+ * enforced structurally by iterating `BUDGETED_VENDORS` itself rather than
2702
+ * filtering a wider set through a predicate. Chrome runs on-device with no pot
2703
+ * to exhaust, so "no other vendor has budget" is not a statement about it, and
2704
+ * "Switch to Chrome to keep going." stays honest advice.
2705
+ *
2706
+ * The sweep runs last but sits OUTSIDE the per-vendor idempotence guard, and
2707
+ * both halves of that matter. Last, so the vendor that actually refused this
2708
+ * turn heads the wall order the multi-vendor banner reads. Outside the guard,
2709
+ * because the verdict can arrive on a LATER 402 for a vendor that is already
2710
+ * walled — turn 1 walls Anthropic while Gemini still has headroom, turn 2 walls
2711
+ * it again and reports that Gemini has since gone too — and an early return
2712
+ * would drop exactly the news the second turn was there to deliver.
2713
+ *
2714
+ * @param reason - the turn's failure reason; anything but `'budget-exhausted'` is ignored.
2715
+ * @param ref - session store to write through; defaults to the live one. `send()`
2716
+ * passes the ref it captured before its awaits, since a lifecycle event during the
2717
+ * turn may already have cleared `_sessionRef`.
2718
+ * @param budget - what the 402 reported: figures when the proxy sent any, the
2719
+ * refusing vendor, and its `otherVendorAvailable` verdict.
2720
+ * @param vendorHint - the `tool-loop-end` detail's top-level vendor, used only
2721
+ * when the budget payload names none.
2722
+ *
2723
+ * @internal
2724
+ */
2725
+ private latchBlockedFrom;
2726
+ /**
2727
+ * Block or unblock the assistant, optionally with custom banner copy.
2728
+ * Equivalent to the {@link FoundationAiAssistant.blocked} setter, plus the
2729
+ * reason in one atomic write.
2730
+ *
2731
+ * Blocking writes the **vendor-agnostic** block — what a host with one budget
2732
+ * pot means — and does not populate
2733
+ * {@link FoundationAiAssistant.blockedVendors}. Unblocking clears the
2734
+ * per-vendor walls as well, so a host asserting "the wall is gone" after its
2735
+ * own pre-flight cannot be silently overruled by a driver latch it never saw.
2736
+ *
2737
+ * @beta
2738
+ */
2739
+ setBlocked(blocked: boolean, reason?: string | null): void;
2740
+ /**
2741
+ * Copy shown in the blocked banner, in ascending specificity:
2742
+ *
2743
+ * 1. the host's `blockedReason` — a whole-banner override, unchanged;
2744
+ * 2. copy composed from the walled vendors (their per-vendor reasons when set,
2745
+ * otherwise their names) plus the action that is actually available;
2746
+ * 3. the default budget-exhaustion message.
2747
+ *
2748
+ * The action clause is computed here rather than stored, because whether
2749
+ * "switch vendor" or "contact your administrator" is honest depends on whether
2750
+ * another reachable vendor still has headroom — which changes when the registry
2751
+ * changes, long after the wall was latched. Telling a user to switch to a
2752
+ * vendor that is also exhausted is worse than saying nothing.
2753
+ *
2754
+ * The `free` set is a client-side inference — "reachable and not known to be
2755
+ * walled" — and it is only ever allowed to be one. Where the proxy has told us
2756
+ * otherwise (`otherVendorAvailable: false`) the latch has already walled those
2757
+ * vendors, so they are not in `free` here and no "switch to X" clause can be
2758
+ * composed from them. Both lists are filtered by reachability, so the copy
2759
+ * names only vendors this user's registry can actually route to.
2760
+ *
2761
+ * **Per-vendor copy is composed however many vendors are walled**, which is
2762
+ * what {@link FoundationAiAssistant.setVendorBlocked} and
2763
+ * `docs/migration-GENC-1464.md` both promise. It previously reached only the
2764
+ * single-vendor branch, so a host that had carefully set copy for each of its
2765
+ * vendors watched all of it vanish the moment a second one walled — replaced by
2766
+ * generic copy, at the exact moment the situation got worse.
2767
+ *
2768
+ * The compact "AI usage limits are reached for A and B." list is kept for the
2769
+ * case it was written for: NO walled vendor carries copy, so a statement per
2770
+ * vendor would just repeat one boilerplate sentence per name. As soon as any of
2771
+ * them does carry copy, the branch lists one statement per vendor instead —
2772
+ * falling back to that same boilerplate for the ones that have none, so the
2773
+ * sentence set stays complete rather than silently naming a subset.
2774
+ *
2775
+ * @internal
2776
+ */
2777
+ get effectiveBlockedReason(): string;
2778
+ /**
2779
+ * Copy the driver writes into the TRANSCRIPT when a turn hits the budget wall.
2780
+ *
2781
+ * A host-set `blockedReason` still wins, so a white-labelled host does not read
2782
+ * its own explanation in the banner and the shipped default directly below it —
2783
+ * that is the whole reason the driver takes this at all.
2784
+ *
2785
+ * What it deliberately is NOT is
2786
+ * {@link FoundationAiAssistant.effectiveBlockedReason}. That getter
2787
+ * composes advice — `"…Switch to Gemini to keep going."` — which is true only
2788
+ * while that vendor has headroom, and the transcript is a permanent record. The
2789
+ * driver reads this once at CONSTRUCTION, and `getOrCreateDriver` keys on the
2790
+ * agents list, so an agents swap *after* a wall re-runs `createDriver` and would
2791
+ * freeze that sentence into every later turn's bubble. Reading the latch's own
2792
+ * copy instead is structurally incapable of carrying the advice: the only
2793
+ * writer of `blockedReason` is the vendor-agnostic branch of
2794
+ * `latchBlockedFrom`, whose `formatBlockedReason(budget)` form has no switch
2795
+ * clause. Per-vendor copy lives in `blockedVendorReasons` and reaches the
2796
+ * banner alone.
2797
+ */
2798
+ private get transcriptBudgetExhaustedMessage();
2207
2799
  /**
2208
2800
  * Name of the agent the user has pinned via the agent picker. `null` means
2209
2801
  * automatic routing (Auto). Persisted on the session store, so it survives
@@ -2448,6 +3040,8 @@ export declare class FoundationAiAssistant extends GenesisElement {
2448
3040
  private driverCleanup?;
2449
3041
  private loadingTimer;
2450
3042
  private unsubBus?;
3043
+ /** Unsubscribe handle for the `tool-loop-end` budget latch (GENC-1464). */
3044
+ private _unsubBudgetLatch?;
2451
3045
  /** Unsubscribe handle for the provider-registry change listener (observable registries only). */
2452
3046
  private unsubProviderRegistry?;
2453
3047
  /** Unsubscribe handle for {@link (AssistantAppSettingsProvider:interface).subscribe}. */
@@ -3147,22 +3741,6 @@ export declare const genesisIconSvg = "<svg viewBox=\"-4 0 30 26\" fill=\"none\"
3147
3741
  */
3148
3742
  export declare function getAiPopoutManager(): FoundationAiPopoutManager | undefined;
3149
3743
 
3150
- /**
3151
- * A single in-flight per-call chat-input override pushed by a `requestSubAgent`
3152
- * or `requestInteraction` call. Tracked as an array (not a counter) so the
3153
- * slice can survive pop-in/pop-out and so a listener that connects
3154
- * mid-execution can compute the effective mode without having seen the start
3155
- * event.
3156
- *
3157
- * @internal
3158
- */
3159
- declare interface InputOverride {
3160
- /** Unique per-invocation id, paired with the start/stop events. */
3161
- id: string;
3162
- /** The mode requested for this invocation. */
3163
- mode: ChatInputDuringExecutionMode;
3164
- }
3165
-
3166
3744
  /**
3167
3745
  * Detail payload for the `interaction-completed` event.
3168
3746
  * @public
@@ -3316,6 +3894,17 @@ export declare class OrchestratingDriver extends EventTarget implements AiDriver
3316
3894
  * user stops. Reset at the start of each `sendMessage`.
3317
3895
  */
3318
3896
  private cancelled;
3897
+ /**
3898
+ * Whether the CURRENT turn's user message has reached the inner driver's
3899
+ * history. False through the pre-first-turn classify (where the only echo of
3900
+ * the message is an optimistic `history-updated` dispatch), true from the
3901
+ * moment `chatDriver.sendMessage` is entered — including through every later
3902
+ * handoff classify. Read by the budget-wall catch in `sendMessage` to decide
3903
+ * whether `reportBudgetExhausted` must append the message itself: appending
3904
+ * it when already appended duplicated it; not appending it when unappended
3905
+ * made it vanish. Reset at the top of each `runOrchestratedTurn`.
3906
+ */
3907
+ private userMessageAppended;
3319
3908
  /**
3320
3909
  * Sticky user pick from the picker (or the host's `setAgent` API). Only
3321
3910
  * changes on explicit user action. Survives flow completion: when a stateful
@@ -3349,6 +3938,8 @@ export declare class OrchestratingDriver extends EventTarget implements AiDriver
3349
3938
  maxTurnSnapshots?: number;
3350
3939
  /** Activity bus passed through to the inner ChatDriver (browser host injects the singleton). */
3351
3940
  activityBus?: ActivityBus;
3941
+ /** Budget-wall transcript copy, passed through to the inner ChatDriver (GENC-1464). */
3942
+ budgetExhaustedMessage?: string;
3352
3943
  });
3353
3944
  resolveInteraction(interactionId: string, result: unknown): void;
3354
3945
  getInteractionContext(interactionId: string): InteractionContext | undefined;
@@ -3381,6 +3972,7 @@ export declare class OrchestratingDriver extends EventTarget implements AiDriver
3381
3972
  getExternalDiagnostics(): ReadonlyArray<DiagnosticEntry>;
3382
3973
  getSuggestions(history: ChatMessage[], prompt: string, count: number, allAgentInfo?: AllAgentSummary[]): Promise<string[]>;
3383
3974
  sendMessage(input: string, attachments?: ChatAttachment[]): Promise<ChatDriverResult>;
3975
+ private runOrchestratedTurn;
3384
3976
  continueFromHistory(transientPrimer?: ChatMessage[]): Promise<ChatDriverResult>;
3385
3977
  /** {@inheritDoc AiDriver.primeRestoredAgentState} */
3386
3978
  primeRestoredAgentState(snapshots: Record<string, unknown>): void;