@syntrologie/adapt-chatbot 2.55.1 → 2.57.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/AdaptiveChatBar.d.ts +18 -0
- package/dist/AdaptiveChatBar.d.ts.map +1 -1
- package/dist/AdaptiveChatBar.interleave.test.d.ts +9 -0
- package/dist/AdaptiveChatBar.interleave.test.d.ts.map +1 -0
- package/dist/AdaptiveChatBar.js +5 -4
- package/dist/AdaptiveChatBarMountable.d.ts +28 -17
- package/dist/AdaptiveChatBarMountable.d.ts.map +1 -1
- package/dist/AdaptiveChatTrail.d.ts.map +1 -1
- package/dist/AdaptiveChatTrail.js +4 -3
- package/dist/AdaptiveChipsStrip.d.ts +20 -20
- package/dist/AdaptiveChipsStrip.js +3 -3
- package/dist/ChatAssistantLit.d.ts.map +1 -1
- package/dist/ChatAssistantLit.js +5 -4
- package/dist/ChatTransport.d.ts +6 -1
- package/dist/ChatTransport.d.ts.map +1 -1
- package/dist/cdn.d.ts +1 -0
- package/dist/cdn.d.ts.map +1 -1
- package/dist/chunk-4V5L7IRV.js +4711 -0
- package/dist/chunk-4V5L7IRV.js.map +7 -0
- package/dist/{chunk-EXDL3OKE.js → chunk-AIQMQZBV.js} +314 -908
- package/dist/{chunk-EXDL3OKE.js.map → chunk-AIQMQZBV.js.map} +4 -4
- package/dist/{chunk-TZA7572J.js → chunk-GN7Z5IVP.js} +2 -2
- package/dist/{chunk-ETDHHQS3.js → chunk-HV52LYST.js} +12 -12
- package/dist/{chunk-ETDHHQS3.js.map → chunk-HV52LYST.js.map} +1 -1
- package/dist/{chunk-LJEPZI6Y.js → chunk-LFJ54PIF.js} +27 -8
- package/dist/chunk-LFJ54PIF.js.map +7 -0
- package/dist/chunk-LY5AGXVD.js +21 -0
- package/dist/chunk-VIRIVP7H.js +898 -0
- package/dist/chunk-VIRIVP7H.js.map +7 -0
- package/dist/{chunk-VFWA5W56.js → chunk-XPUHW2YO.js} +44 -7
- package/dist/chunk-XPUHW2YO.js.map +7 -0
- package/dist/editor-lit.js +1 -1
- package/dist/element-session.d.ts +3 -0
- package/dist/element-session.d.ts.map +1 -0
- package/dist/element-session.js +9 -0
- package/dist/element-session.js.map +7 -0
- package/dist/elements/ElementInstanceStore.d.ts +15 -1
- package/dist/elements/ElementInstanceStore.d.ts.map +1 -1
- package/dist/elements/ElementSessionController.d.ts +37 -0
- package/dist/elements/ElementSessionController.d.ts.map +1 -0
- package/dist/elements/ElementSessionController.test.d.ts +2 -0
- package/dist/elements/ElementSessionController.test.d.ts.map +1 -0
- package/dist/elements/TileHandler.d.ts.map +1 -1
- package/dist/elements/createElementStore.d.ts +11 -0
- package/dist/elements/createElementStore.d.ts.map +1 -0
- package/dist/elements/tileLifecycleProps.d.ts +13 -0
- package/dist/elements/tileLifecycleProps.d.ts.map +1 -0
- package/dist/elements/types.d.ts +7 -0
- package/dist/elements/types.d.ts.map +1 -1
- package/dist/hostAgentController.d.ts +65 -0
- package/dist/hostAgentController.d.ts.map +1 -0
- package/dist/hostAgentController.test.d.ts +2 -0
- package/dist/hostAgentController.test.d.ts.map +1 -0
- package/dist/observer/wire.d.ts +54 -0
- package/dist/observer/wire.d.ts.map +1 -0
- package/dist/observer/wire.test.d.ts +2 -0
- package/dist/observer/wire.test.d.ts.map +1 -0
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +824 -163
- package/dist/runtime.js.map +4 -4
- package/dist/schema.d.ts +66 -66
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +113 -75
- package/dist/schema.js.map +3 -3
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -7
- package/dist/chunk-LJEPZI6Y.js.map +0 -7
- package/dist/chunk-NGV35N4T.js +0 -474
- package/dist/chunk-NGV35N4T.js.map +0 -7
- package/dist/chunk-UVKRO5ER.js +0 -13
- package/dist/chunk-VFWA5W56.js.map +0 -7
- /package/dist/{chunk-TZA7572J.js.map → chunk-GN7Z5IVP.js.map} +0 -0
- /package/dist/{chunk-UVKRO5ER.js.map → chunk-LY5AGXVD.js.map} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
createElementSessionController
|
|
3
|
+
} from "./chunk-VIRIVP7H.js";
|
|
4
|
+
import {
|
|
5
|
+
external_exports,
|
|
6
6
|
stripMountPlumbing
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4V5L7IRV.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LY5AGXVD.js";
|
|
11
11
|
|
|
12
12
|
// ../../../node_modules/@ag-ui/client/node_modules/uuid/dist/esm-browser/stringify.js
|
|
13
13
|
var byteToHex = [];
|
|
@@ -62,70 +62,69 @@ function v4(options, buf, offset) {
|
|
|
62
62
|
var v4_default = v4;
|
|
63
63
|
|
|
64
64
|
// ../../../node_modules/@ag-ui/core/dist/index.mjs
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
arguments: z.string()
|
|
65
|
+
var FunctionCallSchema = external_exports.object({
|
|
66
|
+
name: external_exports.string(),
|
|
67
|
+
arguments: external_exports.string()
|
|
69
68
|
});
|
|
70
|
-
var ToolCallSchema =
|
|
71
|
-
id:
|
|
72
|
-
type:
|
|
69
|
+
var ToolCallSchema = external_exports.object({
|
|
70
|
+
id: external_exports.string(),
|
|
71
|
+
type: external_exports.literal("function"),
|
|
73
72
|
function: FunctionCallSchema,
|
|
74
|
-
encryptedValue:
|
|
73
|
+
encryptedValue: external_exports.string().optional()
|
|
75
74
|
});
|
|
76
|
-
var BaseMessageSchema =
|
|
77
|
-
id:
|
|
78
|
-
role:
|
|
79
|
-
content:
|
|
80
|
-
name:
|
|
81
|
-
encryptedValue:
|
|
75
|
+
var BaseMessageSchema = external_exports.object({
|
|
76
|
+
id: external_exports.string(),
|
|
77
|
+
role: external_exports.string(),
|
|
78
|
+
content: external_exports.string().optional(),
|
|
79
|
+
name: external_exports.string().optional(),
|
|
80
|
+
encryptedValue: external_exports.string().optional()
|
|
82
81
|
});
|
|
83
|
-
var TextInputContentSchema =
|
|
84
|
-
type:
|
|
85
|
-
text:
|
|
82
|
+
var TextInputContentSchema = external_exports.object({
|
|
83
|
+
type: external_exports.literal("text"),
|
|
84
|
+
text: external_exports.string()
|
|
86
85
|
});
|
|
87
|
-
var InputContentDataSourceSchema =
|
|
88
|
-
type:
|
|
89
|
-
value:
|
|
90
|
-
mimeType:
|
|
86
|
+
var InputContentDataSourceSchema = external_exports.object({
|
|
87
|
+
type: external_exports.literal("data"),
|
|
88
|
+
value: external_exports.string(),
|
|
89
|
+
mimeType: external_exports.string()
|
|
91
90
|
});
|
|
92
|
-
var InputContentUrlSourceSchema =
|
|
93
|
-
type:
|
|
94
|
-
value:
|
|
95
|
-
mimeType:
|
|
91
|
+
var InputContentUrlSourceSchema = external_exports.object({
|
|
92
|
+
type: external_exports.literal("url"),
|
|
93
|
+
value: external_exports.string(),
|
|
94
|
+
mimeType: external_exports.string().optional()
|
|
96
95
|
});
|
|
97
|
-
var InputContentSourceSchema =
|
|
98
|
-
var ImageInputContentSchema =
|
|
99
|
-
type:
|
|
96
|
+
var InputContentSourceSchema = external_exports.discriminatedUnion("type", [InputContentDataSourceSchema, InputContentUrlSourceSchema]);
|
|
97
|
+
var ImageInputContentSchema = external_exports.object({
|
|
98
|
+
type: external_exports.literal("image"),
|
|
100
99
|
source: InputContentSourceSchema,
|
|
101
|
-
metadata:
|
|
100
|
+
metadata: external_exports.unknown().optional()
|
|
102
101
|
});
|
|
103
|
-
var AudioInputContentSchema =
|
|
104
|
-
type:
|
|
102
|
+
var AudioInputContentSchema = external_exports.object({
|
|
103
|
+
type: external_exports.literal("audio"),
|
|
105
104
|
source: InputContentSourceSchema,
|
|
106
|
-
metadata:
|
|
105
|
+
metadata: external_exports.unknown().optional()
|
|
107
106
|
});
|
|
108
|
-
var VideoInputContentSchema =
|
|
109
|
-
type:
|
|
107
|
+
var VideoInputContentSchema = external_exports.object({
|
|
108
|
+
type: external_exports.literal("video"),
|
|
110
109
|
source: InputContentSourceSchema,
|
|
111
|
-
metadata:
|
|
110
|
+
metadata: external_exports.unknown().optional()
|
|
112
111
|
});
|
|
113
|
-
var DocumentInputContentSchema =
|
|
114
|
-
type:
|
|
112
|
+
var DocumentInputContentSchema = external_exports.object({
|
|
113
|
+
type: external_exports.literal("document"),
|
|
115
114
|
source: InputContentSourceSchema,
|
|
116
|
-
metadata:
|
|
115
|
+
metadata: external_exports.unknown().optional()
|
|
117
116
|
});
|
|
118
|
-
var LegacyBinaryInputContentObjectSchema =
|
|
119
|
-
type:
|
|
120
|
-
mimeType:
|
|
121
|
-
id:
|
|
122
|
-
url:
|
|
123
|
-
data:
|
|
124
|
-
filename:
|
|
117
|
+
var LegacyBinaryInputContentObjectSchema = external_exports.object({
|
|
118
|
+
type: external_exports.literal("binary"),
|
|
119
|
+
mimeType: external_exports.string(),
|
|
120
|
+
id: external_exports.string().optional(),
|
|
121
|
+
url: external_exports.string().optional(),
|
|
122
|
+
data: external_exports.string().optional(),
|
|
123
|
+
filename: external_exports.string().optional()
|
|
125
124
|
});
|
|
126
125
|
var ensureBinaryPayload = (value, ctx) => {
|
|
127
126
|
if (!value.id && !value.url && !value.data) ctx.addIssue({
|
|
128
|
-
code:
|
|
127
|
+
code: external_exports.ZodIssueCode.custom,
|
|
129
128
|
message: "BinaryInputContent requires at least one of id, url, or data.",
|
|
130
129
|
path: ["id"]
|
|
131
130
|
});
|
|
@@ -133,7 +132,7 @@ var ensureBinaryPayload = (value, ctx) => {
|
|
|
133
132
|
var BinaryInputContentSchema = LegacyBinaryInputContentObjectSchema.superRefine((value, ctx) => {
|
|
134
133
|
ensureBinaryPayload(value, ctx);
|
|
135
134
|
});
|
|
136
|
-
var InputContentBaseSchema =
|
|
135
|
+
var InputContentBaseSchema = external_exports.discriminatedUnion("type", [
|
|
137
136
|
TextInputContentSchema,
|
|
138
137
|
ImageInputContentSchema,
|
|
139
138
|
AudioInputContentSchema,
|
|
@@ -145,43 +144,43 @@ var InputContentSchema = InputContentBaseSchema.superRefine((value, ctx) => {
|
|
|
145
144
|
if (value.type === "binary") ensureBinaryPayload(value, ctx);
|
|
146
145
|
});
|
|
147
146
|
var DeveloperMessageSchema = BaseMessageSchema.extend({
|
|
148
|
-
role:
|
|
149
|
-
content:
|
|
147
|
+
role: external_exports.literal("developer"),
|
|
148
|
+
content: external_exports.string()
|
|
150
149
|
});
|
|
151
150
|
var SystemMessageSchema = BaseMessageSchema.extend({
|
|
152
|
-
role:
|
|
153
|
-
content:
|
|
151
|
+
role: external_exports.literal("system"),
|
|
152
|
+
content: external_exports.string()
|
|
154
153
|
});
|
|
155
154
|
var AssistantMessageSchema = BaseMessageSchema.extend({
|
|
156
|
-
role:
|
|
157
|
-
content:
|
|
158
|
-
toolCalls:
|
|
155
|
+
role: external_exports.literal("assistant"),
|
|
156
|
+
content: external_exports.string().optional(),
|
|
157
|
+
toolCalls: external_exports.array(ToolCallSchema).optional()
|
|
159
158
|
});
|
|
160
159
|
var UserMessageSchema = BaseMessageSchema.extend({
|
|
161
|
-
role:
|
|
162
|
-
content:
|
|
160
|
+
role: external_exports.literal("user"),
|
|
161
|
+
content: external_exports.union([external_exports.string(), external_exports.array(InputContentSchema)])
|
|
163
162
|
});
|
|
164
|
-
var ToolMessageSchema =
|
|
165
|
-
id:
|
|
166
|
-
content:
|
|
167
|
-
role:
|
|
168
|
-
toolCallId:
|
|
169
|
-
error:
|
|
170
|
-
encryptedValue:
|
|
163
|
+
var ToolMessageSchema = external_exports.object({
|
|
164
|
+
id: external_exports.string(),
|
|
165
|
+
content: external_exports.string(),
|
|
166
|
+
role: external_exports.literal("tool"),
|
|
167
|
+
toolCallId: external_exports.string(),
|
|
168
|
+
error: external_exports.string().optional(),
|
|
169
|
+
encryptedValue: external_exports.string().optional()
|
|
171
170
|
});
|
|
172
|
-
var ActivityMessageSchema =
|
|
173
|
-
id:
|
|
174
|
-
role:
|
|
175
|
-
activityType:
|
|
176
|
-
content:
|
|
171
|
+
var ActivityMessageSchema = external_exports.object({
|
|
172
|
+
id: external_exports.string(),
|
|
173
|
+
role: external_exports.literal("activity"),
|
|
174
|
+
activityType: external_exports.string(),
|
|
175
|
+
content: external_exports.record(external_exports.any())
|
|
177
176
|
});
|
|
178
|
-
var ReasoningMessageSchema =
|
|
179
|
-
id:
|
|
180
|
-
role:
|
|
181
|
-
content:
|
|
182
|
-
encryptedValue:
|
|
177
|
+
var ReasoningMessageSchema = external_exports.object({
|
|
178
|
+
id: external_exports.string(),
|
|
179
|
+
role: external_exports.literal("reasoning"),
|
|
180
|
+
content: external_exports.string(),
|
|
181
|
+
encryptedValue: external_exports.string().optional()
|
|
183
182
|
});
|
|
184
|
-
var MessageSchema =
|
|
183
|
+
var MessageSchema = external_exports.discriminatedUnion("role", [
|
|
185
184
|
DeveloperMessageSchema,
|
|
186
185
|
SystemMessageSchema,
|
|
187
186
|
AssistantMessageSchema,
|
|
@@ -190,51 +189,51 @@ var MessageSchema = z.discriminatedUnion("role", [
|
|
|
190
189
|
ActivityMessageSchema,
|
|
191
190
|
ReasoningMessageSchema
|
|
192
191
|
]);
|
|
193
|
-
var RoleSchema =
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
var RoleSchema = external_exports.union([
|
|
193
|
+
external_exports.literal("developer"),
|
|
194
|
+
external_exports.literal("system"),
|
|
195
|
+
external_exports.literal("assistant"),
|
|
196
|
+
external_exports.literal("user"),
|
|
197
|
+
external_exports.literal("tool"),
|
|
198
|
+
external_exports.literal("activity"),
|
|
199
|
+
external_exports.literal("reasoning")
|
|
201
200
|
]);
|
|
202
|
-
var ContextSchema =
|
|
203
|
-
description:
|
|
204
|
-
value:
|
|
201
|
+
var ContextSchema = external_exports.object({
|
|
202
|
+
description: external_exports.string(),
|
|
203
|
+
value: external_exports.string()
|
|
205
204
|
});
|
|
206
|
-
var ToolSchema =
|
|
207
|
-
name:
|
|
208
|
-
description:
|
|
209
|
-
parameters:
|
|
210
|
-
metadata:
|
|
205
|
+
var ToolSchema = external_exports.object({
|
|
206
|
+
name: external_exports.string(),
|
|
207
|
+
description: external_exports.string(),
|
|
208
|
+
parameters: external_exports.any(),
|
|
209
|
+
metadata: external_exports.record(external_exports.any()).optional()
|
|
211
210
|
});
|
|
212
|
-
var InterruptSchema =
|
|
213
|
-
id:
|
|
214
|
-
reason:
|
|
215
|
-
message:
|
|
216
|
-
toolCallId:
|
|
217
|
-
responseSchema:
|
|
218
|
-
expiresAt:
|
|
219
|
-
metadata:
|
|
211
|
+
var InterruptSchema = external_exports.object({
|
|
212
|
+
id: external_exports.string(),
|
|
213
|
+
reason: external_exports.string(),
|
|
214
|
+
message: external_exports.string().optional(),
|
|
215
|
+
toolCallId: external_exports.string().optional(),
|
|
216
|
+
responseSchema: external_exports.record(external_exports.any()).optional(),
|
|
217
|
+
expiresAt: external_exports.string().optional(),
|
|
218
|
+
metadata: external_exports.record(external_exports.any()).optional()
|
|
220
219
|
});
|
|
221
|
-
var ResumeEntrySchema =
|
|
222
|
-
interruptId:
|
|
223
|
-
status:
|
|
224
|
-
payload:
|
|
220
|
+
var ResumeEntrySchema = external_exports.object({
|
|
221
|
+
interruptId: external_exports.string(),
|
|
222
|
+
status: external_exports.enum(["resolved", "cancelled"]),
|
|
223
|
+
payload: external_exports.any().optional()
|
|
225
224
|
});
|
|
226
|
-
var RunAgentInputSchema =
|
|
227
|
-
threadId:
|
|
228
|
-
runId:
|
|
229
|
-
parentRunId:
|
|
230
|
-
state:
|
|
231
|
-
messages:
|
|
232
|
-
tools:
|
|
233
|
-
context:
|
|
234
|
-
forwardedProps:
|
|
235
|
-
resume:
|
|
225
|
+
var RunAgentInputSchema = external_exports.object({
|
|
226
|
+
threadId: external_exports.string(),
|
|
227
|
+
runId: external_exports.string(),
|
|
228
|
+
parentRunId: external_exports.string().optional(),
|
|
229
|
+
state: external_exports.any(),
|
|
230
|
+
messages: external_exports.array(MessageSchema),
|
|
231
|
+
tools: external_exports.array(ToolSchema),
|
|
232
|
+
context: external_exports.array(ContextSchema),
|
|
233
|
+
forwardedProps: external_exports.any(),
|
|
234
|
+
resume: external_exports.array(ResumeEntrySchema).optional()
|
|
236
235
|
});
|
|
237
|
-
var StateSchema =
|
|
236
|
+
var StateSchema = external_exports.any();
|
|
238
237
|
var AGUIError = class extends Error {
|
|
239
238
|
constructor(message) {
|
|
240
239
|
super(message);
|
|
@@ -245,83 +244,83 @@ var AGUIConnectNotImplementedError = class extends AGUIError {
|
|
|
245
244
|
super("Connect not implemented. This method is not supported by the current agent.");
|
|
246
245
|
}
|
|
247
246
|
};
|
|
248
|
-
var SubAgentInfoSchema =
|
|
249
|
-
name:
|
|
250
|
-
description:
|
|
247
|
+
var SubAgentInfoSchema = external_exports.object({
|
|
248
|
+
name: external_exports.string(),
|
|
249
|
+
description: external_exports.string().optional()
|
|
251
250
|
});
|
|
252
|
-
var IdentityCapabilitiesSchema =
|
|
253
|
-
name:
|
|
254
|
-
type:
|
|
255
|
-
description:
|
|
256
|
-
version:
|
|
257
|
-
provider:
|
|
258
|
-
documentationUrl:
|
|
259
|
-
metadata:
|
|
251
|
+
var IdentityCapabilitiesSchema = external_exports.object({
|
|
252
|
+
name: external_exports.string().optional(),
|
|
253
|
+
type: external_exports.string().optional(),
|
|
254
|
+
description: external_exports.string().optional(),
|
|
255
|
+
version: external_exports.string().optional(),
|
|
256
|
+
provider: external_exports.string().optional(),
|
|
257
|
+
documentationUrl: external_exports.string().optional(),
|
|
258
|
+
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
260
259
|
});
|
|
261
|
-
var TransportCapabilitiesSchema =
|
|
262
|
-
streaming:
|
|
263
|
-
websocket:
|
|
264
|
-
httpBinary:
|
|
265
|
-
pushNotifications:
|
|
266
|
-
resumable:
|
|
260
|
+
var TransportCapabilitiesSchema = external_exports.object({
|
|
261
|
+
streaming: external_exports.boolean().optional(),
|
|
262
|
+
websocket: external_exports.boolean().optional(),
|
|
263
|
+
httpBinary: external_exports.boolean().optional(),
|
|
264
|
+
pushNotifications: external_exports.boolean().optional(),
|
|
265
|
+
resumable: external_exports.boolean().optional()
|
|
267
266
|
});
|
|
268
|
-
var ToolsCapabilitiesSchema =
|
|
269
|
-
supported:
|
|
270
|
-
items:
|
|
271
|
-
parallelCalls:
|
|
272
|
-
clientProvided:
|
|
267
|
+
var ToolsCapabilitiesSchema = external_exports.object({
|
|
268
|
+
supported: external_exports.boolean().optional(),
|
|
269
|
+
items: external_exports.array(ToolSchema).optional(),
|
|
270
|
+
parallelCalls: external_exports.boolean().optional(),
|
|
271
|
+
clientProvided: external_exports.boolean().optional()
|
|
273
272
|
});
|
|
274
|
-
var OutputCapabilitiesSchema =
|
|
275
|
-
structuredOutput:
|
|
276
|
-
supportedMimeTypes:
|
|
273
|
+
var OutputCapabilitiesSchema = external_exports.object({
|
|
274
|
+
structuredOutput: external_exports.boolean().optional(),
|
|
275
|
+
supportedMimeTypes: external_exports.array(external_exports.string()).optional()
|
|
277
276
|
});
|
|
278
|
-
var StateCapabilitiesSchema =
|
|
279
|
-
snapshots:
|
|
280
|
-
deltas:
|
|
281
|
-
memory:
|
|
282
|
-
persistentState:
|
|
277
|
+
var StateCapabilitiesSchema = external_exports.object({
|
|
278
|
+
snapshots: external_exports.boolean().optional(),
|
|
279
|
+
deltas: external_exports.boolean().optional(),
|
|
280
|
+
memory: external_exports.boolean().optional(),
|
|
281
|
+
persistentState: external_exports.boolean().optional()
|
|
283
282
|
});
|
|
284
|
-
var MultiAgentCapabilitiesSchema =
|
|
285
|
-
supported:
|
|
286
|
-
delegation:
|
|
287
|
-
handoffs:
|
|
288
|
-
subAgents:
|
|
283
|
+
var MultiAgentCapabilitiesSchema = external_exports.object({
|
|
284
|
+
supported: external_exports.boolean().optional(),
|
|
285
|
+
delegation: external_exports.boolean().optional(),
|
|
286
|
+
handoffs: external_exports.boolean().optional(),
|
|
287
|
+
subAgents: external_exports.array(SubAgentInfoSchema).optional()
|
|
289
288
|
});
|
|
290
|
-
var ReasoningCapabilitiesSchema =
|
|
291
|
-
supported:
|
|
292
|
-
streaming:
|
|
293
|
-
encrypted:
|
|
289
|
+
var ReasoningCapabilitiesSchema = external_exports.object({
|
|
290
|
+
supported: external_exports.boolean().optional(),
|
|
291
|
+
streaming: external_exports.boolean().optional(),
|
|
292
|
+
encrypted: external_exports.boolean().optional()
|
|
294
293
|
});
|
|
295
|
-
var MultimodalInputCapabilitiesSchema =
|
|
296
|
-
image:
|
|
297
|
-
audio:
|
|
298
|
-
video:
|
|
299
|
-
pdf:
|
|
300
|
-
file:
|
|
294
|
+
var MultimodalInputCapabilitiesSchema = external_exports.object({
|
|
295
|
+
image: external_exports.boolean().optional(),
|
|
296
|
+
audio: external_exports.boolean().optional(),
|
|
297
|
+
video: external_exports.boolean().optional(),
|
|
298
|
+
pdf: external_exports.boolean().optional(),
|
|
299
|
+
file: external_exports.boolean().optional()
|
|
301
300
|
});
|
|
302
|
-
var MultimodalOutputCapabilitiesSchema =
|
|
303
|
-
image:
|
|
304
|
-
audio:
|
|
301
|
+
var MultimodalOutputCapabilitiesSchema = external_exports.object({
|
|
302
|
+
image: external_exports.boolean().optional(),
|
|
303
|
+
audio: external_exports.boolean().optional()
|
|
305
304
|
});
|
|
306
|
-
var MultimodalCapabilitiesSchema =
|
|
305
|
+
var MultimodalCapabilitiesSchema = external_exports.object({
|
|
307
306
|
input: MultimodalInputCapabilitiesSchema.optional(),
|
|
308
307
|
output: MultimodalOutputCapabilitiesSchema.optional()
|
|
309
308
|
});
|
|
310
|
-
var ExecutionCapabilitiesSchema =
|
|
311
|
-
codeExecution:
|
|
312
|
-
sandboxed:
|
|
313
|
-
maxIterations:
|
|
314
|
-
maxExecutionTime:
|
|
309
|
+
var ExecutionCapabilitiesSchema = external_exports.object({
|
|
310
|
+
codeExecution: external_exports.boolean().optional(),
|
|
311
|
+
sandboxed: external_exports.boolean().optional(),
|
|
312
|
+
maxIterations: external_exports.number().optional(),
|
|
313
|
+
maxExecutionTime: external_exports.number().optional()
|
|
315
314
|
});
|
|
316
|
-
var HumanInTheLoopCapabilitiesSchema =
|
|
317
|
-
supported:
|
|
318
|
-
approvals:
|
|
319
|
-
interventions:
|
|
320
|
-
feedback:
|
|
321
|
-
interrupts:
|
|
322
|
-
approveWithEdits:
|
|
315
|
+
var HumanInTheLoopCapabilitiesSchema = external_exports.object({
|
|
316
|
+
supported: external_exports.boolean().optional(),
|
|
317
|
+
approvals: external_exports.boolean().optional(),
|
|
318
|
+
interventions: external_exports.boolean().optional(),
|
|
319
|
+
feedback: external_exports.boolean().optional(),
|
|
320
|
+
interrupts: external_exports.boolean().optional(),
|
|
321
|
+
approveWithEdits: external_exports.boolean().optional()
|
|
323
322
|
});
|
|
324
|
-
var AgentCapabilitiesSchema =
|
|
323
|
+
var AgentCapabilitiesSchema = external_exports.object({
|
|
325
324
|
identity: IdentityCapabilitiesSchema.optional(),
|
|
326
325
|
transport: TransportCapabilitiesSchema.optional(),
|
|
327
326
|
tools: ToolsCapabilitiesSchema.optional(),
|
|
@@ -332,13 +331,13 @@ var AgentCapabilitiesSchema = z.object({
|
|
|
332
331
|
multimodal: MultimodalCapabilitiesSchema.optional(),
|
|
333
332
|
execution: ExecutionCapabilitiesSchema.optional(),
|
|
334
333
|
humanInTheLoop: HumanInTheLoopCapabilitiesSchema.optional(),
|
|
335
|
-
custom:
|
|
334
|
+
custom: external_exports.record(external_exports.unknown()).optional()
|
|
336
335
|
});
|
|
337
|
-
var TextMessageRoleSchema =
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
336
|
+
var TextMessageRoleSchema = external_exports.union([
|
|
337
|
+
external_exports.literal("developer"),
|
|
338
|
+
external_exports.literal("system"),
|
|
339
|
+
external_exports.literal("assistant"),
|
|
340
|
+
external_exports.literal("user")
|
|
342
341
|
]);
|
|
343
342
|
var EventType = /* @__PURE__ */ (function(EventType2) {
|
|
344
343
|
EventType2["TEXT_MESSAGE_START"] = "TEXT_MESSAGE_START";
|
|
@@ -376,176 +375,176 @@ var EventType = /* @__PURE__ */ (function(EventType2) {
|
|
|
376
375
|
EventType2["REASONING_ENCRYPTED_VALUE"] = "REASONING_ENCRYPTED_VALUE";
|
|
377
376
|
return EventType2;
|
|
378
377
|
})({});
|
|
379
|
-
var BaseEventSchema =
|
|
380
|
-
type:
|
|
381
|
-
timestamp:
|
|
382
|
-
rawEvent:
|
|
378
|
+
var BaseEventSchema = external_exports.object({
|
|
379
|
+
type: external_exports.nativeEnum(EventType),
|
|
380
|
+
timestamp: external_exports.number().optional(),
|
|
381
|
+
rawEvent: external_exports.any().optional()
|
|
383
382
|
}).passthrough();
|
|
384
383
|
var TextMessageStartEventSchema = BaseEventSchema.extend({
|
|
385
|
-
type:
|
|
386
|
-
messageId:
|
|
384
|
+
type: external_exports.literal(EventType.TEXT_MESSAGE_START),
|
|
385
|
+
messageId: external_exports.string(),
|
|
387
386
|
role: TextMessageRoleSchema.default("assistant"),
|
|
388
|
-
name:
|
|
387
|
+
name: external_exports.string().optional()
|
|
389
388
|
});
|
|
390
389
|
var TextMessageContentEventSchema = BaseEventSchema.extend({
|
|
391
|
-
type:
|
|
392
|
-
messageId:
|
|
393
|
-
delta:
|
|
390
|
+
type: external_exports.literal(EventType.TEXT_MESSAGE_CONTENT),
|
|
391
|
+
messageId: external_exports.string(),
|
|
392
|
+
delta: external_exports.string()
|
|
394
393
|
});
|
|
395
394
|
var TextMessageEndEventSchema = BaseEventSchema.extend({
|
|
396
|
-
type:
|
|
397
|
-
messageId:
|
|
395
|
+
type: external_exports.literal(EventType.TEXT_MESSAGE_END),
|
|
396
|
+
messageId: external_exports.string()
|
|
398
397
|
});
|
|
399
398
|
var TextMessageChunkEventSchema = BaseEventSchema.extend({
|
|
400
|
-
type:
|
|
401
|
-
messageId:
|
|
399
|
+
type: external_exports.literal(EventType.TEXT_MESSAGE_CHUNK),
|
|
400
|
+
messageId: external_exports.string().optional(),
|
|
402
401
|
role: TextMessageRoleSchema.optional(),
|
|
403
|
-
delta:
|
|
404
|
-
name:
|
|
402
|
+
delta: external_exports.string().optional(),
|
|
403
|
+
name: external_exports.string().optional()
|
|
405
404
|
});
|
|
406
|
-
var ThinkingTextMessageStartEventSchema = BaseEventSchema.extend({ type:
|
|
405
|
+
var ThinkingTextMessageStartEventSchema = BaseEventSchema.extend({ type: external_exports.literal(EventType.THINKING_TEXT_MESSAGE_START) });
|
|
407
406
|
var ThinkingTextMessageContentEventSchema = TextMessageContentEventSchema.omit({
|
|
408
407
|
messageId: true,
|
|
409
408
|
type: true
|
|
410
|
-
}).extend({ type:
|
|
411
|
-
var ThinkingTextMessageEndEventSchema = BaseEventSchema.extend({ type:
|
|
409
|
+
}).extend({ type: external_exports.literal(EventType.THINKING_TEXT_MESSAGE_CONTENT) });
|
|
410
|
+
var ThinkingTextMessageEndEventSchema = BaseEventSchema.extend({ type: external_exports.literal(EventType.THINKING_TEXT_MESSAGE_END) });
|
|
412
411
|
var ToolCallStartEventSchema = BaseEventSchema.extend({
|
|
413
|
-
type:
|
|
414
|
-
toolCallId:
|
|
415
|
-
toolCallName:
|
|
416
|
-
parentMessageId:
|
|
412
|
+
type: external_exports.literal(EventType.TOOL_CALL_START),
|
|
413
|
+
toolCallId: external_exports.string(),
|
|
414
|
+
toolCallName: external_exports.string(),
|
|
415
|
+
parentMessageId: external_exports.string().optional()
|
|
417
416
|
});
|
|
418
417
|
var ToolCallArgsEventSchema = BaseEventSchema.extend({
|
|
419
|
-
type:
|
|
420
|
-
toolCallId:
|
|
421
|
-
delta:
|
|
418
|
+
type: external_exports.literal(EventType.TOOL_CALL_ARGS),
|
|
419
|
+
toolCallId: external_exports.string(),
|
|
420
|
+
delta: external_exports.string()
|
|
422
421
|
});
|
|
423
422
|
var ToolCallEndEventSchema = BaseEventSchema.extend({
|
|
424
|
-
type:
|
|
425
|
-
toolCallId:
|
|
423
|
+
type: external_exports.literal(EventType.TOOL_CALL_END),
|
|
424
|
+
toolCallId: external_exports.string()
|
|
426
425
|
});
|
|
427
426
|
var ToolCallResultEventSchema = BaseEventSchema.extend({
|
|
428
|
-
messageId:
|
|
429
|
-
type:
|
|
430
|
-
toolCallId:
|
|
431
|
-
content:
|
|
432
|
-
role:
|
|
427
|
+
messageId: external_exports.string(),
|
|
428
|
+
type: external_exports.literal(EventType.TOOL_CALL_RESULT),
|
|
429
|
+
toolCallId: external_exports.string(),
|
|
430
|
+
content: external_exports.string(),
|
|
431
|
+
role: external_exports.literal("tool").optional()
|
|
433
432
|
});
|
|
434
433
|
var ToolCallChunkEventSchema = BaseEventSchema.extend({
|
|
435
|
-
type:
|
|
436
|
-
toolCallId:
|
|
437
|
-
toolCallName:
|
|
438
|
-
parentMessageId:
|
|
439
|
-
delta:
|
|
434
|
+
type: external_exports.literal(EventType.TOOL_CALL_CHUNK),
|
|
435
|
+
toolCallId: external_exports.string().optional(),
|
|
436
|
+
toolCallName: external_exports.string().optional(),
|
|
437
|
+
parentMessageId: external_exports.string().optional(),
|
|
438
|
+
delta: external_exports.string().optional()
|
|
440
439
|
});
|
|
441
440
|
var ThinkingStartEventSchema = BaseEventSchema.extend({
|
|
442
|
-
type:
|
|
443
|
-
title:
|
|
441
|
+
type: external_exports.literal(EventType.THINKING_START),
|
|
442
|
+
title: external_exports.string().optional()
|
|
444
443
|
});
|
|
445
|
-
var ThinkingEndEventSchema = BaseEventSchema.extend({ type:
|
|
444
|
+
var ThinkingEndEventSchema = BaseEventSchema.extend({ type: external_exports.literal(EventType.THINKING_END) });
|
|
446
445
|
var StateSnapshotEventSchema = BaseEventSchema.extend({
|
|
447
|
-
type:
|
|
446
|
+
type: external_exports.literal(EventType.STATE_SNAPSHOT),
|
|
448
447
|
snapshot: StateSchema
|
|
449
448
|
});
|
|
450
449
|
var StateDeltaEventSchema = BaseEventSchema.extend({
|
|
451
|
-
type:
|
|
452
|
-
delta:
|
|
450
|
+
type: external_exports.literal(EventType.STATE_DELTA),
|
|
451
|
+
delta: external_exports.array(external_exports.any())
|
|
453
452
|
});
|
|
454
453
|
var MessagesSnapshotEventSchema = BaseEventSchema.extend({
|
|
455
|
-
type:
|
|
456
|
-
messages:
|
|
454
|
+
type: external_exports.literal(EventType.MESSAGES_SNAPSHOT),
|
|
455
|
+
messages: external_exports.array(MessageSchema)
|
|
457
456
|
});
|
|
458
457
|
var ActivitySnapshotEventSchema = BaseEventSchema.extend({
|
|
459
|
-
type:
|
|
460
|
-
messageId:
|
|
461
|
-
activityType:
|
|
462
|
-
content:
|
|
463
|
-
replace:
|
|
458
|
+
type: external_exports.literal(EventType.ACTIVITY_SNAPSHOT),
|
|
459
|
+
messageId: external_exports.string(),
|
|
460
|
+
activityType: external_exports.string(),
|
|
461
|
+
content: external_exports.record(external_exports.any()),
|
|
462
|
+
replace: external_exports.boolean().optional().default(true)
|
|
464
463
|
});
|
|
465
464
|
var ActivityDeltaEventSchema = BaseEventSchema.extend({
|
|
466
|
-
type:
|
|
467
|
-
messageId:
|
|
468
|
-
activityType:
|
|
469
|
-
patch:
|
|
465
|
+
type: external_exports.literal(EventType.ACTIVITY_DELTA),
|
|
466
|
+
messageId: external_exports.string(),
|
|
467
|
+
activityType: external_exports.string(),
|
|
468
|
+
patch: external_exports.array(external_exports.any())
|
|
470
469
|
});
|
|
471
470
|
var RawEventSchema = BaseEventSchema.extend({
|
|
472
|
-
type:
|
|
473
|
-
event:
|
|
474
|
-
source:
|
|
471
|
+
type: external_exports.literal(EventType.RAW),
|
|
472
|
+
event: external_exports.any(),
|
|
473
|
+
source: external_exports.string().optional()
|
|
475
474
|
});
|
|
476
475
|
var CustomEventSchema = BaseEventSchema.extend({
|
|
477
|
-
type:
|
|
478
|
-
name:
|
|
479
|
-
value:
|
|
476
|
+
type: external_exports.literal(EventType.CUSTOM),
|
|
477
|
+
name: external_exports.string(),
|
|
478
|
+
value: external_exports.any()
|
|
480
479
|
});
|
|
481
480
|
var RunStartedEventSchema = BaseEventSchema.extend({
|
|
482
|
-
type:
|
|
483
|
-
threadId:
|
|
484
|
-
runId:
|
|
485
|
-
parentRunId:
|
|
481
|
+
type: external_exports.literal(EventType.RUN_STARTED),
|
|
482
|
+
threadId: external_exports.string(),
|
|
483
|
+
runId: external_exports.string(),
|
|
484
|
+
parentRunId: external_exports.string().optional(),
|
|
486
485
|
input: RunAgentInputSchema.optional()
|
|
487
486
|
});
|
|
488
|
-
var RunFinishedSuccessOutcomeSchema =
|
|
489
|
-
var RunFinishedInterruptOutcomeSchema =
|
|
490
|
-
type:
|
|
491
|
-
interrupts:
|
|
487
|
+
var RunFinishedSuccessOutcomeSchema = external_exports.object({ type: external_exports.literal("success") }).strict();
|
|
488
|
+
var RunFinishedInterruptOutcomeSchema = external_exports.object({
|
|
489
|
+
type: external_exports.literal("interrupt"),
|
|
490
|
+
interrupts: external_exports.array(InterruptSchema).min(1)
|
|
492
491
|
}).strict();
|
|
493
|
-
var RunFinishedOutcomeSchema =
|
|
492
|
+
var RunFinishedOutcomeSchema = external_exports.discriminatedUnion("type", [RunFinishedSuccessOutcomeSchema, RunFinishedInterruptOutcomeSchema]);
|
|
494
493
|
var RunFinishedEventSchema = BaseEventSchema.extend({
|
|
495
|
-
type:
|
|
496
|
-
threadId:
|
|
497
|
-
runId:
|
|
498
|
-
result:
|
|
494
|
+
type: external_exports.literal(EventType.RUN_FINISHED),
|
|
495
|
+
threadId: external_exports.string(),
|
|
496
|
+
runId: external_exports.string(),
|
|
497
|
+
result: external_exports.any().optional(),
|
|
499
498
|
outcome: RunFinishedOutcomeSchema.nullable().optional().transform((v) => v ?? void 0)
|
|
500
499
|
});
|
|
501
500
|
var RunErrorEventSchema = BaseEventSchema.extend({
|
|
502
|
-
type:
|
|
503
|
-
message:
|
|
504
|
-
code:
|
|
501
|
+
type: external_exports.literal(EventType.RUN_ERROR),
|
|
502
|
+
message: external_exports.string(),
|
|
503
|
+
code: external_exports.string().optional()
|
|
505
504
|
});
|
|
506
505
|
var StepStartedEventSchema = BaseEventSchema.extend({
|
|
507
|
-
type:
|
|
508
|
-
stepName:
|
|
506
|
+
type: external_exports.literal(EventType.STEP_STARTED),
|
|
507
|
+
stepName: external_exports.string()
|
|
509
508
|
});
|
|
510
509
|
var StepFinishedEventSchema = BaseEventSchema.extend({
|
|
511
|
-
type:
|
|
512
|
-
stepName:
|
|
510
|
+
type: external_exports.literal(EventType.STEP_FINISHED),
|
|
511
|
+
stepName: external_exports.string()
|
|
513
512
|
});
|
|
514
|
-
var ReasoningEncryptedValueSubtypeSchema =
|
|
513
|
+
var ReasoningEncryptedValueSubtypeSchema = external_exports.union([external_exports.literal("tool-call"), external_exports.literal("message")]);
|
|
515
514
|
var ReasoningStartEventSchema = BaseEventSchema.extend({
|
|
516
|
-
type:
|
|
517
|
-
messageId:
|
|
515
|
+
type: external_exports.literal(EventType.REASONING_START),
|
|
516
|
+
messageId: external_exports.string()
|
|
518
517
|
});
|
|
519
518
|
var ReasoningMessageStartEventSchema = BaseEventSchema.extend({
|
|
520
|
-
type:
|
|
521
|
-
messageId:
|
|
522
|
-
role:
|
|
519
|
+
type: external_exports.literal(EventType.REASONING_MESSAGE_START),
|
|
520
|
+
messageId: external_exports.string(),
|
|
521
|
+
role: external_exports.literal("reasoning")
|
|
523
522
|
});
|
|
524
523
|
var ReasoningMessageContentEventSchema = BaseEventSchema.extend({
|
|
525
|
-
type:
|
|
526
|
-
messageId:
|
|
527
|
-
delta:
|
|
524
|
+
type: external_exports.literal(EventType.REASONING_MESSAGE_CONTENT),
|
|
525
|
+
messageId: external_exports.string(),
|
|
526
|
+
delta: external_exports.string()
|
|
528
527
|
});
|
|
529
528
|
var ReasoningMessageEndEventSchema = BaseEventSchema.extend({
|
|
530
|
-
type:
|
|
531
|
-
messageId:
|
|
529
|
+
type: external_exports.literal(EventType.REASONING_MESSAGE_END),
|
|
530
|
+
messageId: external_exports.string()
|
|
532
531
|
});
|
|
533
532
|
var ReasoningMessageChunkEventSchema = BaseEventSchema.extend({
|
|
534
|
-
type:
|
|
535
|
-
messageId:
|
|
536
|
-
delta:
|
|
533
|
+
type: external_exports.literal(EventType.REASONING_MESSAGE_CHUNK),
|
|
534
|
+
messageId: external_exports.string().optional(),
|
|
535
|
+
delta: external_exports.string().optional()
|
|
537
536
|
});
|
|
538
537
|
var ReasoningEndEventSchema = BaseEventSchema.extend({
|
|
539
|
-
type:
|
|
540
|
-
messageId:
|
|
538
|
+
type: external_exports.literal(EventType.REASONING_END),
|
|
539
|
+
messageId: external_exports.string()
|
|
541
540
|
});
|
|
542
541
|
var ReasoningEncryptedValueEventSchema = BaseEventSchema.extend({
|
|
543
|
-
type:
|
|
542
|
+
type: external_exports.literal(EventType.REASONING_ENCRYPTED_VALUE),
|
|
544
543
|
subtype: ReasoningEncryptedValueSubtypeSchema,
|
|
545
|
-
entityId:
|
|
546
|
-
encryptedValue:
|
|
544
|
+
entityId: external_exports.string(),
|
|
545
|
+
encryptedValue: external_exports.string()
|
|
547
546
|
});
|
|
548
|
-
var EventSchemas =
|
|
547
|
+
var EventSchemas = external_exports.discriminatedUnion("type", [
|
|
549
548
|
TextMessageStartEventSchema,
|
|
550
549
|
TextMessageContentEventSchema,
|
|
551
550
|
TextMessageEndEventSchema,
|
|
@@ -6205,9 +6204,6 @@ function decode(data) {
|
|
|
6205
6204
|
}
|
|
6206
6205
|
var AGUI_MEDIA_TYPE = "application/vnd.ag-ui.event+proto";
|
|
6207
6206
|
|
|
6208
|
-
// ../../../node_modules/@ag-ui/client/dist/index.mjs
|
|
6209
|
-
import { z as T } from "zod";
|
|
6210
|
-
|
|
6211
6207
|
// ../../../node_modules/compare-versions/lib/esm/utils.js
|
|
6212
6208
|
var semver = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
|
|
6213
6209
|
var validateAndParse = (version) => {
|
|
@@ -6694,7 +6690,7 @@ var R = (e) => defer(() => from(e())).pipe(switchMap((e2) => {
|
|
|
6694
6690
|
});
|
|
6695
6691
|
})) : throwError(() => Error(`Failed to getReader() from response`));
|
|
6696
6692
|
}));
|
|
6697
|
-
var
|
|
6693
|
+
var z = (e, t) => {
|
|
6698
6694
|
let n = M(t), r = new Subject(), i = new TextDecoder(`utf-8`, { fatal: false }), a = ``;
|
|
6699
6695
|
e.subscribe({ next: (e2) => {
|
|
6700
6696
|
if (e2.type !== L.HEADERS && e2.type === L.DATA && e2.data) {
|
|
@@ -6758,7 +6754,7 @@ var V = (e, t) => {
|
|
|
6758
6754
|
if (o.next(e2), e2.type === L.HEADERS && !s) {
|
|
6759
6755
|
s = true;
|
|
6760
6756
|
let t2 = e2.headers.get(`content-type`);
|
|
6761
|
-
n?.lifecycle(`HTTP`, `Stream format detected:`, { contentType: t2, parser: t2 === AGUI_MEDIA_TYPE ? `protobuf` : `sse` }), t2 === AGUI_MEDIA_TYPE ? B(o).subscribe({ next: (e3) => a.next(e3), error: (e3) => a.error(e3), complete: () => a.complete() }) :
|
|
6757
|
+
n?.lifecycle(`HTTP`, `Stream format detected:`, { contentType: t2, parser: t2 === AGUI_MEDIA_TYPE ? `protobuf` : `sse` }), t2 === AGUI_MEDIA_TYPE ? B(o).subscribe({ next: (e3) => a.next(e3), error: (e3) => a.error(e3), complete: () => a.complete() }) : z(o, n).subscribe({ next: (e3) => {
|
|
6762
6758
|
try {
|
|
6763
6759
|
let t3 = EventSchemas.parse(e3);
|
|
6764
6760
|
n?.event(`HTTP`, `Event validated:`, t3, { type: t3.type, valid: true }), a.next(t3);
|
|
@@ -6779,19 +6775,19 @@ var V = (e, t) => {
|
|
|
6779
6775
|
o.complete();
|
|
6780
6776
|
} }), a.asObservable();
|
|
6781
6777
|
};
|
|
6782
|
-
var H =
|
|
6783
|
-
var se =
|
|
6784
|
-
var ce =
|
|
6785
|
-
var le =
|
|
6786
|
-
var ue =
|
|
6787
|
-
var de =
|
|
6788
|
-
var fe =
|
|
6789
|
-
var pe =
|
|
6790
|
-
var me =
|
|
6791
|
-
var he =
|
|
6792
|
-
var ge =
|
|
6793
|
-
var _e =
|
|
6794
|
-
|
|
6778
|
+
var H = external_exports.enum([`TextMessageStart`, `TextMessageContent`, `TextMessageEnd`, `ActionExecutionStart`, `ActionExecutionArgs`, `ActionExecutionEnd`, `ActionExecutionResult`, `AgentStateMessage`, `MetaEvent`, `RunStarted`, `RunFinished`, `RunError`, `NodeStarted`, `NodeFinished`]);
|
|
6779
|
+
var se = external_exports.enum([`LangGraphInterruptEvent`, `PredictState`, `Exit`]);
|
|
6780
|
+
var ce = external_exports.object({ type: external_exports.literal(H.enum.TextMessageStart), messageId: external_exports.string(), parentMessageId: external_exports.string().optional(), role: external_exports.string().optional() });
|
|
6781
|
+
var le = external_exports.object({ type: external_exports.literal(H.enum.TextMessageContent), messageId: external_exports.string(), content: external_exports.string() });
|
|
6782
|
+
var ue = external_exports.object({ type: external_exports.literal(H.enum.TextMessageEnd), messageId: external_exports.string() });
|
|
6783
|
+
var de = external_exports.object({ type: external_exports.literal(H.enum.ActionExecutionStart), actionExecutionId: external_exports.string(), actionName: external_exports.string(), parentMessageId: external_exports.string().optional() });
|
|
6784
|
+
var fe = external_exports.object({ type: external_exports.literal(H.enum.ActionExecutionArgs), actionExecutionId: external_exports.string(), args: external_exports.string() });
|
|
6785
|
+
var pe = external_exports.object({ type: external_exports.literal(H.enum.ActionExecutionEnd), actionExecutionId: external_exports.string() });
|
|
6786
|
+
var me = external_exports.object({ type: external_exports.literal(H.enum.ActionExecutionResult), actionName: external_exports.string(), actionExecutionId: external_exports.string(), result: external_exports.string() });
|
|
6787
|
+
var he = external_exports.object({ type: external_exports.literal(H.enum.AgentStateMessage), threadId: external_exports.string(), agentName: external_exports.string(), nodeName: external_exports.string(), runId: external_exports.string(), active: external_exports.boolean(), role: external_exports.string(), state: external_exports.string(), running: external_exports.boolean() });
|
|
6788
|
+
var ge = external_exports.object({ type: external_exports.literal(H.enum.MetaEvent), name: se, value: external_exports.any() });
|
|
6789
|
+
var _e = external_exports.object({ type: external_exports.literal(H.enum.RunError), message: external_exports.string(), code: external_exports.string().optional() });
|
|
6790
|
+
external_exports.discriminatedUnion(`type`, [ce, le, ue, de, fe, pe, me, he, ge, _e]), external_exports.object({ id: external_exports.string(), role: external_exports.string(), content: external_exports.string(), parentMessageId: external_exports.string().optional() }), external_exports.object({ id: external_exports.string(), name: external_exports.string(), arguments: external_exports.any(), parentMessageId: external_exports.string().optional() }), external_exports.object({ id: external_exports.string(), result: external_exports.any(), actionExecutionId: external_exports.string(), actionName: external_exports.string() });
|
|
6795
6791
|
var ve = (e) => {
|
|
6796
6792
|
if (typeof e == `string`) return e;
|
|
6797
6793
|
if (!Array.isArray(e)) return;
|
|
@@ -7747,476 +7743,6 @@ var AgUiTransport = class {
|
|
|
7747
7743
|
}
|
|
7748
7744
|
};
|
|
7749
7745
|
|
|
7750
|
-
// src/elements/ActionHandler.ts
|
|
7751
|
-
var ActionHandler = class {
|
|
7752
|
-
constructor() {
|
|
7753
|
-
this.typeName = "action";
|
|
7754
|
-
// v1: only imperative actions are wired. Stateful content-mutation
|
|
7755
|
-
// actions arrive with Phase 7 (Portable Text renderer).
|
|
7756
|
-
this.lifecycle = "imperative";
|
|
7757
|
-
}
|
|
7758
|
-
validate(instance, _ctx) {
|
|
7759
|
-
if (instance.element_type !== "action") {
|
|
7760
|
-
return { accepted: false, reason: "wrong_element_type" };
|
|
7761
|
-
}
|
|
7762
|
-
const kind = instance.content.__kind;
|
|
7763
|
-
if (typeof kind !== "string" || kind.length === 0) {
|
|
7764
|
-
return { accepted: false, reason: "missing_action_kind" };
|
|
7765
|
-
}
|
|
7766
|
-
return { accepted: true };
|
|
7767
|
-
}
|
|
7768
|
-
async mount(instance, ctx) {
|
|
7769
|
-
const action = this._actionFromInstance(instance);
|
|
7770
|
-
await ctx.actions.applyBatch([action]);
|
|
7771
|
-
}
|
|
7772
|
-
async patch(_instance, _ctx) {
|
|
7773
|
-
}
|
|
7774
|
-
async unmount(_instance, _ctx) {
|
|
7775
|
-
}
|
|
7776
|
-
_actionFromInstance(instance) {
|
|
7777
|
-
const { __kind, ...params } = instance.content;
|
|
7778
|
-
const placement = instance.placement;
|
|
7779
|
-
const anchorOverride = placement.type === "selector" ? { anchorId: { selector: placement.selector, route: "**" } } : {};
|
|
7780
|
-
if (typeof params.anchorId === "string") {
|
|
7781
|
-
params.anchorId = { selector: params.anchorId, route: "**" };
|
|
7782
|
-
}
|
|
7783
|
-
return {
|
|
7784
|
-
kind: __kind,
|
|
7785
|
-
...params,
|
|
7786
|
-
...anchorOverride,
|
|
7787
|
-
label: `action:${instance.template_id}:${instance.instance_id}`
|
|
7788
|
-
};
|
|
7789
|
-
}
|
|
7790
|
-
};
|
|
7791
|
-
|
|
7792
|
-
// src/elements/ElementInstanceStore.ts
|
|
7793
|
-
var COMPOSITIONAL_REPLAY_REQUEST_EVENT = "element.compositional_replay_request";
|
|
7794
|
-
var COMPOSITIONAL_APPEND_EVENT = "element.compositional_append";
|
|
7795
|
-
var CHAT_INLINE_SLOT = "chat-inline";
|
|
7796
|
-
var ElementInstanceStore = class {
|
|
7797
|
-
constructor(options) {
|
|
7798
|
-
this._instances = /* @__PURE__ */ new Map();
|
|
7799
|
-
/** Active TTL timeout — replaced on each call to `scheduleClientTtl`. */
|
|
7800
|
-
this._ttlTimer = null;
|
|
7801
|
-
/** Instance IDs the client has dismissed. Persists across canvas remounts
|
|
7802
|
-
* so a dismissed tile never silently reappears on replay/broadcast. */
|
|
7803
|
-
this._dismissedIds = /* @__PURE__ */ new Set();
|
|
7804
|
-
this._actions = options.actions;
|
|
7805
|
-
this._events = options.events;
|
|
7806
|
-
this._resolveTileWidget = options.resolveTileWidget;
|
|
7807
|
-
this._handlers = /* @__PURE__ */ new Map();
|
|
7808
|
-
for (const handler of options.handlers ?? []) {
|
|
7809
|
-
this._handlers.set(handler.typeName, handler);
|
|
7810
|
-
}
|
|
7811
|
-
this._logger = options.logger ?? console;
|
|
7812
|
-
this._subscribeReplayRequests();
|
|
7813
|
-
}
|
|
7814
|
-
/**
|
|
7815
|
-
* Listen for `element.compositional_replay_request` from container
|
|
7816
|
-
* widgets and re-publish `element.compositional_append` for every
|
|
7817
|
-
* matching item still tracked in `_instances`. This keeps LLM-authored
|
|
7818
|
-
* items visible across SPA navigations: the store is a module-level
|
|
7819
|
-
* singleton that survives chat-bar unmount/remount, so when a fresh
|
|
7820
|
-
* chips-strip mounts and subscribes, asking for a replay re-populates
|
|
7821
|
-
* its chip array.
|
|
7822
|
-
*/
|
|
7823
|
-
_subscribeReplayRequests() {
|
|
7824
|
-
const subscribe = this._events?.subscribe;
|
|
7825
|
-
const publish = this._events?.publish;
|
|
7826
|
-
if (!subscribe || !publish) return;
|
|
7827
|
-
subscribe(
|
|
7828
|
-
{
|
|
7829
|
-
names: [
|
|
7830
|
-
COMPOSITIONAL_REPLAY_REQUEST_EVENT,
|
|
7831
|
-
TILE_REPLAY_REQUEST_EVENT,
|
|
7832
|
-
TILE_UNMOUNTED_EVENT
|
|
7833
|
-
]
|
|
7834
|
-
},
|
|
7835
|
-
(event) => {
|
|
7836
|
-
if (event.name === TILE_UNMOUNTED_EVENT) {
|
|
7837
|
-
const id = String(event.props?.instance_id ?? "");
|
|
7838
|
-
if (id) this._dismissedIds.add(id);
|
|
7839
|
-
return;
|
|
7840
|
-
}
|
|
7841
|
-
if (event.name === COMPOSITIONAL_REPLAY_REQUEST_EVENT) {
|
|
7842
|
-
const tileId = String(event.props?.tile_id ?? "");
|
|
7843
|
-
if (!tileId) return;
|
|
7844
|
-
this._replayItems(tileId, publish);
|
|
7845
|
-
return;
|
|
7846
|
-
}
|
|
7847
|
-
if (event.name === TILE_REPLAY_REQUEST_EVENT) {
|
|
7848
|
-
this._replayTiles(publish);
|
|
7849
|
-
return;
|
|
7850
|
-
}
|
|
7851
|
-
}
|
|
7852
|
-
);
|
|
7853
|
-
}
|
|
7854
|
-
_replayItems(tileId, publish) {
|
|
7855
|
-
for (const instance of this._instances.values()) {
|
|
7856
|
-
if (instance.element_type !== "item") continue;
|
|
7857
|
-
if (instance.placement.type !== "parent_tile") continue;
|
|
7858
|
-
if (instance.placement.tile_id !== tileId) continue;
|
|
7859
|
-
if (instance.state !== "active") continue;
|
|
7860
|
-
publish(COMPOSITIONAL_APPEND_EVENT, {
|
|
7861
|
-
tile_id: tileId,
|
|
7862
|
-
instance_id: instance.instance_id,
|
|
7863
|
-
item: instance.content,
|
|
7864
|
-
position: instance.placement.position
|
|
7865
|
-
});
|
|
7866
|
-
}
|
|
7867
|
-
}
|
|
7868
|
-
_replayTiles(publish) {
|
|
7869
|
-
for (const instance of this._instances.values()) {
|
|
7870
|
-
if (instance.element_type !== "tile") continue;
|
|
7871
|
-
if (instance.placement.type !== "slot") continue;
|
|
7872
|
-
if (instance.state !== "active") continue;
|
|
7873
|
-
if (this._dismissedIds.has(instance.instance_id)) continue;
|
|
7874
|
-
const props = {
|
|
7875
|
-
slot: instance.placement.slot,
|
|
7876
|
-
instance_id: instance.instance_id,
|
|
7877
|
-
widget: this._resolveTileWidget?.(instance.template_id) ?? instance.template_id,
|
|
7878
|
-
props: instance.content ?? {}
|
|
7879
|
-
};
|
|
7880
|
-
publish(TILE_MOUNTED_EVENT, props);
|
|
7881
|
-
}
|
|
7882
|
-
}
|
|
7883
|
-
registerHandler(handler) {
|
|
7884
|
-
this._handlers.set(handler.typeName, handler);
|
|
7885
|
-
}
|
|
7886
|
-
isDismissed(instanceId) {
|
|
7887
|
-
return this._dismissedIds.has(instanceId);
|
|
7888
|
-
}
|
|
7889
|
-
getDismissedIds() {
|
|
7890
|
-
return this._dismissedIds;
|
|
7891
|
-
}
|
|
7892
|
-
/** Store-driven receipt source for the chat trail (one per active slot-tile). */
|
|
7893
|
-
listTileReceipts() {
|
|
7894
|
-
const out = [];
|
|
7895
|
-
for (const inst of this._instances.values()) {
|
|
7896
|
-
if (inst.element_type !== "tile" || inst.placement.type !== "slot") continue;
|
|
7897
|
-
if (inst.state !== "active") continue;
|
|
7898
|
-
if (inst.placement.slot === CHAT_INLINE_SLOT) continue;
|
|
7899
|
-
const content = inst.content;
|
|
7900
|
-
const productName = content?.product?.name;
|
|
7901
|
-
const contentTitle = content?.title;
|
|
7902
|
-
const contentHeading = content?.heading;
|
|
7903
|
-
const title = typeof productName === "string" && productName ? productName : typeof contentTitle === "string" && contentTitle ? contentTitle : typeof contentHeading === "string" && contentHeading ? contentHeading : (
|
|
7904
|
-
// Never show a raw template id (kebab-case machine name) in the
|
|
7905
|
-
// chat — prettify the last-resort fallback into Title Case.
|
|
7906
|
-
inst.template_id.replace(/[-_]+/g, " ").replace(/\b\w/g, (c) => c.toUpperCase())
|
|
7907
|
-
);
|
|
7908
|
-
const imgContent = inst.content;
|
|
7909
|
-
const imageCandidate = imgContent?.product?.image?.src ?? imgContent?.items?.[0]?.image_url ?? imgContent?.products?.[0]?.image?.src;
|
|
7910
|
-
const imageUrl = typeof imageCandidate === "string" && imageCandidate.trim() ? imageCandidate : void 0;
|
|
7911
|
-
if (inst.placement.slot === "alert") {
|
|
7912
|
-
out.push({
|
|
7913
|
-
kind: "alert",
|
|
7914
|
-
instanceId: inst.instance_id,
|
|
7915
|
-
title,
|
|
7916
|
-
turnId: inst.mounted_by?.turn_id,
|
|
7917
|
-
toolCallId: inst.tool_call_id ?? void 0
|
|
7918
|
-
});
|
|
7919
|
-
} else {
|
|
7920
|
-
out.push({
|
|
7921
|
-
kind: "tile",
|
|
7922
|
-
instanceId: inst.instance_id,
|
|
7923
|
-
title,
|
|
7924
|
-
dismissed: this._dismissedIds.has(inst.instance_id),
|
|
7925
|
-
turnId: inst.mounted_by?.turn_id,
|
|
7926
|
-
toolCallId: inst.tool_call_id ?? void 0,
|
|
7927
|
-
...imageUrl ? { imageUrl } : {}
|
|
7928
|
-
});
|
|
7929
|
-
}
|
|
7930
|
-
}
|
|
7931
|
-
return out;
|
|
7932
|
-
}
|
|
7933
|
-
/**
|
|
7934
|
-
* Store-driven inline-widget source for the chat trail — one entry per
|
|
7935
|
-
* active `chat-inline` slot-tile. The trail mounts each entry's widget
|
|
7936
|
-
* element (by tag name, via `document.createElement`) inline in the
|
|
7937
|
-
* conversation flow. Distinct from {@link listTileReceipts}: those are
|
|
7938
|
-
* chips that recall a deck tile; these ARE the rendered widget.
|
|
7939
|
-
*/
|
|
7940
|
-
listInlineWidgets() {
|
|
7941
|
-
const out = [];
|
|
7942
|
-
for (const inst of this._instances.values()) {
|
|
7943
|
-
if (inst.element_type !== "tile" || inst.placement.type !== "slot") continue;
|
|
7944
|
-
if (inst.placement.slot !== CHAT_INLINE_SLOT) continue;
|
|
7945
|
-
if (inst.state !== "active") continue;
|
|
7946
|
-
if (this._dismissedIds.has(inst.instance_id)) continue;
|
|
7947
|
-
out.push({
|
|
7948
|
-
instanceId: inst.instance_id,
|
|
7949
|
-
tag: this._resolveTileWidget?.(inst.template_id) ?? inst.template_id,
|
|
7950
|
-
props: inst.content ?? {},
|
|
7951
|
-
turnId: inst.mounted_by?.turn_id,
|
|
7952
|
-
toolCallId: inst.tool_call_id ?? void 0
|
|
7953
|
-
});
|
|
7954
|
-
}
|
|
7955
|
-
return out;
|
|
7956
|
-
}
|
|
7957
|
-
/** Clear a client dismissal and re-publish the tile's mount from retained content. */
|
|
7958
|
-
recreate(instanceId) {
|
|
7959
|
-
const instance = this._instances.get(instanceId);
|
|
7960
|
-
const publish = this._events?.publish;
|
|
7961
|
-
if (!instance || instance.element_type !== "tile" || instance.placement.type !== "slot" || !publish) {
|
|
7962
|
-
return;
|
|
7963
|
-
}
|
|
7964
|
-
this._dismissedIds.delete(instanceId);
|
|
7965
|
-
const props = {
|
|
7966
|
-
slot: instance.placement.slot,
|
|
7967
|
-
instance_id: instance.instance_id,
|
|
7968
|
-
widget: this._resolveTileWidget?.(instance.template_id) ?? instance.template_id,
|
|
7969
|
-
props: instance.content ?? {}
|
|
7970
|
-
};
|
|
7971
|
-
publish(TILE_MOUNTED_EVENT, props);
|
|
7972
|
-
}
|
|
7973
|
-
/**
|
|
7974
|
-
* Apply the server-provided boot snapshot. For each instance:
|
|
7975
|
-
* - stateful: validated + mounted via the type handler;
|
|
7976
|
-
* - imperative + already-applied: recorded only (no DOM action);
|
|
7977
|
-
* - any: tracked in the in-memory map for future patches.
|
|
7978
|
-
*
|
|
7979
|
-
* Safe to call once on SDK init. Calling again would re-mount
|
|
7980
|
-
* stateful instances; callers should not.
|
|
7981
|
-
*/
|
|
7982
|
-
async hydrate(snapshot) {
|
|
7983
|
-
for (const instance of snapshot) {
|
|
7984
|
-
const existing = this._instances.get(instance.instance_id);
|
|
7985
|
-
if (existing && existing.version >= instance.version) {
|
|
7986
|
-
continue;
|
|
7987
|
-
}
|
|
7988
|
-
const handler = this._handlers.get(instance.element_type);
|
|
7989
|
-
if (!handler) {
|
|
7990
|
-
this._logger.warn("elements: hydrate skipped \u2014 unknown element_type", {
|
|
7991
|
-
element_type: instance.element_type,
|
|
7992
|
-
instance_id: instance.instance_id
|
|
7993
|
-
});
|
|
7994
|
-
continue;
|
|
7995
|
-
}
|
|
7996
|
-
this._instances.set(instance.instance_id, instance);
|
|
7997
|
-
if (handler.lifecycle === "imperative" && instance.state === "applied") {
|
|
7998
|
-
continue;
|
|
7999
|
-
}
|
|
8000
|
-
if (instance.state !== "active") {
|
|
8001
|
-
continue;
|
|
8002
|
-
}
|
|
8003
|
-
await this._mount(handler, instance);
|
|
8004
|
-
}
|
|
8005
|
-
this._broadcastActive();
|
|
8006
|
-
}
|
|
8007
|
-
/**
|
|
8008
|
-
* Re-publish `element.tile_mounted` / `element.compositional_append`
|
|
8009
|
-
* for every active LLM-authored instance in the store. Idempotent —
|
|
8010
|
-
* receivers key by `instance_id` (tiles) or by widget identity
|
|
8011
|
-
* (items via tile_id filter).
|
|
8012
|
-
*/
|
|
8013
|
-
_broadcastActive() {
|
|
8014
|
-
const publish = this._events?.publish;
|
|
8015
|
-
if (!publish) return;
|
|
8016
|
-
this._replayTiles(publish);
|
|
8017
|
-
const itemTileIds = /* @__PURE__ */ new Set();
|
|
8018
|
-
for (const instance of this._instances.values()) {
|
|
8019
|
-
if (instance.element_type !== "item") continue;
|
|
8020
|
-
if (instance.placement.type !== "parent_tile") continue;
|
|
8021
|
-
if (instance.state !== "active") continue;
|
|
8022
|
-
itemTileIds.add(instance.placement.tile_id);
|
|
8023
|
-
}
|
|
8024
|
-
for (const tileId of itemTileIds) {
|
|
8025
|
-
this._replayItems(tileId, publish);
|
|
8026
|
-
}
|
|
8027
|
-
}
|
|
8028
|
-
/**
|
|
8029
|
-
* Apply a batch of mutations, atomically per-batch. Each mutation is
|
|
8030
|
-
* version-checked (mount: must not conflict with existing instance;
|
|
8031
|
-
* patch: resulting_version must be > current; unmount: idempotent).
|
|
8032
|
-
*/
|
|
8033
|
-
async apply(mutations) {
|
|
8034
|
-
for (const mutation of mutations) {
|
|
8035
|
-
try {
|
|
8036
|
-
await this._applyOne(mutation);
|
|
8037
|
-
} catch (err) {
|
|
8038
|
-
this._logger.error("elements: mutation failed", { mutation, err });
|
|
8039
|
-
}
|
|
8040
|
-
}
|
|
8041
|
-
}
|
|
8042
|
-
/** Read-only snapshot of currently-known instances. */
|
|
8043
|
-
getInstances() {
|
|
8044
|
-
return Array.from(this._instances.values());
|
|
8045
|
-
}
|
|
8046
|
-
getInstance(instance_id) {
|
|
8047
|
-
return this._instances.get(instance_id);
|
|
8048
|
-
}
|
|
8049
|
-
/**
|
|
8050
|
-
* Schedule a client-side TTL that unmounts every active stateful
|
|
8051
|
-
* instance when the server-side session expires. Replaces any
|
|
8052
|
-
* previously-scheduled TTL.
|
|
8053
|
-
*
|
|
8054
|
-
* Avoids the orphan-window where session-expired tiles linger on the
|
|
8055
|
-
* page until manual refresh — the server forgets at the 4h mark and
|
|
8056
|
-
* the SDK tears down concurrently. Re-schedule on each boot fetch /
|
|
8057
|
-
* mutation event that carries a refreshed `session_expires_at`.
|
|
8058
|
-
*
|
|
8059
|
-
* Pass `null` to clear the existing timer without scheduling a new one.
|
|
8060
|
-
* Pass a past timestamp to trigger cleanup immediately.
|
|
8061
|
-
*/
|
|
8062
|
-
scheduleClientTtl(session_expires_at) {
|
|
8063
|
-
if (this._ttlTimer !== null) {
|
|
8064
|
-
clearTimeout(this._ttlTimer);
|
|
8065
|
-
this._ttlTimer = null;
|
|
8066
|
-
}
|
|
8067
|
-
if (session_expires_at === null) return;
|
|
8068
|
-
const expiryMs = Date.parse(session_expires_at);
|
|
8069
|
-
if (Number.isNaN(expiryMs)) {
|
|
8070
|
-
this._logger.warn("elements: invalid session_expires_at", { session_expires_at });
|
|
8071
|
-
return;
|
|
8072
|
-
}
|
|
8073
|
-
const delay = Math.max(0, expiryMs - Date.now());
|
|
8074
|
-
this._ttlTimer = setTimeout(() => {
|
|
8075
|
-
this._ttlTimer = null;
|
|
8076
|
-
void this._handleSessionExpiry();
|
|
8077
|
-
}, delay);
|
|
8078
|
-
}
|
|
8079
|
-
// -------------------------------------------------------------------
|
|
8080
|
-
// Internals
|
|
8081
|
-
// -------------------------------------------------------------------
|
|
8082
|
-
async _handleSessionExpiry() {
|
|
8083
|
-
const unmounts = [];
|
|
8084
|
-
for (const instance of this._instances.values()) {
|
|
8085
|
-
if (instance.state !== "active") continue;
|
|
8086
|
-
const handler = this._handlers.get(instance.element_type);
|
|
8087
|
-
if (!handler || handler.lifecycle === "imperative") continue;
|
|
8088
|
-
unmounts.push({ op: "unmount", instance_id: instance.instance_id });
|
|
8089
|
-
}
|
|
8090
|
-
if (unmounts.length > 0) {
|
|
8091
|
-
this._logger.info("elements: client TTL fired \u2014 unmounting active instances", {
|
|
8092
|
-
count: unmounts.length
|
|
8093
|
-
});
|
|
8094
|
-
await this.apply(unmounts);
|
|
8095
|
-
}
|
|
8096
|
-
}
|
|
8097
|
-
async _applyOne(mutation) {
|
|
8098
|
-
if (mutation.op === "mount") {
|
|
8099
|
-
const existing = this._instances.get(mutation.instance.instance_id);
|
|
8100
|
-
if (existing && existing.version >= mutation.instance.version) {
|
|
8101
|
-
return;
|
|
8102
|
-
}
|
|
8103
|
-
const handler = this._handlers.get(mutation.instance.element_type);
|
|
8104
|
-
if (!handler) {
|
|
8105
|
-
this._logger.warn("elements: mount dropped \u2014 unknown element_type", {
|
|
8106
|
-
element_type: mutation.instance.element_type
|
|
8107
|
-
});
|
|
8108
|
-
return;
|
|
8109
|
-
}
|
|
8110
|
-
const isActiveStateful = mutation.instance.state === "active" && handler.lifecycle !== "imperative";
|
|
8111
|
-
const isAppliedImperative = mutation.instance.state === "applied" && handler.lifecycle === "imperative";
|
|
8112
|
-
if (isActiveStateful || isAppliedImperative) {
|
|
8113
|
-
this._instances.set(mutation.instance.instance_id, mutation.instance);
|
|
8114
|
-
const applied = await this._mount(handler, mutation.instance);
|
|
8115
|
-
if (!applied) {
|
|
8116
|
-
if (existing) {
|
|
8117
|
-
this._instances.set(mutation.instance.instance_id, existing);
|
|
8118
|
-
} else {
|
|
8119
|
-
this._instances.delete(mutation.instance.instance_id);
|
|
8120
|
-
}
|
|
8121
|
-
}
|
|
8122
|
-
return;
|
|
8123
|
-
}
|
|
8124
|
-
this._instances.set(mutation.instance.instance_id, mutation.instance);
|
|
8125
|
-
return;
|
|
8126
|
-
}
|
|
8127
|
-
if (mutation.op === "patch") {
|
|
8128
|
-
const existing = this._instances.get(mutation.instance_id);
|
|
8129
|
-
if (!existing) {
|
|
8130
|
-
this._logger.warn("elements: patch dropped \u2014 unknown instance", {
|
|
8131
|
-
instance_id: mutation.instance_id
|
|
8132
|
-
});
|
|
8133
|
-
return;
|
|
8134
|
-
}
|
|
8135
|
-
if (typeof mutation.resulting_version !== "number" || mutation.resulting_content == null || typeof mutation.resulting_content !== "object") {
|
|
8136
|
-
this._logger.warn("elements: patch dropped \u2014 malformed envelope (missing resulting_*)", {
|
|
8137
|
-
instance_id: mutation.instance_id
|
|
8138
|
-
});
|
|
8139
|
-
return;
|
|
8140
|
-
}
|
|
8141
|
-
if (mutation.resulting_version <= existing.version) {
|
|
8142
|
-
return;
|
|
8143
|
-
}
|
|
8144
|
-
const patched = {
|
|
8145
|
-
...existing,
|
|
8146
|
-
content: mutation.resulting_content,
|
|
8147
|
-
version: mutation.resulting_version
|
|
8148
|
-
};
|
|
8149
|
-
const handler = this._handlers.get(patched.element_type);
|
|
8150
|
-
if (handler) {
|
|
8151
|
-
const validation = handler.validate(patched, this._ctx());
|
|
8152
|
-
if (!validation.accepted) {
|
|
8153
|
-
this._logger.warn("elements: patch validation failed", {
|
|
8154
|
-
instance_id: mutation.instance_id,
|
|
8155
|
-
reason: validation.reason
|
|
8156
|
-
});
|
|
8157
|
-
return;
|
|
8158
|
-
}
|
|
8159
|
-
try {
|
|
8160
|
-
await handler.patch(patched, this._ctx());
|
|
8161
|
-
} catch (err) {
|
|
8162
|
-
this._logger.warn("elements: handler.patch threw", {
|
|
8163
|
-
instance_id: mutation.instance_id,
|
|
8164
|
-
err
|
|
8165
|
-
});
|
|
8166
|
-
return;
|
|
8167
|
-
}
|
|
8168
|
-
}
|
|
8169
|
-
this._instances.set(mutation.instance_id, patched);
|
|
8170
|
-
return;
|
|
8171
|
-
}
|
|
8172
|
-
if (mutation.op === "unmount") {
|
|
8173
|
-
const existing = this._instances.get(mutation.instance_id);
|
|
8174
|
-
if (!existing) {
|
|
8175
|
-
return;
|
|
8176
|
-
}
|
|
8177
|
-
const reverted = { ...existing, state: "reverted" };
|
|
8178
|
-
this._instances.set(mutation.instance_id, reverted);
|
|
8179
|
-
const handler = this._handlers.get(existing.element_type);
|
|
8180
|
-
if (handler) {
|
|
8181
|
-
try {
|
|
8182
|
-
await handler.unmount(reverted, this._ctx());
|
|
8183
|
-
} catch (err) {
|
|
8184
|
-
this._instances.set(mutation.instance_id, existing);
|
|
8185
|
-
this._logger.warn("elements: handler.unmount threw", {
|
|
8186
|
-
instance_id: mutation.instance_id,
|
|
8187
|
-
err
|
|
8188
|
-
});
|
|
8189
|
-
}
|
|
8190
|
-
}
|
|
8191
|
-
return;
|
|
8192
|
-
}
|
|
8193
|
-
}
|
|
8194
|
-
async _mount(handler, instance) {
|
|
8195
|
-
const validation = handler.validate(instance, this._ctx());
|
|
8196
|
-
if (!validation.accepted) {
|
|
8197
|
-
this._logger.warn("elements: mount validation failed", {
|
|
8198
|
-
instance_id: instance.instance_id,
|
|
8199
|
-
reason: validation.reason,
|
|
8200
|
-
detail: validation.detail
|
|
8201
|
-
});
|
|
8202
|
-
return false;
|
|
8203
|
-
}
|
|
8204
|
-
try {
|
|
8205
|
-
await handler.mount(instance, this._ctx());
|
|
8206
|
-
} catch (err) {
|
|
8207
|
-
this._logger.warn("elements: handler.mount threw", {
|
|
8208
|
-
instance_id: instance.instance_id,
|
|
8209
|
-
err
|
|
8210
|
-
});
|
|
8211
|
-
return false;
|
|
8212
|
-
}
|
|
8213
|
-
return true;
|
|
8214
|
-
}
|
|
8215
|
-
_ctx() {
|
|
8216
|
-
return { actions: this._actions, events: this._events };
|
|
8217
|
-
}
|
|
8218
|
-
};
|
|
8219
|
-
|
|
8220
7746
|
// src/elements/envelope.ts
|
|
8221
7747
|
function decodeMutationEnvelope(payload) {
|
|
8222
7748
|
if (!payload || typeof payload !== "object") return null;
|
|
@@ -8294,126 +7820,6 @@ function _runtimeId(method) {
|
|
|
8294
7820
|
}
|
|
8295
7821
|
}
|
|
8296
7822
|
|
|
8297
|
-
// src/elements/ItemHandler.ts
|
|
8298
|
-
var COMPOSITIONAL_APPEND_EVENT2 = "element.compositional_append";
|
|
8299
|
-
var COMPOSITIONAL_PATCH_EVENT = "element.compositional_patch";
|
|
8300
|
-
var COMPOSITIONAL_REMOVE_EVENT = "element.compositional_remove";
|
|
8301
|
-
var ItemHandler = class {
|
|
8302
|
-
constructor() {
|
|
8303
|
-
this.typeName = "item";
|
|
8304
|
-
this.lifecycle = "stateful";
|
|
8305
|
-
}
|
|
8306
|
-
validate(instance, _ctx) {
|
|
8307
|
-
if (instance.element_type !== "item") {
|
|
8308
|
-
return {
|
|
8309
|
-
accepted: false,
|
|
8310
|
-
reason: "wrong_element_type",
|
|
8311
|
-
detail: instance.element_type
|
|
8312
|
-
};
|
|
8313
|
-
}
|
|
8314
|
-
if (instance.placement.type !== "parent_tile") {
|
|
8315
|
-
return {
|
|
8316
|
-
accepted: false,
|
|
8317
|
-
reason: "item_requires_parent_tile_placement",
|
|
8318
|
-
detail: `got placement.type=${instance.placement.type}`
|
|
8319
|
-
};
|
|
8320
|
-
}
|
|
8321
|
-
if (typeof instance.template_id !== "string" || instance.template_id.length === 0) {
|
|
8322
|
-
return { accepted: false, reason: "missing_template_id" };
|
|
8323
|
-
}
|
|
8324
|
-
return { accepted: true };
|
|
8325
|
-
}
|
|
8326
|
-
async mount(instance, ctx) {
|
|
8327
|
-
if (!ctx.events) return;
|
|
8328
|
-
const placement = instance.placement;
|
|
8329
|
-
ctx.events.publish(COMPOSITIONAL_APPEND_EVENT2, {
|
|
8330
|
-
tile_id: placement.tile_id,
|
|
8331
|
-
instance_id: instance.instance_id,
|
|
8332
|
-
item: instance.content,
|
|
8333
|
-
position: placement.position
|
|
8334
|
-
});
|
|
8335
|
-
}
|
|
8336
|
-
async patch(instance, ctx) {
|
|
8337
|
-
if (!ctx.events) return;
|
|
8338
|
-
const placement = instance.placement;
|
|
8339
|
-
ctx.events.publish(COMPOSITIONAL_PATCH_EVENT, {
|
|
8340
|
-
tile_id: placement.tile_id,
|
|
8341
|
-
instance_id: instance.instance_id,
|
|
8342
|
-
item: instance.content
|
|
8343
|
-
});
|
|
8344
|
-
}
|
|
8345
|
-
async unmount(instance, ctx) {
|
|
8346
|
-
if (!ctx.events) return;
|
|
8347
|
-
const placement = instance.placement;
|
|
8348
|
-
ctx.events.publish(COMPOSITIONAL_REMOVE_EVENT, {
|
|
8349
|
-
tile_id: placement.tile_id,
|
|
8350
|
-
instance_id: instance.instance_id
|
|
8351
|
-
});
|
|
8352
|
-
}
|
|
8353
|
-
};
|
|
8354
|
-
|
|
8355
|
-
// src/elements/TileHandler.ts
|
|
8356
|
-
var TileHandler = class {
|
|
8357
|
-
constructor(resolveWidget) {
|
|
8358
|
-
this.resolveWidget = resolveWidget;
|
|
8359
|
-
this.typeName = "tile";
|
|
8360
|
-
this.lifecycle = "stateful";
|
|
8361
|
-
}
|
|
8362
|
-
_widgetFor(instance) {
|
|
8363
|
-
return this.resolveWidget?.(instance.template_id) ?? instance.template_id;
|
|
8364
|
-
}
|
|
8365
|
-
validate(instance, _ctx) {
|
|
8366
|
-
if (instance.element_type !== "tile") {
|
|
8367
|
-
return { accepted: false, reason: "wrong_element_type", detail: instance.element_type };
|
|
8368
|
-
}
|
|
8369
|
-
if (instance.placement.type !== "slot") {
|
|
8370
|
-
return {
|
|
8371
|
-
accepted: false,
|
|
8372
|
-
reason: "tile_requires_slot_placement",
|
|
8373
|
-
detail: `got placement.type=${instance.placement.type}`
|
|
8374
|
-
};
|
|
8375
|
-
}
|
|
8376
|
-
if (typeof instance.template_id !== "string" || instance.template_id.length === 0) {
|
|
8377
|
-
return { accepted: false, reason: "missing_template_id" };
|
|
8378
|
-
}
|
|
8379
|
-
if (this.resolveWidget && this.resolveWidget(instance.template_id) === void 0) {
|
|
8380
|
-
return { accepted: false, reason: "unknown_template_id", detail: instance.template_id };
|
|
8381
|
-
}
|
|
8382
|
-
return { accepted: true };
|
|
8383
|
-
}
|
|
8384
|
-
async mount(instance, ctx) {
|
|
8385
|
-
if (!ctx.events) return;
|
|
8386
|
-
const placement = instance.placement;
|
|
8387
|
-
const props = {
|
|
8388
|
-
slot: placement.slot,
|
|
8389
|
-
instance_id: instance.instance_id,
|
|
8390
|
-
widget: this._widgetFor(instance),
|
|
8391
|
-
props: instance.content ?? {}
|
|
8392
|
-
};
|
|
8393
|
-
ctx.events.publish(TILE_MOUNTED_EVENT, props);
|
|
8394
|
-
}
|
|
8395
|
-
async patch(instance, ctx) {
|
|
8396
|
-
if (!ctx.events) return;
|
|
8397
|
-
const placement = instance.placement;
|
|
8398
|
-
const props = {
|
|
8399
|
-
slot: placement.slot,
|
|
8400
|
-
instance_id: instance.instance_id,
|
|
8401
|
-
widget: this._widgetFor(instance),
|
|
8402
|
-
props: instance.content ?? {}
|
|
8403
|
-
};
|
|
8404
|
-
ctx.events.publish(TILE_PATCHED_EVENT, props);
|
|
8405
|
-
}
|
|
8406
|
-
async unmount(instance, ctx) {
|
|
8407
|
-
if (!ctx.events) return;
|
|
8408
|
-
const placement = instance.placement;
|
|
8409
|
-
const props = {
|
|
8410
|
-
slot: placement.slot,
|
|
8411
|
-
instance_id: instance.instance_id
|
|
8412
|
-
};
|
|
8413
|
-
ctx.events.publish(TILE_UNMOUNTED_EVENT, props);
|
|
8414
|
-
}
|
|
8415
|
-
};
|
|
8416
|
-
|
|
8417
7823
|
// src/Turnstile.ts
|
|
8418
7824
|
var TURNSTILE_SITEKEY = "0x4AAAAAADSzPbGWxeguF4YJ";
|
|
8419
7825
|
var TURNSTILE_ACQUIRE_TIMEOUT_MS = 5e3;
|
|
@@ -8784,17 +8190,16 @@ var ChatAssistantLitMountable = {
|
|
|
8784
8190
|
}
|
|
8785
8191
|
};
|
|
8786
8192
|
debug("mount", { tileId: resolvedTileId, instanceId, baseUrl });
|
|
8787
|
-
const
|
|
8788
|
-
|
|
8789
|
-
|
|
8193
|
+
const elementSession = createElementSessionController({
|
|
8194
|
+
...runtime,
|
|
8195
|
+
legacyTemplateFallback: true
|
|
8790
8196
|
});
|
|
8791
8197
|
void fetchMountedElements({
|
|
8792
8198
|
endpoint: `${baseUrl}/api/adaptive/mounted_elements`,
|
|
8793
8199
|
token
|
|
8794
8200
|
}).then((response) => {
|
|
8795
8201
|
if (isUnmounted || response === null) return;
|
|
8796
|
-
void
|
|
8797
|
-
elementStore.scheduleClientTtl(response.session_expires_at);
|
|
8202
|
+
void elementSession.hydrateLegacy(response.mounted_elements, response.session_expires_at);
|
|
8798
8203
|
});
|
|
8799
8204
|
const el = document.createElement("syntro-chat");
|
|
8800
8205
|
el.greeting = chatbotConfig?.greeting;
|
|
@@ -8869,7 +8274,12 @@ var ChatAssistantLitMountable = {
|
|
|
8869
8274
|
onA2UIEvent: (payload) => {
|
|
8870
8275
|
const mutations = decodeMutationEnvelope(payload);
|
|
8871
8276
|
if (mutations !== null) {
|
|
8872
|
-
|
|
8277
|
+
elementSession.applyLegacyEnvelope({
|
|
8278
|
+
type: "syntro.element.mutation",
|
|
8279
|
+
schema_version: "v0",
|
|
8280
|
+
mutations
|
|
8281
|
+
}).then(() => {
|
|
8282
|
+
if (isUnmounted) return;
|
|
8873
8283
|
runtime.events.publish("chatbot.element_mutation_applied", {
|
|
8874
8284
|
tileId: resolvedTileId,
|
|
8875
8285
|
count: mutations.length
|
|
@@ -8994,7 +8404,7 @@ var ChatAssistantLitMountable = {
|
|
|
8994
8404
|
});
|
|
8995
8405
|
isUnmounted = true;
|
|
8996
8406
|
clearTimers();
|
|
8997
|
-
|
|
8407
|
+
void elementSession.dispose();
|
|
8998
8408
|
acquireAbort.abort();
|
|
8999
8409
|
if (unsubscribe) {
|
|
9000
8410
|
unsubscribe();
|
|
@@ -9010,12 +8420,8 @@ var ChatAssistantLitMountable = {
|
|
|
9010
8420
|
|
|
9011
8421
|
export {
|
|
9012
8422
|
AgUiTransport,
|
|
9013
|
-
ActionHandler,
|
|
9014
|
-
ElementInstanceStore,
|
|
9015
8423
|
decodeMutationEnvelope,
|
|
9016
8424
|
fetchMountedElements,
|
|
9017
|
-
ItemHandler,
|
|
9018
|
-
TileHandler,
|
|
9019
8425
|
acquireBotCheckTokenForSend,
|
|
9020
8426
|
renderFallbackHtml,
|
|
9021
8427
|
ChatAssistantLitMountable
|
|
@@ -9036,4 +8442,4 @@ fast-json-patch/module/duplex.mjs:
|
|
|
9036
8442
|
* MIT license
|
|
9037
8443
|
*)
|
|
9038
8444
|
*/
|
|
9039
|
-
//# sourceMappingURL=chunk-
|
|
8445
|
+
//# sourceMappingURL=chunk-AIQMQZBV.js.map
|