@genesislcap/ai-assistant 15.76.0 → 15.77.0-GENC-1660.7

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 (139) hide show
  1. package/dist/ai-assistant.api.json +3234 -104
  2. package/dist/ai-assistant.d.ts +1023 -89
  3. package/dist/chat-driver.cjs +444 -99
  4. package/dist/chat-driver.cjs.map +4 -4
  5. package/dist/chat-driver.mjs +444 -99
  6. package/dist/chat-driver.mjs.map +4 -4
  7. package/dist/custom-elements.json +1646 -94
  8. package/dist/dts/autopilot/autopilot-driver.d.ts +113 -10
  9. package/dist/dts/autopilot/autopilot-driver.d.ts.map +1 -1
  10. package/dist/dts/autopilot/autopilot-session.d.ts +55 -7
  11. package/dist/dts/autopilot/autopilot-session.d.ts.map +1 -1
  12. package/dist/dts/autopilot/autopilot-tools.d.ts +3 -2
  13. package/dist/dts/autopilot/autopilot-tools.d.ts.map +1 -1
  14. package/dist/dts/autopilot/decision-message.d.ts +35 -3
  15. package/dist/dts/autopilot/decision-message.d.ts.map +1 -1
  16. package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts +2 -2
  17. package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts.map +1 -1
  18. package/dist/dts/autopilot/hand-back/hand-back.d.ts +2 -2
  19. package/dist/dts/autopilot/hand-back/hand-back.d.ts.map +1 -1
  20. package/dist/dts/autopilot/index.d.ts +1 -0
  21. package/dist/dts/autopilot/index.d.ts.map +1 -1
  22. package/dist/dts/autopilot/widget-tools.d.ts +95 -0
  23. package/dist/dts/autopilot/widget-tools.d.ts.map +1 -0
  24. package/dist/dts/channel/ai-activity-channel.d.ts +20 -2
  25. package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
  26. package/dist/dts/components/ai-driver/ai-driver.d.ts +25 -6
  27. package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
  28. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts +2 -0
  29. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts.map +1 -1
  30. package/dist/dts/components/chat-bubble/chat-bubble.d.ts +2 -0
  31. package/dist/dts/components/chat-bubble/chat-bubble.d.ts.map +1 -1
  32. package/dist/dts/components/chat-driver/chat-driver.d.ts +14 -2
  33. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  34. package/dist/dts/components/chat-driver/interaction-controller.d.ts +55 -17
  35. package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
  36. package/dist/dts/components/notification-level/index.d.ts +2 -0
  37. package/dist/dts/components/notification-level/index.d.ts.map +1 -0
  38. package/dist/dts/components/notification-level/notification-level.d.ts +51 -0
  39. package/dist/dts/components/notification-level/notification-level.d.ts.map +1 -0
  40. package/dist/dts/components/notification-level/notification-level.styles.d.ts +3 -0
  41. package/dist/dts/components/notification-level/notification-level.styles.d.ts.map +1 -0
  42. package/dist/dts/components/notification-level/notification-level.template.d.ts +5 -0
  43. package/dist/dts/components/notification-level/notification-level.template.d.ts.map +1 -0
  44. package/dist/dts/components/settings-modal/settings-modal.styles.d.ts.map +1 -1
  45. package/dist/dts/components/settings-modal/settings-modal.template.d.ts.map +1 -1
  46. package/dist/dts/config/config.d.ts +31 -6
  47. package/dist/dts/config/config.d.ts.map +1 -1
  48. package/dist/dts/config/define-stateful-agent.d.ts +5 -1
  49. package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
  50. package/dist/dts/index.d.ts +6 -2
  51. package/dist/dts/index.d.ts.map +1 -1
  52. package/dist/dts/main/main.d.ts +56 -1
  53. package/dist/dts/main/main.d.ts.map +1 -1
  54. package/dist/dts/main/main.template.d.ts.map +1 -1
  55. package/dist/dts/notifications/agent-notifications.d.ts +139 -0
  56. package/dist/dts/notifications/agent-notifications.d.ts.map +1 -0
  57. package/dist/dts/notifications/agent-notifier.d.ts +58 -0
  58. package/dist/dts/notifications/agent-notifier.d.ts.map +1 -0
  59. package/dist/dts/notifications/index.d.ts +2 -0
  60. package/dist/dts/notifications/index.d.ts.map +1 -0
  61. package/dist/dts/notifications/notification-level-picker.template.d.ts +31 -0
  62. package/dist/dts/notifications/notification-level-picker.template.d.ts.map +1 -0
  63. package/dist/dts/notifications/notification-settings.d.ts +42 -0
  64. package/dist/dts/notifications/notification-settings.d.ts.map +1 -0
  65. package/dist/dts/react.d.ts +10 -0
  66. package/dist/dts/state/ai-assistant-slice.d.ts +8 -0
  67. package/dist/dts/state/ai-assistant-slice.d.ts.map +1 -1
  68. package/dist/dts/state/decision-surface.d.ts +22 -4
  69. package/dist/dts/state/decision-surface.d.ts.map +1 -1
  70. package/dist/dts/state/interaction-context.d.ts +18 -4
  71. package/dist/dts/state/interaction-context.d.ts.map +1 -1
  72. package/dist/dts/state/interaction-registry.d.ts +55 -6
  73. package/dist/dts/state/interaction-registry.d.ts.map +1 -1
  74. package/dist/dts/state/live-interactions.d.ts +28 -0
  75. package/dist/dts/state/live-interactions.d.ts.map +1 -0
  76. package/dist/dts/state/persistence/session-persistence-provider.d.ts +5 -0
  77. package/dist/dts/state/persistence/session-persistence-provider.d.ts.map +1 -1
  78. package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
  79. package/dist/dts/state/persistence/session-snapshot.d.ts +16 -5
  80. package/dist/dts/state/persistence/session-snapshot.d.ts.map +1 -1
  81. package/dist/dts/state/session-store.d.ts +1 -0
  82. package/dist/dts/state/session-store.d.ts.map +1 -1
  83. package/dist/dts/state/test-interaction-context.d.ts +83 -0
  84. package/dist/dts/state/test-interaction-context.d.ts.map +1 -0
  85. package/dist/dts/types/ai-chat-widget.d.ts +7 -6
  86. package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
  87. package/dist/dts/types/interaction-context.d.ts +143 -13
  88. package/dist/dts/types/interaction-context.d.ts.map +1 -1
  89. package/dist/dts/types/interaction-interceptor.d.ts +26 -6
  90. package/dist/dts/types/interaction-interceptor.d.ts.map +1 -1
  91. package/dist/dts/types/interaction-surface.d.ts +145 -23
  92. package/dist/dts/types/interaction-surface.d.ts.map +1 -1
  93. package/dist/dts/utils/resolve-preference-baseline.d.ts +3 -0
  94. package/dist/dts/utils/resolve-preference-baseline.d.ts.map +1 -1
  95. package/dist/esm/autopilot/autopilot-driver.js +272 -56
  96. package/dist/esm/autopilot/autopilot-session.js +219 -40
  97. package/dist/esm/autopilot/autopilot-tools.js +11 -7
  98. package/dist/esm/autopilot/decision-message.js +105 -26
  99. package/dist/esm/autopilot/hand-back/hand-back.controller.js +2 -1
  100. package/dist/esm/autopilot/index.js +1 -0
  101. package/dist/esm/autopilot/widget-tools.js +39 -0
  102. package/dist/esm/components/ai-driver/base-driver-decorator.js +17 -0
  103. package/dist/esm/components/chat-bubble/chat-bubble.js +17 -3
  104. package/dist/esm/components/chat-driver/chat-driver.js +18 -2
  105. package/dist/esm/components/chat-driver/interaction-controller.js +210 -71
  106. package/dist/esm/components/notification-level/index.js +1 -0
  107. package/dist/esm/components/notification-level/notification-level.js +124 -0
  108. package/dist/esm/components/notification-level/notification-level.styles.js +20 -0
  109. package/dist/esm/components/notification-level/notification-level.template.js +11 -0
  110. package/dist/esm/components/settings-modal/settings-modal.styles.js +6 -0
  111. package/dist/esm/components/settings-modal/settings-modal.template.js +10 -1
  112. package/dist/esm/config/define-stateful-agent.js +22 -1
  113. package/dist/esm/index.js +4 -0
  114. package/dist/esm/main/main.js +163 -15
  115. package/dist/esm/main/main.template.js +4 -1
  116. package/dist/esm/notifications/agent-notifications.js +172 -0
  117. package/dist/esm/notifications/agent-notifier.js +86 -0
  118. package/dist/esm/notifications/index.js +1 -0
  119. package/dist/esm/notifications/notification-level-picker.template.js +49 -0
  120. package/dist/esm/notifications/notification-settings.js +42 -0
  121. package/dist/esm/state/ai-assistant-slice.js +5 -0
  122. package/dist/esm/state/debug-event-log.js +5 -5
  123. package/dist/esm/state/decision-surface.js +137 -54
  124. package/dist/esm/state/interaction-context.js +50 -5
  125. package/dist/esm/state/interaction-registry.js +11 -0
  126. package/dist/esm/state/live-interactions.js +36 -0
  127. package/dist/esm/state/persistence/session-persister.js +44 -17
  128. package/dist/esm/state/persistence/session-snapshot.js +2 -2
  129. package/dist/esm/state/test-interaction-context.js +90 -0
  130. package/dist/esm/utils/resolve-preference-baseline.js +9 -0
  131. package/dist/react.cjs +7 -0
  132. package/dist/react.mjs +6 -0
  133. package/docs/notifications.md +169 -0
  134. package/docs/styling.md +33 -0
  135. package/package.json +19 -19
  136. package/sandbox/README.md +3 -2
  137. package/sandbox/autopilot.ts +26 -6
  138. package/sandbox/sandbox.ts +2 -0
  139. /package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +0 -0
@@ -51,6 +51,35 @@ export declare interface ActivityBus {
51
51
  /** Sentinel value representing "Auto" where a menu row needs a string value. */
52
52
  export declare const AGENT_PICKER_AUTO_VALUE = "__auto__";
53
53
 
54
+ /**
55
+ * The detail of the `agent-attention` activity-bus event: something in a session needs the person.
56
+ * Published whatever the person's level is; the assistant for that session decides whether to
57
+ * notify.
58
+ *
59
+ * @beta
60
+ */
61
+ export declare interface AgentAttentionDetail {
62
+ /** The session it happened in. A sub-agent's session is `<parent>::sub:<id>`. */
63
+ readonly sessionKey: string;
64
+ readonly kind: AgentAttentionKind;
65
+ /** The interaction it is about, when there is one. */
66
+ readonly interactionId?: string;
67
+ /** Text that replaces the default message for this one notification. */
68
+ readonly message?: string;
69
+ }
70
+
71
+ /**
72
+ * What an agent notification is about.
73
+ *
74
+ * - `'widget-needs-input'` — a widget asked for the person's attention.
75
+ * - `'autopilot-handed-back'` — the autopilot handed something to the person.
76
+ * - `'autopilot-stopped'` — the autopilot stopped working: the flow ended, the turn ended with
77
+ * nothing left for it to answer, or it hit a wall such as the budget.
78
+ *
79
+ * @beta
80
+ */
81
+ export declare type AgentAttentionKind = 'widget-needs-input' | 'autopilot-handed-back' | 'autopilot-stopped';
82
+
54
83
  /**
55
84
  * Configuration for an agent passed to `FoundationAiAssistant`.
56
85
  *
@@ -198,8 +227,9 @@ export declare interface AgenticActivityEvents {
198
227
  needsUser: boolean;
199
228
  };
200
229
  /**
201
- * The person opened the collapsed assistant from its "needs you" badge: the assistant for
202
- * `sessionKey` (any, when absent) brings what waits on them into view.
230
+ * The person opened the collapsed assistant from its "needs you" badge, or clicked an agent
231
+ * notification (GENC-1676): the assistant for `sessionKey` (any, when absent) brings what waits
232
+ * on them into view, and a closed bubble holding it opens.
203
233
  */
204
234
  'autopilot-show-waiting': {
205
235
  sessionKey?: string;
@@ -322,6 +352,22 @@ export declare interface AgenticActivityEvents {
322
352
  * computing again (until `tool-loop-end`). Tab-local.
323
353
  */
324
354
  'interaction-resolved': undefined;
355
+ /**
356
+ * Something in a session needs the person (GENC-1676): a widget asked for their attention, or
357
+ * the autopilot handed back or stopped working. Published whatever the person's notification
358
+ * level is; the assistant for that session decides whether to show a browser notification, and
359
+ * an app can listen to drive its own UI. Tab-local: the window that owns the session's driver
360
+ * publishes it.
361
+ */
362
+ 'agent-attention': AgentAttentionDetail;
363
+ /**
364
+ * A session's agent notification settings may have changed (GENC-1676): the person's level, what
365
+ * the app offers, or which assistant on the page holds the session. A notification level picker
366
+ * for that session re-reads them. Tab-local.
367
+ */
368
+ 'notification-settings-changed': {
369
+ sessionKey: string;
370
+ };
325
371
  }
326
372
 
327
373
  /**
@@ -348,6 +394,36 @@ export declare interface AgentLifecycleContext {
348
394
  restored?: unknown;
349
395
  }
350
396
 
397
+ /**
398
+ * How often the person wants a browser notification when the assistant needs them (GENC-1676).
399
+ * Each level includes the one before it.
400
+ *
401
+ * - `'off'` — never. The default, always: the browser makes the person grant permission, so
402
+ * nothing can switch it on for them.
403
+ * - `'autopilot'` — only when the autopilot hands back to the person or stops working. Offered
404
+ * only when the app sets `chatConfig.ui.notifications.autopilot`.
405
+ * - `'needs-input'` — every `'autopilot'` case, plus any widget that asks for the person's
406
+ * attention (`InteractionContext.requestAttention`).
407
+ *
408
+ * @beta
409
+ */
410
+ export declare type AgentNotificationLevel = 'off' | 'autopilot' | 'needs-input';
411
+
412
+ /**
413
+ * Whether this page may show notifications: the browser's own `NotificationPermission`, or
414
+ * `'unsupported'` where there is no Notification API (an old browser, an insecure context, Node).
415
+ *
416
+ * @beta
417
+ */
418
+ export declare type AgentNotificationPermission = NotificationPermission | 'unsupported';
419
+
420
+ /**
421
+ * Whether this page may show notifications. Safe to call anywhere, including Node.
422
+ *
423
+ * @beta
424
+ */
425
+ export declare function agentNotificationPermission(): AgentNotificationPermission;
426
+
351
427
  /**
352
428
  * Context passed to an agent's `resumable` predicate (GENC-1351 §5.9), evaluated
353
429
  * at session-save time on the active agent (which, for a locked guided flow, is
@@ -678,11 +754,11 @@ export declare type AiAssistantState = 'idle' | 'loading' | 'cancelling' | 'erro
678
754
  * a `shouldAutoFocus`, and a pending widget cannot be read for a `result`.
679
755
  *
680
756
  * The host sets the widget's `interaction` on mount and REPLACES it (pending →
681
- * resolved) on completion.
757
+ * resolved) on completion. `TController` types the pending context's `controller` (GENC-1660).
682
758
  *
683
759
  * @beta
684
760
  */
685
- export declare type AiChatInteraction<TData = unknown, TResult = unknown> = {
761
+ export declare type AiChatInteraction<TData = unknown, TResult = unknown, TController = unknown> = {
686
762
  status: 'pending';
687
763
  /** Immutable inputs for the interaction. */
688
764
  data: TData;
@@ -693,9 +769,10 @@ export declare type AiChatInteraction<TData = unknown, TResult = unknown> = {
693
769
  shouldAutoFocus: boolean;
694
770
  /**
695
771
  * Live, remount-surviving scratch for this interaction. Present ONLY while
696
- * pending — the host disposes it on resolve. See {@link InteractionContext}.
772
+ * pending — the host disposes it on resolve. See {@link InteractionContext}. Its
773
+ * `controller` is typed `TController`, as the widget was registered.
697
774
  */
698
- interactionContext: InteractionContext;
775
+ interactionContext: InteractionContext<Record<string, unknown>, unknown, TController>;
699
776
  } | {
700
777
  status: 'resolved';
701
778
  /** Same inputs — the resolved view still reads them. */
@@ -767,11 +844,11 @@ export declare class AiChatMarkdown extends GenesisElement {
767
844
  *
768
845
  * @beta
769
846
  */
770
- export declare interface AiChatWidget<TData = unknown, TResult = unknown> {
847
+ export declare interface AiChatWidget<TData = unknown, TResult = unknown, TController = unknown> {
771
848
  /** Stable per-interaction UUID; constant across remounts, present in both states. */
772
849
  interactionId: string;
773
850
  /** The current interaction state (pending or resolved). */
774
- interaction: AiChatInteraction<TData, TResult>;
851
+ interaction: AiChatInteraction<TData, TResult, TController>;
775
852
  }
776
853
 
777
854
  /**
@@ -985,19 +1062,36 @@ export declare interface AiDriver extends EventTarget {
985
1062
  */
986
1063
  getFlowOwner?(): string | null;
987
1064
  /**
988
- * The checkpoint of the long action in flight, or the one a reload cut and nothing has taken over
989
- * yet (GENC-1660 §4.12), for the host to save with the session.
1065
+ * Every checkpoint to save with the session (GENC-1660 §4.12): those a reload cut that nothing
1066
+ * has taken over yet, oldest first, then the long action in flight's, if it has saved one.
990
1067
  *
991
1068
  * Optional, so a third-party driver need not implement it; every shipped driver does.
992
1069
  *
993
1070
  * @beta
994
1071
  */
1072
+ getInteractionCheckpoints?(): readonly PersistedInteractionCheckpoint[];
1073
+ /**
1074
+ * Bring back the checkpoints saved with the session. Their interactions were cut by the reload,
1075
+ * so each waits for a request of its own widget type that the registration's `sameWork` agrees is
1076
+ * the same work: it is offered to every such request until one agrees, kept through refusals and
1077
+ * through checkpoints other interactions save meanwhile, and dropped when the flow ends. Replaces
1078
+ * whatever the driver held.
1079
+ *
1080
+ * @beta
1081
+ */
1082
+ restoreInteractionCheckpoints?(saved: readonly PersistedInteractionCheckpoint[]): void;
1083
+ /**
1084
+ * One checkpoint to save: the long action in flight's, else the newest a reload cut.
1085
+ *
1086
+ * @deprecated Use {@link AiDriver.getInteractionCheckpoints}, which also returns the cut
1087
+ * checkpoints still waiting while another long action runs; this one loses them.
1088
+ * @beta
1089
+ */
995
1090
  getInteractionCheckpoint?(): PersistedInteractionCheckpoint | undefined;
996
1091
  /**
997
- * Bring back a checkpoint saved with the session. Its interaction was cut by the reload, so it
998
- * waits for the first request of the same widget type, which takes it over if the registration's
999
- * `sameWork` agrees; it is dropped when the flow ends.
1092
+ * Bring back one checkpoint, or none (which clears every checkpoint held).
1000
1093
  *
1094
+ * @deprecated Use {@link AiDriver.restoreInteractionCheckpoints}.
1001
1095
  * @beta
1002
1096
  */
1003
1097
  restoreInteractionCheckpoint?(saved: PersistedInteractionCheckpoint | undefined): void;
@@ -1188,11 +1282,13 @@ export declare interface AiDriverEventMap {
1188
1282
  /**
1189
1283
  * An interaction settled, by whatever route — a widget, a controller's `ctx.resolve`, a claimant,
1190
1284
  * a timeout (GENC-1660). Detail: its id, and `answeredBy` when someone answered it (absent for a
1191
- * timeout or a stop).
1285
+ * timeout or a stop); `resolvedItself` in its place when a widget registered `resolvesItself`
1286
+ * settled on its own, which nobody answered but after which the turn carries on.
1192
1287
  */
1193
1288
  'interaction-settled': CustomEvent<{
1194
1289
  interactionId: string;
1195
1290
  answeredBy?: string;
1291
+ resolvedItself?: boolean;
1196
1292
  }>;
1197
1293
  /** Spend was recorded against an already-resolved interaction. */
1198
1294
  'external-cost-recorded': CustomEvent<{
@@ -1218,6 +1314,54 @@ export declare interface AiDriverEventMap {
1218
1314
  'orchestrating-stop': CustomEvent<undefined>;
1219
1315
  }
1220
1316
 
1317
+ /**
1318
+ * The agent notification level picker on its own (GENC-1676), for an app or a widget's view to
1319
+ * place wherever it invites the person to switch notifications on. The same control as the
1320
+ * assistant's settings row, and the same behaviour: picking a level asks the browser for
1321
+ * permission inside the click and snaps back if refused, the hint says when the browser blocks
1322
+ * notifications, and the Autopilot level shows only when the app offers it.
1323
+ *
1324
+ * It works on the session in `session-key`, through the connected assistant that holds it, so
1325
+ * the level is checked and saved as a settings change is. It renders nothing while no connected
1326
+ * assistant holds that session, while the app turns notifications off, or where the browser has
1327
+ * no notifications.
1328
+ *
1329
+ * In a widget, pass the interaction's session:
1330
+ *
1331
+ * ```html
1332
+ * <foundation-ai-notification-level session-key="${(x) => x.interactionContext.sessionKey}">
1333
+ * </foundation-ai-notification-level>
1334
+ * ```
1335
+ *
1336
+ * @beta
1337
+ */
1338
+ export declare class AiNotificationLevel extends GenesisElement implements NotificationLevelPickerSource {
1339
+ /** The session whose level this picks: the assistant's `session-key` (or state key). */
1340
+ sessionKey?: string;
1341
+ designSystemPrefix: string;
1342
+ /** The browser's notification permission, followed while connected. @internal */
1343
+ notificationPermission: AgentNotificationPermission;
1344
+ /** See `NotificationLevelPickerSource`. @internal */
1345
+ notificationPickerRevision: number;
1346
+ /** Bumped whenever the session's settings may have changed, so the getters re-read. @internal */
1347
+ settingsRevision: number;
1348
+ private unwire?;
1349
+ connectedCallback(): void;
1350
+ disconnectedCallback(): void;
1351
+ sessionKeyChanged(): void;
1352
+ private get host();
1353
+ /** Whether to render: a connected assistant holds the session, offers it, and the browser can. @internal */
1354
+ get offered(): boolean;
1355
+ /** See `NotificationLevelPickerSource`. @internal */
1356
+ get effectiveNotificationLevel(): AgentNotificationLevel;
1357
+ /** See `NotificationLevelPickerSource`. @internal */
1358
+ get notificationAutopilotOffered(): boolean;
1359
+ /** The hint under the picker when the browser will not show notifications. @internal */
1360
+ get permissionHint(): string;
1361
+ /** See `NotificationLevelPickerSource`. @internal */
1362
+ chooseNotificationLevel(level: AgentNotificationLevel): Promise<void>;
1363
+ }
1364
+
1221
1365
  /**
1222
1366
  * Optional app-registered policy for which cloud vendor backs the tier-shaped
1223
1367
  * provider registry slots (`low` / `high` / …). Apps inject a concrete
@@ -1499,6 +1643,19 @@ export declare interface AutopilotConfig<S = unknown> {
1499
1643
  definitions: ChatToolDefinition[];
1500
1644
  handlers: ChatToolHandlers;
1501
1645
  };
1646
+ /**
1647
+ * Tools that read from one widget type while it is open, built with `widgetTools`: reads with
1648
+ * parameters, which a surface's views cannot take (one table's rows, a page of them). Declared
1649
+ * here, never discovered from registrations, so the tool list is fixed when the autopilot's
1650
+ * session starts — the fixed three, `tools` and these, sorted by name — and every decision sends
1651
+ * the same one, which keeps the cache. Each call is routed to the interaction of its widget type
1652
+ * being decided, and refused with a reason when none is; while one is open, the platform puts a
1653
+ * line naming its tools in front of the tail. Reads only.
1654
+ *
1655
+ * Every tool name must be unique across these, `tools` and the fixed three: `defineAutopilot`
1656
+ * throws otherwise.
1657
+ */
1658
+ widgetTools?: WidgetTools[];
1502
1659
  /**
1503
1660
  * How the working agent is told a decision was made for the user, e.g. "Decided on the user's
1504
1661
  * behalf, from their brief". Must not name the autopilot.
@@ -1516,10 +1673,14 @@ export declare interface AutopilotConfig<S = unknown> {
1516
1673
  /** Model calls per decision before it is handed back; `> 0`, or the default is used. Default 6. */
1517
1674
  maxIterationsPerDecision?: number;
1518
1675
  /**
1519
- * Written answers (`reply`) allowed per step before `reply` is withdrawn, so refining a proposal
1520
- * cannot loop with the working agent re-proposing it. `>= 0` (0 never offers one), or the
1521
- * default is used. Default 2. Enforced by the platform, not asked of the model: past the limit it
1522
- * can only accept or hand back.
1676
+ * Refinements allowed per step before every refining action is withdrawn, so refining a proposal
1677
+ * cannot loop with the working agent re-proposing it. A refinement is a written answer (`reply`)
1678
+ * or a full-form action declared `refines` (a regenerate with instructions), counted together.
1679
+ * `>= 0` (0 never offers one), or the default is used. Default 2. Enforced by the platform, not
1680
+ * asked of the model: past the limit it can only accept or hand back. Counted the moment one is
1681
+ * taken, so a refining action that does not settle cannot be repeated past it within a decision.
1682
+ * The decision tells the model how many are left (`Refinements left at this step: N`) wherever the
1683
+ * widget has a refining action, so a widget's own summary need not count them.
1523
1684
  */
1524
1685
  maxRefinements?: number;
1525
1686
  /**
@@ -1538,8 +1699,8 @@ export declare interface AutopilotConfig<S = unknown> {
1538
1699
  maxDecisionCostUsd?: number;
1539
1700
  /**
1540
1701
  * How long the autopilot's work on a claimed interaction may go quiet before it is handed back,
1541
- * in ms; `> 0`, or the default is used. Quiet means either no ready surface and no heartbeat
1542
- * (`ctx.notify()`), or a decision of its own still running with no model call landing and no
1702
+ * in ms; `> 0`, or the default is used. Quiet means either no ready surface (no decision due,
1703
+ * which includes a controller that says it is working) and no heartbeat (`ctx.notify()`), or a decision of its own still running with no model call landing and no
1543
1704
  * heartbeat — a stalled model call, which has no timeout of its own. A decision handed back this
1544
1705
  * way is stopped. Must outlast the slowest honest wait, such as a compile. Default 10 minutes.
1545
1706
  */
@@ -1566,6 +1727,13 @@ export declare interface AutopilotCopy {
1566
1727
  paused: string;
1567
1728
  /** While the autopilot waits on one answer it handed back. */
1568
1729
  selfPaused: string;
1730
+ /**
1731
+ * The slim bar's status while running but waiting on the person for a question the autopilot
1732
+ * never took — one its `widgetPolicy` keeps for them, one that is `userOnly`, or one with no
1733
+ * controller to act through — e.g. "Waiting for your answer". Not a hand-back, which is
1734
+ * `selfPaused`: nothing pauses, and the autopilot carries on by itself once they answer.
1735
+ */
1736
+ waitingForUser: string;
1569
1737
  /** In front of a hand-back reason, in the widget's banner, e.g. "I need your input on this one:". */
1570
1738
  handBackLead: string;
1571
1739
  /** The toggle pill's label and its accessible name, e.g. "Autopilot". */
@@ -1636,6 +1804,7 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
1636
1804
  private readonly agents;
1637
1805
  private readonly providerRegistry;
1638
1806
  private readonly sessionKey;
1807
+ private readonly activityBus;
1639
1808
  private readonly listeners;
1640
1809
  private readonly sessions;
1641
1810
  /** The flow the mode applies to: set when it is first switched, cleared when that flow ends. */
@@ -1643,7 +1812,18 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
1643
1812
  private mode;
1644
1813
  private pauseState?;
1645
1814
  private held?;
1646
- /** Written answers given on the current step, for the refinement limit. */
1815
+ /**
1816
+ * The interaction open right now, whoever holds it: claimed or not, it was offered here first.
1817
+ * `held` covers only what the autopilot claimed, so this is how the status knows that the working
1818
+ * agent is parked on a question left with the person (see `waitingOnUser`).
1819
+ */
1820
+ private open?;
1821
+ /**
1822
+ * The open interaction, when the autopilot declined it only for being paused as it opened: a live
1823
+ * Resume may still take it (see `takeOpenOnResume`). Cleared when it is taken or settles.
1824
+ */
1825
+ private declinedWhilePaused?;
1826
+ /** Refining actions taken on the current step (written answers among them), for the limit. */
1647
1827
  private refinements?;
1648
1828
  /** The watchdog's next check, while a claimed interaction is pending. */
1649
1829
  private watchdog?;
@@ -1665,8 +1845,31 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
1665
1845
  private turnsInFlight;
1666
1846
  /** Written questions being answered right now; see `working`. */
1667
1847
  private answersInFlight;
1848
+ /**
1849
+ * Whether the autopilot has been running, and working, since it last stopped or was paused: so
1850
+ * going idle now is a stop to report. Outlives its flow ending, so a turn still running then is
1851
+ * waited out. See `watchForStop`.
1852
+ */
1853
+ private ranSinceStop;
1854
+ /** The check that confirms the autopilot stopped, once it looked like it had. */
1855
+ private stopCheck?;
1668
1856
  constructor(inner: AiDriver, options: AutopilotDriverOptions);
1669
1857
  get state(): AutopilotHostState;
1858
+ /**
1859
+ * Whether the working agent is parked on a question the person holds, with the autopilot deciding
1860
+ * nothing: one it never took — its policy keeps it for the person, it is `userOnly` (the turn-level
1861
+ * hand-back among them), it has no controller, or it opened while paused and no Resume has taken
1862
+ * it since (a restored mode takes nothing) — or one another interceptor took and then gave to the
1863
+ * person. One the autopilot handed back reads `selfPaused`, and one a pause handed over reads
1864
+ * `paused`; `state` settles both before asking this.
1865
+ *
1866
+ * Never one whose controller says it is working (`ctx.setWorking(true)`), nor, when its
1867
+ * controller has said neither, one registered `resolvesItself`: the person holds it, but it asks
1868
+ * them nothing — it is work running, which settles by itself, so "waiting for your answer" would
1869
+ * be untrue. A controller that says it is asking (`ctx.setWorking(false)`) is waiting on the
1870
+ * person, whatever its registration says.
1871
+ */
1872
+ private waitingOnUser;
1670
1873
  get copy(): AutopilotCopy;
1671
1874
  subscribe(listener: () => void): () => void;
1672
1875
  pause(): void;
@@ -1704,9 +1907,9 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
1704
1907
  *
1705
1908
  * Sent only if the question still stands when the answer lands: no pause or resume since it was
1706
1909
  * asked (Pause stops it, and the question is the person's to answer by typing), the flow still
1707
- * running, the working agent idle, and the question still the last thing it said. Otherwise the
1708
- * answer goes nowhere — not sent, not counted, not recorded as acted — and its cost is recorded as
1709
- * dropped, as it is whenever no reply is sent to carry it.
1910
+ * running and the autopilot still available to it, the working agent idle, and the question still
1911
+ * the last thing it said. Otherwise the answer goes nowhere — not sent, not counted, not recorded
1912
+ * as acted — and its cost is recorded as dropped, as it is whenever no reply is sent to carry it.
1710
1913
  */
1711
1914
  private answer;
1712
1915
  /**
@@ -1734,14 +1937,55 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
1734
1937
  private endSessions;
1735
1938
  dispose(): Promise<void>;
1736
1939
  private onInteractionOpened;
1940
+ private decline;
1941
+ /**
1942
+ * Whether the autopilot running for `owner` may take `opened`: the agent that answers for it, or
1943
+ * why not, as `autopilot.declined` records it. The mode is the caller's to check — the open path
1944
+ * asks this only while running, and a live Resume only for what opened while paused — so both ask
1945
+ * the same questions in the same order.
1946
+ */
1947
+ private eligibility;
1948
+ /**
1949
+ * Hold an interaction the autopilot claimed, watch it, and decide it once its surface is ready.
1950
+ * `deferred` when the claim is granted only after the caller returns (the open path), so the
1951
+ * decision waits a microtask for it; a late claim through `hold.claim` is granted already.
1952
+ *
1953
+ * The decision starts only if the autopilot still holds it then, with no pause or resume in
1954
+ * between: a pause hands it over, and the Resume after that decides it itself.
1955
+ */
1956
+ private take;
1957
+ /**
1958
+ * Decide `held` once a decision is due on it (`onSurfaceReady`): at once if one is, or when its
1959
+ * controller next makes one due — exposes a surface, enables an action, or says it is asking.
1960
+ * Only if, by then, the autopilot still holds it with no pause or resume in between: a pause hands
1961
+ * it over, and the Resume after that decides it itself.
1962
+ */
1963
+ private decideWhenReady;
1964
+ /**
1965
+ * On a live Resume: take the open interaction if it was declined only because the autopilot was
1966
+ * paused when it opened, and would be claimed if it opened now — the same checks as the open
1967
+ * path. Returns whether it took it. A person may have started on it; it is taken as it stands, as
1968
+ * Resume takes back one a pause handed over, and the autopilot reads it as it now is.
1969
+ */
1970
+ private takeOpenOnResume;
1971
+ /**
1972
+ * Follow every interaction while it is open, claimed or not, so the status can say when the
1973
+ * person is the one being waited on (see `waitingOnUser`), and tell the host each time that
1974
+ * changes: when it opens, when it moves between holders, and when it settles.
1975
+ */
1976
+ private trackOpen;
1737
1977
  /** Run one decision on the flow's session, and act on how it ended. */
1738
1978
  private decide;
1739
1979
  /** The step a decision belongs to, for the refinement limit (§4.4). */
1740
1980
  private stepKey;
1741
- /** Whether a written answer is still allowed on this step. The count resets when the step changes. */
1742
- private mayRefine;
1981
+ /**
1982
+ * How many refining actions (written answers, and full-form actions declared `refines`) are left
1983
+ * on this step: none left withdraws them all. Read fresh, so a refinement taken mid-decision (a
1984
+ * `refines` action that does not settle) counts at once. The count resets when the step changes.
1985
+ */
1986
+ private refinementsLeft;
1743
1987
  private countRefinement;
1744
- /** Written answers allowed per step: the config's when it is a whole number `>= 0`. */
1988
+ /** Refinements allowed per step: the config's when it is a whole number `>= 0`. */
1745
1989
  private refinementLimit;
1746
1990
  /**
1747
1991
  * The watchdog (§4.2, critique S5): a claimed interaction whose work has gone quiet for longer
@@ -1776,6 +2020,19 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
1776
2020
  private copyFor;
1777
2021
  private sessionFor;
1778
2022
  private record;
2023
+ /** Report that something needs the person, for the assistant to notify them (GENC-1676). */
2024
+ private attention;
2025
+ /**
2026
+ * Report the autopilot stopping work on its own (GENC-1676): after running and working, nothing
2027
+ * is happening and nothing waits on the person — the turn ended with nothing for it to answer,
2028
+ * hit a wall such as the budget, or its flow ended. A flow that ends mid-turn is reported once
2029
+ * the turn ends, not while the assistant is still writing. A pause by the person is not a stop,
2030
+ * and a hand-back reports itself.
2031
+ *
2032
+ * Confirmed a task later, because one state change can briefly look like a stop on the way to
2033
+ * something else (a turn ending just before the next starts).
2034
+ */
2035
+ private watchForStop;
1779
2036
  private notify;
1780
2037
  }
1781
2038
 
@@ -1791,6 +2048,11 @@ export declare interface AutopilotDriverOptions {
1791
2048
  readonly providerRegistry: AIProviderRegistry;
1792
2049
  /** The working session's debug-log key. */
1793
2050
  readonly sessionKey?: string;
2051
+ /**
2052
+ * Where the driver reports that it handed back to the person or stopped working, as
2053
+ * `agent-attention` (GENC-1676). Defaults to {@link NOOP_ACTIVITY_BUS}.
2054
+ */
2055
+ readonly activityBus?: ActivityBus;
1794
2056
  }
1795
2057
 
1796
2058
  /**
@@ -1802,7 +2064,7 @@ export declare interface AutopilotDriverOptions {
1802
2064
  */
1803
2065
  export declare class AutopilotHandBack extends GenesisElement {
1804
2066
  interactionId: string;
1805
- interaction?: AiChatInteraction<HandBackData, HandBackResult['payload']>;
2067
+ interaction?: AiChatInteraction<HandBackData, HandBackResult['payload'], HandBackController>;
1806
2068
  draft: string;
1807
2069
  get data(): HandBackData | undefined;
1808
2070
  /** What was chosen, once resolved. */
@@ -1826,7 +2088,8 @@ export declare interface AutopilotHost {
1826
2088
  pause(): void;
1827
2089
  /**
1828
2090
  * Resume. Takes back an interaction that pausing handed over; during the autopilot's own
1829
- * hand-back it means "decide it yourself".
2091
+ * hand-back it means "decide it yourself". Takes an interaction that opened while paused and is
2092
+ * still open, when it would have claimed it had it been running then.
1830
2093
  */
1831
2094
  resume(): void;
1832
2095
  /** The existing Stop, which also pauses, so what is shown stays honest. */
@@ -1852,9 +2115,16 @@ export declare interface AutopilotHostState {
1852
2115
  readonly interactionId?: string;
1853
2116
  readonly reason?: string;
1854
2117
  };
1855
- /** The slim bar's one-line status. */
2118
+ /**
2119
+ * The slim bar's one-line status, from `AutopilotCopy`: `running`, or `waitingForUser` while the
2120
+ * working agent waits on a question the autopilot left with the person; `selfPaused` while it
2121
+ * waits on one it handed back; `paused` otherwise.
2122
+ */
1856
2123
  readonly status: string;
1857
- /** Whether something waits on the person: drives the "needs you" badge. */
2124
+ /**
2125
+ * Whether the autopilot stopped and needs the person — its own hand-back of a widget or of a
2126
+ * turn: drives the "needs you" badge. Not set for a question it never took (see `status`).
2127
+ */
1858
2128
  readonly needsUser: boolean;
1859
2129
  /**
1860
2130
  * Whether something is happening: the working agent is busy, or the autopilot is deciding (a
@@ -2236,6 +2506,8 @@ export declare abstract class BaseDriverDecorator<TInner extends AiDriver = AiDr
2236
2506
  setPinnedAgent(name: string | null): void;
2237
2507
  setFlowOwner(name: string | null): void;
2238
2508
  getFlowOwner(): string | null;
2509
+ getInteractionCheckpoints(): readonly PersistedInteractionCheckpoint[];
2510
+ restoreInteractionCheckpoints(saved: readonly PersistedInteractionCheckpoint[]): void;
2239
2511
  getInteractionCheckpoint(): PersistedInteractionCheckpoint | undefined;
2240
2512
  restoreInteractionCheckpoint(saved: PersistedInteractionCheckpoint | undefined): void;
2241
2513
  /**
@@ -3395,9 +3667,21 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
3395
3667
  * host) to build the widget's pending `interaction` descriptor.
3396
3668
  */
3397
3669
  getInteractionContext(interactionId: string): InteractionContext | undefined;
3398
- /** {@inheritDoc AiDriver.getInteractionCheckpoint} */
3670
+ /** {@inheritDoc AiDriver.getInteractionCheckpoints} */
3671
+ getInteractionCheckpoints(): readonly PersistedInteractionCheckpoint[];
3672
+ /** {@inheritDoc AiDriver.restoreInteractionCheckpoints} */
3673
+ restoreInteractionCheckpoints(saved: readonly PersistedInteractionCheckpoint[]): void;
3674
+ /**
3675
+ * {@inheritDoc AiDriver.getInteractionCheckpoint}
3676
+ *
3677
+ * @deprecated Use `getInteractionCheckpoints`.
3678
+ */
3399
3679
  getInteractionCheckpoint(): PersistedInteractionCheckpoint | undefined;
3400
- /** {@inheritDoc AiDriver.restoreInteractionCheckpoint} */
3680
+ /**
3681
+ * {@inheritDoc AiDriver.restoreInteractionCheckpoint}
3682
+ *
3683
+ * @deprecated Use `restoreInteractionCheckpoints`.
3684
+ */
3401
3685
  restoreInteractionCheckpoint(saved: PersistedInteractionCheckpoint | undefined): void;
3402
3686
  /**
3403
3687
  * Replace the history message owning `interactionId`. `false` when it is no longer in history.
@@ -3781,6 +4065,48 @@ export declare interface ContinueFromHistoryOptions {
3781
4065
  tailNote?: string;
3782
4066
  }
3783
4067
 
4068
+ /**
4069
+ * What a widget controller needs from whatever hosts it (GENC-1660): the slice of
4070
+ * {@link InteractionContext} a controller uses, so it can be built and tested without the rest. An
4071
+ * `InteractionContext` is one, so a registration passes its `ctx` straight through:
4072
+ *
4073
+ * ```ts
4074
+ * class ReviewController {
4075
+ * constructor(data: ReviewData, private readonly host: ControllerHost<ReviewResult>) {
4076
+ * host.exposeSurface?.({ … });
4077
+ * }
4078
+ * }
4079
+ * registerInteraction<ReviewController>('review', {
4080
+ * controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),
4081
+ * });
4082
+ * ```
4083
+ *
4084
+ * `heldBy`, `exposeDecision` and `exposeSurface` are optional so a view can build the same
4085
+ * controller over a stand-in host for a card with no live context (a resolved one in the
4086
+ * transcript, a gallery): nobody can claim it, so it has nothing to expose and only the person
4087
+ * holds it. Read an absent `heldBy` as `'user'`.
4088
+ *
4089
+ * `TResult` is the payload type the controller resolves with; `TState` what it keeps on `state`.
4090
+ *
4091
+ * @beta
4092
+ */
4093
+ export declare interface ControllerHost<TResult = unknown, TState extends object = object> {
4094
+ /** Survives a remount; where a controller keeps anything the person has started. */
4095
+ readonly state: TState;
4096
+ /** Settle the interaction. See {@link InteractionContext.resolve}. */
4097
+ resolve(result: InteractionResult<TResult>, options?: InteractionResolveOptions): void;
4098
+ /** Something in the controller's state or view model changed. See {@link InteractionContext.notify}. */
4099
+ notify(): void;
4100
+ /** Who holds the interaction right now: `'user'`, or the claimant's id. Absent means the person. */
4101
+ readonly heldBy?: InteractionHolder;
4102
+ /** See {@link InteractionContext.exposeDecision}. Absent on a stand-in host. */
4103
+ exposeDecision?(decision: DecisionSpec): void;
4104
+ /** See {@link InteractionContext.exposeSurface}. Absent on a stand-in host. */
4105
+ exposeSurface?(surface: SurfaceSpec): void;
4106
+ /** See {@link InteractionContext.setWorking}. Absent on a stand-in host. */
4107
+ setWorking?(working: boolean): void;
4108
+ }
4109
+
3784
4110
  /** A model used during a recorded cost session. */
3785
4111
  export declare interface CostSessionModelEntry {
3786
4112
  model: string;
@@ -3836,6 +4162,36 @@ export declare interface CostSessionRecord {
3836
4162
  models: CostSessionModelEntry[];
3837
4163
  }
3838
4164
 
4165
+ /**
4166
+ * Build a real interaction context for a controller test (GENC-1660), so the test exercises the
4167
+ * platform's own context — its `state`, `once`, `notify`, surfaces and their checks — rather than a
4168
+ * hand-built fake that can drift from it. Nothing renders, nothing is persisted, and no driver is
4169
+ * involved: resolving records the result, and the interaction is disposed as it would be.
4170
+ *
4171
+ * @example
4172
+ * ```ts
4173
+ * const t = createTestInteractionContext<ReviewController, ReviewResult>({
4174
+ * data: { round: 1 },
4175
+ * controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),
4176
+ * });
4177
+ * t.setHeldBy('autopilot');
4178
+ * await t.act('regenerate', { text: 'amounts in EUR' });
4179
+ * assert.equal(t.result?.payload, { action: 'regenerate', instructions: 'amounts in EUR' });
4180
+ * ```
4181
+ *
4182
+ * @beta
4183
+ */
4184
+ export declare function createTestInteractionContext<TController = unknown, TResult = unknown>(options?: {
4185
+ /** Defaults to `'test-interaction'`. */
4186
+ readonly interactionId?: string;
4187
+ /** The `data` handed to `controller`. */
4188
+ readonly data?: unknown;
4189
+ /** Build the controller as the platform would, and install it as `context.controller`. */
4190
+ readonly controller?: InteractionControllerFactory<TController>;
4191
+ /** A checkpoint the platform handed over, as after a reload (`ctx.checkpoint`). */
4192
+ readonly checkpoint?: unknown;
4193
+ }): TestInteractionContext<TController, TResult>;
4194
+
3839
4195
  /**
3840
4196
  * Creates a tool fold — a facade that hides a group of related tools behind a single
3841
4197
  * named entry, revealing them progressively when the model invokes the facade.
@@ -3966,10 +4322,12 @@ export declare type DecisionOption = string | {
3966
4322
  /** The option's text, as the person sees it. */
3967
4323
  readonly label: string;
3968
4324
  /**
3969
- * Whether it can be chosen right now — the button's own guard (e.g. `validated` for a
3970
- * Continue). Read fresh every time. A disabled option is listed as unavailable and refused.
4325
+ * Why it cannot be chosen right now, or `undefined` when it can — the button's own guard (e.g.
4326
+ * "2 validation errors" for a Continue that needs a validated handler). Read fresh every time.
4327
+ * An unavailable option is listed with its reason and refused with it. Absent means always
4328
+ * available; an empty string or a throw counts as unavailable, with a generic reason.
3971
4329
  */
3972
- readonly enabledWhen?: () => boolean;
4330
+ readonly unavailable?: () => string | undefined;
3973
4331
  };
3974
4332
 
3975
4333
  /**
@@ -3982,13 +4340,47 @@ export declare interface DecisionSpec {
3982
4340
  readonly options: readonly DecisionOption[];
3983
4341
  /** Adds a `select({ options })` action that picks several. */
3984
4342
  readonly multi?: boolean;
3985
- /** Adds a `reply({ text })` action: an answer in the chooser's own words. */
4343
+ /**
4344
+ * Adds a `reply({ text })` action: an answer in the chooser's own words. It refines, so it counts
4345
+ * against the autopilot's per-step refinement limit and is withdrawn past it.
4346
+ */
3986
4347
  readonly freeText?: boolean;
4348
+ /**
4349
+ * Why the `reply` action cannot be used right now, or `undefined` when it can: the same guard
4350
+ * pattern as an option's {@link DecisionOption} `unavailable`, read fresh. For a widget whose
4351
+ * written answer only makes sense in some states (a review gate that failed, say, where only
4352
+ * handing back is left). Ignored without `freeText`.
4353
+ */
4354
+ readonly freeTextUnavailable?: () => string | undefined;
3987
4355
  /**
3988
4356
  * What a decision needs that the person sees on screen in some other form — e.g.
3989
4357
  * `{ validated: true }`. A getter, so it is read fresh whenever the decision is described.
3990
4358
  */
3991
4359
  readonly facts?: () => Readonly<Record<string, unknown>>;
4360
+ /**
4361
+ * Named views a claimant may read on demand: content too long to send with every decision but
4362
+ * sometimes needed to make it. Each is listed in the decision with its description, and read with
4363
+ * `widget_read({ view })`; a view not listed here is refused. `widget_read()` with no view still
4364
+ * reads the decision's `facts`.
4365
+ *
4366
+ * The same shape as the full form's {@link SurfaceSpec.views}, so a widget can offer something
4367
+ * to read and keep the short form's generated options.
4368
+ *
4369
+ * @example
4370
+ * ```ts
4371
+ * ctx.exposeDecision({
4372
+ * options: ['Yes, add one', 'No, skip this step'],
4373
+ * choose,
4374
+ * views: {
4375
+ * moreInfo: {
4376
+ * description: 'The "More info" explainer the person can open on the card.',
4377
+ * read: () => data.moreInfo,
4378
+ * },
4379
+ * },
4380
+ * });
4381
+ * ```
4382
+ */
4383
+ readonly views?: Readonly<Record<string, SurfaceView>>;
3992
4384
  /**
3993
4385
  * Model-only guidance the person would not see. The decision's own text comes from the
3994
4386
  * widget's `asText`, which is what the person saw.
@@ -4002,6 +4394,13 @@ export declare interface DecisionSpec {
4002
4394
  choose(answer: DecisionAnswer): void | Promise<void>;
4003
4395
  }
4004
4396
 
4397
+ /**
4398
+ * The notification's text when neither the app nor the widget gives one.
4399
+ *
4400
+ * @beta
4401
+ */
4402
+ export declare const DEFAULT_AGENT_NOTIFICATION_MESSAGE = "The assistant is ready for your next input";
4403
+
4005
4404
  /**
4006
4405
  * Animations enabled by default when a consumer opts into the animations
4007
4406
  * feature without specifying an explicit `enabled` list. Keeps the dots loading
@@ -4048,12 +4447,16 @@ export declare function defineAgent<const T extends AgentConfig>(config: T): T;
4048
4447
  * …,
4049
4448
  * autopilot: defineAutopilot<BootstrapState>({
4050
4449
  * availableWhen: ({ state }) => briefApproved(state.machine),
4051
- * widgetPolicy: { 'planning-question': 'allowed' },
4450
+ * widgetPolicy: { 'planning-question': 'allowed', 'sample-data-review': 'allowed' },
4451
+ * widgetTools: [SAMPLE_DATA_TOOLS],
4052
4452
  * systemPrompt: ({ state }) => `${AUTOPILOT_BASE}\n<brief>${frozenBrief(state)}</brief>`,
4053
4453
  * }),
4054
4454
  * });
4055
4455
  * ```
4056
4456
  *
4457
+ * Throws if two of its tools share a name — its widget tools, its own `tools` and the platform's
4458
+ * fixed three — since one would silently shadow the other.
4459
+ *
4057
4460
  * @beta
4058
4461
  */
4059
4462
  export declare function defineAutopilot<S = unknown>(config: AutopilotConfig<S>): AutopilotConfig<S>;
@@ -4522,6 +4925,55 @@ export declare class FoundationAiAssistant extends GenesisElement {
4522
4925
  */
4523
4926
  get timestampDisplay(): TimestampDisplay;
4524
4927
  set timestampDisplay(value: TimestampDisplay);
4928
+ /**
4929
+ * The person's agent notification level (GENC-1676): `'off'` (always the default),
4930
+ * `'autopilot'` or `'needs-input'`. Saved with the other settings.
4931
+ *
4932
+ * An app may set it, e.g. after its own "Notify me" invitation, once the person granted
4933
+ * permission through `requestAgentNotificationPermission`. Ignored when the app does not offer
4934
+ * the level (`chatConfig.ui.notifications`), and before the assistant has a session.
4935
+ */
4936
+ get notificationLevel(): AgentNotificationLevel;
4937
+ set notificationLevel(value: AgentNotificationLevel);
4938
+ /**
4939
+ * The level that applies: the person's choice, as `'off'` when the app no longer offers it.
4940
+ * What the settings picker shows. @internal
4941
+ */
4942
+ get effectiveNotificationLevel(): AgentNotificationLevel;
4943
+ /** The browser's notification permission, followed while connected. @internal */
4944
+ notificationPermission: AgentNotificationPermission;
4945
+ /**
4946
+ * Bumped to make the settings picker re-read its value when a choice did not take (permission
4947
+ * refused), since the stored level, and so its binding, did not change. @internal
4948
+ */
4949
+ notificationPickerRevision: number;
4950
+ /** Whether the settings row shows: offered by the app, and possible in this browser. @internal */
4951
+ get notificationSettingVisible(): boolean;
4952
+ /** Whether the settings picker offers the `'autopilot'` level. @internal */
4953
+ get notificationAutopilotOffered(): boolean;
4954
+ /**
4955
+ * The hint under the settings row when the browser will not show notifications. A block shows
4956
+ * even at Off: otherwise a person picking a level would see it snap back with no reason given,
4957
+ * since a browser that has blocked them never asks again. @internal
4958
+ */
4959
+ get notificationPermissionHint(): string;
4960
+ /**
4961
+ * The person chose a level in settings (GENC-1676). Turning notifications on asks the browser for
4962
+ * permission first — this runs inside their click, which the browser requires — and keeps the
4963
+ * old level if they refuse. @internal
4964
+ */
4965
+ chooseNotificationLevel(level: AgentNotificationLevel): Promise<void>;
4966
+ /**
4967
+ * Notifications, for this connect (GENC-1676): turn this session's `agent-attention` into
4968
+ * browser notifications, follow the browser's permission, and lend this session's settings to
4969
+ * pickers outside this element (`foundation-ai-notification-level`).
4970
+ */
4971
+ private wireNotifications;
4972
+ /**
4973
+ * Turn an `agent-attention` event for this session into a browser notification, if the
4974
+ * person's level covers it and they are not looking (GENC-1676).
4975
+ */
4976
+ private onAgentAttention;
4525
4977
  /**
4526
4978
  * Epoch ms the transcript's relative timestamps are measured against.
4527
4979
  *
@@ -5159,6 +5611,8 @@ export declare class FoundationAiAssistant extends GenesisElement {
5159
5611
  private unsubBus?;
5160
5612
  /** Unsubscribe handle for the `tool-loop-end` budget latch (GENC-1464). */
5161
5613
  private _unsubBudgetLatch?;
5614
+ /** Undoes `wireNotifications`; balanced like `_unsubBudgetLatch`, re-wired per connect. */
5615
+ private _unwireNotifications?;
5162
5616
  /** Unsubscribe handle for the provider-registry change listener (observable registries only). */
5163
5617
  private unsubProviderRegistry?;
5164
5618
  private _handlePageHide;
@@ -5328,7 +5782,10 @@ export declare class FoundationAiAssistant extends GenesisElement {
5328
5782
  */
5329
5783
  get composerAutopilotVisible(): boolean;
5330
5784
  autopilotHostOverrideChanged(): void;
5331
- /** Follow the autopilot host's state, publishing the "needs you" signal for the bubble. */
5785
+ /**
5786
+ * Follow the autopilot host's state, publishing the "needs you" signal for the bubble, and bring
5787
+ * what waits on the person into view when asked.
5788
+ */
5332
5789
  private wireAutopilot;
5333
5790
  /**
5334
5791
  * Scroll to the pending interaction that waits on the person, and pulse it, so opening the chat
@@ -6374,6 +6831,26 @@ export declare type GenesisWriteReviewCompletedEventDetail = InteractionResult<G
6374
6831
  */
6375
6832
  export declare function getAiPopoutManager(): FoundationAiPopoutManager | undefined;
6376
6833
 
6834
+ /**
6835
+ * The live context of a pending interaction, by its id (GENC-1660), for UI that the chat does not
6836
+ * render and so is never handed one: a layout side panel that shows a widget's detail, say. It can
6837
+ * subscribe, read `heldBy` and reach the controller directly, rather than through a channel of its
6838
+ * own. `undefined` once the interaction has resolved (its context is disposed then) and for an id
6839
+ * that never opened.
6840
+ *
6841
+ * `TController` types `controller`, as it was registered (`registerInteraction<TController>()`).
6842
+ * Unchecked: the caller says what it expects.
6843
+ *
6844
+ * @example
6845
+ * ```ts
6846
+ * const ctx = getInteractionContext<ReviewController>(interactionId);
6847
+ * const unsubscribe = ctx?.subscribe(() => this.render(ctx.controller?.view(), ctx.heldBy));
6848
+ * ```
6849
+ *
6850
+ * @beta
6851
+ */
6852
+ export declare function getInteractionContext<TController = unknown>(interactionId: string): InteractionContext<Record<string, unknown>, unknown, TController> | undefined;
6853
+
6377
6854
  /**
6378
6855
  * The registration for a component name, or `undefined` when it has none.
6379
6856
  *
@@ -6389,6 +6866,19 @@ export declare function getInteractionRegistration(name: string): InteractionReg
6389
6866
  */
6390
6867
  export declare type HandBackChoice = 'carry-on' | 'try-again' | 'compact' | 'pause' | 'reply';
6391
6868
 
6869
+ /**
6870
+ * The hand-back's controller. DOM-free: it exposes the choices as a decision (so the visible
6871
+ * transcript and the debug log describe it like any widget) and resolves through `ctx.resolve`. The
6872
+ * hand-back is always `userOnly`, so nothing but the person ever answers it.
6873
+ */
6874
+ declare class HandBackController {
6875
+ readonly data: HandBackData;
6876
+ private readonly ctx;
6877
+ constructor(data: HandBackData, ctx: ControllerHost<HandBackResult['payload']>);
6878
+ /** The person's choice, from the view's buttons or its text box. */
6879
+ choose(answer: DecisionAnswer): void;
6880
+ }
6881
+
6392
6882
  /**
6393
6883
  * The hand-back's inputs. Every word it shows comes from here, so it follows the autopilot's
6394
6884
  * `AutopilotCopy`.
@@ -6510,9 +7000,16 @@ export declare type InteractionCompletedEventDetail = ChatInteractionEventsMap['
6510
7000
  *
6511
7001
  * @beta
6512
7002
  */
6513
- export declare interface InteractionContext<TState extends object = Record<string, unknown>, TCheckpoint = unknown> {
7003
+ export declare interface InteractionContext<TState extends object = Record<string, unknown>, TCheckpoint = unknown, TController = unknown> {
6514
7004
  /** Stable id of the interaction this context belongs to. */
6515
7005
  readonly interactionId: string;
7006
+ /**
7007
+ * The session the interaction belongs to (GENC-1676) — plain data, the same in Node. A view
7008
+ * passes it to anything that works per session, such as
7009
+ * `<foundation-ai-notification-level session-key="...">`. Empty for a context made outside a
7010
+ * session (an inert fallback, a test).
7011
+ */
7012
+ readonly sessionKey: string;
6516
7013
  /**
6517
7014
  * Who holds this pending interaction right now: `'user'`, or the id of the interceptor that
6518
7015
  * claimed it, e.g. `'autopilot'` (GENC-1660). `'user'` unless something claimed it.
@@ -6546,6 +7043,10 @@ export declare interface InteractionContext<TState extends object = Record<strin
6546
7043
  * live resource here must guard on the resolved state and stop touching `once`
6547
7044
  * when the interaction completes — a stray late call (e.g. an async callback
6548
7045
  * landing after a `timeoutMs` timeout) gets `null` rather than a leaked resource.
7046
+ *
7047
+ * Once means once for the interaction's whole life, so it cannot fire twice: anything a
7048
+ * claimant's hand-back must do again (reopening a side panel it shut while it held the
7049
+ * interaction, say) needs a flag on `state` instead, cleared when it is undone.
6549
7050
  */
6550
7051
  once<T>(key: string, factory: () => T): T | null;
6551
7052
  /**
@@ -6568,16 +7069,53 @@ export declare interface InteractionContext<TState extends object = Record<strin
6568
7069
  onDispose(fn: () => void): void;
6569
7070
  /**
6570
7071
  * The widget's controller, built by the platform from its registration when the interaction was
6571
- * requested, before anything rendered. `undefined` for an unregistered widget. One per
6572
- * interaction for its whole life, so a remounted view picks up the same one.
7072
+ * requested, before anything rendered. `undefined` for an unregistered widget, and inside the
7073
+ * registration's own factory, which is building it. One per interaction for its whole life, so a
7074
+ * remounted view picks up the same one. Typed by `TController`: a registration made with
7075
+ * `registerInteraction<TController>()` builds one, and a view reads it typed through
7076
+ * `AiChatInteraction`'s third type argument.
6573
7077
  */
6574
- readonly controller: unknown;
7078
+ readonly controller: TController | undefined;
6575
7079
  /**
6576
7080
  * Settle the interaction with `result` — the controller's way to resolve, in place of an element
6577
7081
  * emitting `interaction-completed`, so resolving needs no mounted view. Goes through the same
6578
7082
  * path, so cost and diagnostics fold in as before. Settles once: later calls do nothing.
7083
+ *
7084
+ * Pass `{ resolvedItself: true }` when this outcome settled by itself and asked nobody, for a
7085
+ * widget that sometimes works on its own and sometimes asks (see
7086
+ * {@link InteractionResolveOptions.resolvedItself}).
7087
+ */
7088
+ resolve(result: unknown, options?: InteractionResolveOptions): void;
7089
+ /**
7090
+ * What the controller last said it is doing (GENC-1660), through {@link InteractionContext.setWorking}:
7091
+ * `true` working on its own (generating, running tests), `false` asking (what it has exposed is
7092
+ * the decision to make now), `undefined` until it says either.
7093
+ */
7094
+ readonly working: boolean | undefined;
7095
+ /**
7096
+ * Say whether the controller is working on its own or asking (GENC-1660), for a widget that does
7097
+ * both — e.g. it generates, then opens a review gate. Optional: a controller that never calls it
7098
+ * behaves exactly as before. Notifies when it changes.
7099
+ *
7100
+ * - **Status.** While it is working the person is not being asked anything, so an autopilot's
7101
+ * status reads running rather than waiting for the user, even while the person holds it. Said
7102
+ * either way, it overrides the registration's `resolvesItself` for this interaction.
7103
+ * - **Readiness** (see {@link InteractionSurface.isReady}). While it is working, nothing it
7104
+ * exposed is a decision yet, so a claimant is never sent one mid-work, even with actions
7105
+ * enabled. Once it says it is asking, what it exposed is the decision to make now, even with
7106
+ * every action unavailable — a failed gate the claimant may not cancel, say: the claimant is
7107
+ * then sent it with the actions marked unavailable, and can only hand it back. Never said, a
7108
+ * decision is due once something is enabled, as before.
7109
+ *
7110
+ * @example
7111
+ * ```ts
7112
+ * ctx.setWorking(true);
7113
+ * const code = await generate();
7114
+ * ctx.exposeDecision({ options: [...], choose });
7115
+ * ctx.setWorking(false); // the gate is open: decide it, even if nothing can be chosen
7116
+ * ```
6579
7117
  */
6580
- resolve(result: unknown): void;
7118
+ setWorking(working: boolean): void;
6581
7119
  /**
6582
7120
  * Expose what can be decided here (the short form). Called by the controller: in its constructor
6583
7121
  * for a pure question, or when its gate opens for a widget that works first. Calling again
@@ -6593,9 +7131,10 @@ export declare interface InteractionContext<TState extends object = Record<strin
6593
7131
  /** The surface the controller exposed, or `undefined` until it exposes one. */
6594
7132
  readonly surface: InteractionSurface | undefined;
6595
7133
  /**
6596
- * Run `fn` once the surface is ready (see `InteractionSurface.isReady`) — or now if
6597
- * it already is. Readiness is re-checked on every `notify()`, so a gate whose guard turns true
6598
- * later fires it then. Never runs after the interaction ends. Returns an unsubscribe.
7134
+ * Run `fn` once the surface is ready (see `InteractionSurface.isReady`, which honours
7135
+ * {@link InteractionContext.setWorking}) — or now if it already is. Readiness is re-checked on
7136
+ * every `notify()` (which `setWorking` and both `expose` calls make), so a gate whose guard turns
7137
+ * true later fires it then. Never runs after the interaction ends. Returns an unsubscribe.
6599
7138
  */
6600
7139
  onSurfaceReady(fn: () => void): () => void;
6601
7140
  /**
@@ -6606,29 +7145,49 @@ export declare interface InteractionContext<TState extends object = Record<strin
6606
7145
  claimantOwns(action: string): boolean;
6607
7146
  /** When the controller last called `notify()` (or the interaction opened), in epoch ms. A heartbeat. */
6608
7147
  readonly lastActivityAt: number;
7148
+ /**
7149
+ * Say this interaction needs the person to act (GENC-1676). If their notification level covers
7150
+ * it and they are not looking at the page, they get a browser notification. Call it at the
7151
+ * moment the widget starts waiting on the person — not before, if it has work to do first. A
7152
+ * widget that only shows information never calls it.
7153
+ *
7154
+ * Safe to call from anywhere, the controller's constructor included: the platform reports it
7155
+ * only once it has decided who holds the interaction, and drops it if a claimant (the autopilot)
7156
+ * holds it then or when it is called — the claimant's own hand-back notifies instead. Only the
7157
+ * first call counts, whatever happened to it; later ones do nothing, as do calls after the
7158
+ * interaction ends.
7159
+ *
7160
+ * @param message - The notification's text for this case. Defaults to the app's
7161
+ * `chatConfig.ui.notifications.message`, then to "The assistant is ready for your next input".
7162
+ */
7163
+ requestAttention(message?: string): void;
6609
7164
  /**
6610
7165
  * What is already done, for long work that should survive a reload: the last checkpoint saved,
6611
- * or the one the platform handed over — after a restore, the first request for the same widget
6612
- * type takes over the checkpoint the reload cut, if the registration's `sameWork` agrees.
6613
- * `undefined` for fresh work. See `runSteps`, which reads and writes it for you.
7166
+ * or the one the platform handed over. After a restore, a checkpoint the reload cut waits for a
7167
+ * request of the same widget type that the registration's `sameWork` agrees is the same work —
7168
+ * offered to each such request in turn, however many other interactions come first, and kept
7169
+ * through every refusal — and is handed to the first that agrees. `undefined` for fresh work. See
7170
+ * `runSteps`, which reads and writes it for you.
6614
7171
  */
6615
7172
  readonly checkpoint: TCheckpoint | undefined;
6616
7173
  /**
6617
7174
  * Save a checkpoint into the session snapshot, so a reload does not lose it. Kept as JSON, so it
6618
7175
  * must be storable as JSON; keep it small and hold anything large by reference (a job id, a store
6619
- * key). One per interaction: each save replaces the last. Cleared when the interaction settles,
6620
- * and when its flow ends.
7176
+ * key). One per interaction: each save replaces the last. Never replaces a checkpoint a reload cut
7177
+ * that is still waiting for its own widget. Cleared when the interaction settles, and when its
7178
+ * flow ends.
6621
7179
  */
6622
7180
  saveCheckpoint(checkpoint: TCheckpoint): void;
6623
7181
  }
6624
7182
 
6625
7183
  /**
6626
7184
  * Builds a widget's controller when its interaction is requested (GENC-1660). DOM-free: it owns the
6627
- * interaction's state, its surface and resolving it; the view only renders.
7185
+ * interaction's state, its surface and resolving it; the view only renders. `ctx` is a
7186
+ * `ControllerHost` as it stands, so a controller that takes one is passed it directly.
6628
7187
  *
6629
7188
  * @beta
6630
7189
  */
6631
- export declare type InteractionControllerFactory = (data: unknown, ctx: InteractionContext) => unknown;
7190
+ export declare type InteractionControllerFactory<TController = unknown> = (data: unknown, ctx: InteractionContext<Record<string, unknown>, unknown, TController>) => TController;
6632
7191
 
6633
7192
  /**
6634
7193
  * Detail payload for the `interaction-cost` event — a POSITIVE DELTA in USD, not a running total.
@@ -6645,12 +7204,26 @@ export { InteractionEdit }
6645
7204
  * Every interceptor is offered one, but only the claimant's works: on any other interceptor's
6646
7205
  * handle, and after the interaction ends, its members do nothing and return `false`. A claim is
6647
7206
  * granted only once `onInteractionOpened` has returned `'claim'` (it may yet be refused), so the
6648
- * claimant's own handle does nothing until then either: act on it afterwards. Views read the
7207
+ * claimant's own handle does nothing until then either: act on it afterwards. An interceptor that
7208
+ * declined can still become the claimant later with `claim`, while nobody else is. Views read the
6649
7209
  * result as `ctx.heldBy`; they never change it.
6650
7210
  *
6651
7211
  * @beta
6652
7212
  */
6653
7213
  export declare interface InteractionHold {
7214
+ /**
7215
+ * Claim the interaction after declining it when it opened, as if it had claimed it then: it
7216
+ * moves to this interceptor, and the other members work for it from here on. For an interceptor
7217
+ * whose reason to decline has gone while the interaction is still open, such as an autopilot
7218
+ * that was paused when it opened and has since been resumed.
7219
+ *
7220
+ * Refused, returning `false` with nothing changed, while the interceptors are still being asked
7221
+ * (a claim at open is made by returning `'claim'`), once any interceptor has claimed it — this
7222
+ * one included, even if it has since given it to the person, which `set('claimant')` undoes —
7223
+ * when it is `userOnly`, and after it has ended. Notifies the context's subscribers and records
7224
+ * `interaction.held`, marked `late`.
7225
+ */
7226
+ claim(): boolean;
6654
7227
  /**
6655
7228
  * Give the interaction to the person (`'user'`) or back to the claimant (`'claimant'`). Notifies
6656
7229
  * the context's subscribers and records `interaction.held`. Returns whether it applied.
@@ -6673,7 +7246,8 @@ export declare interface InteractionHold {
6673
7246
  * Settle the interaction AS the claimant (GENC-1660). The only route that stamps the claimant as
6674
7247
  * `answeredBy`: an answer through the host's `resolveInteraction` — a click — is the person's,
6675
7248
  * whoever held the interaction at the time, so attribution never depends on a view honouring
6676
- * `heldBy`. Returns `false`, settling nothing, unless this interceptor holds it right now.
7249
+ * `heldBy`. The result's `userMessage` is ignored: the person did not say it. Returns `false`,
7250
+ * settling nothing, unless this interceptor holds it right now.
6677
7251
  */
6678
7252
  resolve(result: unknown): boolean;
6679
7253
  /**
@@ -6683,7 +7257,8 @@ export declare interface InteractionHold {
6683
7257
  * and `note`, verbatim, as what they were shown about it — so `recordDecision` is not needed.
6684
7258
  *
6685
7259
  * A finishing action settles the interaction AS the claimant, as {@link InteractionHold.resolve}
6686
- * does, so it is stamped `answeredBy` the claimant.
7260
+ * does, so it is stamped `answeredBy` the claimant. Its `note` is what the person is shown about
7261
+ * the choice; the widget's `userMessage` echo is never shown for a claimant's answer, note or not.
6687
7262
  *
6688
7263
  * Refused, with nothing run, unless this interceptor holds the interaction right now, the
6689
7264
  * surface has that action, it is enabled and `args` fit it. One action runs at a time: a call
@@ -6714,8 +7289,9 @@ export declare type InteractionHolder = 'user' | (string & {});
6714
7289
  * decorator such as an autopilot or a test harness.
6715
7290
  *
6716
7291
  * Interceptors are asked outermost first. The first to claim an interaction holds it; the rest
6717
- * observe — they see the same context but their `hold` does nothing. Nobody can claim a `userOnly`
6718
- * interaction. A throwing interceptor is logged and treated as abstaining.
7292
+ * observe — they see the same context but their `hold` does nothing. When none claims it, any of
7293
+ * them may claim it later with `hold.claim`, the first to do so winning. Nobody can claim a
7294
+ * `userOnly` interaction. A throwing interceptor is logged and treated as abstaining.
6719
7295
  *
6720
7296
  * @beta
6721
7297
  */
@@ -6763,21 +7339,25 @@ export declare interface InteractionOpened {
6763
7339
  readonly userOnly: boolean;
6764
7340
  /** The interaction's live context, the same object its widget is handed. */
6765
7341
  readonly ctx: InteractionContext;
6766
- /** See {@link InteractionHold}. Works only for the interceptor whose claim was granted. */
7342
+ /**
7343
+ * See {@link InteractionHold}. Works only for the interceptor whose claim was granted, at open or
7344
+ * later through `claim`.
7345
+ */
6767
7346
  readonly hold: InteractionHold;
6768
7347
  }
6769
7348
 
6770
7349
  /**
6771
- * How a widget is registered with the platform, once, at start-up (GENC-1660).
7350
+ * How a widget is registered with the platform, once, at start-up (GENC-1660). `TController` is
7351
+ * the type its factory builds, which `ctx.controller` then carries.
6772
7352
  *
6773
7353
  * @beta
6774
7354
  */
6775
- export declare interface InteractionRegistration {
7355
+ export declare interface InteractionRegistration<TController = unknown> {
6776
7356
  /**
6777
7357
  * Builds the controller when the interaction is requested, before anything renders. Without
6778
7358
  * one the widget works exactly as today and is never handed to a claimant.
6779
7359
  */
6780
- readonly controller?: InteractionControllerFactory;
7360
+ readonly controller?: InteractionControllerFactory<TController>;
6781
7361
  /** The custom element that renders it. Defaults to the registered name. */
6782
7362
  readonly view?: string;
6783
7363
  /**
@@ -6796,8 +7376,45 @@ export declare interface InteractionRegistration {
6796
7376
  * Without it, the same widget type is enough. Compare identity only — the fields the work's
6797
7377
  * output depends on, kept in the checkpoint itself — never the model's prose, which a resumed call
6798
7378
  * rewrites.
7379
+ *
7380
+ * Asked of every request of this widget type until it agrees: a refusal keeps the checkpoint for
7381
+ * a later request, so it must refuse whatever is not this work (another handler, superseded code)
7382
+ * rather than rely on being asked only once.
6799
7383
  */
6800
7384
  readonly sameWork?: (saved: unknown, next: unknown) => boolean;
7385
+ /**
7386
+ * Whether the widget does its work and settles on its own, asking the person nothing: a
7387
+ * generation run that resolves when it is done, which the person may interrupt (a Skip button)
7388
+ * but is not being asked to answer. Defaults to `false`, a widget that asks.
7389
+ *
7390
+ * While one is open the turn is working, not parked on the person, so an autopilot's status stays
7391
+ * `running` rather than `waitingForUser`. When it settles by any route but a claimant's hold,
7392
+ * nobody answered it: the interaction message carries no `answeredBy`, the `interaction-settled`
7393
+ * event and the `interaction.resolved` debug event carry `resolvedItself: true` instead, and the
7394
+ * transcript a claimant reads labels it `finished` rather than answered by the user. The platform
7395
+ * cannot tell the widget finishing from the person interrupting it — both settle it the same way
7396
+ * — so a widget whose agent needs to know which says so in its own result.
7397
+ *
7398
+ * Claiming is unchanged: a claimant can take one only through a controller and its policy, as for
7399
+ * any widget.
7400
+ *
7401
+ * For a widget that sometimes works on its own and sometimes asks — a generation phase that ends
7402
+ * at a review gate — leave this unset and say it per interaction instead: `ctx.setWorking(true)`
7403
+ * while it works (the status), and `ctx.resolve(result, { resolvedItself: true })` for an outcome
7404
+ * that settled itself (a generation that failed outright). A controller's `setWorking` overrides
7405
+ * this flag for the status of its own interaction.
7406
+ *
7407
+ * @example
7408
+ * ```ts
7409
+ * registerInteraction('sample-data-generation', {
7410
+ * resolvesItself: true,
7411
+ * asText: sampleDataAsText,
7412
+ * });
7413
+ * ```
7414
+ *
7415
+ * @beta
7416
+ */
7417
+ readonly resolvesItself?: boolean;
6801
7418
  }
6802
7419
 
6803
7420
  /**
@@ -6807,13 +7424,40 @@ export declare interface InteractionRegistration {
6807
7424
  */
6808
7425
  declare type InteractionRequester = <T>(componentName: string, data: any, options?: InteractionRequestOptions, onOpened?: (interactionId: string) => void, ownerPath?: readonly string[], onSettled?: (settled: InteractionSettled) => void) => Promise<T>;
6809
7426
 
7427
+ /**
7428
+ * How a controller settles its interaction, beside the result (GENC-1660). See
7429
+ * {@link InteractionContext.resolve}.
7430
+ *
7431
+ * @beta
7432
+ */
7433
+ export declare interface InteractionResolveOptions {
7434
+ /**
7435
+ * This outcome settled by itself and nobody answered it — a generation that failed outright, say
7436
+ * — though the widget is not registered `resolvesItself` because at other times it asks (a review
7437
+ * gate). It is then treated exactly as a `resolvesItself` widget's settle: no `answeredBy` on the
7438
+ * message, the asking tool's result or the `interaction-settled` event, and `resolvedItself: true`
7439
+ * on the message, the event and the `interaction.resolved` debug event, so neither the working
7440
+ * agent nor a claimant is told the person decided it.
7441
+ *
7442
+ * Ignored when a claimant settles it through its hold (a finishing action that ends up resolving
7443
+ * here is the claimant's answer), and on a timeout or a stop, which nobody answered anyway.
7444
+ */
7445
+ readonly resolvedItself?: boolean;
7446
+ }
7447
+
6810
7448
  /**
6811
7449
  * Who answered an interaction, as its requester is told (GENC-1660). `answeredBy` is absent when it
6812
- * closed unanswered (a timeout or a stop); `decision` is present when an interceptor answered;
6813
- * `edited` is present when the person answered one an interceptor had changed first.
7450
+ * closed unanswered (a timeout or a stop) and when nobody answered it because it settled by itself
7451
+ * (`resolvedItself`); `decision` is present when an interceptor answered; `edited` is present when
7452
+ * the person answered one an interceptor had changed first.
6814
7453
  */
6815
7454
  declare interface InteractionSettled {
6816
7455
  readonly answeredBy?: string;
7456
+ /**
7457
+ * It settled by itself, other than through a claimant's hold: its widget is registered
7458
+ * `resolvesItself`, or its controller resolved this outcome with `{ resolvedItself: true }`.
7459
+ */
7460
+ readonly resolvedItself?: boolean;
6817
7461
  readonly decision?: DelegatedDecision;
6818
7462
  readonly edited?: DelegatedEdits;
6819
7463
  }
@@ -6827,20 +7471,35 @@ declare interface InteractionSettled {
6827
7471
  export declare interface InteractionSurface {
6828
7472
  /** Model-only guidance, from the decision's `prompt`. */
6829
7473
  readonly prompt?: string;
6830
- /** Read fresh on every call. */
7474
+ /** Read fresh on every call. Always `{}` on a full-form surface. */
6831
7475
  facts(): Readonly<Record<string, unknown>>;
6832
7476
  /** A full-form surface's description. Absent on a short-form decision. */
6833
7477
  describe?(): string;
6834
- /** A full-form surface's views. */
6835
- readonly views?: readonly string[];
6836
- /** Read one view of a full-form surface; absent on a short-form decision. */
7478
+ /**
7479
+ * Its views, by name, each with the description the model is shown: a full-form surface's or a
7480
+ * short-form decision's. Absent when it has none.
7481
+ */
7482
+ readonly views?: Readonly<Record<string, string>>;
7483
+ /** A full-form surface's {@link SurfaceSpec.preview}: the view sent with the decision. */
7484
+ readonly preview?: string;
7485
+ /**
7486
+ * Read one view by name, or the default with none: a short-form decision's facts, or a full-form
7487
+ * surface's preview (`undefined` when it names none). A name it does not list reads as
7488
+ * `undefined`. Absent when it has no views.
7489
+ */
6837
7490
  read?(view?: string): unknown;
6838
7491
  /** Read fresh on every call: `enabled` reflects each option's guard right now. */
6839
7492
  actions(): readonly SurfaceAction[];
6840
7493
  /**
6841
- * Whether a claimant could act on it now. A short-form decision is ready once one of its options
6842
- * is enabled; a full-form surface once any of its actions is, since editing comes before
6843
- * finishing (its Save may be disabled until something is edited).
7494
+ * Whether a decision is due now: what a claimant is sent a decision on (`onSurfaceReady`).
7495
+ *
7496
+ * First, what the controller said through `ctx.setWorking`: while it is working, never, whatever
7497
+ * is enabled; once it is asking, always, even with every action unavailable — the claimant is
7498
+ * then sent the decision with the actions marked unavailable, and can only hand it back. When it
7499
+ * has said neither, the surface's own rule: a short-form decision is ready once one of its
7500
+ * finishing options is enabled (a `reply` counts, having no guard); a full-form surface once any
7501
+ * of its actions is, since editing comes before finishing (its Save may be disabled until
7502
+ * something is edited).
6844
7503
  */
6845
7504
  isReady(): boolean;
6846
7505
  }
@@ -6964,6 +7623,26 @@ export { ModelTagAppearance }
6964
7623
  */
6965
7624
  export declare const NOOP_ACTIVITY_BUS: ActivityBus;
6966
7625
 
7626
+ /**
7627
+ * What a notification level picker reads and calls (GENC-1676): the assistant, in its own
7628
+ * settings, and `foundation-ai-notification-level` anywhere else.
7629
+ *
7630
+ * @internal
7631
+ */
7632
+ declare interface NotificationLevelPickerSource {
7633
+ /** The level that applies: what the picker shows. */
7634
+ readonly effectiveNotificationLevel: AgentNotificationLevel;
7635
+ /** Whether to offer the `'autopilot'` level. */
7636
+ readonly notificationAutopilotOffered: boolean;
7637
+ /**
7638
+ * Bumped to make the picker re-read its value when a choice did not take (permission refused),
7639
+ * since the level, and so its binding, did not change.
7640
+ */
7641
+ readonly notificationPickerRevision: number;
7642
+ /** The person picked a level. Called straight from their click, for the permission request. */
7643
+ chooseNotificationLevel(level: AgentNotificationLevel): Promise<void>;
7644
+ }
7645
+
6967
7646
  /**
6968
7647
  * Orchestrates multiple specialist agents. Sits between `FoundationAiAssistant`
6969
7648
  * and `ChatDriver`, classifying each user message and routing it to the right
@@ -7278,10 +7957,21 @@ export declare interface PersistedSession {
7278
7957
  mode: 'running' | 'paused';
7279
7958
  };
7280
7959
  /**
7281
- * The checkpoint of a long action (GENC-1660 §4.12): what a widget's work had already done, so a
7282
- * reload skips it. Kept here rather than on the interaction message, which a restore trims. On
7283
- * restore it waits for the first request of the same widget type. Optional and additive, like
7284
- * `condensePolicies`.
7960
+ * The checkpoints of long actions (GENC-1660 §4.12): what widgets' work had already done, so a
7961
+ * reload skips it — the one in flight, and any an earlier reload cut that nothing has taken over
7962
+ * yet. Kept here rather than on the interaction messages, which a restore trims. On restore each
7963
+ * waits for a request of its own widget type that `sameWork` agrees is the same work. Optional
7964
+ * and additive, like `condensePolicies`; omitted when there are none.
7965
+ */
7966
+ checkpoints?: Array<{
7967
+ componentName: string;
7968
+ value: unknown;
7969
+ }>;
7970
+ /**
7971
+ * The one checkpoint a snapshot held before `checkpoints` existed. Read on restore when
7972
+ * `checkpoints` is absent; never written now.
7973
+ *
7974
+ * @deprecated Written as `checkpoints`.
7285
7975
  */
7286
7976
  checkpoint?: {
7287
7977
  componentName: string;
@@ -7339,9 +8029,19 @@ declare type ProviderRefusedDetail = NonNullable<Extract<ChatDriverResult, {
7339
8029
  *
7340
8030
  * Registering is optional and additive: an unregistered widget works exactly as before.
7341
8031
  *
8032
+ * Generic over the controller its factory builds, which types `ctx.controller` for the factory and
8033
+ * for anything that reads the context with the same type argument (a view, a widget tool):
8034
+ *
8035
+ * ```ts
8036
+ * registerInteraction<ReviewController>('review', {
8037
+ * controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),
8038
+ * asText: reviewAsText,
8039
+ * });
8040
+ * ```
8041
+ *
7342
8042
  * @beta
7343
8043
  */
7344
- export declare function registerInteraction(name: string, registration: InteractionRegistration): void;
8044
+ export declare function registerInteraction<TController = unknown>(name: string, registration: InteractionRegistration<TController>): void;
7345
8045
 
7346
8046
  /**
7347
8047
  * Build a {@link TieredAIProviderSwitcher} — which registers the tier-shaped provider
@@ -7366,6 +8066,16 @@ export declare function registerTieredAIProviders(container: Container, options:
7366
8066
  */
7367
8067
  export declare const REQUEST_CONTINUATION_TOOL = "request_continuation";
7368
8068
 
8069
+ /**
8070
+ * Ask the person for permission to show notifications, and resolve to the result. Call it from a
8071
+ * click or key handler: browsers ignore or refuse a request that does not come from the person.
8072
+ * Resolves straight away when permission is already decided or unsupported, since a browser only
8073
+ * ever asks once.
8074
+ *
8075
+ * @beta
8076
+ */
8077
+ export declare function requestAgentNotificationPermission(): Promise<AgentNotificationPermission>;
8078
+
7369
8079
  /** Resolved context-headroom thresholds for the active model. */
7370
8080
  declare interface ResolvedContextBudget {
7371
8081
  /**
@@ -7717,6 +8427,11 @@ export declare interface SessionPreferences {
7717
8427
  * Absent keeps the `chatConfig.ui.showTimestamps` default, which is `'always'`.
7718
8428
  */
7719
8429
  timestampDisplay?: string;
8430
+ /**
8431
+ * The agent notification level (`AgentNotificationLevel` values, as plain strings). Absent
8432
+ * means `'off'`: unlike the other preferences, no config default can switch it on.
8433
+ */
8434
+ notificationLevel?: string;
7720
8435
  /** Enabled loading-animation ids (`AiAssistantAnimation` values, as plain strings). */
7721
8436
  animations?: string[];
7722
8437
  }
@@ -8191,7 +8906,7 @@ export declare type SuggestionsState = {
8191
8906
  * @beta
8192
8907
  */
8193
8908
  export declare interface SurfaceAction {
8194
- /** The name to invoke it by: an option's id, or `select` / `reply`. */
8909
+ /** The name to invoke it by: an option's id, `select` / `reply`, or a full-form action's name. */
8195
8910
  readonly name: string;
8196
8911
  /** The text the person sees for it, where it has one. */
8197
8912
  readonly label?: string;
@@ -8199,11 +8914,20 @@ export declare interface SurfaceAction {
8199
8914
  readonly finishes: boolean;
8200
8915
  /** Whether it can be run right now. */
8201
8916
  readonly enabled: boolean;
8917
+ /** Why it cannot be run right now, when it is not enabled. */
8918
+ readonly unavailable?: string;
8202
8919
  /**
8203
8920
  * What its `args` must look like, where it takes any: `options` (a multi-select's picks), `text`
8204
- * (a written answer) or `fields` (an object, described by `argsSchema`).
8921
+ * (one free-text argument: a written answer, or a full-form action declared with
8922
+ * {@link SurfaceActionSpec.text}) or `fields` (an object, described by `argsSchema`).
8205
8923
  */
8206
8924
  readonly args?: 'options' | 'text' | 'fields';
8925
+ /**
8926
+ * Whether it counts against the autopilot's per-step refinement limit (`maxRefinements`), and is
8927
+ * withdrawn once the limit is reached: `reply`, and a full-form action declared with
8928
+ * {@link SurfaceActionSpec.refines}.
8929
+ */
8930
+ readonly refines?: boolean;
8207
8931
  /** A full-form action's own description, for the model. Short-form options have none. */
8208
8932
  readonly description?: string;
8209
8933
  /** For `fields`: the JSON schema its arguments are checked against. */
@@ -8214,6 +8938,9 @@ export declare interface SurfaceAction {
8214
8938
  * One action of a full-form surface (GENC-1660 §4.2): a named thing a claimant can do, which may or
8215
8939
  * may not settle the interaction.
8216
8940
  *
8941
+ * It takes nothing, one free-text argument (`text`), or a form (`argsSchema`), never both of the
8942
+ * last two.
8943
+ *
8217
8944
  * @beta
8218
8945
  */
8219
8946
  export declare interface SurfaceActionSpec {
@@ -8221,16 +8948,42 @@ export declare interface SurfaceActionSpec {
8221
8948
  readonly description: string;
8222
8949
  /** Whether it settles the interaction. An editing action (`edit_rows`) does not. */
8223
8950
  readonly finishes?: boolean;
8224
- /** The button's own guard, read fresh: the claimant can never do what the view would refuse. */
8225
- readonly enabledWhen?: () => boolean;
8226
8951
  /**
8227
- * The JSON schema of its arguments, an object. Its `properties` and `required` are checked before
8228
- * it runs; a mismatch is refused with the reason, so the model can correct itself.
8952
+ * Why it cannot be run right now, or `undefined` when it can: the button's own guard, read fresh,
8953
+ * so the claimant can never do what the view would refuse. The reason is shown with the action
8954
+ * and given when a call is refused. Absent means always available; an empty string or a throw
8955
+ * counts as unavailable, with a generic reason.
8956
+ */
8957
+ readonly unavailable?: () => string | undefined;
8958
+ /**
8959
+ * It takes one free-text argument, which the claimant passes as `widget_act`'s own `text`, as
8960
+ * for `reply` — e.g. a regenerate's instruction. `run` then receives that text, trimmed, as a
8961
+ * string; an empty one is refused before it runs. Prefer it to an `argsSchema` with one string
8962
+ * property: plain text needs no JSON inside a string, which models get wrong.
8963
+ */
8964
+ readonly text?: boolean;
8965
+ /**
8966
+ * The JSON schema of its arguments, an object, for a real form. Its `properties` and `required`
8967
+ * are checked before it runs; a mismatch is refused with the reason, so the model can correct
8968
+ * itself. The claimant sends them as JSON text in `widget_act`'s `fields`, which is parsed
8969
+ * leniently (an object is taken as it is, a code fence is stripped), and invalid JSON is refused
8970
+ * with an example built from this schema. For one free-text argument use
8971
+ * {@link SurfaceActionSpec.text} instead.
8229
8972
  */
8230
8973
  readonly argsSchema?: Readonly<Record<string, unknown>>;
8974
+ /**
8975
+ * It refines rather than accepts — a regenerate with instructions, a retry with changes — so it
8976
+ * counts against the autopilot's per-step refinement limit (`maxRefinements`) exactly as a
8977
+ * written `reply` does, and is withdrawn (not listed, and refused) once the limit is reached.
8978
+ * Counted per step, not per interaction, so a refine that opens a new review of the same step
8979
+ * still counts. A claimant's limit only: a person's button is never limited by it.
8980
+ */
8981
+ readonly refines?: boolean;
8231
8982
  /**
8232
8983
  * Do it — the SAME code the view's control runs. A finishing action resolves the interaction; an
8233
- * editing one returns what changed (fresh errors, say), which the claimant is shown.
8984
+ * editing one returns what changed (fresh errors, say), which the claimant is shown. Receives
8985
+ * the text for a {@link SurfaceActionSpec.text} action, the checked object for an `argsSchema`
8986
+ * one, and `{}` otherwise.
8234
8987
  *
8235
8988
  * A finishing action should settle promptly. While one runs asynchronously, the claimant can run
8236
8989
  * nothing else, and it keeps the claimant's credit even if the interaction is handed to the person
@@ -8252,18 +9005,52 @@ export declare interface SurfaceActionSpec {
8252
9005
  export declare interface SurfaceSpec {
8253
9006
  /** For the model: what this is, and what good looks like. Read fresh. */
8254
9007
  describe(): string;
8255
- /** The names of the views `read` answers, e.g. `['summary', 'rows', 'errors']`. */
8256
- readonly views?: readonly string[];
8257
9008
  /**
8258
- * The widget's state as JSON, by view, so a large widget is read a slice at a time. Called with
8259
- * no view for the default (shown with the decision, so pick something small).
9009
+ * Named views a claimant may read with `widget_read({ view })`, each listed in the decision with
9010
+ * its description — the same shape as a short-form decision's {@link DecisionSpec.views}. Fixed
9011
+ * names with no parameters: a read that takes any (one table's rows) is a widget tool (see
9012
+ * `widgetTools`), and a view not listed here is refused.
9013
+ */
9014
+ readonly views?: Readonly<Record<string, SurfaceView>>;
9015
+ /**
9016
+ * The view sent with the decision, as `Now:`, to save a round trip; `widget_read()` with no view
9017
+ * reads it again. One of {@link SurfaceSpec.views}; unset sends none. Keep it small, and do not
9018
+ * repeat the widget's `asText`, which opens the same decision message: send what the text form
9019
+ * does not already say.
8260
9020
  */
8261
- read(view?: string): unknown;
9021
+ readonly preview?: string;
8262
9022
  readonly actions: Readonly<Record<string, SurfaceActionSpec>>;
8263
9023
  /** Model-only guidance, beside `describe`. */
8264
9024
  readonly prompt?: string;
8265
9025
  }
8266
9026
 
9027
+ /**
9028
+ * One named view of a surface (GENC-1660): content a claimant reads only when it asks for it, such
9029
+ * as a long explainer the person opens on the card, or a summary of a rich widget's state. Listed
9030
+ * in the decision with its description; its content is not, unless it is a full-form surface's
9031
+ * {@link SurfaceSpec.preview}.
9032
+ *
9033
+ * The same shape in both forms: a short-form decision's {@link DecisionSpec.views} and a full-form
9034
+ * surface's {@link SurfaceSpec.views}.
9035
+ *
9036
+ * A view takes no parameters. A read that needs them (one table's rows, a page at an offset) is a
9037
+ * widget tool instead: see `widgetTools`.
9038
+ *
9039
+ * Every read is capped at about 20,000 characters, cut with a note telling the model to ask for
9040
+ * less, so page anything that can grow.
9041
+ *
9042
+ * @beta
9043
+ */
9044
+ export declare interface SurfaceView {
9045
+ /**
9046
+ * For the model: what the view holds and when it is worth reading. Shown with every decision, so
9047
+ * keep it to a sentence — it is what tells the model the view exists at all.
9048
+ */
9049
+ readonly description: string;
9050
+ /** The view's content, as JSON. Read fresh on every `widget_read({ view })`. */
9051
+ read(): unknown;
9052
+ }
9053
+
8267
9054
  /**
8268
9055
  * Context passed to the function form of `systemPrompt` / `toolDefinitions`.
8269
9056
  * Resolved each tool-loop iteration so the agent can vary what the LLM sees per turn.
@@ -8314,6 +9101,57 @@ export declare type TailContextInput = string | ((ctx: SystemPromptContext) => s
8314
9101
  */
8315
9102
  export declare type TemperatureInput = number | ((ctx: SystemPromptContext) => number | Promise<number>);
8316
9103
 
9104
+ /**
9105
+ * What a claimant's action came to in a test: as `InteractionHold.invoke` reports it, less the
9106
+ * holding (a test context has no claimant to check).
9107
+ *
9108
+ * @beta
9109
+ */
9110
+ export declare type TestActResult = {
9111
+ readonly ok: true;
9112
+ readonly finished: boolean;
9113
+ readonly output?: unknown;
9114
+ } | {
9115
+ readonly ok: false;
9116
+ readonly error: 'no-surface' | 'unknown-action' | 'disabled' | 'invalid-args' | 'threw';
9117
+ readonly message: string;
9118
+ };
9119
+
9120
+ /**
9121
+ * A real {@link InteractionContext} for a controller test, with the handles a test needs
9122
+ * (GENC-1660). See {@link createTestInteractionContext}.
9123
+ *
9124
+ * @beta
9125
+ */
9126
+ export declare interface TestInteractionContext<TController = unknown, TResult = unknown> {
9127
+ /** The context, as the platform builds it: pass it to the controller as its host. */
9128
+ readonly context: InteractionContext<Record<string, unknown>, unknown, TController>;
9129
+ /** The controller, when built through `options.controller`; otherwise `undefined`. */
9130
+ readonly controller: TController | undefined;
9131
+ /** What the controller resolved with, or `undefined` while it has not. Only the first counts. */
9132
+ readonly result: InteractionResult<TResult> | undefined;
9133
+ /**
9134
+ * Whether the controller said its outcome settled by itself
9135
+ * (`ctx.resolve(result, { resolvedItself: true })`), which the platform then stamps as answered
9136
+ * by nobody. `false` while it has not resolved.
9137
+ */
9138
+ readonly resolvedItself: boolean;
9139
+ /** How many times `notify()` has been called. */
9140
+ readonly notifications: number;
9141
+ /** The surface the controller exposed, as a claimant reads it; `undefined` until it exposes one. */
9142
+ readonly surface: InteractionSurface | undefined;
9143
+ /** Move the interaction to `holder` (`'user'`, or a claimant's id such as `'autopilot'`). */
9144
+ setHeldBy(holder: InteractionHolder): void;
9145
+ /**
9146
+ * Run one of the surface's actions as a claimant would, through the platform's own checks (the
9147
+ * action exists, its guard allows it, its arguments fit) and then its `run`: an option by id,
9148
+ * `select` with `{ options }`, `reply` or a text action with `{ text }`, a form with its fields.
9149
+ */
9150
+ act(action: string, args?: unknown): Promise<TestActResult>;
9151
+ /** End the interaction, running its `onDispose` callbacks, as settling it would. */
9152
+ dispose(): void;
9153
+ }
9154
+
8317
9155
  /**
8318
9156
  * Extended-thinking posture for an agent — whether the model reasons before answering. Either a
8319
9157
  * static `ChatThinkingPolicy` or a function resolved **once per user turn**, at the start of the
@@ -8835,6 +9673,102 @@ export declare class WebStorageSessionProvider implements SessionPersistenceProv
8835
9673
  savePreferences(sessionKey: string, preferences: SessionPreferences): Promise<void>;
8836
9674
  }
8837
9675
 
9676
+ /**
9677
+ * A widget's tools, bound to its component name: what {@link widgetTools} builds, and what an
9678
+ * autopilot's `widgetTools` takes.
9679
+ *
9680
+ * @beta
9681
+ */
9682
+ export declare interface WidgetTools {
9683
+ /** The widget type the tools read from: its registered component name. */
9684
+ readonly componentName: string;
9685
+ /** The tools, by name. */
9686
+ readonly tools: Readonly<Record<string, WidgetToolSpec<unknown, Record<string, unknown>>>>;
9687
+ }
9688
+
9689
+ /**
9690
+ * Declare tools that read from one widget type (GENC-1660): parameterised reads that a view cannot
9691
+ * express, such as one table's rows, or a page of them.
9692
+ *
9693
+ * Put them on the autopilot (`defineAutopilot({ widgetTools: [...] })`), never discovered from the
9694
+ * registration. Its tool list is fixed when its session starts, sorted by name, and identical for
9695
+ * every decision, so the cache never breaks. Each call is routed to the interaction of
9696
+ * `componentName` the autopilot is deciding, and `run` gets its controller; with none open, it is
9697
+ * refused with a reason. While one is open, the autopilot's tail says which tools are usable now.
9698
+ *
9699
+ * Reads only. Their results leave the autopilot's history at the end of the decision, as
9700
+ * `widget_read`'s do.
9701
+ *
9702
+ * @example
9703
+ * ```ts
9704
+ * export const SAMPLE_DATA_TOOLS = widgetTools('sample-data-review', {
9705
+ * sample_data_rows: {
9706
+ * definition: {
9707
+ * description: "One table's rows. Only while a sample-data review is open.",
9708
+ * parameters: {
9709
+ * type: 'object',
9710
+ * properties: { table: { type: 'string' }, offset: { type: 'integer' } },
9711
+ * required: ['table'],
9712
+ * },
9713
+ * },
9714
+ * run: (controller: SampleDataReviewController, args: { table: string; offset?: number }) =>
9715
+ * controller.rows(args.table, args.offset ?? 0),
9716
+ * },
9717
+ * });
9718
+ * ```
9719
+ *
9720
+ * @beta
9721
+ */
9722
+ export declare function widgetTools<TController, TArgs extends {
9723
+ [name: string]: object;
9724
+ }>(componentName: string, tools: {
9725
+ [K in keyof TArgs]: WidgetToolSpec<TController, TArgs[K]>;
9726
+ }): WidgetTools;
9727
+
9728
+ /**
9729
+ * One widget tool (GENC-1660): an ordinary tool with native, typed parameters that reads from the
9730
+ * widget open right now. `TController` is the widget's controller, as it was registered; `TArgs`
9731
+ * the parameters, as the model sends them.
9732
+ *
9733
+ * @beta
9734
+ */
9735
+ export declare interface WidgetToolSpec<TController = unknown, TArgs = Record<string, unknown>> {
9736
+ /**
9737
+ * The tool as the model sees it, less its name (the key it is declared under). Design it to the
9738
+ * same provider rules as any other tool: plain types, no type unions, no arrays of objects. Its
9739
+ * description should say when it applies, e.g. "Only while a sample-data review is open.": the
9740
+ * tool is offered on every decision, so the cached prefix never changes.
9741
+ *
9742
+ * Its `parameters`' `required` properties and their declared top-level types are checked before
9743
+ * `run` is called; a mismatch is refused with the reason.
9744
+ */
9745
+ readonly definition: Omit<ChatToolDefinition, 'name'>;
9746
+ /**
9747
+ * Why it cannot be used right now, or `undefined` when it can, for a tool that applies only in
9748
+ * some of its widget's states (the handler's code, once there is some). Read fresh: the tail lists
9749
+ * the tool only while this is `undefined`, and a call otherwise is refused with this reason before
9750
+ * `run`. Absent means whenever its widget is open; an empty string or a throw counts as
9751
+ * unavailable, with a generic reason. The tool stays declared either way, so the cached prefix
9752
+ * never changes.
9753
+ *
9754
+ * @example
9755
+ * ```ts
9756
+ * unavailable: (c) => (c.code ? undefined : 'No code has been generated yet.'),
9757
+ * ```
9758
+ */
9759
+ unavailable?(controller: TController): string | undefined;
9760
+ /**
9761
+ * Read what was asked from the open widget's controller, and return it: JSON, or text. Reads
9762
+ * only — it must never settle or change the widget; anything that does goes through a
9763
+ * `widget_act` action, under the claimant's hold. A throw is reported to the model as the reason
9764
+ * the read failed.
9765
+ *
9766
+ * What it returns is capped at about 20,000 characters, cut with a note telling the model to ask
9767
+ * for less, so page anything that can grow (an `offset`, a `limit`).
9768
+ */
9769
+ run(controller: TController, args: TArgs): unknown | Promise<unknown>;
9770
+ }
9771
+
8838
9772
  /**
8839
9773
  * A stored diagnostics stream with its `meta-snapshot`s replaced by `fresh` — what to
8840
9774
  * pass {@link assembleDebugLog} when reassembling a persisted stream for export.