@genesislcap/ai-assistant 15.81.0 → 15.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-assistant.api.json +2800 -116
- package/dist/ai-assistant.d.ts +887 -109
- package/dist/chat-driver.cjs +468 -107
- package/dist/chat-driver.cjs.map +4 -4
- package/dist/chat-driver.mjs +468 -107
- package/dist/chat-driver.mjs.map +4 -4
- package/dist/custom-elements.json +1108 -61
- package/dist/dts/autopilot/autopilot-driver.d.ts +117 -11
- package/dist/dts/autopilot/autopilot-driver.d.ts.map +1 -1
- package/dist/dts/autopilot/autopilot-session.d.ts +55 -7
- package/dist/dts/autopilot/autopilot-session.d.ts.map +1 -1
- package/dist/dts/autopilot/autopilot-tools.d.ts +3 -2
- package/dist/dts/autopilot/autopilot-tools.d.ts.map +1 -1
- package/dist/dts/autopilot/decision-message.d.ts +35 -3
- package/dist/dts/autopilot/decision-message.d.ts.map +1 -1
- package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts +2 -2
- package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts.map +1 -1
- package/dist/dts/autopilot/hand-back/hand-back.d.ts +2 -2
- package/dist/dts/autopilot/hand-back/hand-back.d.ts.map +1 -1
- package/dist/dts/autopilot/index.d.ts +1 -0
- package/dist/dts/autopilot/index.d.ts.map +1 -1
- package/dist/dts/autopilot/widget-tools.d.ts +95 -0
- package/dist/dts/autopilot/widget-tools.d.ts.map +1 -0
- package/dist/dts/channel/ai-activity-channel.d.ts +10 -0
- package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
- package/dist/dts/components/agent-session/agent-session.d.ts +2 -1
- package/dist/dts/components/agent-session/agent-session.d.ts.map +1 -1
- package/dist/dts/components/ai-driver/ai-driver.d.ts +25 -6
- package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
- package/dist/dts/components/ai-driver/base-driver-decorator.d.ts +2 -0
- package/dist/dts/components/ai-driver/base-driver-decorator.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts +14 -2
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/interaction-controller.d.ts +61 -17
- package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +6 -0
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
- package/dist/dts/config/config.d.ts +31 -6
- package/dist/dts/config/config.d.ts.map +1 -1
- package/dist/dts/config/define-stateful-agent.d.ts +5 -1
- package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
- package/dist/dts/index.d.ts +4 -2
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +33 -16
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/main/main.template.d.ts.map +1 -1
- package/dist/dts/main/main.types.d.ts +15 -0
- package/dist/dts/main/main.types.d.ts.map +1 -1
- package/dist/dts/notifications/agent-notifications.d.ts +6 -2
- package/dist/dts/notifications/agent-notifications.d.ts.map +1 -1
- package/dist/dts/notifications/agent-notifier.d.ts +26 -4
- package/dist/dts/notifications/agent-notifier.d.ts.map +1 -1
- package/dist/dts/state/decision-surface.d.ts +22 -4
- package/dist/dts/state/decision-surface.d.ts.map +1 -1
- package/dist/dts/state/interaction-context.d.ts +23 -4
- package/dist/dts/state/interaction-context.d.ts.map +1 -1
- package/dist/dts/state/interaction-registry.d.ts +55 -6
- package/dist/dts/state/interaction-registry.d.ts.map +1 -1
- package/dist/dts/state/live-interactions.d.ts +28 -0
- package/dist/dts/state/live-interactions.d.ts.map +1 -0
- package/dist/dts/state/persistence/session-persister.d.ts +6 -0
- package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
- package/dist/dts/state/persistence/session-snapshot.d.ts +16 -5
- package/dist/dts/state/persistence/session-snapshot.d.ts.map +1 -1
- package/dist/dts/state/test-interaction-context.d.ts +93 -0
- package/dist/dts/state/test-interaction-context.d.ts.map +1 -0
- package/dist/dts/types/ai-chat-widget.d.ts +7 -6
- package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
- package/dist/dts/types/interaction-context.d.ts +128 -17
- package/dist/dts/types/interaction-context.d.ts.map +1 -1
- package/dist/dts/types/interaction-interceptor.d.ts +48 -6
- package/dist/dts/types/interaction-interceptor.d.ts.map +1 -1
- package/dist/dts/types/interaction-surface.d.ts +145 -23
- package/dist/dts/types/interaction-surface.d.ts.map +1 -1
- package/dist/dts/utils/delegated-message.d.ts +7 -0
- package/dist/dts/utils/delegated-message.d.ts.map +1 -1
- package/dist/esm/autopilot/autopilot-driver.js +313 -60
- package/dist/esm/autopilot/autopilot-session.js +219 -40
- package/dist/esm/autopilot/autopilot-tools.js +11 -7
- package/dist/esm/autopilot/decision-message.js +105 -26
- package/dist/esm/autopilot/hand-back/hand-back.controller.js +2 -1
- package/dist/esm/autopilot/index.js +1 -0
- package/dist/esm/autopilot/widget-tools.js +39 -0
- package/dist/esm/components/agent-session/agent-session.js +3 -2
- package/dist/esm/components/ai-driver/base-driver-decorator.js +17 -0
- package/dist/esm/components/chat-driver/chat-driver.js +18 -2
- package/dist/esm/components/chat-driver/interaction-controller.js +232 -71
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +14 -6
- package/dist/esm/components/settings-modal/settings-modal.template.js +2 -2
- package/dist/esm/config/define-stateful-agent.js +22 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/main/main.js +88 -35
- package/dist/esm/main/main.template.js +4 -1
- package/dist/esm/notifications/agent-notifications.js +11 -1
- package/dist/esm/notifications/agent-notifier.js +41 -7
- package/dist/esm/state/debug-event-log.js +6 -6
- package/dist/esm/state/decision-surface.js +137 -54
- package/dist/esm/state/interaction-context.js +41 -8
- package/dist/esm/state/interaction-registry.js +11 -0
- package/dist/esm/state/live-interactions.js +36 -0
- package/dist/esm/state/persistence/session-persister.js +55 -18
- package/dist/esm/state/persistence/session-snapshot.js +2 -2
- package/dist/esm/state/test-interaction-context.js +99 -0
- package/docs/notifications.md +55 -5
- package/docs/styling.md +33 -0
- package/package.json +19 -19
- package/sandbox/README.md +3 -2
- package/sandbox/autopilot.ts +26 -6
- package/sandbox/sandbox.ts +2 -0
- /package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +0 -0
package/dist/ai-assistant.d.ts
CHANGED
|
@@ -75,10 +75,13 @@ export declare interface AgentAttentionDetail {
|
|
|
75
75
|
* - `'autopilot-handed-back'` — the autopilot handed something to the person.
|
|
76
76
|
* - `'autopilot-stopped'` — the autopilot stopped working: the flow ended, the turn ended with
|
|
77
77
|
* nothing left for it to answer, or it hit a wall such as the budget.
|
|
78
|
+
* - `'turn-ended'` — a turn ended and the assistant is waiting for the person to type (GENC-1660):
|
|
79
|
+
* nothing else waits on them (no open interaction), the person did not stop the turn, and no
|
|
80
|
+
* autopilot is running for the flow. Only the `'needs-input'` level shows it.
|
|
78
81
|
*
|
|
79
82
|
* @beta
|
|
80
83
|
*/
|
|
81
|
-
export declare type AgentAttentionKind = 'widget-needs-input' | 'autopilot-handed-back' | 'autopilot-stopped';
|
|
84
|
+
export declare type AgentAttentionKind = 'widget-needs-input' | 'autopilot-handed-back' | 'autopilot-stopped' | 'turn-ended';
|
|
82
85
|
|
|
83
86
|
/**
|
|
84
87
|
* Configuration for an agent passed to `FoundationAiAssistant`.
|
|
@@ -360,6 +363,16 @@ export declare interface AgenticActivityEvents {
|
|
|
360
363
|
* publishes it.
|
|
361
364
|
*/
|
|
362
365
|
'agent-attention': AgentAttentionDetail;
|
|
366
|
+
/**
|
|
367
|
+
* An interaction no longer waits on the person (GENC-1660): it settled, or a claimant (such as
|
|
368
|
+
* the autopilot, on Resume) took it. A notification shown for it is stale, so the assistant for
|
|
369
|
+
* that session closes it if it is still showing. Published for every interaction, whether a
|
|
370
|
+
* notification was shown or not. Tab-local, like `agent-attention`.
|
|
371
|
+
*/
|
|
372
|
+
'agent-attention-ended': {
|
|
373
|
+
sessionKey: string;
|
|
374
|
+
interactionId: string;
|
|
375
|
+
};
|
|
363
376
|
/**
|
|
364
377
|
* A session's agent notification settings may have changed (GENC-1676): the person's level, what
|
|
365
378
|
* the app offers, or which assistant on the page holds the session. A notification level picker
|
|
@@ -403,7 +416,8 @@ export declare interface AgentLifecycleContext {
|
|
|
403
416
|
* - `'autopilot'` — only when the autopilot hands back to the person or stops working. Offered
|
|
404
417
|
* only when the app sets `chatConfig.ui.notifications.autopilot`.
|
|
405
418
|
* - `'needs-input'` — every `'autopilot'` case, plus any widget that asks for the person's
|
|
406
|
-
* attention (`InteractionContext.requestAttention`)
|
|
419
|
+
* attention (`InteractionContext.requestAttention`), and every turn that ends with the assistant
|
|
420
|
+
* waiting for the person to type (GENC-1660).
|
|
407
421
|
*
|
|
408
422
|
* @beta
|
|
409
423
|
*/
|
|
@@ -560,8 +574,9 @@ export declare class AgentSession {
|
|
|
560
574
|
/**
|
|
561
575
|
* The name routing is locked to, flow lock first. A flow in progress outranks the user's
|
|
562
576
|
* sticky pick for the duration of the flow; neither being set means automatic routing.
|
|
577
|
+
* `pin`, when given, stands in for the sticky pick: one message routed its own way.
|
|
563
578
|
*/
|
|
564
|
-
getLockedName(): string | null;
|
|
579
|
+
getLockedName(pin?: string | null): string | null;
|
|
565
580
|
/** Set the sticky user pin. `null` returns to automatic routing. */
|
|
566
581
|
setPinned(name: string | null): void;
|
|
567
582
|
/**
|
|
@@ -754,11 +769,11 @@ export declare type AiAssistantState = 'idle' | 'loading' | 'cancelling' | 'erro
|
|
|
754
769
|
* a `shouldAutoFocus`, and a pending widget cannot be read for a `result`.
|
|
755
770
|
*
|
|
756
771
|
* The host sets the widget's `interaction` on mount and REPLACES it (pending →
|
|
757
|
-
* resolved) on completion.
|
|
772
|
+
* resolved) on completion. `TController` types the pending context's `controller` (GENC-1660).
|
|
758
773
|
*
|
|
759
774
|
* @beta
|
|
760
775
|
*/
|
|
761
|
-
export declare type AiChatInteraction<TData = unknown, TResult = unknown> = {
|
|
776
|
+
export declare type AiChatInteraction<TData = unknown, TResult = unknown, TController = unknown> = {
|
|
762
777
|
status: 'pending';
|
|
763
778
|
/** Immutable inputs for the interaction. */
|
|
764
779
|
data: TData;
|
|
@@ -769,9 +784,10 @@ export declare type AiChatInteraction<TData = unknown, TResult = unknown> = {
|
|
|
769
784
|
shouldAutoFocus: boolean;
|
|
770
785
|
/**
|
|
771
786
|
* Live, remount-surviving scratch for this interaction. Present ONLY while
|
|
772
|
-
* pending — the host disposes it on resolve. See {@link InteractionContext}.
|
|
787
|
+
* pending — the host disposes it on resolve. See {@link InteractionContext}. Its
|
|
788
|
+
* `controller` is typed `TController`, as the widget was registered.
|
|
773
789
|
*/
|
|
774
|
-
interactionContext: InteractionContext
|
|
790
|
+
interactionContext: InteractionContext<Record<string, unknown>, unknown, TController>;
|
|
775
791
|
} | {
|
|
776
792
|
status: 'resolved';
|
|
777
793
|
/** Same inputs — the resolved view still reads them. */
|
|
@@ -843,11 +859,11 @@ export declare class AiChatMarkdown extends GenesisElement {
|
|
|
843
859
|
*
|
|
844
860
|
* @beta
|
|
845
861
|
*/
|
|
846
|
-
export declare interface AiChatWidget<TData = unknown, TResult = unknown> {
|
|
862
|
+
export declare interface AiChatWidget<TData = unknown, TResult = unknown, TController = unknown> {
|
|
847
863
|
/** Stable per-interaction UUID; constant across remounts, present in both states. */
|
|
848
864
|
interactionId: string;
|
|
849
865
|
/** The current interaction state (pending or resolved). */
|
|
850
|
-
interaction: AiChatInteraction<TData, TResult>;
|
|
866
|
+
interaction: AiChatInteraction<TData, TResult, TController>;
|
|
851
867
|
}
|
|
852
868
|
|
|
853
869
|
/**
|
|
@@ -1061,19 +1077,36 @@ export declare interface AiDriver extends EventTarget {
|
|
|
1061
1077
|
*/
|
|
1062
1078
|
getFlowOwner?(): string | null;
|
|
1063
1079
|
/**
|
|
1064
|
-
*
|
|
1065
|
-
* yet
|
|
1080
|
+
* Every checkpoint to save with the session (GENC-1660 §4.12): those a reload cut that nothing
|
|
1081
|
+
* has taken over yet, oldest first, then the long action in flight's, if it has saved one.
|
|
1066
1082
|
*
|
|
1067
1083
|
* Optional, so a third-party driver need not implement it; every shipped driver does.
|
|
1068
1084
|
*
|
|
1069
1085
|
* @beta
|
|
1070
1086
|
*/
|
|
1087
|
+
getInteractionCheckpoints?(): readonly PersistedInteractionCheckpoint[];
|
|
1088
|
+
/**
|
|
1089
|
+
* Bring back the checkpoints saved with the session. Their interactions were cut by the reload,
|
|
1090
|
+
* so each waits for a request of its own widget type that the registration's `sameWork` agrees is
|
|
1091
|
+
* the same work: it is offered to every such request until one agrees, kept through refusals and
|
|
1092
|
+
* through checkpoints other interactions save meanwhile, and dropped when the flow ends. Replaces
|
|
1093
|
+
* whatever the driver held.
|
|
1094
|
+
*
|
|
1095
|
+
* @beta
|
|
1096
|
+
*/
|
|
1097
|
+
restoreInteractionCheckpoints?(saved: readonly PersistedInteractionCheckpoint[]): void;
|
|
1098
|
+
/**
|
|
1099
|
+
* One checkpoint to save: the long action in flight's, else the newest a reload cut.
|
|
1100
|
+
*
|
|
1101
|
+
* @deprecated Use {@link AiDriver.getInteractionCheckpoints}, which also returns the cut
|
|
1102
|
+
* checkpoints still waiting while another long action runs; this one loses them.
|
|
1103
|
+
* @beta
|
|
1104
|
+
*/
|
|
1071
1105
|
getInteractionCheckpoint?(): PersistedInteractionCheckpoint | undefined;
|
|
1072
1106
|
/**
|
|
1073
|
-
* Bring back
|
|
1074
|
-
* waits for the first request of the same widget type, which takes it over if the registration's
|
|
1075
|
-
* `sameWork` agrees; it is dropped when the flow ends.
|
|
1107
|
+
* Bring back one checkpoint, or none (which clears every checkpoint held).
|
|
1076
1108
|
*
|
|
1109
|
+
* @deprecated Use {@link AiDriver.restoreInteractionCheckpoints}.
|
|
1077
1110
|
* @beta
|
|
1078
1111
|
*/
|
|
1079
1112
|
restoreInteractionCheckpoint?(saved: PersistedInteractionCheckpoint | undefined): void;
|
|
@@ -1264,11 +1297,13 @@ export declare interface AiDriverEventMap {
|
|
|
1264
1297
|
/**
|
|
1265
1298
|
* An interaction settled, by whatever route — a widget, a controller's `ctx.resolve`, a claimant,
|
|
1266
1299
|
* a timeout (GENC-1660). Detail: its id, and `answeredBy` when someone answered it (absent for a
|
|
1267
|
-
* timeout or a stop)
|
|
1300
|
+
* timeout or a stop); `resolvedItself` in its place when a widget registered `resolvesItself`
|
|
1301
|
+
* settled on its own, which nobody answered but after which the turn carries on.
|
|
1268
1302
|
*/
|
|
1269
1303
|
'interaction-settled': CustomEvent<{
|
|
1270
1304
|
interactionId: string;
|
|
1271
1305
|
answeredBy?: string;
|
|
1306
|
+
resolvedItself?: boolean;
|
|
1272
1307
|
}>;
|
|
1273
1308
|
/** Spend was recorded against an already-resolved interaction. */
|
|
1274
1309
|
'external-cost-recorded': CustomEvent<{
|
|
@@ -1623,6 +1658,19 @@ export declare interface AutopilotConfig<S = unknown> {
|
|
|
1623
1658
|
definitions: ChatToolDefinition[];
|
|
1624
1659
|
handlers: ChatToolHandlers;
|
|
1625
1660
|
};
|
|
1661
|
+
/**
|
|
1662
|
+
* Tools that read from one widget type while it is open, built with `widgetTools`: reads with
|
|
1663
|
+
* parameters, which a surface's views cannot take (one table's rows, a page of them). Declared
|
|
1664
|
+
* here, never discovered from registrations, so the tool list is fixed when the autopilot's
|
|
1665
|
+
* session starts — the fixed three, `tools` and these, sorted by name — and every decision sends
|
|
1666
|
+
* the same one, which keeps the cache. Each call is routed to the interaction of its widget type
|
|
1667
|
+
* being decided, and refused with a reason when none is; while one is open, the platform puts a
|
|
1668
|
+
* line naming its tools in front of the tail. Reads only.
|
|
1669
|
+
*
|
|
1670
|
+
* Every tool name must be unique across these, `tools` and the fixed three: `defineAutopilot`
|
|
1671
|
+
* throws otherwise.
|
|
1672
|
+
*/
|
|
1673
|
+
widgetTools?: WidgetTools[];
|
|
1626
1674
|
/**
|
|
1627
1675
|
* How the working agent is told a decision was made for the user, e.g. "Decided on the user's
|
|
1628
1676
|
* behalf, from their brief". Must not name the autopilot.
|
|
@@ -1640,10 +1688,14 @@ export declare interface AutopilotConfig<S = unknown> {
|
|
|
1640
1688
|
/** Model calls per decision before it is handed back; `> 0`, or the default is used. Default 6. */
|
|
1641
1689
|
maxIterationsPerDecision?: number;
|
|
1642
1690
|
/**
|
|
1643
|
-
*
|
|
1644
|
-
* cannot loop with the working agent re-proposing it.
|
|
1645
|
-
*
|
|
1646
|
-
*
|
|
1691
|
+
* Refinements allowed per step before every refining action is withdrawn, so refining a proposal
|
|
1692
|
+
* cannot loop with the working agent re-proposing it. A refinement is a written answer (`reply`)
|
|
1693
|
+
* or a full-form action declared `refines` (a regenerate with instructions), counted together.
|
|
1694
|
+
* `>= 0` (0 never offers one), or the default is used. Default 2. Enforced by the platform, not
|
|
1695
|
+
* asked of the model: past the limit it can only accept or hand back. Counted the moment one is
|
|
1696
|
+
* taken, so a refining action that does not settle cannot be repeated past it within a decision.
|
|
1697
|
+
* The decision tells the model how many are left (`Refinements left at this step: N`) wherever the
|
|
1698
|
+
* widget has a refining action, so a widget's own summary need not count them.
|
|
1647
1699
|
*/
|
|
1648
1700
|
maxRefinements?: number;
|
|
1649
1701
|
/**
|
|
@@ -1662,8 +1714,8 @@ export declare interface AutopilotConfig<S = unknown> {
|
|
|
1662
1714
|
maxDecisionCostUsd?: number;
|
|
1663
1715
|
/**
|
|
1664
1716
|
* How long the autopilot's work on a claimed interaction may go quiet before it is handed back,
|
|
1665
|
-
* in ms; `> 0`, or the default is used. Quiet means either no ready surface
|
|
1666
|
-
* (`ctx.notify()`), or a decision of its own still running with no model call landing and no
|
|
1717
|
+
* in ms; `> 0`, or the default is used. Quiet means either no ready surface (no decision due,
|
|
1718
|
+
* 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
|
|
1667
1719
|
* heartbeat — a stalled model call, which has no timeout of its own. A decision handed back this
|
|
1668
1720
|
* way is stopped. Must outlast the slowest honest wait, such as a compile. Default 10 minutes.
|
|
1669
1721
|
*/
|
|
@@ -1690,6 +1742,13 @@ export declare interface AutopilotCopy {
|
|
|
1690
1742
|
paused: string;
|
|
1691
1743
|
/** While the autopilot waits on one answer it handed back. */
|
|
1692
1744
|
selfPaused: string;
|
|
1745
|
+
/**
|
|
1746
|
+
* The slim bar's status while running but waiting on the person for a question the autopilot
|
|
1747
|
+
* never took — one its `widgetPolicy` keeps for them, one that is `userOnly`, or one with no
|
|
1748
|
+
* controller to act through — e.g. "Waiting for your answer". Not a hand-back, which is
|
|
1749
|
+
* `selfPaused`: nothing pauses, and the autopilot carries on by itself once they answer.
|
|
1750
|
+
*/
|
|
1751
|
+
waitingForUser: string;
|
|
1693
1752
|
/** In front of a hand-back reason, in the widget's banner, e.g. "I need your input on this one:". */
|
|
1694
1753
|
handBackLead: string;
|
|
1695
1754
|
/** The toggle pill's label and its accessible name, e.g. "Autopilot". */
|
|
@@ -1768,7 +1827,18 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
|
|
|
1768
1827
|
private mode;
|
|
1769
1828
|
private pauseState?;
|
|
1770
1829
|
private held?;
|
|
1771
|
-
/**
|
|
1830
|
+
/**
|
|
1831
|
+
* The interaction open right now, whoever holds it: claimed or not, it was offered here first.
|
|
1832
|
+
* `held` covers only what the autopilot claimed, so this is how the status knows that the working
|
|
1833
|
+
* agent is parked on a question left with the person (see `waitingOnUser`).
|
|
1834
|
+
*/
|
|
1835
|
+
private open?;
|
|
1836
|
+
/**
|
|
1837
|
+
* The open interaction, when the autopilot declined it only for being paused as it opened: a live
|
|
1838
|
+
* Resume may still take it (see `takeOpenOnResume`). Cleared when it is taken or settles.
|
|
1839
|
+
*/
|
|
1840
|
+
private declinedWhilePaused?;
|
|
1841
|
+
/** Refining actions taken on the current step (written answers among them), for the limit. */
|
|
1772
1842
|
private refinements?;
|
|
1773
1843
|
/** The watchdog's next check, while a claimed interaction is pending. */
|
|
1774
1844
|
private watchdog?;
|
|
@@ -1798,8 +1868,23 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
|
|
|
1798
1868
|
private ranSinceStop;
|
|
1799
1869
|
/** The check that confirms the autopilot stopped, once it looked like it had. */
|
|
1800
1870
|
private stopCheck?;
|
|
1871
|
+
/** Stops each wait for a widget left with the person to ask them; see `reportHandBackWhenAsking`. */
|
|
1872
|
+
private readonly handBackWaits;
|
|
1801
1873
|
constructor(inner: AiDriver, options: AutopilotDriverOptions);
|
|
1802
1874
|
get state(): AutopilotHostState;
|
|
1875
|
+
/**
|
|
1876
|
+
* Whether the working agent is parked on a question the person holds, with the autopilot deciding
|
|
1877
|
+
* nothing: one it never took — its policy keeps it for the person, it is `userOnly` (the turn-level
|
|
1878
|
+
* hand-back among them), it has no controller, or it opened while paused and no Resume has taken
|
|
1879
|
+
* it since (a restored mode takes nothing) — or one another interceptor took and then gave to the
|
|
1880
|
+
* person. One the autopilot handed back reads `selfPaused`, and one a pause handed over reads
|
|
1881
|
+
* `paused`; `state` settles both before asking this.
|
|
1882
|
+
*
|
|
1883
|
+
* Never one that asks them nothing (see `asksThePerson`): the person holds it, but it is work
|
|
1884
|
+
* running, which settles by itself, so "waiting for your answer" would be untrue. A hand-back is
|
|
1885
|
+
* reported by the same rule (see `reportHandBackWhenAsking`).
|
|
1886
|
+
*/
|
|
1887
|
+
private waitingOnUser;
|
|
1803
1888
|
get copy(): AutopilotCopy;
|
|
1804
1889
|
subscribe(listener: () => void): () => void;
|
|
1805
1890
|
pause(): void;
|
|
@@ -1837,9 +1922,9 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
|
|
|
1837
1922
|
*
|
|
1838
1923
|
* Sent only if the question still stands when the answer lands: no pause or resume since it was
|
|
1839
1924
|
* asked (Pause stops it, and the question is the person's to answer by typing), the flow still
|
|
1840
|
-
* running, the working agent idle, and the question still
|
|
1841
|
-
* answer goes nowhere — not sent, not counted, not recorded
|
|
1842
|
-
* dropped, as it is whenever no reply is sent to carry it.
|
|
1925
|
+
* running and the autopilot still available to it, the working agent idle, and the question still
|
|
1926
|
+
* the last thing it said. Otherwise the answer goes nowhere — not sent, not counted, not recorded
|
|
1927
|
+
* as acted — and its cost is recorded as dropped, as it is whenever no reply is sent to carry it.
|
|
1843
1928
|
*/
|
|
1844
1929
|
private answer;
|
|
1845
1930
|
/**
|
|
@@ -1867,14 +1952,69 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
|
|
|
1867
1952
|
private endSessions;
|
|
1868
1953
|
dispose(): Promise<void>;
|
|
1869
1954
|
private onInteractionOpened;
|
|
1955
|
+
private decline;
|
|
1956
|
+
/**
|
|
1957
|
+
* Report a widget the autopilot declined, and so left with the person, as a hand-back (GENC-1660)
|
|
1958
|
+
* — but only once it waits on them: by the rule the status reads (`asksThePerson`), or because the
|
|
1959
|
+
* widget asked for their attention. Then only if it still does, and is still theirs, after
|
|
1960
|
+
* `HAND_BACK_GRACE_MS`, so one that settles itself as it mounts never reports. One that is working
|
|
1961
|
+
* reports when it starts asking, with the message it asked with. One that settles first, or that
|
|
1962
|
+
* another interceptor claims first, never reports: that claimant reports its own hand-back.
|
|
1963
|
+
*
|
|
1964
|
+
* The report is the interaction's one notification. The widget's own request is taken over
|
|
1965
|
+
* (`hold.takeAttention`), so it is not reported as well, before or after: it only counts as the
|
|
1966
|
+
* widget asking. When its request has already counted — reported while the person held it, before
|
|
1967
|
+
* a decline on Resume — the person was told then, so nothing more is reported.
|
|
1968
|
+
*/
|
|
1969
|
+
private reportHandBackWhenAsking;
|
|
1970
|
+
/**
|
|
1971
|
+
* Whether the autopilot running for `owner` may take `opened`: the agent that answers for it, or
|
|
1972
|
+
* why not, as `autopilot.declined` records it. The mode is the caller's to check — the open path
|
|
1973
|
+
* asks this only while running, and a live Resume only for what opened while paused — so both ask
|
|
1974
|
+
* the same questions in the same order.
|
|
1975
|
+
*/
|
|
1976
|
+
private eligibility;
|
|
1977
|
+
/**
|
|
1978
|
+
* Hold an interaction the autopilot claimed, watch it, and decide it once its surface is ready.
|
|
1979
|
+
* `deferred` when the claim is granted only after the caller returns (the open path), so the
|
|
1980
|
+
* decision waits a microtask for it; a late claim through `hold.claim` is granted already.
|
|
1981
|
+
*
|
|
1982
|
+
* The decision starts only if the autopilot still holds it then, with no pause or resume in
|
|
1983
|
+
* between: a pause hands it over, and the Resume after that decides it itself.
|
|
1984
|
+
*/
|
|
1985
|
+
private take;
|
|
1986
|
+
/**
|
|
1987
|
+
* Decide `held` once a decision is due on it (`onSurfaceReady`): at once if one is, or when its
|
|
1988
|
+
* controller next makes one due — exposes a surface, enables an action, or says it is asking.
|
|
1989
|
+
* Only if, by then, the autopilot still holds it with no pause or resume in between: a pause hands
|
|
1990
|
+
* it over, and the Resume after that decides it itself.
|
|
1991
|
+
*/
|
|
1992
|
+
private decideWhenReady;
|
|
1993
|
+
/**
|
|
1994
|
+
* On a live Resume: take the open interaction if it was declined only because the autopilot was
|
|
1995
|
+
* paused when it opened, and would be claimed if it opened now — the same checks as the open
|
|
1996
|
+
* path. Returns whether it took it. A person may have started on it; it is taken as it stands, as
|
|
1997
|
+
* Resume takes back one a pause handed over, and the autopilot reads it as it now is.
|
|
1998
|
+
*/
|
|
1999
|
+
private takeOpenOnResume;
|
|
2000
|
+
/**
|
|
2001
|
+
* Follow every interaction while it is open, claimed or not, so the status can say when the
|
|
2002
|
+
* person is the one being waited on (see `waitingOnUser`), and tell the host each time that
|
|
2003
|
+
* changes: when it opens, when it moves between holders, and when it settles.
|
|
2004
|
+
*/
|
|
2005
|
+
private trackOpen;
|
|
1870
2006
|
/** Run one decision on the flow's session, and act on how it ended. */
|
|
1871
2007
|
private decide;
|
|
1872
2008
|
/** The step a decision belongs to, for the refinement limit (§4.4). */
|
|
1873
2009
|
private stepKey;
|
|
1874
|
-
/**
|
|
1875
|
-
|
|
2010
|
+
/**
|
|
2011
|
+
* How many refining actions (written answers, and full-form actions declared `refines`) are left
|
|
2012
|
+
* on this step: none left withdraws them all. Read fresh, so a refinement taken mid-decision (a
|
|
2013
|
+
* `refines` action that does not settle) counts at once. The count resets when the step changes.
|
|
2014
|
+
*/
|
|
2015
|
+
private refinementsLeft;
|
|
1876
2016
|
private countRefinement;
|
|
1877
|
-
/**
|
|
2017
|
+
/** Refinements allowed per step: the config's when it is a whole number `>= 0`. */
|
|
1878
2018
|
private refinementLimit;
|
|
1879
2019
|
/**
|
|
1880
2020
|
* The watchdog (§4.2, critique S5): a claimed interaction whose work has gone quiet for longer
|
|
@@ -1909,7 +2049,10 @@ export declare class AutopilotDriver extends BaseDriverDecorator implements Auto
|
|
|
1909
2049
|
private copyFor;
|
|
1910
2050
|
private sessionFor;
|
|
1911
2051
|
private record;
|
|
1912
|
-
/**
|
|
2052
|
+
/**
|
|
2053
|
+
* Report that something needs the person, for the assistant to notify them (GENC-1676), with the
|
|
2054
|
+
* widget's own message when it gave one (GENC-1660).
|
|
2055
|
+
*/
|
|
1913
2056
|
private attention;
|
|
1914
2057
|
/**
|
|
1915
2058
|
* Report the autopilot stopping work on its own (GENC-1676): after running and working, nothing
|
|
@@ -1953,7 +2096,7 @@ export declare interface AutopilotDriverOptions {
|
|
|
1953
2096
|
*/
|
|
1954
2097
|
export declare class AutopilotHandBack extends GenesisElement {
|
|
1955
2098
|
interactionId: string;
|
|
1956
|
-
interaction?: AiChatInteraction<HandBackData, HandBackResult['payload']>;
|
|
2099
|
+
interaction?: AiChatInteraction<HandBackData, HandBackResult['payload'], HandBackController>;
|
|
1957
2100
|
draft: string;
|
|
1958
2101
|
get data(): HandBackData | undefined;
|
|
1959
2102
|
/** What was chosen, once resolved. */
|
|
@@ -1977,7 +2120,8 @@ export declare interface AutopilotHost {
|
|
|
1977
2120
|
pause(): void;
|
|
1978
2121
|
/**
|
|
1979
2122
|
* Resume. Takes back an interaction that pausing handed over; during the autopilot's own
|
|
1980
|
-
* hand-back it means "decide it yourself".
|
|
2123
|
+
* hand-back it means "decide it yourself". Takes an interaction that opened while paused and is
|
|
2124
|
+
* still open, when it would have claimed it had it been running then.
|
|
1981
2125
|
*/
|
|
1982
2126
|
resume(): void;
|
|
1983
2127
|
/** The existing Stop, which also pauses, so what is shown stays honest. */
|
|
@@ -2003,9 +2147,16 @@ export declare interface AutopilotHostState {
|
|
|
2003
2147
|
readonly interactionId?: string;
|
|
2004
2148
|
readonly reason?: string;
|
|
2005
2149
|
};
|
|
2006
|
-
/**
|
|
2150
|
+
/**
|
|
2151
|
+
* The slim bar's one-line status, from `AutopilotCopy`: `running`, or `waitingForUser` while the
|
|
2152
|
+
* working agent waits on a question the autopilot left with the person; `selfPaused` while it
|
|
2153
|
+
* waits on one it handed back; `paused` otherwise.
|
|
2154
|
+
*/
|
|
2007
2155
|
readonly status: string;
|
|
2008
|
-
/**
|
|
2156
|
+
/**
|
|
2157
|
+
* Whether the autopilot stopped and needs the person — its own hand-back of a widget or of a
|
|
2158
|
+
* turn: drives the "needs you" badge. Not set for a question it never took (see `status`).
|
|
2159
|
+
*/
|
|
2009
2160
|
readonly needsUser: boolean;
|
|
2010
2161
|
/**
|
|
2011
2162
|
* Whether something is happening: the working agent is busy, or the autopilot is deciding (a
|
|
@@ -2387,6 +2538,8 @@ export declare abstract class BaseDriverDecorator<TInner extends AiDriver = AiDr
|
|
|
2387
2538
|
setPinnedAgent(name: string | null): void;
|
|
2388
2539
|
setFlowOwner(name: string | null): void;
|
|
2389
2540
|
getFlowOwner(): string | null;
|
|
2541
|
+
getInteractionCheckpoints(): readonly PersistedInteractionCheckpoint[];
|
|
2542
|
+
restoreInteractionCheckpoints(saved: readonly PersistedInteractionCheckpoint[]): void;
|
|
2390
2543
|
getInteractionCheckpoint(): PersistedInteractionCheckpoint | undefined;
|
|
2391
2544
|
restoreInteractionCheckpoint(saved: PersistedInteractionCheckpoint | undefined): void;
|
|
2392
2545
|
/**
|
|
@@ -3546,9 +3699,21 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
3546
3699
|
* host) to build the widget's pending `interaction` descriptor.
|
|
3547
3700
|
*/
|
|
3548
3701
|
getInteractionContext(interactionId: string): InteractionContext | undefined;
|
|
3549
|
-
/** {@inheritDoc AiDriver.
|
|
3702
|
+
/** {@inheritDoc AiDriver.getInteractionCheckpoints} */
|
|
3703
|
+
getInteractionCheckpoints(): readonly PersistedInteractionCheckpoint[];
|
|
3704
|
+
/** {@inheritDoc AiDriver.restoreInteractionCheckpoints} */
|
|
3705
|
+
restoreInteractionCheckpoints(saved: readonly PersistedInteractionCheckpoint[]): void;
|
|
3706
|
+
/**
|
|
3707
|
+
* {@inheritDoc AiDriver.getInteractionCheckpoint}
|
|
3708
|
+
*
|
|
3709
|
+
* @deprecated Use `getInteractionCheckpoints`.
|
|
3710
|
+
*/
|
|
3550
3711
|
getInteractionCheckpoint(): PersistedInteractionCheckpoint | undefined;
|
|
3551
|
-
/**
|
|
3712
|
+
/**
|
|
3713
|
+
* {@inheritDoc AiDriver.restoreInteractionCheckpoint}
|
|
3714
|
+
*
|
|
3715
|
+
* @deprecated Use `restoreInteractionCheckpoints`.
|
|
3716
|
+
*/
|
|
3552
3717
|
restoreInteractionCheckpoint(saved: PersistedInteractionCheckpoint | undefined): void;
|
|
3553
3718
|
/**
|
|
3554
3719
|
* Replace the history message owning `interactionId`. `false` when it is no longer in history.
|
|
@@ -3932,6 +4097,50 @@ export declare interface ContinueFromHistoryOptions {
|
|
|
3932
4097
|
tailNote?: string;
|
|
3933
4098
|
}
|
|
3934
4099
|
|
|
4100
|
+
/**
|
|
4101
|
+
* What a widget controller needs from whatever hosts it (GENC-1660): the slice of
|
|
4102
|
+
* {@link InteractionContext} a controller uses, so it can be built and tested without the rest. An
|
|
4103
|
+
* `InteractionContext` is one, so a registration passes its `ctx` straight through:
|
|
4104
|
+
*
|
|
4105
|
+
* ```ts
|
|
4106
|
+
* class ReviewController {
|
|
4107
|
+
* constructor(data: ReviewData, private readonly host: ControllerHost<ReviewResult>) {
|
|
4108
|
+
* host.exposeSurface?.({ … });
|
|
4109
|
+
* }
|
|
4110
|
+
* }
|
|
4111
|
+
* registerInteraction<ReviewController>('review', {
|
|
4112
|
+
* controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),
|
|
4113
|
+
* });
|
|
4114
|
+
* ```
|
|
4115
|
+
*
|
|
4116
|
+
* `heldBy`, `exposeDecision` and `exposeSurface` are optional so a view can build the same
|
|
4117
|
+
* controller over a stand-in host for a card with no live context (a resolved one in the
|
|
4118
|
+
* transcript, a gallery): nobody can claim it, so it has nothing to expose and only the person
|
|
4119
|
+
* holds it. Read an absent `heldBy` as `'user'`.
|
|
4120
|
+
*
|
|
4121
|
+
* `TResult` is the payload type the controller resolves with; `TState` what it keeps on `state`.
|
|
4122
|
+
*
|
|
4123
|
+
* @beta
|
|
4124
|
+
*/
|
|
4125
|
+
export declare interface ControllerHost<TResult = unknown, TState extends object = object> {
|
|
4126
|
+
/** Survives a remount; where a controller keeps anything the person has started. */
|
|
4127
|
+
readonly state: TState;
|
|
4128
|
+
/** Settle the interaction. See {@link InteractionContext.resolve}. */
|
|
4129
|
+
resolve(result: InteractionResult<TResult>, options?: InteractionResolveOptions): void;
|
|
4130
|
+
/** Something in the controller's state or view model changed. See {@link InteractionContext.notify}. */
|
|
4131
|
+
notify(): void;
|
|
4132
|
+
/** Who holds the interaction right now: `'user'`, or the claimant's id. Absent means the person. */
|
|
4133
|
+
readonly heldBy?: InteractionHolder;
|
|
4134
|
+
/** See {@link InteractionContext.exposeDecision}. Absent on a stand-in host. */
|
|
4135
|
+
exposeDecision?(decision: DecisionSpec): void;
|
|
4136
|
+
/** See {@link InteractionContext.exposeSurface}. Absent on a stand-in host. */
|
|
4137
|
+
exposeSurface?(surface: SurfaceSpec): void;
|
|
4138
|
+
/** See {@link InteractionContext.setWorking}. Absent on a stand-in host. */
|
|
4139
|
+
setWorking?(working: boolean): void;
|
|
4140
|
+
/** See {@link InteractionContext.requestAttention}. Absent on a stand-in host. */
|
|
4141
|
+
requestAttention?(message?: string): void;
|
|
4142
|
+
}
|
|
4143
|
+
|
|
3935
4144
|
/** A model used during a recorded cost session. */
|
|
3936
4145
|
export declare interface CostSessionModelEntry {
|
|
3937
4146
|
model: string;
|
|
@@ -3987,6 +4196,36 @@ export declare interface CostSessionRecord {
|
|
|
3987
4196
|
models: CostSessionModelEntry[];
|
|
3988
4197
|
}
|
|
3989
4198
|
|
|
4199
|
+
/**
|
|
4200
|
+
* Build a real interaction context for a controller test (GENC-1660), so the test exercises the
|
|
4201
|
+
* platform's own context — its `state`, `once`, `notify`, surfaces and their checks — rather than a
|
|
4202
|
+
* hand-built fake that can drift from it. Nothing renders, nothing is persisted, and no driver is
|
|
4203
|
+
* involved: resolving records the result, and the interaction is disposed as it would be.
|
|
4204
|
+
*
|
|
4205
|
+
* @example
|
|
4206
|
+
* ```ts
|
|
4207
|
+
* const t = createTestInteractionContext<ReviewController, ReviewResult>({
|
|
4208
|
+
* data: { round: 1 },
|
|
4209
|
+
* controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),
|
|
4210
|
+
* });
|
|
4211
|
+
* t.setHeldBy('autopilot');
|
|
4212
|
+
* await t.act('regenerate', { text: 'amounts in EUR' });
|
|
4213
|
+
* assert.equal(t.result?.payload, { action: 'regenerate', instructions: 'amounts in EUR' });
|
|
4214
|
+
* ```
|
|
4215
|
+
*
|
|
4216
|
+
* @beta
|
|
4217
|
+
*/
|
|
4218
|
+
export declare function createTestInteractionContext<TController = unknown, TResult = unknown>(options?: {
|
|
4219
|
+
/** Defaults to `'test-interaction'`. */
|
|
4220
|
+
readonly interactionId?: string;
|
|
4221
|
+
/** The `data` handed to `controller`. */
|
|
4222
|
+
readonly data?: unknown;
|
|
4223
|
+
/** Build the controller as the platform would, and install it as `context.controller`. */
|
|
4224
|
+
readonly controller?: InteractionControllerFactory<TController>;
|
|
4225
|
+
/** A checkpoint the platform handed over, as after a reload (`ctx.checkpoint`). */
|
|
4226
|
+
readonly checkpoint?: unknown;
|
|
4227
|
+
}): TestInteractionContext<TController, TResult>;
|
|
4228
|
+
|
|
3990
4229
|
/**
|
|
3991
4230
|
* Creates a tool fold — a facade that hides a group of related tools behind a single
|
|
3992
4231
|
* named entry, revealing them progressively when the model invokes the facade.
|
|
@@ -4117,10 +4356,12 @@ export declare type DecisionOption = string | {
|
|
|
4117
4356
|
/** The option's text, as the person sees it. */
|
|
4118
4357
|
readonly label: string;
|
|
4119
4358
|
/**
|
|
4120
|
-
*
|
|
4121
|
-
*
|
|
4359
|
+
* Why it cannot be chosen right now, or `undefined` when it can — the button's own guard (e.g.
|
|
4360
|
+
* "2 validation errors" for a Continue that needs a validated handler). Read fresh every time.
|
|
4361
|
+
* An unavailable option is listed with its reason and refused with it. Absent means always
|
|
4362
|
+
* available; an empty string or a throw counts as unavailable, with a generic reason.
|
|
4122
4363
|
*/
|
|
4123
|
-
readonly
|
|
4364
|
+
readonly unavailable?: () => string | undefined;
|
|
4124
4365
|
};
|
|
4125
4366
|
|
|
4126
4367
|
/**
|
|
@@ -4133,13 +4374,47 @@ export declare interface DecisionSpec {
|
|
|
4133
4374
|
readonly options: readonly DecisionOption[];
|
|
4134
4375
|
/** Adds a `select({ options })` action that picks several. */
|
|
4135
4376
|
readonly multi?: boolean;
|
|
4136
|
-
/**
|
|
4377
|
+
/**
|
|
4378
|
+
* Adds a `reply({ text })` action: an answer in the chooser's own words. It refines, so it counts
|
|
4379
|
+
* against the autopilot's per-step refinement limit and is withdrawn past it.
|
|
4380
|
+
*/
|
|
4137
4381
|
readonly freeText?: boolean;
|
|
4382
|
+
/**
|
|
4383
|
+
* Why the `reply` action cannot be used right now, or `undefined` when it can: the same guard
|
|
4384
|
+
* pattern as an option's {@link DecisionOption} `unavailable`, read fresh. For a widget whose
|
|
4385
|
+
* written answer only makes sense in some states (a review gate that failed, say, where only
|
|
4386
|
+
* handing back is left). Ignored without `freeText`.
|
|
4387
|
+
*/
|
|
4388
|
+
readonly freeTextUnavailable?: () => string | undefined;
|
|
4138
4389
|
/**
|
|
4139
4390
|
* What a decision needs that the person sees on screen in some other form — e.g.
|
|
4140
4391
|
* `{ validated: true }`. A getter, so it is read fresh whenever the decision is described.
|
|
4141
4392
|
*/
|
|
4142
4393
|
readonly facts?: () => Readonly<Record<string, unknown>>;
|
|
4394
|
+
/**
|
|
4395
|
+
* Named views a claimant may read on demand: content too long to send with every decision but
|
|
4396
|
+
* sometimes needed to make it. Each is listed in the decision with its description, and read with
|
|
4397
|
+
* `widget_read({ view })`; a view not listed here is refused. `widget_read()` with no view still
|
|
4398
|
+
* reads the decision's `facts`.
|
|
4399
|
+
*
|
|
4400
|
+
* The same shape as the full form's {@link SurfaceSpec.views}, so a widget can offer something
|
|
4401
|
+
* to read and keep the short form's generated options.
|
|
4402
|
+
*
|
|
4403
|
+
* @example
|
|
4404
|
+
* ```ts
|
|
4405
|
+
* ctx.exposeDecision({
|
|
4406
|
+
* options: ['Yes, add one', 'No, skip this step'],
|
|
4407
|
+
* choose,
|
|
4408
|
+
* views: {
|
|
4409
|
+
* moreInfo: {
|
|
4410
|
+
* description: 'The "More info" explainer the person can open on the card.',
|
|
4411
|
+
* read: () => data.moreInfo,
|
|
4412
|
+
* },
|
|
4413
|
+
* },
|
|
4414
|
+
* });
|
|
4415
|
+
* ```
|
|
4416
|
+
*/
|
|
4417
|
+
readonly views?: Readonly<Record<string, SurfaceView>>;
|
|
4143
4418
|
/**
|
|
4144
4419
|
* Model-only guidance the person would not see. The decision's own text comes from the
|
|
4145
4420
|
* widget's `asText`, which is what the person saw.
|
|
@@ -4206,12 +4481,16 @@ export declare function defineAgent<const T extends AgentConfig>(config: T): T;
|
|
|
4206
4481
|
* …,
|
|
4207
4482
|
* autopilot: defineAutopilot<BootstrapState>({
|
|
4208
4483
|
* availableWhen: ({ state }) => briefApproved(state.machine),
|
|
4209
|
-
* widgetPolicy: { 'planning-question': 'allowed' },
|
|
4484
|
+
* widgetPolicy: { 'planning-question': 'allowed', 'sample-data-review': 'allowed' },
|
|
4485
|
+
* widgetTools: [SAMPLE_DATA_TOOLS],
|
|
4210
4486
|
* systemPrompt: ({ state }) => `${AUTOPILOT_BASE}\n<brief>${frozenBrief(state)}</brief>`,
|
|
4211
4487
|
* }),
|
|
4212
4488
|
* });
|
|
4213
4489
|
* ```
|
|
4214
4490
|
*
|
|
4491
|
+
* Throws if two of its tools share a name — its widget tools, its own `tools` and the platform's
|
|
4492
|
+
* fixed three — since one would silently shadow the other.
|
|
4493
|
+
*
|
|
4215
4494
|
* @beta
|
|
4216
4495
|
*/
|
|
4217
4496
|
export declare function defineAutopilot<S = unknown>(config: AutopilotConfig<S>): AutopilotConfig<S>;
|
|
@@ -5065,7 +5344,8 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
5065
5344
|
/**
|
|
5066
5345
|
* Name of the agent the user has pinned via the agent picker. `null` means
|
|
5067
5346
|
* orchestration: the assistant routes each message. Persisted on the session store, so it survives
|
|
5068
|
-
* pop-in/pop-out
|
|
5347
|
+
* pop-in/pop-out. A page refresh resets it unless session persistence is on, which saves it with
|
|
5348
|
+
* the session and restores it.
|
|
5069
5349
|
*
|
|
5070
5350
|
* Only changes on explicit user action (picker click or host's `setAgent`).
|
|
5071
5351
|
* The orchestrator's auto-pin on stateful activation writes
|
|
@@ -6405,30 +6685,30 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
6405
6685
|
handleStopClick(): void;
|
|
6406
6686
|
handleSuggestionClick(suggestion: string): void;
|
|
6407
6687
|
/**
|
|
6408
|
-
* Programmatically submit a message.
|
|
6409
|
-
*
|
|
6410
|
-
*
|
|
6411
|
-
*
|
|
6688
|
+
* Programmatically submit a message. Sends it the way the built-in composer's
|
|
6689
|
+
* Send does, but from external code — a custom input rendered inside
|
|
6690
|
+
* `slot="splash"` when paired with `chatConfig.ui.hideComposer`, or a host
|
|
6691
|
+
* sending on the user's behalf.
|
|
6412
6692
|
*
|
|
6413
|
-
* The input fully describes the turn: `text` and `files`
|
|
6414
|
-
* composer
|
|
6693
|
+
* The input fully describes the turn: `text` and `files` are sent as given,
|
|
6694
|
+
* and the composer is never read or cleared, so whatever the user has typed or
|
|
6695
|
+
* attached there stays where it is. Files are validated against
|
|
6415
6696
|
* `chatConfig.ui.acceptedFiles` using the same pipeline as the composer's
|
|
6416
|
-
* attach button.
|
|
6697
|
+
* attach button. `options` routes the message — see {@link SubmitMessageOptions}.
|
|
6417
6698
|
*
|
|
6418
|
-
* Atomic on validation: if any file fails validation, no
|
|
6419
|
-
*
|
|
6420
|
-
*
|
|
6421
|
-
* chip UI still surfaces them when visible.
|
|
6699
|
+
* Atomic on validation: if any file fails validation, no send is dispatched,
|
|
6700
|
+
* and the failure messages are returned in `errors`. They are not shown as
|
|
6701
|
+
* composer chips: the files are the caller's, not the user's.
|
|
6422
6702
|
*
|
|
6423
|
-
* Resolves
|
|
6424
|
-
* the assistant's response.
|
|
6703
|
+
* Resolves when the send settles: it awaits the driver's `sendMessage`, which
|
|
6704
|
+
* for the built-in drivers is the whole turn, the assistant's response included.
|
|
6425
6705
|
*
|
|
6426
6706
|
* @beta
|
|
6427
6707
|
*/
|
|
6428
6708
|
submitMessage(input: {
|
|
6429
6709
|
text?: string;
|
|
6430
6710
|
files?: File[];
|
|
6431
|
-
}): Promise<SubmitMessageResult>;
|
|
6711
|
+
}, options?: SubmitMessageOptions): Promise<SubmitMessageResult>;
|
|
6432
6712
|
private fetchSuggestions;
|
|
6433
6713
|
/**
|
|
6434
6714
|
* User text of the message currently being sent, stashed for the lifetime of `send()`.
|
|
@@ -6437,12 +6717,28 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
6437
6717
|
* a stale raw-history lookup. Cleared once the send settles. (GENC-1351 §5.9)
|
|
6438
6718
|
*/
|
|
6439
6719
|
private _pendingSendPrompt?;
|
|
6720
|
+
/**
|
|
6721
|
+
* @param message - What to send in place of the composer's contents, which are then neither
|
|
6722
|
+
* read nor cleared (`submitMessage`). Left out, the composer's contents are sent and cleared.
|
|
6723
|
+
* @param routing - Passed on to the driver: how this one message is routed.
|
|
6724
|
+
*/
|
|
6440
6725
|
private send;
|
|
6441
6726
|
/**
|
|
6442
6727
|
* The post-turn settle shared by `send()` and a resumed restore turn: back to idle through
|
|
6443
6728
|
* the session ref captured at turn start, then the cleanup the state setter would have done.
|
|
6444
6729
|
*/
|
|
6445
6730
|
private settleAfterTurn;
|
|
6731
|
+
/**
|
|
6732
|
+
* Report a turn that ended with the assistant waiting for the person to type (GENC-1660), for the
|
|
6733
|
+
* Always level: `turn-ended` on the activity bus, like every other notification report.
|
|
6734
|
+
*
|
|
6735
|
+
* Only for a turn that ran to its end, failed ones included: not one the person stopped
|
|
6736
|
+
* (`cancelling`), since they are there. Not while an interaction waits on them, which reports
|
|
6737
|
+
* itself, so the person is never told twice about one moment. And not while an autopilot runs for
|
|
6738
|
+
* the flow: it answers, hands back or reports its own stop. Sub-agents' turns never get here; they
|
|
6739
|
+
* run inside one of the parent's.
|
|
6740
|
+
*/
|
|
6741
|
+
private reportTurnEnded;
|
|
6446
6742
|
onChatHeaderMouseDown(e: MouseEvent): void;
|
|
6447
6743
|
handleInteractionCompleted(e: Event): void;
|
|
6448
6744
|
/**
|
|
@@ -6604,6 +6900,26 @@ export declare type GenesisWriteReviewCompletedEventDetail = InteractionResult<G
|
|
|
6604
6900
|
*/
|
|
6605
6901
|
export declare function getAiPopoutManager(): FoundationAiPopoutManager | undefined;
|
|
6606
6902
|
|
|
6903
|
+
/**
|
|
6904
|
+
* The live context of a pending interaction, by its id (GENC-1660), for UI that the chat does not
|
|
6905
|
+
* render and so is never handed one: a layout side panel that shows a widget's detail, say. It can
|
|
6906
|
+
* subscribe, read `heldBy` and reach the controller directly, rather than through a channel of its
|
|
6907
|
+
* own. `undefined` once the interaction has resolved (its context is disposed then) and for an id
|
|
6908
|
+
* that never opened.
|
|
6909
|
+
*
|
|
6910
|
+
* `TController` types `controller`, as it was registered (`registerInteraction<TController>()`).
|
|
6911
|
+
* Unchecked: the caller says what it expects.
|
|
6912
|
+
*
|
|
6913
|
+
* @example
|
|
6914
|
+
* ```ts
|
|
6915
|
+
* const ctx = getInteractionContext<ReviewController>(interactionId);
|
|
6916
|
+
* const unsubscribe = ctx?.subscribe(() => this.render(ctx.controller?.view(), ctx.heldBy));
|
|
6917
|
+
* ```
|
|
6918
|
+
*
|
|
6919
|
+
* @beta
|
|
6920
|
+
*/
|
|
6921
|
+
export declare function getInteractionContext<TController = unknown>(interactionId: string): InteractionContext<Record<string, unknown>, unknown, TController> | undefined;
|
|
6922
|
+
|
|
6607
6923
|
/**
|
|
6608
6924
|
* The registration for a component name, or `undefined` when it has none.
|
|
6609
6925
|
*
|
|
@@ -6619,6 +6935,19 @@ export declare function getInteractionRegistration(name: string): InteractionReg
|
|
|
6619
6935
|
*/
|
|
6620
6936
|
export declare type HandBackChoice = 'carry-on' | 'try-again' | 'compact' | 'pause' | 'reply';
|
|
6621
6937
|
|
|
6938
|
+
/**
|
|
6939
|
+
* The hand-back's controller. DOM-free: it exposes the choices as a decision (so the visible
|
|
6940
|
+
* transcript and the debug log describe it like any widget) and resolves through `ctx.resolve`. The
|
|
6941
|
+
* hand-back is always `userOnly`, so nothing but the person ever answers it.
|
|
6942
|
+
*/
|
|
6943
|
+
declare class HandBackController {
|
|
6944
|
+
readonly data: HandBackData;
|
|
6945
|
+
private readonly ctx;
|
|
6946
|
+
constructor(data: HandBackData, ctx: ControllerHost<HandBackResult['payload']>);
|
|
6947
|
+
/** The person's choice, from the view's buttons or its text box. */
|
|
6948
|
+
choose(answer: DecisionAnswer): void;
|
|
6949
|
+
}
|
|
6950
|
+
|
|
6622
6951
|
/**
|
|
6623
6952
|
* The hand-back's inputs. Every word it shows comes from here, so it follows the autopilot's
|
|
6624
6953
|
* `AutopilotCopy`.
|
|
@@ -6740,7 +7069,7 @@ export declare type InteractionCompletedEventDetail = ChatInteractionEventsMap['
|
|
|
6740
7069
|
*
|
|
6741
7070
|
* @beta
|
|
6742
7071
|
*/
|
|
6743
|
-
export declare interface InteractionContext<TState extends object = Record<string, unknown>, TCheckpoint = unknown> {
|
|
7072
|
+
export declare interface InteractionContext<TState extends object = Record<string, unknown>, TCheckpoint = unknown, TController = unknown> {
|
|
6744
7073
|
/** Stable id of the interaction this context belongs to. */
|
|
6745
7074
|
readonly interactionId: string;
|
|
6746
7075
|
/**
|
|
@@ -6783,6 +7112,10 @@ export declare interface InteractionContext<TState extends object = Record<strin
|
|
|
6783
7112
|
* live resource here must guard on the resolved state and stop touching `once`
|
|
6784
7113
|
* when the interaction completes — a stray late call (e.g. an async callback
|
|
6785
7114
|
* landing after a `timeoutMs` timeout) gets `null` rather than a leaked resource.
|
|
7115
|
+
*
|
|
7116
|
+
* Once means once for the interaction's whole life, so it cannot fire twice: anything a
|
|
7117
|
+
* claimant's hand-back must do again (reopening a side panel it shut while it held the
|
|
7118
|
+
* interaction, say) needs a flag on `state` instead, cleared when it is undone.
|
|
6786
7119
|
*/
|
|
6787
7120
|
once<T>(key: string, factory: () => T): T | null;
|
|
6788
7121
|
/**
|
|
@@ -6805,16 +7138,53 @@ export declare interface InteractionContext<TState extends object = Record<strin
|
|
|
6805
7138
|
onDispose(fn: () => void): void;
|
|
6806
7139
|
/**
|
|
6807
7140
|
* The widget's controller, built by the platform from its registration when the interaction was
|
|
6808
|
-
* requested, before anything rendered. `undefined` for an unregistered widget
|
|
6809
|
-
* interaction for its whole life, so a
|
|
7141
|
+
* requested, before anything rendered. `undefined` for an unregistered widget, and inside the
|
|
7142
|
+
* registration's own factory, which is building it. One per interaction for its whole life, so a
|
|
7143
|
+
* remounted view picks up the same one. Typed by `TController`: a registration made with
|
|
7144
|
+
* `registerInteraction<TController>()` builds one, and a view reads it typed through
|
|
7145
|
+
* `AiChatInteraction`'s third type argument.
|
|
6810
7146
|
*/
|
|
6811
|
-
readonly controller:
|
|
7147
|
+
readonly controller: TController | undefined;
|
|
6812
7148
|
/**
|
|
6813
7149
|
* Settle the interaction with `result` — the controller's way to resolve, in place of an element
|
|
6814
7150
|
* emitting `interaction-completed`, so resolving needs no mounted view. Goes through the same
|
|
6815
7151
|
* path, so cost and diagnostics fold in as before. Settles once: later calls do nothing.
|
|
7152
|
+
*
|
|
7153
|
+
* Pass `{ resolvedItself: true }` when this outcome settled by itself and asked nobody, for a
|
|
7154
|
+
* widget that sometimes works on its own and sometimes asks (see
|
|
7155
|
+
* {@link InteractionResolveOptions.resolvedItself}).
|
|
7156
|
+
*/
|
|
7157
|
+
resolve(result: unknown, options?: InteractionResolveOptions): void;
|
|
7158
|
+
/**
|
|
7159
|
+
* What the controller last said it is doing (GENC-1660), through {@link InteractionContext.setWorking}:
|
|
7160
|
+
* `true` working on its own (generating, running tests), `false` asking (what it has exposed is
|
|
7161
|
+
* the decision to make now), `undefined` until it says either.
|
|
6816
7162
|
*/
|
|
6817
|
-
|
|
7163
|
+
readonly working: boolean | undefined;
|
|
7164
|
+
/**
|
|
7165
|
+
* Say whether the controller is working on its own or asking (GENC-1660), for a widget that does
|
|
7166
|
+
* both — e.g. it generates, then opens a review gate. Optional: a controller that never calls it
|
|
7167
|
+
* behaves exactly as before. Notifies when it changes.
|
|
7168
|
+
*
|
|
7169
|
+
* - **Status.** While it is working the person is not being asked anything, so an autopilot's
|
|
7170
|
+
* status reads running rather than waiting for the user, even while the person holds it. Said
|
|
7171
|
+
* either way, it overrides the registration's `resolvesItself` for this interaction.
|
|
7172
|
+
* - **Readiness** (see {@link InteractionSurface.isReady}). While it is working, nothing it
|
|
7173
|
+
* exposed is a decision yet, so a claimant is never sent one mid-work, even with actions
|
|
7174
|
+
* enabled. Once it says it is asking, what it exposed is the decision to make now, even with
|
|
7175
|
+
* every action unavailable — a failed gate the claimant may not cancel, say: the claimant is
|
|
7176
|
+
* then sent it with the actions marked unavailable, and can only hand it back. Never said, a
|
|
7177
|
+
* decision is due once something is enabled, as before.
|
|
7178
|
+
*
|
|
7179
|
+
* @example
|
|
7180
|
+
* ```ts
|
|
7181
|
+
* ctx.setWorking(true);
|
|
7182
|
+
* const code = await generate();
|
|
7183
|
+
* ctx.exposeDecision({ options: [...], choose });
|
|
7184
|
+
* ctx.setWorking(false); // the gate is open: decide it, even if nothing can be chosen
|
|
7185
|
+
* ```
|
|
7186
|
+
*/
|
|
7187
|
+
setWorking(working: boolean): void;
|
|
6818
7188
|
/**
|
|
6819
7189
|
* Expose what can be decided here (the short form). Called by the controller: in its constructor
|
|
6820
7190
|
* for a pure question, or when its gate opens for a widget that works first. Calling again
|
|
@@ -6830,9 +7200,10 @@ export declare interface InteractionContext<TState extends object = Record<strin
|
|
|
6830
7200
|
/** The surface the controller exposed, or `undefined` until it exposes one. */
|
|
6831
7201
|
readonly surface: InteractionSurface | undefined;
|
|
6832
7202
|
/**
|
|
6833
|
-
* Run `fn` once the surface is ready (see `InteractionSurface.isReady
|
|
6834
|
-
* it already is. Readiness is re-checked on
|
|
6835
|
-
*
|
|
7203
|
+
* Run `fn` once the surface is ready (see `InteractionSurface.isReady`, which honours
|
|
7204
|
+
* {@link InteractionContext.setWorking}) — or now if it already is. Readiness is re-checked on
|
|
7205
|
+
* every `notify()` (which `setWorking` and both `expose` calls make), so a gate whose guard turns
|
|
7206
|
+
* true later fires it then. Never runs after the interaction ends. Returns an unsubscribe.
|
|
6836
7207
|
*/
|
|
6837
7208
|
onSurfaceReady(fn: () => void): () => void;
|
|
6838
7209
|
/**
|
|
@@ -6850,10 +7221,12 @@ export declare interface InteractionContext<TState extends object = Record<strin
|
|
|
6850
7221
|
* widget that only shows information never calls it.
|
|
6851
7222
|
*
|
|
6852
7223
|
* Safe to call from anywhere, the controller's constructor included: the platform reports it
|
|
6853
|
-
* only once it has decided who holds the interaction, and
|
|
6854
|
-
* holds it then or when it is called — the claimant's own hand-back notifies instead
|
|
6855
|
-
*
|
|
6856
|
-
*
|
|
7224
|
+
* only once it has decided who holds the interaction, and holds it back if a claimant (the
|
|
7225
|
+
* autopilot) holds it then or when it is called — the claimant's own hand-back notifies instead,
|
|
7226
|
+
* with `message` (GENC-1660). An autopilot that may not answer the interaction reports the
|
|
7227
|
+
* hand-back in its place too, once the widget waits on the person: the call then only says it
|
|
7228
|
+
* does, and gives that one notification its text. Only the first call counts, whatever happened
|
|
7229
|
+
* to it; later ones do nothing, as do calls after the interaction ends.
|
|
6857
7230
|
*
|
|
6858
7231
|
* @param message - The notification's text for this case. Defaults to the app's
|
|
6859
7232
|
* `chatConfig.ui.notifications.message`, then to "The assistant is ready for your next input".
|
|
@@ -6861,27 +7234,31 @@ export declare interface InteractionContext<TState extends object = Record<strin
|
|
|
6861
7234
|
requestAttention(message?: string): void;
|
|
6862
7235
|
/**
|
|
6863
7236
|
* What is already done, for long work that should survive a reload: the last checkpoint saved,
|
|
6864
|
-
* or the one the platform handed over
|
|
6865
|
-
*
|
|
6866
|
-
*
|
|
7237
|
+
* or the one the platform handed over. After a restore, a checkpoint the reload cut waits for a
|
|
7238
|
+
* request of the same widget type that the registration's `sameWork` agrees is the same work —
|
|
7239
|
+
* offered to each such request in turn, however many other interactions come first, and kept
|
|
7240
|
+
* through every refusal — and is handed to the first that agrees. `undefined` for fresh work. See
|
|
7241
|
+
* `runSteps`, which reads and writes it for you.
|
|
6867
7242
|
*/
|
|
6868
7243
|
readonly checkpoint: TCheckpoint | undefined;
|
|
6869
7244
|
/**
|
|
6870
7245
|
* Save a checkpoint into the session snapshot, so a reload does not lose it. Kept as JSON, so it
|
|
6871
7246
|
* must be storable as JSON; keep it small and hold anything large by reference (a job id, a store
|
|
6872
|
-
* key). One per interaction: each save replaces the last.
|
|
6873
|
-
*
|
|
7247
|
+
* key). One per interaction: each save replaces the last. Never replaces a checkpoint a reload cut
|
|
7248
|
+
* that is still waiting for its own widget. Cleared when the interaction settles, and when its
|
|
7249
|
+
* flow ends.
|
|
6874
7250
|
*/
|
|
6875
7251
|
saveCheckpoint(checkpoint: TCheckpoint): void;
|
|
6876
7252
|
}
|
|
6877
7253
|
|
|
6878
7254
|
/**
|
|
6879
7255
|
* Builds a widget's controller when its interaction is requested (GENC-1660). DOM-free: it owns the
|
|
6880
|
-
* interaction's state, its surface and resolving it; the view only renders.
|
|
7256
|
+
* interaction's state, its surface and resolving it; the view only renders. `ctx` is a
|
|
7257
|
+
* `ControllerHost` as it stands, so a controller that takes one is passed it directly.
|
|
6881
7258
|
*
|
|
6882
7259
|
* @beta
|
|
6883
7260
|
*/
|
|
6884
|
-
export declare type InteractionControllerFactory = (data: unknown, ctx: InteractionContext) =>
|
|
7261
|
+
export declare type InteractionControllerFactory<TController = unknown> = (data: unknown, ctx: InteractionContext<Record<string, unknown>, unknown, TController>) => TController;
|
|
6885
7262
|
|
|
6886
7263
|
/**
|
|
6887
7264
|
* Detail payload for the `interaction-cost` event — a POSITIVE DELTA in USD, not a running total.
|
|
@@ -6898,12 +7275,26 @@ export { InteractionEdit }
|
|
|
6898
7275
|
* Every interceptor is offered one, but only the claimant's works: on any other interceptor's
|
|
6899
7276
|
* handle, and after the interaction ends, its members do nothing and return `false`. A claim is
|
|
6900
7277
|
* granted only once `onInteractionOpened` has returned `'claim'` (it may yet be refused), so the
|
|
6901
|
-
* claimant's own handle does nothing until then either: act on it afterwards.
|
|
7278
|
+
* claimant's own handle does nothing until then either: act on it afterwards. An interceptor that
|
|
7279
|
+
* declined can still become the claimant later with `claim`, while nobody else is. Views read the
|
|
6902
7280
|
* result as `ctx.heldBy`; they never change it.
|
|
6903
7281
|
*
|
|
6904
7282
|
* @beta
|
|
6905
7283
|
*/
|
|
6906
7284
|
export declare interface InteractionHold {
|
|
7285
|
+
/**
|
|
7286
|
+
* Claim the interaction after declining it when it opened, as if it had claimed it then: it
|
|
7287
|
+
* moves to this interceptor, and the other members work for it from here on. For an interceptor
|
|
7288
|
+
* whose reason to decline has gone while the interaction is still open, such as an autopilot
|
|
7289
|
+
* that was paused when it opened and has since been resumed.
|
|
7290
|
+
*
|
|
7291
|
+
* Refused, returning `false` with nothing changed, while the interceptors are still being asked
|
|
7292
|
+
* (a claim at open is made by returning `'claim'`), once any interceptor has claimed it — this
|
|
7293
|
+
* one included, even if it has since given it to the person, which `set('claimant')` undoes —
|
|
7294
|
+
* when it is `userOnly`, and after it has ended. Notifies the context's subscribers and records
|
|
7295
|
+
* `interaction.held`, marked `late`.
|
|
7296
|
+
*/
|
|
7297
|
+
claim(): boolean;
|
|
6907
7298
|
/**
|
|
6908
7299
|
* Give the interaction to the person (`'user'`) or back to the claimant (`'claimant'`). Notifies
|
|
6909
7300
|
* the context's subscribers and records `interaction.held`. Returns whether it applied.
|
|
@@ -6926,7 +7317,8 @@ export declare interface InteractionHold {
|
|
|
6926
7317
|
* Settle the interaction AS the claimant (GENC-1660). The only route that stamps the claimant as
|
|
6927
7318
|
* `answeredBy`: an answer through the host's `resolveInteraction` — a click — is the person's,
|
|
6928
7319
|
* whoever held the interaction at the time, so attribution never depends on a view honouring
|
|
6929
|
-
* `heldBy`.
|
|
7320
|
+
* `heldBy`. The result's `userMessage` is ignored: the person did not say it. Returns `false`,
|
|
7321
|
+
* settling nothing, unless this interceptor holds it right now.
|
|
6930
7322
|
*/
|
|
6931
7323
|
resolve(result: unknown): boolean;
|
|
6932
7324
|
/**
|
|
@@ -6936,7 +7328,8 @@ export declare interface InteractionHold {
|
|
|
6936
7328
|
* and `note`, verbatim, as what they were shown about it — so `recordDecision` is not needed.
|
|
6937
7329
|
*
|
|
6938
7330
|
* A finishing action settles the interaction AS the claimant, as {@link InteractionHold.resolve}
|
|
6939
|
-
* does, so it is stamped `answeredBy` the claimant.
|
|
7331
|
+
* does, so it is stamped `answeredBy` the claimant. Its `note` is what the person is shown about
|
|
7332
|
+
* the choice; the widget's `userMessage` echo is never shown for a claimant's answer, note or not.
|
|
6940
7333
|
*
|
|
6941
7334
|
* Refused, with nothing run, unless this interceptor holds the interaction right now, the
|
|
6942
7335
|
* surface has that action, it is enabled and `args` fit it. One action runs at a time: a call
|
|
@@ -6951,6 +7344,28 @@ export declare interface InteractionHold {
|
|
|
6951
7344
|
invoke(action: string, args?: unknown, options?: {
|
|
6952
7345
|
note?: string;
|
|
6953
7346
|
}): Promise<InvokeResult>;
|
|
7347
|
+
/**
|
|
7348
|
+
* The message the widget passed to `InteractionContext.requestAttention`, once it has asked with
|
|
7349
|
+
* one (GENC-1660). A widget's request is not reported while a claimant holds the interaction, so
|
|
7350
|
+
* a claimant that hands it to the person reports with this, and the person reads the widget's
|
|
7351
|
+
* own words. Readable by every interceptor, claimant or not: one that declines the interaction
|
|
7352
|
+
* reports the hand-back too.
|
|
7353
|
+
*/
|
|
7354
|
+
attentionMessage(): string | undefined;
|
|
7355
|
+
/**
|
|
7356
|
+
* Report the widget's request for the person's attention in its place (GENC-1660), for an
|
|
7357
|
+
* interceptor that leaves the interaction with the person and reports that itself, such as an
|
|
7358
|
+
* autopilot handing a widget it may not answer to the person. The widget's
|
|
7359
|
+
* `InteractionContext.requestAttention` is then not reported on its own: `onRequest` is called
|
|
7360
|
+
* instead, when it would have been, so the interceptor knows the widget is asking and the person
|
|
7361
|
+
* gets one notification for the interaction. `attentionMessage` still returns the widget's words.
|
|
7362
|
+
*
|
|
7363
|
+
* Works for every interceptor, claimant or not, while the interaction is open. Returns the undo,
|
|
7364
|
+
* for an interceptor that ends up not reporting after all, or `undefined` when there is nothing to
|
|
7365
|
+
* take: the widget's request already counted, the interaction has ended, or another interceptor
|
|
7366
|
+
* took it first.
|
|
7367
|
+
*/
|
|
7368
|
+
takeAttention(onRequest: (message?: string) => void): (() => void) | undefined;
|
|
6954
7369
|
}
|
|
6955
7370
|
|
|
6956
7371
|
/**
|
|
@@ -6967,8 +7382,9 @@ export declare type InteractionHolder = 'user' | (string & {});
|
|
|
6967
7382
|
* decorator such as an autopilot or a test harness.
|
|
6968
7383
|
*
|
|
6969
7384
|
* Interceptors are asked outermost first. The first to claim an interaction holds it; the rest
|
|
6970
|
-
* observe — they see the same context but their `hold` does nothing.
|
|
6971
|
-
*
|
|
7385
|
+
* observe — they see the same context but their `hold` does nothing. When none claims it, any of
|
|
7386
|
+
* them may claim it later with `hold.claim`, the first to do so winning. Nobody can claim a
|
|
7387
|
+
* `userOnly` interaction. A throwing interceptor is logged and treated as abstaining.
|
|
6972
7388
|
*
|
|
6973
7389
|
* @beta
|
|
6974
7390
|
*/
|
|
@@ -7016,21 +7432,25 @@ export declare interface InteractionOpened {
|
|
|
7016
7432
|
readonly userOnly: boolean;
|
|
7017
7433
|
/** The interaction's live context, the same object its widget is handed. */
|
|
7018
7434
|
readonly ctx: InteractionContext;
|
|
7019
|
-
/**
|
|
7435
|
+
/**
|
|
7436
|
+
* See {@link InteractionHold}. Works only for the interceptor whose claim was granted, at open or
|
|
7437
|
+
* later through `claim`.
|
|
7438
|
+
*/
|
|
7020
7439
|
readonly hold: InteractionHold;
|
|
7021
7440
|
}
|
|
7022
7441
|
|
|
7023
7442
|
/**
|
|
7024
|
-
* How a widget is registered with the platform, once, at start-up (GENC-1660).
|
|
7443
|
+
* How a widget is registered with the platform, once, at start-up (GENC-1660). `TController` is
|
|
7444
|
+
* the type its factory builds, which `ctx.controller` then carries.
|
|
7025
7445
|
*
|
|
7026
7446
|
* @beta
|
|
7027
7447
|
*/
|
|
7028
|
-
export declare interface InteractionRegistration {
|
|
7448
|
+
export declare interface InteractionRegistration<TController = unknown> {
|
|
7029
7449
|
/**
|
|
7030
7450
|
* Builds the controller when the interaction is requested, before anything renders. Without
|
|
7031
7451
|
* one the widget works exactly as today and is never handed to a claimant.
|
|
7032
7452
|
*/
|
|
7033
|
-
readonly controller?: InteractionControllerFactory
|
|
7453
|
+
readonly controller?: InteractionControllerFactory<TController>;
|
|
7034
7454
|
/** The custom element that renders it. Defaults to the registered name. */
|
|
7035
7455
|
readonly view?: string;
|
|
7036
7456
|
/**
|
|
@@ -7049,8 +7469,45 @@ export declare interface InteractionRegistration {
|
|
|
7049
7469
|
* Without it, the same widget type is enough. Compare identity only — the fields the work's
|
|
7050
7470
|
* output depends on, kept in the checkpoint itself — never the model's prose, which a resumed call
|
|
7051
7471
|
* rewrites.
|
|
7472
|
+
*
|
|
7473
|
+
* Asked of every request of this widget type until it agrees: a refusal keeps the checkpoint for
|
|
7474
|
+
* a later request, so it must refuse whatever is not this work (another handler, superseded code)
|
|
7475
|
+
* rather than rely on being asked only once.
|
|
7052
7476
|
*/
|
|
7053
7477
|
readonly sameWork?: (saved: unknown, next: unknown) => boolean;
|
|
7478
|
+
/**
|
|
7479
|
+
* Whether the widget does its work and settles on its own, asking the person nothing: a
|
|
7480
|
+
* generation run that resolves when it is done, which the person may interrupt (a Skip button)
|
|
7481
|
+
* but is not being asked to answer. Defaults to `false`, a widget that asks.
|
|
7482
|
+
*
|
|
7483
|
+
* While one is open the turn is working, not parked on the person, so an autopilot's status stays
|
|
7484
|
+
* `running` rather than `waitingForUser`. When it settles by any route but a claimant's hold,
|
|
7485
|
+
* nobody answered it: the interaction message carries no `answeredBy`, the `interaction-settled`
|
|
7486
|
+
* event and the `interaction.resolved` debug event carry `resolvedItself: true` instead, and the
|
|
7487
|
+
* transcript a claimant reads labels it `finished` rather than answered by the user. The platform
|
|
7488
|
+
* cannot tell the widget finishing from the person interrupting it — both settle it the same way
|
|
7489
|
+
* — so a widget whose agent needs to know which says so in its own result.
|
|
7490
|
+
*
|
|
7491
|
+
* Claiming is unchanged: a claimant can take one only through a controller and its policy, as for
|
|
7492
|
+
* any widget.
|
|
7493
|
+
*
|
|
7494
|
+
* For a widget that sometimes works on its own and sometimes asks — a generation phase that ends
|
|
7495
|
+
* at a review gate — leave this unset and say it per interaction instead: `ctx.setWorking(true)`
|
|
7496
|
+
* while it works (the status), and `ctx.resolve(result, { resolvedItself: true })` for an outcome
|
|
7497
|
+
* that settled itself (a generation that failed outright). A controller's `setWorking` overrides
|
|
7498
|
+
* this flag for the status of its own interaction.
|
|
7499
|
+
*
|
|
7500
|
+
* @example
|
|
7501
|
+
* ```ts
|
|
7502
|
+
* registerInteraction('sample-data-generation', {
|
|
7503
|
+
* resolvesItself: true,
|
|
7504
|
+
* asText: sampleDataAsText,
|
|
7505
|
+
* });
|
|
7506
|
+
* ```
|
|
7507
|
+
*
|
|
7508
|
+
* @beta
|
|
7509
|
+
*/
|
|
7510
|
+
readonly resolvesItself?: boolean;
|
|
7054
7511
|
}
|
|
7055
7512
|
|
|
7056
7513
|
/**
|
|
@@ -7060,13 +7517,40 @@ export declare interface InteractionRegistration {
|
|
|
7060
7517
|
*/
|
|
7061
7518
|
declare type InteractionRequester = <T>(componentName: string, data: any, options?: InteractionRequestOptions, onOpened?: (interactionId: string) => void, ownerPath?: readonly string[], onSettled?: (settled: InteractionSettled) => void) => Promise<T>;
|
|
7062
7519
|
|
|
7520
|
+
/**
|
|
7521
|
+
* How a controller settles its interaction, beside the result (GENC-1660). See
|
|
7522
|
+
* {@link InteractionContext.resolve}.
|
|
7523
|
+
*
|
|
7524
|
+
* @beta
|
|
7525
|
+
*/
|
|
7526
|
+
export declare interface InteractionResolveOptions {
|
|
7527
|
+
/**
|
|
7528
|
+
* This outcome settled by itself and nobody answered it — a generation that failed outright, say
|
|
7529
|
+
* — though the widget is not registered `resolvesItself` because at other times it asks (a review
|
|
7530
|
+
* gate). It is then treated exactly as a `resolvesItself` widget's settle: no `answeredBy` on the
|
|
7531
|
+
* message, the asking tool's result or the `interaction-settled` event, and `resolvedItself: true`
|
|
7532
|
+
* on the message, the event and the `interaction.resolved` debug event, so neither the working
|
|
7533
|
+
* agent nor a claimant is told the person decided it.
|
|
7534
|
+
*
|
|
7535
|
+
* Ignored when a claimant settles it through its hold (a finishing action that ends up resolving
|
|
7536
|
+
* here is the claimant's answer), and on a timeout or a stop, which nobody answered anyway.
|
|
7537
|
+
*/
|
|
7538
|
+
readonly resolvedItself?: boolean;
|
|
7539
|
+
}
|
|
7540
|
+
|
|
7063
7541
|
/**
|
|
7064
7542
|
* Who answered an interaction, as its requester is told (GENC-1660). `answeredBy` is absent when it
|
|
7065
|
-
* closed unanswered (a timeout or a stop)
|
|
7066
|
-
* `
|
|
7543
|
+
* closed unanswered (a timeout or a stop) and when nobody answered it because it settled by itself
|
|
7544
|
+
* (`resolvedItself`); `decision` is present when an interceptor answered; `edited` is present when
|
|
7545
|
+
* the person answered one an interceptor had changed first.
|
|
7067
7546
|
*/
|
|
7068
7547
|
declare interface InteractionSettled {
|
|
7069
7548
|
readonly answeredBy?: string;
|
|
7549
|
+
/**
|
|
7550
|
+
* It settled by itself, other than through a claimant's hold: its widget is registered
|
|
7551
|
+
* `resolvesItself`, or its controller resolved this outcome with `{ resolvedItself: true }`.
|
|
7552
|
+
*/
|
|
7553
|
+
readonly resolvedItself?: boolean;
|
|
7070
7554
|
readonly decision?: DelegatedDecision;
|
|
7071
7555
|
readonly edited?: DelegatedEdits;
|
|
7072
7556
|
}
|
|
@@ -7080,20 +7564,35 @@ declare interface InteractionSettled {
|
|
|
7080
7564
|
export declare interface InteractionSurface {
|
|
7081
7565
|
/** Model-only guidance, from the decision's `prompt`. */
|
|
7082
7566
|
readonly prompt?: string;
|
|
7083
|
-
/** Read fresh on every call. */
|
|
7567
|
+
/** Read fresh on every call. Always `{}` on a full-form surface. */
|
|
7084
7568
|
facts(): Readonly<Record<string, unknown>>;
|
|
7085
7569
|
/** A full-form surface's description. Absent on a short-form decision. */
|
|
7086
7570
|
describe?(): string;
|
|
7087
|
-
/**
|
|
7088
|
-
|
|
7089
|
-
|
|
7571
|
+
/**
|
|
7572
|
+
* Its views, by name, each with the description the model is shown: a full-form surface's or a
|
|
7573
|
+
* short-form decision's. Absent when it has none.
|
|
7574
|
+
*/
|
|
7575
|
+
readonly views?: Readonly<Record<string, string>>;
|
|
7576
|
+
/** A full-form surface's {@link SurfaceSpec.preview}: the view sent with the decision. */
|
|
7577
|
+
readonly preview?: string;
|
|
7578
|
+
/**
|
|
7579
|
+
* Read one view by name, or the default with none: a short-form decision's facts, or a full-form
|
|
7580
|
+
* surface's preview (`undefined` when it names none). A name it does not list reads as
|
|
7581
|
+
* `undefined`. Absent when it has no views.
|
|
7582
|
+
*/
|
|
7090
7583
|
read?(view?: string): unknown;
|
|
7091
7584
|
/** Read fresh on every call: `enabled` reflects each option's guard right now. */
|
|
7092
7585
|
actions(): readonly SurfaceAction[];
|
|
7093
7586
|
/**
|
|
7094
|
-
* Whether a
|
|
7095
|
-
*
|
|
7096
|
-
*
|
|
7587
|
+
* Whether a decision is due now: what a claimant is sent a decision on (`onSurfaceReady`).
|
|
7588
|
+
*
|
|
7589
|
+
* First, what the controller said through `ctx.setWorking`: while it is working, never, whatever
|
|
7590
|
+
* is enabled; once it is asking, always, even with every action unavailable — the claimant is
|
|
7591
|
+
* then sent the decision with the actions marked unavailable, and can only hand it back. When it
|
|
7592
|
+
* has said neither, the surface's own rule: a short-form decision is ready once one of its
|
|
7593
|
+
* finishing options is enabled (a `reply` counts, having no guard); a full-form surface once any
|
|
7594
|
+
* of its actions is, since editing comes before finishing (its Save may be disabled until
|
|
7595
|
+
* something is edited).
|
|
7097
7596
|
*/
|
|
7098
7597
|
isReady(): boolean;
|
|
7099
7598
|
}
|
|
@@ -7350,6 +7849,10 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
|
|
|
7350
7849
|
* Two cases, because routing has two modes and they need opposite answers.
|
|
7351
7850
|
*/
|
|
7352
7851
|
getContextReserve(): ContextReserveResolution | undefined;
|
|
7852
|
+
/**
|
|
7853
|
+
* `pin` stands in for the user-pin when given, as for
|
|
7854
|
+
* {@link OrchestratingDriver.resolvePinnedAgent}.
|
|
7855
|
+
*/
|
|
7353
7856
|
private installAgent;
|
|
7354
7857
|
/**
|
|
7355
7858
|
* Release the current stateful agent: fire `onDeactivate` and clear the flow-owner lock. The
|
|
@@ -7403,6 +7906,8 @@ export declare class OrchestratingDriver extends BaseDriverDecorator<ChatDriver>
|
|
|
7403
7906
|
*
|
|
7404
7907
|
* Logs and returns `undefined` if a name no longer matches the agents array
|
|
7405
7908
|
* — protects against stale state after an agents-array reassignment.
|
|
7909
|
+
*
|
|
7910
|
+
* `pin` stands in for the user-pin when given — `SendMessageOptions.agent`.
|
|
7406
7911
|
*/
|
|
7407
7912
|
private resolvePinnedAgent;
|
|
7408
7913
|
/**
|
|
@@ -7551,10 +8056,21 @@ export declare interface PersistedSession {
|
|
|
7551
8056
|
mode: 'running' | 'paused';
|
|
7552
8057
|
};
|
|
7553
8058
|
/**
|
|
7554
|
-
* The
|
|
7555
|
-
* reload skips it
|
|
7556
|
-
*
|
|
7557
|
-
* `
|
|
8059
|
+
* The checkpoints of long actions (GENC-1660 §4.12): what widgets' work had already done, so a
|
|
8060
|
+
* reload skips it — the one in flight, and any an earlier reload cut that nothing has taken over
|
|
8061
|
+
* yet. Kept here rather than on the interaction messages, which a restore trims. On restore each
|
|
8062
|
+
* waits for a request of its own widget type that `sameWork` agrees is the same work. Optional
|
|
8063
|
+
* and additive, like `condensePolicies`; omitted when there are none.
|
|
8064
|
+
*/
|
|
8065
|
+
checkpoints?: Array<{
|
|
8066
|
+
componentName: string;
|
|
8067
|
+
value: unknown;
|
|
8068
|
+
}>;
|
|
8069
|
+
/**
|
|
8070
|
+
* The one checkpoint a snapshot held before `checkpoints` existed. Read on restore when
|
|
8071
|
+
* `checkpoints` is absent; never written now.
|
|
8072
|
+
*
|
|
8073
|
+
* @deprecated Written as `checkpoints`.
|
|
7558
8074
|
*/
|
|
7559
8075
|
checkpoint?: {
|
|
7560
8076
|
componentName: string;
|
|
@@ -7617,9 +8133,19 @@ declare type ProviderRefusedDetail = NonNullable<Extract<ChatDriverResult, {
|
|
|
7617
8133
|
*
|
|
7618
8134
|
* Registering is optional and additive: an unregistered widget works exactly as before.
|
|
7619
8135
|
*
|
|
8136
|
+
* Generic over the controller its factory builds, which types `ctx.controller` for the factory and
|
|
8137
|
+
* for anything that reads the context with the same type argument (a view, a widget tool):
|
|
8138
|
+
*
|
|
8139
|
+
* ```ts
|
|
8140
|
+
* registerInteraction<ReviewController>('review', {
|
|
8141
|
+
* controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),
|
|
8142
|
+
* asText: reviewAsText,
|
|
8143
|
+
* });
|
|
8144
|
+
* ```
|
|
8145
|
+
*
|
|
7620
8146
|
* @beta
|
|
7621
8147
|
*/
|
|
7622
|
-
export declare function registerInteraction(name: string, registration: InteractionRegistration): void;
|
|
8148
|
+
export declare function registerInteraction<TController = unknown>(name: string, registration: InteractionRegistration<TController>): void;
|
|
7623
8149
|
|
|
7624
8150
|
/**
|
|
7625
8151
|
* Build a {@link TieredAIProviderSwitcher} — which registers the tier-shaped provider
|
|
@@ -7868,6 +8394,13 @@ export declare interface SendMessageOptions {
|
|
|
7868
8394
|
* reaches the session total. Ignored unless `delegate` is set and it is a positive, finite number.
|
|
7869
8395
|
*/
|
|
7870
8396
|
externalCostUsd?: number;
|
|
8397
|
+
/**
|
|
8398
|
+
* Route only this message as if this agent were pinned, or as Auto when `null`, in place of the
|
|
8399
|
+
* sticky pin. Left out, the pin routes it. A flow-owner lock still outranks it, and a stateful
|
|
8400
|
+
* agent it reaches takes that lock as usual. Ignored by a driver with nothing to route between,
|
|
8401
|
+
* such as a bare `ChatDriver`.
|
|
8402
|
+
*/
|
|
8403
|
+
agent?: string | null;
|
|
7871
8404
|
}
|
|
7872
8405
|
|
|
7873
8406
|
/**
|
|
@@ -8447,6 +8980,22 @@ export declare type StepOutcome = 'started' | 'resumed' | 'done' | 'skipped';
|
|
|
8447
8980
|
*/
|
|
8448
8981
|
export declare const strictFallbackAgent: FallbackAgentConfig;
|
|
8449
8982
|
|
|
8983
|
+
/**
|
|
8984
|
+
* How {@link FoundationAiAssistant.submitMessage} routes its message.
|
|
8985
|
+
*
|
|
8986
|
+
* @beta
|
|
8987
|
+
*/
|
|
8988
|
+
export declare interface SubmitMessageOptions {
|
|
8989
|
+
/**
|
|
8990
|
+
* Route only this message as if this agent were pinned, or as Auto when `null`, without
|
|
8991
|
+
* changing `pinnedAgentName`. Left out, the message routes as any other would. A guided flow's
|
|
8992
|
+
* lock still outranks it, as it outranks the pin. A stateful agent it reaches takes that lock as
|
|
8993
|
+
* usual, so the messages after it go to that agent too, until its flow releases. An agent that
|
|
8994
|
+
* is not in `agents` is refused, and nothing is sent.
|
|
8995
|
+
*/
|
|
8996
|
+
agent?: string | null;
|
|
8997
|
+
}
|
|
8998
|
+
|
|
8450
8999
|
/**
|
|
8451
9000
|
* Result returned by {@link FoundationAiAssistant.submitMessage}.
|
|
8452
9001
|
*
|
|
@@ -8484,7 +9033,7 @@ export declare type SuggestionsState = {
|
|
|
8484
9033
|
* @beta
|
|
8485
9034
|
*/
|
|
8486
9035
|
export declare interface SurfaceAction {
|
|
8487
|
-
/** The name to invoke it by: an option's id,
|
|
9036
|
+
/** The name to invoke it by: an option's id, `select` / `reply`, or a full-form action's name. */
|
|
8488
9037
|
readonly name: string;
|
|
8489
9038
|
/** The text the person sees for it, where it has one. */
|
|
8490
9039
|
readonly label?: string;
|
|
@@ -8492,11 +9041,20 @@ export declare interface SurfaceAction {
|
|
|
8492
9041
|
readonly finishes: boolean;
|
|
8493
9042
|
/** Whether it can be run right now. */
|
|
8494
9043
|
readonly enabled: boolean;
|
|
9044
|
+
/** Why it cannot be run right now, when it is not enabled. */
|
|
9045
|
+
readonly unavailable?: string;
|
|
8495
9046
|
/**
|
|
8496
9047
|
* What its `args` must look like, where it takes any: `options` (a multi-select's picks), `text`
|
|
8497
|
-
* (a written answer
|
|
9048
|
+
* (one free-text argument: a written answer, or a full-form action declared with
|
|
9049
|
+
* {@link SurfaceActionSpec.text}) or `fields` (an object, described by `argsSchema`).
|
|
8498
9050
|
*/
|
|
8499
9051
|
readonly args?: 'options' | 'text' | 'fields';
|
|
9052
|
+
/**
|
|
9053
|
+
* Whether it counts against the autopilot's per-step refinement limit (`maxRefinements`), and is
|
|
9054
|
+
* withdrawn once the limit is reached: `reply`, and a full-form action declared with
|
|
9055
|
+
* {@link SurfaceActionSpec.refines}.
|
|
9056
|
+
*/
|
|
9057
|
+
readonly refines?: boolean;
|
|
8500
9058
|
/** A full-form action's own description, for the model. Short-form options have none. */
|
|
8501
9059
|
readonly description?: string;
|
|
8502
9060
|
/** For `fields`: the JSON schema its arguments are checked against. */
|
|
@@ -8507,6 +9065,9 @@ export declare interface SurfaceAction {
|
|
|
8507
9065
|
* One action of a full-form surface (GENC-1660 §4.2): a named thing a claimant can do, which may or
|
|
8508
9066
|
* may not settle the interaction.
|
|
8509
9067
|
*
|
|
9068
|
+
* It takes nothing, one free-text argument (`text`), or a form (`argsSchema`), never both of the
|
|
9069
|
+
* last two.
|
|
9070
|
+
*
|
|
8510
9071
|
* @beta
|
|
8511
9072
|
*/
|
|
8512
9073
|
export declare interface SurfaceActionSpec {
|
|
@@ -8514,16 +9075,42 @@ export declare interface SurfaceActionSpec {
|
|
|
8514
9075
|
readonly description: string;
|
|
8515
9076
|
/** Whether it settles the interaction. An editing action (`edit_rows`) does not. */
|
|
8516
9077
|
readonly finishes?: boolean;
|
|
8517
|
-
/** The button's own guard, read fresh: the claimant can never do what the view would refuse. */
|
|
8518
|
-
readonly enabledWhen?: () => boolean;
|
|
8519
9078
|
/**
|
|
8520
|
-
*
|
|
8521
|
-
*
|
|
9079
|
+
* Why it cannot be run right now, or `undefined` when it can: the button's own guard, read fresh,
|
|
9080
|
+
* so the claimant can never do what the view would refuse. The reason is shown with the action
|
|
9081
|
+
* and given when a call is refused. Absent means always available; an empty string or a throw
|
|
9082
|
+
* counts as unavailable, with a generic reason.
|
|
9083
|
+
*/
|
|
9084
|
+
readonly unavailable?: () => string | undefined;
|
|
9085
|
+
/**
|
|
9086
|
+
* It takes one free-text argument, which the claimant passes as `widget_act`'s own `text`, as
|
|
9087
|
+
* for `reply` — e.g. a regenerate's instruction. `run` then receives that text, trimmed, as a
|
|
9088
|
+
* string; an empty one is refused before it runs. Prefer it to an `argsSchema` with one string
|
|
9089
|
+
* property: plain text needs no JSON inside a string, which models get wrong.
|
|
9090
|
+
*/
|
|
9091
|
+
readonly text?: boolean;
|
|
9092
|
+
/**
|
|
9093
|
+
* The JSON schema of its arguments, an object, for a real form. Its `properties` and `required`
|
|
9094
|
+
* are checked before it runs; a mismatch is refused with the reason, so the model can correct
|
|
9095
|
+
* itself. The claimant sends them as JSON text in `widget_act`'s `fields`, which is parsed
|
|
9096
|
+
* leniently (an object is taken as it is, a code fence is stripped), and invalid JSON is refused
|
|
9097
|
+
* with an example built from this schema. For one free-text argument use
|
|
9098
|
+
* {@link SurfaceActionSpec.text} instead.
|
|
8522
9099
|
*/
|
|
8523
9100
|
readonly argsSchema?: Readonly<Record<string, unknown>>;
|
|
9101
|
+
/**
|
|
9102
|
+
* It refines rather than accepts — a regenerate with instructions, a retry with changes — so it
|
|
9103
|
+
* counts against the autopilot's per-step refinement limit (`maxRefinements`) exactly as a
|
|
9104
|
+
* written `reply` does, and is withdrawn (not listed, and refused) once the limit is reached.
|
|
9105
|
+
* Counted per step, not per interaction, so a refine that opens a new review of the same step
|
|
9106
|
+
* still counts. A claimant's limit only: a person's button is never limited by it.
|
|
9107
|
+
*/
|
|
9108
|
+
readonly refines?: boolean;
|
|
8524
9109
|
/**
|
|
8525
9110
|
* Do it — the SAME code the view's control runs. A finishing action resolves the interaction; an
|
|
8526
|
-
* editing one returns what changed (fresh errors, say), which the claimant is shown.
|
|
9111
|
+
* editing one returns what changed (fresh errors, say), which the claimant is shown. Receives
|
|
9112
|
+
* the text for a {@link SurfaceActionSpec.text} action, the checked object for an `argsSchema`
|
|
9113
|
+
* one, and `{}` otherwise.
|
|
8527
9114
|
*
|
|
8528
9115
|
* A finishing action should settle promptly. While one runs asynchronously, the claimant can run
|
|
8529
9116
|
* nothing else, and it keeps the claimant's credit even if the interaction is handed to the person
|
|
@@ -8545,18 +9132,52 @@ export declare interface SurfaceActionSpec {
|
|
|
8545
9132
|
export declare interface SurfaceSpec {
|
|
8546
9133
|
/** For the model: what this is, and what good looks like. Read fresh. */
|
|
8547
9134
|
describe(): string;
|
|
8548
|
-
/** The names of the views `read` answers, e.g. `['summary', 'rows', 'errors']`. */
|
|
8549
|
-
readonly views?: readonly string[];
|
|
8550
9135
|
/**
|
|
8551
|
-
*
|
|
8552
|
-
*
|
|
9136
|
+
* Named views a claimant may read with `widget_read({ view })`, each listed in the decision with
|
|
9137
|
+
* its description — the same shape as a short-form decision's {@link DecisionSpec.views}. Fixed
|
|
9138
|
+
* names with no parameters: a read that takes any (one table's rows) is a widget tool (see
|
|
9139
|
+
* `widgetTools`), and a view not listed here is refused.
|
|
9140
|
+
*/
|
|
9141
|
+
readonly views?: Readonly<Record<string, SurfaceView>>;
|
|
9142
|
+
/**
|
|
9143
|
+
* The view sent with the decision, as `Now:`, to save a round trip; `widget_read()` with no view
|
|
9144
|
+
* reads it again. One of {@link SurfaceSpec.views}; unset sends none. Keep it small, and do not
|
|
9145
|
+
* repeat the widget's `asText`, which opens the same decision message: send what the text form
|
|
9146
|
+
* does not already say.
|
|
8553
9147
|
*/
|
|
8554
|
-
|
|
9148
|
+
readonly preview?: string;
|
|
8555
9149
|
readonly actions: Readonly<Record<string, SurfaceActionSpec>>;
|
|
8556
9150
|
/** Model-only guidance, beside `describe`. */
|
|
8557
9151
|
readonly prompt?: string;
|
|
8558
9152
|
}
|
|
8559
9153
|
|
|
9154
|
+
/**
|
|
9155
|
+
* One named view of a surface (GENC-1660): content a claimant reads only when it asks for it, such
|
|
9156
|
+
* as a long explainer the person opens on the card, or a summary of a rich widget's state. Listed
|
|
9157
|
+
* in the decision with its description; its content is not, unless it is a full-form surface's
|
|
9158
|
+
* {@link SurfaceSpec.preview}.
|
|
9159
|
+
*
|
|
9160
|
+
* The same shape in both forms: a short-form decision's {@link DecisionSpec.views} and a full-form
|
|
9161
|
+
* surface's {@link SurfaceSpec.views}.
|
|
9162
|
+
*
|
|
9163
|
+
* A view takes no parameters. A read that needs them (one table's rows, a page at an offset) is a
|
|
9164
|
+
* widget tool instead: see `widgetTools`.
|
|
9165
|
+
*
|
|
9166
|
+
* Every read is capped at about 20,000 characters, cut with a note telling the model to ask for
|
|
9167
|
+
* less, so page anything that can grow.
|
|
9168
|
+
*
|
|
9169
|
+
* @beta
|
|
9170
|
+
*/
|
|
9171
|
+
export declare interface SurfaceView {
|
|
9172
|
+
/**
|
|
9173
|
+
* For the model: what the view holds and when it is worth reading. Shown with every decision, so
|
|
9174
|
+
* keep it to a sentence — it is what tells the model the view exists at all.
|
|
9175
|
+
*/
|
|
9176
|
+
readonly description: string;
|
|
9177
|
+
/** The view's content, as JSON. Read fresh on every `widget_read({ view })`. */
|
|
9178
|
+
read(): unknown;
|
|
9179
|
+
}
|
|
9180
|
+
|
|
8560
9181
|
/**
|
|
8561
9182
|
* Context passed to the function form of `systemPrompt` / `toolDefinitions`.
|
|
8562
9183
|
* Resolved each tool-loop iteration so the agent can vary what the LLM sees per turn.
|
|
@@ -8607,6 +9228,67 @@ export declare type TailContextInput = string | ((ctx: SystemPromptContext) => s
|
|
|
8607
9228
|
*/
|
|
8608
9229
|
export declare type TemperatureInput = number | ((ctx: SystemPromptContext) => number | Promise<number>);
|
|
8609
9230
|
|
|
9231
|
+
/**
|
|
9232
|
+
* What a claimant's action came to in a test: as `InteractionHold.invoke` reports it, less the
|
|
9233
|
+
* holding (a test context has no claimant to check).
|
|
9234
|
+
*
|
|
9235
|
+
* @beta
|
|
9236
|
+
*/
|
|
9237
|
+
export declare type TestActResult = {
|
|
9238
|
+
readonly ok: true;
|
|
9239
|
+
readonly finished: boolean;
|
|
9240
|
+
readonly output?: unknown;
|
|
9241
|
+
} | {
|
|
9242
|
+
readonly ok: false;
|
|
9243
|
+
readonly error: 'no-surface' | 'unknown-action' | 'disabled' | 'invalid-args' | 'threw';
|
|
9244
|
+
readonly message: string;
|
|
9245
|
+
};
|
|
9246
|
+
|
|
9247
|
+
/**
|
|
9248
|
+
* A real {@link InteractionContext} for a controller test, with the handles a test needs
|
|
9249
|
+
* (GENC-1660). See {@link createTestInteractionContext}.
|
|
9250
|
+
*
|
|
9251
|
+
* @beta
|
|
9252
|
+
*/
|
|
9253
|
+
export declare interface TestInteractionContext<TController = unknown, TResult = unknown> {
|
|
9254
|
+
/** The context, as the platform builds it: pass it to the controller as its host. */
|
|
9255
|
+
readonly context: InteractionContext<Record<string, unknown>, unknown, TController>;
|
|
9256
|
+
/** The controller, when built through `options.controller`; otherwise `undefined`. */
|
|
9257
|
+
readonly controller: TController | undefined;
|
|
9258
|
+
/** What the controller resolved with, or `undefined` while it has not. Only the first counts. */
|
|
9259
|
+
readonly result: InteractionResult<TResult> | undefined;
|
|
9260
|
+
/**
|
|
9261
|
+
* Whether the controller said its outcome settled by itself
|
|
9262
|
+
* (`ctx.resolve(result, { resolvedItself: true })`), which the platform then stamps as answered
|
|
9263
|
+
* by nobody. `false` while it has not resolved.
|
|
9264
|
+
*/
|
|
9265
|
+
readonly resolvedItself: boolean;
|
|
9266
|
+
/** How many times `notify()` has been called. */
|
|
9267
|
+
readonly notifications: number;
|
|
9268
|
+
/**
|
|
9269
|
+
* The widget's `requestAttention` calls that were reported, as the platform would report them
|
|
9270
|
+
* (GENC-1660): only the first call counts, none after the interaction ends, and none while a
|
|
9271
|
+
* claimant holds it. The test context offers the interaction straight after building the
|
|
9272
|
+
* controller, with nobody claiming it, so a call made while being built is reported as the
|
|
9273
|
+
* person's; one made after `setHeldBy('autopilot')` is held back for the claimant's hand-back.
|
|
9274
|
+
*/
|
|
9275
|
+
readonly attention: ReadonlyArray<{
|
|
9276
|
+
readonly message?: string;
|
|
9277
|
+
}>;
|
|
9278
|
+
/** The surface the controller exposed, as a claimant reads it; `undefined` until it exposes one. */
|
|
9279
|
+
readonly surface: InteractionSurface | undefined;
|
|
9280
|
+
/** Move the interaction to `holder` (`'user'`, or a claimant's id such as `'autopilot'`). */
|
|
9281
|
+
setHeldBy(holder: InteractionHolder): void;
|
|
9282
|
+
/**
|
|
9283
|
+
* Run one of the surface's actions as a claimant would, through the platform's own checks (the
|
|
9284
|
+
* action exists, its guard allows it, its arguments fit) and then its `run`: an option by id,
|
|
9285
|
+
* `select` with `{ options }`, `reply` or a text action with `{ text }`, a form with its fields.
|
|
9286
|
+
*/
|
|
9287
|
+
act(action: string, args?: unknown): Promise<TestActResult>;
|
|
9288
|
+
/** End the interaction, running its `onDispose` callbacks, as settling it would. */
|
|
9289
|
+
dispose(): void;
|
|
9290
|
+
}
|
|
9291
|
+
|
|
8610
9292
|
/**
|
|
8611
9293
|
* Extended-thinking posture for an agent — whether the model reasons before answering. Either a
|
|
8612
9294
|
* static `ChatThinkingPolicy` or a function resolved **once per user turn**, at the start of the
|
|
@@ -9128,6 +9810,102 @@ export declare class WebStorageSessionProvider implements SessionPersistenceProv
|
|
|
9128
9810
|
savePreferences(sessionKey: string, preferences: SessionPreferences): Promise<void>;
|
|
9129
9811
|
}
|
|
9130
9812
|
|
|
9813
|
+
/**
|
|
9814
|
+
* A widget's tools, bound to its component name: what {@link widgetTools} builds, and what an
|
|
9815
|
+
* autopilot's `widgetTools` takes.
|
|
9816
|
+
*
|
|
9817
|
+
* @beta
|
|
9818
|
+
*/
|
|
9819
|
+
export declare interface WidgetTools {
|
|
9820
|
+
/** The widget type the tools read from: its registered component name. */
|
|
9821
|
+
readonly componentName: string;
|
|
9822
|
+
/** The tools, by name. */
|
|
9823
|
+
readonly tools: Readonly<Record<string, WidgetToolSpec<unknown, Record<string, unknown>>>>;
|
|
9824
|
+
}
|
|
9825
|
+
|
|
9826
|
+
/**
|
|
9827
|
+
* Declare tools that read from one widget type (GENC-1660): parameterised reads that a view cannot
|
|
9828
|
+
* express, such as one table's rows, or a page of them.
|
|
9829
|
+
*
|
|
9830
|
+
* Put them on the autopilot (`defineAutopilot({ widgetTools: [...] })`), never discovered from the
|
|
9831
|
+
* registration. Its tool list is fixed when its session starts, sorted by name, and identical for
|
|
9832
|
+
* every decision, so the cache never breaks. Each call is routed to the interaction of
|
|
9833
|
+
* `componentName` the autopilot is deciding, and `run` gets its controller; with none open, it is
|
|
9834
|
+
* refused with a reason. While one is open, the autopilot's tail says which tools are usable now.
|
|
9835
|
+
*
|
|
9836
|
+
* Reads only. Their results leave the autopilot's history at the end of the decision, as
|
|
9837
|
+
* `widget_read`'s do.
|
|
9838
|
+
*
|
|
9839
|
+
* @example
|
|
9840
|
+
* ```ts
|
|
9841
|
+
* export const SAMPLE_DATA_TOOLS = widgetTools('sample-data-review', {
|
|
9842
|
+
* sample_data_rows: {
|
|
9843
|
+
* definition: {
|
|
9844
|
+
* description: "One table's rows. Only while a sample-data review is open.",
|
|
9845
|
+
* parameters: {
|
|
9846
|
+
* type: 'object',
|
|
9847
|
+
* properties: { table: { type: 'string' }, offset: { type: 'integer' } },
|
|
9848
|
+
* required: ['table'],
|
|
9849
|
+
* },
|
|
9850
|
+
* },
|
|
9851
|
+
* run: (controller: SampleDataReviewController, args: { table: string; offset?: number }) =>
|
|
9852
|
+
* controller.rows(args.table, args.offset ?? 0),
|
|
9853
|
+
* },
|
|
9854
|
+
* });
|
|
9855
|
+
* ```
|
|
9856
|
+
*
|
|
9857
|
+
* @beta
|
|
9858
|
+
*/
|
|
9859
|
+
export declare function widgetTools<TController, TArgs extends {
|
|
9860
|
+
[name: string]: object;
|
|
9861
|
+
}>(componentName: string, tools: {
|
|
9862
|
+
[K in keyof TArgs]: WidgetToolSpec<TController, TArgs[K]>;
|
|
9863
|
+
}): WidgetTools;
|
|
9864
|
+
|
|
9865
|
+
/**
|
|
9866
|
+
* One widget tool (GENC-1660): an ordinary tool with native, typed parameters that reads from the
|
|
9867
|
+
* widget open right now. `TController` is the widget's controller, as it was registered; `TArgs`
|
|
9868
|
+
* the parameters, as the model sends them.
|
|
9869
|
+
*
|
|
9870
|
+
* @beta
|
|
9871
|
+
*/
|
|
9872
|
+
export declare interface WidgetToolSpec<TController = unknown, TArgs = Record<string, unknown>> {
|
|
9873
|
+
/**
|
|
9874
|
+
* The tool as the model sees it, less its name (the key it is declared under). Design it to the
|
|
9875
|
+
* same provider rules as any other tool: plain types, no type unions, no arrays of objects. Its
|
|
9876
|
+
* description should say when it applies, e.g. "Only while a sample-data review is open.": the
|
|
9877
|
+
* tool is offered on every decision, so the cached prefix never changes.
|
|
9878
|
+
*
|
|
9879
|
+
* Its `parameters`' `required` properties and their declared top-level types are checked before
|
|
9880
|
+
* `run` is called; a mismatch is refused with the reason.
|
|
9881
|
+
*/
|
|
9882
|
+
readonly definition: Omit<ChatToolDefinition, 'name'>;
|
|
9883
|
+
/**
|
|
9884
|
+
* Why it cannot be used right now, or `undefined` when it can, for a tool that applies only in
|
|
9885
|
+
* some of its widget's states (the handler's code, once there is some). Read fresh: the tail lists
|
|
9886
|
+
* the tool only while this is `undefined`, and a call otherwise is refused with this reason before
|
|
9887
|
+
* `run`. Absent means whenever its widget is open; an empty string or a throw counts as
|
|
9888
|
+
* unavailable, with a generic reason. The tool stays declared either way, so the cached prefix
|
|
9889
|
+
* never changes.
|
|
9890
|
+
*
|
|
9891
|
+
* @example
|
|
9892
|
+
* ```ts
|
|
9893
|
+
* unavailable: (c) => (c.code ? undefined : 'No code has been generated yet.'),
|
|
9894
|
+
* ```
|
|
9895
|
+
*/
|
|
9896
|
+
unavailable?(controller: TController): string | undefined;
|
|
9897
|
+
/**
|
|
9898
|
+
* Read what was asked from the open widget's controller, and return it: JSON, or text. Reads
|
|
9899
|
+
* only — it must never settle or change the widget; anything that does goes through a
|
|
9900
|
+
* `widget_act` action, under the claimant's hold. A throw is reported to the model as the reason
|
|
9901
|
+
* the read failed.
|
|
9902
|
+
*
|
|
9903
|
+
* What it returns is capped at about 20,000 characters, cut with a note telling the model to ask
|
|
9904
|
+
* for less, so page anything that can grow (an `offset`, a `limit`).
|
|
9905
|
+
*/
|
|
9906
|
+
run(controller: TController, args: TArgs): unknown | Promise<unknown>;
|
|
9907
|
+
}
|
|
9908
|
+
|
|
9131
9909
|
/**
|
|
9132
9910
|
* A stored diagnostics stream with its `meta-snapshot`s replaced by `fresh` — what to
|
|
9133
9911
|
* pass {@link assembleDebugLog} when reassembling a persisted stream for export.
|