@object-ui/plugin-chatbot 17.3.0 → 17.5.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/CHANGELOG.md +267 -0
- package/README.md +81 -12
- package/dist/chatMessageAdapter.d.ts +134 -0
- package/dist/chatMessageAdapter.d.ts.map +1 -0
- package/dist/index.d.ts +53 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +611 -568
- package/dist/index.umd.cjs +1 -1
- package/dist/tool-display.d.ts +30 -1
- package/dist/tool-display.d.ts.map +1 -1
- package/dist/useHitlInChat.d.ts +19 -1
- package/dist/useHitlInChat.d.ts.map +1 -1
- package/dist/useObjectChat.d.ts +55 -4
- package/dist/useObjectChat.d.ts.map +1 -1
- package/dist/usePendingActions.d.ts +39 -17
- package/dist/usePendingActions.d.ts.map +1 -1
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -16,31 +16,31 @@ import { nanoid as Nt } from "nanoid";
|
|
|
16
16
|
import { codeToHtml as Pt } from "shiki";
|
|
17
17
|
import { useControllableState as Ft } from "@radix-ui/react-use-controllable-state";
|
|
18
18
|
import { motion as It } from "motion/react";
|
|
19
|
-
import { ComponentRegistry as Lt } from "@object-ui/core";
|
|
19
|
+
import { ComponentRegistry as Lt, toDomProps as Rt } from "@object-ui/core";
|
|
20
20
|
//#region \0rolldown/runtime.js
|
|
21
|
-
var
|
|
21
|
+
var zt = Object.defineProperty, Bt = (e, t) => {
|
|
22
22
|
let n = {};
|
|
23
|
-
for (var r in e)
|
|
23
|
+
for (var r in e) zt(n, r, {
|
|
24
24
|
get: e[r],
|
|
25
25
|
enumerable: !0
|
|
26
26
|
});
|
|
27
|
-
return t ||
|
|
27
|
+
return t || zt(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
28
28
|
};
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/utils.ts
|
|
31
|
-
function
|
|
31
|
+
function Vt(e = "msg") {
|
|
32
32
|
return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
33
33
|
}
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/mapMessages.ts
|
|
36
|
-
function
|
|
36
|
+
function Ht(e, t) {
|
|
37
37
|
return typeof e.content == "string" ? e.content : t.filter((e) => e.type === "text").map((e) => e.text ?? "").join("");
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function Ut(e) {
|
|
40
40
|
let t = e.filter((e) => e.type === "reasoning" || e.type === "reasoning-delta").map((e) => e.text ?? "").join("\n").trim();
|
|
41
41
|
return t.length > 0 ? t : void 0;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function Wt(e) {
|
|
44
44
|
let t = (e) => {
|
|
45
45
|
if (e && typeof e == "object") return e;
|
|
46
46
|
if (typeof e != "string") return;
|
|
@@ -63,8 +63,8 @@ function Ut(e) {
|
|
|
63
63
|
}
|
|
64
64
|
return r;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
let t =
|
|
66
|
+
function Gt(e) {
|
|
67
|
+
let t = Wt(e);
|
|
68
68
|
if (!t) return;
|
|
69
69
|
let n = t.pendingActionId;
|
|
70
70
|
if (t.status === "pending_approval" && typeof n == "string" && n.length > 0) return {
|
|
@@ -72,11 +72,11 @@ function Wt(e) {
|
|
|
72
72
|
raw: t
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function Kt(e) {
|
|
76
76
|
return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
let t =
|
|
78
|
+
function qt(e) {
|
|
79
|
+
let t = Wt(e);
|
|
80
80
|
if (!t || t.status !== "blueprint_proposed") return;
|
|
81
81
|
let n = t.blueprint, r = n && typeof n == "object" ? n : {}, i = (Array.isArray(r.objects) ? r.objects : []).flatMap((e) => {
|
|
82
82
|
let t = e;
|
|
@@ -92,7 +92,7 @@ function Kt(e) {
|
|
|
92
92
|
views: a(o.views, Array.isArray(r.views) ? r.views.length : 0),
|
|
93
93
|
dashboards: a(o.dashboards, Array.isArray(r.dashboards) ? r.dashboards.length : 0),
|
|
94
94
|
seedData: a(o.seedData, Array.isArray(r.seedData) ? r.seedData.length : 0)
|
|
95
|
-
}, c =
|
|
95
|
+
}, c = Kt(t.questions), l = t.questionChoices, u = Array.isArray(l) ? l.flatMap((e) => {
|
|
96
96
|
let t = e;
|
|
97
97
|
if (typeof t?.text != "string" || !t.text) return [];
|
|
98
98
|
let n = Array.isArray(t.options) ? t.options.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
@@ -105,14 +105,14 @@ function Kt(e) {
|
|
|
105
105
|
...d ? { summary: d } : {},
|
|
106
106
|
objects: i,
|
|
107
107
|
counts: s,
|
|
108
|
-
questions: c.length ? c :
|
|
108
|
+
questions: c.length ? c : Kt(r.questions),
|
|
109
109
|
...u.length ? { questionChoices: u } : {},
|
|
110
|
-
assumptions:
|
|
110
|
+
assumptions: Kt(r.assumptions),
|
|
111
111
|
...typeof f == "string" && f ? { targetApp: f } : {}
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
let t =
|
|
114
|
+
function Jt(e) {
|
|
115
|
+
let t = Wt(e);
|
|
116
116
|
if (!t || t.status !== "build_handoff") return;
|
|
117
117
|
let n = typeof t.prompt == "string" ? t.prompt.trim() : "";
|
|
118
118
|
if (!n) return;
|
|
@@ -122,8 +122,8 @@ function qt(e) {
|
|
|
122
122
|
...i ? { packageId: i } : {}
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
function
|
|
126
|
-
let t =
|
|
125
|
+
function Yt(e) {
|
|
126
|
+
let t = Wt(e);
|
|
127
127
|
if (!t || t.status !== "changes_proposed") return;
|
|
128
128
|
let n = (e) => typeof e == "string" && e ? e : void 0, r = t.changes, i = (Array.isArray(r) ? r : []).flatMap((e) => {
|
|
129
129
|
let t = e;
|
|
@@ -141,8 +141,8 @@ function Jt(e) {
|
|
|
141
141
|
changes: i
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
let t =
|
|
144
|
+
function Xt(e) {
|
|
145
|
+
let t = Wt(e);
|
|
146
146
|
if (!t || t.status !== "drafted") return;
|
|
147
147
|
let n = [];
|
|
148
148
|
if (Array.isArray(t.drafted)) {
|
|
@@ -182,23 +182,23 @@ function Yt(e) {
|
|
|
182
182
|
...s.length ? { issues: s } : {}
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function Zt(e) {
|
|
186
186
|
return e.replace(/[._-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function Qt(e) {
|
|
189
189
|
if (!e || !Array.isArray(e.items) || e.items.length === 0) return;
|
|
190
190
|
let t = e.items.find((e) => e.type === "app");
|
|
191
191
|
if (t) return {
|
|
192
192
|
phase: "done",
|
|
193
|
-
appLabel:
|
|
193
|
+
appLabel: Zt(t.name),
|
|
194
194
|
items: e.items,
|
|
195
195
|
done: e.items.length,
|
|
196
196
|
total: e.items.length
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function $t(e, t = {}) {
|
|
200
200
|
return e.filter((e) => e.type === "dynamic-tool" || typeof e.type == "string" && e.type.startsWith("tool-")).map((e) => {
|
|
201
|
-
let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result, i =
|
|
201
|
+
let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result, i = Gt(r), a = Xt(r), o = qt(r), s = Yt(r), c = Jt(r), l = e.state, u = (l === "input-available" || l === "input-streaming") && (r !== void 0 || !t.liveTail) ? "output-available" : l, d = i && u !== "output-error" ? "approval-requested" : u;
|
|
202
202
|
return {
|
|
203
203
|
toolCallId: e.toolCallId ?? e.id ?? `${e.type ?? "tool"}-${Math.random().toString(36).slice(2, 8)}`,
|
|
204
204
|
toolName: n,
|
|
@@ -214,7 +214,7 @@ function Qt(e, t = {}) {
|
|
|
214
214
|
};
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function en(e) {
|
|
218
218
|
let t = e.filter((e) => e.type === "source-url" || e.type === "source").map((e) => ({
|
|
219
219
|
id: e.id,
|
|
220
220
|
title: e.title,
|
|
@@ -222,7 +222,7 @@ function $t(e) {
|
|
|
222
222
|
})).filter((e) => !!e.url);
|
|
223
223
|
return t.length > 0 ? t : void 0;
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function tn(e) {
|
|
226
226
|
let t = e.filter((e) => e.type === "data-build-progress").pop()?.data;
|
|
227
227
|
if (!t || typeof t != "object") return;
|
|
228
228
|
let n = t, r = Array.isArray(n.items) ? n.items.filter((e) => typeof e?.type == "string" && typeof e?.name == "string").map((e) => ({
|
|
@@ -238,7 +238,7 @@ function en(e) {
|
|
|
238
238
|
...typeof n.seq == "number" ? { seq: n.seq } : {}
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function nn(e) {
|
|
242
242
|
let t = e.filter((e) => e.type === "data-blueprint-progress").pop()?.data;
|
|
243
243
|
if (!t || typeof t != "object") return;
|
|
244
244
|
let n = t, r = Array.isArray(n.objects) ? n.objects.filter((e) => typeof e?.name == "string").map((e) => ({
|
|
@@ -260,7 +260,7 @@ function tn(e) {
|
|
|
260
260
|
...typeof n.seq == "number" ? { seq: n.seq } : {}
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function rn(e) {
|
|
264
264
|
let t = [];
|
|
265
265
|
for (let n of e) {
|
|
266
266
|
if (n.type !== "data-chart") continue;
|
|
@@ -280,35 +280,70 @@ function nn(e) {
|
|
|
280
280
|
}
|
|
281
281
|
return t.length > 0 ? t : void 0;
|
|
282
282
|
}
|
|
283
|
-
function
|
|
284
|
-
let n = Array.isArray(e.parts) ? e.parts : [], r =
|
|
283
|
+
function an(e, t = {}) {
|
|
284
|
+
let n = Array.isArray(e.parts) ? e.parts : [], r = $t(n, { liveTail: t.streaming }), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [], a = r.length > 0 ? r : i, o = tn(n) ?? a.map((e) => Qt(e.draftReview)).find((e) => !!e);
|
|
285
285
|
return {
|
|
286
286
|
id: e.id ?? `msg-${Math.random().toString(36).slice(2, 8)}`,
|
|
287
287
|
role: e.role ?? "assistant",
|
|
288
|
-
content:
|
|
289
|
-
reasoning:
|
|
288
|
+
content: Ht(e, n),
|
|
289
|
+
reasoning: Ut(n),
|
|
290
290
|
toolInvocations: a,
|
|
291
|
-
sources:
|
|
291
|
+
sources: en(n),
|
|
292
292
|
buildProgress: o,
|
|
293
|
-
blueprintProgress:
|
|
294
|
-
charts:
|
|
293
|
+
blueprintProgress: nn(n),
|
|
294
|
+
charts: rn(n),
|
|
295
295
|
streaming: t.streaming
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function on(e, t = {}) {
|
|
299
299
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
300
300
|
let n = e.length - 1;
|
|
301
|
-
return e.map((e, r) =>
|
|
301
|
+
return e.map((e, r) => an(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
|
|
302
|
+
}
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/chatMessageAdapter.ts
|
|
305
|
+
function sn(e) {
|
|
306
|
+
return typeof e == "string" ? e : e instanceof Date ? e.toISOString() : void 0;
|
|
307
|
+
}
|
|
308
|
+
function cn(e) {
|
|
309
|
+
return e === "tool" ? "assistant" : e;
|
|
310
|
+
}
|
|
311
|
+
function ln(e) {
|
|
312
|
+
switch (e) {
|
|
313
|
+
case "partial-call": return "input-streaming";
|
|
314
|
+
case "call": return "input-available";
|
|
315
|
+
case "result": return "output-available";
|
|
316
|
+
default: return e;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function un(e) {
|
|
320
|
+
let { state: t, ...n } = e;
|
|
321
|
+
return {
|
|
322
|
+
...n,
|
|
323
|
+
state: ln(t)
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function dn(e) {
|
|
327
|
+
let { role: t, timestamp: n, toolInvocations: r, ...i } = e;
|
|
328
|
+
return {
|
|
329
|
+
...i,
|
|
330
|
+
role: cn(t),
|
|
331
|
+
timestamp: sn(n),
|
|
332
|
+
toolInvocations: r?.map(un)
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function fn(e) {
|
|
336
|
+
return (e ?? []).map(dn);
|
|
302
337
|
}
|
|
303
338
|
//#endregion
|
|
304
339
|
//#region src/useObjectChat.ts
|
|
305
|
-
var
|
|
306
|
-
function
|
|
340
|
+
var pn = "objectui:ai-usage-refresh";
|
|
341
|
+
function mn() {
|
|
307
342
|
if (!(typeof window > "u" || typeof window.dispatchEvent != "function")) try {
|
|
308
|
-
window.dispatchEvent(new CustomEvent(
|
|
343
|
+
window.dispatchEvent(new CustomEvent(pn));
|
|
309
344
|
} catch {}
|
|
310
345
|
}
|
|
311
|
-
async function
|
|
346
|
+
async function hn(e, t) {
|
|
312
347
|
let n;
|
|
313
348
|
try {
|
|
314
349
|
n = await fetch(e, t);
|
|
@@ -326,7 +361,7 @@ async function cn(e, t) {
|
|
|
326
361
|
}
|
|
327
362
|
return n;
|
|
328
363
|
}
|
|
329
|
-
function
|
|
364
|
+
function gn(e) {
|
|
330
365
|
let t = [...e.messages].reverse().find((e) => e.role === "user");
|
|
331
366
|
return { body: {
|
|
332
367
|
...e.body ?? {},
|
|
@@ -337,7 +372,7 @@ function ln(e) {
|
|
|
337
372
|
...t ? { turnId: t.id } : {}
|
|
338
373
|
} };
|
|
339
374
|
}
|
|
340
|
-
function
|
|
375
|
+
function _n(e, t) {
|
|
341
376
|
let n = e.context ?? {};
|
|
342
377
|
return {
|
|
343
378
|
...e,
|
|
@@ -347,25 +382,25 @@ function un(e, t) {
|
|
|
347
382
|
}
|
|
348
383
|
};
|
|
349
384
|
}
|
|
350
|
-
function
|
|
385
|
+
function vn(e) {
|
|
351
386
|
return (e ?? []).map((e, t) => ({
|
|
352
387
|
id: e.id || `msg-${t}`,
|
|
353
388
|
role: e.role || "user",
|
|
354
389
|
content: e.content || "",
|
|
355
|
-
timestamp:
|
|
390
|
+
timestamp: sn(e.timestamp),
|
|
356
391
|
metadata: e.metadata,
|
|
357
392
|
streaming: e.streaming,
|
|
358
393
|
toolInvocations: e.toolInvocations
|
|
359
394
|
}));
|
|
360
395
|
}
|
|
361
|
-
function
|
|
396
|
+
function yn(e = {}) {
|
|
362
397
|
let { api: t, initialMessages: n, conversationId: r, parentConversationId: i, systemPrompt: a, model: s, streamingEnabled: f = !0, headers: p, body: m, maxToolRoundtrips: h = 5, onError: g, showTimestamp: _, autoResponse: v, autoResponseText: y, autoResponseDelay: b = 1e3, onSend: x } = e, S = u(t ? "api" : "local").current === "api", C = l(() => (n ?? []).map((e, t) => {
|
|
363
398
|
if (Array.isArray(e.parts) && e.parts.length > 0) return {
|
|
364
399
|
id: e.id || `msg-${t}`,
|
|
365
400
|
role: e.role || "user",
|
|
366
401
|
parts: e.parts
|
|
367
402
|
};
|
|
368
|
-
let n =
|
|
403
|
+
let n = vn([e])[0], r = [];
|
|
369
404
|
n.content && r.push({
|
|
370
405
|
type: "text",
|
|
371
406
|
text: n.content
|
|
@@ -400,7 +435,7 @@ function fn(e = {}) {
|
|
|
400
435
|
let D = l(() => {
|
|
401
436
|
if (S) return new Ct({
|
|
402
437
|
api: t,
|
|
403
|
-
fetch:
|
|
438
|
+
fetch: hn,
|
|
404
439
|
headers: { ...p },
|
|
405
440
|
body: {
|
|
406
441
|
...m,
|
|
@@ -410,14 +445,14 @@ function fn(e = {}) {
|
|
|
410
445
|
...f === void 0 ? {} : { stream: f }
|
|
411
446
|
},
|
|
412
447
|
prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) => {
|
|
413
|
-
let a =
|
|
448
|
+
let a = gn({
|
|
414
449
|
id: e,
|
|
415
450
|
body: t,
|
|
416
451
|
messages: n,
|
|
417
452
|
trigger: r,
|
|
418
453
|
messageId: i
|
|
419
454
|
});
|
|
420
|
-
return w.current && (a.body.model = w.current), T.current &&= (a.body =
|
|
455
|
+
return w.current && (a.body.model = w.current), T.current &&= (a.body = _n(a.body, T.current), void 0), a;
|
|
421
456
|
}
|
|
422
457
|
});
|
|
423
458
|
}, [
|
|
@@ -435,7 +470,7 @@ function fn(e = {}) {
|
|
|
435
470
|
onError: S ? (e) => {
|
|
436
471
|
if (e.notSent) {
|
|
437
472
|
let e = O.current, t = e?.messages;
|
|
438
|
-
e?.setMessages && t && t.length > 0 && t[t.length - 1]?.role === "user" && e.setMessages(t.slice(0, -1)),
|
|
473
|
+
e?.setMessages && t && t.length > 0 && t[t.length - 1]?.role === "user" && e.setMessages(t.slice(0, -1)), mn();
|
|
439
474
|
}
|
|
440
475
|
g?.(e);
|
|
441
476
|
} : void 0
|
|
@@ -444,20 +479,20 @@ function fn(e = {}) {
|
|
|
444
479
|
let A = u(void 0), j = k?.status;
|
|
445
480
|
c(() => {
|
|
446
481
|
let e = A.current;
|
|
447
|
-
A.current = j, (e === "streaming" || e === "submitted") && j === "ready" &&
|
|
482
|
+
A.current = j, (e === "streaming" || e === "submitted") && j === "ready" && mn();
|
|
448
483
|
}, [j]);
|
|
449
|
-
let [M, N] = d(() =>
|
|
484
|
+
let [M, N] = d(() => vn(n)), [ee, P] = d(!1), [F, I] = d(""), [te, ne] = d(""), L = u(null);
|
|
450
485
|
c(() => () => {
|
|
451
486
|
L.current &&= (clearTimeout(L.current), null);
|
|
452
487
|
}, []);
|
|
453
|
-
let { messages: re, status: ie, error: R, sendMessage: ae, regenerate: oe, stop: z, setMessages: B } = k, V = ie === "submitted" || ie === "streaming", H =
|
|
488
|
+
let { messages: re, status: ie, error: R, sendMessage: ae, regenerate: oe, stop: z, setMessages: B } = k, V = ie === "submitted" || ie === "streaming", H = on(re, { isStreaming: V }).map((e, t) => ({
|
|
454
489
|
...e,
|
|
455
490
|
metadata: re[t]?.metadata
|
|
456
491
|
})), se = o((e) => {
|
|
457
492
|
let t = e.trim();
|
|
458
493
|
if (!t) return;
|
|
459
494
|
let n = [...H, {
|
|
460
|
-
id:
|
|
495
|
+
id: Vt("msg"),
|
|
461
496
|
role: "user",
|
|
462
497
|
content: t
|
|
463
498
|
}];
|
|
@@ -475,7 +510,7 @@ function fn(e = {}) {
|
|
|
475
510
|
}, []), de = o((e) => {
|
|
476
511
|
if (!e.trim()) return;
|
|
477
512
|
let t = {
|
|
478
|
-
id:
|
|
513
|
+
id: Vt("msg"),
|
|
479
514
|
role: "user",
|
|
480
515
|
content: e.trim(),
|
|
481
516
|
timestamp: _ ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
@@ -485,7 +520,7 @@ function fn(e = {}) {
|
|
|
485
520
|
return x?.(e.trim(), r), r;
|
|
486
521
|
}), I(""), v && (P(!0), L.current = setTimeout(() => {
|
|
487
522
|
let e = {
|
|
488
|
-
id:
|
|
523
|
+
id: Vt("msg"),
|
|
489
524
|
role: "assistant",
|
|
490
525
|
content: y || "Thank you for your message!",
|
|
491
526
|
timestamp: _ ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
@@ -532,31 +567,31 @@ function fn(e = {}) {
|
|
|
532
567
|
}
|
|
533
568
|
//#endregion
|
|
534
569
|
//#region src/agentAliases.ts
|
|
535
|
-
var
|
|
536
|
-
function
|
|
537
|
-
return
|
|
570
|
+
var bn = [["build", "metadata_assistant"], ["ask", "data_chat"]];
|
|
571
|
+
function xn(e) {
|
|
572
|
+
return bn.find((t) => t.includes(e)) ?? [e];
|
|
538
573
|
}
|
|
539
|
-
function
|
|
540
|
-
return
|
|
574
|
+
function Sn(e) {
|
|
575
|
+
return xn(e)[0];
|
|
541
576
|
}
|
|
542
|
-
function
|
|
577
|
+
function Cn(e, t) {
|
|
543
578
|
if (e) {
|
|
544
579
|
if (t.includes(e)) return e;
|
|
545
|
-
for (let n of
|
|
580
|
+
for (let n of xn(e)) if (t.includes(n)) return n;
|
|
546
581
|
}
|
|
547
582
|
}
|
|
548
|
-
function
|
|
549
|
-
return e != null &&
|
|
583
|
+
function wn(e) {
|
|
584
|
+
return e != null && bn.some((t) => t.includes(e));
|
|
550
585
|
}
|
|
551
|
-
function
|
|
552
|
-
return e != null &&
|
|
586
|
+
function Tn(e) {
|
|
587
|
+
return e != null && Sn(e) === "build";
|
|
553
588
|
}
|
|
554
|
-
function
|
|
555
|
-
return e != null &&
|
|
589
|
+
function En(e) {
|
|
590
|
+
return e != null && Sn(e) === "ask";
|
|
556
591
|
}
|
|
557
592
|
//#endregion
|
|
558
593
|
//#region src/useAgents.ts
|
|
559
|
-
function
|
|
594
|
+
function Dn(e) {
|
|
560
595
|
if (!(!e || typeof e != "object")) return {
|
|
561
596
|
authoring: e.authoring === !0,
|
|
562
597
|
canvas: e.canvas === !0,
|
|
@@ -564,45 +599,45 @@ function bn(e) {
|
|
|
564
599
|
resume: e.resume === !0
|
|
565
600
|
};
|
|
566
601
|
}
|
|
567
|
-
function
|
|
602
|
+
function On(e, t, n) {
|
|
568
603
|
if (!t) return !1;
|
|
569
604
|
let r = e.find((e) => e.name === t);
|
|
570
|
-
return r?.capabilities ? r.capabilities[n] :
|
|
605
|
+
return r?.capabilities ? r.capabilities[n] : Tn(t);
|
|
571
606
|
}
|
|
572
|
-
var
|
|
573
|
-
function
|
|
607
|
+
var kn = "ask";
|
|
608
|
+
function An(e, t) {
|
|
574
609
|
if (e.length === 0) return;
|
|
575
610
|
let n = e.map((e) => e.name);
|
|
576
611
|
if (t) {
|
|
577
|
-
let e =
|
|
612
|
+
let e = Cn(t, n);
|
|
578
613
|
if (e) return e;
|
|
579
614
|
}
|
|
580
|
-
return
|
|
615
|
+
return Cn("ask", n) || e[0].name;
|
|
581
616
|
}
|
|
582
|
-
function
|
|
617
|
+
function jn(e) {
|
|
583
618
|
let t = e && typeof e == "object" && !Array.isArray(e) && typeof e.success == "boolean" ? e.data : e;
|
|
584
619
|
if (Array.isArray(t)) return t;
|
|
585
620
|
let n = t?.agents;
|
|
586
621
|
return Array.isArray(n) ? n : [];
|
|
587
622
|
}
|
|
588
|
-
function
|
|
623
|
+
function Mn(e) {
|
|
589
624
|
return e.filter((e) => typeof e?.name == "string" && e.name.length > 0).map((e) => ({
|
|
590
625
|
name: e.name,
|
|
591
626
|
label: e.label || e.name,
|
|
592
627
|
description: e.description,
|
|
593
628
|
role: e.role,
|
|
594
629
|
active: e.active !== !1,
|
|
595
|
-
capabilities:
|
|
630
|
+
capabilities: Dn(e.capabilities)
|
|
596
631
|
}));
|
|
597
632
|
}
|
|
598
|
-
var
|
|
599
|
-
function
|
|
600
|
-
if (n)
|
|
633
|
+
var Nn = 3e4, Pn = /* @__PURE__ */ new Map(), Fn = /* @__PURE__ */ new Map();
|
|
634
|
+
function In(e, t, n) {
|
|
635
|
+
if (n) Pn.delete(e);
|
|
601
636
|
else {
|
|
602
|
-
let t =
|
|
603
|
-
if (t && Date.now() - t.timestamp <
|
|
637
|
+
let t = Pn.get(e);
|
|
638
|
+
if (t && Date.now() - t.timestamp < Nn) return Promise.resolve(t.data);
|
|
604
639
|
}
|
|
605
|
-
let r =
|
|
640
|
+
let r = Fn.get(e);
|
|
606
641
|
if (r && !n) return r;
|
|
607
642
|
let i = `${e.replace(/\/$/, "")}/agents`, a = fetch(i, {
|
|
608
643
|
method: "GET",
|
|
@@ -613,21 +648,21 @@ function kn(e, t, n) {
|
|
|
613
648
|
credentials: "include"
|
|
614
649
|
}).then(async (e) => {
|
|
615
650
|
if (!e.ok) throw Error(`Failed to load agents (${e.status})`);
|
|
616
|
-
return
|
|
617
|
-
}).then((t) => (
|
|
651
|
+
return Mn(jn(await e.json()));
|
|
652
|
+
}).then((t) => (Pn.set(e, {
|
|
618
653
|
data: t,
|
|
619
654
|
timestamp: Date.now()
|
|
620
655
|
}), t)).finally(() => {
|
|
621
|
-
|
|
656
|
+
Fn.delete(e);
|
|
622
657
|
});
|
|
623
|
-
return
|
|
658
|
+
return Fn.set(e, a), a;
|
|
624
659
|
}
|
|
625
|
-
function
|
|
660
|
+
function Ln(e = {}) {
|
|
626
661
|
let { apiBase: t, headers: n, enabled: r = !0, fallback: i = [] } = e, [a, s] = d(i), [l, f] = d(!1), [p, m] = d(void 0), [h, g] = d(0), _ = u(n);
|
|
627
662
|
return _.current = n, c(() => {
|
|
628
663
|
if (!r || !t) return;
|
|
629
664
|
let e = !1;
|
|
630
|
-
return f(!0), m(void 0),
|
|
665
|
+
return f(!0), m(void 0), In(t, _.current, h > 0).then((t) => {
|
|
631
666
|
e || s(t.length > 0 ? t : i);
|
|
632
667
|
}).catch((t) => {
|
|
633
668
|
e || (m(t), s(i));
|
|
@@ -649,13 +684,13 @@ function An(e = {}) {
|
|
|
649
684
|
}
|
|
650
685
|
//#endregion
|
|
651
686
|
//#region src/useAiModels.ts
|
|
652
|
-
function
|
|
687
|
+
function Rn(e) {
|
|
653
688
|
return e.filter((e) => typeof e?.id == "string" && e.id.length > 0).map((e) => ({
|
|
654
689
|
id: e.id,
|
|
655
690
|
label: e.label || e.id
|
|
656
691
|
}));
|
|
657
692
|
}
|
|
658
|
-
function
|
|
693
|
+
function zn(e = {}) {
|
|
659
694
|
let { apiBase: t, headers: n, enabled: r = !0 } = e, [i, a] = d([]), [s, l] = d(void 0), [f, p] = d(!1), [m, h] = d(void 0), [g, _] = d(0), v = u(n);
|
|
660
695
|
return v.current = n, c(() => {
|
|
661
696
|
if (!r || !t) return;
|
|
@@ -675,7 +710,7 @@ function Mn(e = {}) {
|
|
|
675
710
|
if (!t.ok) throw Error(`Failed to load AI models (${t.status})`);
|
|
676
711
|
let r = await t.json();
|
|
677
712
|
if (n) return;
|
|
678
|
-
let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d =
|
|
713
|
+
let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d = Rn(c);
|
|
679
714
|
a(d), l(u ?? c.find((e) => e?.default)?.id ?? c[0]?.id), p(!1), d.length === 0 && o < 5 && !n && (o += 1, setTimeout(() => {
|
|
680
715
|
s();
|
|
681
716
|
}, 1200));
|
|
@@ -704,8 +739,8 @@ function Mn(e = {}) {
|
|
|
704
739
|
}
|
|
705
740
|
//#endregion
|
|
706
741
|
//#region src/FloatingChatbotProvider.tsx
|
|
707
|
-
var
|
|
708
|
-
function
|
|
742
|
+
var Bn = e.createContext(null);
|
|
743
|
+
function Vn({ defaultOpen: t = !1, children: n }) {
|
|
709
744
|
let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
|
|
710
745
|
isOpen: r,
|
|
711
746
|
isFullscreen: a,
|
|
@@ -716,26 +751,26 @@ function Pn({ defaultOpen: t = !1, children: n }) {
|
|
|
716
751
|
toggle: () => i((e) => !e),
|
|
717
752
|
toggleFullscreen: () => o((e) => !e)
|
|
718
753
|
}), [r, a]);
|
|
719
|
-
return /* @__PURE__ */ Z(
|
|
754
|
+
return /* @__PURE__ */ Z(Bn.Provider, {
|
|
720
755
|
value: s,
|
|
721
756
|
children: n
|
|
722
757
|
});
|
|
723
758
|
}
|
|
724
|
-
function
|
|
725
|
-
let t = e.useContext(
|
|
759
|
+
function Hn() {
|
|
760
|
+
let t = e.useContext(Bn);
|
|
726
761
|
if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
|
|
727
762
|
return t;
|
|
728
763
|
}
|
|
729
764
|
//#endregion
|
|
730
765
|
//#region src/FloatingChatbotTrigger.tsx
|
|
731
|
-
function
|
|
766
|
+
function Un() {
|
|
732
767
|
let { t: e } = $();
|
|
733
768
|
return (t, n) => {
|
|
734
769
|
let r = e(`common.${t}`);
|
|
735
770
|
return !r || r === `common.${t}` ? n : r;
|
|
736
771
|
};
|
|
737
772
|
}
|
|
738
|
-
var
|
|
773
|
+
var Wn = {
|
|
739
774
|
32: "size-8",
|
|
740
775
|
36: "size-9",
|
|
741
776
|
40: "size-10",
|
|
@@ -748,17 +783,17 @@ var Ln = {
|
|
|
748
783
|
72: "size-[72px]",
|
|
749
784
|
80: "size-20"
|
|
750
785
|
};
|
|
751
|
-
function
|
|
786
|
+
function Gn(e, t) {
|
|
752
787
|
return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
753
788
|
}
|
|
754
|
-
function
|
|
755
|
-
return
|
|
789
|
+
function Kn(e) {
|
|
790
|
+
return Wn[e] ?? Wn[Gn(e, Object.keys(Wn).map(Number))];
|
|
756
791
|
}
|
|
757
|
-
function
|
|
758
|
-
let { isOpen: r, toggle: i } =
|
|
792
|
+
function qn({ position: e = "bottom-right", size: t = 56, className: n }) {
|
|
793
|
+
let { isOpen: r, toggle: i } = Hn(), a = Un();
|
|
759
794
|
return /* @__PURE__ */ Z(v, {
|
|
760
795
|
onClick: i,
|
|
761
|
-
className: G("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105",
|
|
796
|
+
className: G("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", Kn(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
|
|
762
797
|
size: "icon",
|
|
763
798
|
"aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
|
|
764
799
|
"data-testid": "floating-chatbot-trigger",
|
|
@@ -767,7 +802,7 @@ function Bn({ position: e = "bottom-right", size: t = 56, className: n }) {
|
|
|
767
802
|
}
|
|
768
803
|
//#endregion
|
|
769
804
|
//#region src/FloatingChatbotPanel.tsx
|
|
770
|
-
var
|
|
805
|
+
var Jn = {
|
|
771
806
|
300: "sm:w-[300px]",
|
|
772
807
|
320: "sm:w-[320px]",
|
|
773
808
|
340: "sm:w-[340px]",
|
|
@@ -786,7 +821,7 @@ var Vn = {
|
|
|
786
821
|
640: "sm:w-[640px]",
|
|
787
822
|
720: "sm:w-[720px]",
|
|
788
823
|
800: "sm:w-[800px]"
|
|
789
|
-
},
|
|
824
|
+
}, Yn = {
|
|
790
825
|
360: "h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]",
|
|
791
826
|
400: "h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]",
|
|
792
827
|
420: "h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]",
|
|
@@ -800,19 +835,19 @@ var Vn = {
|
|
|
800
835
|
720: "h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]",
|
|
801
836
|
800: "h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]"
|
|
802
837
|
};
|
|
803
|
-
function
|
|
838
|
+
function Xn(e, t) {
|
|
804
839
|
return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
805
840
|
}
|
|
806
|
-
function
|
|
807
|
-
return
|
|
841
|
+
function Zn(e) {
|
|
842
|
+
return Jn[e] ?? Jn[Xn(e, Object.keys(Jn).map(Number))];
|
|
808
843
|
}
|
|
809
|
-
function
|
|
810
|
-
return
|
|
844
|
+
function Qn(e) {
|
|
845
|
+
return Yn[e] ?? Yn[Xn(e, Object.keys(Yn).map(Number))];
|
|
811
846
|
}
|
|
812
|
-
function
|
|
813
|
-
let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } =
|
|
847
|
+
function $n({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
|
|
848
|
+
let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = Hn();
|
|
814
849
|
return c ? /* @__PURE__ */ Q("div", {
|
|
815
|
-
className: G("fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all", l ? "inset-0 h-svh w-screen rounded-none" : t === "bottom-right" ? G("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]",
|
|
850
|
+
className: G("fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all", l ? "inset-0 h-svh w-screen rounded-none" : t === "bottom-right" ? G("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", Zn(n), Qn(r)) : G("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:right-auto sm:left-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", Zn(n), Qn(r)), a),
|
|
816
851
|
role: "dialog",
|
|
817
852
|
"aria-label": e,
|
|
818
853
|
"data-testid": "floating-chatbot-panel",
|
|
@@ -861,7 +896,7 @@ function Kn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
861
896
|
}
|
|
862
897
|
//#endregion
|
|
863
898
|
//#region src/tool-display.ts
|
|
864
|
-
var
|
|
899
|
+
var er = {
|
|
865
900
|
ai: "AI",
|
|
866
901
|
api: "API",
|
|
867
902
|
crm: "CRM",
|
|
@@ -873,17 +908,17 @@ var qn = {
|
|
|
873
908
|
url: "URL",
|
|
874
909
|
utc: "UTC"
|
|
875
910
|
};
|
|
876
|
-
function
|
|
911
|
+
function tr(e) {
|
|
877
912
|
if (!e) return "";
|
|
878
913
|
let t = String(e).trim();
|
|
879
914
|
if (!t) return "";
|
|
880
915
|
let n = t.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean);
|
|
881
916
|
return n.length === 0 ? t : n.map((e, t) => {
|
|
882
917
|
let n = e.toLowerCase();
|
|
883
|
-
return
|
|
918
|
+
return er[n] ? er[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
|
|
884
919
|
}).join(" ");
|
|
885
920
|
}
|
|
886
|
-
function
|
|
921
|
+
function nr(e) {
|
|
887
922
|
if (e == null) return e;
|
|
888
923
|
let t = e;
|
|
889
924
|
for (let e = 0; e < 2; e++) {
|
|
@@ -901,7 +936,7 @@ function Yn(e) {
|
|
|
901
936
|
}
|
|
902
937
|
return t;
|
|
903
938
|
}
|
|
904
|
-
function
|
|
939
|
+
function rr(e) {
|
|
905
940
|
let t = (e instanceof Error ? e.message : String(e ?? "")).replace(/\s+/g, " ").trim();
|
|
906
941
|
if (!t) return { summary: "Something went wrong. Please try again." };
|
|
907
942
|
let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, ""), r = n.match(/^Invalid error response format:\s*(.+)$/i)?.[1]?.trim() ?? n, i = r.match(/^([^:]{8,80}):\s+(.+)$/)?.[1]?.trim() ?? r.match(/^([^.;!?]+[.;!?])\s/)?.[1]?.trim() ?? (r.length > 140 ? `${r.slice(0, 137).trimEnd()}…` : r);
|
|
@@ -910,12 +945,18 @@ function Xn(e) {
|
|
|
910
945
|
details: n.length > i.length ? n : void 0
|
|
911
946
|
};
|
|
912
947
|
}
|
|
913
|
-
var
|
|
948
|
+
var ir = /* @__PURE__ */ new Set([
|
|
914
949
|
"ai_design_quota_exhausted",
|
|
915
950
|
"ai_data_chat_trial_exhausted",
|
|
916
951
|
"ai_allowance_exhausted"
|
|
917
952
|
]);
|
|
918
|
-
function
|
|
953
|
+
function ar(e) {
|
|
954
|
+
return typeof e == "string" && ir.has(e) ? e : void 0;
|
|
955
|
+
}
|
|
956
|
+
function or(e) {
|
|
957
|
+
return typeof e == "string" && e.trim() ? e : void 0;
|
|
958
|
+
}
|
|
959
|
+
function sr(e) {
|
|
919
960
|
let t = e instanceof Error ? e.message : String(e ?? "");
|
|
920
961
|
if (!t) return null;
|
|
921
962
|
let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, "").replace(/^Invalid error response format:\s*/i, "").trim(), r = n.indexOf("{"), i = n.lastIndexOf("}");
|
|
@@ -926,38 +967,40 @@ function Qn(e) {
|
|
|
926
967
|
} catch {
|
|
927
968
|
return null;
|
|
928
969
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
970
|
+
if (!a || typeof a != "object") return null;
|
|
971
|
+
let o = a.error && typeof a.error == "object" ? a.error : void 0, s = ar(a.error), c = ar(o?.code) ?? s ?? ar(a.code);
|
|
972
|
+
return c ? {
|
|
973
|
+
code: c,
|
|
974
|
+
message: or(o?.message) ?? or(a.message) ?? (s ? void 0 : or(a.error)) ?? "",
|
|
975
|
+
messageEn: or(a.messageEn),
|
|
933
976
|
upgrade: a.upgrade === !0,
|
|
934
977
|
topUp: a.topUp === !0
|
|
935
|
-
};
|
|
978
|
+
} : null;
|
|
936
979
|
}
|
|
937
|
-
function
|
|
980
|
+
function cr(e) {
|
|
938
981
|
return !!(e && typeof e == "object" && e.notSent === !0);
|
|
939
982
|
}
|
|
940
|
-
function
|
|
983
|
+
function lr(e) {
|
|
941
984
|
let t = e && typeof e == "object" ? e.status : void 0;
|
|
942
985
|
return typeof t == "number" ? t : void 0;
|
|
943
986
|
}
|
|
944
|
-
function
|
|
945
|
-
if (
|
|
987
|
+
function ur(e) {
|
|
988
|
+
if (lr(e) === 429) return !0;
|
|
946
989
|
let t = e instanceof Error ? e.message : typeof e == "string" ? e : "";
|
|
947
990
|
return /\b429\b|too many requests|rate[\s_-]?limit/i.test(t);
|
|
948
991
|
}
|
|
949
992
|
//#endregion
|
|
950
993
|
//#region src/elements/conversation.tsx
|
|
951
|
-
var
|
|
994
|
+
var dr = ({ className: e, ...t }) => /* @__PURE__ */ Z(Ot, {
|
|
952
995
|
className: G("relative flex-1 overflow-y-hidden", e),
|
|
953
996
|
initial: "smooth",
|
|
954
997
|
resize: "smooth",
|
|
955
998
|
role: "log",
|
|
956
999
|
...t
|
|
957
|
-
}),
|
|
1000
|
+
}), fr = ({ className: e, ...t }) => /* @__PURE__ */ Z(Ot.Content, {
|
|
958
1001
|
className: G("flex flex-col gap-8 p-4", e),
|
|
959
1002
|
...t
|
|
960
|
-
}),
|
|
1003
|
+
}), pr = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Z("div", {
|
|
961
1004
|
className: G("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
|
|
962
1005
|
...a,
|
|
963
1006
|
children: i ?? /* @__PURE__ */ Q(X, { children: [r && /* @__PURE__ */ Z("div", {
|
|
@@ -973,7 +1016,7 @@ var nr = ({ className: e, ...t }) => /* @__PURE__ */ Z(Ot, {
|
|
|
973
1016
|
children: n
|
|
974
1017
|
})]
|
|
975
1018
|
})] })
|
|
976
|
-
}),
|
|
1019
|
+
}), mr = ({ className: e, ...t }) => {
|
|
977
1020
|
let { isAtBottom: n, scrollToBottom: r } = kt(), i = o(() => {
|
|
978
1021
|
r();
|
|
979
1022
|
}, [r]);
|
|
@@ -986,23 +1029,23 @@ var nr = ({ className: e, ...t }) => /* @__PURE__ */ Z(Ot, {
|
|
|
986
1029
|
...t,
|
|
987
1030
|
children: /* @__PURE__ */ Z(Me, { className: "size-4" })
|
|
988
1031
|
});
|
|
989
|
-
},
|
|
1032
|
+
}, hr = At("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
|
|
990
1033
|
variants: { orientation: {
|
|
991
1034
|
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
992
1035
|
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
|
|
993
1036
|
} },
|
|
994
1037
|
defaultVariants: { orientation: "horizontal" }
|
|
995
1038
|
});
|
|
996
|
-
function
|
|
1039
|
+
function gr({ className: e, orientation: t, ...n }) {
|
|
997
1040
|
return /* @__PURE__ */ Z("div", {
|
|
998
1041
|
role: "group",
|
|
999
1042
|
"data-slot": "button-group",
|
|
1000
1043
|
"data-orientation": t,
|
|
1001
|
-
className: G(
|
|
1044
|
+
className: G(hr({ orientation: t }), e),
|
|
1002
1045
|
...n
|
|
1003
1046
|
});
|
|
1004
1047
|
}
|
|
1005
|
-
function
|
|
1048
|
+
function _r({ className: e, asChild: t = !1, ...n }) {
|
|
1006
1049
|
return /* @__PURE__ */ Z(t ? jt : "div", {
|
|
1007
1050
|
className: G("flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", e),
|
|
1008
1051
|
...n
|
|
@@ -1010,18 +1053,18 @@ function cr({ className: e, asChild: t = !1, ...n }) {
|
|
|
1010
1053
|
}
|
|
1011
1054
|
//#endregion
|
|
1012
1055
|
//#region src/elements/message.tsx
|
|
1013
|
-
var
|
|
1056
|
+
var vr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
1014
1057
|
className: G("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
|
|
1015
1058
|
...n
|
|
1016
|
-
}),
|
|
1059
|
+
}), yr = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
1017
1060
|
className: G("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm", "group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground", "group-[.is-assistant]:text-foreground", t),
|
|
1018
1061
|
...n,
|
|
1019
1062
|
children: e
|
|
1020
|
-
}),
|
|
1063
|
+
}), br = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
1021
1064
|
className: G("flex items-center gap-1", e),
|
|
1022
1065
|
...n,
|
|
1023
1066
|
children: t
|
|
1024
|
-
}),
|
|
1067
|
+
}), xr = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
|
|
1025
1068
|
let o = /* @__PURE__ */ Q(v, {
|
|
1026
1069
|
size: i,
|
|
1027
1070
|
type: "button",
|
|
@@ -1036,11 +1079,11 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1036
1079
|
asChild: !0,
|
|
1037
1080
|
children: o
|
|
1038
1081
|
}), /* @__PURE__ */ Z(Oe, { children: /* @__PURE__ */ Z("p", { children: e }) })] }) }) : o;
|
|
1039
|
-
},
|
|
1040
|
-
let e = s(
|
|
1082
|
+
}, Sr = r(null), Cr = () => {
|
|
1083
|
+
let e = s(Sr);
|
|
1041
1084
|
if (!e) throw Error("MessageBranch components must be used within MessageBranch");
|
|
1042
1085
|
return e;
|
|
1043
|
-
},
|
|
1086
|
+
}, wr = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
|
|
1044
1087
|
let [i, a] = d(e), [o, s] = d([]), c = (e) => {
|
|
1045
1088
|
a(e), t?.(e);
|
|
1046
1089
|
}, l = {
|
|
@@ -1057,15 +1100,15 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1057
1100
|
branches: o,
|
|
1058
1101
|
setBranches: s
|
|
1059
1102
|
};
|
|
1060
|
-
return /* @__PURE__ */ Z(
|
|
1103
|
+
return /* @__PURE__ */ Z(Sr.Provider, {
|
|
1061
1104
|
value: l,
|
|
1062
1105
|
children: /* @__PURE__ */ Z("div", {
|
|
1063
1106
|
className: G("grid w-full gap-2 [&>div]:pb-0", n),
|
|
1064
1107
|
...r
|
|
1065
1108
|
})
|
|
1066
1109
|
});
|
|
1067
|
-
},
|
|
1068
|
-
let { currentBranch: n, setBranches: r, branches: i } =
|
|
1110
|
+
}, Tr = ({ children: e, ...t }) => {
|
|
1111
|
+
let { currentBranch: n, setBranches: r, branches: i } = Cr(), a = Array.isArray(e) ? e : [e];
|
|
1069
1112
|
return c(() => {
|
|
1070
1113
|
i.length !== a.length && r(a);
|
|
1071
1114
|
}, [
|
|
@@ -1077,15 +1120,15 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1077
1120
|
...t,
|
|
1078
1121
|
children: e
|
|
1079
1122
|
}, e.key));
|
|
1080
|
-
},
|
|
1081
|
-
let { totalBranches: r } =
|
|
1082
|
-
return r <= 1 ? null : /* @__PURE__ */ Z(
|
|
1123
|
+
}, Er = ({ className: e, from: t, ...n }) => {
|
|
1124
|
+
let { totalBranches: r } = Cr();
|
|
1125
|
+
return r <= 1 ? null : /* @__PURE__ */ Z(gr, {
|
|
1083
1126
|
className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
|
|
1084
1127
|
orientation: "horizontal",
|
|
1085
1128
|
...n
|
|
1086
1129
|
});
|
|
1087
|
-
},
|
|
1088
|
-
let { goToPrevious: n, totalBranches: r } =
|
|
1130
|
+
}, Dr = ({ children: e, ...t }) => {
|
|
1131
|
+
let { goToPrevious: n, totalBranches: r } = Cr();
|
|
1089
1132
|
return /* @__PURE__ */ Z(v, {
|
|
1090
1133
|
"aria-label": "Previous branch",
|
|
1091
1134
|
disabled: r <= 1,
|
|
@@ -1096,8 +1139,8 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1096
1139
|
...t,
|
|
1097
1140
|
children: e ?? /* @__PURE__ */ Z(Be, { size: 14 })
|
|
1098
1141
|
});
|
|
1099
|
-
},
|
|
1100
|
-
let { goToNext: r, totalBranches: i } =
|
|
1142
|
+
}, Or = ({ children: e, className: t, ...n }) => {
|
|
1143
|
+
let { goToNext: r, totalBranches: i } = Cr();
|
|
1101
1144
|
return /* @__PURE__ */ Z(v, {
|
|
1102
1145
|
"aria-label": "Next branch",
|
|
1103
1146
|
disabled: i <= 1,
|
|
@@ -1108,9 +1151,9 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1108
1151
|
...n,
|
|
1109
1152
|
children: e ?? /* @__PURE__ */ Z(Ve, { size: 14 })
|
|
1110
1153
|
});
|
|
1111
|
-
},
|
|
1112
|
-
let { currentBranch: n, totalBranches: r } =
|
|
1113
|
-
return /* @__PURE__ */ Q(
|
|
1154
|
+
}, kr = ({ className: e, ...t }) => {
|
|
1155
|
+
let { currentBranch: n, totalBranches: r } = Cr();
|
|
1156
|
+
return /* @__PURE__ */ Q(_r, {
|
|
1114
1157
|
className: G("border-none bg-transparent text-muted-foreground shadow-none", e),
|
|
1115
1158
|
...t,
|
|
1116
1159
|
children: [
|
|
@@ -1119,12 +1162,12 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
|
1119
1162
|
r
|
|
1120
1163
|
]
|
|
1121
1164
|
});
|
|
1122
|
-
},
|
|
1165
|
+
}, Ar = a(({ className: e, ...t }) => /* @__PURE__ */ Z(Mt, {
|
|
1123
1166
|
className: G("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
|
|
1124
1167
|
...t
|
|
1125
1168
|
}), (e, t) => e.children === t.children);
|
|
1126
|
-
|
|
1127
|
-
function
|
|
1169
|
+
Ar.displayName = "MessageResponse";
|
|
1170
|
+
function jr({ data: e, className: t, onRemove: n, ...r }) {
|
|
1128
1171
|
let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
1129
1172
|
return /* @__PURE__ */ Z("div", {
|
|
1130
1173
|
className: G("group relative size-24 overflow-hidden rounded-lg", t),
|
|
@@ -1168,21 +1211,21 @@ function Sr({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
1168
1211
|
})] })
|
|
1169
1212
|
});
|
|
1170
1213
|
}
|
|
1171
|
-
function
|
|
1214
|
+
function Mr({ children: e, className: t, ...n }) {
|
|
1172
1215
|
return e ? /* @__PURE__ */ Z("div", {
|
|
1173
1216
|
className: G("ml-auto flex w-fit flex-wrap items-start gap-2", t),
|
|
1174
1217
|
...n,
|
|
1175
1218
|
children: e
|
|
1176
1219
|
}) : null;
|
|
1177
1220
|
}
|
|
1178
|
-
var
|
|
1221
|
+
var Nr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z("div", {
|
|
1179
1222
|
className: G("mt-4 flex w-full items-center justify-between gap-4", e),
|
|
1180
1223
|
...n,
|
|
1181
1224
|
children: t
|
|
1182
1225
|
});
|
|
1183
1226
|
//#endregion
|
|
1184
1227
|
//#region src/elements/ui/input-group.tsx
|
|
1185
|
-
function
|
|
1228
|
+
function Pr({ className: e, ...t }) {
|
|
1186
1229
|
return /* @__PURE__ */ Z("div", {
|
|
1187
1230
|
"data-slot": "input-group",
|
|
1188
1231
|
role: "group",
|
|
@@ -1190,7 +1233,7 @@ function Tr({ className: e, ...t }) {
|
|
|
1190
1233
|
...t
|
|
1191
1234
|
});
|
|
1192
1235
|
}
|
|
1193
|
-
var
|
|
1236
|
+
var Fr = At("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
|
|
1194
1237
|
variants: { align: {
|
|
1195
1238
|
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
1196
1239
|
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
@@ -1199,19 +1242,19 @@ var Er = At("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 te
|
|
|
1199
1242
|
} },
|
|
1200
1243
|
defaultVariants: { align: "inline-start" }
|
|
1201
1244
|
});
|
|
1202
|
-
function
|
|
1245
|
+
function Ir({ className: e, align: t = "inline-start", ...n }) {
|
|
1203
1246
|
return /* @__PURE__ */ Z("div", {
|
|
1204
1247
|
role: "group",
|
|
1205
1248
|
"data-slot": "input-group-addon",
|
|
1206
1249
|
"data-align": t,
|
|
1207
|
-
className: G(
|
|
1250
|
+
className: G(Fr({ align: t }), e),
|
|
1208
1251
|
onClick: (e) => {
|
|
1209
1252
|
e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
1210
1253
|
},
|
|
1211
1254
|
...n
|
|
1212
1255
|
});
|
|
1213
1256
|
}
|
|
1214
|
-
var
|
|
1257
|
+
var Lr = At("flex items-center gap-2 text-sm shadow-none", {
|
|
1215
1258
|
variants: { size: {
|
|
1216
1259
|
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
1217
1260
|
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
@@ -1220,16 +1263,16 @@ var Or = At("flex items-center gap-2 text-sm shadow-none", {
|
|
|
1220
1263
|
} },
|
|
1221
1264
|
defaultVariants: { size: "xs" }
|
|
1222
1265
|
});
|
|
1223
|
-
function
|
|
1266
|
+
function Rr({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
|
|
1224
1267
|
return /* @__PURE__ */ Z(v, {
|
|
1225
1268
|
type: t,
|
|
1226
1269
|
"data-size": r,
|
|
1227
1270
|
variant: n,
|
|
1228
|
-
className: G(
|
|
1271
|
+
className: G(Lr({ size: r }), e),
|
|
1229
1272
|
...i
|
|
1230
1273
|
});
|
|
1231
1274
|
}
|
|
1232
|
-
function
|
|
1275
|
+
function zr({ className: e, ...t }) {
|
|
1233
1276
|
return /* @__PURE__ */ Z(Ee, {
|
|
1234
1277
|
"data-slot": "input-group-control",
|
|
1235
1278
|
className: G("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
|
|
@@ -1238,16 +1281,16 @@ function Ar({ className: e, ...t }) {
|
|
|
1238
1281
|
}
|
|
1239
1282
|
//#endregion
|
|
1240
1283
|
//#region src/elements/prompt-input.tsx
|
|
1241
|
-
var
|
|
1242
|
-
let e = s(
|
|
1284
|
+
var Br = r(null), Vr = r(null), Hr = () => {
|
|
1285
|
+
let e = s(Br);
|
|
1243
1286
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
|
|
1244
1287
|
return e;
|
|
1245
|
-
},
|
|
1246
|
-
let e = s(
|
|
1288
|
+
}, Ur = () => s(Br), Wr = () => {
|
|
1289
|
+
let e = s(Vr);
|
|
1247
1290
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
|
|
1248
1291
|
return e;
|
|
1249
|
-
},
|
|
1250
|
-
function
|
|
1292
|
+
}, Gr = () => s(Vr);
|
|
1293
|
+
function Kr({ initialInput: e = "", children: t }) {
|
|
1251
1294
|
let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
|
|
1252
1295
|
let t = Array.from(e);
|
|
1253
1296
|
t.length !== 0 && s((e) => e.concat(t.map((e) => ({
|
|
@@ -1303,22 +1346,22 @@ function Lr({ initialInput: e = "", children: t }) {
|
|
|
1303
1346
|
y,
|
|
1304
1347
|
b
|
|
1305
1348
|
]);
|
|
1306
|
-
return /* @__PURE__ */ Z(
|
|
1349
|
+
return /* @__PURE__ */ Z(Br.Provider, {
|
|
1307
1350
|
value: x,
|
|
1308
|
-
children: /* @__PURE__ */ Z(
|
|
1351
|
+
children: /* @__PURE__ */ Z(Vr.Provider, {
|
|
1309
1352
|
value: y,
|
|
1310
1353
|
children: t
|
|
1311
1354
|
})
|
|
1312
1355
|
});
|
|
1313
1356
|
}
|
|
1314
|
-
var
|
|
1315
|
-
let e =
|
|
1357
|
+
var qr = r(null), Jr = () => {
|
|
1358
|
+
let e = Gr(), t = s(qr), n = e ?? t;
|
|
1316
1359
|
if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
|
|
1317
1360
|
return n;
|
|
1318
1361
|
};
|
|
1319
|
-
function
|
|
1320
|
-
let r =
|
|
1321
|
-
return /* @__PURE__ */ Q(
|
|
1362
|
+
function Yr({ data: e, className: t, ...n }) {
|
|
1363
|
+
let r = Jr(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
1364
|
+
return /* @__PURE__ */ Q(gi, { children: [/* @__PURE__ */ Z(oe, {
|
|
1322
1365
|
asChild: !0,
|
|
1323
1366
|
children: /* @__PURE__ */ Q("div", {
|
|
1324
1367
|
className: G("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", t),
|
|
@@ -1355,7 +1398,7 @@ function Br({ data: e, className: t, ...n }) {
|
|
|
1355
1398
|
children: o
|
|
1356
1399
|
})]
|
|
1357
1400
|
}, e.id)
|
|
1358
|
-
}), /* @__PURE__ */ Z(
|
|
1401
|
+
}), /* @__PURE__ */ Z(vi, {
|
|
1359
1402
|
className: "w-auto p-2",
|
|
1360
1403
|
children: /* @__PURE__ */ Q("div", {
|
|
1361
1404
|
className: "w-auto space-y-3",
|
|
@@ -1384,16 +1427,16 @@ function Br({ data: e, className: t, ...n }) {
|
|
|
1384
1427
|
})
|
|
1385
1428
|
})] });
|
|
1386
1429
|
}
|
|
1387
|
-
function
|
|
1388
|
-
let i =
|
|
1430
|
+
function Xr({ children: e, className: t, ...r }) {
|
|
1431
|
+
let i = Jr();
|
|
1389
1432
|
return i.files.length ? /* @__PURE__ */ Z("div", {
|
|
1390
1433
|
className: G("flex flex-wrap items-center gap-2 p-3 w-full", t),
|
|
1391
1434
|
...r,
|
|
1392
1435
|
children: i.files.map((t) => /* @__PURE__ */ Z(n, { children: e(t) }, t.id))
|
|
1393
1436
|
}) : null;
|
|
1394
1437
|
}
|
|
1395
|
-
var
|
|
1396
|
-
let n =
|
|
1438
|
+
var Zr = ({ label: e = "Add photos or files", ...t }) => {
|
|
1439
|
+
let n = Jr();
|
|
1397
1440
|
return /* @__PURE__ */ Q(F, {
|
|
1398
1441
|
...t,
|
|
1399
1442
|
onSelect: (e) => {
|
|
@@ -1405,8 +1448,8 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1405
1448
|
e
|
|
1406
1449
|
]
|
|
1407
1450
|
});
|
|
1408
|
-
},
|
|
1409
|
-
let _ =
|
|
1451
|
+
}, Qr = ({ className: e, accept: t, multiple: n, fileInputLabel: r = "Upload files", globalDrop: i, syncHiddenInput: a, maxFiles: s, maxFileSize: f, onError: p, onSubmit: m, children: h, ...g }) => {
|
|
1452
|
+
let _ = Ur(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
|
|
1410
1453
|
w.current = C;
|
|
1411
1454
|
let T = o(() => {
|
|
1412
1455
|
y.current?.click();
|
|
@@ -1555,20 +1598,20 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1555
1598
|
},
|
|
1556
1599
|
ref: b,
|
|
1557
1600
|
...g,
|
|
1558
|
-
children: /* @__PURE__ */ Z(
|
|
1601
|
+
children: /* @__PURE__ */ Z(Pr, {
|
|
1559
1602
|
className: "overflow-hidden",
|
|
1560
1603
|
children: h
|
|
1561
1604
|
})
|
|
1562
1605
|
})] });
|
|
1563
|
-
return v ? I : /* @__PURE__ */ Z(
|
|
1606
|
+
return v ? I : /* @__PURE__ */ Z(qr.Provider, {
|
|
1564
1607
|
value: F,
|
|
1565
1608
|
children: I
|
|
1566
1609
|
});
|
|
1567
|
-
},
|
|
1610
|
+
}, $r = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1568
1611
|
className: G("contents", e),
|
|
1569
1612
|
...t
|
|
1570
|
-
}),
|
|
1571
|
-
let i =
|
|
1613
|
+
}), ei = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
|
|
1614
|
+
let i = Ur(), a = Jr(), [o, s] = d(!1), c = (e) => {
|
|
1572
1615
|
if (e.key === "Enter") {
|
|
1573
1616
|
if (o || e.nativeEvent.isComposing || e.shiftKey) return;
|
|
1574
1617
|
e.preventDefault();
|
|
@@ -1596,7 +1639,7 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1596
1639
|
i.textInput.setInput(t.currentTarget.value), e?.(t);
|
|
1597
1640
|
}
|
|
1598
1641
|
} : { onChange: e };
|
|
1599
|
-
return /* @__PURE__ */ Z(
|
|
1642
|
+
return /* @__PURE__ */ Z(zr, {
|
|
1600
1643
|
className: G("field-sizing-content max-h-48 min-h-16", t),
|
|
1601
1644
|
name: "message",
|
|
1602
1645
|
onCompositionEnd: () => s(!1),
|
|
@@ -1607,43 +1650,43 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1607
1650
|
...r,
|
|
1608
1651
|
...u
|
|
1609
1652
|
});
|
|
1610
|
-
},
|
|
1653
|
+
}, ti = ({ className: e, ...t }) => /* @__PURE__ */ Z(Ir, {
|
|
1611
1654
|
align: "block-end",
|
|
1612
1655
|
className: G("order-first flex-wrap gap-1", e),
|
|
1613
1656
|
...t
|
|
1614
|
-
}),
|
|
1657
|
+
}), ni = ({ className: e, ...t }) => /* @__PURE__ */ Z(Ir, {
|
|
1615
1658
|
align: "block-end",
|
|
1616
1659
|
className: G("justify-between gap-1", e),
|
|
1617
1660
|
...t
|
|
1618
|
-
}),
|
|
1661
|
+
}), ri = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1619
1662
|
className: G("flex items-center gap-1", e),
|
|
1620
1663
|
...t
|
|
1621
|
-
}),
|
|
1664
|
+
}), ii = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
|
|
1622
1665
|
let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
|
|
1623
|
-
return /* @__PURE__ */ Z(
|
|
1666
|
+
return /* @__PURE__ */ Z(Rr, {
|
|
1624
1667
|
className: G(n),
|
|
1625
1668
|
size: a,
|
|
1626
1669
|
type: "button",
|
|
1627
1670
|
variant: e,
|
|
1628
1671
|
...i
|
|
1629
1672
|
});
|
|
1630
|
-
},
|
|
1673
|
+
}, ai = (e) => /* @__PURE__ */ Z(ee, { ...e }), oi = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z(I, {
|
|
1631
1674
|
asChild: !0,
|
|
1632
|
-
children: /* @__PURE__ */ Z(
|
|
1675
|
+
children: /* @__PURE__ */ Z(ii, {
|
|
1633
1676
|
className: e,
|
|
1634
1677
|
...n,
|
|
1635
1678
|
children: t ?? /* @__PURE__ */ Z(ct, { className: "size-4" })
|
|
1636
1679
|
})
|
|
1637
|
-
}),
|
|
1680
|
+
}), si = ({ className: e, ...t }) => /* @__PURE__ */ Z(P, {
|
|
1638
1681
|
align: "start",
|
|
1639
1682
|
className: G(e),
|
|
1640
1683
|
...t
|
|
1641
|
-
}),
|
|
1684
|
+
}), ci = ({ className: e, ...t }) => /* @__PURE__ */ Z(F, {
|
|
1642
1685
|
className: G(e),
|
|
1643
1686
|
...t
|
|
1644
|
-
}),
|
|
1687
|
+
}), li = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
|
|
1645
1688
|
let o = /* @__PURE__ */ Z(J, { className: "size-4" });
|
|
1646
|
-
return r === "submitted" ? o = /* @__PURE__ */ Z(rt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Z(mt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Z(xt, { className: "size-4" })), /* @__PURE__ */ Z(
|
|
1689
|
+
return r === "submitted" ? o = /* @__PURE__ */ Z(rt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Z(mt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Z(xt, { className: "size-4" })), /* @__PURE__ */ Z(Rr, {
|
|
1647
1690
|
"aria-label": "Submit",
|
|
1648
1691
|
className: G(e),
|
|
1649
1692
|
size: n,
|
|
@@ -1652,7 +1695,7 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1652
1695
|
...a,
|
|
1653
1696
|
children: i ?? o
|
|
1654
1697
|
});
|
|
1655
|
-
},
|
|
1698
|
+
}, ui = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
|
|
1656
1699
|
let [i, a] = d(!1), [s, l] = d(null), f = u(null);
|
|
1657
1700
|
c(() => {
|
|
1658
1701
|
if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
|
|
@@ -1682,69 +1725,69 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1682
1725
|
let p = o(() => {
|
|
1683
1726
|
s && (i ? s.stop() : s.start());
|
|
1684
1727
|
}, [s, i]);
|
|
1685
|
-
return /* @__PURE__ */ Z(
|
|
1728
|
+
return /* @__PURE__ */ Z(ii, {
|
|
1686
1729
|
className: G("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
|
|
1687
1730
|
disabled: !s,
|
|
1688
1731
|
onClick: p,
|
|
1689
1732
|
...r,
|
|
1690
1733
|
children: /* @__PURE__ */ Z(at, { className: "size-4" })
|
|
1691
1734
|
});
|
|
1692
|
-
},
|
|
1735
|
+
}, di = (e) => /* @__PURE__ */ Z(se, { ...e }), fi = ({ className: e, ...t }) => /* @__PURE__ */ Z(ue, {
|
|
1693
1736
|
className: G("border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors", "hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground", e),
|
|
1694
1737
|
...t
|
|
1695
|
-
}),
|
|
1738
|
+
}), pi = ({ className: e, ...t }) => /* @__PURE__ */ Z(ce, {
|
|
1696
1739
|
className: G(e),
|
|
1697
1740
|
...t
|
|
1698
|
-
}),
|
|
1741
|
+
}), mi = ({ className: e, ...t }) => /* @__PURE__ */ Z(le, {
|
|
1699
1742
|
className: G(e),
|
|
1700
1743
|
...t
|
|
1701
|
-
}),
|
|
1744
|
+
}), hi = ({ className: e, ...t }) => /* @__PURE__ */ Z(de, {
|
|
1702
1745
|
className: G(e),
|
|
1703
1746
|
...t
|
|
1704
|
-
}),
|
|
1747
|
+
}), gi = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Z(R, {
|
|
1705
1748
|
closeDelay: t,
|
|
1706
1749
|
openDelay: e,
|
|
1707
1750
|
...n
|
|
1708
|
-
}),
|
|
1751
|
+
}), _i = (e) => /* @__PURE__ */ Z(oe, { ...e }), vi = ({ align: e = "start", ...t }) => /* @__PURE__ */ Z(ae, {
|
|
1709
1752
|
align: e,
|
|
1710
1753
|
...t
|
|
1711
|
-
}),
|
|
1754
|
+
}), yi = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1712
1755
|
className: G(e),
|
|
1713
1756
|
...t
|
|
1714
|
-
}),
|
|
1757
|
+
}), bi = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1715
1758
|
className: G(e),
|
|
1716
1759
|
...t
|
|
1717
|
-
}),
|
|
1760
|
+
}), xi = ({ className: e, ...t }) => /* @__PURE__ */ Z("h3", {
|
|
1718
1761
|
className: G("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
|
|
1719
1762
|
...t
|
|
1720
|
-
}),
|
|
1763
|
+
}), Si = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1721
1764
|
className: G("space-y-1", e),
|
|
1722
1765
|
...t
|
|
1723
|
-
}),
|
|
1766
|
+
}), Ci = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
|
|
1724
1767
|
className: G("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
|
|
1725
1768
|
...t
|
|
1726
|
-
}),
|
|
1769
|
+
}), wi = ({ className: e, ...t }) => /* @__PURE__ */ Z(D, {
|
|
1727
1770
|
className: G(e),
|
|
1728
1771
|
...t
|
|
1729
|
-
}),
|
|
1772
|
+
}), Ti = ({ className: e, ...t }) => /* @__PURE__ */ Z(A, {
|
|
1730
1773
|
className: G(e),
|
|
1731
1774
|
...t
|
|
1732
|
-
}),
|
|
1775
|
+
}), Ei = ({ className: e, ...t }) => /* @__PURE__ */ Z(M, {
|
|
1733
1776
|
className: G(e),
|
|
1734
1777
|
...t
|
|
1735
|
-
}),
|
|
1778
|
+
}), Di = ({ className: e, ...t }) => /* @__PURE__ */ Z(O, {
|
|
1736
1779
|
className: G(e),
|
|
1737
1780
|
...t
|
|
1738
|
-
}),
|
|
1781
|
+
}), Oi = ({ className: e, ...t }) => /* @__PURE__ */ Z(k, {
|
|
1739
1782
|
className: G(e),
|
|
1740
1783
|
...t
|
|
1741
|
-
}),
|
|
1784
|
+
}), ki = ({ className: e, ...t }) => /* @__PURE__ */ Z(j, {
|
|
1742
1785
|
className: G(e),
|
|
1743
1786
|
...t
|
|
1744
|
-
}),
|
|
1787
|
+
}), Ai = ({ className: e, ...t }) => /* @__PURE__ */ Z(N, {
|
|
1745
1788
|
className: G(e),
|
|
1746
1789
|
...t
|
|
1747
|
-
}),
|
|
1790
|
+
}), ji = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(V, {
|
|
1748
1791
|
className: "w-full overflow-x-auto whitespace-nowrap",
|
|
1749
1792
|
...n,
|
|
1750
1793
|
children: [/* @__PURE__ */ Z("div", {
|
|
@@ -1754,7 +1797,7 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1754
1797
|
className: "hidden",
|
|
1755
1798
|
orientation: "horizontal"
|
|
1756
1799
|
})]
|
|
1757
|
-
}),
|
|
1800
|
+
}), Mi = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Z(v, {
|
|
1758
1801
|
className: G("cursor-pointer rounded-full px-4", n),
|
|
1759
1802
|
onClick: () => {
|
|
1760
1803
|
t?.(e);
|
|
@@ -1764,7 +1807,7 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1764
1807
|
variant: r,
|
|
1765
1808
|
...o,
|
|
1766
1809
|
children: a || e
|
|
1767
|
-
}),
|
|
1810
|
+
}), Ni = r({ code: "" }), Pi = {
|
|
1768
1811
|
name: "line-numbers",
|
|
1769
1812
|
line(e, t) {
|
|
1770
1813
|
e.children.unshift({
|
|
@@ -1785,8 +1828,8 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1785
1828
|
});
|
|
1786
1829
|
}
|
|
1787
1830
|
};
|
|
1788
|
-
async function
|
|
1789
|
-
let r = n ? [
|
|
1831
|
+
async function Fi(e, t, n = !1) {
|
|
1832
|
+
let r = n ? [Pi] : [];
|
|
1790
1833
|
return await Promise.all([Pt(e, {
|
|
1791
1834
|
lang: t,
|
|
1792
1835
|
theme: "one-light",
|
|
@@ -1797,9 +1840,9 @@ async function Ei(e, t, n = !1) {
|
|
|
1797
1840
|
transformers: r
|
|
1798
1841
|
})]);
|
|
1799
1842
|
}
|
|
1800
|
-
var
|
|
1843
|
+
var Ii = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
|
|
1801
1844
|
let [o, s] = d(""), [l, f] = d(""), p = u(!1);
|
|
1802
|
-
return c(() => (
|
|
1845
|
+
return c(() => (Fi(e, t, n).then(([e, t]) => {
|
|
1803
1846
|
p.current ||= (s(e), f(t), !0);
|
|
1804
1847
|
}), () => {
|
|
1805
1848
|
p.current = !1;
|
|
@@ -1807,7 +1850,7 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1807
1850
|
e,
|
|
1808
1851
|
t,
|
|
1809
1852
|
n
|
|
1810
|
-
]), /* @__PURE__ */ Z(
|
|
1853
|
+
]), /* @__PURE__ */ Z(Ni.Provider, {
|
|
1811
1854
|
value: { code: e },
|
|
1812
1855
|
children: /* @__PURE__ */ Z("div", {
|
|
1813
1856
|
className: G("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
|
|
@@ -1831,8 +1874,8 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1831
1874
|
})
|
|
1832
1875
|
})
|
|
1833
1876
|
});
|
|
1834
|
-
},
|
|
1835
|
-
let [o, c] = d(!1), { code: l } = s(
|
|
1877
|
+
}, Li = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
|
|
1878
|
+
let [o, c] = d(!1), { code: l } = s(Ni), u = async () => {
|
|
1836
1879
|
if (typeof window > "u" || !navigator?.clipboard?.writeText) {
|
|
1837
1880
|
t?.(/* @__PURE__ */ Error("Clipboard API not available"));
|
|
1838
1881
|
return;
|
|
@@ -1851,10 +1894,10 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1851
1894
|
...a,
|
|
1852
1895
|
children: r ?? /* @__PURE__ */ Z(f, { size: 14 })
|
|
1853
1896
|
});
|
|
1854
|
-
},
|
|
1897
|
+
}, Ri = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
|
|
1855
1898
|
className: G("not-prose mb-4 w-full rounded-md border", e),
|
|
1856
1899
|
...t
|
|
1857
|
-
}),
|
|
1900
|
+
}), zi = (e) => /* @__PURE__ */ Q(_, {
|
|
1858
1901
|
className: "gap-1.5 rounded-full text-xs",
|
|
1859
1902
|
variant: "secondary",
|
|
1860
1903
|
children: [{
|
|
@@ -1874,7 +1917,7 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1874
1917
|
"output-error": "Error",
|
|
1875
1918
|
"output-denied": "Denied"
|
|
1876
1919
|
}[e]]
|
|
1877
|
-
}),
|
|
1920
|
+
}), Bi = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ Q(E, {
|
|
1878
1921
|
className: G("flex w-full items-center justify-between gap-4 p-3", e),
|
|
1879
1922
|
...i,
|
|
1880
1923
|
children: [/* @__PURE__ */ Q("div", {
|
|
@@ -1885,13 +1928,13 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1885
1928
|
className: "font-medium text-sm",
|
|
1886
1929
|
children: t ?? n.split("-").slice(1).join("-")
|
|
1887
1930
|
}),
|
|
1888
|
-
|
|
1931
|
+
zi(r)
|
|
1889
1932
|
]
|
|
1890
1933
|
}), /* @__PURE__ */ Z(ze, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
|
|
1891
|
-
}),
|
|
1934
|
+
}), Vi = ({ className: e, ...t }) => /* @__PURE__ */ Z(T, {
|
|
1892
1935
|
className: G("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
1893
1936
|
...t
|
|
1894
|
-
}),
|
|
1937
|
+
}), Hi = ({ className: e, input: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
1895
1938
|
className: G("space-y-2 overflow-hidden p-4", e),
|
|
1896
1939
|
...n,
|
|
1897
1940
|
children: [/* @__PURE__ */ Z("h4", {
|
|
@@ -1899,18 +1942,18 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1899
1942
|
children: "Parameters"
|
|
1900
1943
|
}), /* @__PURE__ */ Z("div", {
|
|
1901
1944
|
className: "rounded-md bg-muted/50",
|
|
1902
|
-
children: /* @__PURE__ */ Z(
|
|
1945
|
+
children: /* @__PURE__ */ Z(Ii, {
|
|
1903
1946
|
code: JSON.stringify(t, null, 2),
|
|
1904
1947
|
language: "json"
|
|
1905
1948
|
})
|
|
1906
1949
|
})]
|
|
1907
|
-
}),
|
|
1950
|
+
}), Ui = ({ className: e, output: t, errorText: n, ...r }) => {
|
|
1908
1951
|
if (!(t || n)) return null;
|
|
1909
1952
|
let a = /* @__PURE__ */ Z("div", { children: t });
|
|
1910
|
-
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Z(
|
|
1953
|
+
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Z(Ii, {
|
|
1911
1954
|
code: JSON.stringify(t, null, 2),
|
|
1912
1955
|
language: "json"
|
|
1913
|
-
}) : typeof t == "string" && (a = /* @__PURE__ */ Z(
|
|
1956
|
+
}) : typeof t == "string" && (a = /* @__PURE__ */ Z(Ii, {
|
|
1914
1957
|
code: t,
|
|
1915
1958
|
language: "json"
|
|
1916
1959
|
})), /* @__PURE__ */ Q("div", {
|
|
@@ -1924,7 +1967,7 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1924
1967
|
children: [n && /* @__PURE__ */ Z("div", { children: n }), a]
|
|
1925
1968
|
})]
|
|
1926
1969
|
});
|
|
1927
|
-
},
|
|
1970
|
+
}, Wi = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
|
|
1928
1971
|
let a = l(() => It.create(t), [t]), o = l(() => (e?.length ?? 0) * i, [e, i]);
|
|
1929
1972
|
return /* @__PURE__ */ Z(a, {
|
|
1930
1973
|
animate: { backgroundPosition: "0% center" },
|
|
@@ -1941,11 +1984,11 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1941
1984
|
},
|
|
1942
1985
|
children: e
|
|
1943
1986
|
});
|
|
1944
|
-
}),
|
|
1945
|
-
let e = s(
|
|
1987
|
+
}), Gi = r(null), Ki = () => {
|
|
1988
|
+
let e = s(Gi);
|
|
1946
1989
|
if (!e) throw Error("Reasoning components must be used within Reasoning");
|
|
1947
1990
|
return e;
|
|
1948
|
-
},
|
|
1991
|
+
}, qi = 1e3, Ji = 1e3, Yi = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
|
|
1949
1992
|
let [l, u] = Ft({
|
|
1950
1993
|
prop: n,
|
|
1951
1994
|
defaultProp: r,
|
|
@@ -1955,7 +1998,7 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1955
1998
|
defaultProp: void 0
|
|
1956
1999
|
}), [m, h] = d(!1), [g, _] = d(null);
|
|
1957
2000
|
return c(() => {
|
|
1958
|
-
t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) /
|
|
2001
|
+
t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / Ji)), _(null));
|
|
1959
2002
|
}, [
|
|
1960
2003
|
t,
|
|
1961
2004
|
g,
|
|
@@ -1964,7 +2007,7 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1964
2007
|
if (r && !t && l && !m) {
|
|
1965
2008
|
let e = setTimeout(() => {
|
|
1966
2009
|
u(!1), h(!0);
|
|
1967
|
-
},
|
|
2010
|
+
}, qi);
|
|
1968
2011
|
return () => clearTimeout(e);
|
|
1969
2012
|
}
|
|
1970
2013
|
}, [
|
|
@@ -1973,7 +2016,7 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1973
2016
|
r,
|
|
1974
2017
|
u,
|
|
1975
2018
|
m
|
|
1976
|
-
]), /* @__PURE__ */ Z(
|
|
2019
|
+
]), /* @__PURE__ */ Z(Gi.Provider, {
|
|
1977
2020
|
value: {
|
|
1978
2021
|
isStreaming: t,
|
|
1979
2022
|
isOpen: l,
|
|
@@ -1990,15 +2033,15 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
1990
2033
|
children: o
|
|
1991
2034
|
})
|
|
1992
2035
|
});
|
|
1993
|
-
}),
|
|
2036
|
+
}), Xi = (e, t) => e || t === 0 ? /* @__PURE__ */ Z(Wi, {
|
|
1994
2037
|
duration: 1,
|
|
1995
2038
|
children: "Thinking..."
|
|
1996
2039
|
}) : t === void 0 ? /* @__PURE__ */ Z("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ Q("p", { children: [
|
|
1997
2040
|
"Thought for ",
|
|
1998
2041
|
t,
|
|
1999
2042
|
" seconds"
|
|
2000
|
-
] }),
|
|
2001
|
-
let { isStreaming: i, isOpen: a, duration: o } =
|
|
2043
|
+
] }), Zi = a(({ className: e, children: t, getThinkingMessage: n = Xi, ...r }) => {
|
|
2044
|
+
let { isStreaming: i, isOpen: a, duration: o } = Ki();
|
|
2002
2045
|
return /* @__PURE__ */ Z(E, {
|
|
2003
2046
|
className: G("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
|
|
2004
2047
|
...r,
|
|
@@ -2008,18 +2051,18 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
|
|
|
2008
2051
|
/* @__PURE__ */ Z(ze, { className: G("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
|
|
2009
2052
|
] })
|
|
2010
2053
|
});
|
|
2011
|
-
}),
|
|
2054
|
+
}), Qi = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Z(T, {
|
|
2012
2055
|
className: G("mt-4 text-sm", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
2013
2056
|
...n,
|
|
2014
2057
|
children: /* @__PURE__ */ Z(Mt, { children: t })
|
|
2015
2058
|
}));
|
|
2016
|
-
|
|
2059
|
+
Yi.displayName = "Reasoning", Zi.displayName = "ReasoningTrigger", Qi.displayName = "ReasoningContent";
|
|
2017
2060
|
//#endregion
|
|
2018
2061
|
//#region src/elements/sources.tsx
|
|
2019
|
-
var
|
|
2062
|
+
var $i = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
|
|
2020
2063
|
className: G("not-prose mb-4 text-primary text-xs", e),
|
|
2021
2064
|
...t
|
|
2022
|
-
}),
|
|
2065
|
+
}), ea = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Z(E, {
|
|
2023
2066
|
className: G("flex items-center gap-2", e),
|
|
2024
2067
|
...r,
|
|
2025
2068
|
children: n ?? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Q("p", {
|
|
@@ -2030,10 +2073,10 @@ var Wi = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
|
|
|
2030
2073
|
" sources"
|
|
2031
2074
|
]
|
|
2032
2075
|
}), /* @__PURE__ */ Z(ze, { className: "h-4 w-4" })] })
|
|
2033
|
-
}),
|
|
2076
|
+
}), ta = ({ className: e, ...t }) => /* @__PURE__ */ Z(T, {
|
|
2034
2077
|
className: G("mt-3 flex w-fit flex-col gap-2", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
2035
2078
|
...t
|
|
2036
|
-
}),
|
|
2079
|
+
}), na = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Z("a", {
|
|
2037
2080
|
className: "flex items-center gap-2",
|
|
2038
2081
|
href: e,
|
|
2039
2082
|
rel: "noreferrer",
|
|
@@ -2046,7 +2089,7 @@ var Wi = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
|
|
|
2046
2089
|
});
|
|
2047
2090
|
//#endregion
|
|
2048
2091
|
//#region src/ChatbotEnhanced.tsx
|
|
2049
|
-
function
|
|
2092
|
+
function ra(e) {
|
|
2050
2093
|
let t = e ?? {}, n = t.data && typeof t.data == "object" ? t.data : t, r = n.seedApplied, i = n.probes;
|
|
2051
2094
|
if (!r && !i) return;
|
|
2052
2095
|
let a = {};
|
|
@@ -2060,10 +2103,10 @@ function Ji(e) {
|
|
|
2060
2103
|
message: String(e.message)
|
|
2061
2104
|
}))), a;
|
|
2062
2105
|
}
|
|
2063
|
-
function
|
|
2106
|
+
function ia(e) {
|
|
2064
2107
|
return e === "user" ? "user" : "assistant";
|
|
2065
2108
|
}
|
|
2066
|
-
function
|
|
2109
|
+
function aa(e) {
|
|
2067
2110
|
let t = e.trim();
|
|
2068
2111
|
if (t.length < 2 || !(t.startsWith("{") || t.startsWith("[")) || !(t.endsWith("}") || t.endsWith("]"))) return !1;
|
|
2069
2112
|
try {
|
|
@@ -2072,15 +2115,15 @@ function Xi(e) {
|
|
|
2072
2115
|
return !1;
|
|
2073
2116
|
}
|
|
2074
2117
|
}
|
|
2075
|
-
function
|
|
2076
|
-
let t =
|
|
2118
|
+
function oa(e) {
|
|
2119
|
+
let t = Wt(e)?.status;
|
|
2077
2120
|
return t === "changes_proposed" || t === "blueprint_proposed" || t === "awaiting_confirmation";
|
|
2078
2121
|
}
|
|
2079
|
-
function
|
|
2122
|
+
function sa(e) {
|
|
2080
2123
|
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available");
|
|
2081
|
-
return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ?
|
|
2124
|
+
return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? oa(e.result) ? "awaiting" : "completed" : "running";
|
|
2082
2125
|
}
|
|
2083
|
-
var
|
|
2126
|
+
var ca = {
|
|
2084
2127
|
create_object: "Create object",
|
|
2085
2128
|
add_field: "Add field",
|
|
2086
2129
|
modify_field: "Modify field",
|
|
@@ -2090,20 +2133,20 @@ var $i = {
|
|
|
2090
2133
|
create_seed: "Generate sample data",
|
|
2091
2134
|
create_package: "Create app package"
|
|
2092
2135
|
};
|
|
2093
|
-
function
|
|
2136
|
+
function la(e, t = ca) {
|
|
2094
2137
|
return [
|
|
2095
|
-
t[e.verb] ??
|
|
2138
|
+
t[e.verb] ?? ca[e.verb] ?? e.verb,
|
|
2096
2139
|
`${e.field ? `${e.object ? `${e.object}.` : ""}${e.field}` : e.object ?? e.name ?? ""}${e.type ? ` (${e.type})` : ""}`,
|
|
2097
2140
|
e.details
|
|
2098
2141
|
].filter(Boolean).join(" ");
|
|
2099
2142
|
}
|
|
2100
|
-
function
|
|
2143
|
+
function ua(e) {
|
|
2101
2144
|
return e.toolName === "propose_blueprint";
|
|
2102
2145
|
}
|
|
2103
|
-
function
|
|
2104
|
-
return
|
|
2146
|
+
function da(e) {
|
|
2147
|
+
return ua(e) && sa(e) === "completed" && !e.proposedPlan && !e.proposedChanges && !e.draftReview?.items.length;
|
|
2105
2148
|
}
|
|
2106
|
-
var
|
|
2149
|
+
var fa = [
|
|
2107
2150
|
"待补",
|
|
2108
2151
|
"后续",
|
|
2109
2152
|
"将在",
|
|
@@ -2129,25 +2172,25 @@ var ra = [
|
|
|
2129
2172
|
"coming soon",
|
|
2130
2173
|
"tbd"
|
|
2131
2174
|
];
|
|
2132
|
-
function
|
|
2175
|
+
function pa(e) {
|
|
2133
2176
|
let t = [], n = [];
|
|
2134
2177
|
for (let r of e) {
|
|
2135
2178
|
if (typeof r != "string") continue;
|
|
2136
2179
|
let e = r.trim();
|
|
2137
2180
|
if (!e) continue;
|
|
2138
2181
|
let i = e.toLowerCase();
|
|
2139
|
-
|
|
2182
|
+
fa.some((e) => i.includes(e)) ? n.push(e) : t.push(e);
|
|
2140
2183
|
}
|
|
2141
2184
|
return {
|
|
2142
2185
|
designNotes: t,
|
|
2143
2186
|
deferred: n
|
|
2144
2187
|
};
|
|
2145
2188
|
}
|
|
2146
|
-
function
|
|
2147
|
-
let t =
|
|
2148
|
-
return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff ||
|
|
2189
|
+
function ma(e) {
|
|
2190
|
+
let t = sa(e);
|
|
2191
|
+
return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff || da(e);
|
|
2149
2192
|
}
|
|
2150
|
-
function
|
|
2193
|
+
function ha(e) {
|
|
2151
2194
|
switch (e) {
|
|
2152
2195
|
case "failed": return 4;
|
|
2153
2196
|
case "awaiting": return 3;
|
|
@@ -2155,20 +2198,20 @@ function oa(e) {
|
|
|
2155
2198
|
case "completed": return 1;
|
|
2156
2199
|
}
|
|
2157
2200
|
}
|
|
2158
|
-
function
|
|
2201
|
+
function ga(e) {
|
|
2159
2202
|
return /^\((?:called [^)]*|tool call|no content)\)$/.test(e.trim());
|
|
2160
2203
|
}
|
|
2161
|
-
function
|
|
2204
|
+
function _a(e) {
|
|
2162
2205
|
let t = /* @__PURE__ */ new Map();
|
|
2163
2206
|
for (let n of e) {
|
|
2164
|
-
let e =
|
|
2207
|
+
let e = sa(n), r = `${n.toolName}:${e}`, i = t.get(r);
|
|
2165
2208
|
if (i) {
|
|
2166
2209
|
i.count += 1, i.errorText = i.errorText ?? n.errorText;
|
|
2167
2210
|
continue;
|
|
2168
2211
|
}
|
|
2169
2212
|
t.set(r, {
|
|
2170
2213
|
key: r,
|
|
2171
|
-
title:
|
|
2214
|
+
title: tr(n.toolName) || n.toolName,
|
|
2172
2215
|
rawName: n.toolName,
|
|
2173
2216
|
count: 1,
|
|
2174
2217
|
state: e,
|
|
@@ -2176,11 +2219,11 @@ function ca(e) {
|
|
|
2176
2219
|
});
|
|
2177
2220
|
}
|
|
2178
2221
|
return Array.from(t.values()).sort((e, t) => {
|
|
2179
|
-
let n =
|
|
2222
|
+
let n = ha(t.state) - ha(e.state);
|
|
2180
2223
|
return n === 0 ? e.title.localeCompare(t.title) : n;
|
|
2181
2224
|
});
|
|
2182
2225
|
}
|
|
2183
|
-
function
|
|
2226
|
+
function va({ health: e }) {
|
|
2184
2227
|
if (!e) return null;
|
|
2185
2228
|
let t = e.issues ?? [], n = t.filter((e) => e.severity === "error"), r = t.filter((e) => e.severity !== "error"), i = e.checked, a = !!i && i.seeds + i.views + i.widgets > 0, o = [];
|
|
2186
2229
|
if (typeof e.seededRows == "number" && e.seededRows > 0 && !e.seedError && o.push(`${e.seededRows} sample row${e.seededRows === 1 ? "" : "s"} live`), a && n.length === 0) {
|
|
@@ -2210,7 +2253,7 @@ function la({ health: e }) {
|
|
|
2210
2253
|
]
|
|
2211
2254
|
});
|
|
2212
2255
|
}
|
|
2213
|
-
var
|
|
2256
|
+
var ya = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, onUpgrade: c, disabled: l = !1, readOnly: u = !1, isLoading: d = !1, error: f, showTimestamp: p = !1, showAvatars: m = !1, userAvatarUrl: h, userAvatarFallback: g = "You", assistantAvatarUrl: _, assistantAvatarFallback: v = "AI", hideClearBar: y = !1, maxHeight: b = "500px", enableMarkdown: x = !0, enableFileUpload: S = !1, acceptedFileTypes: C = "image/*,.pdf,.doc,.docx,.txt,.csv,.tsv,.xlsx,.xlsm", maxFileSize: w = 10485760, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: ee = "Approve", toolDenyLabel: P = "Deny", toolDenyReason: F = "User denied the operation", toolDecisions: I, onReviewDraft: te, toolReviewLabel: ne = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: L, onOpenBuiltApp: re, openBuiltAppLabel: ie = "Open app", onDesignBuiltApp: R, designBuiltAppLabel: ae = "Design in Studio", getArtifactAction: oe, onPreviewDraftApp: z, previewDraftLabel: B = "Preview", onDraftArtifacts: V, onBuildMaterialized: H, publishDraftsLabel: se = "Publish", publishedLabel: ce = "Published", verifiedLabel: le = "Verified", nextStepsLabel: ue = "What's next", planTitleLabel: de = "Proposed plan", builderHandoffTitleLabel: fe = "Build this in the Builder", builderHandoffOpenLabel: pe = "Open in Builder →", builderHandoffSupersededTitle: me = "A newer request is available", onOpenBuilder: he, planExtendLabel: ge = "Adding to existing app", planQuestionsLabel: _e = "Confirm before building", planAssumptionsLabel: ve = "Assumptions", planDeferredLabel: ye = "Not yet built", planApproveHintLabel: be = "Reply to approve or adjust this plan.", planApproveLabel: U = "Build it", planAdjustLabel: W = "Adjust", planBuiltLabel: xe = "Built", planBuildingLabel: Se = "Building…", planReadyLabel: Ce = "The plan is ready. Build it now, or tell me what to adjust.", planApproveMessage: we = "Looks good — build it as proposed.", planApproveDefaultsMessage: Te = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: Ee = (e, t) => `For "${e}", go with: ${t}.`, changesTitleLabel: De = "Confirm changes", changesConfirmedLabel: Oe = "Confirmed", changesConfirmLabel: ke = "Confirm", changesConfirmHintLabel: Ae = "Reply to confirm or adjust this change.", changesConfirmMessage: Me = "Confirm — apply the change you just proposed.", changeVerbLabels: Ne = ca, fetchPendingDraftCount: Pe, autoPublishDrafts: Ie = !1, processVisibility: q = "summary", surface: Re = "card", ...ze }, Be) => {
|
|
2214
2257
|
let Ve = d ? "streaming" : "ready", He = Re === "plain", [We, Ge] = e.useState(null), Ke = e.useRef(""), Je = e.useRef(null), J = e.useMemo(() => ({
|
|
2215
2258
|
emptyTitle: E?.emptyTitle ?? "Start a conversation",
|
|
2216
2259
|
emptyDescription: E?.emptyDescription ?? "Ask anything — the assistant has access to your current app context.",
|
|
@@ -2237,7 +2280,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2237
2280
|
connectionStalledLabel: E?.connectionStalledLabel ?? "Still working…",
|
|
2238
2281
|
connectionOfflineLabel: E?.connectionOfflineLabel ?? "Connection lost — reconnecting…",
|
|
2239
2282
|
designingPlanLabel: E?.designingPlanLabel ?? "Designing your app…",
|
|
2240
|
-
designingPlanHints: E?.designingPlanHints ??
|
|
2283
|
+
designingPlanHints: E?.designingPlanHints ?? Oa
|
|
2241
2284
|
}), [E]), [et, tt] = e.useState(() => /* @__PURE__ */ new Set()), [rt, it] = e.useState(() => /* @__PURE__ */ new Map()), [at, ot] = e.useState(() => /* @__PURE__ */ new Map()), st = e.useRef(/* @__PURE__ */ new Set()), ct = e.useCallback(async (e) => {
|
|
2242
2285
|
if (Pe) try {
|
|
2243
2286
|
let t = await Pe(e);
|
|
@@ -2359,7 +2402,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2359
2402
|
e && (e.focus(), e.scrollIntoView({ block: "nearest" }));
|
|
2360
2403
|
}, []);
|
|
2361
2404
|
e.useEffect(() => {
|
|
2362
|
-
if (!f ||
|
|
2405
|
+
if (!f || !cr(f) || Je.current === f) return;
|
|
2363
2406
|
if (Je.current = f, $.current) {
|
|
2364
2407
|
let e = $.current;
|
|
2365
2408
|
$.current = null, wt((t) => {
|
|
@@ -2377,7 +2420,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2377
2420
|
navigator.clipboard?.writeText(e.content), Ge(e.id), window.setTimeout(() => Ge((t) => t === e.id ? null : t), 1500);
|
|
2378
2421
|
}, []), kt = e.useMemo(() => {
|
|
2379
2422
|
let e = /* @__PURE__ */ new Set(), t = [], r = -1, i = 0;
|
|
2380
|
-
for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan ||
|
|
2423
|
+
for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan || da(n)) && n.toolCallId && t.push({
|
|
2381
2424
|
id: n.toolCallId,
|
|
2382
2425
|
order: i
|
|
2383
2426
|
}), n.toolName === "apply_blueprint" && (r = i), i += 1;
|
|
@@ -2400,7 +2443,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2400
2443
|
}
|
|
2401
2444
|
return e;
|
|
2402
2445
|
}, [n]), Mt = (e) => {
|
|
2403
|
-
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = I?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s =
|
|
2446
|
+
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = I?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = tr(e.toolName), c = nr(e.result), l = q === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = q === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : at.get(d), p = f === void 0 ? et.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = t === "output-available" && oa(e.result) ? "approval-requested" : t, g = /* @__PURE__ */ Q("span", {
|
|
2404
2447
|
className: "inline-flex min-w-0 items-center gap-2",
|
|
2405
2448
|
children: [
|
|
2406
2449
|
/* @__PURE__ */ Z("span", { children: s || e.toolName }),
|
|
@@ -2408,22 +2451,22 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2408
2451
|
className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
|
|
2409
2452
|
children: e.toolName
|
|
2410
2453
|
}) : null,
|
|
2411
|
-
m ?
|
|
2454
|
+
m ? ua(e) ? /* @__PURE__ */ Z(ja, {
|
|
2412
2455
|
label: J.designingPlanLabel,
|
|
2413
2456
|
hints: J.designingPlanHints,
|
|
2414
2457
|
offlineLabel: J.connectionOfflineLabel
|
|
2415
|
-
}) : /* @__PURE__ */ Z(
|
|
2458
|
+
}) : /* @__PURE__ */ Z(Ma, { offlineLabel: J.connectionOfflineLabel }) : null
|
|
2416
2459
|
]
|
|
2417
2460
|
});
|
|
2418
|
-
return /* @__PURE__ */ Q(
|
|
2419
|
-
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff ||
|
|
2420
|
-
children: [/* @__PURE__ */ Z(
|
|
2461
|
+
return /* @__PURE__ */ Q(Ri, {
|
|
2462
|
+
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff || da(e),
|
|
2463
|
+
children: [/* @__PURE__ */ Z(Bi, {
|
|
2421
2464
|
type: n,
|
|
2422
2465
|
state: h,
|
|
2423
2466
|
title: g
|
|
2424
|
-
}), /* @__PURE__ */ Q(
|
|
2425
|
-
u && e.args !== void 0 ? /* @__PURE__ */ Z(
|
|
2426
|
-
o ? null : u || t === "output-error" ? /* @__PURE__ */ Z(
|
|
2467
|
+
}), /* @__PURE__ */ Q(Vi, { children: [
|
|
2468
|
+
u && e.args !== void 0 ? /* @__PURE__ */ Z(Hi, { input: e.args }) : null,
|
|
2469
|
+
o ? null : u || t === "output-error" ? /* @__PURE__ */ Z(Ha, {
|
|
2427
2470
|
output: c,
|
|
2428
2471
|
errorText: e.errorText
|
|
2429
2472
|
}) : null,
|
|
@@ -2515,7 +2558,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2515
2558
|
children: [/* @__PURE__ */ Z(je, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.message })]
|
|
2516
2559
|
}, `w${t}`))]
|
|
2517
2560
|
}) : null,
|
|
2518
|
-
et.has(e.toolCallId) ? /* @__PURE__ */ Z(
|
|
2561
|
+
et.has(e.toolCallId) ? /* @__PURE__ */ Z(va, { health: rt.get(e.toolCallId) }) : null,
|
|
2519
2562
|
e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ Q("div", {
|
|
2520
2563
|
className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
|
|
2521
2564
|
"data-testid": "draft-next-steps",
|
|
@@ -2603,7 +2646,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2603
2646
|
}) : null;
|
|
2604
2647
|
})(),
|
|
2605
2648
|
(() => {
|
|
2606
|
-
let { designNotes: t, deferred: n } =
|
|
2649
|
+
let { designNotes: t, deferred: n } = pa(e.proposedPlan.assumptions);
|
|
2607
2650
|
return /* @__PURE__ */ Q(X, { children: [t.length > 0 ? /* @__PURE__ */ Q("div", {
|
|
2608
2651
|
className: "flex flex-col gap-0.5",
|
|
2609
2652
|
"data-testid": "proposed-plan-assumptions",
|
|
@@ -2699,7 +2742,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2699
2742
|
})
|
|
2700
2743
|
]
|
|
2701
2744
|
}) : null,
|
|
2702
|
-
|
|
2745
|
+
da(e) ? /* @__PURE__ */ Q("div", {
|
|
2703
2746
|
className: "flex flex-col gap-2 border-t bg-muted/20 px-3 py-2.5",
|
|
2704
2747
|
"data-testid": "proposed-plan-fallback",
|
|
2705
2748
|
children: [
|
|
@@ -2765,7 +2808,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2765
2808
|
className: "flex flex-col gap-1",
|
|
2766
2809
|
children: e.proposedChanges.changes.map((e, t) => /* @__PURE__ */ Q("div", {
|
|
2767
2810
|
className: "flex items-start gap-1.5 rounded-md border bg-background px-2 py-1 text-[11px] text-foreground/80",
|
|
2768
|
-
children: [/* @__PURE__ */ Z(ht, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Z("span", { children:
|
|
2811
|
+
children: [/* @__PURE__ */ Z(ht, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Z("span", { children: la(e, Ne) })]
|
|
2769
2812
|
}, t))
|
|
2770
2813
|
}),
|
|
2771
2814
|
i ? jt.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
|
|
@@ -2820,11 +2863,11 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2820
2863
|
className: G("shrink-0", !He && "border-b bg-background/50"),
|
|
2821
2864
|
children: A
|
|
2822
2865
|
}) : null,
|
|
2823
|
-
/* @__PURE__ */ Q(
|
|
2866
|
+
/* @__PURE__ */ Q(dr, {
|
|
2824
2867
|
className: "flex-1 min-h-0",
|
|
2825
|
-
children: [/* @__PURE__ */ Q(
|
|
2868
|
+
children: [/* @__PURE__ */ Q(fr, {
|
|
2826
2869
|
className: G("space-y-4", He ? "mx-auto w-full max-w-2xl px-4 py-8 sm:px-0" : "px-4 py-3"),
|
|
2827
|
-
children: [n.length === 0 ? /* @__PURE__ */ Q(
|
|
2870
|
+
children: [n.length === 0 ? /* @__PURE__ */ Q(pr, {
|
|
2828
2871
|
className: "gap-3 px-0 py-8",
|
|
2829
2872
|
children: [
|
|
2830
2873
|
/* @__PURE__ */ Z("div", {
|
|
@@ -2847,7 +2890,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2847
2890
|
}),
|
|
2848
2891
|
T && T.length > 0 ? /* @__PURE__ */ Z("div", {
|
|
2849
2892
|
className: "flex w-full max-w-full flex-wrap justify-center gap-2",
|
|
2850
|
-
children: T.map((e) => /* @__PURE__ */ Z(
|
|
2893
|
+
children: T.map((e) => /* @__PURE__ */ Z(Mi, {
|
|
2851
2894
|
className: "h-auto min-h-8 min-w-0 max-w-full whitespace-normal break-words rounded-full border-border/60 bg-background/80 px-3 py-1 text-left text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60",
|
|
2852
2895
|
suggestion: e,
|
|
2853
2896
|
onClick: xt
|
|
@@ -2855,19 +2898,19 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2855
2898
|
}) : null
|
|
2856
2899
|
]
|
|
2857
2900
|
}) : n.map((e) => {
|
|
2858
|
-
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !n.some((e) => !!e.proposedPlan) ? e.blueprintProgress : void 0, c = !t && q === "summary" ? n.filter((e) => !
|
|
2859
|
-
return /* @__PURE__ */ Z(
|
|
2860
|
-
from:
|
|
2901
|
+
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !n.some((e) => !!e.proposedPlan) ? e.blueprintProgress : void 0, c = !t && q === "summary" ? n.filter((e) => !ma(e) && !(o && e.toolName === "propose_blueprint")) : [], l = !t && q === "debug" ? n : !t && q !== "debug" ? n.filter(ma) : [], u = !t && e.content.trim().length > 0 && !ga(e.content), d = q === "debug" && !!r, f = !t && !!e.streaming && !u && c.length === 0 && l.length === 0 && !d && !a && !o;
|
|
2902
|
+
return /* @__PURE__ */ Z(vr, {
|
|
2903
|
+
from: ia(e.role),
|
|
2861
2904
|
children: /* @__PURE__ */ Q("div", {
|
|
2862
2905
|
className: G("flex w-full gap-2.5", m ? t ? "flex-row-reverse items-start" : "flex-row items-start" : "flex-col"),
|
|
2863
|
-
children: [m ? /* @__PURE__ */ Z(
|
|
2906
|
+
children: [m ? /* @__PURE__ */ Z(ba, {
|
|
2864
2907
|
isUser: t,
|
|
2865
2908
|
url: t ? h : _,
|
|
2866
2909
|
fallback: t ? g : v
|
|
2867
2910
|
}) : null, /* @__PURE__ */ Q("div", {
|
|
2868
2911
|
className: G("flex min-w-0 flex-col gap-2", m && !t && "flex-1"),
|
|
2869
|
-
children: [/* @__PURE__ */ Q(
|
|
2870
|
-
o ? /* @__PURE__ */ Z(
|
|
2912
|
+
children: [/* @__PURE__ */ Q(yr, { children: [
|
|
2913
|
+
o ? /* @__PURE__ */ Z(Fa, {
|
|
2871
2914
|
progress: o,
|
|
2872
2915
|
designingLabel: J.designingPlanLabel,
|
|
2873
2916
|
extendLabel: ge,
|
|
@@ -2875,7 +2918,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2875
2918
|
stalledLabel: J.connectionStalledLabel,
|
|
2876
2919
|
offlineLabel: J.connectionOfflineLabel
|
|
2877
2920
|
}) : null,
|
|
2878
|
-
a ? /* @__PURE__ */ Z(
|
|
2921
|
+
a ? /* @__PURE__ */ Z(Ia, {
|
|
2879
2922
|
progress: a,
|
|
2880
2923
|
appSegment: e.toolInvocations?.map((e) => e.draftReview).find((e) => e?.packageId && e.items?.some((e) => e.type === "app"))?.packageId,
|
|
2881
2924
|
onOpenBuiltApp: re,
|
|
@@ -2889,20 +2932,20 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2889
2932
|
stalledLabel: J.connectionStalledLabel,
|
|
2890
2933
|
offlineLabel: J.connectionOfflineLabel
|
|
2891
2934
|
}) : null,
|
|
2892
|
-
!t && q === "debug" && r ? /* @__PURE__ */ Q(
|
|
2935
|
+
!t && q === "debug" && r ? /* @__PURE__ */ Q(Yi, {
|
|
2893
2936
|
isStreaming: !!e.streaming && !e.content,
|
|
2894
2937
|
className: "mb-2",
|
|
2895
|
-
children: [/* @__PURE__ */ Z(
|
|
2938
|
+
children: [/* @__PURE__ */ Z(Zi, {}), /* @__PURE__ */ Z(Qi, { children: r })]
|
|
2896
2939
|
}) : null,
|
|
2897
|
-
!t && q === "summary" && c.length > 0 ? /* @__PURE__ */ Z(
|
|
2898
|
-
groups:
|
|
2940
|
+
!t && q === "summary" && c.length > 0 ? /* @__PURE__ */ Z(La, {
|
|
2941
|
+
groups: _a(c),
|
|
2899
2942
|
labels: J
|
|
2900
2943
|
}) : null,
|
|
2901
2944
|
!t && l.length > 0 ? l.map(Mt) : null,
|
|
2902
2945
|
t ? e.content ? /* @__PURE__ */ Z("div", {
|
|
2903
2946
|
className: "whitespace-pre-wrap break-words",
|
|
2904
2947
|
children: e.content
|
|
2905
|
-
}) : null : f ? /* @__PURE__ */ Z(
|
|
2948
|
+
}) : null : f ? /* @__PURE__ */ Z(Sa, {}) : u ? /* @__PURE__ */ Z(Ar, { children: e.content }) : !e.streaming && ga(e.content) ? /* @__PURE__ */ Z("span", {
|
|
2906
2949
|
className: "text-xs italic text-muted-foreground/70",
|
|
2907
2950
|
title: e.content,
|
|
2908
2951
|
children: J.agentActivity
|
|
@@ -2930,7 +2973,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2930
2973
|
} })]
|
|
2931
2974
|
}, t))
|
|
2932
2975
|
}) : null,
|
|
2933
|
-
!t && i.length > 0 ? /* @__PURE__ */ Q(
|
|
2976
|
+
!t && i.length > 0 ? /* @__PURE__ */ Q($i, { children: [/* @__PURE__ */ Z(ea, { count: i.length }), /* @__PURE__ */ Z(ta, { children: i.map((e, t) => /* @__PURE__ */ Z(na, {
|
|
2934
2977
|
href: e.url,
|
|
2935
2978
|
title: e.title ?? e.url
|
|
2936
2979
|
}, e.id ?? e.url ?? t)) })] }) : null,
|
|
@@ -2938,16 +2981,16 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2938
2981
|
className: "text-[10px] opacity-70 mt-1",
|
|
2939
2982
|
children: e.timestamp
|
|
2940
2983
|
}) : null
|
|
2941
|
-
] }), !t && !f ? /* @__PURE__ */ Q(
|
|
2984
|
+
] }), !t && !f ? /* @__PURE__ */ Q(br, {
|
|
2942
2985
|
className: "opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
|
|
2943
2986
|
children: [
|
|
2944
|
-
/* @__PURE__ */ Z(
|
|
2987
|
+
/* @__PURE__ */ Z(xr, {
|
|
2945
2988
|
label: We === e.id ? J.copied : J.copy,
|
|
2946
2989
|
tooltip: We === e.id ? J.copied : J.copy,
|
|
2947
2990
|
onClick: () => Ot(e),
|
|
2948
2991
|
children: We === e.id ? /* @__PURE__ */ Z(Le, { className: "size-3.5" }) : /* @__PURE__ */ Z(qe, { className: "size-3.5" })
|
|
2949
2992
|
}),
|
|
2950
|
-
s ? /* @__PURE__ */ Z(
|
|
2993
|
+
s ? /* @__PURE__ */ Z(xr, {
|
|
2951
2994
|
label: J.regenerate,
|
|
2952
2995
|
tooltip: J.regenerate,
|
|
2953
2996
|
onClick: s,
|
|
@@ -2965,7 +3008,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2965
3008
|
})]
|
|
2966
3009
|
})
|
|
2967
3010
|
}, e.id);
|
|
2968
|
-
}), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Z(
|
|
3011
|
+
}), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Z(xa, {
|
|
2969
3012
|
showAvatar: m,
|
|
2970
3013
|
assistantAvatarUrl: _,
|
|
2971
3014
|
assistantAvatarFallback: v,
|
|
@@ -2973,13 +3016,13 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2973
3016
|
stalledLabel: J.connectionStalledLabel,
|
|
2974
3017
|
offlineLabel: J.connectionOfflineLabel
|
|
2975
3018
|
}) : null]
|
|
2976
|
-
}), /* @__PURE__ */ Z(
|
|
3019
|
+
}), /* @__PURE__ */ Z(mr, {})]
|
|
2977
3020
|
}),
|
|
2978
|
-
f ?
|
|
3021
|
+
f ? cr(f) && !sr(f) ? /* @__PURE__ */ Z(Ba, {
|
|
2979
3022
|
error: f,
|
|
2980
3023
|
rateLimitedLabel: J.sendFailedRateLimited,
|
|
2981
3024
|
genericLabel: J.sendFailedGeneric
|
|
2982
|
-
}) : /* @__PURE__ */ Z(
|
|
3025
|
+
}) : /* @__PURE__ */ Z(Va, {
|
|
2983
3026
|
error: f,
|
|
2984
3027
|
onReload: s,
|
|
2985
3028
|
onUpgrade: c
|
|
@@ -2990,7 +3033,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2990
3033
|
children: [j ? /* @__PURE__ */ Z("div", {
|
|
2991
3034
|
className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
|
|
2992
3035
|
children: j
|
|
2993
|
-
}) : null, /* @__PURE__ */ Q(
|
|
3036
|
+
}) : null, /* @__PURE__ */ Q(Qr, {
|
|
2994
3037
|
accept: C,
|
|
2995
3038
|
fileInputLabel: J.uploadFiles,
|
|
2996
3039
|
maxFileSize: w,
|
|
@@ -2999,14 +3042,14 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2999
3042
|
console.warn("[plugin-chatbot] prompt-input error", e);
|
|
3000
3043
|
},
|
|
3001
3044
|
children: [
|
|
3002
|
-
S ? /* @__PURE__ */ Z(
|
|
3003
|
-
/* @__PURE__ */ Z(
|
|
3045
|
+
S ? /* @__PURE__ */ Z($r, { children: /* @__PURE__ */ Z(Xr, { children: (e) => /* @__PURE__ */ Z(Yr, { data: e }) }) }) : null,
|
|
3046
|
+
/* @__PURE__ */ Z(ei, {
|
|
3004
3047
|
placeholder: r,
|
|
3005
3048
|
disabled: l || Ve === "streaming",
|
|
3006
3049
|
onChange: M ? (e) => M(e.currentTarget.value) : void 0
|
|
3007
3050
|
}),
|
|
3008
|
-
/* @__PURE__ */ Q(
|
|
3009
|
-
S ? /* @__PURE__ */ Q(
|
|
3051
|
+
/* @__PURE__ */ Q(ni, { children: [/* @__PURE__ */ Q(ri, { children: [
|
|
3052
|
+
S ? /* @__PURE__ */ Q(ai, { children: [/* @__PURE__ */ Z(oi, {}), /* @__PURE__ */ Z(si, { children: /* @__PURE__ */ Z(Zr, {}) })] }) : null,
|
|
3010
3053
|
D && D.length > 1 ? /* @__PURE__ */ Z("select", {
|
|
3011
3054
|
"aria-label": J.model,
|
|
3012
3055
|
value: O ?? D[0].id,
|
|
@@ -3025,7 +3068,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
3025
3068
|
children: J.sendHint
|
|
3026
3069
|
})]
|
|
3027
3070
|
})
|
|
3028
|
-
] }), /* @__PURE__ */ Z(
|
|
3071
|
+
] }), /* @__PURE__ */ Z(li, {
|
|
3029
3072
|
"aria-label": Ve === "streaming" ? J.stopResponse : J.submit,
|
|
3030
3073
|
status: Ve,
|
|
3031
3074
|
disabled: l,
|
|
@@ -3038,8 +3081,8 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
3038
3081
|
]
|
|
3039
3082
|
});
|
|
3040
3083
|
});
|
|
3041
|
-
|
|
3042
|
-
function
|
|
3084
|
+
ya.displayName = "ChatbotEnhanced";
|
|
3085
|
+
function ba({ isUser: e, url: t, fallback: n }) {
|
|
3043
3086
|
return /* @__PURE__ */ Z("div", {
|
|
3044
3087
|
className: G("mt-0.5 flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-medium", e ? "bg-secondary text-secondary-foreground" : "bg-primary/10 text-primary"),
|
|
3045
3088
|
"aria-hidden": "true",
|
|
@@ -3050,21 +3093,21 @@ function da({ isUser: e, url: t, fallback: n }) {
|
|
|
3050
3093
|
}) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Z(Fe, { className: "size-4" })
|
|
3051
3094
|
});
|
|
3052
3095
|
}
|
|
3053
|
-
function
|
|
3054
|
-
return /* @__PURE__ */ Z(
|
|
3096
|
+
function xa({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
|
|
3097
|
+
return /* @__PURE__ */ Z(vr, {
|
|
3055
3098
|
from: "assistant",
|
|
3056
3099
|
"aria-live": "polite",
|
|
3057
3100
|
children: /* @__PURE__ */ Q("div", {
|
|
3058
3101
|
className: G("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
|
|
3059
|
-
children: [e ? /* @__PURE__ */ Z(
|
|
3102
|
+
children: [e ? /* @__PURE__ */ Z(ba, {
|
|
3060
3103
|
isUser: !1,
|
|
3061
3104
|
url: t,
|
|
3062
3105
|
fallback: n
|
|
3063
|
-
}) : null, /* @__PURE__ */ Z(
|
|
3106
|
+
}) : null, /* @__PURE__ */ Z(yr, {
|
|
3064
3107
|
className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
|
|
3065
3108
|
children: /* @__PURE__ */ Q("span", {
|
|
3066
3109
|
className: "inline-flex items-center gap-2",
|
|
3067
|
-
children: [/* @__PURE__ */ Z(
|
|
3110
|
+
children: [/* @__PURE__ */ Z(Sa, {}), /* @__PURE__ */ Z(Da, {
|
|
3068
3111
|
active: !0,
|
|
3069
3112
|
pending: !0,
|
|
3070
3113
|
activityKey: 0,
|
|
@@ -3077,7 +3120,7 @@ function fa({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n,
|
|
|
3077
3120
|
})
|
|
3078
3121
|
});
|
|
3079
3122
|
}
|
|
3080
|
-
function
|
|
3123
|
+
function Sa() {
|
|
3081
3124
|
return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("span", {
|
|
3082
3125
|
className: "sr-only",
|
|
3083
3126
|
children: "Assistant is responding"
|
|
@@ -3091,12 +3134,12 @@ function pa() {
|
|
|
3091
3134
|
]
|
|
3092
3135
|
})] });
|
|
3093
3136
|
}
|
|
3094
|
-
function
|
|
3137
|
+
function Ca(e) {
|
|
3095
3138
|
let t = Math.floor(e / 60), n = e % 60;
|
|
3096
3139
|
return `${t}:${String(n).padStart(2, "0")}`;
|
|
3097
3140
|
}
|
|
3098
|
-
var
|
|
3099
|
-
function
|
|
3141
|
+
var wa = 6;
|
|
3142
|
+
function Ta(t, n) {
|
|
3100
3143
|
let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
|
|
3101
3144
|
elapsed: 0,
|
|
3102
3145
|
quiet: 0
|
|
@@ -3125,10 +3168,10 @@ function ga(t, n) {
|
|
|
3125
3168
|
}, [t]), {
|
|
3126
3169
|
elapsedSeconds: a.elapsed,
|
|
3127
3170
|
quietSeconds: a.quiet,
|
|
3128
|
-
live: a.quiet <
|
|
3171
|
+
live: a.quiet < wa
|
|
3129
3172
|
};
|
|
3130
3173
|
}
|
|
3131
|
-
function
|
|
3174
|
+
function Ea() {
|
|
3132
3175
|
let [t, n] = e.useState(() => typeof navigator < "u" && navigator.onLine === !1);
|
|
3133
3176
|
return e.useEffect(() => {
|
|
3134
3177
|
if (typeof window > "u") return;
|
|
@@ -3138,8 +3181,8 @@ function _a() {
|
|
|
3138
3181
|
};
|
|
3139
3182
|
}, []), t;
|
|
3140
3183
|
}
|
|
3141
|
-
function
|
|
3142
|
-
let { elapsedSeconds: o, quietSeconds: s, live: c } =
|
|
3184
|
+
function Da({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
|
|
3185
|
+
let { elapsedSeconds: o, quietSeconds: s, live: c } = Ta(e, t), l = Ea() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = Ca(o);
|
|
3143
3186
|
return /* @__PURE__ */ Q("span", {
|
|
3144
3187
|
className: G("inline-flex items-center gap-1.5 text-xs tabular-nums", l === "offline" ? "text-red-600 font-medium" : l === "stalled" ? "text-amber-600 font-medium" : "font-normal text-muted-foreground"),
|
|
3145
3188
|
"aria-live": "polite",
|
|
@@ -3162,7 +3205,7 @@ function va({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stall
|
|
|
3162
3205
|
]
|
|
3163
3206
|
});
|
|
3164
3207
|
}
|
|
3165
|
-
var
|
|
3208
|
+
var Oa = [
|
|
3166
3209
|
"Mapping out the data you’ll track…",
|
|
3167
3210
|
"Shaping objects and their fields…",
|
|
3168
3211
|
"Connecting related records…",
|
|
@@ -3173,21 +3216,21 @@ var ya = [
|
|
|
3173
3216
|
"Sketching a dashboard to track it…",
|
|
3174
3217
|
"Double-checking the structure hangs together…",
|
|
3175
3218
|
"Pulling the plan together…"
|
|
3176
|
-
],
|
|
3177
|
-
function
|
|
3219
|
+
], ka = 3500;
|
|
3220
|
+
function Aa(e, t, n = ka) {
|
|
3178
3221
|
if (t <= 0) return -1;
|
|
3179
3222
|
if (t === 1) return 0;
|
|
3180
|
-
let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n :
|
|
3223
|
+
let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n : ka));
|
|
3181
3224
|
return Math.min(r, t - 1);
|
|
3182
3225
|
}
|
|
3183
|
-
function
|
|
3226
|
+
function ja({ label: t, hints: n, offlineLabel: r }) {
|
|
3184
3227
|
let [i, a] = e.useState(0);
|
|
3185
3228
|
e.useEffect(() => {
|
|
3186
3229
|
if (n.length <= 1) return;
|
|
3187
|
-
let e = Date.now(), t = setInterval(() => a(Date.now() - e),
|
|
3230
|
+
let e = Date.now(), t = setInterval(() => a(Date.now() - e), ka);
|
|
3188
3231
|
return () => clearInterval(t);
|
|
3189
3232
|
}, [n.length]);
|
|
3190
|
-
let o =
|
|
3233
|
+
let o = Aa(i, n.length), s = o >= 0 ? n[o] : void 0, c = n.length > 1 && n.length <= 12;
|
|
3191
3234
|
return /* @__PURE__ */ Q("span", {
|
|
3192
3235
|
className: "inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",
|
|
3193
3236
|
"data-testid": "build-proposal-progress",
|
|
@@ -3211,12 +3254,12 @@ function Sa({ label: t, hints: n, offlineLabel: r }) {
|
|
|
3211
3254
|
"aria-hidden": !0,
|
|
3212
3255
|
children: n.map((e, t) => /* @__PURE__ */ Z("span", { className: G("size-1 rounded-full transition-colors", t <= o ? "bg-primary/70" : "bg-muted-foreground/25") }, t))
|
|
3213
3256
|
}) : null,
|
|
3214
|
-
/* @__PURE__ */ Z(
|
|
3257
|
+
/* @__PURE__ */ Z(Ma, { offlineLabel: r })
|
|
3215
3258
|
]
|
|
3216
3259
|
});
|
|
3217
3260
|
}
|
|
3218
|
-
function
|
|
3219
|
-
let [n, r] = e.useState(0), i =
|
|
3261
|
+
function Ma({ offlineLabel: t }) {
|
|
3262
|
+
let [n, r] = e.useState(0), i = Ea();
|
|
3220
3263
|
return e.useEffect(() => {
|
|
3221
3264
|
let e = Date.now(), t = setInterval(() => r(Math.floor((Date.now() - e) / 1e3)), 1e3);
|
|
3222
3265
|
return () => clearInterval(t);
|
|
@@ -3229,25 +3272,25 @@ function Ca({ offlineLabel: t }) {
|
|
|
3229
3272
|
className: "size-3 shrink-0",
|
|
3230
3273
|
"aria-hidden": !0
|
|
3231
3274
|
}),
|
|
3232
|
-
/* @__PURE__ */ Z("span", { children:
|
|
3275
|
+
/* @__PURE__ */ Z("span", { children: Ca(n) }),
|
|
3233
3276
|
i ? /* @__PURE__ */ Q("span", { children: ["· ", t] }) : null
|
|
3234
3277
|
]
|
|
3235
3278
|
});
|
|
3236
3279
|
}
|
|
3237
|
-
var
|
|
3280
|
+
var Na = [
|
|
3238
3281
|
"object",
|
|
3239
3282
|
"view",
|
|
3240
3283
|
"dashboard",
|
|
3241
3284
|
"app",
|
|
3242
3285
|
"seed"
|
|
3243
|
-
],
|
|
3286
|
+
], Pa = {
|
|
3244
3287
|
object: "Objects",
|
|
3245
3288
|
view: "Views",
|
|
3246
3289
|
dashboard: "Dashboards",
|
|
3247
3290
|
app: "App",
|
|
3248
3291
|
seed: "Sample data"
|
|
3249
3292
|
};
|
|
3250
|
-
function
|
|
3293
|
+
function Fa({ progress: e, designingLabel: t = "Designing your app…", extendLabel: n = "Adding to existing app", waitingLabel: r = "Waiting for server…", stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
|
|
3251
3294
|
let { phase: o, summary: s, appLabel: c, targetApp: l, objects: u, counts: d, seq: f } = e, p = o === "done", m = f ?? `${o}:${u.length}`, h = p && (s || c) || t, g = [];
|
|
3252
3295
|
return d?.objects && g.push(`${d.objects} object${d.objects === 1 ? "" : "s"}`), d?.views && g.push(`${d.views} view${d.views === 1 ? "" : "s"}`), d?.dashboards && g.push(`${d.dashboards} dashboard${d.dashboards === 1 ? "" : "s"}`), /* @__PURE__ */ Q("div", {
|
|
3253
3296
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
@@ -3274,7 +3317,7 @@ function Ea({ progress: e, designingLabel: t = "Designing your app…", extendLa
|
|
|
3274
3317
|
}) : null,
|
|
3275
3318
|
p ? null : /* @__PURE__ */ Z("span", {
|
|
3276
3319
|
className: "ml-auto shrink-0",
|
|
3277
|
-
children: /* @__PURE__ */ Z(
|
|
3320
|
+
children: /* @__PURE__ */ Z(Da, {
|
|
3278
3321
|
active: !0,
|
|
3279
3322
|
activityKey: m,
|
|
3280
3323
|
waitingLabel: r,
|
|
@@ -3311,7 +3354,7 @@ function Ea({ progress: e, designingLabel: t = "Designing your app…", extendLa
|
|
|
3311
3354
|
]
|
|
3312
3355
|
});
|
|
3313
3356
|
}
|
|
3314
|
-
function
|
|
3357
|
+
function Ia({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel: i = "Open app", onDesignBuiltApp: a, designBuiltAppLabel: o = "Design in Studio", getArtifactAction: s, onPreviewDraftApp: c, previewDraftLabel: l = "Preview", waitingLabel: u = "Waiting for server…", stalledLabel: d = "Still working…", offlineLabel: f = "Connection lost — reconnecting…" }) {
|
|
3315
3358
|
let { phase: p, appLabel: m, items: h, done: g, total: _, seq: v } = t, y = p === "done", b = v ?? `${p}:${g}:${h.length}`, x = h.find((e) => e.type === "app"), S = _ > 0 ? Math.min(100, Math.round(g / _ * 100)) : y ? 100 : 6, C = /* @__PURE__ */ new Map();
|
|
3316
3359
|
for (let e of h) {
|
|
3317
3360
|
let t = C.get(e.type) ?? [];
|
|
@@ -3320,7 +3363,7 @@ function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
|
|
|
3320
3363
|
display: e.name.replace(/_sample$/, "")
|
|
3321
3364
|
}), C.set(e.type, t);
|
|
3322
3365
|
}
|
|
3323
|
-
let w = [...
|
|
3366
|
+
let w = [...Na.filter((e) => C.has(e)), ...[...C.keys()].filter((e) => !Na.includes(e))];
|
|
3324
3367
|
return /* @__PURE__ */ Q("div", {
|
|
3325
3368
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
3326
3369
|
"data-testid": "build-progress",
|
|
@@ -3336,7 +3379,7 @@ function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
|
|
|
3336
3379
|
}) : null,
|
|
3337
3380
|
y ? null : /* @__PURE__ */ Z("span", {
|
|
3338
3381
|
className: "ml-auto",
|
|
3339
|
-
children: /* @__PURE__ */ Z(
|
|
3382
|
+
children: /* @__PURE__ */ Z(Da, {
|
|
3340
3383
|
active: !0,
|
|
3341
3384
|
activityKey: b,
|
|
3342
3385
|
waitingLabel: u,
|
|
@@ -3364,7 +3407,7 @@ function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
|
|
|
3364
3407
|
children: [
|
|
3365
3408
|
/* @__PURE__ */ Z("span", {
|
|
3366
3409
|
className: "font-medium text-foreground",
|
|
3367
|
-
children:
|
|
3410
|
+
children: Pa[t] ?? t
|
|
3368
3411
|
}),
|
|
3369
3412
|
" ",
|
|
3370
3413
|
r.slice(0, 6).map((r, i) => {
|
|
@@ -3415,7 +3458,7 @@ function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
|
|
|
3415
3458
|
]
|
|
3416
3459
|
});
|
|
3417
3460
|
}
|
|
3418
|
-
function
|
|
3461
|
+
function La({ groups: e, labels: t }) {
|
|
3419
3462
|
return e.length === 0 ? null : /* @__PURE__ */ Z("div", {
|
|
3420
3463
|
className: "not-prose mb-2 border-l border-border/70 pl-3",
|
|
3421
3464
|
children: /* @__PURE__ */ Z("div", {
|
|
@@ -3425,7 +3468,7 @@ function Oa({ groups: e, labels: t }) {
|
|
|
3425
3468
|
children: [/* @__PURE__ */ Q("div", {
|
|
3426
3469
|
className: "flex min-w-0 items-center gap-2",
|
|
3427
3470
|
children: [
|
|
3428
|
-
/* @__PURE__ */ Z(
|
|
3471
|
+
/* @__PURE__ */ Z(Ra, { state: e.state }),
|
|
3429
3472
|
/* @__PURE__ */ Z("span", {
|
|
3430
3473
|
className: "truncate font-medium text-foreground",
|
|
3431
3474
|
children: e.title
|
|
@@ -3435,22 +3478,22 @@ function Oa({ groups: e, labels: t }) {
|
|
|
3435
3478
|
children: ["x", e.count]
|
|
3436
3479
|
}) : null
|
|
3437
3480
|
]
|
|
3438
|
-
}), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Z(
|
|
3481
|
+
}), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Z(ja, {
|
|
3439
3482
|
label: t.designingPlanLabel,
|
|
3440
3483
|
hints: t.designingPlanHints,
|
|
3441
3484
|
offlineLabel: t.connectionOfflineLabel
|
|
3442
|
-
}) : /* @__PURE__ */ Z(
|
|
3485
|
+
}) : /* @__PURE__ */ Z(Ma, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Z("span", {
|
|
3443
3486
|
className: G("shrink-0 text-[10px] font-medium", e.state === "failed" ? "text-destructive" : e.state === "completed" ? "text-emerald-700 dark:text-emerald-400" : "text-muted-foreground"),
|
|
3444
|
-
children:
|
|
3487
|
+
children: za(e.state, t)
|
|
3445
3488
|
})]
|
|
3446
3489
|
}, e.key))
|
|
3447
3490
|
})
|
|
3448
3491
|
});
|
|
3449
3492
|
}
|
|
3450
|
-
function
|
|
3493
|
+
function Ra({ state: e }) {
|
|
3451
3494
|
return e === "failed" ? /* @__PURE__ */ Z(Y, { className: "size-3.5 shrink-0 text-destructive" }) : e === "completed" ? /* @__PURE__ */ Z(K, { className: "size-3.5 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Z(Ge, { className: "size-3.5 shrink-0 text-muted-foreground" });
|
|
3452
3495
|
}
|
|
3453
|
-
function
|
|
3496
|
+
function za(e, t) {
|
|
3454
3497
|
switch (e) {
|
|
3455
3498
|
case "failed": return t.toolFailed;
|
|
3456
3499
|
case "awaiting": return t.toolAwaitingApproval;
|
|
@@ -3458,8 +3501,8 @@ function Aa(e, t) {
|
|
|
3458
3501
|
case "completed": return t.toolCompleted;
|
|
3459
3502
|
}
|
|
3460
3503
|
}
|
|
3461
|
-
function
|
|
3462
|
-
let i = e.useMemo(() =>
|
|
3504
|
+
function Ba({ error: t, rateLimitedLabel: n, genericLabel: r }) {
|
|
3505
|
+
let i = e.useMemo(() => ur(t) ? n : r, [
|
|
3463
3506
|
t,
|
|
3464
3507
|
n,
|
|
3465
3508
|
r
|
|
@@ -3480,8 +3523,8 @@ function ja({ error: t, rateLimitedLabel: n, genericLabel: r }) {
|
|
|
3480
3523
|
})
|
|
3481
3524
|
});
|
|
3482
3525
|
}
|
|
3483
|
-
function
|
|
3484
|
-
let { language: i } = Et(), a = Dt(), o = e.useMemo(() =>
|
|
3526
|
+
function Va({ error: t, onReload: n, onUpgrade: r }) {
|
|
3527
|
+
let { language: i } = Et(), a = Dt(), o = e.useMemo(() => sr(t), [t]), { summary: s, details: c } = e.useMemo(() => rr(t), [t]), [l, u] = e.useState(!1);
|
|
3485
3528
|
if (o) {
|
|
3486
3529
|
let e = (i.toLowerCase().startsWith("zh") ? o.message : o.messageEn ?? o.message) || a("chatbotQuota.fallbackMessage", "You have reached your AI quota."), t = o.topUp ? a("chatbotQuota.buyCredits", "Buy a credit pack") : a("chatbotQuota.upgradePlan", "Upgrade plan"), n = a("chatbotQuota.title", "Upgrade needed");
|
|
3487
3530
|
return /* @__PURE__ */ Z("div", {
|
|
@@ -3552,27 +3595,27 @@ function Ma({ error: t, onReload: n, onUpgrade: r }) {
|
|
|
3552
3595
|
})
|
|
3553
3596
|
});
|
|
3554
3597
|
}
|
|
3555
|
-
function
|
|
3556
|
-
return t ? /* @__PURE__ */ Z(
|
|
3598
|
+
function Ha({ output: e, errorText: t }) {
|
|
3599
|
+
return t ? /* @__PURE__ */ Z(Ui, {
|
|
3557
3600
|
output: void 0,
|
|
3558
3601
|
errorText: t
|
|
3559
|
-
}) : e == null || e === "" ? null : typeof e == "string" && !
|
|
3602
|
+
}) : e == null || e === "" ? null : typeof e == "string" && !aa(e) ? /* @__PURE__ */ Q("div", {
|
|
3560
3603
|
className: "space-y-2 p-4",
|
|
3561
3604
|
children: [/* @__PURE__ */ Z("h4", {
|
|
3562
3605
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
3563
3606
|
children: "Result"
|
|
3564
3607
|
}), /* @__PURE__ */ Z("div", {
|
|
3565
3608
|
className: "overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground",
|
|
3566
|
-
children: /* @__PURE__ */ Z(
|
|
3609
|
+
children: /* @__PURE__ */ Z(Ar, { children: e })
|
|
3567
3610
|
})]
|
|
3568
|
-
}) : /* @__PURE__ */ Z(
|
|
3611
|
+
}) : /* @__PURE__ */ Z(Ui, {
|
|
3569
3612
|
output: e,
|
|
3570
3613
|
errorText: void 0
|
|
3571
3614
|
});
|
|
3572
3615
|
}
|
|
3573
3616
|
//#endregion
|
|
3574
3617
|
//#region src/FloatingChatbot.tsx
|
|
3575
|
-
function
|
|
3618
|
+
function Ua({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
3576
3619
|
let { position: a = "bottom-right", defaultOpen: o = !1, panelWidth: s = 400, panelHeight: c = 520, title: l = "Chat", triggerSize: u = 56 } = t ?? {}, [d, f] = e.useState(null);
|
|
3577
3620
|
e.useEffect(() => {
|
|
3578
3621
|
let e = document.getElementById("floating-chatbot-portal");
|
|
@@ -3580,19 +3623,19 @@ function Pa({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
|
3580
3623
|
e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
|
|
3581
3624
|
};
|
|
3582
3625
|
}, []);
|
|
3583
|
-
let p = /* @__PURE__ */ Q(
|
|
3626
|
+
let p = /* @__PURE__ */ Q(Vn, {
|
|
3584
3627
|
defaultOpen: o,
|
|
3585
|
-
children: [/* @__PURE__ */ Z(
|
|
3628
|
+
children: [/* @__PURE__ */ Z(qn, {
|
|
3586
3629
|
position: a,
|
|
3587
3630
|
size: u
|
|
3588
|
-
}), /* @__PURE__ */ Z(
|
|
3631
|
+
}), /* @__PURE__ */ Z($n, {
|
|
3589
3632
|
title: l,
|
|
3590
3633
|
position: a,
|
|
3591
3634
|
width: s,
|
|
3592
3635
|
height: c,
|
|
3593
3636
|
headerExtra: n,
|
|
3594
3637
|
headerActions: r,
|
|
3595
|
-
children: /* @__PURE__ */ Z(
|
|
3638
|
+
children: /* @__PURE__ */ Z(ya, {
|
|
3596
3639
|
...i,
|
|
3597
3640
|
maxHeight: "100%",
|
|
3598
3641
|
className: "h-full border-0 rounded-none"
|
|
@@ -3601,8 +3644,8 @@ function Pa({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
|
3601
3644
|
});
|
|
3602
3645
|
return d ? wt.createPortal(p, d) : p;
|
|
3603
3646
|
}
|
|
3604
|
-
Lt.register("chatbot", ({ schema: e, className: t,
|
|
3605
|
-
let { messages:
|
|
3647
|
+
Lt.register("chatbot", ({ schema: e, className: t, disabled: n, ...r }) => {
|
|
3648
|
+
let { messages: i, isLoading: a, sendMessage: o } = yn({
|
|
3606
3649
|
api: e.api,
|
|
3607
3650
|
initialMessages: e.messages,
|
|
3608
3651
|
conversationId: e.conversationId,
|
|
@@ -3618,22 +3661,22 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3618
3661
|
autoResponseText: e.autoResponseText,
|
|
3619
3662
|
autoResponseDelay: e.autoResponseDelay,
|
|
3620
3663
|
onSend: e.onSend
|
|
3621
|
-
})
|
|
3622
|
-
|
|
3623
|
-
|
|
3664
|
+
}), s = (e) => {
|
|
3665
|
+
o(e);
|
|
3666
|
+
}, c = l(() => fn(i), [i]);
|
|
3667
|
+
return /* @__PURE__ */ Z(uo, {
|
|
3668
|
+
...Rt(r),
|
|
3669
|
+
messages: c,
|
|
3624
3670
|
placeholder: e.placeholder,
|
|
3625
|
-
onSendMessage:
|
|
3626
|
-
|
|
3627
|
-
},
|
|
3628
|
-
disabled: e.disabled || i,
|
|
3671
|
+
onSendMessage: s,
|
|
3672
|
+
disabled: n || a,
|
|
3629
3673
|
showTimestamp: e.showTimestamp,
|
|
3630
3674
|
userAvatarUrl: e.userAvatarUrl,
|
|
3631
3675
|
userAvatarFallback: e.userAvatarFallback,
|
|
3632
3676
|
assistantAvatarUrl: e.assistantAvatarUrl,
|
|
3633
3677
|
assistantAvatarFallback: e.assistantAvatarFallback,
|
|
3634
3678
|
maxHeight: e.maxHeight,
|
|
3635
|
-
className: t
|
|
3636
|
-
...n
|
|
3679
|
+
className: t
|
|
3637
3680
|
});
|
|
3638
3681
|
}, {
|
|
3639
3682
|
namespace: "plugin-chatbot",
|
|
@@ -3767,8 +3810,8 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3767
3810
|
autoResponseDelay: 1e3,
|
|
3768
3811
|
className: "w-full max-w-2xl"
|
|
3769
3812
|
}
|
|
3770
|
-
}), Lt.register("chatbot-enhanced", ({ schema: e, className: t,
|
|
3771
|
-
let { messages:
|
|
3813
|
+
}), Lt.register("chatbot-enhanced", ({ schema: e, className: t, disabled: n, ...r }) => {
|
|
3814
|
+
let { messages: i, isLoading: a, error: o, sendMessage: s, stop: c, reload: u, clear: d, isApiMode: f } = yn({
|
|
3772
3815
|
api: e.api,
|
|
3773
3816
|
initialMessages: e.messages,
|
|
3774
3817
|
conversationId: e.conversationId,
|
|
@@ -3784,21 +3827,22 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3784
3827
|
autoResponseText: e.autoResponseText,
|
|
3785
3828
|
autoResponseDelay: e.autoResponseDelay,
|
|
3786
3829
|
onSend: e.onSend
|
|
3787
|
-
})
|
|
3788
|
-
|
|
3789
|
-
|
|
3830
|
+
}), p = (e, t) => {
|
|
3831
|
+
s(e, t);
|
|
3832
|
+
}, m = () => {
|
|
3833
|
+
d(), e.onClear?.();
|
|
3834
|
+
}, h = l(() => fn(i), [i]);
|
|
3835
|
+
return /* @__PURE__ */ Z(ya, {
|
|
3836
|
+
...Rt(r),
|
|
3837
|
+
messages: h,
|
|
3790
3838
|
placeholder: e.placeholder,
|
|
3791
|
-
onSendMessage:
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
onReload: u ? c : void 0,
|
|
3799
|
-
disabled: e.disabled,
|
|
3800
|
-
isLoading: i,
|
|
3801
|
-
error: a,
|
|
3839
|
+
onSendMessage: p,
|
|
3840
|
+
onClear: m,
|
|
3841
|
+
onStop: f && a ? c : void 0,
|
|
3842
|
+
onReload: f ? u : void 0,
|
|
3843
|
+
disabled: n,
|
|
3844
|
+
isLoading: a,
|
|
3845
|
+
error: o,
|
|
3802
3846
|
showTimestamp: e.showTimestamp,
|
|
3803
3847
|
userAvatarUrl: e.userAvatarUrl,
|
|
3804
3848
|
userAvatarFallback: e.userAvatarFallback,
|
|
@@ -3808,8 +3852,7 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3808
3852
|
enableMarkdown: e.enableMarkdown ?? !0,
|
|
3809
3853
|
enableFileUpload: e.enableFileUpload ?? !1,
|
|
3810
3854
|
processVisibility: e.processVisibility,
|
|
3811
|
-
className: t
|
|
3812
|
-
...n
|
|
3855
|
+
className: t
|
|
3813
3856
|
});
|
|
3814
3857
|
}, {
|
|
3815
3858
|
namespace: "plugin-chatbot",
|
|
@@ -3955,7 +3998,7 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3955
3998
|
className: "w-full max-w-2xl"
|
|
3956
3999
|
}
|
|
3957
4000
|
}), Lt.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
|
|
3958
|
-
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear:
|
|
4001
|
+
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: u, isApiMode: d } = yn({
|
|
3959
4002
|
api: e.api,
|
|
3960
4003
|
initialMessages: e.messages,
|
|
3961
4004
|
conversationId: e.conversationId,
|
|
@@ -3971,19 +4014,19 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3971
4014
|
autoResponseText: e.autoResponseText,
|
|
3972
4015
|
autoResponseDelay: e.autoResponseDelay,
|
|
3973
4016
|
onSend: e.onSend
|
|
3974
|
-
})
|
|
3975
|
-
|
|
4017
|
+
}), f = (e, t) => {
|
|
4018
|
+
o(e, t);
|
|
4019
|
+
}, p = () => {
|
|
4020
|
+
u(), e.onClear?.();
|
|
4021
|
+
}, m = l(() => fn(r), [r]);
|
|
4022
|
+
return /* @__PURE__ */ Z(Ua, {
|
|
3976
4023
|
floatingConfig: e.floatingConfig,
|
|
3977
|
-
messages:
|
|
4024
|
+
messages: m,
|
|
3978
4025
|
placeholder: e.placeholder,
|
|
3979
|
-
onSendMessage:
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
l(), e.onClear?.();
|
|
3984
|
-
},
|
|
3985
|
-
onStop: u && i ? s : void 0,
|
|
3986
|
-
onReload: u ? c : void 0,
|
|
4026
|
+
onSendMessage: f,
|
|
4027
|
+
onClear: p,
|
|
4028
|
+
onStop: d && i ? s : void 0,
|
|
4029
|
+
onReload: d ? c : void 0,
|
|
3987
4030
|
disabled: e.disabled,
|
|
3988
4031
|
isLoading: i,
|
|
3989
4032
|
error: a,
|
|
@@ -4144,7 +4187,7 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
4144
4187
|
});
|
|
4145
4188
|
//#endregion
|
|
4146
4189
|
//#region src/elements/loader.tsx
|
|
4147
|
-
var
|
|
4190
|
+
var Wa = ({ size: e = 16 }) => /* @__PURE__ */ Q("svg", {
|
|
4148
4191
|
height: e,
|
|
4149
4192
|
strokeLinejoin: "round",
|
|
4150
4193
|
style: { color: "currentcolor" },
|
|
@@ -4225,97 +4268,97 @@ var Fa = ({ size: e = 16 }) => /* @__PURE__ */ Q("svg", {
|
|
|
4225
4268
|
})
|
|
4226
4269
|
}) })
|
|
4227
4270
|
]
|
|
4228
|
-
}),
|
|
4271
|
+
}), Ga = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Z("div", {
|
|
4229
4272
|
className: G("inline-flex animate-spin items-center justify-center", e),
|
|
4230
4273
|
...n,
|
|
4231
|
-
children: /* @__PURE__ */ Z(
|
|
4232
|
-
}),
|
|
4233
|
-
CodeBlock: () =>
|
|
4234
|
-
CodeBlockCopyButton: () =>
|
|
4235
|
-
Conversation: () =>
|
|
4236
|
-
ConversationContent: () =>
|
|
4237
|
-
ConversationEmptyState: () =>
|
|
4238
|
-
ConversationScrollButton: () =>
|
|
4239
|
-
Loader: () =>
|
|
4240
|
-
Message: () =>
|
|
4241
|
-
MessageAction: () =>
|
|
4242
|
-
MessageActions: () =>
|
|
4243
|
-
MessageAttachment: () =>
|
|
4244
|
-
MessageAttachments: () =>
|
|
4245
|
-
MessageBranch: () =>
|
|
4246
|
-
MessageBranchContent: () =>
|
|
4247
|
-
MessageBranchNext: () =>
|
|
4248
|
-
MessageBranchPage: () =>
|
|
4249
|
-
MessageBranchPrevious: () =>
|
|
4250
|
-
MessageBranchSelector: () =>
|
|
4251
|
-
MessageContent: () =>
|
|
4252
|
-
MessageResponse: () =>
|
|
4253
|
-
MessageToolbar: () =>
|
|
4254
|
-
PromptInput: () =>
|
|
4255
|
-
PromptInputActionAddAttachments: () =>
|
|
4256
|
-
PromptInputActionMenu: () =>
|
|
4257
|
-
PromptInputActionMenuContent: () =>
|
|
4258
|
-
PromptInputActionMenuItem: () =>
|
|
4259
|
-
PromptInputActionMenuTrigger: () =>
|
|
4260
|
-
PromptInputAttachment: () =>
|
|
4261
|
-
PromptInputAttachments: () =>
|
|
4262
|
-
PromptInputBody: () =>
|
|
4263
|
-
PromptInputButton: () =>
|
|
4264
|
-
PromptInputCommand: () =>
|
|
4265
|
-
PromptInputCommandEmpty: () =>
|
|
4266
|
-
PromptInputCommandGroup: () =>
|
|
4267
|
-
PromptInputCommandInput: () =>
|
|
4268
|
-
PromptInputCommandItem: () =>
|
|
4269
|
-
PromptInputCommandList: () =>
|
|
4270
|
-
PromptInputCommandSeparator: () =>
|
|
4271
|
-
PromptInputFooter: () =>
|
|
4272
|
-
PromptInputHeader: () =>
|
|
4273
|
-
PromptInputHoverCard: () =>
|
|
4274
|
-
PromptInputHoverCardContent: () =>
|
|
4275
|
-
PromptInputHoverCardTrigger: () =>
|
|
4276
|
-
PromptInputProvider: () =>
|
|
4277
|
-
PromptInputSelect: () =>
|
|
4278
|
-
PromptInputSelectContent: () =>
|
|
4279
|
-
PromptInputSelectItem: () =>
|
|
4280
|
-
PromptInputSelectTrigger: () =>
|
|
4281
|
-
PromptInputSelectValue: () =>
|
|
4282
|
-
PromptInputSpeechButton: () =>
|
|
4283
|
-
PromptInputSubmit: () =>
|
|
4284
|
-
PromptInputTab: () =>
|
|
4285
|
-
PromptInputTabBody: () =>
|
|
4286
|
-
PromptInputTabItem: () =>
|
|
4287
|
-
PromptInputTabLabel: () =>
|
|
4288
|
-
PromptInputTabsList: () =>
|
|
4289
|
-
PromptInputTextarea: () =>
|
|
4290
|
-
PromptInputTools: () =>
|
|
4291
|
-
Reasoning: () =>
|
|
4292
|
-
ReasoningContent: () =>
|
|
4293
|
-
ReasoningTrigger: () =>
|
|
4294
|
-
Shimmer: () =>
|
|
4295
|
-
Source: () =>
|
|
4296
|
-
Sources: () =>
|
|
4297
|
-
SourcesContent: () =>
|
|
4298
|
-
SourcesTrigger: () =>
|
|
4299
|
-
Suggestion: () =>
|
|
4300
|
-
Suggestions: () =>
|
|
4301
|
-
Tool: () =>
|
|
4302
|
-
ToolContent: () =>
|
|
4303
|
-
ToolHeader: () =>
|
|
4304
|
-
ToolInput: () =>
|
|
4305
|
-
ToolOutput: () =>
|
|
4306
|
-
highlightCode: () =>
|
|
4307
|
-
usePromptInputAttachments: () =>
|
|
4308
|
-
usePromptInputController: () =>
|
|
4309
|
-
useProviderAttachments: () =>
|
|
4310
|
-
useReasoning: () =>
|
|
4311
|
-
}),
|
|
4312
|
-
function
|
|
4274
|
+
children: /* @__PURE__ */ Z(Wa, { size: t })
|
|
4275
|
+
}), Ka = /* @__PURE__ */ Bt({
|
|
4276
|
+
CodeBlock: () => Ii,
|
|
4277
|
+
CodeBlockCopyButton: () => Li,
|
|
4278
|
+
Conversation: () => dr,
|
|
4279
|
+
ConversationContent: () => fr,
|
|
4280
|
+
ConversationEmptyState: () => pr,
|
|
4281
|
+
ConversationScrollButton: () => mr,
|
|
4282
|
+
Loader: () => Ga,
|
|
4283
|
+
Message: () => vr,
|
|
4284
|
+
MessageAction: () => xr,
|
|
4285
|
+
MessageActions: () => br,
|
|
4286
|
+
MessageAttachment: () => jr,
|
|
4287
|
+
MessageAttachments: () => Mr,
|
|
4288
|
+
MessageBranch: () => wr,
|
|
4289
|
+
MessageBranchContent: () => Tr,
|
|
4290
|
+
MessageBranchNext: () => Or,
|
|
4291
|
+
MessageBranchPage: () => kr,
|
|
4292
|
+
MessageBranchPrevious: () => Dr,
|
|
4293
|
+
MessageBranchSelector: () => Er,
|
|
4294
|
+
MessageContent: () => yr,
|
|
4295
|
+
MessageResponse: () => Ar,
|
|
4296
|
+
MessageToolbar: () => Nr,
|
|
4297
|
+
PromptInput: () => Qr,
|
|
4298
|
+
PromptInputActionAddAttachments: () => Zr,
|
|
4299
|
+
PromptInputActionMenu: () => ai,
|
|
4300
|
+
PromptInputActionMenuContent: () => si,
|
|
4301
|
+
PromptInputActionMenuItem: () => ci,
|
|
4302
|
+
PromptInputActionMenuTrigger: () => oi,
|
|
4303
|
+
PromptInputAttachment: () => Yr,
|
|
4304
|
+
PromptInputAttachments: () => Xr,
|
|
4305
|
+
PromptInputBody: () => $r,
|
|
4306
|
+
PromptInputButton: () => ii,
|
|
4307
|
+
PromptInputCommand: () => wi,
|
|
4308
|
+
PromptInputCommandEmpty: () => Di,
|
|
4309
|
+
PromptInputCommandGroup: () => Oi,
|
|
4310
|
+
PromptInputCommandInput: () => Ti,
|
|
4311
|
+
PromptInputCommandItem: () => ki,
|
|
4312
|
+
PromptInputCommandList: () => Ei,
|
|
4313
|
+
PromptInputCommandSeparator: () => Ai,
|
|
4314
|
+
PromptInputFooter: () => ni,
|
|
4315
|
+
PromptInputHeader: () => ti,
|
|
4316
|
+
PromptInputHoverCard: () => gi,
|
|
4317
|
+
PromptInputHoverCardContent: () => vi,
|
|
4318
|
+
PromptInputHoverCardTrigger: () => _i,
|
|
4319
|
+
PromptInputProvider: () => Kr,
|
|
4320
|
+
PromptInputSelect: () => di,
|
|
4321
|
+
PromptInputSelectContent: () => pi,
|
|
4322
|
+
PromptInputSelectItem: () => mi,
|
|
4323
|
+
PromptInputSelectTrigger: () => fi,
|
|
4324
|
+
PromptInputSelectValue: () => hi,
|
|
4325
|
+
PromptInputSpeechButton: () => ui,
|
|
4326
|
+
PromptInputSubmit: () => li,
|
|
4327
|
+
PromptInputTab: () => bi,
|
|
4328
|
+
PromptInputTabBody: () => Si,
|
|
4329
|
+
PromptInputTabItem: () => Ci,
|
|
4330
|
+
PromptInputTabLabel: () => xi,
|
|
4331
|
+
PromptInputTabsList: () => yi,
|
|
4332
|
+
PromptInputTextarea: () => ei,
|
|
4333
|
+
PromptInputTools: () => ri,
|
|
4334
|
+
Reasoning: () => Yi,
|
|
4335
|
+
ReasoningContent: () => Qi,
|
|
4336
|
+
ReasoningTrigger: () => Zi,
|
|
4337
|
+
Shimmer: () => Wi,
|
|
4338
|
+
Source: () => na,
|
|
4339
|
+
Sources: () => $i,
|
|
4340
|
+
SourcesContent: () => ta,
|
|
4341
|
+
SourcesTrigger: () => ea,
|
|
4342
|
+
Suggestion: () => Mi,
|
|
4343
|
+
Suggestions: () => ji,
|
|
4344
|
+
Tool: () => Ri,
|
|
4345
|
+
ToolContent: () => Vi,
|
|
4346
|
+
ToolHeader: () => Bi,
|
|
4347
|
+
ToolInput: () => Hi,
|
|
4348
|
+
ToolOutput: () => Ui,
|
|
4349
|
+
highlightCode: () => Fi,
|
|
4350
|
+
usePromptInputAttachments: () => Jr,
|
|
4351
|
+
usePromptInputController: () => Hr,
|
|
4352
|
+
useProviderAttachments: () => Wr,
|
|
4353
|
+
useReasoning: () => Ki
|
|
4354
|
+
}), qa = "/api/v1/ai";
|
|
4355
|
+
function Ja(e, t, n) {
|
|
4313
4356
|
let r = e.replace(/\/$/, ""), i = new URLSearchParams();
|
|
4314
4357
|
if (n) for (let [e, t] of Object.entries(n)) t != null && t !== "" && i.set(e, String(t));
|
|
4315
4358
|
let a = i.toString();
|
|
4316
4359
|
return `${r}${t}${a ? `?${a}` : ""}`;
|
|
4317
4360
|
}
|
|
4318
|
-
async function
|
|
4361
|
+
async function Ya(e, t, n) {
|
|
4319
4362
|
let r = await fetch(e, {
|
|
4320
4363
|
credentials: "include",
|
|
4321
4364
|
...t,
|
|
@@ -4335,8 +4378,8 @@ async function Ba(e, t, n) {
|
|
|
4335
4378
|
}
|
|
4336
4379
|
return i;
|
|
4337
4380
|
}
|
|
4338
|
-
function
|
|
4339
|
-
let { apiBase: n =
|
|
4381
|
+
function Xa(t = {}) {
|
|
4382
|
+
let { apiBase: n = qa, status: r = "pending", conversationId: i, limit: a, headers: o, pollInterval: s = 5e3, enabled: c = !0 } = t, [l, u] = e.useState([]), [d, f] = e.useState(0), [p, m] = e.useState(!1), [h, g] = e.useState(void 0), _ = e.useRef({
|
|
4340
4383
|
apiBase: n,
|
|
4341
4384
|
status: r,
|
|
4342
4385
|
conversationId: i,
|
|
@@ -4354,7 +4397,7 @@ function Va(t = {}) {
|
|
|
4354
4397
|
let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
|
|
4355
4398
|
m(!0), g(void 0);
|
|
4356
4399
|
try {
|
|
4357
|
-
let a = await
|
|
4400
|
+
let a = await Ya(Ja(e, "/pending-actions", {
|
|
4358
4401
|
status: t && t !== "all" ? t : void 0,
|
|
4359
4402
|
conversationId: n,
|
|
4360
4403
|
limit: r
|
|
@@ -4366,9 +4409,9 @@ function Va(t = {}) {
|
|
|
4366
4409
|
m(!1);
|
|
4367
4410
|
}
|
|
4368
4411
|
}, []), y = e.useCallback(async (e) => {
|
|
4369
|
-
let { apiBase: t, headers: n } = _.current, r =
|
|
4412
|
+
let { apiBase: t, headers: n } = _.current, r = Ja(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
|
|
4370
4413
|
try {
|
|
4371
|
-
return await
|
|
4414
|
+
return await Ya(r, {
|
|
4372
4415
|
method: "POST",
|
|
4373
4416
|
body: "{}"
|
|
4374
4417
|
}, n);
|
|
@@ -4376,9 +4419,9 @@ function Va(t = {}) {
|
|
|
4376
4419
|
v();
|
|
4377
4420
|
}
|
|
4378
4421
|
}, [v]), b = e.useCallback(async (e, t) => {
|
|
4379
|
-
let { apiBase: n, headers: r } = _.current, i =
|
|
4422
|
+
let { apiBase: n, headers: r } = _.current, i = Ja(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
|
|
4380
4423
|
try {
|
|
4381
|
-
return await
|
|
4424
|
+
return await Ya(i, {
|
|
4382
4425
|
method: "POST",
|
|
4383
4426
|
body: JSON.stringify(t ? { reason: t } : {})
|
|
4384
4427
|
}, r);
|
|
@@ -4412,7 +4455,7 @@ function Va(t = {}) {
|
|
|
4412
4455
|
}
|
|
4413
4456
|
//#endregion
|
|
4414
4457
|
//#region src/AiPendingActionsInbox.tsx
|
|
4415
|
-
var
|
|
4458
|
+
var Za = {
|
|
4416
4459
|
pending: {
|
|
4417
4460
|
variant: "secondary",
|
|
4418
4461
|
label: "Pending"
|
|
@@ -4434,8 +4477,8 @@ var Ha = {
|
|
|
4434
4477
|
label: "Rejected"
|
|
4435
4478
|
}
|
|
4436
4479
|
};
|
|
4437
|
-
function
|
|
4438
|
-
let t =
|
|
4480
|
+
function Qa({ status: e }) {
|
|
4481
|
+
let t = Za[e] ?? {
|
|
4439
4482
|
variant: "outline",
|
|
4440
4483
|
label: e
|
|
4441
4484
|
};
|
|
@@ -4444,7 +4487,7 @@ function Ua({ status: e }) {
|
|
|
4444
4487
|
children: t.label
|
|
4445
4488
|
});
|
|
4446
4489
|
}
|
|
4447
|
-
function
|
|
4490
|
+
function $a(e) {
|
|
4448
4491
|
if (!e) return "—";
|
|
4449
4492
|
let t = Date.parse(e);
|
|
4450
4493
|
if (Number.isNaN(t)) return e;
|
|
@@ -4462,7 +4505,7 @@ function Wa(e) {
|
|
|
4462
4505
|
return e;
|
|
4463
4506
|
}
|
|
4464
4507
|
}
|
|
4465
|
-
function
|
|
4508
|
+
function eo(e) {
|
|
4466
4509
|
if (!e) return null;
|
|
4467
4510
|
try {
|
|
4468
4511
|
return JSON.parse(e);
|
|
@@ -4470,7 +4513,7 @@ function Ga(e) {
|
|
|
4470
4513
|
return e;
|
|
4471
4514
|
}
|
|
4472
4515
|
}
|
|
4473
|
-
function
|
|
4516
|
+
function to({ value: e, max: t = 320 }) {
|
|
4474
4517
|
let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
4475
4518
|
return n == null || n === "" ? /* @__PURE__ */ Z("span", {
|
|
4476
4519
|
className: "text-muted-foreground text-xs",
|
|
@@ -4481,20 +4524,20 @@ function Ka({ value: e, max: t = 320 }) {
|
|
|
4481
4524
|
children: n
|
|
4482
4525
|
});
|
|
4483
4526
|
}
|
|
4484
|
-
function
|
|
4527
|
+
function no(e) {
|
|
4485
4528
|
switch (e) {
|
|
4486
4529
|
case "pending": return "pending";
|
|
4487
4530
|
case "all": return "all";
|
|
4488
4531
|
case "decided": return "all";
|
|
4489
4532
|
}
|
|
4490
4533
|
}
|
|
4491
|
-
function
|
|
4492
|
-
let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: ee, approve: P, reject: F } =
|
|
4534
|
+
function ro({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i, variant: a = "card", title: o = "AI Approvals", description: s = "Actions an AI agent proposed that need a human review before execution.", className: c }) {
|
|
4535
|
+
let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: ee, approve: P, reject: F } = Xa({
|
|
4493
4536
|
apiBase: t,
|
|
4494
4537
|
headers: n,
|
|
4495
4538
|
pollInterval: r,
|
|
4496
4539
|
conversationId: i,
|
|
4497
|
-
status:
|
|
4540
|
+
status: no(l)
|
|
4498
4541
|
}), I = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), R = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]), ae = e.useCallback(async (e) => {
|
|
4499
4542
|
E(e), O(null);
|
|
4500
4543
|
try {
|
|
@@ -4643,7 +4686,7 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4643
4686
|
className: "text-sm",
|
|
4644
4687
|
children: e.object_name
|
|
4645
4688
|
}),
|
|
4646
|
-
/* @__PURE__ */ Z(U, { children: /* @__PURE__ */ Z(
|
|
4689
|
+
/* @__PURE__ */ Z(U, { children: /* @__PURE__ */ Z(Qa, { status: e.status }) }),
|
|
4647
4690
|
/* @__PURE__ */ Z(U, {
|
|
4648
4691
|
className: "text-xs text-muted-foreground",
|
|
4649
4692
|
children: /* @__PURE__ */ Q("span", {
|
|
@@ -4651,7 +4694,7 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4651
4694
|
children: [
|
|
4652
4695
|
/* @__PURE__ */ Z(We, { className: "h-3 w-3" }),
|
|
4653
4696
|
" ",
|
|
4654
|
-
|
|
4697
|
+
$a(e.proposed_at)
|
|
4655
4698
|
]
|
|
4656
4699
|
})
|
|
4657
4700
|
}),
|
|
@@ -4740,14 +4783,14 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4740
4783
|
children: "Status"
|
|
4741
4784
|
}), /* @__PURE__ */ Z("div", {
|
|
4742
4785
|
className: "mt-1",
|
|
4743
|
-
children: /* @__PURE__ */ Z(
|
|
4786
|
+
children: /* @__PURE__ */ Z(Qa, { status: R.status })
|
|
4744
4787
|
})] }),
|
|
4745
4788
|
/* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4746
4789
|
className: "text-xs text-muted-foreground",
|
|
4747
4790
|
children: "Proposed"
|
|
4748
4791
|
}), /* @__PURE__ */ Z("div", {
|
|
4749
4792
|
className: "mt-1 text-xs",
|
|
4750
|
-
children:
|
|
4793
|
+
children: $a(R.proposed_at)
|
|
4751
4794
|
})] }),
|
|
4752
4795
|
/* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4753
4796
|
className: "text-xs text-muted-foreground",
|
|
@@ -4781,21 +4824,21 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4781
4824
|
children: "Tool input"
|
|
4782
4825
|
}), /* @__PURE__ */ Z("div", {
|
|
4783
4826
|
className: "mt-1.5",
|
|
4784
|
-
children: /* @__PURE__ */ Z(
|
|
4827
|
+
children: /* @__PURE__ */ Z(to, { value: eo(R.tool_input) })
|
|
4785
4828
|
})] }),
|
|
4786
4829
|
R.result ? /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4787
4830
|
className: "text-xs",
|
|
4788
4831
|
children: "Result"
|
|
4789
4832
|
}), /* @__PURE__ */ Z("div", {
|
|
4790
4833
|
className: "mt-1.5",
|
|
4791
|
-
children: /* @__PURE__ */ Z(
|
|
4834
|
+
children: /* @__PURE__ */ Z(to, { value: eo(R.result) })
|
|
4792
4835
|
})] }) : null,
|
|
4793
4836
|
R.error ? /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4794
4837
|
className: "text-xs text-destructive",
|
|
4795
4838
|
children: "Error"
|
|
4796
4839
|
}), /* @__PURE__ */ Z("div", {
|
|
4797
4840
|
className: "mt-1.5",
|
|
4798
|
-
children: /* @__PURE__ */ Z(
|
|
4841
|
+
children: /* @__PURE__ */ Z(to, { value: R.error })
|
|
4799
4842
|
})] }) : null,
|
|
4800
4843
|
R.rejection_reason ? /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
|
|
4801
4844
|
className: "text-xs",
|
|
@@ -4866,14 +4909,14 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4866
4909
|
}
|
|
4867
4910
|
//#endregion
|
|
4868
4911
|
//#region src/useHitlInChat.ts
|
|
4869
|
-
function
|
|
4912
|
+
function io(e) {
|
|
4870
4913
|
return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
|
|
4871
4914
|
}
|
|
4872
|
-
function
|
|
4915
|
+
function ao(e, t) {
|
|
4873
4916
|
let n = { ...e ?? {} };
|
|
4874
4917
|
return t && (n["Content-Type"] = "application/json"), n;
|
|
4875
4918
|
}
|
|
4876
|
-
async function
|
|
4919
|
+
async function oo(e) {
|
|
4877
4920
|
let t = await e.text();
|
|
4878
4921
|
if (!t) return null;
|
|
4879
4922
|
try {
|
|
@@ -4882,8 +4925,8 @@ async function Za(e) {
|
|
|
4882
4925
|
return { raw: t };
|
|
4883
4926
|
}
|
|
4884
4927
|
}
|
|
4885
|
-
function
|
|
4886
|
-
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s =
|
|
4928
|
+
function so(t) {
|
|
4929
|
+
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = io(r), c = e.useMemo(() => {
|
|
4887
4930
|
let e = /* @__PURE__ */ new Map();
|
|
4888
4931
|
for (let t of n) {
|
|
4889
4932
|
let n = t.toolInvocations ?? [];
|
|
@@ -4926,9 +4969,9 @@ function Qa(t) {
|
|
|
4926
4969
|
let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
|
|
4927
4970
|
method: "POST",
|
|
4928
4971
|
credentials: "include",
|
|
4929
|
-
headers:
|
|
4972
|
+
headers: ao(i, !0),
|
|
4930
4973
|
body: c
|
|
4931
|
-
}), f = await
|
|
4974
|
+
}), f = await oo(d) ?? {};
|
|
4932
4975
|
if (!d.ok) {
|
|
4933
4976
|
let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
|
|
4934
4977
|
m(e, {
|
|
@@ -4961,7 +5004,7 @@ function Qa(t) {
|
|
|
4961
5004
|
message: `Status: ${p}`
|
|
4962
5005
|
}), h = !0;
|
|
4963
5006
|
if (a?.(e, f), h && o) {
|
|
4964
|
-
let r =
|
|
5007
|
+
let r = co({
|
|
4965
5008
|
approved: t,
|
|
4966
5009
|
status: p,
|
|
4967
5010
|
toolName: u,
|
|
@@ -4997,24 +5040,24 @@ function Qa(t) {
|
|
|
4997
5040
|
isDeciding: f
|
|
4998
5041
|
};
|
|
4999
5042
|
}
|
|
5000
|
-
function
|
|
5043
|
+
function co(e) {
|
|
5001
5044
|
let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
|
|
5002
5045
|
if (t && n === "executed") {
|
|
5003
5046
|
let e = a.result;
|
|
5004
|
-
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e :
|
|
5047
|
+
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : lo(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
|
|
5005
5048
|
}
|
|
5006
5049
|
if (!t && n === "rejected") return `${s} The operator rejected the \`${r}\` call.${o && o.trim().length > 0 ? ` Reason: ${o}.` : ""} Acknowledge the rejection and ask whether to try a different approach.`;
|
|
5007
5050
|
if (n === "failed") {
|
|
5008
5051
|
let e = a.error;
|
|
5009
|
-
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e :
|
|
5052
|
+
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : lo(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
|
|
5010
5053
|
}
|
|
5011
5054
|
}
|
|
5012
|
-
function
|
|
5055
|
+
function lo(e, t) {
|
|
5013
5056
|
return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
|
|
5014
5057
|
}
|
|
5015
5058
|
//#endregion
|
|
5016
5059
|
//#region src/index.tsx
|
|
5017
|
-
var
|
|
5060
|
+
var uo = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: l, assistantAvatarFallback: u = "AI", maxHeight: d = "500px", ...f }, p) => {
|
|
5018
5061
|
let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
|
|
5019
5062
|
e.useEffect(() => {
|
|
5020
5063
|
if (g.current) {
|
|
@@ -5040,7 +5083,7 @@ var to = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
5040
5083
|
children: n.length === 0 ? /* @__PURE__ */ Z("div", {
|
|
5041
5084
|
className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
|
|
5042
5085
|
children: "No messages yet. Start a conversation!"
|
|
5043
|
-
}) : n.map((e) => /* @__PURE__ */ Z(
|
|
5086
|
+
}) : n.map((e) => /* @__PURE__ */ Z(fo, {
|
|
5044
5087
|
message: e,
|
|
5045
5088
|
showTimestamp: o,
|
|
5046
5089
|
userAvatarUrl: s,
|
|
@@ -5071,8 +5114,8 @@ var to = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
5071
5114
|
})]
|
|
5072
5115
|
});
|
|
5073
5116
|
});
|
|
5074
|
-
|
|
5075
|
-
var
|
|
5117
|
+
uo.displayName = "Chatbot";
|
|
5118
|
+
var fo = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
|
|
5076
5119
|
let o = e.role === "user";
|
|
5077
5120
|
if (e.role === "system") return /* @__PURE__ */ Z("div", {
|
|
5078
5121
|
className: "flex justify-center",
|
|
@@ -5104,7 +5147,7 @@ var no = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
5104
5147
|
})]
|
|
5105
5148
|
})]
|
|
5106
5149
|
});
|
|
5107
|
-
},
|
|
5150
|
+
}, po = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ Q("div", {
|
|
5108
5151
|
ref: i,
|
|
5109
5152
|
className: G("flex gap-3", e),
|
|
5110
5153
|
...r,
|
|
@@ -5126,6 +5169,6 @@ var no = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
5126
5169
|
})
|
|
5127
5170
|
})]
|
|
5128
5171
|
}));
|
|
5129
|
-
|
|
5172
|
+
po.displayName = "TypingIndicator";
|
|
5130
5173
|
//#endregion
|
|
5131
|
-
export {
|
|
5174
|
+
export { bn as AGENT_ALIAS_GROUPS, Ka as AIElements, pn as AI_USAGE_REFRESH_EVENT, ro as AiPendingActionsInbox, uo as Chatbot, ya as ChatbotEnhanced, Ua as FloatingChatbot, $n as FloatingChatbotPanel, Vn as FloatingChatbotProvider, qn as FloatingChatbotTrigger, kn as PLATFORM_DEFAULT_AGENT, po as TypingIndicator, xn as agentAliasGroup, On as agentHasCapability, Sn as agentRouteName, dn as authoredToRuntimeMessage, Qt as buildProgressFromDraftReview, Jt as detectBuilderHandoff, Xt as detectDraftResult, Yt as detectProposedChanges, qt as detectProposedPlan, mn as emitAiUsageRefresh, tr as humanizeToolName, En as isAskAgent, Tn as isBuildAgent, wn as isBuiltinAgentName, ra as publishHealthFromResponse, Cn as resolveAgentParam, An as resolveDefaultAgentName, rr as summarizeChatError, fn as toRuntimeMessages, cn as toRuntimeRole, sn as toRuntimeTimestamp, un as toRuntimeToolInvocation, ln as toRuntimeToolState, an as uiMessageToChatMessage, on as uiMessagesToChatMessages, nr as unwrapToolResult, Ln as useAgents, zn as useAiModels, Hn as useFloatingChatbot, so as useHitlInChat, yn as useObjectChat, Xa as usePendingActions };
|