@agentskit/chat-solid 0.1.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/LICENSE +22 -0
- package/README.md +5 -0
- package/dist/index.cjs +863 -0
- package/dist/index.d.cts +44 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +835 -0
- package/package.json +57 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,835 @@
|
|
|
1
|
+
// src/index.tsx
|
|
2
|
+
import { template as _$template2 } from "solid-js/web";
|
|
3
|
+
import { delegateEvents as _$delegateEvents2 } from "solid-js/web";
|
|
4
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
5
|
+
import { setStyleProperty as _$setStyleProperty } from "solid-js/web";
|
|
6
|
+
import { style as _$style } from "solid-js/web";
|
|
7
|
+
import { addEventListener as _$addEventListener } from "solid-js/web";
|
|
8
|
+
import { setAttribute as _$setAttribute2 } from "solid-js/web";
|
|
9
|
+
import { effect as _$effect2 } from "solid-js/web";
|
|
10
|
+
import { insert as _$insert2 } from "solid-js/web";
|
|
11
|
+
import { createComponent as _$createComponent2 } from "solid-js/web";
|
|
12
|
+
import { memo as _$memo2 } from "solid-js/web";
|
|
13
|
+
import { formatSemanticFallback, getLifecycleTargets, presentChatMessage, resolveChatSession, resolveChatTheme, resolveChoiceAction, resolveChoiceListFrame, resolveComponentFrame as resolveComponentFrame2, selectChoice } from "@agentskit/chat";
|
|
14
|
+
import { ChatContainer, InputBar, Message, ThinkingIndicator, ToolConfirmation, useChat } from "@agentskit/solid";
|
|
15
|
+
import { For as For2, Show as Show2, createEffect, createMemo, createSignal as createSignal2, on, untrack } from "solid-js";
|
|
16
|
+
|
|
17
|
+
// src/StandardComponent.tsx
|
|
18
|
+
import { template as _$template } from "solid-js/web";
|
|
19
|
+
import { delegateEvents as _$delegateEvents } from "solid-js/web";
|
|
20
|
+
import { memo as _$memo } from "solid-js/web";
|
|
21
|
+
import { setAttribute as _$setAttribute } from "solid-js/web";
|
|
22
|
+
import { effect as _$effect } from "solid-js/web";
|
|
23
|
+
import { insert as _$insert } from "solid-js/web";
|
|
24
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
25
|
+
import { ApprovalRequestPropsSchema, ButtonGroupPropsSchema, ConfirmationPropsSchema, ErrorNoticePropsSchema, FileAttachmentPropsSchema, FormPropsSchema, LinkCardPropsSchema, ProgressPropsSchema, SourceListPropsSchema, TablePropsSchema, ToolCallPropsSchema, createComponentInteraction, resolveComponentFallback, resolveComponentFrame } from "@agentskit/chat";
|
|
26
|
+
import { createSignal, For, Show } from "solid-js";
|
|
27
|
+
var _tmpl$ = /* @__PURE__ */ _$template(`<form data-ak-component=form><button type=submit>`);
|
|
28
|
+
var _tmpl$2 = /* @__PURE__ */ _$template(`<h3>`);
|
|
29
|
+
var _tmpl$3 = /* @__PURE__ */ _$template(`<label>`);
|
|
30
|
+
var _tmpl$4 = /* @__PURE__ */ _$template(`<select><option value disabled>Select\u2026`);
|
|
31
|
+
var _tmpl$5 = /* @__PURE__ */ _$template(`<option>`);
|
|
32
|
+
var _tmpl$6 = /* @__PURE__ */ _$template(`<input>`);
|
|
33
|
+
var _tmpl$7 = /* @__PURE__ */ _$template(`<fieldset><legend>`);
|
|
34
|
+
var _tmpl$8 = /* @__PURE__ */ _$template(`<button type=button>`);
|
|
35
|
+
var _tmpl$9 = /* @__PURE__ */ _$template(`<section><h3></h3><p></p><button></button><button>`);
|
|
36
|
+
var _tmpl$0 = /* @__PURE__ */ _$template(`<div><label><progress max=100>`);
|
|
37
|
+
var _tmpl$1 = /* @__PURE__ */ _$template(`<p>`);
|
|
38
|
+
var _tmpl$10 = /* @__PURE__ */ _$template(`<section><h3></h3><ul>`);
|
|
39
|
+
var _tmpl$11 = /* @__PURE__ */ _$template(`<li>`);
|
|
40
|
+
var _tmpl$12 = /* @__PURE__ */ _$template(`<a>`);
|
|
41
|
+
var _tmpl$13 = /* @__PURE__ */ _$template(`<a><strong></strong><span></span><span>`);
|
|
42
|
+
var _tmpl$14 = /* @__PURE__ */ _$template(`<section role=alert><strong></strong><p></p><code>`);
|
|
43
|
+
var _tmpl$15 = /* @__PURE__ */ _$template(`<button>`);
|
|
44
|
+
var _tmpl$16 = /* @__PURE__ */ _$template(`<section role=status><strong></strong><span></span><pre></pre><pre>`);
|
|
45
|
+
var _tmpl$17 = /* @__PURE__ */ _$template(`<table><caption></caption><thead><tr></tr></thead><tbody>`);
|
|
46
|
+
var _tmpl$18 = /* @__PURE__ */ _$template(`<th scope=col>`);
|
|
47
|
+
var _tmpl$19 = /* @__PURE__ */ _$template(`<tr>`);
|
|
48
|
+
var _tmpl$20 = /* @__PURE__ */ _$template(`<td>`);
|
|
49
|
+
var _tmpl$21 = /* @__PURE__ */ _$template(`<article><strong></strong><span></span><span>`);
|
|
50
|
+
var _tmpl$22 = /* @__PURE__ */ _$template(`<a>Open`);
|
|
51
|
+
var _tmpl$23 = /* @__PURE__ */ _$template(`<p data-ak-component-fallback>`);
|
|
52
|
+
var StandardForm = (props) => {
|
|
53
|
+
const item = FormPropsSchema.parse(props.frame.props);
|
|
54
|
+
const [values, setValues] = createSignal({});
|
|
55
|
+
return (() => {
|
|
56
|
+
var _el$ = _tmpl$(), _el$2 = _el$.firstChild;
|
|
57
|
+
_el$.addEventListener("submit", (event) => {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
props.onInteract(createComponentInteraction(props.frame, props.manifest, "submit", values()));
|
|
60
|
+
});
|
|
61
|
+
_$insert(_el$, _$createComponent(Show, {
|
|
62
|
+
get when() {
|
|
63
|
+
return item.title;
|
|
64
|
+
},
|
|
65
|
+
children: (title) => (() => {
|
|
66
|
+
var _el$3 = _tmpl$2();
|
|
67
|
+
_$insert(_el$3, title);
|
|
68
|
+
return _el$3;
|
|
69
|
+
})()
|
|
70
|
+
}), _el$2);
|
|
71
|
+
_$insert(_el$, _$createComponent(For, {
|
|
72
|
+
get each() {
|
|
73
|
+
return item.fields;
|
|
74
|
+
},
|
|
75
|
+
children: (field) => (() => {
|
|
76
|
+
var _el$4 = _tmpl$3();
|
|
77
|
+
_$insert(_el$4, () => field.label, null);
|
|
78
|
+
_$insert(_el$4, (() => {
|
|
79
|
+
var _c$ = _$memo(() => field.type === "select");
|
|
80
|
+
return () => _c$() ? (() => {
|
|
81
|
+
var _el$5 = _tmpl$4(), _el$6 = _el$5.firstChild;
|
|
82
|
+
_el$5.$$input = (event) => setValues((current) => ({
|
|
83
|
+
...current,
|
|
84
|
+
[field.id]: event.currentTarget.value
|
|
85
|
+
}));
|
|
86
|
+
_$insert(_el$5, _$createComponent(For, {
|
|
87
|
+
get each() {
|
|
88
|
+
return field.options;
|
|
89
|
+
},
|
|
90
|
+
children: (option) => (() => {
|
|
91
|
+
var _el$7 = _tmpl$5();
|
|
92
|
+
_$insert(_el$7, () => option.label);
|
|
93
|
+
_$effect(() => _el$7.value = option.id);
|
|
94
|
+
return _el$7;
|
|
95
|
+
})()
|
|
96
|
+
}), null);
|
|
97
|
+
_$effect((_p$) => {
|
|
98
|
+
var _v$3 = field.required, _v$4 = props.disabled;
|
|
99
|
+
_v$3 !== _p$.e && (_el$5.required = _p$.e = _v$3);
|
|
100
|
+
_v$4 !== _p$.t && (_el$5.disabled = _p$.t = _v$4);
|
|
101
|
+
return _p$;
|
|
102
|
+
}, {
|
|
103
|
+
e: void 0,
|
|
104
|
+
t: void 0
|
|
105
|
+
});
|
|
106
|
+
_$effect(() => _el$5.value = String(values()[field.id] ?? ""));
|
|
107
|
+
return _el$5;
|
|
108
|
+
})() : (() => {
|
|
109
|
+
var _el$8 = _tmpl$6();
|
|
110
|
+
_el$8.$$input = (event) => setValues((current) => ({
|
|
111
|
+
...current,
|
|
112
|
+
[field.id]: field.type === "checkbox" ? event.currentTarget.checked : event.currentTarget.value
|
|
113
|
+
}));
|
|
114
|
+
_$effect((_p$) => {
|
|
115
|
+
var _v$5 = field.type, _v$6 = field.required, _v$7 = props.disabled, _v$8 = field.placeholder;
|
|
116
|
+
_v$5 !== _p$.e && _$setAttribute(_el$8, "type", _p$.e = _v$5);
|
|
117
|
+
_v$6 !== _p$.t && (_el$8.required = _p$.t = _v$6);
|
|
118
|
+
_v$7 !== _p$.a && (_el$8.disabled = _p$.a = _v$7);
|
|
119
|
+
_v$8 !== _p$.o && _$setAttribute(_el$8, "placeholder", _p$.o = _v$8);
|
|
120
|
+
return _p$;
|
|
121
|
+
}, {
|
|
122
|
+
e: void 0,
|
|
123
|
+
t: void 0,
|
|
124
|
+
a: void 0,
|
|
125
|
+
o: void 0
|
|
126
|
+
});
|
|
127
|
+
return _el$8;
|
|
128
|
+
})();
|
|
129
|
+
})(), null);
|
|
130
|
+
return _el$4;
|
|
131
|
+
})()
|
|
132
|
+
}), _el$2);
|
|
133
|
+
_$insert(_el$2, () => item.submitLabel);
|
|
134
|
+
_$effect((_p$) => {
|
|
135
|
+
var _v$ = item.title ?? "Form", _v$2 = props.disabled;
|
|
136
|
+
_v$ !== _p$.e && _$setAttribute(_el$, "aria-label", _p$.e = _v$);
|
|
137
|
+
_v$2 !== _p$.t && (_el$2.disabled = _p$.t = _v$2);
|
|
138
|
+
return _p$;
|
|
139
|
+
}, {
|
|
140
|
+
e: void 0,
|
|
141
|
+
t: void 0
|
|
142
|
+
});
|
|
143
|
+
return _el$;
|
|
144
|
+
})();
|
|
145
|
+
};
|
|
146
|
+
var StandardComponent = (props) => {
|
|
147
|
+
if (!resolveComponentFrame(props.frame, props.manifest).ok || props.frame.componentKey === "choice-list") return null;
|
|
148
|
+
const emit = (event, value) => props.onInteract(createComponentInteraction(props.frame, props.manifest, event, value));
|
|
149
|
+
const key = props.frame.componentKey;
|
|
150
|
+
if (key === "button-group") {
|
|
151
|
+
const item = ButtonGroupPropsSchema.parse(props.frame.props);
|
|
152
|
+
return (() => {
|
|
153
|
+
var _el$9 = _tmpl$7(), _el$0 = _el$9.firstChild;
|
|
154
|
+
_$setAttribute(_el$9, "data-ak-component", key);
|
|
155
|
+
_$insert(_el$0, () => item.label);
|
|
156
|
+
_$insert(_el$9, _$createComponent(For, {
|
|
157
|
+
get each() {
|
|
158
|
+
return item.buttons;
|
|
159
|
+
},
|
|
160
|
+
children: (button) => (() => {
|
|
161
|
+
var _el$1 = _tmpl$8();
|
|
162
|
+
_el$1.$$click = () => emit("select", button.id);
|
|
163
|
+
_$insert(_el$1, () => button.label);
|
|
164
|
+
_$effect(() => _el$1.disabled = props.disabled || button.disabled);
|
|
165
|
+
return _el$1;
|
|
166
|
+
})()
|
|
167
|
+
}), null);
|
|
168
|
+
_$effect(() => _$setAttribute(_el$9, "aria-label", item.label));
|
|
169
|
+
return _el$9;
|
|
170
|
+
})();
|
|
171
|
+
}
|
|
172
|
+
if (key === "form") return _$createComponent(StandardForm, props);
|
|
173
|
+
if (key === "confirmation") {
|
|
174
|
+
const item = ConfirmationPropsSchema.parse(props.frame.props);
|
|
175
|
+
return (() => {
|
|
176
|
+
var _el$10 = _tmpl$9(), _el$11 = _el$10.firstChild, _el$12 = _el$11.nextSibling, _el$13 = _el$12.nextSibling, _el$14 = _el$13.nextSibling;
|
|
177
|
+
_$setAttribute(_el$10, "data-ak-component", key);
|
|
178
|
+
_$insert(_el$11, () => item.title);
|
|
179
|
+
_$insert(_el$12, () => item.message);
|
|
180
|
+
_el$13.$$click = () => emit("confirm");
|
|
181
|
+
_$insert(_el$13, () => item.confirmLabel);
|
|
182
|
+
_el$14.$$click = () => emit("cancel");
|
|
183
|
+
_$insert(_el$14, () => item.cancelLabel);
|
|
184
|
+
_$effect((_p$) => {
|
|
185
|
+
var _v$9 = item.title, _v$0 = props.disabled, _v$1 = props.disabled;
|
|
186
|
+
_v$9 !== _p$.e && _$setAttribute(_el$10, "aria-label", _p$.e = _v$9);
|
|
187
|
+
_v$0 !== _p$.t && (_el$13.disabled = _p$.t = _v$0);
|
|
188
|
+
_v$1 !== _p$.a && (_el$14.disabled = _p$.a = _v$1);
|
|
189
|
+
return _p$;
|
|
190
|
+
}, {
|
|
191
|
+
e: void 0,
|
|
192
|
+
t: void 0,
|
|
193
|
+
a: void 0
|
|
194
|
+
});
|
|
195
|
+
return _el$10;
|
|
196
|
+
})();
|
|
197
|
+
}
|
|
198
|
+
if (key === "progress") {
|
|
199
|
+
const item = ProgressPropsSchema.parse(props.frame.props);
|
|
200
|
+
return (() => {
|
|
201
|
+
var _el$15 = _tmpl$0(), _el$16 = _el$15.firstChild, _el$17 = _el$16.firstChild;
|
|
202
|
+
_$setAttribute(_el$15, "data-ak-component", key);
|
|
203
|
+
_$insert(_el$16, () => item.label, _el$17);
|
|
204
|
+
_$insert(_el$15, _$createComponent(Show, {
|
|
205
|
+
get when() {
|
|
206
|
+
return item.status;
|
|
207
|
+
},
|
|
208
|
+
children: (status) => (() => {
|
|
209
|
+
var _el$18 = _tmpl$1();
|
|
210
|
+
_$insert(_el$18, status);
|
|
211
|
+
return _el$18;
|
|
212
|
+
})()
|
|
213
|
+
}), null);
|
|
214
|
+
_$effect(() => _el$17.value = item.value);
|
|
215
|
+
return _el$15;
|
|
216
|
+
})();
|
|
217
|
+
}
|
|
218
|
+
if (key === "source-list") {
|
|
219
|
+
const item = SourceListPropsSchema.parse(props.frame.props);
|
|
220
|
+
return (() => {
|
|
221
|
+
var _el$19 = _tmpl$10(), _el$20 = _el$19.firstChild, _el$21 = _el$20.nextSibling;
|
|
222
|
+
_$setAttribute(_el$19, "data-ak-component", key);
|
|
223
|
+
_$insert(_el$20, () => item.label);
|
|
224
|
+
_$insert(_el$21, _$createComponent(For, {
|
|
225
|
+
get each() {
|
|
226
|
+
return item.sources;
|
|
227
|
+
},
|
|
228
|
+
children: (source) => (() => {
|
|
229
|
+
var _el$22 = _tmpl$11();
|
|
230
|
+
_$insert(_el$22, (() => {
|
|
231
|
+
var _c$2 = _$memo(() => !!source.url);
|
|
232
|
+
return () => _c$2() ? (() => {
|
|
233
|
+
var _el$23 = _tmpl$12();
|
|
234
|
+
_el$23.$$click = (event) => {
|
|
235
|
+
event.preventDefault();
|
|
236
|
+
emit("open", source.id);
|
|
237
|
+
};
|
|
238
|
+
_$insert(_el$23, () => source.title);
|
|
239
|
+
_$effect(() => _$setAttribute(_el$23, "href", source.url));
|
|
240
|
+
return _el$23;
|
|
241
|
+
})() : source.title;
|
|
242
|
+
})(), null);
|
|
243
|
+
_$insert(_el$22, _$createComponent(Show, {
|
|
244
|
+
get when() {
|
|
245
|
+
return source.snippet;
|
|
246
|
+
},
|
|
247
|
+
children: (snippet) => (() => {
|
|
248
|
+
var _el$24 = _tmpl$1();
|
|
249
|
+
_$insert(_el$24, snippet);
|
|
250
|
+
return _el$24;
|
|
251
|
+
})()
|
|
252
|
+
}), null);
|
|
253
|
+
return _el$22;
|
|
254
|
+
})()
|
|
255
|
+
}));
|
|
256
|
+
return _el$19;
|
|
257
|
+
})();
|
|
258
|
+
}
|
|
259
|
+
if (key === "link-card") {
|
|
260
|
+
const item = LinkCardPropsSchema.parse(props.frame.props);
|
|
261
|
+
return (() => {
|
|
262
|
+
var _el$25 = _tmpl$13(), _el$26 = _el$25.firstChild, _el$27 = _el$26.nextSibling, _el$28 = _el$27.nextSibling;
|
|
263
|
+
_el$25.$$click = (event) => {
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
emit("open", item.href);
|
|
266
|
+
};
|
|
267
|
+
_$setAttribute(_el$25, "data-ak-component", key);
|
|
268
|
+
_$insert(_el$26, () => item.title);
|
|
269
|
+
_$insert(_el$27, () => item.description);
|
|
270
|
+
_$insert(_el$28, () => item.label);
|
|
271
|
+
_$effect(() => _$setAttribute(_el$25, "href", item.href));
|
|
272
|
+
return _el$25;
|
|
273
|
+
})();
|
|
274
|
+
}
|
|
275
|
+
if (key === "error-notice") {
|
|
276
|
+
const item = ErrorNoticePropsSchema.parse(props.frame.props);
|
|
277
|
+
return (() => {
|
|
278
|
+
var _el$29 = _tmpl$14(), _el$30 = _el$29.firstChild, _el$31 = _el$30.nextSibling, _el$32 = _el$31.nextSibling;
|
|
279
|
+
_$setAttribute(_el$29, "data-ak-component", key);
|
|
280
|
+
_$insert(_el$30, () => item.title);
|
|
281
|
+
_$insert(_el$31, () => item.message);
|
|
282
|
+
_$insert(_el$32, () => item.code);
|
|
283
|
+
_$insert(_el$29, _$createComponent(Show, {
|
|
284
|
+
get when() {
|
|
285
|
+
return item.retryLabel;
|
|
286
|
+
},
|
|
287
|
+
children: (label) => (() => {
|
|
288
|
+
var _el$33 = _tmpl$15();
|
|
289
|
+
_el$33.$$click = () => emit("retry");
|
|
290
|
+
_$insert(_el$33, label);
|
|
291
|
+
_$effect(() => _el$33.disabled = props.disabled);
|
|
292
|
+
return _el$33;
|
|
293
|
+
})()
|
|
294
|
+
}), null);
|
|
295
|
+
return _el$29;
|
|
296
|
+
})();
|
|
297
|
+
}
|
|
298
|
+
if (key === "tool-call") {
|
|
299
|
+
const item = ToolCallPropsSchema.parse(props.frame.props);
|
|
300
|
+
return (() => {
|
|
301
|
+
var _el$34 = _tmpl$16(), _el$35 = _el$34.firstChild, _el$36 = _el$35.nextSibling, _el$37 = _el$36.nextSibling, _el$38 = _el$37.nextSibling;
|
|
302
|
+
_$setAttribute(_el$34, "data-ak-component", key);
|
|
303
|
+
_$insert(_el$35, () => item.name);
|
|
304
|
+
_$insert(_el$36, () => item.status);
|
|
305
|
+
_$insert(_el$37, (() => {
|
|
306
|
+
var _c$3 = _$memo(() => !!item.arguments);
|
|
307
|
+
return () => _c$3() ? JSON.stringify(item.arguments, null, 2) : "";
|
|
308
|
+
})());
|
|
309
|
+
_$insert(_el$38, (() => {
|
|
310
|
+
var _c$4 = _$memo(() => item.result === void 0);
|
|
311
|
+
return () => _c$4() ? "" : JSON.stringify(item.result, null, 2);
|
|
312
|
+
})());
|
|
313
|
+
return _el$34;
|
|
314
|
+
})();
|
|
315
|
+
}
|
|
316
|
+
if (key === "approval-request") {
|
|
317
|
+
const item = ApprovalRequestPropsSchema.parse(props.frame.props);
|
|
318
|
+
return (() => {
|
|
319
|
+
var _el$39 = _tmpl$9(), _el$40 = _el$39.firstChild, _el$41 = _el$40.nextSibling, _el$42 = _el$41.nextSibling, _el$43 = _el$42.nextSibling;
|
|
320
|
+
_$setAttribute(_el$39, "data-ak-component", key);
|
|
321
|
+
_$insert(_el$40, () => item.title);
|
|
322
|
+
_$insert(_el$41, () => item.description);
|
|
323
|
+
_el$42.$$click = () => emit("approve");
|
|
324
|
+
_$insert(_el$42, () => item.approveLabel);
|
|
325
|
+
_el$43.$$click = () => emit("deny");
|
|
326
|
+
_$insert(_el$43, () => item.denyLabel);
|
|
327
|
+
_$effect((_p$) => {
|
|
328
|
+
var _v$10 = item.title, _v$11 = props.disabled, _v$12 = props.disabled;
|
|
329
|
+
_v$10 !== _p$.e && _$setAttribute(_el$39, "aria-label", _p$.e = _v$10);
|
|
330
|
+
_v$11 !== _p$.t && (_el$42.disabled = _p$.t = _v$11);
|
|
331
|
+
_v$12 !== _p$.a && (_el$43.disabled = _p$.a = _v$12);
|
|
332
|
+
return _p$;
|
|
333
|
+
}, {
|
|
334
|
+
e: void 0,
|
|
335
|
+
t: void 0,
|
|
336
|
+
a: void 0
|
|
337
|
+
});
|
|
338
|
+
return _el$39;
|
|
339
|
+
})();
|
|
340
|
+
}
|
|
341
|
+
if (key === "table") {
|
|
342
|
+
const item = TablePropsSchema.parse(props.frame.props);
|
|
343
|
+
return (() => {
|
|
344
|
+
var _el$44 = _tmpl$17(), _el$45 = _el$44.firstChild, _el$46 = _el$45.nextSibling, _el$47 = _el$46.firstChild, _el$48 = _el$46.nextSibling;
|
|
345
|
+
_$setAttribute(_el$44, "data-ak-component", key);
|
|
346
|
+
_$insert(_el$45, () => item.caption);
|
|
347
|
+
_$insert(_el$47, _$createComponent(For, {
|
|
348
|
+
get each() {
|
|
349
|
+
return item.columns;
|
|
350
|
+
},
|
|
351
|
+
children: (column) => (() => {
|
|
352
|
+
var _el$49 = _tmpl$18();
|
|
353
|
+
_$insert(_el$49, () => column.label);
|
|
354
|
+
return _el$49;
|
|
355
|
+
})()
|
|
356
|
+
}));
|
|
357
|
+
_$insert(_el$48, _$createComponent(For, {
|
|
358
|
+
get each() {
|
|
359
|
+
return item.rows;
|
|
360
|
+
},
|
|
361
|
+
children: (row) => (() => {
|
|
362
|
+
var _el$50 = _tmpl$19();
|
|
363
|
+
_$insert(_el$50, _$createComponent(For, {
|
|
364
|
+
get each() {
|
|
365
|
+
return item.columns;
|
|
366
|
+
},
|
|
367
|
+
children: (column) => (() => {
|
|
368
|
+
var _el$51 = _tmpl$20();
|
|
369
|
+
_$insert(_el$51, () => String(row[column.key] ?? ""));
|
|
370
|
+
return _el$51;
|
|
371
|
+
})()
|
|
372
|
+
}));
|
|
373
|
+
return _el$50;
|
|
374
|
+
})()
|
|
375
|
+
}));
|
|
376
|
+
return _el$44;
|
|
377
|
+
})();
|
|
378
|
+
}
|
|
379
|
+
if (key === "file-attachment") {
|
|
380
|
+
const item = FileAttachmentPropsSchema.parse(props.frame.props);
|
|
381
|
+
return (() => {
|
|
382
|
+
var _el$52 = _tmpl$21(), _el$53 = _el$52.firstChild, _el$54 = _el$53.nextSibling, _el$55 = _el$54.nextSibling;
|
|
383
|
+
_$setAttribute(_el$52, "data-ak-component", key);
|
|
384
|
+
_$insert(_el$53, () => item.name);
|
|
385
|
+
_$insert(_el$54, () => item.mimeType);
|
|
386
|
+
_$insert(_el$55, (() => {
|
|
387
|
+
var _c$5 = _$memo(() => item.sizeBytes === void 0);
|
|
388
|
+
return () => _c$5() ? "" : `${item.sizeBytes} bytes`;
|
|
389
|
+
})());
|
|
390
|
+
_$insert(_el$52, (() => {
|
|
391
|
+
var _c$6 = _$memo(() => !!item.url);
|
|
392
|
+
return () => _c$6() ? (() => {
|
|
393
|
+
var _el$56 = _tmpl$22();
|
|
394
|
+
_el$56.$$click = (event) => {
|
|
395
|
+
event.preventDefault();
|
|
396
|
+
emit("open", item.url);
|
|
397
|
+
};
|
|
398
|
+
_$effect(() => _$setAttribute(_el$56, "href", item.url));
|
|
399
|
+
return _el$56;
|
|
400
|
+
})() : null;
|
|
401
|
+
})(), null);
|
|
402
|
+
return _el$52;
|
|
403
|
+
})();
|
|
404
|
+
}
|
|
405
|
+
return (() => {
|
|
406
|
+
var _el$57 = _tmpl$23();
|
|
407
|
+
_$insert(_el$57, () => resolveComponentFallback(props.frame, props.manifest));
|
|
408
|
+
return _el$57;
|
|
409
|
+
})();
|
|
410
|
+
};
|
|
411
|
+
_$delegateEvents(["input", "click"]);
|
|
412
|
+
|
|
413
|
+
// src/index.tsx
|
|
414
|
+
var _tmpl$24 = /* @__PURE__ */ _$template2(`<fieldset data-ak-component=choice-list><legend>`);
|
|
415
|
+
var _tmpl$25 = /* @__PURE__ */ _$template2(`<button type=button><span>`);
|
|
416
|
+
var _tmpl$32 = /* @__PURE__ */ _$template2(`<small>`);
|
|
417
|
+
var _tmpl$42 = /* @__PURE__ */ _$template2(`<p data-ak-component-fallback>`);
|
|
418
|
+
var _tmpl$52 = /* @__PURE__ */ _$template2(`<p role=alert>`);
|
|
419
|
+
var _tmpl$62 = /* @__PURE__ */ _$template2(`<button type=button>Stop`);
|
|
420
|
+
var _tmpl$72 = /* @__PURE__ */ _$template2(`<div aria-label="Response actions"><button type=button aria-label="Retry response">Retry</button><button type=button>Edit last message`);
|
|
421
|
+
var _tmpl$82 = /* @__PURE__ */ _$template2(`<section data-ak-app-chat><div aria-live=polite aria-relevant="additions text"role=log>`);
|
|
422
|
+
var _tmpl$92 = /* @__PURE__ */ _$template2(`<button type=button aria-label="Regenerate response">Regenerate`);
|
|
423
|
+
var _tmpl$02 = /* @__PURE__ */ _$template2(`<form><label>Edit message<input aria-label="Edit message"></label><button type=submit aria-label="Save edit">Save edit</button><button type=button>Cancel edit`);
|
|
424
|
+
var toChatCssVariables = (input) => {
|
|
425
|
+
const theme = resolveChatTheme(input);
|
|
426
|
+
return {
|
|
427
|
+
"--ak-color-bg": theme.colors.background,
|
|
428
|
+
"--ak-color-surface": theme.colors.surface,
|
|
429
|
+
"--ak-color-border": theme.colors.border,
|
|
430
|
+
"--ak-color-text": theme.colors.text,
|
|
431
|
+
"--ak-color-text-muted": theme.colors.muted,
|
|
432
|
+
"--ak-color-bubble-user": theme.colors.accent,
|
|
433
|
+
"--ak-color-bubble-user-text": theme.colors.onAccent,
|
|
434
|
+
"--ak-color-bubble-assistant": theme.colors.surface,
|
|
435
|
+
"--ak-color-bubble-assistant-text": theme.colors.text,
|
|
436
|
+
"--ak-color-input-bg": theme.colors.background,
|
|
437
|
+
"--ak-color-input-border": theme.colors.border,
|
|
438
|
+
"--ak-color-input-focus": theme.colors.accent,
|
|
439
|
+
"--ak-color-button": theme.colors.accent,
|
|
440
|
+
"--ak-color-button-text": theme.colors.onAccent,
|
|
441
|
+
"--ak-color-tool-bg": theme.colors.surface,
|
|
442
|
+
"--ak-color-tool-border": theme.colors.border,
|
|
443
|
+
"--ak-app-color-danger": theme.colors.danger,
|
|
444
|
+
"--ak-font-family": theme.fontFamily === "system" ? "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" : theme.fontFamily,
|
|
445
|
+
"--ak-radius": `${theme.radius.medium}px`,
|
|
446
|
+
"--ak-radius-lg": `${theme.radius.large}px`,
|
|
447
|
+
"--ak-spacing-sm": `${theme.spacing.small}px`,
|
|
448
|
+
"--ak-spacing-md": `${theme.spacing.medium}px`,
|
|
449
|
+
"--ak-spacing-lg": `${theme.spacing.large}px`
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
function ChoiceList(props) {
|
|
453
|
+
const resolved = createMemo(() => resolveChoiceListFrame(props.frame, props.manifest));
|
|
454
|
+
return _$createComponent2(Show2, {
|
|
455
|
+
get when() {
|
|
456
|
+
return _$memo2(() => !!resolved().ok)() ? resolved() : void 0;
|
|
457
|
+
},
|
|
458
|
+
children: (value) => {
|
|
459
|
+
const item = value();
|
|
460
|
+
return (() => {
|
|
461
|
+
var _el$ = _tmpl$24(), _el$2 = _el$.firstChild;
|
|
462
|
+
_$insert2(_el$2, () => item.props.prompt);
|
|
463
|
+
_$insert2(_el$, _$createComponent2(For2, {
|
|
464
|
+
get each() {
|
|
465
|
+
return item.props.choices;
|
|
466
|
+
},
|
|
467
|
+
children: (choice) => (() => {
|
|
468
|
+
var _el$3 = _tmpl$25(), _el$4 = _el$3.firstChild;
|
|
469
|
+
_el$3.$$click = () => props.onSelect(selectChoice(item.frame, choice.id));
|
|
470
|
+
_$insert2(_el$4, () => choice.label);
|
|
471
|
+
_$insert2(_el$3, _$createComponent2(Show2, {
|
|
472
|
+
get when() {
|
|
473
|
+
return choice.description;
|
|
474
|
+
},
|
|
475
|
+
children: (description) => (() => {
|
|
476
|
+
var _el$5 = _tmpl$32();
|
|
477
|
+
_$insert2(_el$5, description);
|
|
478
|
+
return _el$5;
|
|
479
|
+
})()
|
|
480
|
+
}), null);
|
|
481
|
+
_$effect2(() => _el$3.disabled = props.disabled);
|
|
482
|
+
return _el$3;
|
|
483
|
+
})()
|
|
484
|
+
}), null);
|
|
485
|
+
_$effect2(() => _$setAttribute2(_el$, "aria-label", item.props.prompt));
|
|
486
|
+
return _el$;
|
|
487
|
+
})();
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
function ChatBinding(props) {
|
|
492
|
+
const chat = useChat(props.config);
|
|
493
|
+
createEffect(() => {
|
|
494
|
+
void chat.status;
|
|
495
|
+
void chat.messages;
|
|
496
|
+
props.onState(chat);
|
|
497
|
+
});
|
|
498
|
+
return props.children(chat);
|
|
499
|
+
}
|
|
500
|
+
function AgentChatSession(props) {
|
|
501
|
+
const initial = untrack(() => ({
|
|
502
|
+
definition: props.definition,
|
|
503
|
+
session: props.session,
|
|
504
|
+
ttl: props.actionConfirmationTtlMs
|
|
505
|
+
}));
|
|
506
|
+
const session = resolveChatSession(initial.definition, initial.session);
|
|
507
|
+
const sessionId = session.sessionId;
|
|
508
|
+
const [activeChat, setActiveChat] = createSignal2(initial.definition.chat);
|
|
509
|
+
let messages = initial.definition.chat.initialMessages ?? [];
|
|
510
|
+
const [actionError, setActionError] = createSignal2();
|
|
511
|
+
const [editDraft, setEditDraft] = createSignal2();
|
|
512
|
+
const [resolvedInstances, setResolvedInstances] = createSignal2(/* @__PURE__ */ new Set());
|
|
513
|
+
let currentChat;
|
|
514
|
+
const coordinator = session.createConfirmation({
|
|
515
|
+
...initial.ttl === void 0 ? {} : {
|
|
516
|
+
ttlMs: initial.ttl
|
|
517
|
+
},
|
|
518
|
+
chat: {
|
|
519
|
+
proposeToolCall: (proposal) => currentChat.proposeToolCall(proposal),
|
|
520
|
+
approve: (id) => currentChat.approve(id),
|
|
521
|
+
deny: (id, reason) => currentChat.deny(id, reason)
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
createEffect(on(() => props.definition.chat, (next) => setActiveChat(() => next), {
|
|
525
|
+
defer: true
|
|
526
|
+
}));
|
|
527
|
+
const fail = (error, fallback) => {
|
|
528
|
+
setActionError(error instanceof Error ? error : new Error(fallback));
|
|
529
|
+
};
|
|
530
|
+
const selectComponent = (event, frame) => {
|
|
531
|
+
if (resolvedInstances().has(event.instanceId)) return;
|
|
532
|
+
setActionError();
|
|
533
|
+
setResolvedInstances((current) => new Set(current).add(event.instanceId));
|
|
534
|
+
try {
|
|
535
|
+
props.onComponentSelect?.(event);
|
|
536
|
+
} catch (error) {
|
|
537
|
+
fail(error, "Component selection callback failed.");
|
|
538
|
+
}
|
|
539
|
+
const action = resolveChoiceAction(frame, event.choiceId);
|
|
540
|
+
if (action) void coordinator.propose(action).catch((error) => {
|
|
541
|
+
setResolvedInstances((current) => {
|
|
542
|
+
const next = new Set(current);
|
|
543
|
+
next.delete(event.instanceId);
|
|
544
|
+
return next;
|
|
545
|
+
});
|
|
546
|
+
fail(error, "Action proposal failed.");
|
|
547
|
+
});
|
|
548
|
+
else {
|
|
549
|
+
let submission;
|
|
550
|
+
try {
|
|
551
|
+
submission = props.definition.choiceSubmission?.(frame, event.choiceId, {
|
|
552
|
+
sessionId
|
|
553
|
+
});
|
|
554
|
+
} catch (error) {
|
|
555
|
+
setResolvedInstances((current) => {
|
|
556
|
+
const next = new Set(current);
|
|
557
|
+
next.delete(event.instanceId);
|
|
558
|
+
return next;
|
|
559
|
+
});
|
|
560
|
+
fail(error, "Choice submission authorization failed.");
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (submission && "unavailable" in submission) {
|
|
564
|
+
setResolvedInstances((current) => {
|
|
565
|
+
const next = new Set(current);
|
|
566
|
+
next.delete(event.instanceId);
|
|
567
|
+
return next;
|
|
568
|
+
});
|
|
569
|
+
fail(new Error("This deterministic choice expired. Ask the question again."), "Choice unavailable.");
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
if (submission) void currentChat.send(submission.value).then(() => {
|
|
573
|
+
try {
|
|
574
|
+
submission.commit();
|
|
575
|
+
} catch (error) {
|
|
576
|
+
fail(error, "Choice submission settlement failed.");
|
|
577
|
+
}
|
|
578
|
+
}, (error) => {
|
|
579
|
+
try {
|
|
580
|
+
submission.release();
|
|
581
|
+
} catch {
|
|
582
|
+
} finally {
|
|
583
|
+
setResolvedInstances((current) => {
|
|
584
|
+
const next = new Set(current);
|
|
585
|
+
next.delete(event.instanceId);
|
|
586
|
+
return next;
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
fail(error, "Choice submission failed.");
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
const interactComponent = (event) => {
|
|
594
|
+
if (resolvedInstances().has(event.instanceId)) return;
|
|
595
|
+
setResolvedInstances((current) => new Set(current).add(event.instanceId));
|
|
596
|
+
try {
|
|
597
|
+
props.onComponentInteract?.(event);
|
|
598
|
+
} catch (error) {
|
|
599
|
+
setResolvedInstances((current) => {
|
|
600
|
+
const next = new Set(current);
|
|
601
|
+
next.delete(event.instanceId);
|
|
602
|
+
return next;
|
|
603
|
+
});
|
|
604
|
+
fail(error, "Component interaction callback failed.");
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
const approve = (id) => {
|
|
608
|
+
const record = coordinator.getByToolCall(id);
|
|
609
|
+
void (record ? coordinator.approve(record.token, sessionId) : currentChat.approve(id)).catch((error) => fail(error, "Action approval failed."));
|
|
610
|
+
};
|
|
611
|
+
const deny = (id, reason) => {
|
|
612
|
+
const record = coordinator.getByToolCall(id);
|
|
613
|
+
void (record ? coordinator.reject(record.token, sessionId, reason) : currentChat.deny(id, reason)).catch((error) => fail(error, "Action rejection failed."));
|
|
614
|
+
};
|
|
615
|
+
const run = (operation) => {
|
|
616
|
+
setActionError();
|
|
617
|
+
void operation.catch((error) => fail(error, "Lifecycle operation failed."));
|
|
618
|
+
};
|
|
619
|
+
const renderMessage = (item) => {
|
|
620
|
+
const rendered = createMemo(() => _$createComponent2(For2, {
|
|
621
|
+
get each() {
|
|
622
|
+
return presentChatMessage(item);
|
|
623
|
+
},
|
|
624
|
+
children: (presentation) => {
|
|
625
|
+
if (presentation.kind === "component") {
|
|
626
|
+
const resolved = props.definition.components === void 0 ? void 0 : resolveComponentFrame2(presentation.frame, props.definition.components);
|
|
627
|
+
if (resolved?.ok) {
|
|
628
|
+
if (presentation.frame.componentKey === "choice-list") {
|
|
629
|
+
const choiceProps = {
|
|
630
|
+
frame: presentation.frame,
|
|
631
|
+
manifest: props.definition.components,
|
|
632
|
+
get disabled() {
|
|
633
|
+
return resolvedInstances().has(presentation.frame.instanceId);
|
|
634
|
+
},
|
|
635
|
+
onSelect: (event) => selectComponent(event, presentation.frame)
|
|
636
|
+
};
|
|
637
|
+
return props.choiceList?.(choiceProps) ?? _$createComponent2(ChoiceList, {
|
|
638
|
+
get frame() {
|
|
639
|
+
return choiceProps.frame;
|
|
640
|
+
},
|
|
641
|
+
get manifest() {
|
|
642
|
+
return choiceProps.manifest;
|
|
643
|
+
},
|
|
644
|
+
get disabled() {
|
|
645
|
+
return resolvedInstances().has(presentation.frame.instanceId);
|
|
646
|
+
},
|
|
647
|
+
get onSelect() {
|
|
648
|
+
return choiceProps.onSelect;
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
const standardProps = {
|
|
653
|
+
frame: presentation.frame,
|
|
654
|
+
manifest: props.definition.components,
|
|
655
|
+
get disabled() {
|
|
656
|
+
return resolvedInstances().has(presentation.frame.instanceId);
|
|
657
|
+
},
|
|
658
|
+
onInteract: interactComponent
|
|
659
|
+
};
|
|
660
|
+
return props.standardComponent?.(standardProps) ?? _$createComponent2(StandardComponent, standardProps);
|
|
661
|
+
}
|
|
662
|
+
return (() => {
|
|
663
|
+
var _el$6 = _tmpl$42();
|
|
664
|
+
_$insert2(_el$6, () => formatSemanticFallback(presentation.frame.fallback));
|
|
665
|
+
return _el$6;
|
|
666
|
+
})();
|
|
667
|
+
}
|
|
668
|
+
if (presentation.kind === "diagnostic") return (() => {
|
|
669
|
+
var _el$7 = _tmpl$52();
|
|
670
|
+
_$insert2(_el$7, () => presentation.message);
|
|
671
|
+
_$effect2(() => _$setAttribute2(_el$7, "data-ak-component-diagnostic", presentation.code));
|
|
672
|
+
return _el$7;
|
|
673
|
+
})();
|
|
674
|
+
return props.message?.(presentation.message) ?? _$createComponent2(Message, {
|
|
675
|
+
get message() {
|
|
676
|
+
return presentation.message;
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}));
|
|
681
|
+
return rendered;
|
|
682
|
+
};
|
|
683
|
+
const renderChat = (chat) => {
|
|
684
|
+
currentChat = chat;
|
|
685
|
+
const targets = createMemo(() => getLifecycleTargets(chat.messages));
|
|
686
|
+
const content = [_$createComponent2(For2, {
|
|
687
|
+
get each() {
|
|
688
|
+
return chat.messages;
|
|
689
|
+
},
|
|
690
|
+
children: renderMessage
|
|
691
|
+
}), _$createComponent2(For2, {
|
|
692
|
+
get each() {
|
|
693
|
+
return chat.messages.flatMap((item) => item.toolCalls ?? []);
|
|
694
|
+
},
|
|
695
|
+
children: (toolCall) => props.confirmation?.(toolCall, approve, deny) ?? _$createComponent2(ToolConfirmation, {
|
|
696
|
+
toolCall,
|
|
697
|
+
onApprove: approve,
|
|
698
|
+
onDeny: deny
|
|
699
|
+
})
|
|
700
|
+
}), _$memo2(() => props.thinking?.(chat.status === "streaming") ?? _$createComponent2(ThinkingIndicator, {
|
|
701
|
+
get visible() {
|
|
702
|
+
return chat.status === "streaming";
|
|
703
|
+
}
|
|
704
|
+
}))];
|
|
705
|
+
return (() => {
|
|
706
|
+
var _el$8 = _tmpl$82(), _el$9 = _el$8.firstChild;
|
|
707
|
+
_$insert2(_el$9, () => props.container?.(content) ?? _$createComponent2(ChatContainer, {
|
|
708
|
+
children: content
|
|
709
|
+
}));
|
|
710
|
+
_$insert2(_el$8, _$createComponent2(Show2, {
|
|
711
|
+
get when() {
|
|
712
|
+
return chat.error ?? actionError();
|
|
713
|
+
},
|
|
714
|
+
children: (error) => (() => {
|
|
715
|
+
var _el$12 = _tmpl$52();
|
|
716
|
+
_$insert2(_el$12, () => error().message);
|
|
717
|
+
_$effect2((_$p) => _$setStyleProperty(_el$12, "color", resolveChatTheme(props.theme).colors.danger));
|
|
718
|
+
return _el$12;
|
|
719
|
+
})()
|
|
720
|
+
}), null);
|
|
721
|
+
_$insert2(_el$8, _$createComponent2(Show2, {
|
|
722
|
+
get when() {
|
|
723
|
+
return chat.status === "streaming";
|
|
724
|
+
},
|
|
725
|
+
get children() {
|
|
726
|
+
var _el$0 = _tmpl$62();
|
|
727
|
+
_$addEventListener(_el$0, "click", chat.stop, true);
|
|
728
|
+
return _el$0;
|
|
729
|
+
}
|
|
730
|
+
}), null);
|
|
731
|
+
_$insert2(_el$8, _$createComponent2(Show2, {
|
|
732
|
+
get when() {
|
|
733
|
+
return _$memo2(() => chat.status !== "streaming")() && targets().userId;
|
|
734
|
+
},
|
|
735
|
+
get children() {
|
|
736
|
+
var _el$1 = _tmpl$72(), _el$10 = _el$1.firstChild, _el$11 = _el$10.nextSibling;
|
|
737
|
+
_el$10.$$click = () => run(chat.retry());
|
|
738
|
+
_$insert2(_el$1, _$createComponent2(Show2, {
|
|
739
|
+
get when() {
|
|
740
|
+
return targets().assistantId;
|
|
741
|
+
},
|
|
742
|
+
children: (assistantId) => (() => {
|
|
743
|
+
var _el$13 = _tmpl$92();
|
|
744
|
+
_el$13.$$click = () => run(chat.regenerate(assistantId()));
|
|
745
|
+
return _el$13;
|
|
746
|
+
})()
|
|
747
|
+
}), _el$11);
|
|
748
|
+
_el$11.$$click = () => {
|
|
749
|
+
const id = targets().userId;
|
|
750
|
+
setEditDraft({
|
|
751
|
+
messageId: id,
|
|
752
|
+
content: chat.messages.find((item) => item.id === id)?.content ?? ""
|
|
753
|
+
});
|
|
754
|
+
};
|
|
755
|
+
_$insert2(_el$1, _$createComponent2(Show2, {
|
|
756
|
+
get when() {
|
|
757
|
+
return editDraft();
|
|
758
|
+
},
|
|
759
|
+
children: (draft) => (() => {
|
|
760
|
+
var _el$14 = _tmpl$02(), _el$15 = _el$14.firstChild, _el$16 = _el$15.firstChild, _el$17 = _el$16.nextSibling, _el$18 = _el$15.nextSibling, _el$19 = _el$18.nextSibling;
|
|
761
|
+
_el$14.addEventListener("submit", (event) => {
|
|
762
|
+
event.preventDefault();
|
|
763
|
+
if (!draft().content.trim()) return;
|
|
764
|
+
run(chat.edit(draft().messageId, draft().content));
|
|
765
|
+
setEditDraft();
|
|
766
|
+
});
|
|
767
|
+
_el$17.$$input = (event) => setEditDraft({
|
|
768
|
+
...draft(),
|
|
769
|
+
content: event.currentTarget.value
|
|
770
|
+
});
|
|
771
|
+
_el$19.$$click = () => setEditDraft();
|
|
772
|
+
_$effect2(() => _el$17.value = draft().content);
|
|
773
|
+
return _el$14;
|
|
774
|
+
})()
|
|
775
|
+
}), null);
|
|
776
|
+
return _el$1;
|
|
777
|
+
}
|
|
778
|
+
}), null);
|
|
779
|
+
_$insert2(_el$8, () => props.input?.(chat, chat.status === "streaming", props.placeholder) ?? _$createComponent2(InputBar, _$mergeProps({
|
|
780
|
+
chat,
|
|
781
|
+
get disabled() {
|
|
782
|
+
return chat.status === "streaming";
|
|
783
|
+
}
|
|
784
|
+
}, () => props.placeholder === void 0 ? {} : {
|
|
785
|
+
placeholder: props.placeholder
|
|
786
|
+
})), null);
|
|
787
|
+
_$effect2((_p$) => {
|
|
788
|
+
var _v$ = `${props.definition.id} chat`, _v$2 = props.theme === void 0 ? void 0 : toChatCssVariables(props.theme);
|
|
789
|
+
_v$ !== _p$.e && _$setAttribute2(_el$8, "aria-label", _p$.e = _v$);
|
|
790
|
+
_p$.t = _$style(_el$8, _v$2, _p$.t);
|
|
791
|
+
return _p$;
|
|
792
|
+
}, {
|
|
793
|
+
e: void 0,
|
|
794
|
+
t: void 0
|
|
795
|
+
});
|
|
796
|
+
return _el$8;
|
|
797
|
+
})();
|
|
798
|
+
};
|
|
799
|
+
return _$createComponent2(Show2, {
|
|
800
|
+
keyed: true,
|
|
801
|
+
get when() {
|
|
802
|
+
return activeChat();
|
|
803
|
+
},
|
|
804
|
+
children: (config) => _$createComponent2(ChatBinding, {
|
|
805
|
+
get config() {
|
|
806
|
+
return session.updateChat({
|
|
807
|
+
...config,
|
|
808
|
+
initialMessages: messages
|
|
809
|
+
});
|
|
810
|
+
},
|
|
811
|
+
onState: (chat) => {
|
|
812
|
+
currentChat = chat;
|
|
813
|
+
messages = chat.messages;
|
|
814
|
+
},
|
|
815
|
+
children: renderChat
|
|
816
|
+
})
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
function AgentChat(props) {
|
|
820
|
+
const key = createMemo(() => `${props.definition.id}:${props.definition.revision ?? 1}:${props.session?.sessionId ?? "new"}`);
|
|
821
|
+
return _$createComponent2(Show2, {
|
|
822
|
+
keyed: true,
|
|
823
|
+
get when() {
|
|
824
|
+
return key();
|
|
825
|
+
},
|
|
826
|
+
children: (_key) => _$createComponent2(AgentChatSession, props)
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
_$delegateEvents2(["click", "input"]);
|
|
830
|
+
export {
|
|
831
|
+
AgentChat,
|
|
832
|
+
ChoiceList,
|
|
833
|
+
StandardComponent,
|
|
834
|
+
toChatCssVariables
|
|
835
|
+
};
|