@genesislcap/ai-assistant 15.61.0 → 15.62.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.
Files changed (134) hide show
  1. package/dist/ai-assistant.api.json +18231 -11171
  2. package/dist/ai-assistant.d.ts +1235 -9
  3. package/dist/chat-driver.cjs +658 -50
  4. package/dist/chat-driver.cjs.map +4 -4
  5. package/dist/chat-driver.mjs +657 -50
  6. package/dist/chat-driver.mjs.map +4 -4
  7. package/dist/custom-elements.json +6169 -2127
  8. package/dist/dts/autopilot/autopilot-driver.d.ts +278 -0
  9. package/dist/dts/autopilot/autopilot-driver.d.ts.map +1 -0
  10. package/dist/dts/autopilot/autopilot-session.d.ts +163 -0
  11. package/dist/dts/autopilot/autopilot-session.d.ts.map +1 -0
  12. package/dist/dts/autopilot/autopilot-tools.d.ts +15 -0
  13. package/dist/dts/autopilot/autopilot-tools.d.ts.map +1 -0
  14. package/dist/dts/autopilot/decision-message.d.ts +62 -0
  15. package/dist/dts/autopilot/decision-message.d.ts.map +1 -0
  16. package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts +69 -0
  17. package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts.map +1 -0
  18. package/dist/dts/autopilot/hand-back/hand-back.d.ts +22 -0
  19. package/dist/dts/autopilot/hand-back/hand-back.d.ts.map +1 -0
  20. package/dist/dts/autopilot/index.d.ts +4 -0
  21. package/dist/dts/autopilot/index.d.ts.map +1 -0
  22. package/dist/dts/channel/ai-activity-bus.d.ts.map +1 -1
  23. package/dist/dts/channel/ai-activity-channel.d.ts +17 -0
  24. package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
  25. package/dist/dts/channel/autopilot-needs-user.d.ts +8 -0
  26. package/dist/dts/channel/autopilot-needs-user.d.ts.map +1 -0
  27. package/dist/dts/components/agent-picker/agent-picker.constants.d.ts +10 -0
  28. package/dist/dts/components/agent-picker/agent-picker.constants.d.ts.map +1 -1
  29. package/dist/dts/components/agent-picker/agent-picker.d.ts +4 -0
  30. package/dist/dts/components/agent-picker/agent-picker.d.ts.map +1 -1
  31. package/dist/dts/components/agent-picker/agent-picker.template.d.ts.map +1 -1
  32. package/dist/dts/components/ai-driver/ai-driver.d.ts +34 -1
  33. package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
  34. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts +3 -1
  35. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts.map +1 -1
  36. package/dist/dts/components/chat-bubble/chat-bubble.d.ts +21 -0
  37. package/dist/dts/components/chat-bubble/chat-bubble.d.ts.map +1 -1
  38. package/dist/dts/components/chat-bubble/chat-bubble.styles.d.ts.map +1 -1
  39. package/dist/dts/components/chat-bubble/chat-bubble.template.d.ts.map +1 -1
  40. package/dist/dts/components/chat-driver/chat-driver.d.ts +5 -1
  41. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  42. package/dist/dts/components/chat-driver/interaction-controller.d.ts +27 -3
  43. package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
  44. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts +10 -2
  45. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts.map +1 -1
  46. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +9 -1
  47. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
  48. package/dist/dts/config/config.d.ts +183 -0
  49. package/dist/dts/config/config.d.ts.map +1 -1
  50. package/dist/dts/config/define-stateful-agent.d.ts +31 -1
  51. package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
  52. package/dist/dts/index.d.ts +7 -3
  53. package/dist/dts/index.d.ts.map +1 -1
  54. package/dist/dts/main/main.d.ts +128 -5
  55. package/dist/dts/main/main.d.ts.map +1 -1
  56. package/dist/dts/main/main.styles.d.ts.map +1 -1
  57. package/dist/dts/main/main.template.d.ts +2 -2
  58. package/dist/dts/main/main.template.d.ts.map +1 -1
  59. package/dist/dts/react.d.ts +10 -0
  60. package/dist/dts/state/debug-event-log.d.ts +1 -1
  61. package/dist/dts/state/debug-event-log.d.ts.map +1 -1
  62. package/dist/dts/state/decision-surface.d.ts +46 -0
  63. package/dist/dts/state/decision-surface.d.ts.map +1 -0
  64. package/dist/dts/state/interaction-context.d.ts +21 -1
  65. package/dist/dts/state/interaction-context.d.ts.map +1 -1
  66. package/dist/dts/state/interaction-registry.d.ts +63 -0
  67. package/dist/dts/state/interaction-registry.d.ts.map +1 -0
  68. package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
  69. package/dist/dts/state/persistence/session-snapshot.d.ts +21 -0
  70. package/dist/dts/state/persistence/session-snapshot.d.ts.map +1 -1
  71. package/dist/dts/state/run-steps.d.ts +66 -0
  72. package/dist/dts/state/run-steps.d.ts.map +1 -0
  73. package/dist/dts/types/ai-chat-widget.d.ts +7 -1
  74. package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
  75. package/dist/dts/types/interaction-context.d.ts +66 -1
  76. package/dist/dts/types/interaction-context.d.ts.map +1 -1
  77. package/dist/dts/types/interaction-interceptor.d.ts +60 -2
  78. package/dist/dts/types/interaction-interceptor.d.ts.map +1 -1
  79. package/dist/dts/types/interaction-surface.d.ts +195 -0
  80. package/dist/dts/types/interaction-surface.d.ts.map +1 -0
  81. package/dist/dts/utils/context-tokens.d.ts +6 -0
  82. package/dist/dts/utils/context-tokens.d.ts.map +1 -1
  83. package/dist/dts/utils/delegated-message.d.ts +13 -0
  84. package/dist/dts/utils/delegated-message.d.ts.map +1 -1
  85. package/dist/dts/utils/history-transform.d.ts.map +1 -1
  86. package/dist/dts/utils/preserved-user-messages.d.ts +21 -0
  87. package/dist/dts/utils/preserved-user-messages.d.ts.map +1 -0
  88. package/dist/esm/autopilot/autopilot-driver.js +906 -0
  89. package/dist/esm/autopilot/autopilot-session.js +449 -0
  90. package/dist/esm/autopilot/autopilot-tools.js +68 -0
  91. package/dist/esm/autopilot/decision-message.js +206 -0
  92. package/dist/esm/autopilot/hand-back/hand-back.controller.js +47 -0
  93. package/dist/esm/autopilot/hand-back/hand-back.js +129 -0
  94. package/dist/esm/autopilot/index.js +4 -0
  95. package/dist/esm/channel/ai-activity-bus.js +7 -0
  96. package/dist/esm/channel/autopilot-needs-user.js +26 -0
  97. package/dist/esm/components/agent-picker/agent-picker.constants.js +10 -0
  98. package/dist/esm/components/agent-picker/agent-picker.js +11 -1
  99. package/dist/esm/components/agent-picker/agent-picker.template.js +2 -4
  100. package/dist/esm/components/ai-driver/ai-driver.js +2 -0
  101. package/dist/esm/components/ai-driver/base-driver-decorator.js +8 -0
  102. package/dist/esm/components/chat-bubble/chat-bubble.js +45 -0
  103. package/dist/esm/components/chat-bubble/chat-bubble.styles.js +26 -0
  104. package/dist/esm/components/chat-bubble/chat-bubble.template.js +13 -0
  105. package/dist/esm/components/chat-driver/chat-driver.js +53 -18
  106. package/dist/esm/components/chat-driver/interaction-controller.js +297 -12
  107. package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.js +16 -2
  108. package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +28 -11
  109. package/dist/esm/config/define-stateful-agent.js +34 -29
  110. package/dist/esm/index.js +3 -0
  111. package/dist/esm/main/main.js +334 -15
  112. package/dist/esm/main/main.styles.js +126 -0
  113. package/dist/esm/main/main.template.js +116 -11
  114. package/dist/esm/state/debug-event-log.js +28 -1
  115. package/dist/esm/state/decision-surface.js +209 -0
  116. package/dist/esm/state/interaction-context.js +89 -1
  117. package/dist/esm/state/interaction-registry.js +33 -0
  118. package/dist/esm/state/persistence/session-persister.js +23 -11
  119. package/dist/esm/state/persistence/session-snapshot.js +1 -1
  120. package/dist/esm/state/run-steps.js +77 -0
  121. package/dist/esm/types/interaction-surface.js +1 -0
  122. package/dist/esm/utils/context-tokens.js +23 -9
  123. package/dist/esm/utils/delegated-message.js +15 -0
  124. package/dist/esm/utils/history-transform.js +18 -7
  125. package/dist/esm/utils/preserved-user-messages.js +31 -0
  126. package/dist/react.cjs +7 -0
  127. package/dist/react.mjs +6 -0
  128. package/docs/styling.md +1 -1
  129. package/package.json +17 -17
  130. package/sandbox/README.md +38 -2
  131. package/sandbox/autopilot.ts +358 -0
  132. package/sandbox/controls.ts +24 -1
  133. package/sandbox/fixtures.ts +2 -0
  134. package/sandbox/sandbox.ts +188 -1
@@ -0,0 +1,278 @@
1
+ import type { AIProviderRegistry, ChatAttachment, ChatDriverResult, ChatMessage } from '@genesislcap/foundation-ai';
2
+ import type { AiDriver } from '../components/ai-driver/ai-driver';
3
+ import { BaseDriverDecorator } from '../components/ai-driver/base-driver-decorator';
4
+ import type { ContinueFromHistoryOptions } from '../components/chat-driver/chat-driver';
5
+ import type { AgentConfig, AutopilotCopy } from '../config/config';
6
+ import type { DiagnosticEntry } from '../state/persistence/diagnostics';
7
+ import type { SendMessageOptions } from '../utils/delegated-message';
8
+ /**
9
+ * The holder id the autopilot claims interactions as.
10
+ *
11
+ * @beta
12
+ */
13
+ export declare const AUTOPILOT_CLAIMANT = "autopilot";
14
+ /**
15
+ * The autopilot's mode for the current flow (GENC-1660 §4.10). `'unavailable'`: no autopilot for
16
+ * this flow, or not yet (e.g. no approved brief). `'paused'`: available but not answering.
17
+ * `'running'`: answering what its policy allows.
18
+ *
19
+ * @beta
20
+ */
21
+ export type AutopilotMode = 'unavailable' | 'paused' | 'running';
22
+ /**
23
+ * What the autopilot UI reads (GENC-1660 §4.10).
24
+ *
25
+ * @beta
26
+ */
27
+ export interface AutopilotHostState {
28
+ readonly mode: AutopilotMode;
29
+ /**
30
+ * Set while paused. `'this-interaction'` is the autopilot's own hand-back: it resumes by itself
31
+ * once the person answers `interactionId`, and `reason` is the banner's text.
32
+ */
33
+ readonly pause?: {
34
+ readonly scope: 'until-resumed' | 'this-interaction';
35
+ readonly interactionId?: string;
36
+ readonly reason?: string;
37
+ };
38
+ /** The slim bar's one-line status. */
39
+ readonly status: string;
40
+ /** Whether something waits on the person: drives the "needs you" badge. */
41
+ readonly needsUser: boolean;
42
+ /**
43
+ * Whether something is happening: the working agent is busy, or the autopilot is deciding (a
44
+ * widget it holds, or a written question it is answering). The slim bar replaces the composer
45
+ * only while this is set; running but idle — stopped at a wall such as the budget, or at the end
46
+ * of a turn it had nothing to answer for — the host shows what the agent's own rules show. A host
47
+ * that hides the built-in composer keeps the slim bar regardless, as its only place for the pill.
48
+ */
49
+ readonly working: boolean;
50
+ }
51
+ /**
52
+ * The contract the autopilot UI is built against (GENC-1660 §4.10): the slim bar, its buttons, the
53
+ * banner's "Keep paused", and the badge. The host installs `AutopilotDriver` itself, so it reads it
54
+ * as this; nothing about it travels through `AiDriver`.
55
+ *
56
+ * @beta
57
+ */
58
+ export interface AutopilotHost {
59
+ readonly state: AutopilotHostState;
60
+ subscribe(listener: () => void): () => void;
61
+ /** Pause until resumed. Hands a held interaction to the person on the spot. */
62
+ pause(): void;
63
+ /**
64
+ * Resume. Takes back an interaction that pausing handed over; during the autopilot's own
65
+ * hand-back it means "decide it yourself".
66
+ */
67
+ resume(): void;
68
+ /** The existing Stop, which also pauses, so what is shown stays honest. */
69
+ stop(): void;
70
+ /** The banner's "Keep paused": turn the autopilot's own hand-back into an ordinary pause. */
71
+ keepPaused(interactionId: string): void;
72
+ readonly copy: AutopilotCopy;
73
+ }
74
+ /**
75
+ * The autopilot's mode as saved with the session (GENC-1660 §4.8): which flow it was set for, and
76
+ * whether it was running. Cleared when that flow ends, so a saved mode never outlives its flow.
77
+ *
78
+ * @beta
79
+ */
80
+ export interface PersistedAutopilotMode {
81
+ readonly onFor: string;
82
+ readonly mode: 'running' | 'paused';
83
+ }
84
+ /**
85
+ * What a working agent's tool handlers get as `context.capabilities.autopilot` (GENC-1660): the
86
+ * mode of their own flow, and a way to set it — e.g. after the user picks "Build it for me".
87
+ * Absent when the flow has no autopilot, so a handler feature-detects and does not offer the choice.
88
+ *
89
+ * @beta
90
+ */
91
+ export interface AutopilotCapability {
92
+ readonly mode: AutopilotMode;
93
+ setMode(mode: 'paused' | 'running'): void;
94
+ }
95
+ declare module '@genesislcap/foundation-ai' {
96
+ interface ChatHandlerCapabilities {
97
+ autopilot: AutopilotCapability;
98
+ }
99
+ }
100
+ /**
101
+ * Options for {@link AutopilotDriver}.
102
+ *
103
+ * @beta
104
+ */
105
+ export interface AutopilotDriverOptions {
106
+ /** The agents the host configured; an agent's `autopilot` key is what this driver runs. */
107
+ readonly agents: readonly AgentConfig[];
108
+ /** The registry the autopilot's own driver resolves its provider from. */
109
+ readonly providerRegistry: AIProviderRegistry;
110
+ /** The working session's debug-log key. */
111
+ readonly sessionKey?: string;
112
+ }
113
+ /**
114
+ * Autopilot (GENC-1660): a driver decorator that answers the questions a working agent asks the
115
+ * user, on their behalf, grounded in the agent's autopilot config (for bootstrap, the brief).
116
+ *
117
+ * Neither side calls the other. The working agent asks as it always does; this driver claims the
118
+ * interactions its policy allows, while it is running for that flow, and answers each in one short
119
+ * turn on the flow's `AutopilotSession`. It plugs in only through the generic extension points
120
+ * — an interaction interceptor, a handler capability and the flow lifecycle — so the core knows
121
+ * nothing about it, and it wraps any `AiDriver`.
122
+ *
123
+ * @beta
124
+ */
125
+ export declare class AutopilotDriver extends BaseDriverDecorator implements AutopilotHost {
126
+ private readonly agents;
127
+ private readonly providerRegistry;
128
+ private readonly sessionKey;
129
+ private readonly listeners;
130
+ private readonly sessions;
131
+ /** The flow the mode applies to: set when it is first switched, cleared when that flow ends. */
132
+ private onFor;
133
+ private mode;
134
+ private pauseState?;
135
+ private held?;
136
+ /** Written answers given on the current step, for the refinement limit. */
137
+ private refinements?;
138
+ /** The watchdog's next check, while a claimed interaction is pending. */
139
+ private watchdog?;
140
+ /** What sessions that have ended did, kept for the debug log. */
141
+ private readonly endedDiagnostics;
142
+ /** Written answers sent in a row; see `MAX_CONSECUTIVE_REPLIES`. */
143
+ private consecutiveReplies;
144
+ /** Set while the turn-level hand-back waits on the person. */
145
+ private turnHandBack?;
146
+ /** A mode restored with the session, waiting for its flow to become the owner again. */
147
+ private restored?;
148
+ /**
149
+ * Bumped on every pause and resume, and when its sessions end. A written answer is sent only if
150
+ * none came between asking for it and its landing: one started before a pause is stale after it,
151
+ * even once resumed.
152
+ */
153
+ private generation;
154
+ /** Working turns this driver has started that have not ended yet; see `working`. */
155
+ private turnsInFlight;
156
+ /** Written questions being answered right now; see `working`. */
157
+ private answersInFlight;
158
+ constructor(inner: AiDriver, options: AutopilotDriverOptions);
159
+ get state(): AutopilotHostState;
160
+ get copy(): AutopilotCopy;
161
+ subscribe(listener: () => void): () => void;
162
+ pause(): void;
163
+ resume(): void;
164
+ stop(): void;
165
+ /** The mode to save with the session, while it is set for the current flow. */
166
+ getPersistedMode(): PersistedAutopilotMode | undefined;
167
+ /**
168
+ * Bring back a saved mode. It applies once its flow is the owner again — at once if it already
169
+ * is, otherwise when the restored flow re-activates. Restoring starts nothing: the autopilot acts
170
+ * only on live events, such as the working agent's own resume asking a question (§4.10, S3).
171
+ */
172
+ restorePersistedMode(saved: PersistedAutopilotMode | undefined): void;
173
+ private adoptRestored;
174
+ keepPaused(interactionId: string): void;
175
+ sendMessage(input: string, attachments?: ChatAttachment[], options?: SendMessageOptions): Promise<ChatDriverResult>;
176
+ continueFromHistory(transientPrimer?: ChatMessage[], options?: ContinueFromHistoryOptions): Promise<ChatDriverResult>;
177
+ resumeRestoredFlow(resumeNote?: string, agent?: AgentConfig): Promise<ChatDriverResult | undefined>;
178
+ /**
179
+ * Run a working turn, counted for `working` from the moment it is asked for: the wrapped driver
180
+ * may not say it is busy until some way in. The caller notifies once it has acted on the end.
181
+ */
182
+ private whileWorking;
183
+ /**
184
+ * Act on how a working turn ended, without holding up whoever awaited it, then notify: idle
185
+ * unless that started something (an answer, a hand-back), which it does before this returns.
186
+ */
187
+ private afterTurn;
188
+ private onTurnEnded;
189
+ /** {@link AutopilotDriver.answer}, from a caller that does not wait for it. */
190
+ private answerInBackground;
191
+ /**
192
+ * Answer a written question the working agent ended its turn on, and send the answer on the
193
+ * user's behalf, with what writing it cost booked on that message (§4.2).
194
+ *
195
+ * Sent only if the question still stands when the answer lands: no pause or resume since it was
196
+ * asked (Pause stops it, and the question is the person's to answer by typing), the flow still
197
+ * running, the working agent idle, and the question still the last thing it said. Otherwise the
198
+ * answer goes nowhere — not sent, not counted, not recorded as acted — and its cost is recorded as
199
+ * dropped, as it is whenever no reply is sent to carry it.
200
+ */
201
+ private answer;
202
+ /**
203
+ * Spend on a written answer that no reply carries into the session total — it was handed back,
204
+ * stopped, or went stale — recorded so it is never lost silently.
205
+ */
206
+ private dropCost;
207
+ /** The working agent's last visible words, when its turn ended on them. */
208
+ private lastQuestion;
209
+ /**
210
+ * The turn-level hand-back (§4.10): a working turn ended needing the person and there is no
211
+ * widget to hand over, so the autopilot shows its own, `userOnly`, and acts on the choice.
212
+ */
213
+ private presentHandBack;
214
+ /**
215
+ * The inner driver's diagnostics, then everything the autopilot did (§4.8): diagnostics compose
216
+ * down the decorator stack, so they reach the downloaded and the persisted debug log through the
217
+ * host's existing external-diagnostics channel.
218
+ */
219
+ getExternalDiagnostics(): ReadonlyArray<DiagnosticEntry>;
220
+ /**
221
+ * Close every session, keeping what it did for the debug log. An answer one was still writing is
222
+ * stale from here: it is never sent, and its cost is recorded as dropped when it lands.
223
+ */
224
+ private endSessions;
225
+ dispose(): Promise<void>;
226
+ private onInteractionOpened;
227
+ /** Run one decision on the flow's session, and act on how it ended. */
228
+ private decide;
229
+ /** The step a decision belongs to, for the refinement limit (§4.4). */
230
+ private stepKey;
231
+ /** Whether a written answer is still allowed on this step. The count resets when the step changes. */
232
+ private mayRefine;
233
+ private countRefinement;
234
+ /** Written answers allowed per step: the config's when it is a whole number `>= 0`. */
235
+ private refinementLimit;
236
+ /**
237
+ * The watchdog (§4.2, critique S5): a claimed interaction whose work has gone quiet for longer
238
+ * than `watchdogMs` is handed back rather than left to hang silently. Quiet is either no surface
239
+ * ready to act on and no heartbeat, or the autopilot's own decision still running with no model
240
+ * call landing and no heartbeat — a stalled model call, which nothing else times out. It checks a
241
+ * few times per window, and stops when the interaction settles.
242
+ */
243
+ private armWatchdog;
244
+ private disarmWatchdog;
245
+ private onDecided;
246
+ /**
247
+ * The autopilot's self-pause, for one interaction (§4.10): the person gets it, with the reason as
248
+ * the banner, and the autopilot carries on by itself once they answer. Only while it is still
249
+ * the autopilot's to hand back — not settled, not already with the person — and its decision
250
+ * stops with it, so a decision still running spends nothing more on an interaction it no longer
251
+ * holds. Every caller (a decision's own hand-back, a failed decision, the watchdog) gets both.
252
+ */
253
+ private handBack;
254
+ /**
255
+ * On detach: hand a claimed interaction the autopilot still holds to the person, stopping its
256
+ * decision, so the driver it wrapped lives on with nothing held by an autopilot that is gone.
257
+ */
258
+ private releaseHeld;
259
+ /** A claimed interaction settled, whoever settled it. */
260
+ private onSettled;
261
+ private onFlowOwnerChanged;
262
+ private capabilityFor;
263
+ private flowOwner;
264
+ private bindingFor;
265
+ private isAvailable;
266
+ private copyFor;
267
+ private sessionFor;
268
+ private record;
269
+ private notify;
270
+ }
271
+ /**
272
+ * The autopilot a host installed, if `driver` is one (GENC-1660). The host installs it outermost,
273
+ * so this is the driver it holds; nothing about the autopilot travels through `AiDriver`.
274
+ *
275
+ * @internal
276
+ */
277
+ export declare const autopilotOf: (driver: unknown) => AutopilotDriver | undefined;
278
+ //# sourceMappingURL=autopilot-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autopilot-driver.d.ts","sourceRoot":"","sources":["../../../src/autopilot/autopilot-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,KAAK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H,WAAW;IA4BzB,+EAA+E;IAC/E,OAAO,CAAC,kBAAkB;IAO1B;;;;;;;;;OASG;YACW,MAAM;IAoDpB;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAIhB,2EAA2E;IAC3E,OAAO,CAAC,YAAY;IAcpB;;;OAGG;YACW,eAAe;IA4D7B;;;;OAIG;IACM,sBAAsB,IAAI,aAAa,CAAC,eAAe,CAAC;IAQjE;;;OAGG;IACH,OAAO,CAAC,WAAW;IASJ,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IASvC,OAAO,CAAC,mBAAmB;IA4C3B,uEAAuE;IACvE,OAAO,CAAC,MAAM;IAqBd,uEAAuE;IACvE,OAAO,CAAC,OAAO;IAWf,sGAAsG;IACtG,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,eAAe;IAYvB,uFAAuF;IACvF,OAAO,CAAC,eAAe;IAOvB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IA+BnB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,SAAS;IAKjB;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAkBhB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAYnB,yDAAyD;IACzD,OAAO,CAAC,SAAS;IAgBjB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,MAAM;CASf;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,OAAO,KAAG,eAAe,GAAG,SACR,CAAC"}
@@ -0,0 +1,163 @@
1
+ import type { AIProviderRegistry } from '@genesislcap/foundation-ai';
2
+ import type { AiDriver } from '../components/ai-driver/ai-driver';
3
+ import type { AutopilotBinding, AutopilotCopy } from '../config/config';
4
+ import type { DiagnosticEntry } from '../state/persistence/diagnostics';
5
+ import type { InteractionOpened } from '../types/interaction-interceptor';
6
+ /** What a decision may do, set by the driver from the mode and the refinement count. */
7
+ export interface DecisionOptions {
8
+ /** `false` when the person said "decide it yourself". */
9
+ readonly allowHandBack: boolean;
10
+ /** `false` past the refinement limit for this step. */
11
+ readonly allowReply: boolean;
12
+ /**
13
+ * Called the moment a written answer is accepted — before the working agent can ask its next
14
+ * question — so the refinement count is current when that question is decided.
15
+ */
16
+ readonly onReply?: () => void;
17
+ }
18
+ /**
19
+ * A numeric guard from an autopilot's config: the value when it is a positive, finite number, the
20
+ * fallback otherwise — so `0`, a negative or `NaN` cannot turn a guard into a hair trigger.
21
+ */
22
+ export declare const positiveOr: <T>(value: number | undefined, fallback: T) => number | T;
23
+ /**
24
+ * The newest `lines` that fit in `maxChars`, after one line saying how many earlier ones were left
25
+ * out: a transcript cut to size from the old end, since what the autopilot decides next turns on the
26
+ * recent past.
27
+ */
28
+ export declare function newestThatFit(lines: readonly string[], maxChars: number): string[];
29
+ /**
30
+ * How a decision ended, from the autopilot's side. `costUsd` is set on the outcome of a written
31
+ * question: what answering it cost, which has no interaction to be booked to, so the driver books it
32
+ * on the reply it sends on the user's behalf, or records it as dropped when it sends none. A widget
33
+ * decision's cost is booked to its interaction, and is not on the outcome.
34
+ */
35
+ export type DecisionOutcome =
36
+ /** It ran a widget action that settled the interaction. */
37
+ {
38
+ kind: 'acted';
39
+ action: string;
40
+ costUsd?: number;
41
+ }
42
+ /** It answered a written question; the driver sends `text` on the user's behalf. */
43
+ | {
44
+ kind: 'replied';
45
+ text: string;
46
+ costUsd?: number;
47
+ } | {
48
+ kind: 'handed-back';
49
+ reason: string;
50
+ trigger: 'model' | 'no-decision' | 'error' | 'budget';
51
+ costUsd?: number;
52
+ } | {
53
+ kind: 'aborted';
54
+ costUsd?: number;
55
+ };
56
+ /** What a session needs from the `AutopilotDriver` that owns it. */
57
+ export interface AutopilotSessionDeps {
58
+ /** The working agent this autopilot serves (its flow owner). */
59
+ readonly agentName: string;
60
+ readonly binding: AutopilotBinding;
61
+ readonly providerRegistry: AIProviderRegistry;
62
+ /** The working session's debug-log key: the autopilot's events go to the working timeline. */
63
+ readonly sessionKey: string;
64
+ /** The working driver, for its history (what the person saw) and cost booking. */
65
+ readonly working: AiDriver;
66
+ /** The claimant id the autopilot acts as. */
67
+ readonly claimant: string;
68
+ /** The autopilot's wording: the reasons it gives when it hands a decision back. */
69
+ readonly copy: AutopilotCopy;
70
+ }
71
+ /**
72
+ * One autopilot for one flow (GENC-1660): its own `ChatDriver`, its own history, and the last
73
+ * message of what the person has seen that it was told about. Each decision is one short turn on
74
+ * that driver, which ends when the autopilot acts or hands back.
75
+ *
76
+ * Its history holds only its own conversation — the decisions it was sent, its tool calls and
77
+ * their results — never the working agent's. What happened without it (answers the person gave,
78
+ * messages they typed, what the assistant showed) arrives at the top of the next decision as a
79
+ * `<since-last>` block, built from the working history by code. Its own messages in the working
80
+ * history (what it sent on the user's behalf) are left out of that block while its history holds
81
+ * them, and labelled as its own whenever it does not: on its first decision (after a reload, too),
82
+ * after a size rebuild, and when a compaction removed the last message it saw.
83
+ */
84
+ export declare class AutopilotSession {
85
+ private readonly deps;
86
+ private readonly driver;
87
+ /** The last message of the working history the autopilot was told about; see `SeenThrough`. */
88
+ private seen?;
89
+ private current?;
90
+ /** The tail of the decision queue: decisions run one after another, never interleaved. */
91
+ private queue;
92
+ /** Its own messages a size-bounded rebuild dropped, kept for the debug log. */
93
+ private readonly archived;
94
+ /** This session's own debug-log key; see `ownSessionKey`. */
95
+ private readonly ownKey;
96
+ /**
97
+ * When the decision in progress last showed progress: when it started, and each time its history
98
+ * moved (a model call or a tool result landing). For the watchdog, which hands back a decision
99
+ * that has stalled.
100
+ */
101
+ private progressAt?;
102
+ constructor(deps: AutopilotSessionDeps);
103
+ /**
104
+ * Decide one interaction this autopilot holds. Resolves when the autopilot's turn ends, however it
105
+ * ended; the interaction itself is settled (or handed back) by then, unless the turn was aborted.
106
+ *
107
+ * Queued behind any decision still unwinding — an aborted one finishes its in-flight call before
108
+ * it can stop — so a Resume straight after a Pause is not lost. Checked again when its turn
109
+ * comes: if the autopilot no longer holds the interaction, nothing is sent.
110
+ */
111
+ decide(opened: InteractionOpened, options: DecisionOptions): Promise<DecisionOutcome>;
112
+ /**
113
+ * Answer a written question the working agent ended its turn on (GENC-1660 §4.2): `replied` with
114
+ * the text to send on the user's behalf, or `handed-back`. Either way the outcome carries what it
115
+ * cost (see `DecisionOutcome`).
116
+ *
117
+ * Queued like `decide`, and checked again when its turn comes: if `stillWanted` says no — the
118
+ * person paused since it was asked — nothing is sent and it ends `aborted`.
119
+ */
120
+ answerQuestion(question: string, options: {
121
+ allowHandBack: boolean;
122
+ stillWanted?: () => boolean;
123
+ }): Promise<DecisionOutcome>;
124
+ /**
125
+ * Everything the autopilot did, as debug-log entries (§4.8): its turns (prompt, tools, model,
126
+ * usage), its messages (the decisions it was sent, its calls and their results) and its own
127
+ * events, tagged `delegate` and breadcrumbed with the agent it serves, so a replay can follow one
128
+ * decision from what it was shown to what it did and what it cost.
129
+ */
130
+ diagnostics(): DiagnosticEntry[];
131
+ /**
132
+ * The autopilot's own debug-log key: under the working session's, named for the agent it serves,
133
+ * and unique to this session, so two agents' autopilots never relabel each other's events and a
134
+ * later flow's session never reads an ended one's again. Cleared when the session is disposed,
135
+ * after the driver has harvested it.
136
+ */
137
+ private get ownSessionKey();
138
+ /**
139
+ * When the decision on `interactionId` last showed progress (it started, or a model call or tool
140
+ * result landed); `undefined` when no decision on it is running. Read by the watchdog.
141
+ */
142
+ decisionProgressAt(interactionId: string): number | undefined;
143
+ /** Stop the decision in progress: the person took it back, or it ended another way. */
144
+ abort(): void;
145
+ /**
146
+ * Stop, and drop its debug-log bucket. The owner harvests `diagnostics()` first. Cleared again once
147
+ * the aborted turn has unwound, so nothing it records on the way out is left behind.
148
+ */
149
+ dispose(): void;
150
+ private enqueue;
151
+ /**
152
+ * One turn on the autopilot's driver: the `<since-last>` block, then the decision. Ends when the
153
+ * autopilot acts, replies or hands back, when it passes its spend cap, or when it runs out of
154
+ * calls. Books what it cost to `interactionId`; for a written question, which has none, returns
155
+ * it on the outcome for the driver to book on its reply.
156
+ */
157
+ private runTurn;
158
+ /** The autopilot as an agent: its config's resolvers bound to the working agent's state. */
159
+ private agentConfig;
160
+ /** `widget_read`, `widget_act` and `hand_back`, acting on the decision in progress. */
161
+ private fixedHandlers;
162
+ }
163
+ //# sourceMappingURL=autopilot-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autopilot-session.d.ts","sourceRoot":"","sources":["../../../src/autopilot/autopilot-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAiC,MAAM,4BAA4B,CAAC;AAEpG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,KAAK,EAEV,gBAAgB,EAChB,aAAa,EAEd,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAW1E,wFAAwF;AACxF,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAiBD;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,OAAO,MAAM,GAAG,SAAS,EAAE,UAAU,CAAC,KAAG,MAAM,GAAG,CACK,CAAC;AAEtF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAQlF;AAaD;;;;;GAKG;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AuC;IACpD,+EAA+E;IAC/E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,6DAA6D;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC;;;;OAIG;IACH,OAAO,CAAC,UAAU,CAAC,CAAS;gBAEC,IAAI,EAAE,oBAAoB;IAoBvD;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAoBrF;;;;;;;OAOG;IACH,cAAc,CACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QAAE,aAAa,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,OAAO,CAAA;KAAE,GAC/D,OAAO,CAAC,eAAe,CAAC;IAU3B;;;;;OAKG;IACH,WAAW,IAAI,eAAe,EAAE;IAShC;;;;;OAKG;IACH,OAAO,KAAK,aAAa,GAExB;IAED;;;OAGG;IACH,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI7D,uFAAuF;IACvF,KAAK,IAAI,IAAI;IAMb;;;OAGG;IACH,OAAO,IAAI,IAAI;IAOf,OAAO,CAAC,OAAO;IAMf;;;;;OAKG;YACW,OAAO;IA0GrB,4FAA4F;IAC5F,OAAO,CAAC,WAAW;IAyBnB,uFAAuF;IACvF,OAAO,CAAC,aAAa;CAiHtB"}
@@ -0,0 +1,15 @@
1
+ import type { ChatToolDefinition } from '@genesislcap/foundation-ai';
2
+ /** Read the widget as it stands now. */
3
+ export declare const WIDGET_READ = "widget_read";
4
+ /** Run one of the widget's actions. */
5
+ export declare const WIDGET_ACT = "widget_act";
6
+ /** Hand this one decision to the person. */
7
+ export declare const HAND_BACK = "hand_back";
8
+ /**
9
+ * The autopilot's three fixed tools (GENC-1660 §4.2, §4.6). Fixed for every decision, so the cached
10
+ * prefix holds: what varies — the widget, its actions, their arguments — travels in the decision
11
+ * message, not here. Plain string and string-array fields only, which every provider accepts
12
+ * (critique round 2, N5: Gemini rejects a type-array union).
13
+ */
14
+ export declare const AUTOPILOT_TOOL_DEFINITIONS: ChatToolDefinition[];
15
+ //# sourceMappingURL=autopilot-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autopilot-tools.d.ts","sourceRoot":"","sources":["../../../src/autopilot/autopilot-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,wCAAwC;AACxC,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,uCAAuC;AACvC,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,4CAA4C;AAC5C,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,kBAAkB,EA4D1D,CAAC"}
@@ -0,0 +1,62 @@
1
+ import type { ChatMessage } from '@genesislcap/foundation-ai';
2
+ import type { InteractionSurface, SurfaceAction } from '../types/interaction-surface';
3
+ /**
4
+ * A widget as text: what the person saw (GENC-1660 §4.7). From its registration's `asText` when it
5
+ * has one; otherwise its name and a size-limited dump of its data — ugly, never wrong, and a nudge
6
+ * to register one.
7
+ */
8
+ export declare function widgetAsText(componentName: string, data: unknown, result?: unknown): string;
9
+ /** The numbered list of a surface's actions, and which name each number stands for. */
10
+ export interface RenderedActions {
11
+ readonly text: string;
12
+ /** `numbering[n - 1]` is the action named by number `n`. */
13
+ readonly numbering: readonly string[];
14
+ }
15
+ /**
16
+ * List a surface's actions for the model (GENC-1660 §4.2). Options are numbered from 1, so they are
17
+ * chosen by number rather than by retyping a label; platform-owned actions keep their names. An
18
+ * unavailable action is listed, and marked, so the model knows it exists but cannot take it.
19
+ */
20
+ export declare function renderActions(actions: readonly SurfaceAction[], options?: {
21
+ withholdReply?: boolean;
22
+ }): RenderedActions;
23
+ /** The current decision as one message for the autopilot (GENC-1660 §4.2). */
24
+ export declare function renderDecision(opts: {
25
+ interactionId: string;
26
+ componentName: string;
27
+ data: unknown;
28
+ surface: InteractionSurface;
29
+ /** Set when the person clicked Resume to say "decide it yourself": no hand-back this time. */
30
+ decideYourself?: boolean;
31
+ /** Set past the refinement limit: `reply` is withdrawn. */
32
+ withholdReply?: boolean;
33
+ }): RenderedActions;
34
+ /**
35
+ * A written question the working agent ended its turn on, as one message for the autopilot
36
+ * (GENC-1660 §4.2): answer it in the user's place, or hand it back.
37
+ */
38
+ export declare function renderQuestion(question: string, opts?: {
39
+ decideYourself?: boolean;
40
+ }): string;
41
+ /**
42
+ * What the person could see in `messages`, as lines, for the autopilot's `<since-last>` block
43
+ * (GENC-1660 §4.7). Built with the renderer's own visibility function at the default settings, so
44
+ * what the autopilot is told and what the person sees cannot drift: verbatim user messages and
45
+ * visible assistant output (driver notices included — hidden from the model is not hidden from the
46
+ * person); interactions by their text form and who answered. Never the working agent's hidden prose,
47
+ * tool calls or results: the autopilot checks proposals against its grounding, not against the
48
+ * argument that produced them.
49
+ *
50
+ * `claimant` is this autopilot's id. Its own messages — what it said to the person, and what it
51
+ * sent on the user's behalf — are left out while its own history holds them; `includeOwn` puts them
52
+ * in, labelled as its own, for when it does not (a first decision, a reload, a rebuild, or a
53
+ * compaction that removed what it last saw). `short` keeps the last entries verbatim and reduces
54
+ * older answered widgets to their first line — the form a catch-up after a long flow uses.
55
+ */
56
+ export declare function visibleTranscript(messages: readonly ChatMessage[], opts: {
57
+ claimant: string;
58
+ skipInteractionId?: string;
59
+ short?: boolean;
60
+ includeOwn?: boolean;
61
+ }): string[];
62
+ //# sourceMappingURL=decision-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-message.d.ts","sourceRoot":"","sources":["../../../src/autopilot/decision-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AA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Answer } from '../../types/interaction-surface';
3
+ /**
4
+ * The tag of the turn-level hand-back widget (GENC-1660 §4.10): what the autopilot shows when a
5
+ * working turn ends needing the person, and there is no widget to hand over.
6
+ *
7
+ * @beta
8
+ */
9
+ export declare const AUTOPILOT_HAND_BACK = "ai-autopilot-hand-back";
10
+ /**
11
+ * One choice the hand-back offers.
12
+ *
13
+ * @beta
14
+ */
15
+ export interface HandBackOption {
16
+ readonly id: HandBackChoice;
17
+ readonly label: string;
18
+ }
19
+ /**
20
+ * What the person can choose. `reply` carries their written answer to the working agent's
21
+ * question; the rest tell the autopilot what to do next.
22
+ *
23
+ * @beta
24
+ */
25
+ export type HandBackChoice = 'carry-on' | 'try-again' | 'compact' | 'pause' | 'reply';
26
+ /**
27
+ * The hand-back's inputs. Every word it shows comes from here, so it follows the autopilot's
28
+ * `AutopilotCopy`.
29
+ *
30
+ * @beta
31
+ */
32
+ export interface HandBackData {
33
+ /** Why the person is needed, in the assistant's voice. */
34
+ readonly message: string;
35
+ /** The working agent's question, when the turn ended on one. */
36
+ readonly question?: string;
37
+ readonly options: readonly HandBackOption[];
38
+ /** Whether a written answer is offered (a turn that ended on a question). */
39
+ readonly freeText?: boolean;
40
+ /** The label of the button that sends the written answer, with `freeText`. */
41
+ readonly sendLabel?: string;
42
+ }
43
+ /**
44
+ * What the hand-back resolves with.
45
+ *
46
+ * @beta
47
+ */
48
+ export interface HandBackResult {
49
+ readonly status: 'approved';
50
+ readonly payload: {
51
+ choice: HandBackChoice;
52
+ text?: string;
53
+ };
54
+ }
55
+ /**
56
+ * The hand-back's controller. DOM-free: it exposes the choices as a decision (so the visible
57
+ * transcript and the debug log describe it like any widget) and resolves through `ctx.resolve`. The
58
+ * hand-back is always `userOnly`, so nothing but the person ever answers it.
59
+ */
60
+ export declare class HandBackController {
61
+ readonly data: HandBackData;
62
+ private readonly ctx;
63
+ constructor(data: HandBackData, ctx: InteractionContext);
64
+ /** The person's choice, from the view's buttons or its text box. */
65
+ choose(answer: DecisionAnswer): void;
66
+ }
67
+ /** The hand-back as text: what the person saw, and what they chose. */
68
+ export declare function handBackAsText(data: unknown, result?: unknown): string;
69
+ //# sourceMappingURL=hand-back.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hand-back.controller.d.ts","sourceRoot":"","sources":["../../../../src/autopilot/hand-back/hand-back.controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAEtF;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,cAAc,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7D;AAED;;;;GAIG;AACH,qBAAa,kBAAkB;IAE3B,QAAQ,CAAC,IAAI,EAAE,YAAY;IAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG;gBADX,IAAI,EAAE,YAAY,EACV,GAAG,EAAE,kBAAkB;IAS1C,oEAAoE;IACpE,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;CAWrC;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAUtE"}
@@ -0,0 +1,22 @@
1
+ import { GenesisElement } from '@genesislcap/web-core';
2
+ import type { AiChatInteraction } from '../../types/ai-chat-widget';
3
+ import { type HandBackData, type HandBackResult } from './hand-back.controller';
4
+ /**
5
+ * The turn-level hand-back's view (GENC-1660 §4.10): the message, the working agent's question if
6
+ * there was one, and the choices. It only renders: choosing calls the controller, which resolves.
7
+ * Always the person's to answer (`userOnly`), so it never hides itself.
8
+ *
9
+ * @beta
10
+ */
11
+ export declare class AutopilotHandBack extends GenesisElement {
12
+ interactionId: string;
13
+ interaction?: AiChatInteraction<HandBackData, HandBackResult['payload']>;
14
+ draft: string;
15
+ get data(): HandBackData | undefined;
16
+ /** What was chosen, once resolved. */
17
+ get answer(): string | undefined;
18
+ private get controller();
19
+ choose(option: string): void;
20
+ reply(): void;
21
+ }
22
+ //# sourceMappingURL=hand-back.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hand-back.d.ts","sourceRoot":"","sources":["../../../../src/autopilot/hand-back/hand-back.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EAKf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAGL,KAAK,YAAY,EAEjB,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAyFhC;;;;;;GAMG;AACH,qBACa,iBAAkB,SAAQ,cAAc;IACnD,aAAa,SAAM;IACP,WAAW,CAAC,EAAE,iBAAiB,CAAC,YAAY,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IACzE,KAAK,SAAM;IAEvB,IAAI,IAAI,IAAI,YAAY,GAAG,SAAS,CAEnC;IAED,sCAAsC;IACtC,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAM/B;IAED,OAAO,KAAK,UAAU,GAIrB;IAED,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI5B,KAAK,IAAI,IAAI;CAId"}
@@ -0,0 +1,4 @@
1
+ export { AUTOPILOT_CLAIMANT, AutopilotDriver, type AutopilotCapability, type AutopilotDriverOptions, type AutopilotHost, type AutopilotHostState, type AutopilotMode, type PersistedAutopilotMode, } from './autopilot-driver';
2
+ export { AUTOPILOT_HAND_BACK, type HandBackChoice, type HandBackData, type HandBackOption, type HandBackResult, } from './hand-back/hand-back.controller';
3
+ export { AutopilotHandBack } from './hand-back/hand-back';
4
+ //# sourceMappingURL=index.d.ts.map