@runtypelabs/persona 4.17.0 → 4.18.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/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-BpWGm7_6.d.cts → types-DsmTD8TO.d.cts} +12 -0
- package/dist/animations/{types-BpWGm7_6.d.ts → types-DsmTD8TO.d.ts} +12 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/chunk-3I2S3I5P.js +1 -0
- package/dist/chunk-76IELU7F.js +1 -0
- package/dist/chunk-EFJBUH5F.js +1 -0
- package/dist/chunk-PDPVORUF.js +1 -0
- package/dist/chunk-Q735PSZL.js +1 -0
- package/dist/chunk-VK6JOIYJ.js +1 -0
- package/dist/codegen.cjs +4 -4
- package/dist/codegen.js +4 -4
- package/dist/{context-mentions-BTSTIBFC.js → context-mentions-MJL6S6P2.js} +1 -1
- package/dist/context-mentions.cjs +9 -8
- package/dist/context-mentions.d.cts +1224 -14
- package/dist/context-mentions.d.ts +1224 -14
- package/dist/context-mentions.js +9 -8
- package/dist/event-stream-view-4EZ7BGFK.js +1 -0
- package/dist/event-stream-view.cjs +129 -0
- package/dist/event-stream-view.d.cts +8384 -0
- package/dist/event-stream-view.d.ts +8384 -0
- package/dist/event-stream-view.js +129 -0
- package/dist/history-view-BD6OXLNA.js +898 -0
- package/dist/history-view.cjs +898 -0
- package/dist/history-view.d.cts +1461 -0
- package/dist/history-view.d.ts +1461 -0
- package/dist/history-view.js +898 -0
- package/dist/index.cjs +77 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2040 -21
- package/dist/index.d.ts +2040 -21
- package/dist/index.global.js +67 -66
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +77 -77
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js +5 -4
- package/dist/launcher.global.js.map +1 -1
- package/dist/plugin-kit.cjs +1 -1
- package/dist/plugin-kit.d.cts +0 -8
- package/dist/plugin-kit.d.ts +0 -8
- package/dist/plugin-kit.js +1 -1
- package/dist/smart-dom-reader.d.cts +1224 -14
- package/dist/smart-dom-reader.d.ts +1224 -14
- package/dist/theme-editor-preview.cjs +970 -73
- package/dist/theme-editor-preview.d.cts +1343 -15
- package/dist/theme-editor-preview.d.ts +1343 -15
- package/dist/theme-editor-preview.js +81 -81
- package/dist/theme-editor.cjs +7 -7
- package/dist/theme-editor.d.cts +1227 -15
- package/dist/theme-editor.d.ts +1227 -15
- package/dist/theme-editor.js +9 -9
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +226 -7
- package/dist/theme-reference.d.ts +226 -7
- package/dist/theme-reference.js +1 -1
- package/dist/webmcp-polyfill.js +2 -2
- package/dist/widget.css +1 -1
- package/package.json +18 -6
- package/src/client-history-rest.test.ts +1034 -0
- package/src/client-visitor-history.test.ts +596 -0
- package/src/client.ts +1040 -24
- package/src/components/artifact-inline.ts +8 -1
- package/src/components/artifact-pane.test.ts +278 -1
- package/src/components/artifact-pane.ts +135 -67
- package/src/components/artifact-preview.test.ts +14 -1
- package/src/components/artifact-preview.ts +9 -0
- package/src/components/header-builder.ts +3 -0
- package/src/components/header-layouts.test.ts +171 -7
- package/src/components/header-layouts.ts +83 -53
- package/src/components/header-parts.test.ts +154 -1
- package/src/components/header-parts.ts +266 -138
- package/src/components/history-confirm-dialog.ts +177 -0
- package/src/components/history-shell-copy.ts +99 -0
- package/src/components/history-view/announcer.ts +40 -0
- package/src/components/history-view/copy.ts +105 -0
- package/src/components/history-view/css.ts +1078 -0
- package/src/components/history-view/grouping.test.ts +142 -0
- package/src/components/history-view/grouping.ts +142 -0
- package/src/components/history-view/icons.ts +73 -0
- package/src/components/history-view/rows.ts +341 -0
- package/src/components/history-view/state.ts +309 -0
- package/src/components/history-view.test.ts +2660 -0
- package/src/components/history-view.ts +1891 -0
- package/src/components/launcher-surface.test.ts +133 -0
- package/src/components/launcher.test.ts +18 -0
- package/src/components/launcher.ts +7 -7
- package/src/components/panel.ts +17 -7
- package/src/components/welcome.ts +72 -2
- package/src/defaults.ts +36 -3
- package/src/event-stream-view-bundle.test.ts +69 -0
- package/src/event-stream-view-entry.ts +19 -0
- package/src/event-stream-view-loader.ts +31 -0
- package/src/event-stream-view.ts +19 -0
- package/src/generated/runtype-openapi-contract.ts +54 -4
- package/src/history-render.ts +325 -0
- package/src/history-view-bundle.test.ts +78 -0
- package/src/history-view-entry.ts +41 -0
- package/src/history-view-loader.test.ts +30 -0
- package/src/history-view-loader.ts +32 -0
- package/src/history-view.ts +28 -0
- package/src/index-core.ts +50 -2
- package/src/index-global.ts +55 -0
- package/src/internal/demo-history-provider.test.ts +402 -0
- package/src/internal/demo-history-provider.ts +689 -0
- package/src/internal/history-provider-registry.ts +25 -0
- package/src/internal/history-provider.ts +150 -0
- package/src/internal/runtype-history-provider.test.ts +313 -0
- package/src/internal/runtype-history-provider.ts +240 -0
- package/src/plugin-kit.test.ts +16 -0
- package/src/plugin-kit.ts +13 -5
- package/src/plugins/types.ts +177 -1
- package/src/session-history.test.ts +1397 -0
- package/src/session.ts +1200 -26
- package/src/styles/widget-styles.test.ts +133 -0
- package/src/styles/widget.css +227 -8
- package/src/theme-editor/preview-utils.test.ts +19 -0
- package/src/theme-editor/preview-utils.ts +15 -1
- package/src/theme-editor/preview.ts +7 -1
- package/src/theme-editor/role-mappings.ts +4 -1
- package/src/theme-editor/sections.test.ts +168 -1
- package/src/theme-editor/sections.ts +136 -7
- package/src/theme-editor/webmcp/summary.ts +16 -2
- package/src/theme-reference.ts +20 -6
- package/src/types/theme.ts +213 -7
- package/src/types.ts +927 -7
- package/src/ui.artifact-rail-resize.test.ts +235 -0
- package/src/ui.attachments-drop.test.ts +1 -0
- package/src/ui.header-update-stability.test.ts +2 -2
- package/src/ui.history-chunk.test.ts +72 -0
- package/src/ui.history-config-provider.test.ts +318 -0
- package/src/ui.history-controller.test.ts +711 -0
- package/src/ui.history-lifecycle.test.ts +456 -0
- package/src/ui.history-render-hooks.test.ts +904 -0
- package/src/ui.history-shell.test.ts +1887 -0
- package/src/ui.rail-overlay.test.ts +573 -0
- package/src/ui.rail-resize.test.ts +284 -0
- package/src/ui.rebuild-composer.test.ts +21 -0
- package/src/ui.render-welcome.test.ts +42 -0
- package/src/ui.shortcuts.test.ts +166 -0
- package/src/ui.ts +3071 -240
- package/src/utils/__fixtures__/client-conversation-history-wire.json +108 -0
- package/src/utils/artifact-file.ts +15 -0
- package/src/utils/artifact-gate.test.ts +4 -0
- package/src/utils/artifact-gate.ts +13 -17
- package/src/utils/artifact-resize.test.ts +28 -0
- package/src/utils/artifact-resize.ts +9 -2
- package/src/utils/buttons.ts +188 -1
- package/src/utils/config-merge.test.ts +91 -0
- package/src/utils/dropdown.ts +10 -1
- package/src/utils/history-messages.test.ts +284 -0
- package/src/utils/history-messages.ts +284 -0
- package/src/utils/icons.ts +3 -0
- package/src/utils/shortcuts.test.ts +288 -0
- package/src/utils/shortcuts.ts +221 -0
- package/src/utils/theme.test.ts +501 -4
- package/src/utils/theme.ts +42 -3
- package/src/utils/tokens.ts +153 -15
- package/src/utils/tooltip-timing.ts +4 -0
- package/src/utils/tooltip.test.ts +249 -7
- package/src/utils/tooltip.ts +146 -4
- package/src/utils/visitor-store.test.ts +425 -0
- package/src/utils/visitor-store.ts +337 -0
- package/dist/chunk-QJ4LV2KW.js +0 -1
|
@@ -0,0 +1,1461 @@
|
|
|
1
|
+
interface TooltipOptions {
|
|
2
|
+
/** The control the tooltip describes and positions against. */
|
|
3
|
+
anchor: HTMLElement;
|
|
4
|
+
/** Hover target. Defaults to `anchor`; wrappers make small icon buttons easier to hit. */
|
|
5
|
+
trigger?: HTMLElement;
|
|
6
|
+
/** Tooltip copy. A callback keeps live aria-label updates in sync. */
|
|
7
|
+
text: string | (() => string);
|
|
8
|
+
/**
|
|
9
|
+
* Muted chip after the label, e.g. a keyboard shortcut. Empty renders
|
|
10
|
+
* nothing. A callback is re-read on every reposition, like `text`.
|
|
11
|
+
*/
|
|
12
|
+
hint?: string | (() => string);
|
|
13
|
+
/** Whether the visual tooltip may open. The anchor's accessible name is unaffected. */
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
/** Gap between the control and tooltip, in pixels. */
|
|
16
|
+
gap?: number;
|
|
17
|
+
/** Minimum distance from viewport edges, in pixels. */
|
|
18
|
+
viewportPadding?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Hover wait before the first tooltip. Falls back to the widget
|
|
21
|
+
* `tooltip.delayMs` (default 200). Keyboard focus ignores this.
|
|
22
|
+
*/
|
|
23
|
+
delayMs?: number;
|
|
24
|
+
/**
|
|
25
|
+
* After a tooltip closes, later hovers in this window skip `delayMs`.
|
|
26
|
+
* Falls back to the widget `tooltip.skipDelayMs` (default 300).
|
|
27
|
+
*/
|
|
28
|
+
skipDelayMs?: number;
|
|
29
|
+
}
|
|
30
|
+
interface TooltipHandle {
|
|
31
|
+
readonly isOpen: boolean;
|
|
32
|
+
show(): void;
|
|
33
|
+
hide(): void;
|
|
34
|
+
reposition(): void;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type RuntypeExecutionStreamEvent = ({
|
|
39
|
+
agentId?: string;
|
|
40
|
+
agentName?: string;
|
|
41
|
+
config?: Record<string, unknown>;
|
|
42
|
+
executionId: string;
|
|
43
|
+
flowId?: string;
|
|
44
|
+
flowName?: string;
|
|
45
|
+
kind: "agent" | "flow";
|
|
46
|
+
maxTurns?: number;
|
|
47
|
+
seq: number;
|
|
48
|
+
source?: string;
|
|
49
|
+
startedAt: string;
|
|
50
|
+
totalSteps?: number;
|
|
51
|
+
type: "execution_start";
|
|
52
|
+
}) | ({
|
|
53
|
+
claudeManagedAgentId?: string;
|
|
54
|
+
completedAt?: string;
|
|
55
|
+
durationMs?: number;
|
|
56
|
+
executionId: string;
|
|
57
|
+
externalAgent?: {
|
|
58
|
+
contextId?: string;
|
|
59
|
+
taskId?: string;
|
|
60
|
+
};
|
|
61
|
+
failedSteps?: number;
|
|
62
|
+
finalOutput?: string;
|
|
63
|
+
iterations?: number;
|
|
64
|
+
kind: "agent" | "flow";
|
|
65
|
+
seq: number;
|
|
66
|
+
stepErrorCount?: number;
|
|
67
|
+
stopReason?: string;
|
|
68
|
+
success: boolean;
|
|
69
|
+
successfulSteps?: number;
|
|
70
|
+
totalCost?: number;
|
|
71
|
+
totalSteps?: number;
|
|
72
|
+
totalTokens?: {
|
|
73
|
+
input: number;
|
|
74
|
+
output: number;
|
|
75
|
+
};
|
|
76
|
+
totalTokensUsed?: number;
|
|
77
|
+
type: "execution_complete";
|
|
78
|
+
}) | ({
|
|
79
|
+
blockReason?: string;
|
|
80
|
+
code?: string;
|
|
81
|
+
completedAt?: string;
|
|
82
|
+
error: string | {
|
|
83
|
+
code: string;
|
|
84
|
+
details?: Record<string, unknown>;
|
|
85
|
+
message: string;
|
|
86
|
+
};
|
|
87
|
+
executionId: string;
|
|
88
|
+
kind: "agent" | "flow";
|
|
89
|
+
seq: number;
|
|
90
|
+
type: "execution_error";
|
|
91
|
+
upgradeUrl?: string;
|
|
92
|
+
}) | ({
|
|
93
|
+
executionId: string;
|
|
94
|
+
id: string;
|
|
95
|
+
iteration?: number;
|
|
96
|
+
role: "user" | "assistant" | "system";
|
|
97
|
+
seq: number;
|
|
98
|
+
turnIndex?: number;
|
|
99
|
+
type: "turn_start";
|
|
100
|
+
}) | ({
|
|
101
|
+
completedAt?: string;
|
|
102
|
+
content?: string;
|
|
103
|
+
cost?: number;
|
|
104
|
+
estimatedContextBreakdown?: {
|
|
105
|
+
categories: Record<string, {
|
|
106
|
+
chars: number;
|
|
107
|
+
estimatedTokens: number;
|
|
108
|
+
}>;
|
|
109
|
+
contextWindowSize?: number;
|
|
110
|
+
estimatedTotalTokens: number;
|
|
111
|
+
estimatedUtilizationPercent?: number;
|
|
112
|
+
};
|
|
113
|
+
executionId: string;
|
|
114
|
+
fallback?: {
|
|
115
|
+
attempts: Array<{
|
|
116
|
+
attempt: number;
|
|
117
|
+
error?: string;
|
|
118
|
+
model?: string;
|
|
119
|
+
success: boolean;
|
|
120
|
+
type: "retry" | "model" | "message" | "flow";
|
|
121
|
+
}>;
|
|
122
|
+
exhausted: boolean;
|
|
123
|
+
model?: string;
|
|
124
|
+
reason?: string | null;
|
|
125
|
+
used: boolean;
|
|
126
|
+
};
|
|
127
|
+
id: string;
|
|
128
|
+
iteration?: number;
|
|
129
|
+
role: "user" | "assistant" | "system";
|
|
130
|
+
seq: number;
|
|
131
|
+
stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
|
|
132
|
+
tokens?: {
|
|
133
|
+
input: number;
|
|
134
|
+
output: number;
|
|
135
|
+
};
|
|
136
|
+
type: "turn_complete";
|
|
137
|
+
}) | {
|
|
138
|
+
executionId: string;
|
|
139
|
+
id: string;
|
|
140
|
+
index?: number;
|
|
141
|
+
name?: string;
|
|
142
|
+
outputVariable?: string;
|
|
143
|
+
seq: number;
|
|
144
|
+
startedAt?: string;
|
|
145
|
+
stepType?: string;
|
|
146
|
+
totalSteps?: number;
|
|
147
|
+
type: "step_start";
|
|
148
|
+
} | ({
|
|
149
|
+
completedAt?: string;
|
|
150
|
+
cost?: number;
|
|
151
|
+
durationMs?: number;
|
|
152
|
+
error?: string;
|
|
153
|
+
executionId: string;
|
|
154
|
+
fallback?: {
|
|
155
|
+
attempts: Array<{
|
|
156
|
+
attempt: number;
|
|
157
|
+
error?: string;
|
|
158
|
+
model?: string;
|
|
159
|
+
success: boolean;
|
|
160
|
+
type: "retry" | "model" | "message" | "flow";
|
|
161
|
+
}>;
|
|
162
|
+
exhausted: boolean;
|
|
163
|
+
model?: string;
|
|
164
|
+
reason?: string | null;
|
|
165
|
+
used: boolean;
|
|
166
|
+
};
|
|
167
|
+
id: string;
|
|
168
|
+
name?: string;
|
|
169
|
+
result?: unknown;
|
|
170
|
+
seq: number;
|
|
171
|
+
stepType?: string;
|
|
172
|
+
stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
|
|
173
|
+
success?: boolean;
|
|
174
|
+
tokensUsed?: number;
|
|
175
|
+
type: "step_complete";
|
|
176
|
+
unresolvedVariables?: Array<string>;
|
|
177
|
+
}) | {
|
|
178
|
+
executionId: string;
|
|
179
|
+
id: string;
|
|
180
|
+
index?: number;
|
|
181
|
+
name?: string;
|
|
182
|
+
seq: number;
|
|
183
|
+
skippedAt?: string;
|
|
184
|
+
stepType?: string;
|
|
185
|
+
totalSteps?: number;
|
|
186
|
+
type: "step_skip";
|
|
187
|
+
when?: string;
|
|
188
|
+
} | ({
|
|
189
|
+
executionId: string;
|
|
190
|
+
id: string;
|
|
191
|
+
parentToolCallId?: string;
|
|
192
|
+
role?: "user" | "assistant" | "system";
|
|
193
|
+
seq: number;
|
|
194
|
+
stepId?: string;
|
|
195
|
+
turnId?: string;
|
|
196
|
+
type: "text_start";
|
|
197
|
+
}) | {
|
|
198
|
+
delta: string;
|
|
199
|
+
executionId: string;
|
|
200
|
+
id: string;
|
|
201
|
+
seq: number;
|
|
202
|
+
type: "text_delta";
|
|
203
|
+
} | {
|
|
204
|
+
executionId: string;
|
|
205
|
+
id: string;
|
|
206
|
+
seq: number;
|
|
207
|
+
text?: string;
|
|
208
|
+
type: "text_complete";
|
|
209
|
+
} | ({
|
|
210
|
+
executionId: string;
|
|
211
|
+
id: string;
|
|
212
|
+
parentToolCallId?: string;
|
|
213
|
+
scope?: "turn" | "loop";
|
|
214
|
+
seq: number;
|
|
215
|
+
type: "reasoning_start";
|
|
216
|
+
}) | {
|
|
217
|
+
delta: string;
|
|
218
|
+
executionId: string;
|
|
219
|
+
id: string;
|
|
220
|
+
seq: number;
|
|
221
|
+
type: "reasoning_delta";
|
|
222
|
+
} | ({
|
|
223
|
+
executionId: string;
|
|
224
|
+
id: string;
|
|
225
|
+
scope?: "turn" | "loop";
|
|
226
|
+
seq: number;
|
|
227
|
+
text?: string;
|
|
228
|
+
type: "reasoning_complete";
|
|
229
|
+
}) | ({
|
|
230
|
+
executionId: string;
|
|
231
|
+
id: string;
|
|
232
|
+
mediaType: string;
|
|
233
|
+
role?: "user" | "assistant" | "system";
|
|
234
|
+
seq: number;
|
|
235
|
+
toolCallId?: string;
|
|
236
|
+
type: "media_start";
|
|
237
|
+
}) | {
|
|
238
|
+
delta: string;
|
|
239
|
+
executionId: string;
|
|
240
|
+
id: string;
|
|
241
|
+
seq: number;
|
|
242
|
+
type: "media_delta";
|
|
243
|
+
} | {
|
|
244
|
+
data?: string;
|
|
245
|
+
executionId: string;
|
|
246
|
+
id: string;
|
|
247
|
+
mediaType?: string;
|
|
248
|
+
seq: number;
|
|
249
|
+
toolCallId?: string;
|
|
250
|
+
type: "media_complete";
|
|
251
|
+
url?: string;
|
|
252
|
+
} | ({
|
|
253
|
+
artifactType: "markdown" | "component";
|
|
254
|
+
component?: string;
|
|
255
|
+
executionId?: string;
|
|
256
|
+
file?: {
|
|
257
|
+
language?: string;
|
|
258
|
+
mimeType: string;
|
|
259
|
+
path: string;
|
|
260
|
+
};
|
|
261
|
+
id: string;
|
|
262
|
+
seq?: number;
|
|
263
|
+
title?: string;
|
|
264
|
+
type: "artifact_start";
|
|
265
|
+
}) | {
|
|
266
|
+
delta: string;
|
|
267
|
+
executionId?: string;
|
|
268
|
+
id: string;
|
|
269
|
+
seq?: number;
|
|
270
|
+
type: "artifact_delta";
|
|
271
|
+
} | {
|
|
272
|
+
component: string;
|
|
273
|
+
executionId?: string;
|
|
274
|
+
id: string;
|
|
275
|
+
props: Record<string, unknown>;
|
|
276
|
+
seq?: number;
|
|
277
|
+
type: "artifact_update";
|
|
278
|
+
} | {
|
|
279
|
+
executionId?: string;
|
|
280
|
+
id: string;
|
|
281
|
+
seq?: number;
|
|
282
|
+
type: "artifact_complete";
|
|
283
|
+
} | {
|
|
284
|
+
executionId: string;
|
|
285
|
+
id?: string;
|
|
286
|
+
seq: number;
|
|
287
|
+
sourceType?: string;
|
|
288
|
+
title?: string;
|
|
289
|
+
type: "source";
|
|
290
|
+
url?: string;
|
|
291
|
+
[key: string]: unknown;
|
|
292
|
+
} | {
|
|
293
|
+
executionId: string;
|
|
294
|
+
iteration?: number;
|
|
295
|
+
seq: number;
|
|
296
|
+
state: Record<string, unknown>;
|
|
297
|
+
type: "state_snapshot";
|
|
298
|
+
} | ({
|
|
299
|
+
executionId: string;
|
|
300
|
+
iteration?: number;
|
|
301
|
+
patch: Array<{
|
|
302
|
+
from?: string;
|
|
303
|
+
op: "add" | "remove" | "replace" | "move" | "copy" | "test";
|
|
304
|
+
path: string;
|
|
305
|
+
value?: unknown;
|
|
306
|
+
}>;
|
|
307
|
+
seq: number;
|
|
308
|
+
type: "state_delta";
|
|
309
|
+
}) | ({
|
|
310
|
+
executionId: string;
|
|
311
|
+
hiddenParameterNames?: Array<string>;
|
|
312
|
+
iteration?: number;
|
|
313
|
+
origin?: "webmcp" | "sdk";
|
|
314
|
+
pageOrigin?: string;
|
|
315
|
+
parameters?: Record<string, unknown>;
|
|
316
|
+
seq: number;
|
|
317
|
+
startedAt?: string;
|
|
318
|
+
stepId?: string;
|
|
319
|
+
toolCallId: string;
|
|
320
|
+
toolName: string;
|
|
321
|
+
toolType: string;
|
|
322
|
+
type: "tool_start";
|
|
323
|
+
}) | {
|
|
324
|
+
delta: string;
|
|
325
|
+
executionId: string;
|
|
326
|
+
seq: number;
|
|
327
|
+
toolCallId: string;
|
|
328
|
+
type: "tool_input_delta";
|
|
329
|
+
} | {
|
|
330
|
+
executionId: string;
|
|
331
|
+
hiddenParameterNames?: Array<string>;
|
|
332
|
+
parameters: Record<string, unknown>;
|
|
333
|
+
seq: number;
|
|
334
|
+
toolCallId: string;
|
|
335
|
+
toolName?: string;
|
|
336
|
+
type: "tool_input_complete";
|
|
337
|
+
} | {
|
|
338
|
+
delta: string;
|
|
339
|
+
executionId: string;
|
|
340
|
+
seq: number;
|
|
341
|
+
toolCallId: string;
|
|
342
|
+
type: "tool_output_delta";
|
|
343
|
+
} | {
|
|
344
|
+
error?: string;
|
|
345
|
+
executionId: string;
|
|
346
|
+
executionTime?: number;
|
|
347
|
+
iteration?: number;
|
|
348
|
+
result?: unknown;
|
|
349
|
+
seq: number;
|
|
350
|
+
stepId?: string;
|
|
351
|
+
success: boolean;
|
|
352
|
+
toolCallId: string;
|
|
353
|
+
toolCost?: number;
|
|
354
|
+
toolName?: string;
|
|
355
|
+
type: "tool_complete";
|
|
356
|
+
} | {
|
|
357
|
+
approvalId: string;
|
|
358
|
+
description?: string;
|
|
359
|
+
executionId: string;
|
|
360
|
+
externalAgent?: {
|
|
361
|
+
contextId?: string;
|
|
362
|
+
taskId?: string;
|
|
363
|
+
};
|
|
364
|
+
iteration?: number;
|
|
365
|
+
parameters?: Record<string, unknown>;
|
|
366
|
+
reason?: string;
|
|
367
|
+
seq: number;
|
|
368
|
+
startedAt?: string;
|
|
369
|
+
subagent?: {
|
|
370
|
+
agentName?: string;
|
|
371
|
+
parentToolCallId?: string;
|
|
372
|
+
toolName: string;
|
|
373
|
+
};
|
|
374
|
+
timeout?: number;
|
|
375
|
+
toolCallId?: string;
|
|
376
|
+
toolName: string;
|
|
377
|
+
toolType?: string;
|
|
378
|
+
type: "approval_start";
|
|
379
|
+
} | ({
|
|
380
|
+
approvalId: string;
|
|
381
|
+
completedAt?: string;
|
|
382
|
+
decision: "approved" | "denied" | "timeout";
|
|
383
|
+
executionId: string;
|
|
384
|
+
resolvedBy?: "user" | "system";
|
|
385
|
+
seq: number;
|
|
386
|
+
type: "approval_complete";
|
|
387
|
+
}) | ({
|
|
388
|
+
awaitReason?: string;
|
|
389
|
+
awaitedAt?: string;
|
|
390
|
+
crawlId?: string;
|
|
391
|
+
elicitation?: {
|
|
392
|
+
message: string;
|
|
393
|
+
mode: "form" | "url";
|
|
394
|
+
pauseCount?: number;
|
|
395
|
+
requestedSchema?: Record<string, unknown>;
|
|
396
|
+
requests?: Array<{
|
|
397
|
+
message: string;
|
|
398
|
+
mode: "form" | "url";
|
|
399
|
+
name: string;
|
|
400
|
+
requestedSchema?: Record<string, unknown>;
|
|
401
|
+
url?: string;
|
|
402
|
+
}>;
|
|
403
|
+
serverName?: string;
|
|
404
|
+
url?: string;
|
|
405
|
+
};
|
|
406
|
+
executionId: string;
|
|
407
|
+
externalAgent?: {
|
|
408
|
+
contextId?: string;
|
|
409
|
+
taskId?: string;
|
|
410
|
+
};
|
|
411
|
+
origin?: "webmcp" | "sdk";
|
|
412
|
+
pageOrigin?: string;
|
|
413
|
+
parameters?: Record<string, unknown>;
|
|
414
|
+
seq: number;
|
|
415
|
+
stepId?: string;
|
|
416
|
+
toolCallId?: string;
|
|
417
|
+
toolId?: string;
|
|
418
|
+
toolName?: string;
|
|
419
|
+
type: "await";
|
|
420
|
+
}) | ({
|
|
421
|
+
error: string | {
|
|
422
|
+
code: string;
|
|
423
|
+
details?: Record<string, unknown>;
|
|
424
|
+
message: string;
|
|
425
|
+
};
|
|
426
|
+
executionId: string;
|
|
427
|
+
recoverable?: boolean;
|
|
428
|
+
seq: number;
|
|
429
|
+
type: "error";
|
|
430
|
+
}) | {
|
|
431
|
+
executionId: string;
|
|
432
|
+
seq: number;
|
|
433
|
+
timestamp: string;
|
|
434
|
+
type: "ping";
|
|
435
|
+
} | {
|
|
436
|
+
executionId?: string;
|
|
437
|
+
name: string;
|
|
438
|
+
seq?: number;
|
|
439
|
+
type: "custom";
|
|
440
|
+
value?: unknown;
|
|
441
|
+
};
|
|
442
|
+
type RuntypeStreamEventOf<U, T extends string> = Extract<U, {
|
|
443
|
+
type: T;
|
|
444
|
+
}>;
|
|
445
|
+
type RuntypeTurnCompleteEvent = RuntypeStreamEventOf<RuntypeExecutionStreamEvent, "turn_complete">;
|
|
446
|
+
type RuntypeStepCompleteEvent = RuntypeStreamEventOf<RuntypeExecutionStreamEvent, "step_complete">;
|
|
447
|
+
type RuntypeStopReasonKind = NonNullable<RuntypeTurnCompleteEvent["stopReason"] | RuntypeStepCompleteEvent["stopReason"]>;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* History provider seam (`docs/visitor-history-implementation-plan.md` D9).
|
|
451
|
+
* Session/UI history code depends on this interface, never on
|
|
452
|
+
* `AgentWidgetClient`.
|
|
453
|
+
*
|
|
454
|
+
* The module stays under `internal/` but its contract is public: `index-core.ts`
|
|
455
|
+
* re-exports these declarations so integrators can implement
|
|
456
|
+
* `features.history.provider`. The provider REGISTRY beside it stays private.
|
|
457
|
+
*/
|
|
458
|
+
|
|
459
|
+
/** Fixed for the lifetime of one opened history view/action chain. */
|
|
460
|
+
interface HistoryOperationContext {
|
|
461
|
+
scope: HistoryScope;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* An authorized-but-not-yet-applied conversation activation. The provider must
|
|
465
|
+
* not mutate the active chat until `commit()`.
|
|
466
|
+
*/
|
|
467
|
+
interface PreparedHistoryActivation {
|
|
468
|
+
conversationId: string;
|
|
469
|
+
conversationRevision: string;
|
|
470
|
+
/** Apply the already-authorized provider-specific transport/session binding. */
|
|
471
|
+
commit(): void | Promise<void>;
|
|
472
|
+
/** Idempotently abandon a stale/superseded activation without changing chat. */
|
|
473
|
+
discard(): void;
|
|
474
|
+
}
|
|
475
|
+
interface HistoryListOptions {
|
|
476
|
+
cursor?: string;
|
|
477
|
+
limit?: number;
|
|
478
|
+
targetId?: string;
|
|
479
|
+
context: HistoryOperationContext;
|
|
480
|
+
}
|
|
481
|
+
interface HistoryListResult {
|
|
482
|
+
items: HistoryConversationSummary[];
|
|
483
|
+
nextCursor: string | null;
|
|
484
|
+
}
|
|
485
|
+
interface HistoryPageOptions {
|
|
486
|
+
cursor?: string;
|
|
487
|
+
/** Lets the provider synthesize stable timestamps across page boundaries. */
|
|
488
|
+
beforeCreatedAt?: string;
|
|
489
|
+
context: HistoryOperationContext;
|
|
490
|
+
}
|
|
491
|
+
interface HistoryPageResult {
|
|
492
|
+
summary: HistoryConversationSummary;
|
|
493
|
+
/** Already mapped; the visitor-visible projection lives in `content`. */
|
|
494
|
+
messages: AgentWidgetMessage[];
|
|
495
|
+
conversationRevision: string;
|
|
496
|
+
/** Follow for the next older page. `null` at the start of the transcript. */
|
|
497
|
+
nextCursor: string | null;
|
|
498
|
+
}
|
|
499
|
+
interface HistoryDeleteAllOptions {
|
|
500
|
+
/** Absent means the whole authorized scope, never the UI default. */
|
|
501
|
+
targetId?: string;
|
|
502
|
+
context: HistoryOperationContext;
|
|
503
|
+
}
|
|
504
|
+
/** The contract a `features.history.provider` implementation satisfies. */
|
|
505
|
+
interface HistoryProvider {
|
|
506
|
+
readonly capabilities: {
|
|
507
|
+
scopes: readonly HistoryScope[];
|
|
508
|
+
};
|
|
509
|
+
getIdentityStatus(): HistoryIdentityStatus;
|
|
510
|
+
subscribeIdentityStatus(callback: (status: HistoryIdentityStatus) => void): () => void;
|
|
511
|
+
list(opts: HistoryListOptions): Promise<HistoryListResult>;
|
|
512
|
+
getPage(id: string, opts: HistoryPageOptions): Promise<HistoryPageResult>;
|
|
513
|
+
prepareOpen(id: string, opts: {
|
|
514
|
+
context: HistoryOperationContext;
|
|
515
|
+
}): Promise<PreparedHistoryActivation>;
|
|
516
|
+
prepareStartNew(opts: {
|
|
517
|
+
context: HistoryOperationContext;
|
|
518
|
+
}): Promise<PreparedHistoryActivation>;
|
|
519
|
+
delete(id: string, opts: {
|
|
520
|
+
context: HistoryOperationContext;
|
|
521
|
+
}): Promise<void>;
|
|
522
|
+
deleteAll(opts: HistoryDeleteAllOptions): Promise<{
|
|
523
|
+
deleted: number;
|
|
524
|
+
}>;
|
|
525
|
+
/**
|
|
526
|
+
* Optional capability: visitor-scoped rename/star. Absence hides every
|
|
527
|
+
* update affordance (star glyphs, built-in title-menu actions). A user-set
|
|
528
|
+
* title pins: the provider must never let a later auto-generated title
|
|
529
|
+
* overwrite one set through this call.
|
|
530
|
+
*/
|
|
531
|
+
update?(id: string, patch: HistoryConversationPatch, opts: {
|
|
532
|
+
context: HistoryOperationContext;
|
|
533
|
+
}): Promise<HistoryConversationSummary>;
|
|
534
|
+
/**
|
|
535
|
+
* Optional capability. Absence hides "forget this device". Resolves (never
|
|
536
|
+
* rejects) on remote failure; credentials are cleared in `finally` either way.
|
|
537
|
+
*/
|
|
538
|
+
resetDevice?(): Promise<{
|
|
539
|
+
remoteRevocationConfirmed: boolean;
|
|
540
|
+
}>;
|
|
541
|
+
subscribeAvailability?(callback: (available: boolean) => void): () => void;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Text content part for multi-modal messages
|
|
546
|
+
*/
|
|
547
|
+
type TextContentPart = {
|
|
548
|
+
type: 'text';
|
|
549
|
+
text: string;
|
|
550
|
+
};
|
|
551
|
+
/**
|
|
552
|
+
* Image content part for multi-modal messages
|
|
553
|
+
* Supports base64 data URIs or URLs
|
|
554
|
+
*/
|
|
555
|
+
type ImageContentPart = {
|
|
556
|
+
type: 'image';
|
|
557
|
+
image: string;
|
|
558
|
+
mimeType?: string;
|
|
559
|
+
alt?: string;
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* File content part for multi-modal messages
|
|
563
|
+
* Supports PDF, TXT, DOCX, and other document types
|
|
564
|
+
*/
|
|
565
|
+
type FileContentPart = {
|
|
566
|
+
type: 'file';
|
|
567
|
+
data: string;
|
|
568
|
+
mimeType: string;
|
|
569
|
+
filename: string;
|
|
570
|
+
};
|
|
571
|
+
/**
|
|
572
|
+
* Audio content part for multi-modal messages
|
|
573
|
+
* Supports base64 data URIs or URLs
|
|
574
|
+
*/
|
|
575
|
+
type AudioContentPart = {
|
|
576
|
+
type: 'audio';
|
|
577
|
+
audio: string;
|
|
578
|
+
mimeType?: string;
|
|
579
|
+
};
|
|
580
|
+
/**
|
|
581
|
+
* Video content part for multi-modal messages
|
|
582
|
+
* Supports base64 data URIs or URLs
|
|
583
|
+
*/
|
|
584
|
+
type VideoContentPart = {
|
|
585
|
+
type: 'video';
|
|
586
|
+
video: string;
|
|
587
|
+
mimeType?: string;
|
|
588
|
+
};
|
|
589
|
+
/**
|
|
590
|
+
* Union type for all content part types
|
|
591
|
+
*/
|
|
592
|
+
type ContentPart = TextContentPart | ImageContentPart | FileContentPart | AudioContentPart | VideoContentPart;
|
|
593
|
+
/** Reference stored on a sent message for transcript fidelity + chip rendering. */
|
|
594
|
+
type AgentWidgetContextMentionRef = {
|
|
595
|
+
sourceId: string;
|
|
596
|
+
itemId: string;
|
|
597
|
+
label: string;
|
|
598
|
+
iconName?: string;
|
|
599
|
+
/** Accent color for the inline token (see `AgentWidgetContextMentionItem.color`). */
|
|
600
|
+
color?: string;
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* One ordered segment of a sent message's prose, for inline mention rendering
|
|
604
|
+
* (`contextMentions.display: "inline"`). Text runs and atomic mention tokens
|
|
605
|
+
* interleave in document order so the sent bubble re-renders `@tokens` in place
|
|
606
|
+
* and composer history can round-trip them. Display/transcript concern only —
|
|
607
|
+
* the model still sees resolved bodies via `llmContent`/`contentParts`.
|
|
608
|
+
*/
|
|
609
|
+
type AgentWidgetContentSegment = {
|
|
610
|
+
kind: "text";
|
|
611
|
+
text: string;
|
|
612
|
+
} | {
|
|
613
|
+
kind: "mention";
|
|
614
|
+
ref: AgentWidgetContextMentionRef;
|
|
615
|
+
};
|
|
616
|
+
/**
|
|
617
|
+
* Metadata attached to messages created during agent execution.
|
|
618
|
+
*/
|
|
619
|
+
type AgentMessageMetadata = {
|
|
620
|
+
executionId?: string;
|
|
621
|
+
iteration?: number;
|
|
622
|
+
turnId?: string;
|
|
623
|
+
agentName?: string;
|
|
624
|
+
/**
|
|
625
|
+
* When this message was produced by a step inside a nested flow executed
|
|
626
|
+
* as a tool, identifies the parent tool call id. Enables renderers to
|
|
627
|
+
* visually group or indent nested-flow output under its parent tool.
|
|
628
|
+
*/
|
|
629
|
+
parentToolId?: string;
|
|
630
|
+
/**
|
|
631
|
+
* Nested flow step id that produced this message (e.g. a `send-stream`
|
|
632
|
+
* or `prompt` step inside the nested flow). Stable key for that step.
|
|
633
|
+
*/
|
|
634
|
+
parentStepId?: string;
|
|
635
|
+
/**
|
|
636
|
+
* Set to `true` on a tool-variant message produced from a `step_await`
|
|
637
|
+
* event (`awaitReason: "local_tool_required"`). Signals to UI code that
|
|
638
|
+
* the tool call is a LOCAL tool and the server is paused waiting for a
|
|
639
|
+
* `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
|
|
640
|
+
*/
|
|
641
|
+
awaitingLocalTool?: boolean;
|
|
642
|
+
/**
|
|
643
|
+
* The provider per-call id (`toolu_…`) carried on the `step_await` /
|
|
644
|
+
* `flow_await` events for a LOCAL tool (core#3878). Present only when the
|
|
645
|
+
* server emits it. Two PARALLEL calls to the same tool in one turn share a
|
|
646
|
+
* `toolName` (and a collapsed `toolId`) but get DISTINCT `webMcpToolCallId`s,
|
|
647
|
+
* so this is the key the widget batches a single `/resume` on: preferred
|
|
648
|
+
* over tool name, which collides for same-tool parallel calls. Absent →
|
|
649
|
+
* fall back to the legacy name-keyed resume contract.
|
|
650
|
+
*/
|
|
651
|
+
webMcpToolCallId?: string;
|
|
652
|
+
/**
|
|
653
|
+
* Set to `true` once the user has picked / typed / dismissed an answer for
|
|
654
|
+
* an `ask_user_question` tool call, so renderers stop re-mounting the
|
|
655
|
+
* answer-pill sheet for this tool call on subsequent render passes.
|
|
656
|
+
*/
|
|
657
|
+
askUserQuestionAnswered?: boolean;
|
|
658
|
+
/**
|
|
659
|
+
* In-progress answers for a multi-question `ask_user_question` payload,
|
|
660
|
+
* keyed by question text. Persisted across refresh so the user lands back
|
|
661
|
+
* where they were if the page reloads mid-flow. Cleared once
|
|
662
|
+
* `askUserQuestionAnswered` flips to `true`.
|
|
663
|
+
*/
|
|
664
|
+
askUserQuestionAnswers?: Record<string, string | string[]>;
|
|
665
|
+
/**
|
|
666
|
+
* Current page index for a multi-question `ask_user_question` payload's
|
|
667
|
+
* paginated stepper. Persists alongside `askUserQuestionAnswers`.
|
|
668
|
+
*/
|
|
669
|
+
askUserQuestionIndex?: number;
|
|
670
|
+
/**
|
|
671
|
+
* Set to `true` once a `suggest_replies` tool call's fire-and-forget
|
|
672
|
+
* `/resume` has been accepted by the server. Persisted belt-and-suspenders
|
|
673
|
+
* mirror of the in-memory resolved-key dedupe, so hydration/re-emit paths
|
|
674
|
+
* never re-resume the call.
|
|
675
|
+
*/
|
|
676
|
+
suggestRepliesResolved?: boolean;
|
|
677
|
+
};
|
|
678
|
+
/**
|
|
679
|
+
* Copy overrides for the visitor-facing conversation history surface. These are
|
|
680
|
+
* the widget's only localization mechanism for history, so every user-visible
|
|
681
|
+
* history string is listed here.
|
|
682
|
+
*/
|
|
683
|
+
interface AgentWidgetHistoryCopy {
|
|
684
|
+
/** Title of the history view. Defaults to "Messages". */
|
|
685
|
+
viewTitle?: string;
|
|
686
|
+
/** Heading shown when the visitor has no stored conversations. */
|
|
687
|
+
emptyTitle?: string;
|
|
688
|
+
/** Body text shown when the visitor has no stored conversations. */
|
|
689
|
+
emptyDescription?: string;
|
|
690
|
+
/** Heading shown when a history request fails. */
|
|
691
|
+
errorTitle?: string;
|
|
692
|
+
/** Body text shown when a history request fails. */
|
|
693
|
+
errorDescription?: string;
|
|
694
|
+
/** Label for the retry action on the error state. */
|
|
695
|
+
retryLabel?: string;
|
|
696
|
+
/** Heading shown after a 429 rate-limited history response. */
|
|
697
|
+
rateLimitedTitle?: string;
|
|
698
|
+
/** Body text shown after a 429 rate-limited history response. */
|
|
699
|
+
rateLimitedDescription?: string;
|
|
700
|
+
/** Confirmation prompt before deleting a single conversation. */
|
|
701
|
+
deleteConversationConfirm?: string;
|
|
702
|
+
/** Confirmation prompt before deleting every conversation in the active scope. */
|
|
703
|
+
clearHistoryConfirm?: string;
|
|
704
|
+
/** Confirmation prompt before detaching this browser from its history identity. */
|
|
705
|
+
resetIdentityConfirm?: string;
|
|
706
|
+
/** Label for the action that starts a new server conversation. */
|
|
707
|
+
newConversationLabel?: string;
|
|
708
|
+
/** Label for the action that prepends the previous transcript page. */
|
|
709
|
+
showEarlierMessagesLabel?: string;
|
|
710
|
+
/** Accessible label for the transcript skeleton while a conversation loads. */
|
|
711
|
+
openConversationLoadingLabel?: string;
|
|
712
|
+
/** Body text when a selected conversation failed to load. */
|
|
713
|
+
openConversationErrorTitle?: string;
|
|
714
|
+
/** Label for the retry action after a conversation failed to load. */
|
|
715
|
+
openConversationRetryLabel?: string;
|
|
716
|
+
/** Label for the return-to-messages action after a conversation failed to load. */
|
|
717
|
+
openConversationBackLabel?: string;
|
|
718
|
+
/** Status notice after a deleted conversation was recovered into a fresh one. */
|
|
719
|
+
conversationDeletedNotice?: string;
|
|
720
|
+
/** Status notice after this browser was detached from its history identity. */
|
|
721
|
+
identityResetNotice?: string;
|
|
722
|
+
/** Status notice when a local reset succeeded but server revocation was unconfirmed. */
|
|
723
|
+
identityResetUnconfirmedNotice?: string;
|
|
724
|
+
/** Pinned group heading for starred conversations. */
|
|
725
|
+
groupStarred?: string;
|
|
726
|
+
/** Time-group heading for conversations updated today. */
|
|
727
|
+
groupToday?: string;
|
|
728
|
+
/** Time-group heading for conversations updated yesterday. */
|
|
729
|
+
groupYesterday?: string;
|
|
730
|
+
/** Time-group heading for the trailing 7-day window. */
|
|
731
|
+
groupPrevious7Days?: string;
|
|
732
|
+
/** Time-group heading for the trailing 30-day window. */
|
|
733
|
+
groupPrevious30Days?: string;
|
|
734
|
+
/** Time-group heading for older conversations, grouped by month and year. */
|
|
735
|
+
groupMonthYear?: string;
|
|
736
|
+
/** Scope title when history is limited to this browser. */
|
|
737
|
+
browserOnlyTitle?: string;
|
|
738
|
+
/** Scope description when history is limited to this browser. */
|
|
739
|
+
browserOnlyDescription?: string;
|
|
740
|
+
/** Scope title while an identity proof is being resolved. */
|
|
741
|
+
verifyingTitle?: string;
|
|
742
|
+
/** Scope description while an identity proof is being resolved. */
|
|
743
|
+
verifyingDescription?: string;
|
|
744
|
+
/** Scope title when history is available across signed-in devices. */
|
|
745
|
+
verifiedTitle?: string;
|
|
746
|
+
/** Scope description when history is available across signed-in devices. */
|
|
747
|
+
verifiedDescription?: string;
|
|
748
|
+
/** Scope title when the visitor must sign in again to view account history. */
|
|
749
|
+
authenticationRequiredTitle?: string;
|
|
750
|
+
/** Scope description when the visitor must sign in again to view account history. */
|
|
751
|
+
authenticationRequiredDescription?: string;
|
|
752
|
+
/** Scope title when the host identity provider threw or rejected. */
|
|
753
|
+
identityProviderFailedTitle?: string;
|
|
754
|
+
/** Scope description when the host identity provider threw or rejected. */
|
|
755
|
+
identityProviderFailedDescription?: string;
|
|
756
|
+
/** Scope title when the server did not admit a supplied identity proof. */
|
|
757
|
+
proofNotAdmittedTitle?: string;
|
|
758
|
+
/** Scope description when the server did not admit a supplied identity proof. */
|
|
759
|
+
proofNotAdmittedDescription?: string;
|
|
760
|
+
/** Label for the action that retries identity resolution. */
|
|
761
|
+
retryIdentityLabel?: string;
|
|
762
|
+
/** Accessible name of the header control that opens history. */
|
|
763
|
+
openHistoryLabel?: string;
|
|
764
|
+
/** Accessible name of that control while a turn is streaming or resuming. */
|
|
765
|
+
openHistoryBusyLabel?: string;
|
|
766
|
+
/** Least-destructive action in every history confirmation dialog. */
|
|
767
|
+
confirmCancelLabel?: string;
|
|
768
|
+
/** Heading of the delete-one confirmation. */
|
|
769
|
+
deleteConversationConfirmTitle?: string;
|
|
770
|
+
/** Confirming action of the delete-one confirmation. */
|
|
771
|
+
deleteConversationConfirmLabel?: string;
|
|
772
|
+
/** Heading of the delete-all confirmation. */
|
|
773
|
+
clearHistoryConfirmTitle?: string;
|
|
774
|
+
/** Confirming action of the delete-all confirmation. */
|
|
775
|
+
clearHistoryConfirmLabel?: string;
|
|
776
|
+
/** Delete-all body used when the resolved scope is the signed-in user. */
|
|
777
|
+
clearHistoryVerifiedConfirm?: string;
|
|
778
|
+
/** Heading of the forget-this-device confirmation. */
|
|
779
|
+
resetIdentityConfirmTitle?: string;
|
|
780
|
+
/** Confirming action of the forget-this-device confirmation. */
|
|
781
|
+
resetIdentityConfirmLabel?: string;
|
|
782
|
+
/** Panel back control; returns to the surface that opened Messages. */
|
|
783
|
+
backLabel?: string;
|
|
784
|
+
/** Rail close control, shown only when the rail is not collapsible. */
|
|
785
|
+
closeLabel?: string;
|
|
786
|
+
/** Rail collapse toggle while the rail is expanded. */
|
|
787
|
+
collapseLabel?: string;
|
|
788
|
+
/** Rail collapse toggle while the rail is collapsed to icons. */
|
|
789
|
+
expandLabel?: string;
|
|
790
|
+
/** Accessible name of the docked rail's drag-resize handle. */
|
|
791
|
+
resizeLabel?: string;
|
|
792
|
+
/** Accessible status while the first page loads. */
|
|
793
|
+
loadingLabel?: string;
|
|
794
|
+
/** Label of the paging action below the last group. */
|
|
795
|
+
loadMoreLabel?: string;
|
|
796
|
+
/** Label of that action while its page is in flight. */
|
|
797
|
+
loadingMoreLabel?: string;
|
|
798
|
+
/**
|
|
799
|
+
* Heading over the conversation list. Visible in rail presentation, where it
|
|
800
|
+
* carries the list overflow trigger; sr-only in panel presentation.
|
|
801
|
+
*/
|
|
802
|
+
conversationsTitle?: string;
|
|
803
|
+
/** Accessible name of the per-row overflow trigger and its menu. */
|
|
804
|
+
rowActionsLabel?: string;
|
|
805
|
+
/** Accessible name of the list-level overflow trigger and its menu. */
|
|
806
|
+
listOptionsLabel?: string;
|
|
807
|
+
/** Delete item inside the per-row overflow menu. */
|
|
808
|
+
deleteConversationLabel?: string;
|
|
809
|
+
/** Delete-all item inside the list overflow menu. */
|
|
810
|
+
clearHistoryLabel?: string;
|
|
811
|
+
/** Forget-this-device item inside the list overflow menu. */
|
|
812
|
+
resetIdentityLabel?: string;
|
|
813
|
+
/** Row message count. `{count}` placeholder. */
|
|
814
|
+
messageCountLabel?: string;
|
|
815
|
+
/** Row message count for exactly one message. */
|
|
816
|
+
messageCountLabelOne?: string;
|
|
817
|
+
/** Announced after a single conversation was deleted. */
|
|
818
|
+
conversationRemovedNotice?: string;
|
|
819
|
+
/** Announced after every conversation in scope was deleted. */
|
|
820
|
+
historyClearedNotice?: string;
|
|
821
|
+
/** Heading shown when history is unavailable for this surface. */
|
|
822
|
+
unavailableTitle?: string;
|
|
823
|
+
/** Body text shown when history is unavailable for this surface. */
|
|
824
|
+
unavailableDescription?: string;
|
|
825
|
+
/** Heading of the post-deletion replacement-init recovery state. */
|
|
826
|
+
newConversationRequiredTitle?: string;
|
|
827
|
+
/** Body text of the post-deletion replacement-init recovery state. */
|
|
828
|
+
newConversationRequiredDescription?: string;
|
|
829
|
+
/** Rate-limited wait guidance. `{seconds}` placeholder. */
|
|
830
|
+
rateLimitedWaitDescription?: string;
|
|
831
|
+
/** Row-adjacent error after a failed open. */
|
|
832
|
+
openFailedLabel?: string;
|
|
833
|
+
/** Row-adjacent error after a failed delete. */
|
|
834
|
+
deleteFailedLabel?: string;
|
|
835
|
+
/** Relative time for the most recent bucket. */
|
|
836
|
+
relativeNow?: string;
|
|
837
|
+
/** Relative time in minutes. `{value}` placeholder. */
|
|
838
|
+
relativeMinutes?: string;
|
|
839
|
+
/** Relative time in hours. `{value}` placeholder. */
|
|
840
|
+
relativeHours?: string;
|
|
841
|
+
/** Relative time in days. `{value}` placeholder. */
|
|
842
|
+
relativeDays?: string;
|
|
843
|
+
/** Relative time in weeks. `{value}` placeholder. */
|
|
844
|
+
relativeWeeks?: string;
|
|
845
|
+
/** Relative time in years. `{value}` placeholder. */
|
|
846
|
+
relativeYears?: string;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Host-defined item in the list overflow menu (the `…` beside the
|
|
850
|
+
* conversation-list heading). Rendered above the built-in destructive items.
|
|
851
|
+
*/
|
|
852
|
+
interface AgentWidgetHistoryListAction {
|
|
853
|
+
/** Stable identity; keeps menu focus keys stable across re-renders. */
|
|
854
|
+
id: string;
|
|
855
|
+
label: string;
|
|
856
|
+
/** Destructive (red) styling like the built-in delete-all. Default false. */
|
|
857
|
+
danger?: boolean;
|
|
858
|
+
/** Receives the conversation summaries loaded at selection time. */
|
|
859
|
+
onSelect: (context: {
|
|
860
|
+
conversations: HistoryConversationSummary[];
|
|
861
|
+
}) => void | Promise<void>;
|
|
862
|
+
}
|
|
863
|
+
/** Resolved scope for a logical history operation. */
|
|
864
|
+
type HistoryScope = "browser" | "verified-user";
|
|
865
|
+
/**
|
|
866
|
+
* Evidence-based history identity state. Never inferred from the mere presence
|
|
867
|
+
* of `getIdentityProof`, and never carries token, visitor, or end-user values.
|
|
868
|
+
*/
|
|
869
|
+
type HistoryIdentityStatus = {
|
|
870
|
+
state: "browser_only";
|
|
871
|
+
reason: "configured_browser_scope" | "no_identity_provider" | "proof_unavailable_before_binding";
|
|
872
|
+
} | {
|
|
873
|
+
state: "verifying";
|
|
874
|
+
} | {
|
|
875
|
+
state: "verified";
|
|
876
|
+
} | {
|
|
877
|
+
state: "authentication_required";
|
|
878
|
+
reason: "proof_unavailable_after_binding" | "invalid_identity_proof";
|
|
879
|
+
} | {
|
|
880
|
+
state: "identity_provider_failed";
|
|
881
|
+
} | {
|
|
882
|
+
state: "configuration_error";
|
|
883
|
+
reason: "proof_not_admitted";
|
|
884
|
+
} | {
|
|
885
|
+
state: "resetting";
|
|
886
|
+
} | {
|
|
887
|
+
state: "unavailable";
|
|
888
|
+
reason: "history_disabled" | "ineligible_mode";
|
|
889
|
+
};
|
|
890
|
+
/**
|
|
891
|
+
* Every history operation a render hook may invoke. Each routes through the
|
|
892
|
+
* same controller/session path as the default renderer, so busy gating,
|
|
893
|
+
* selection epochs, and confirmations behave identically.
|
|
894
|
+
*/
|
|
895
|
+
type AgentWidgetHistoryRenderActions = {
|
|
896
|
+
refresh(): Promise<void>;
|
|
897
|
+
loadMore(): Promise<void>;
|
|
898
|
+
openConversation(conversationId: string): Promise<void>;
|
|
899
|
+
startNewConversation(): Promise<void>;
|
|
900
|
+
/** Each request method opens Persona's accessible confirmation first. */
|
|
901
|
+
requestDeleteConversation(conversationId: string): Promise<"deleted" | "cancelled">;
|
|
902
|
+
requestClearConversationHistory(): Promise<"cleared" | "cancelled">;
|
|
903
|
+
requestResetHistoryIdentity(): Promise<{
|
|
904
|
+
outcome: "cancelled";
|
|
905
|
+
} | {
|
|
906
|
+
outcome: "reset";
|
|
907
|
+
remoteRevocationConfirmed: boolean;
|
|
908
|
+
}>;
|
|
909
|
+
close(): void;
|
|
910
|
+
};
|
|
911
|
+
/**
|
|
912
|
+
* One conversation row, normalized at the Runtype boundary. The deprecated wire
|
|
913
|
+
* `flowId` alias never escapes that boundary: history code reads `targetId`.
|
|
914
|
+
*/
|
|
915
|
+
type HistoryConversationSummary = {
|
|
916
|
+
id: string;
|
|
917
|
+
/** Server-generated; rendered verbatim, never derived locally. */
|
|
918
|
+
title: string;
|
|
919
|
+
/** Resolved chat target (flow or agent); `null` when the server omits it. */
|
|
920
|
+
targetId: string | null;
|
|
921
|
+
/** Server-produced plain-text preview; `null` when unavailable. */
|
|
922
|
+
preview: string | null;
|
|
923
|
+
messageCount: number;
|
|
924
|
+
createdAt: string;
|
|
925
|
+
updatedAt: string;
|
|
926
|
+
/** Visitor-pinned flag. Absent when the provider has no update capability. */
|
|
927
|
+
starred?: boolean;
|
|
928
|
+
};
|
|
929
|
+
/** Visitor-editable conversation metadata. Absent fields are left unchanged. */
|
|
930
|
+
type HistoryConversationPatch = {
|
|
931
|
+
title?: string;
|
|
932
|
+
starred?: boolean;
|
|
933
|
+
};
|
|
934
|
+
type AgentWidgetMessageRole = "user" | "assistant" | "system";
|
|
935
|
+
type AgentWidgetReasoning = {
|
|
936
|
+
id: string;
|
|
937
|
+
status: "pending" | "streaming" | "complete";
|
|
938
|
+
chunks: string[];
|
|
939
|
+
/**
|
|
940
|
+
* Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
|
|
941
|
+
* thinking; `"loop"` is a cross-iteration agent reflection (the fold that
|
|
942
|
+
* replaced the legacy `agent_reflection` event). Absent for legacy streams.
|
|
943
|
+
*/
|
|
944
|
+
scope?: "turn" | "loop";
|
|
945
|
+
startedAt?: number;
|
|
946
|
+
completedAt?: number;
|
|
947
|
+
durationMs?: number;
|
|
948
|
+
};
|
|
949
|
+
type AgentWidgetToolCall = {
|
|
950
|
+
id: string;
|
|
951
|
+
name?: string;
|
|
952
|
+
status: "pending" | "running" | "complete";
|
|
953
|
+
args?: unknown;
|
|
954
|
+
chunks?: string[];
|
|
955
|
+
result?: unknown;
|
|
956
|
+
duration?: number;
|
|
957
|
+
startedAt?: number;
|
|
958
|
+
completedAt?: number;
|
|
959
|
+
durationMs?: number;
|
|
960
|
+
};
|
|
961
|
+
/**
|
|
962
|
+
* Represents a tool approval request in the chat conversation.
|
|
963
|
+
* Created when the agent requires human approval before executing a tool.
|
|
964
|
+
*/
|
|
965
|
+
type AgentWidgetApproval = {
|
|
966
|
+
id: string;
|
|
967
|
+
status: "pending" | "approved" | "denied" | "timeout";
|
|
968
|
+
agentId: string;
|
|
969
|
+
executionId: string;
|
|
970
|
+
toolName: string;
|
|
971
|
+
toolType?: string;
|
|
972
|
+
description: string;
|
|
973
|
+
/**
|
|
974
|
+
* Agent-authored justification for this specific call (the agent's own
|
|
975
|
+
* claim about its intent, extracted server-side from the reserved
|
|
976
|
+
* `_approvalReason` parameter). Render it attributed to the agent and as
|
|
977
|
+
* plain text: it is approver context, not a system statement.
|
|
978
|
+
*/
|
|
979
|
+
reason?: string;
|
|
980
|
+
parameters?: unknown;
|
|
981
|
+
resolvedAt?: number;
|
|
982
|
+
};
|
|
983
|
+
type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
|
|
984
|
+
/**
|
|
985
|
+
* Per-turn / per-step stop reason emitted by the runtime on
|
|
986
|
+
* `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
|
|
987
|
+
* owned by the upstream Runtype API: do not extend without coordination.
|
|
988
|
+
*
|
|
989
|
+
* - `end_turn`: natural completion (no affordance needed)
|
|
990
|
+
* - `max_tool_calls`: agent loop tripped the configured tool-call ceiling
|
|
991
|
+
* - `length`: provider hit max output tokens
|
|
992
|
+
* - `content_filter`: provider content filter intervened
|
|
993
|
+
* - `error`: provider/runtime error (prefer existing error rendering)
|
|
994
|
+
* - `unknown`: explicitly reported but uninformative
|
|
995
|
+
*
|
|
996
|
+
* Absent (`undefined`) means "not reported": distinct from `'unknown'`.
|
|
997
|
+
*/
|
|
998
|
+
type StopReasonKind = RuntypeStopReasonKind;
|
|
999
|
+
/**
|
|
1000
|
+
* Represents a message in the chat conversation.
|
|
1001
|
+
*
|
|
1002
|
+
* @property id - Unique message identifier
|
|
1003
|
+
* @property role - Message role: "user", "assistant", or "system"
|
|
1004
|
+
* @property content - Message text content (for display)
|
|
1005
|
+
* @property contentParts - Original multi-modal content parts (for API requests)
|
|
1006
|
+
* @property createdAt - ISO timestamp when message was created
|
|
1007
|
+
* @property streaming - Whether message is still streaming (for assistant messages)
|
|
1008
|
+
* @property variant - Message variant for assistant messages: "assistant", "reasoning", or "tool"
|
|
1009
|
+
* @property sequence - Message ordering number
|
|
1010
|
+
* @property reasoning - Reasoning data for assistant reasoning messages
|
|
1011
|
+
* @property toolCall - Tool call data for assistant tool messages
|
|
1012
|
+
* @property tools - Array of tool calls
|
|
1013
|
+
* @property viaVoice - Set to `true` when a user message is sent via voice recognition.
|
|
1014
|
+
* Useful for implementing voice-specific behaviors like auto-reactivation.
|
|
1015
|
+
*/
|
|
1016
|
+
type AgentWidgetMessage = {
|
|
1017
|
+
id: string;
|
|
1018
|
+
role: AgentWidgetMessageRole;
|
|
1019
|
+
content: string;
|
|
1020
|
+
createdAt: string;
|
|
1021
|
+
/**
|
|
1022
|
+
* Original multi-modal content parts for this message.
|
|
1023
|
+
* When present, this is sent to the API instead of `content`.
|
|
1024
|
+
* The `content` field contains the text-only representation for display.
|
|
1025
|
+
*/
|
|
1026
|
+
contentParts?: ContentPart[];
|
|
1027
|
+
/**
|
|
1028
|
+
* Context mentions attached to this (user) message, for transcript fidelity +
|
|
1029
|
+
* chip rendering in the sent bubble. Refs only — the resolved payloads are
|
|
1030
|
+
* merged into `llmContent`/`contentParts` (model-visible) at send time.
|
|
1031
|
+
*/
|
|
1032
|
+
contextMentions?: AgentWidgetContextMentionRef[];
|
|
1033
|
+
/**
|
|
1034
|
+
* Ordered prose + mention blocks for inline-mode rendering and composer history
|
|
1035
|
+
* recall (`contextMentions.display: "inline"`). Present only on inline-mode user
|
|
1036
|
+
* messages; when omitted the sent bubble falls back to the chip row derived from
|
|
1037
|
+
* `contextMentions`. Display/transcript concern only — not the model channel.
|
|
1038
|
+
*/
|
|
1039
|
+
contentSegments?: AgentWidgetContentSegment[];
|
|
1040
|
+
/**
|
|
1041
|
+
* Resolved opt-in structured mention context for this (user) message, merged
|
|
1042
|
+
* into the request `context` under `mentions.<sourceId>.<itemId>` by the
|
|
1043
|
+
* client. Internal: set at send time from each source's `resolve().context`.
|
|
1044
|
+
*/
|
|
1045
|
+
mentionContext?: Record<string, unknown>;
|
|
1046
|
+
streaming?: boolean;
|
|
1047
|
+
variant?: AgentWidgetMessageVariant;
|
|
1048
|
+
sequence?: number;
|
|
1049
|
+
reasoning?: AgentWidgetReasoning;
|
|
1050
|
+
toolCall?: AgentWidgetToolCall;
|
|
1051
|
+
tools?: AgentWidgetToolCall[];
|
|
1052
|
+
/** Approval data for messages with variant "approval" */
|
|
1053
|
+
approval?: AgentWidgetApproval;
|
|
1054
|
+
viaVoice?: boolean;
|
|
1055
|
+
/**
|
|
1056
|
+
* Set to `true` on placeholder messages injected during Runtype voice processing.
|
|
1057
|
+
* Use this in `messageTransform` to detect and customize voice processing placeholders.
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* messageTransform: ({ text, message }) => {
|
|
1061
|
+
* if (message.voiceProcessing && message.role === 'user') {
|
|
1062
|
+
* return '<div class="my-voice-spinner">Transcribing...</div>';
|
|
1063
|
+
* }
|
|
1064
|
+
* return text;
|
|
1065
|
+
* }
|
|
1066
|
+
*/
|
|
1067
|
+
voiceProcessing?: boolean;
|
|
1068
|
+
/**
|
|
1069
|
+
* Raw structured payload for this message (e.g., JSON action response).
|
|
1070
|
+
* Populated automatically when structured parsers run.
|
|
1071
|
+
*/
|
|
1072
|
+
rawContent?: string;
|
|
1073
|
+
/**
|
|
1074
|
+
* LLM-specific content for API requests.
|
|
1075
|
+
* When present, this is sent to the LLM instead of `content`.
|
|
1076
|
+
*
|
|
1077
|
+
* Priority for API payload:
|
|
1078
|
+
* 1. `contentParts` (if present, used as-is for multi-modal)
|
|
1079
|
+
* 2. `llmContent` (if present, sent as string)
|
|
1080
|
+
* 3. `rawContent` (backward compatibility with structured parsers)
|
|
1081
|
+
* 4. `content` (fallback - display content)
|
|
1082
|
+
*
|
|
1083
|
+
* The `content` field is always used for UI display.
|
|
1084
|
+
*
|
|
1085
|
+
* @example
|
|
1086
|
+
* // Show full details to user, send summary to LLM
|
|
1087
|
+
* {
|
|
1088
|
+
* content: "**Product:** iPhone 15 Pro\n**Price:** $1,199\n**SKU:** IP15P-256",
|
|
1089
|
+
* llmContent: "[Product search: iPhone 15 Pro, $1199]"
|
|
1090
|
+
* }
|
|
1091
|
+
*/
|
|
1092
|
+
llmContent?: string;
|
|
1093
|
+
/**
|
|
1094
|
+
* Text segment identity for chronological ordering.
|
|
1095
|
+
* When present, identifies which text segment this message represents
|
|
1096
|
+
* (e.g., "text_0", "text_1") for messages split at tool boundaries.
|
|
1097
|
+
*/
|
|
1098
|
+
partId?: string;
|
|
1099
|
+
/**
|
|
1100
|
+
* Metadata for messages created during agent loop execution.
|
|
1101
|
+
* Contains execution context like iteration number and turn ID.
|
|
1102
|
+
*/
|
|
1103
|
+
agentMetadata?: AgentMessageMetadata;
|
|
1104
|
+
/**
|
|
1105
|
+
* Per-turn stop reason reported by the runtime on `agent_turn_complete`
|
|
1106
|
+
* (agent-loop path) or the last `step_complete` for a prompt step
|
|
1107
|
+
* (dispatch / flow path). Absent when the API did not report a value.
|
|
1108
|
+
*
|
|
1109
|
+
* When set to a non-natural value (`max_tool_calls`, `length`,
|
|
1110
|
+
* `content_filter`, `error`), the widget renders an inline notice on
|
|
1111
|
+
* the assistant bubble. See `config.copy.stopReasonNotice` to override
|
|
1112
|
+
* the default copy.
|
|
1113
|
+
*/
|
|
1114
|
+
stopReason?: StopReasonKind;
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Resolved copy for the history ("Messages") view.
|
|
1119
|
+
*
|
|
1120
|
+
* `AgentWidgetHistoryCopy` (types.ts) is the single authoritative
|
|
1121
|
+
* host-overridable type; the defaults live here, in the chunk. The handful of
|
|
1122
|
+
* strings the shell must render before this chunk loads come from
|
|
1123
|
+
* `components/history-shell-copy.ts` so each key still has one default.
|
|
1124
|
+
*
|
|
1125
|
+
* House style: sentence case, no em-dashes, no all-caps.
|
|
1126
|
+
*/
|
|
1127
|
+
|
|
1128
|
+
type HistoryViewCopyInput = AgentWidgetHistoryCopy;
|
|
1129
|
+
type ResolvedHistoryViewCopy = Required<AgentWidgetHistoryCopy>;
|
|
1130
|
+
declare const HISTORY_VIEW_COPY_DEFAULTS: ResolvedHistoryViewCopy;
|
|
1131
|
+
/** Idempotent: safe to call on an already-resolved copy object. */
|
|
1132
|
+
declare function resolveHistoryViewCopy(copy: HistoryViewCopyInput | undefined): ResolvedHistoryViewCopy;
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Client-side time grouping and relative-time formatting for the Messages list.
|
|
1136
|
+
*
|
|
1137
|
+
* Grouping never reorders: it walks the server order and opens a new group
|
|
1138
|
+
* whenever the resolved key changes, so an appended page merges into the
|
|
1139
|
+
* trailing group when its first item shares that group's key.
|
|
1140
|
+
*/
|
|
1141
|
+
|
|
1142
|
+
/** `features.history.grouping`. Starred rows keep their pinned group in both. */
|
|
1143
|
+
type HistoryGroupingMode = "time" | "none";
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* Conversation row + its overflow menu.
|
|
1147
|
+
*
|
|
1148
|
+
* The row is a whole-row button; the overflow trigger is a SIBLING absolutely
|
|
1149
|
+
* positioned over it, because a button cannot legally nest inside a button.
|
|
1150
|
+
*
|
|
1151
|
+
* Hierarchy: avatar, then title over preview with the relative time aligned to
|
|
1152
|
+
* the title. A conversation without a server title promotes its preview to the
|
|
1153
|
+
* title line rather than rendering an empty one; nothing is derived locally.
|
|
1154
|
+
*/
|
|
1155
|
+
|
|
1156
|
+
type RowPending = "opening" | "deleting" | null;
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* List-region state model plus its DOM. These blocks replace the LIST only:
|
|
1160
|
+
* the top bar, the primary new-conversation action, and the destructive footer
|
|
1161
|
+
* are built once and never move between states.
|
|
1162
|
+
*/
|
|
1163
|
+
|
|
1164
|
+
type HistoryListErrorReason = "unavailable" | "authentication_failed" | "authentication_required" | "identity_provider_failed" | "proof_not_admitted" | "unsupported_scope" | "unknown";
|
|
1165
|
+
type HistoryListState = {
|
|
1166
|
+
kind: "loading";
|
|
1167
|
+
phase: "initial" | "refresh" | "load-more";
|
|
1168
|
+
} | {
|
|
1169
|
+
kind: "ready";
|
|
1170
|
+
} | {
|
|
1171
|
+
kind: "empty";
|
|
1172
|
+
} | {
|
|
1173
|
+
kind: "error";
|
|
1174
|
+
reason: HistoryListErrorReason;
|
|
1175
|
+
retryable: boolean;
|
|
1176
|
+
} | {
|
|
1177
|
+
kind: "rate_limited";
|
|
1178
|
+
retryAfterSeconds: number;
|
|
1179
|
+
} | {
|
|
1180
|
+
kind: "new_conversation_required";
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* History ("Messages") navigation view — the default visitor-facing surface
|
|
1185
|
+
* described in `docs/visitor-history-implementation-plan.md` D7.
|
|
1186
|
+
*
|
|
1187
|
+
* Scope split: this file owns the VIEW (list, grouping, paging, list-region
|
|
1188
|
+
* states, row/menu affordances, its own announcements and styles). The shell
|
|
1189
|
+
* owns placement, open/close, inertness of the obscured conversation, focus
|
|
1190
|
+
* orchestration between surfaces, confirmations, and every session mutation —
|
|
1191
|
+
* the view only invokes the callbacks below and awaits their promises.
|
|
1192
|
+
*
|
|
1193
|
+
* Never statically imported on the core path: the IIFE build marks
|
|
1194
|
+
* `@runtypelabs/persona/history-view` external and `build:client` marks the same
|
|
1195
|
+
* subpath external for ESM/CJS. The core reaches it through
|
|
1196
|
+
* `history-view-loader.ts`. Guarded by `history-view-bundle.test.ts`.
|
|
1197
|
+
*/
|
|
1198
|
+
|
|
1199
|
+
type HistoryViewPresentation = "panel" | "rail";
|
|
1200
|
+
/**
|
|
1201
|
+
* Where the top bar's contents live. `"external"` hands them to the shell,
|
|
1202
|
+
* which mounts them inside its own persistent header; the view element then
|
|
1203
|
+
* starts at the body.
|
|
1204
|
+
*/
|
|
1205
|
+
type HistoryHeaderPlacement = "inline" | "external";
|
|
1206
|
+
type HistoryViewPendingAction = {
|
|
1207
|
+
kind: "refresh" | "load-more" | "start-new" | "clear" | "reset";
|
|
1208
|
+
} | {
|
|
1209
|
+
kind: "open" | "delete";
|
|
1210
|
+
conversationId: string;
|
|
1211
|
+
} | null;
|
|
1212
|
+
/**
|
|
1213
|
+
* Slot seams for the core arbitration layer (`history-render.ts`). The public
|
|
1214
|
+
* plugin contexts are built there: the view only supplies the slot's data and
|
|
1215
|
+
* its own default DOM, and never sees a plugin.
|
|
1216
|
+
*/
|
|
1217
|
+
interface HistoryHeaderSlotContext {
|
|
1218
|
+
identityStatus: HistoryIdentityStatus;
|
|
1219
|
+
pendingAction: HistoryViewPendingAction;
|
|
1220
|
+
copy: ResolvedHistoryViewCopy;
|
|
1221
|
+
defaultRenderer: () => HTMLElement;
|
|
1222
|
+
}
|
|
1223
|
+
interface HistoryConversationSlotContext {
|
|
1224
|
+
conversation: HistoryConversationSummary;
|
|
1225
|
+
active: boolean;
|
|
1226
|
+
pending: RowPending;
|
|
1227
|
+
open: () => Promise<void>;
|
|
1228
|
+
requestDelete: () => Promise<"deleted" | "cancelled">;
|
|
1229
|
+
defaultRenderer: () => HTMLElement;
|
|
1230
|
+
}
|
|
1231
|
+
interface HistoryStateSlotContext {
|
|
1232
|
+
state: Exclude<HistoryListState, {
|
|
1233
|
+
kind: "ready";
|
|
1234
|
+
}>;
|
|
1235
|
+
identityStatus: HistoryIdentityStatus;
|
|
1236
|
+
copy: ResolvedHistoryViewCopy;
|
|
1237
|
+
retry?: () => Promise<void>;
|
|
1238
|
+
startNewConversation?: () => Promise<void>;
|
|
1239
|
+
defaultRenderer: () => HTMLElement;
|
|
1240
|
+
}
|
|
1241
|
+
interface HistoryViewSlotRenderers {
|
|
1242
|
+
header?: (context: HistoryHeaderSlotContext) => HTMLElement | null;
|
|
1243
|
+
conversation?: (context: HistoryConversationSlotContext) => HTMLElement | null;
|
|
1244
|
+
state?: (context: HistoryStateSlotContext) => HTMLElement | null;
|
|
1245
|
+
}
|
|
1246
|
+
/** Snapshot source for the core arbitration layer. Read-only by contract. */
|
|
1247
|
+
interface HistoryViewModel {
|
|
1248
|
+
conversations: readonly HistoryConversationSummary[];
|
|
1249
|
+
activeConversationId: string | null;
|
|
1250
|
+
state: HistoryListState;
|
|
1251
|
+
pendingAction: HistoryViewPendingAction;
|
|
1252
|
+
identityStatus: HistoryIdentityStatus;
|
|
1253
|
+
nextCursor: string | null;
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* The operations the default DOM invokes. Shaped as the public render actions
|
|
1257
|
+
* minus `close` (the shell owns that) so the core can forward them verbatim.
|
|
1258
|
+
*/
|
|
1259
|
+
type HistoryViewOperations = Omit<AgentWidgetHistoryRenderActions, "close">;
|
|
1260
|
+
/** Where a rail section sits relative to the built-in conversation list. */
|
|
1261
|
+
type HistoryRailSectionPlacement = "above-conversations" | "below-conversations" | "footer";
|
|
1262
|
+
/** Core-normalized rail nav item: one label, one pre-resolved icon, one action. */
|
|
1263
|
+
interface HistoryRailSectionItem {
|
|
1264
|
+
id: string;
|
|
1265
|
+
label: string;
|
|
1266
|
+
badge?: string;
|
|
1267
|
+
/** Memoized by the core, so a presentation flip reuses the same node. */
|
|
1268
|
+
iconNode?: () => Element | null;
|
|
1269
|
+
/** Already guarded by the core; this chunk calls it bare. */
|
|
1270
|
+
onSelect: () => void;
|
|
1271
|
+
}
|
|
1272
|
+
interface HistoryRailSection {
|
|
1273
|
+
id: string;
|
|
1274
|
+
title?: string;
|
|
1275
|
+
placement: HistoryRailSectionPlacement;
|
|
1276
|
+
items: HistoryRailSectionItem[];
|
|
1277
|
+
/**
|
|
1278
|
+
* Plugin-backed body, in place of `items`. Re-invoked with each new collapsed
|
|
1279
|
+
* value; null empties and hides the section, as does a throw after one warn.
|
|
1280
|
+
*/
|
|
1281
|
+
render?: (collapsed: boolean) => Element | null;
|
|
1282
|
+
}
|
|
1283
|
+
interface HistoryViewOptions {
|
|
1284
|
+
/** Internal seam (D9). The view never touches `AgentWidgetClient`. */
|
|
1285
|
+
provider: HistoryProvider;
|
|
1286
|
+
/** Resolved once when history opens; reused by every operation. */
|
|
1287
|
+
context: HistoryOperationContext;
|
|
1288
|
+
/** Canonical active target filter. `null` lists the whole authorized scope. */
|
|
1289
|
+
targetId: string | null;
|
|
1290
|
+
/** Host overrides; defaults are applied here, so passing a partial is fine. */
|
|
1291
|
+
copy?: HistoryViewCopyInput;
|
|
1292
|
+
/** Already resolved against the host container width by the shell, not here. */
|
|
1293
|
+
presentation: HistoryViewPresentation;
|
|
1294
|
+
/**
|
|
1295
|
+
* Rail only. Default true: the bar's leading control is a collapse toggle
|
|
1296
|
+
* instead of a close (x), and `onToggleCollapse` drives it.
|
|
1297
|
+
*/
|
|
1298
|
+
collapsible?: boolean;
|
|
1299
|
+
/** Rail only. Initial collapsed state; the shell owns and persists it. */
|
|
1300
|
+
collapsed?: boolean;
|
|
1301
|
+
/**
|
|
1302
|
+
* Rail only. The edge the rail docks to, so the bar can put its collapse
|
|
1303
|
+
* toggle on the inner edge facing the conversation. Default `"left"`.
|
|
1304
|
+
*/
|
|
1305
|
+
railSide?: "left" | "right";
|
|
1306
|
+
/**
|
|
1307
|
+
* Rail only. Host-rendered identity for the bar's heading area. The `h2`
|
|
1308
|
+
* stays in the DOM as sr-only, so the region keeps its accessible name.
|
|
1309
|
+
*/
|
|
1310
|
+
renderRailHeader?: (context: {
|
|
1311
|
+
collapsed: boolean;
|
|
1312
|
+
defaultTitle: string;
|
|
1313
|
+
}) => Element | null;
|
|
1314
|
+
/**
|
|
1315
|
+
* Rail only. Core-resolved brand mark for both identity spots: the heading
|
|
1316
|
+
* default composition (`false`) and the collapsed toggle's rest face
|
|
1317
|
+
* (`true`). Null means no brand for that spot. Outranked by
|
|
1318
|
+
* `renderRailHeader` in the heading.
|
|
1319
|
+
*/
|
|
1320
|
+
railBrand?: (collapsed: boolean) => Element | null;
|
|
1321
|
+
/**
|
|
1322
|
+
* Rail only. Host navigation sections stacked around the conversation list.
|
|
1323
|
+
* Normalized by the core, which also resolves each item's icon precedence
|
|
1324
|
+
* into `iconNode` so this chunk never imports the lucide registry.
|
|
1325
|
+
*/
|
|
1326
|
+
railSections?: HistoryRailSection[];
|
|
1327
|
+
/**
|
|
1328
|
+
* Rail only. Pre-formatted collapse shortcut: `hint` is the tooltip chip,
|
|
1329
|
+
* `aria` the `aria-keyshortcuts` value. The shell owns the binding and both
|
|
1330
|
+
* strings, so this chunk never bundles the shortcut module.
|
|
1331
|
+
*/
|
|
1332
|
+
collapseShortcut?: {
|
|
1333
|
+
hint: string;
|
|
1334
|
+
aria: string;
|
|
1335
|
+
};
|
|
1336
|
+
/** Default `"inline"`. Rail is always inline; the shell enforces that. */
|
|
1337
|
+
headerPlacement?: HistoryHeaderPlacement;
|
|
1338
|
+
showScopeStatus: boolean;
|
|
1339
|
+
/**
|
|
1340
|
+
* Per-row delete via the row overflow menu. Default true; false drops the
|
|
1341
|
+
* trigger (delete is its only item). Hides the control only — custom row
|
|
1342
|
+
* slots still receive `requestDelete`.
|
|
1343
|
+
*/
|
|
1344
|
+
showDelete?: boolean;
|
|
1345
|
+
/** The list overflow menu's clear-history item. Default true. */
|
|
1346
|
+
showDeleteAll?: boolean;
|
|
1347
|
+
/** Host items in the list overflow menu, above the built-in destructive ones. */
|
|
1348
|
+
listActions?: AgentWidgetHistoryListAction[];
|
|
1349
|
+
/**
|
|
1350
|
+
* Leading row avatar: an image URL, a glyph, or `false` to omit the block.
|
|
1351
|
+
* Absent falls back to the same glyph the header uses.
|
|
1352
|
+
*/
|
|
1353
|
+
rowAvatar?: string | false;
|
|
1354
|
+
activeConversationId: string | null;
|
|
1355
|
+
/**
|
|
1356
|
+
* Date bucketing of the list. Default `"time"`; `"none"` folds the time
|
|
1357
|
+
* buckets into one flat group. Starred rows keep their pinned group either
|
|
1358
|
+
* way.
|
|
1359
|
+
*/
|
|
1360
|
+
grouping?: HistoryGroupingMode;
|
|
1361
|
+
/** List page size. Default 25. */
|
|
1362
|
+
pageSize?: number;
|
|
1363
|
+
/** Clock seam for grouping and relative time. */
|
|
1364
|
+
now?: () => number;
|
|
1365
|
+
/** Row selection. The shell commits the open; the view shows row pending. */
|
|
1366
|
+
onSelect: (conversationId: string) => void | Promise<void>;
|
|
1367
|
+
onStartNew: () => void | Promise<void>;
|
|
1368
|
+
/** Back (panel) or close (rail without a collapse toggle). */
|
|
1369
|
+
onClose: () => void;
|
|
1370
|
+
/** Collapse toggle. The shell decides, then calls `setCollapsed`. */
|
|
1371
|
+
onToggleCollapse?: () => void;
|
|
1372
|
+
/** Shell owns the confirmation; resolves with the outcome. */
|
|
1373
|
+
onRequestDeleteConversation: (conversationId: string) => Promise<"deleted" | "cancelled">;
|
|
1374
|
+
onRequestClearHistory: () => Promise<"cleared" | "cancelled">;
|
|
1375
|
+
/** Rendered only when the provider exposes `resetDevice`. */
|
|
1376
|
+
onRequestResetIdentity?: () => Promise<{
|
|
1377
|
+
outcome: "cancelled";
|
|
1378
|
+
} | {
|
|
1379
|
+
outcome: "reset";
|
|
1380
|
+
remoteRevocationConfirmed: boolean;
|
|
1381
|
+
}>;
|
|
1382
|
+
/** Core-owned plugin slots. Absent means the default DOM everywhere. */
|
|
1383
|
+
slots?: HistoryViewSlotRenderers;
|
|
1384
|
+
/**
|
|
1385
|
+
* Start with DOM rendering suspended so the core can arbitrate a full-view
|
|
1386
|
+
* hook before any slot runs. Default true.
|
|
1387
|
+
*/
|
|
1388
|
+
renderDom?: boolean;
|
|
1389
|
+
/** Model-change signal, emitted only while DOM rendering is suspended. */
|
|
1390
|
+
onModelChange?: () => void;
|
|
1391
|
+
/**
|
|
1392
|
+
* Fired whenever the ACTIVE conversation's list summary changes: on
|
|
1393
|
+
* selection, on a list refresh that delivers a server-generated title, on a
|
|
1394
|
+
* rename/star patch, and with `null` when no active conversation is listed.
|
|
1395
|
+
* Feeds the shell's `layout.header.titleSource: "conversation"` binding and
|
|
1396
|
+
* its built-in title-menu star toggle.
|
|
1397
|
+
*/
|
|
1398
|
+
onActiveConversationChange?: (summary: HistoryConversationSummary | null) => void;
|
|
1399
|
+
/** Shell live region, used while this view's own one is detached. */
|
|
1400
|
+
onAnnounce?: (message: string) => void;
|
|
1401
|
+
/**
|
|
1402
|
+
* The shell's tooltip attacher, passed in so the size-capped chunk never
|
|
1403
|
+
* bundles a second copy of the tooltip module. Absent means no tooltips.
|
|
1404
|
+
*/
|
|
1405
|
+
attachTooltip?: (options: TooltipOptions) => TooltipHandle;
|
|
1406
|
+
}
|
|
1407
|
+
interface HistoryViewHandle {
|
|
1408
|
+
element: HTMLElement;
|
|
1409
|
+
/** Resolved copy, defaults included. The defaults live in this chunk. */
|
|
1410
|
+
copy: ResolvedHistoryViewCopy;
|
|
1411
|
+
/** Immutable-by-contract model snapshot for the core arbitration layer. */
|
|
1412
|
+
getModel(): HistoryViewModel;
|
|
1413
|
+
/** The same operations the default DOM invokes, for public render hooks. */
|
|
1414
|
+
operations: HistoryViewOperations;
|
|
1415
|
+
/** Suspend/resume this view's DOM while a plugin owns the full surface. */
|
|
1416
|
+
setDomRenderEnabled(enabled: boolean): void;
|
|
1417
|
+
/** Re-fetch and re-render the list in place, preserving list/focus state. */
|
|
1418
|
+
refresh(): void;
|
|
1419
|
+
/**
|
|
1420
|
+
* Retarget the view when the shell moves it between hosts (rail <-> panel).
|
|
1421
|
+
* The instance and all its state survive the move; only chrome changes.
|
|
1422
|
+
*/
|
|
1423
|
+
setPresentation(presentation: HistoryViewPresentation): void;
|
|
1424
|
+
/**
|
|
1425
|
+
* Collapse the rail to its icon column. The view only styles itself and
|
|
1426
|
+
* relabels the toggle; the shell owns the host width and the persisted state.
|
|
1427
|
+
*/
|
|
1428
|
+
setCollapsed(collapsed: boolean): void;
|
|
1429
|
+
/** Re-mirror the bar for a live `rail.side` change. */
|
|
1430
|
+
setRailSide(side: "left" | "right"): void;
|
|
1431
|
+
/**
|
|
1432
|
+
* The top bar's CURRENT content node (the default bar or a slot replacement).
|
|
1433
|
+
* A slot re-render swaps it in place, so an external host stays its parent.
|
|
1434
|
+
*/
|
|
1435
|
+
getHeaderElement(): HTMLElement;
|
|
1436
|
+
/**
|
|
1437
|
+
* Hand the bar's contents to the shell (`"external"`, detached for the shell
|
|
1438
|
+
* to re-home) or take them back (`"inline"`). Idempotent; never replays the
|
|
1439
|
+
* entrance.
|
|
1440
|
+
*/
|
|
1441
|
+
setHeaderPlacement(placement: HistoryHeaderPlacement): void;
|
|
1442
|
+
/** Keep the active-row indicator in sync when the shell changes conversation. */
|
|
1443
|
+
setActiveConversationId(conversationId: string | null): void;
|
|
1444
|
+
/** Patch one listed summary in place after a shell-side rename/star. */
|
|
1445
|
+
applyConversationSummary(summary: HistoryConversationSummary): void;
|
|
1446
|
+
/** Drop one listed row after a shell-side delete (headless or built-in). */
|
|
1447
|
+
removeConversationSummary(conversationId: string): void;
|
|
1448
|
+
/** Enter/leave the post-deletion replacement-init recovery state. */
|
|
1449
|
+
setNewConversationRequired(required: boolean): void;
|
|
1450
|
+
/**
|
|
1451
|
+
* Mirrored exit for the shell's close sequence. Resolves once the surface has
|
|
1452
|
+
* visually left; never rejects, and repeat calls join the running exit.
|
|
1453
|
+
* `null` means nothing to wait for (motion off, or no WAAPI): the caller must
|
|
1454
|
+
* tear down synchronously rather than deferring by a microtask.
|
|
1455
|
+
*/
|
|
1456
|
+
playExit(): Promise<void> | null;
|
|
1457
|
+
destroy(): void;
|
|
1458
|
+
}
|
|
1459
|
+
declare function createHistoryView(options: HistoryViewOptions): HistoryViewHandle;
|
|
1460
|
+
|
|
1461
|
+
export { HISTORY_VIEW_COPY_DEFAULTS, type HistoryListErrorReason, type HistoryListState, type HistoryViewCopyInput, type HistoryViewHandle, type HistoryViewOptions, type HistoryViewPendingAction, type HistoryViewPresentation, type ResolvedHistoryViewCopy, createHistoryView, resolveHistoryViewCopy };
|