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