@runtypelabs/persona 3.26.0 → 3.28.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/README.md +29 -13
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-BZVr1YOV.d.cts → types-CxvHw0X6.d.cts} +551 -1
- package/dist/animations/{types-BZVr1YOV.d.ts → types-CxvHw0X6.d.ts} +551 -1
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/codegen.cjs +80 -0
- package/dist/codegen.d.cts +143 -0
- package/dist/codegen.d.ts +143 -0
- package/dist/codegen.js +80 -0
- package/dist/index.cjs +35 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1230 -3
- package/dist/index.d.ts +1230 -3
- package/dist/index.global.js +35 -35
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +31 -31
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/install.global.js.map +1 -1
- package/dist/launcher.global.js +133 -0
- package/dist/launcher.global.js.map +1 -0
- package/dist/smart-dom-reader.d.cts +551 -1
- package/dist/smart-dom-reader.d.ts +551 -1
- package/dist/theme-editor.d.cts +551 -1
- package/dist/theme-editor.d.ts +551 -1
- package/package.json +14 -4
- package/src/client.test.ts +9 -9
- package/src/codegen.test.ts +39 -0
- package/src/codegen.ts +20 -0
- package/src/generated/runtype-openapi-contract.ts +1249 -0
- package/src/index-core.ts +19 -0
- package/src/install.test.ts +442 -0
- package/src/install.ts +283 -49
- package/src/launcher-global.ts +115 -0
- package/src/runtime/init.test.ts +71 -0
- package/src/runtime/init.ts +17 -1
- package/src/types.ts +14 -8
package/README.md
CHANGED
|
@@ -92,7 +92,8 @@ const docked = initAgentWidget({
|
|
|
92
92
|
| `target` | `string \| HTMLElement` | CSS selector or element where widget mounts. |
|
|
93
93
|
| `config` | `AgentWidgetConfig` | Widget configuration object (see [Configuration reference](#configuration-reference) below). |
|
|
94
94
|
| `useShadowDom` | `boolean` | Use Shadow DOM for style isolation (default: `true`). |
|
|
95
|
-
| `
|
|
95
|
+
| `onChatReady` | `() => void` | Callback fired when the widget is initialized and its API is callable. |
|
|
96
|
+
| `onReady` | `() => void` | **Deprecated** alias of `onChatReady`; still works, removed in the next major. |
|
|
96
97
|
| `windowKey` | `string` | If provided, stores the controller on `window[windowKey]` for global access. Automatically cleaned up on `destroy()`. |
|
|
97
98
|
|
|
98
99
|
When `config.launcher.mountMode` is `'docked'`, `target` is treated as the page container that Persona should wrap. Use a concrete element such as `#workspace-main`; `body` and `html` are rejected.
|
|
@@ -354,7 +355,7 @@ window.chatController.submitMessage("Test message")
|
|
|
354
355
|
window.chatController.startVoiceRecognition()
|
|
355
356
|
```
|
|
356
357
|
|
|
357
|
-
When using the automatic installer script (`install.global.js`), see [Programmatic access with the installer](#programmatic-access-with-the-installer) for additional approaches including the `
|
|
358
|
+
When using the automatic installer script (`install.global.js`), see [Programmatic access with the installer](#programmatic-access-with-the-installer) for additional approaches including the `onChatReady` callback and `persona:chat-ready` event.
|
|
358
359
|
|
|
359
360
|
#### Message Types
|
|
360
361
|
|
|
@@ -619,19 +620,30 @@ window.dispatchEvent(new CustomEvent('persona:focusInput', {
|
|
|
619
620
|
|
|
620
621
|
**Instance scoping:** Same as `persona:showEventStream` — use `detail.instanceId` to target a specific widget. Without `instanceId`, all instances receive the event.
|
|
621
622
|
|
|
622
|
-
#### `persona:ready`
|
|
623
|
+
#### `persona:chat-ready`
|
|
623
624
|
|
|
624
|
-
Dispatched on `window` by the automatic installer script (`install.global.js`)
|
|
625
|
+
Dispatched on `window` by the automatic installer script (`install.global.js`) when the widget is initialized and its controller API is callable. The `event.detail` contains the `AgentWidgetInitHandle` (the same object returned by `initAgentWidget()`). In a deferred install (the default floating-launcher case) this fires after the user first opens the panel; in an eager install it fires on page load.
|
|
625
626
|
|
|
626
627
|
```ts
|
|
627
|
-
window.addEventListener('persona:ready', (e) => {
|
|
628
|
+
window.addEventListener('persona:chat-ready', (e) => {
|
|
628
629
|
const handle = e.detail;
|
|
629
630
|
handle.on('message:sent', (msg) => console.log(msg));
|
|
630
631
|
handle.open();
|
|
631
632
|
});
|
|
632
633
|
```
|
|
633
634
|
|
|
634
|
-
|
|
635
|
+
The installer also dispatches sibling lifecycle events for diagnostics and analytics:
|
|
636
|
+
|
|
637
|
+
| Event | `detail` | Fires |
|
|
638
|
+
| --- | --- | --- |
|
|
639
|
+
| `persona:script-load` | `{ version }` | the installer script executed (before any loading) |
|
|
640
|
+
| `persona:launcher-shown` | `{ deferred, element? }` | the floating launcher painted on the page (page-load time) |
|
|
641
|
+
| `persona:chat-ready` | the widget handle | the widget is initialized and its API is callable |
|
|
642
|
+
| `persona:error` | `{ phase, error }` | a load step (`css` / `bundle` / `init`) failed |
|
|
643
|
+
|
|
644
|
+
> **Note:** These events are only dispatched by the automatic installer script. Direct calls to `initAgentWidget()` return the handle synchronously and do not fire them.
|
|
645
|
+
>
|
|
646
|
+
> `persona:ready` is still dispatched as a **deprecated** alias of `persona:chat-ready` and will be removed in the next major.
|
|
635
647
|
|
|
636
648
|
### Controller Events
|
|
637
649
|
|
|
@@ -1553,7 +1565,11 @@ The easiest way is to use the automatic installer script. It handles loading CSS
|
|
|
1553
1565
|
- `previewQueryParam` - Query parameter key that gates widget loading; widget only loads when the parameter is present and truthy
|
|
1554
1566
|
- `useShadowDom` - Use Shadow DOM for style isolation (default: `false`)
|
|
1555
1567
|
- `windowKey` - If provided, stores the widget handle on `window[windowKey]` for programmatic access
|
|
1556
|
-
- `
|
|
1568
|
+
- `onScriptLoad` - Fired as soon as the installer script executes, before it loads or gates anything (diagnostics / timing); signature: `({ version }) => void`
|
|
1569
|
+
- `onLauncherShown` - Fired when the floating launcher is painted on the page (page-load time — for "widget appeared" analytics); signature: `({ deferred, element? }) => void`
|
|
1570
|
+
- `onChatReady` - Fired when the widget is initialized and its controller API is callable (after first open in a deferred install); signature: `(handle) => void`
|
|
1571
|
+
- `onError` - Fired when a load step fails (`css` / `bundle` / `init`), so ad-blocked / timed-out installs don't fail silently; signature: `({ phase, error }) => void`
|
|
1572
|
+
- `onReady` - **Deprecated** alias of `onChatReady`; still works, removed in the next major; signature: `(handle) => void`
|
|
1557
1573
|
|
|
1558
1574
|
**Example with version pinning:**
|
|
1559
1575
|
|
|
@@ -1574,14 +1590,14 @@ The easiest way is to use the automatic installer script. It handles loading CSS
|
|
|
1574
1590
|
|
|
1575
1591
|
The installer is fully asynchronous (it waits for framework hydration, then loads CSS and JS). To interact with the widget after it initializes, use one of these approaches:
|
|
1576
1592
|
|
|
1577
|
-
**`
|
|
1593
|
+
**`onChatReady` callback** — best when config and access logic live in the same script:
|
|
1578
1594
|
|
|
1579
1595
|
```html
|
|
1580
1596
|
<script>
|
|
1581
1597
|
window.siteAgentConfig = {
|
|
1582
1598
|
clientToken: 'YOUR_TOKEN',
|
|
1583
1599
|
windowKey: 'myChat',
|
|
1584
|
-
|
|
1600
|
+
onChatReady(handle) {
|
|
1585
1601
|
handle.on('message:sent', (e) => console.log('sent:', e));
|
|
1586
1602
|
handle.on('message:received', (e) => console.log('received:', e));
|
|
1587
1603
|
}
|
|
@@ -1590,11 +1606,11 @@ The installer is fully asynchronous (it waits for framework hydration, then load
|
|
|
1590
1606
|
<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@latest/dist/install.global.js"></script>
|
|
1591
1607
|
```
|
|
1592
1608
|
|
|
1593
|
-
**`persona:ready` event** — best for decoupled integration (e.g. tag managers, separate scripts):
|
|
1609
|
+
**`persona:chat-ready` event** — best for decoupled integration (e.g. tag managers, separate scripts):
|
|
1594
1610
|
|
|
1595
1611
|
```html
|
|
1596
1612
|
<script>
|
|
1597
|
-
window.addEventListener('persona:ready', (e) => {
|
|
1613
|
+
window.addEventListener('persona:chat-ready', (e) => {
|
|
1598
1614
|
const handle = e.detail;
|
|
1599
1615
|
handle.on('message:sent', (e) => console.log('sent:', e));
|
|
1600
1616
|
});
|
|
@@ -1607,7 +1623,7 @@ The installer is fully asynchronous (it waits for framework hydration, then load
|
|
|
1607
1623
|
<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@latest/dist/install.global.js"></script>
|
|
1608
1624
|
```
|
|
1609
1625
|
|
|
1610
|
-
**`windowKey`** — stores the handle on `window[windowKey]` for persistent global access. Combine with `
|
|
1626
|
+
**`windowKey`** — stores the handle on `window[windowKey]` for persistent global access. Combine with `onChatReady` or `persona:chat-ready` to know when it's available:
|
|
1611
1627
|
|
|
1612
1628
|
```html
|
|
1613
1629
|
<script>
|
|
@@ -1619,7 +1635,7 @@ The installer is fully asynchronous (it waits for framework hydration, then load
|
|
|
1619
1635
|
<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@latest/dist/install.global.js"></script>
|
|
1620
1636
|
|
|
1621
1637
|
<script>
|
|
1622
|
-
window.addEventListener('persona:ready', () => {
|
|
1638
|
+
window.addEventListener('persona:chat-ready', () => {
|
|
1623
1639
|
// window.myChat is now available and persists until destroy()
|
|
1624
1640
|
window.myChat.open();
|
|
1625
1641
|
});
|
|
@@ -1,3 +1,553 @@
|
|
|
1
|
+
type RuntypeAgentSSEEvent = {
|
|
2
|
+
agentId: string;
|
|
3
|
+
agentName: string;
|
|
4
|
+
config?: {
|
|
5
|
+
enableReflection?: boolean;
|
|
6
|
+
model?: string;
|
|
7
|
+
};
|
|
8
|
+
executionId: string;
|
|
9
|
+
maxTurns: number;
|
|
10
|
+
seq: number;
|
|
11
|
+
startedAt: string;
|
|
12
|
+
type: "agent_start";
|
|
13
|
+
} | {
|
|
14
|
+
executionId: string;
|
|
15
|
+
iteration: number;
|
|
16
|
+
maxTurns: number;
|
|
17
|
+
seq: number;
|
|
18
|
+
startedAt: string;
|
|
19
|
+
totalCost?: number;
|
|
20
|
+
type: "agent_iteration_start";
|
|
21
|
+
} | ({
|
|
22
|
+
executionId: string;
|
|
23
|
+
iteration: number;
|
|
24
|
+
role: "user" | "assistant" | "system";
|
|
25
|
+
seq: number;
|
|
26
|
+
turnId: string;
|
|
27
|
+
turnIndex: number;
|
|
28
|
+
type: "agent_turn_start";
|
|
29
|
+
}) | ({
|
|
30
|
+
contentType: "text" | "thinking" | "tool_input";
|
|
31
|
+
delta: string;
|
|
32
|
+
executionId: string;
|
|
33
|
+
iteration: number;
|
|
34
|
+
seq: number;
|
|
35
|
+
turnId: string;
|
|
36
|
+
type: "agent_turn_delta";
|
|
37
|
+
}) | ({
|
|
38
|
+
completedAt: string;
|
|
39
|
+
content?: string;
|
|
40
|
+
cost?: number;
|
|
41
|
+
estimatedContextBreakdown?: {
|
|
42
|
+
categories: Record<string, {
|
|
43
|
+
chars: number;
|
|
44
|
+
estimatedTokens: number;
|
|
45
|
+
}>;
|
|
46
|
+
contextWindowSize?: number;
|
|
47
|
+
estimatedTotalTokens: number;
|
|
48
|
+
estimatedUtilizationPercent?: number;
|
|
49
|
+
};
|
|
50
|
+
executionId: string;
|
|
51
|
+
iteration: number;
|
|
52
|
+
role: "user" | "assistant" | "system";
|
|
53
|
+
seq: number;
|
|
54
|
+
stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
|
|
55
|
+
tokens?: {
|
|
56
|
+
input: number;
|
|
57
|
+
output: number;
|
|
58
|
+
};
|
|
59
|
+
turnId: string;
|
|
60
|
+
type: "agent_turn_complete";
|
|
61
|
+
}) | ({
|
|
62
|
+
executionId: string;
|
|
63
|
+
iteration: number;
|
|
64
|
+
origin?: "webmcp" | "sdk";
|
|
65
|
+
pageOrigin?: string;
|
|
66
|
+
parameters?: Record<string, unknown>;
|
|
67
|
+
seq: number;
|
|
68
|
+
toolCallId: string;
|
|
69
|
+
toolName: string;
|
|
70
|
+
toolType: "flow" | "mcp" | "builtin" | "custom" | "external" | "advisor" | "subagent" | "local";
|
|
71
|
+
type: "agent_tool_start";
|
|
72
|
+
}) | {
|
|
73
|
+
delta: string;
|
|
74
|
+
executionId: string;
|
|
75
|
+
iteration: number;
|
|
76
|
+
seq: number;
|
|
77
|
+
toolCallId: string;
|
|
78
|
+
type: "agent_tool_delta";
|
|
79
|
+
} | {
|
|
80
|
+
delta: string;
|
|
81
|
+
executionId: string;
|
|
82
|
+
iteration: number;
|
|
83
|
+
seq: number;
|
|
84
|
+
toolCallId: string;
|
|
85
|
+
type: "agent_tool_input_delta";
|
|
86
|
+
} | {
|
|
87
|
+
executionId: string;
|
|
88
|
+
hiddenParameterNames?: Array<string>;
|
|
89
|
+
iteration: number;
|
|
90
|
+
parameters: Record<string, unknown>;
|
|
91
|
+
seq: number;
|
|
92
|
+
toolCallId: string;
|
|
93
|
+
toolName: string;
|
|
94
|
+
type: "agent_tool_input_complete";
|
|
95
|
+
} | {
|
|
96
|
+
executionId: string;
|
|
97
|
+
executionTime?: number;
|
|
98
|
+
iteration: number;
|
|
99
|
+
result?: unknown;
|
|
100
|
+
seq: number;
|
|
101
|
+
success: boolean;
|
|
102
|
+
toolCallId: string;
|
|
103
|
+
toolName: string;
|
|
104
|
+
type: "agent_tool_complete";
|
|
105
|
+
} | ({
|
|
106
|
+
executionId?: string;
|
|
107
|
+
iteration: number;
|
|
108
|
+
media: Array<({
|
|
109
|
+
annotations?: {
|
|
110
|
+
audience?: Array<"user" | "assistant">;
|
|
111
|
+
};
|
|
112
|
+
data: string;
|
|
113
|
+
mediaType: string;
|
|
114
|
+
type: "media";
|
|
115
|
+
}) | ({
|
|
116
|
+
annotations?: {
|
|
117
|
+
audience?: Array<"user" | "assistant">;
|
|
118
|
+
};
|
|
119
|
+
mediaType?: string;
|
|
120
|
+
type: "image-url";
|
|
121
|
+
url: string;
|
|
122
|
+
}) | ({
|
|
123
|
+
annotations?: {
|
|
124
|
+
audience?: Array<"user" | "assistant">;
|
|
125
|
+
};
|
|
126
|
+
mediaType: string;
|
|
127
|
+
type: "file-url";
|
|
128
|
+
url: string;
|
|
129
|
+
})>;
|
|
130
|
+
seq?: number;
|
|
131
|
+
toolCallId: string;
|
|
132
|
+
toolName: string;
|
|
133
|
+
type: "agent_media";
|
|
134
|
+
}) | {
|
|
135
|
+
approvalId: string;
|
|
136
|
+
description: string;
|
|
137
|
+
executionId: string;
|
|
138
|
+
externalAgent?: {
|
|
139
|
+
contextId?: string;
|
|
140
|
+
taskId?: string;
|
|
141
|
+
};
|
|
142
|
+
iteration?: number;
|
|
143
|
+
parameters?: Record<string, unknown>;
|
|
144
|
+
seq: number;
|
|
145
|
+
startedAt: string;
|
|
146
|
+
timeout: number;
|
|
147
|
+
toolCallId: string;
|
|
148
|
+
toolName: string;
|
|
149
|
+
toolType: string;
|
|
150
|
+
type: "agent_approval_start";
|
|
151
|
+
} | ({
|
|
152
|
+
approvalId: string;
|
|
153
|
+
completedAt: string;
|
|
154
|
+
decision: "approved" | "denied" | "timeout";
|
|
155
|
+
executionId: string;
|
|
156
|
+
resolvedBy: "user" | "system";
|
|
157
|
+
seq: number;
|
|
158
|
+
type: "agent_approval_complete";
|
|
159
|
+
}) | ({
|
|
160
|
+
awaitedAt: string;
|
|
161
|
+
executionId: string;
|
|
162
|
+
origin?: "webmcp" | "sdk";
|
|
163
|
+
pageOrigin?: string;
|
|
164
|
+
parameters?: Record<string, unknown>;
|
|
165
|
+
seq: number;
|
|
166
|
+
toolCallId?: string;
|
|
167
|
+
toolId: string;
|
|
168
|
+
toolName: string;
|
|
169
|
+
type: "agent_await";
|
|
170
|
+
}) | {
|
|
171
|
+
completedAt: string;
|
|
172
|
+
cost?: number;
|
|
173
|
+
duration?: number;
|
|
174
|
+
estimatedContextBreakdown?: {
|
|
175
|
+
categories: Record<string, {
|
|
176
|
+
chars: number;
|
|
177
|
+
estimatedTokens: number;
|
|
178
|
+
}>;
|
|
179
|
+
contextWindowSize?: number;
|
|
180
|
+
estimatedTotalTokens: number;
|
|
181
|
+
estimatedUtilizationPercent?: number;
|
|
182
|
+
};
|
|
183
|
+
executionId: string;
|
|
184
|
+
iteration: number;
|
|
185
|
+
output?: string;
|
|
186
|
+
runningTotalCost?: number;
|
|
187
|
+
seq: number;
|
|
188
|
+
stopConditionMet: boolean;
|
|
189
|
+
tokens?: {
|
|
190
|
+
input: number;
|
|
191
|
+
output: number;
|
|
192
|
+
};
|
|
193
|
+
toolCallsMade: number;
|
|
194
|
+
type: "agent_iteration_complete";
|
|
195
|
+
} | {
|
|
196
|
+
executionId: string;
|
|
197
|
+
iteration: number;
|
|
198
|
+
reflection?: string;
|
|
199
|
+
seq: number;
|
|
200
|
+
type: "agent_reflection";
|
|
201
|
+
} | {
|
|
202
|
+
activatedCapabilities: Array<string>;
|
|
203
|
+
executionId: string;
|
|
204
|
+
iteration: number;
|
|
205
|
+
seq: number;
|
|
206
|
+
skill: string;
|
|
207
|
+
toolCallId: string;
|
|
208
|
+
type: "agent_skill_loaded";
|
|
209
|
+
} | ({
|
|
210
|
+
executionId: string;
|
|
211
|
+
iteration: number;
|
|
212
|
+
outcome: "pending_approval" | "auto_published";
|
|
213
|
+
proposalId?: string;
|
|
214
|
+
seq: number;
|
|
215
|
+
skill: string;
|
|
216
|
+
toolCallId: string;
|
|
217
|
+
type: "agent_skill_proposed";
|
|
218
|
+
}) | ({
|
|
219
|
+
agentId: string;
|
|
220
|
+
completedAt: string;
|
|
221
|
+
duration?: number;
|
|
222
|
+
error?: string;
|
|
223
|
+
executionId: string;
|
|
224
|
+
externalAgent?: {
|
|
225
|
+
contextId?: string;
|
|
226
|
+
taskId?: string;
|
|
227
|
+
};
|
|
228
|
+
finalOutput?: string;
|
|
229
|
+
iterations: number;
|
|
230
|
+
seq: number;
|
|
231
|
+
stopReason: "complete" | "end_turn" | "max_turns" | "max_cost" | "timeout" | "error";
|
|
232
|
+
success: boolean;
|
|
233
|
+
totalCost?: number;
|
|
234
|
+
totalTokens?: {
|
|
235
|
+
input: number;
|
|
236
|
+
output: number;
|
|
237
|
+
};
|
|
238
|
+
type: "agent_complete";
|
|
239
|
+
}) | {
|
|
240
|
+
error: {
|
|
241
|
+
code: string;
|
|
242
|
+
details?: Record<string, unknown>;
|
|
243
|
+
message: string;
|
|
244
|
+
};
|
|
245
|
+
executionId: string;
|
|
246
|
+
iteration?: number;
|
|
247
|
+
recoverable: boolean;
|
|
248
|
+
seq: number;
|
|
249
|
+
type: "agent_error";
|
|
250
|
+
} | {
|
|
251
|
+
executionId: string;
|
|
252
|
+
seq: number;
|
|
253
|
+
timestamp: string;
|
|
254
|
+
type: "agent_ping";
|
|
255
|
+
};
|
|
256
|
+
type RuntypeFlowSSEEvent = {
|
|
257
|
+
executionContext?: Record<string, unknown>;
|
|
258
|
+
executionId?: string;
|
|
259
|
+
flowId: string;
|
|
260
|
+
flowName?: string;
|
|
261
|
+
input?: unknown;
|
|
262
|
+
seq?: number;
|
|
263
|
+
source?: string;
|
|
264
|
+
startedAt: string;
|
|
265
|
+
toolContext?: {
|
|
266
|
+
executionId: string;
|
|
267
|
+
stepId: string;
|
|
268
|
+
toolId: string;
|
|
269
|
+
};
|
|
270
|
+
totalSteps?: number;
|
|
271
|
+
type: "flow_start";
|
|
272
|
+
} | {
|
|
273
|
+
completedAt?: string;
|
|
274
|
+
completedSteps?: number;
|
|
275
|
+
duration?: number;
|
|
276
|
+
executionContext?: Record<string, unknown>;
|
|
277
|
+
executionId?: string;
|
|
278
|
+
executionTime?: number;
|
|
279
|
+
failedSteps?: number;
|
|
280
|
+
finalOutput?: string;
|
|
281
|
+
flowId?: string;
|
|
282
|
+
output?: unknown;
|
|
283
|
+
seq?: number;
|
|
284
|
+
source?: string;
|
|
285
|
+
success?: boolean;
|
|
286
|
+
successfulSteps?: number;
|
|
287
|
+
toolContext?: {
|
|
288
|
+
executionId: string;
|
|
289
|
+
stepId: string;
|
|
290
|
+
toolId: string;
|
|
291
|
+
};
|
|
292
|
+
totalSteps?: number;
|
|
293
|
+
totalTokensUsed?: number;
|
|
294
|
+
type: "flow_complete";
|
|
295
|
+
} | ({
|
|
296
|
+
code?: string;
|
|
297
|
+
error: string | {
|
|
298
|
+
code: string;
|
|
299
|
+
message: string;
|
|
300
|
+
stepId?: string;
|
|
301
|
+
stepType?: string;
|
|
302
|
+
};
|
|
303
|
+
executionId?: string;
|
|
304
|
+
executionTime?: number;
|
|
305
|
+
flowId?: string;
|
|
306
|
+
seq?: number;
|
|
307
|
+
timestamp?: string;
|
|
308
|
+
toolContext?: {
|
|
309
|
+
executionId: string;
|
|
310
|
+
stepId: string;
|
|
311
|
+
toolId: string;
|
|
312
|
+
};
|
|
313
|
+
type: "flow_error";
|
|
314
|
+
upgradeUrl?: string;
|
|
315
|
+
}) | ({
|
|
316
|
+
awaitedAt: string;
|
|
317
|
+
executionId?: string;
|
|
318
|
+
flowId: string;
|
|
319
|
+
origin?: "webmcp" | "sdk";
|
|
320
|
+
pageOrigin?: string;
|
|
321
|
+
parameters?: Record<string, unknown>;
|
|
322
|
+
seq?: number;
|
|
323
|
+
toolCallId?: string;
|
|
324
|
+
toolId?: string;
|
|
325
|
+
toolName?: string;
|
|
326
|
+
type: "flow_await";
|
|
327
|
+
}) | {
|
|
328
|
+
estimatedTokens?: number;
|
|
329
|
+
executionId?: string;
|
|
330
|
+
id?: string;
|
|
331
|
+
index?: number;
|
|
332
|
+
name?: string;
|
|
333
|
+
seq?: number;
|
|
334
|
+
startedAt: string;
|
|
335
|
+
stepId?: string;
|
|
336
|
+
stepName?: string;
|
|
337
|
+
stepType?: string;
|
|
338
|
+
toolContext?: {
|
|
339
|
+
executionId: string;
|
|
340
|
+
stepId: string;
|
|
341
|
+
toolId: string;
|
|
342
|
+
};
|
|
343
|
+
totalSteps?: number;
|
|
344
|
+
type: "step_start";
|
|
345
|
+
} | {
|
|
346
|
+
delta?: string;
|
|
347
|
+
executionId?: string;
|
|
348
|
+
id?: string;
|
|
349
|
+
messageId?: string;
|
|
350
|
+
partId?: string;
|
|
351
|
+
seq?: number;
|
|
352
|
+
text?: string;
|
|
353
|
+
toolContext?: {
|
|
354
|
+
executionId: string;
|
|
355
|
+
stepId: string;
|
|
356
|
+
toolId: string;
|
|
357
|
+
};
|
|
358
|
+
toolId?: string;
|
|
359
|
+
type: "step_delta";
|
|
360
|
+
} | ({
|
|
361
|
+
completedAt?: string;
|
|
362
|
+
duration?: number;
|
|
363
|
+
durationMs?: number;
|
|
364
|
+
error?: string;
|
|
365
|
+
executionId?: string;
|
|
366
|
+
executionTime?: number;
|
|
367
|
+
id?: string;
|
|
368
|
+
index?: number;
|
|
369
|
+
name?: string;
|
|
370
|
+
output?: unknown;
|
|
371
|
+
result?: unknown;
|
|
372
|
+
seq?: number;
|
|
373
|
+
stepId?: string;
|
|
374
|
+
stepName?: string;
|
|
375
|
+
stepType?: string;
|
|
376
|
+
stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
|
|
377
|
+
success?: boolean;
|
|
378
|
+
tokensUsed?: number;
|
|
379
|
+
toolContext?: {
|
|
380
|
+
executionId: string;
|
|
381
|
+
stepId: string;
|
|
382
|
+
toolId: string;
|
|
383
|
+
};
|
|
384
|
+
type: "step_complete";
|
|
385
|
+
}) | {
|
|
386
|
+
error: string;
|
|
387
|
+
executionId?: string;
|
|
388
|
+
executionTime?: number;
|
|
389
|
+
id?: string;
|
|
390
|
+
index?: number;
|
|
391
|
+
name?: string;
|
|
392
|
+
seq?: number;
|
|
393
|
+
stepType?: string;
|
|
394
|
+
type: "step_error";
|
|
395
|
+
} | {
|
|
396
|
+
error?: string;
|
|
397
|
+
executionId?: string;
|
|
398
|
+
id: string;
|
|
399
|
+
index?: number;
|
|
400
|
+
name?: string;
|
|
401
|
+
seq?: number;
|
|
402
|
+
skippedAt: string;
|
|
403
|
+
stepType: string;
|
|
404
|
+
totalSteps: number;
|
|
405
|
+
type: "step_skip";
|
|
406
|
+
when: string;
|
|
407
|
+
} | {
|
|
408
|
+
executionId?: string;
|
|
409
|
+
seq?: number;
|
|
410
|
+
type: "step_await";
|
|
411
|
+
[key: string]: unknown;
|
|
412
|
+
} | ({
|
|
413
|
+
agentContext?: {
|
|
414
|
+
executionId: string;
|
|
415
|
+
iteration: number;
|
|
416
|
+
seq: number;
|
|
417
|
+
};
|
|
418
|
+
executionId?: string;
|
|
419
|
+
hiddenParameterNames?: Array<string>;
|
|
420
|
+
name?: string;
|
|
421
|
+
parameters?: Record<string, unknown>;
|
|
422
|
+
providerOptions?: Record<string, unknown>;
|
|
423
|
+
seq?: number;
|
|
424
|
+
startedAt?: string;
|
|
425
|
+
stepId?: string;
|
|
426
|
+
toolCallId?: string;
|
|
427
|
+
toolId?: string;
|
|
428
|
+
toolName?: string;
|
|
429
|
+
toolType: "flow" | "mcp" | "builtin" | "custom" | "external" | "advisor" | "subagent" | "local";
|
|
430
|
+
type: "tool_start";
|
|
431
|
+
[key: string]: unknown;
|
|
432
|
+
}) | {
|
|
433
|
+
delta?: string;
|
|
434
|
+
executionId?: string;
|
|
435
|
+
seq?: number;
|
|
436
|
+
toolId?: string;
|
|
437
|
+
type: "tool_delta";
|
|
438
|
+
[key: string]: unknown;
|
|
439
|
+
} | {
|
|
440
|
+
delta: string;
|
|
441
|
+
executionId?: string;
|
|
442
|
+
seq?: number;
|
|
443
|
+
stepId?: string;
|
|
444
|
+
toolCallId?: string;
|
|
445
|
+
toolId?: string;
|
|
446
|
+
type: "tool_input_delta";
|
|
447
|
+
} | {
|
|
448
|
+
executionId?: string;
|
|
449
|
+
hiddenParameterNames?: Array<string>;
|
|
450
|
+
parameters: Record<string, unknown>;
|
|
451
|
+
providerOptions?: Record<string, unknown>;
|
|
452
|
+
seq?: number;
|
|
453
|
+
stepId?: string;
|
|
454
|
+
toolCallId?: string;
|
|
455
|
+
toolId?: string;
|
|
456
|
+
toolName?: string;
|
|
457
|
+
type: "tool_input_complete";
|
|
458
|
+
} | {
|
|
459
|
+
agentContext?: {
|
|
460
|
+
executionId: string;
|
|
461
|
+
iteration: number;
|
|
462
|
+
seq: number;
|
|
463
|
+
};
|
|
464
|
+
completedAt?: string;
|
|
465
|
+
error?: string;
|
|
466
|
+
executionId?: string;
|
|
467
|
+
executionTime?: number;
|
|
468
|
+
name?: string;
|
|
469
|
+
result?: unknown;
|
|
470
|
+
seq?: number;
|
|
471
|
+
stepId?: string;
|
|
472
|
+
success: boolean;
|
|
473
|
+
toolCallId?: string;
|
|
474
|
+
toolCost?: number;
|
|
475
|
+
toolId?: string;
|
|
476
|
+
toolName?: string;
|
|
477
|
+
type: "tool_complete";
|
|
478
|
+
} | {
|
|
479
|
+
agentContext?: {
|
|
480
|
+
executionId: string;
|
|
481
|
+
iteration: number;
|
|
482
|
+
seq: number;
|
|
483
|
+
};
|
|
484
|
+
error: string;
|
|
485
|
+
executionId?: string;
|
|
486
|
+
executionTime?: number;
|
|
487
|
+
failedAt?: string;
|
|
488
|
+
name: string;
|
|
489
|
+
seq?: number;
|
|
490
|
+
toolId: string;
|
|
491
|
+
type: "tool_error";
|
|
492
|
+
} | {
|
|
493
|
+
executionId?: string;
|
|
494
|
+
id: string;
|
|
495
|
+
seq?: number;
|
|
496
|
+
text: string;
|
|
497
|
+
type: "chunk";
|
|
498
|
+
} | {
|
|
499
|
+
executionId?: string;
|
|
500
|
+
seq?: number;
|
|
501
|
+
type: "text_start";
|
|
502
|
+
[key: string]: unknown;
|
|
503
|
+
} | {
|
|
504
|
+
executionId?: string;
|
|
505
|
+
seq?: number;
|
|
506
|
+
type: "text_end";
|
|
507
|
+
[key: string]: unknown;
|
|
508
|
+
} | {
|
|
509
|
+
executionId?: string;
|
|
510
|
+
seq?: number;
|
|
511
|
+
type: "reason_start";
|
|
512
|
+
[key: string]: unknown;
|
|
513
|
+
} | {
|
|
514
|
+
executionId?: string;
|
|
515
|
+
seq?: number;
|
|
516
|
+
type: "reason_delta";
|
|
517
|
+
[key: string]: unknown;
|
|
518
|
+
} | {
|
|
519
|
+
executionId?: string;
|
|
520
|
+
seq?: number;
|
|
521
|
+
type: "reason_complete";
|
|
522
|
+
[key: string]: unknown;
|
|
523
|
+
} | {
|
|
524
|
+
executionId?: string;
|
|
525
|
+
seq?: number;
|
|
526
|
+
type: "source";
|
|
527
|
+
[key: string]: unknown;
|
|
528
|
+
} | {
|
|
529
|
+
executionId?: string;
|
|
530
|
+
seq?: number;
|
|
531
|
+
type: "fallback_start";
|
|
532
|
+
[key: string]: unknown;
|
|
533
|
+
} | {
|
|
534
|
+
executionId?: string;
|
|
535
|
+
seq?: number;
|
|
536
|
+
type: "fallback_complete";
|
|
537
|
+
[key: string]: unknown;
|
|
538
|
+
} | {
|
|
539
|
+
executionId?: string;
|
|
540
|
+
seq?: number;
|
|
541
|
+
type: "fallback_exhausted";
|
|
542
|
+
[key: string]: unknown;
|
|
543
|
+
};
|
|
544
|
+
type RuntypeStreamEventOf<U, T extends string> = Extract<U, {
|
|
545
|
+
type: T;
|
|
546
|
+
}>;
|
|
547
|
+
type RuntypeAgentTurnCompleteEvent = RuntypeStreamEventOf<RuntypeAgentSSEEvent, "agent_turn_complete">;
|
|
548
|
+
type RuntypeStepCompleteEvent = RuntypeStreamEventOf<RuntypeFlowSSEEvent, "step_complete">;
|
|
549
|
+
type RuntypeStopReasonKind = NonNullable<RuntypeAgentTurnCompleteEvent["stopReason"] | RuntypeStepCompleteEvent["stopReason"]>;
|
|
550
|
+
|
|
1
551
|
/**
|
|
2
552
|
* Text content part for multi-modal messages
|
|
3
553
|
*/
|
|
@@ -232,7 +782,7 @@ type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval"
|
|
|
232
782
|
*
|
|
233
783
|
* Absent (`undefined`) means "not reported" — distinct from `'unknown'`.
|
|
234
784
|
*/
|
|
235
|
-
type StopReasonKind =
|
|
785
|
+
type StopReasonKind = RuntypeStopReasonKind;
|
|
236
786
|
/**
|
|
237
787
|
* Represents a message in the chat conversation.
|
|
238
788
|
*
|